From df50b468a807d462b7ea6645bc81a01106ad5d29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <pawel.kedzia@pwr.wroc.pl>
Date: Wed, 11 May 2011 13:56:01 +0200
Subject: [PATCH] (swig) Added wrapper for Wccl::WcclFileOpSections

---
 swig/Makefile                   | 23 +++++++--
 swig/libcclwcclfileopsections.i | 88 +++++++++++++++++++++++++++++++++
 2 files changed, 106 insertions(+), 5 deletions(-)
 create mode 100644 swig/libcclwcclfileopsections.i

diff --git a/swig/Makefile b/swig/Makefile
index 3fdbb67..bd71eca 100644
--- a/swig/Makefile
+++ b/swig/Makefile
@@ -38,6 +38,7 @@ CBIN=libcclvalue.o \
 	libccltagrulesequence.o \
 	libcclmatchrule.o \
 	libcclfunctionalopsequence.o \
+	libcclwcclfileopsections.o \
 	wccl.o
 
 CBINOUT=_libcclvalue.so \
@@ -62,8 +63,9 @@ CBINOUT=_libcclvalue.so \
 				_libccltagrule.so \
 				_libccltagrulesequence.so \
 				_libcclmatchrule.so \
-				_wccl.so \
 				_libcclfunctionalopsequence.so \
+				_libcclwcclfileopsections.so \
+				_wccl.so \
 				_boost_shared_ptr.so
 
 CWRAP=libcclvalue_wrap.cxx \
@@ -88,8 +90,9 @@ CWRAP=libcclvalue_wrap.cxx \
 			libccltagrule_wrap.cxx \
 			libccltagrulesequence_wrap.cxx \
 			libcclmatchrule_wrap.cxx \
-			wccl_wrap.cxx \
 			libcclfunctionalopsequence_wrap.cxx \
+			libcclwcclfileopsections_wrap.cxx \
+			wccl_wrap.cxx \
 			boost_shared_ptr_wrap.cxx
 
 CWRAPBIN=libcclvalue_wrap.o \
@@ -114,8 +117,9 @@ CWRAPBIN=libcclvalue_wrap.o \
 				 libccltagrule_wrap.o \
 				 libccltagrulesequence_wrap.o \
 				 libcclmatchrule_wrap.o \
-				 wccl_wrap.o \
 				 libcclfunctionalopsequence_wrap.o \
+				 libcclwcclfileopsections_wrap.o \
+				 wccl_wrap.o \
 				 boost_shared_ptr_wrap.o
 
 PYMODULES=libcclvalue.py \
@@ -140,8 +144,9 @@ PYMODULES=libcclvalue.py \
 					libccltagrule.py \
 					libccltagrulesequence.py \
 					libcclmatchrule.py \
-					wccl.py \
 					libcclfunctionalopsequence.py \
+					libcclwcclfileopsections.py \
+					wccl.py \
 					boost_shared_ptr.py
 
 PYCBIN=libcclvalue.pyc \
@@ -166,8 +171,9 @@ PYCBIN=libcclvalue.pyc \
 			 libccltagrule.pyc \
 			 libccltagrulesequence.pyc \
 			 libcclmatchrule.pyc \
-			 wccl.pyc \
 			 libcclfunctionalopsequence.pyc \
+			 libcclwcclfileopsections.pyc \
+			 wccl.pyc \
 			 boost_shared_ptr.pyc
 
 all:boost_shared_ptr.o $(CBIN)
@@ -354,6 +360,13 @@ libcclfunctionalopsequence.o:
 	$(CPP) -shared libcclfunctionalopsequence_wrap.o \
 		$(CCLBIN) $(ANTLRLIB) -o _libcclfunctionalopsequence.so
 
+# WcclFileOpSections
+libcclwcclfileopsections.o:
+	$(SWIG) $(SWIGOPTS_LANG) libcclwcclfileopsections.i
+	$(CPP) -c libcclwcclfileopsections_wrap.cxx -I$(PYTHONDIR) -I$(WCCLDIR) $(CPPFLAGS)
+	$(CPP) -shared libcclwcclfileopsections_wrap.o \
+		$(CCLBIN) $(ANTLRLIB) -o _libcclwcclfileopsections.so
+
 # -----------------------------------------------------------------------------
 # Wccl Library
 wccl.o:
