Skip to content
Snippets Groups Projects
Commit 2de71d7b authored by Paweł Kędzia's avatar Paweł Kędzia
Browse files

Wrapper for Corpus2::Tag

parent b9a600cc
No related merge requests found
CPP=g++
SWIG=swig
SWIGOPTS_LANG=-c++ -python
PYTHONDIR=/usr/include/python2.6
WCCLDIR=/usr/local/include/libwccl/
CORPUS2DIR=/usr/local/include/libcorpus2/
PWRUTILDIR=
CORPUS2BIN=/usr/local/lib/libcorpus2.so
PWRUTILBIN=/usr/local/lib/libpwrutils.so
ANTLRLIB=/usr/lib/libantlr-pic.a
CPPFLAGS=-fPIC -O2
CBIN=libcorpustag.o
CBINOUT=_boost_shared_ptr.so \
_libcorpustag.so
CWRAP=boost_shared_ptr_wrap.cxx \
libcorpustag_wrap.cxx
CWRAPBIN=boost_shared_ptr_wrap.o \
libcorpustag_wrap.o
PYMODULES=boost_shared_ptr.py \
libcorpustag.py
PYCBIN=boost_shared_ptr.pyc \
libcorpustag.pyc
# -----------------------------------------------------------------------------
all:boost_shared_ptr.o $(CBIN)
# Done
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# boost::shared_ptr wrappers
# -----------------------------------------------------------------------------
# shared_ptr
boost_shared_ptr.o:
$(SWIG) $(SWIGOPTS_LANG) boost_shared_ptr.i
$(CPP) -c boost_shared_ptr_wrap.cxx -I$(PYTHONDIR) $(CPPFLAGS)
$(CPP) -shared boost_shared_ptr_wrap.o -o _boost_shared_ptr.so
# -----------------------------------------------------------------------------
# Corpus2 Wrappers
# -----------------------------------------------------------------------------
# Tag
libcorpustag.o:
$(SWIG) $(SWIGOPTS_LANG) libcorpustag.i
$(CPP) -c libcorpustag_wrap.cxx -I$(PYTHONDIR) $(CPPFLAGS)
$(CPP) -shared libcorpustag_wrap.o \
$(PWRUTILBIN) $(CORPUS2BIN) -o _libcorpustag.so
# -----------------------------------------------------------------------------
clean:
rm -f $(CBIN) $(CBINOUT) $(CWRAP) $(CWRAPBIN) $(PYMODULES) $(PYCBIN)
/**
* Wrapper for boost shared_ptr
*/
#ifndef SWIG_BOOST_SHAREDPTR
#define SWIG_BOOST_SHAREDPTR
%module boost_shared_ptr
%{
%}
namespace boost {
template<class T> class shared_ptr {
public:
shared_ptr();
shared_ptr(T * p);
T* operator->();
private:
T * px;
int pn;
};
}
using namespace boost;
#endif /* SWIG_BOOST_SHAREDPTR */
#ifndef SWIG_LIBCORPUS2_TAG_I
#define SWIG_LIBCORPUS2_TAG_I
%module libcorpustag
%{
#include <libcorpus2/tag.h>
#include <boost/cstdint.hpp>
%}
%include "std_string.i"
%include "std_vector.i"
/* Typedefs */
%inline %{
typedef std::bitset<64> mask_t;
%}
%feature("notabstract") Corpus2::Tag;
%rename(__op_eq__) Corpus2::Tag::operator==(const Tag& other) const;
%rename(__op_lw__) Corpus2::Tag::operator<(const Tag& other) const;
namespace Corpus2 {
class Tag {
public:
Tag();
explicit Tag(mask_t pos);
Tag(mask_t pos, mask_t values);
/* --------------------------------------------------------------------- */
~Tag();
/* --------------------------------------------------------------------- */
bool is_null() const;
int pos_count() const;
int get_pos_index() const;
mask_t get_values() const;
mask_t get_pos() const;
Tag& combine_with(const Tag& other);
Tag get_combined(const Tag& other) const;
Tag& mask_with(const Tag& other);
Tag get_masked(const Tag& other);
std::string raw_dump() const;
bool operator<(const Tag& other) const;
bool operator==(const Tag& other) const;
};
size_t hash_value(const Tag &tag);
}
using namespace std;
using namespace Corpus2;
#endif /* SWIG_LIBCORPUS2_TAG_I */
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment