From 1fd833995cf1904f41c5d3a2bd86f98f1b407e60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl>
Date: Fri, 6 May 2011 10:22:56 +0200
Subject: [PATCH] Wrapper for PwrNlp::PwrNlpError

---
 swig/Makefile         | 26 ++++++++++++++++++++------
 swig/libpwrnlperror.i | 29 +++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 6 deletions(-)
 create mode 100644 swig/libpwrnlperror.i

diff --git a/swig/Makefile b/swig/Makefile
index 8ca3262..bb9c5c5 100644
--- a/swig/Makefile
+++ b/swig/Makefile
@@ -13,7 +13,8 @@ ANTLRLIB=/usr/lib/libantlr-pic.a
 
 CPPFLAGS=-fPIC -O2
 
-CBIN=libcorpustag.o \
+CBIN=libpwrnlperror.o \
+		 libcorpustag.o \
 		 libcorpustagset.o \
 		 libcorpustagsetmanager.o \
 		 libcorpuslexeme.o \
@@ -27,7 +28,8 @@ CBIN=libcorpustag.o \
 		 libcorpusannotatedsentence.o \
 		 libcorpusannotationview.o
 
-CBINOUT=_boost_shared_ptr.so \
+CBINOUT=_libpwrnlperror.so \
+				_boost_shared_ptr.so \
 				_libcorpustag.so \
 				_libcorpustagset.so \
 				_libcorpustagsetmanager.so \
@@ -42,7 +44,8 @@ CBINOUT=_boost_shared_ptr.so \
 				_libcorpusannotatedsentence.so \
 				_libcorpusannotationview.so
 
-CWRAP=boost_shared_ptr_wrap.cxx \
+CWRAP=libpwrnlperror_wrap.cxx \
+			boost_shared_ptr_wrap.cxx \
 			libcorpustag_wrap.cxx \
 			libcorpustagset_wrap.cxx \
 			libcorpustagsetmanager_wrap.cxx \
@@ -57,7 +60,8 @@ CWRAP=boost_shared_ptr_wrap.cxx \
 			libcorpusannotatedsentence_wrap.cxx \
 			libcorpusannotationview_wrap.cxx
 
-CWRAPBIN=boost_shared_ptr_wrap.o \
+CWRAPBIN=libpwrnlperror_wrap.o \
+				 boost_shared_ptr_wrap.o \
 				 libcorpustag_wrap.o \
 				 libcorpustagset_wrap.o \
 				 libcorpustagsetmanager_wrap.o \
@@ -72,7 +76,8 @@ CWRAPBIN=boost_shared_ptr_wrap.o \
 				 libcorpusannotatedsentence_wrap.o \
 				 libcorpusannotationview_wrap.o
 
-PYMODULES=boost_shared_ptr.py \
+PYMODULES=libpwrnlperror.py \
+					boost_shared_ptr.py \
 					libcorpustag.py \
 					libcorpustagset.py \
 					libcorpustagsetmanager.py \
@@ -87,7 +92,8 @@ PYMODULES=boost_shared_ptr.py \
 					libcorpusannotatedsentence.py \
 					libcorpusannotationview.py
 
-PYCBIN=boost_shared_ptr.pyc \
+PYCBIN=libpwrnlperror.pyc \
+			 boost_shared_ptr.pyc \
 			 libcorpustag.pyc \
 			 libcorpustagset.pyc \
 			 libcorpustagsetmanager.pyc \
@@ -116,6 +122,14 @@ boost_shared_ptr.o:
 	$(CPP) -c boost_shared_ptr_wrap.cxx -I$(PYTHONDIR) $(CPPFLAGS)
 	$(CPP) -shared boost_shared_ptr_wrap.o -o _boost_shared_ptr.so
 
+# -----------------------------------------------------------------------------
+#  PwrNlpError wprapper
+# -----------------------------------------------------------------------------
+# PwrNlpError
+libpwrnlperror.o:
+	$(SWIG) $(SWIGOPTS_LANG) libpwrnlperror.i
+	$(CPP) -c libpwrnlperror_wrap.cxx -I$(PYTHONDIR) $(CPPFLAGS)
+	$(CPP) -shared libpwrnlperror_wrap.o -o _libpwrnlperror.so
 
 # -----------------------------------------------------------------------------
 #  Corpus2 Wrappers
diff --git a/swig/libpwrnlperror.i b/swig/libpwrnlperror.i
new file mode 100644
index 0000000..9a40158
--- /dev/null
+++ b/swig/libpwrnlperror.i
@@ -0,0 +1,29 @@
+#ifndef SWIG_LIBPWRNLP_PWRNLPERROR_I
+#define SWIG_LIBPWRNLP_PWRNLPERROR_I
+
+%module libpwrnlperror
+%{
+  #include <libpwrutils/exception.h>
+%} 
+
+%include "std_except.i"
+
+%nodefaultctor PwrNlp::PwrNlpError;
+
+namespace PwrNlp {
+  class PwrNlpError : public std::runtime_error {
+  public:
+    PwrNlpError(const std::string &what);
+
+    /* --------------------------------------------------------------------- */
+    ~PwrNlpError() throw();
+
+    virtual std::string info() const;
+    virtual std::string scope() const;
+  };
+}
+
+using namespace std;
+using namespace PwrNlp;
+
+#endif /* SWIG_LIBPWRNLP_PWRNLPERROR_I */
-- 
GitLab