diff --git a/swig/libcclwcclfileopsections.i b/swig/libcclwcclfileopsections.i
new file mode 100644
index 0000000..f5ca976
--- /dev/null
+++ b/swig/libcclwcclfileopsections.i
@@ -0,0 +1,88 @@
+#ifndef SWIG_LIBWCCL_WCCLFILEOPSECTIONS_I
+#define SWIG_LIBWCCL_WCCLFILEOPSECTIONS_I
+
+%module libcclwcclfileopsections
+%{
+  #include <libwccl/wcclfileopsections.h>
+%}
+
+%include "libcclbool.i"
+%include "libcclmatch.i"
+%include "libcclposition.i"
+%include "libcclstrset.i"
+%include "libccltset.i"
+%include "libcclvalue.i"
+%include "libcclfunctionalopsequence.i"
+
+%include "std_string.i"
+%include "std_vector.i"
+%include "boost_shared_ptr.i"
+
+namespace Wccl {
+  template<class T> class WcclFileOpSections {
+  public:
+    typedef typename T::op_t op_t;
+    typedef typename boost::shared_ptr<op_t> op_ptr_t;
+    typedef typename boost::shared_ptr<const op_t> op_ptr_c_t;
+    typedef typename boost::shared_ptr<T> ptr_t;
+    typedef typename boost::shared_ptr<const T> ptr_c_t;
+    typedef typename std::vector<ptr_t> ptr_v_t;
+    typedef typename boost::unordered_map<std::string, ptr_t> map_t;
+    typedef typename T::name_op_v_t name_op_v_t;
+    typedef typename T::name_op_v_c_t name_op_v_c_t;
+    /* --------------------------------------------------------------------- */
+
+  protected:  
+    bool has_section(const std::string& name) const;
+    const ptr_v_t& sections();
+    /* --------------------------------------------------------------------- */
+  
+    size_t size() const;
+    bool empty() const;
+    /* --------------------------------------------------------------------- */
+
+    std::vector<std::string> section_names() const;
+    /* --------------------------------------------------------------------- */
+
+    T& get_section(const std::string& name);
+    const T& get_section(const std::string& name) const;
+    /* --------------------------------------------------------------------- */
+
+    ptr_t get_section_ptr(const std::string& name);
+    ptr_c_t get_section_ptr(const std::string& name) const;
+    /* --------------------------------------------------------------------- */
+
+    op_t& get_op(const std::string& name, size_t idx = 0);
+    const op_t& get_op(const std::string& name, size_t idx = 0) const;
+    /* --------------------------------------------------------------------- */
+
+    op_ptr_t get_op_ptr(const std::string& name, size_t idx = 0);
+    op_ptr_c_t get_op_ptr(const std::string& name, size_t idx = 0) const;
+    /* --------------------------------------------------------------------- */
+
+    name_op_v_t& add_name_op_pairs(name_op_v_t& pairs);
+    name_op_v_c_t& add_name_op_pairs(name_op_v_c_t& pairs) const;
+    /* --------------------------------------------------------------------- */
+
+    name_op_v_t gen_name_op_pairs();
+    name_op_v_c_t gen_name_op_pairs() const;
+    /* --------------------------------------------------------------------- */
+  
+    WcclFileOpSections();
+
+    void append(const ptr_t& section);
+    /* --------------------------------------------------------------------- */
+  };
+
+  %template(UntypedOpSequenceWcclFileOpSections) WcclFileOpSections<UntypedOpSequence>;
+  %template(StrSetOpSequence) WcclFileOpSections<OpSequence<StrSet> >;
+  %template(TSetOpSequence) WcclFileOpSections<OpSequence<TSet> >;
+  %template(BoolOpSequence) WcclFileOpSections<OpSequence<Bool> >;
+  %template(PositionOpSequence) WcclFileOpSections<OpSequence<Position> >;
+  %template(MatchOpSequence) WcclFileOpSections<OpSequence<Match> >;
+}
+
+using namespace std;
+using namespace Wccl;
+
+#endif /* SWIG_LIBWCCL_WCCLFILEOPSECTIONS_I */
-- 
GitLab