From 6c76152dd59d5d9c3a0d53adbdb66ccfdd157576 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 16:28:46 +0200 Subject: [PATCH] (swig) Added wrapper for Wccl::Lexicons --- swig/Makefile | 13 ++++++++++++ swig/libccllexicons.i | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 swig/libccllexicons.i diff --git a/swig/Makefile b/swig/Makefile index 63c97ce..2e94c98 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -40,6 +40,7 @@ CBIN=libcclvalue.o \ libcclmatchrulesequence.o \ libcclfunctionalopsequence.o \ libccllexicon.o \ + libccllexicons.o \ libcclwcclfileopsections.o \ libcclwcclfile.o \ wccl.o @@ -69,6 +70,7 @@ CBINOUT=_libcclvalue.so \ _libcclmatchrulesequence.so \ _libcclfunctionalopsequence.so \ _libccllexicon.so \ + _libccllexicons.so \ _libcclwcclfileopsections.so \ _wccl.so \ _boost_shared_ptr.so @@ -98,6 +100,7 @@ CWRAP=libcclvalue_wrap.cxx \ libcclmatchrulesequence_wrap.cxx \ libcclfunctionalopsequence_wrap.cxx \ libccllexicon_wrap.cxx \ + libccllexicons_wrap.cxx \ libcclwcclfileopsections_wrap.cxx \ wccl_wrap.cxx \ boost_shared_ptr_wrap.cxx @@ -127,6 +130,7 @@ CWRAPBIN=libcclvalue_wrap.o \ libcclmatchrulesequence_wrap.o \ libcclfunctionalopsequence_wrap.o \ libccllexicon_wrap.o \ + libccllexicons_wrap.o \ libcclwcclfileopsections_wrap.o \ wccl_wrap.o \ boost_shared_ptr_wrap.o @@ -156,6 +160,7 @@ PYMODULES=libcclvalue.py \ libcclmatchrulesequence.py \ libcclfunctionalopsequence.py \ libccllexicon.py \ + libccllexicons.py \ libcclwcclfileopsections.py \ wccl.py \ boost_shared_ptr.py @@ -185,6 +190,7 @@ PYCBIN=libcclvalue.pyc \ libcclmatchrulesequence.pyc \ libcclfunctionalopsequence.pyc \ libccllexicon.pyc \ + libccllexicons.pyc \ libcclwcclfileopsections.pyc \ wccl.pyc \ boost_shared_ptr.pyc @@ -387,6 +393,13 @@ libccllexicon.o: $(CPP) -shared libccllexicon_wrap.o \ $(CCLBIN) $(ANTLRLIB) -o _libccllexicon.so +# Lexicons +libccllexicons.o: + $(SWIG) $(SWIGOPTS_LANG) libccllexicons.i + $(CPP) -c libccllexicons_wrap.cxx -I$(PYTHONDIR) -I$(WCCLDIR) $(CPPFLAGS) + $(CPP) -shared libccllexicons_wrap.o \ + $(CCLBIN) $(ANTLRLIB) -o _libccllexicons.so + # WcclFileOpSections libcclwcclfileopsections.o: $(SWIG) $(SWIGOPTS_LANG) libcclwcclfileopsections.i diff --git a/swig/libccllexicons.i b/swig/libccllexicons.i new file mode 100644 index 0000000..95727b8 --- /dev/null +++ b/swig/libccllexicons.i @@ -0,0 +1,48 @@ +#ifndef SWIG_LIBWCCL_LEXICONS_I +#define SWIG_LIBWCCL_LEXICONS_I + +%module libccllexicons +%{ + #include <libwccl/lexicon/lexicons.h> +%} + +%include "libccllexicon.i" + +%include "std_string.i" +%include "boost_shared_ptr.i" + +%rename(map_t) boost::unordered_map<std::string, boost::shared_ptr<Lexicon> >; + +namespace Wccl { + class Lexicons { + public: + typedef boost::unordered_map<std::string, boost::shared_ptr<Lexicon> > map_t; + + /* --------------------------------------------------------------------- */ + + Lexicons(); + + /* --------------------------------------------------------------------- */ + + bool has_lexicon(const std::string& name) const; + + /* --------------------------------------------------------------------- */ + + const Lexicon& get(const std::string& name) const; + boost::shared_ptr<const Lexicon> get_ptr(const std::string& name) const; + + /* --------------------------------------------------------------------- */ + + void insert(const boost::shared_ptr<Lexicon>& lexicon); + + /* --------------------------------------------------------------------- */ + + const map_t& get_lexicons() const; + }; +} + +using namespace boost; +using namespace Wccl; +using namespace std; + +#endif /* SWIG_LIBWCCL_LEXICONS_I */ -- GitLab