Checkin swig binaries for win, linux and Mac
Swig needs to be checked in because windows and linux don't come with swig by default. Mac does, but I've included Mac binaries nevertheless for
version consistency.
Not enabled, so nothing should break yet.
BUG=32285
TEST=None
Review URL: http://codereview.chromium.org/553095
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/swig/Lib@37274 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/allkw.swg b/allkw.swg
new file mode 100644
index 0000000..fb76ff2
--- /dev/null
+++ b/allkw.swg
@@ -0,0 +1,31 @@
+#ifndef __Lib_allkw_swg__
+#define __Lib_allkw_swg__
+
+
+/*
+ Include all the known keyword warnings. Very useful for adding test
+ files to the test-suite, or check if your own library is ok for all
+ the swig supported languages.
+
+ Use as
+
+ swig -Wallkw ...
+
+ If you add a new language, remember to create a separete languagekw.swg
+ file, and add it here.
+
+*/
+
+%include <chicken/chickenkw.swg>
+%include <csharp/csharpkw.swg>
+%include <java/javakw.swg>
+%include <php/phpkw.swg>
+%include <pike/pikekw.swg>
+%include <python/pythonkw.swg>
+%include <ocaml/ocamlkw.swg>
+%include <ruby/rubykw.swg>
+%include <tcl/tclkw.swg>
+%include <perl5/perlkw.swg>
+
+
+#endif //__Lib_allkw_swg__
diff --git a/attribute.i b/attribute.i
new file mode 100644
index 0000000..45c3c5b
--- /dev/null
+++ b/attribute.i
@@ -0,0 +1,24 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * attribute.i
+ *
+ * SWIG library file for implementing attributes.
+ * ----------------------------------------------------------------------------- */
+
+/* we use a simple exception warning here */
+%{
+#include <stdio.h>
+%}
+#define %attribute_exception(code,msg) printf("%s\n",msg)
+
+#ifndef %arg
+#define %arg(x) x
+#endif
+
+#ifndef %mangle
+#define %mangle(Type...) #@Type
+#endif
+
+%include <typemaps/attribute.swg>
diff --git a/carrays.i b/carrays.i
new file mode 100644
index 0000000..738b457
--- /dev/null
+++ b/carrays.i
@@ -0,0 +1,120 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * carrays.i
+ *
+ * SWIG library file containing macros that can be used to manipulate simple
+ * pointers as arrays.
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * %array_functions(TYPE,NAME)
+ *
+ * Generates functions for creating and accessing elements of a C array
+ * (as pointers). Creates the following functions:
+ *
+ * TYPE *new_NAME(int nelements)
+ * void delete_NAME(TYPE *);
+ * TYPE NAME_getitem(TYPE *, int index);
+ * void NAME_setitem(TYPE *, int index, TYPE value);
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define %array_functions(TYPE,NAME)
+%{
+static TYPE *new_##NAME(int nelements) { %}
+#ifdef __cplusplus
+%{ return new TYPE[nelements]; %}
+#else
+%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
+#endif
+%{}
+
+static void delete_##NAME(TYPE *ary) { %}
+#ifdef __cplusplus
+%{ delete [] ary; %}
+#else
+%{ free(ary); %}
+#endif
+%{}
+
+static TYPE NAME##_getitem(TYPE *ary, int index) {
+ return ary[index];
+}
+static void NAME##_setitem(TYPE *ary, int index, TYPE value) {
+ ary[index] = value;
+}
+%}
+
+TYPE *new_##NAME(int nelements);
+void delete_##NAME(TYPE *ary);
+TYPE NAME##_getitem(TYPE *ary, int index);
+void NAME##_setitem(TYPE *ary, int index, TYPE value);
+
+%enddef
+
+
+/* -----------------------------------------------------------------------------
+ * %array_class(TYPE,NAME)
+ *
+ * Generates a class wrapper around a C array. The class has the following
+ * interface:
+ *
+ * struct NAME {
+ * NAME(int nelements);
+ * ~NAME();
+ * TYPE getitem(int index);
+ * void setitem(int index, TYPE value);
+ * TYPE * cast();
+ * static NAME *frompointer(TYPE *t);
+ * }
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define %array_class(TYPE,NAME)
+%{
+typedef TYPE NAME;
+%}
+typedef struct NAME {
+ /* Put language specific enhancements here */
+
+} NAME;
+
+%extend NAME {
+
+#ifdef __cplusplus
+NAME(int nelements) {
+ return new TYPE[nelements];
+}
+~NAME() {
+ delete [] self;
+}
+#else
+NAME(int nelements) {
+ return (TYPE *) calloc(nelements,sizeof(TYPE));
+}
+~NAME() {
+ free(self);
+}
+#endif
+
+TYPE getitem(int index) {
+ return self[index];
+}
+void setitem(int index, TYPE value) {
+ self[index] = value;
+}
+TYPE * cast() {
+ return self;
+}
+static NAME *frompointer(TYPE *t) {
+ return (NAME *) t;
+}
+
+};
+
+%types(NAME = TYPE);
+
+%enddef
+
diff --git a/cdata.i b/cdata.i
new file mode 100644
index 0000000..67601f7
--- /dev/null
+++ b/cdata.i
@@ -0,0 +1,83 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * cdata.i
+ *
+ * SWIG library file containing macros for manipulating raw C data as strings.
+ * ----------------------------------------------------------------------------- */
+
+%{
+typedef struct SWIGCDATA {
+ char *data;
+ int len;
+} SWIGCDATA;
+%}
+
+/* -----------------------------------------------------------------------------
+ * Typemaps for returning binary data
+ * ----------------------------------------------------------------------------- */
+
+#if SWIGGUILE
+%typemap(out) SWIGCDATA {
+ $result = gh_str2scm($1.data,$1.len);
+}
+%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
+#elif SWIGCHICKEN
+%typemap(out) SWIGCDATA {
+ C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len));
+ $result = C_string(&string_space, $1.len, $1.data);
+}
+%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
+#elif SWIGPHP
+%typemap(out) SWIGCDATA {
+ ZVAL_STRINGL($result, $1.data, $1.len, 1);
+}
+%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
+#else
+%echo "cdata.i module not supported."
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * %cdata(TYPE [, NAME])
+ *
+ * Convert raw C data to a binary string.
+ * ----------------------------------------------------------------------------- */
+
+%define %cdata(TYPE,NAME...)
+
+%insert("header") {
+#if #NAME == ""
+static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) {
+#else
+static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) {
+#endif
+ SWIGCDATA d;
+ d.data = (char *) ptr;
+#if #TYPE != "void"
+ d.len = nelements*sizeof(TYPE);
+#else
+ d.len = nelements;
+#endif
+ return d;
+}
+}
+
+%typemap(default) int nelements "$1 = 1;"
+
+#if #NAME == ""
+SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements);
+#else
+SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements);
+#endif
+%enddef
+
+%typemap(default) int nelements;
+
+%rename(cdata) ::cdata_void(void *ptr, int nelements);
+
+%cdata(void);
+
+/* Memory move function */
+void memmove(void *data, const void *indata, int inlen);
diff --git a/cmalloc.i b/cmalloc.i
new file mode 100644
index 0000000..03a6135
--- /dev/null
+++ b/cmalloc.i
@@ -0,0 +1,113 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * cmalloc.i
+ *
+ * SWIG library file containing macros that can be used to create objects using
+ * the C malloc function.
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <stdlib.h>
+%}
+
+/* %malloc(TYPE [, NAME = TYPE])
+ %calloc(TYPE [, NAME = TYPE])
+ %realloc(TYPE [, NAME = TYPE])
+ %free(TYPE [, NAME = TYPE])
+ %allocators(TYPE [,NAME = TYPE])
+
+ Creates functions for allocating/reallocating memory.
+
+ TYPE *malloc_NAME(int nbytes = sizeof(TYPE);
+ TYPE *calloc_NAME(int nobj=1, int size=sizeof(TYPE));
+ TYPE *realloc_NAME(TYPE *ptr, int nbytes);
+ void free_NAME(TYPE *ptr);
+
+*/
+
+%define %malloc(TYPE,NAME...)
+#if #NAME != ""
+%rename(malloc_##NAME) ::malloc(int nbytes);
+#else
+%rename(malloc_##TYPE) ::malloc(int nbytes);
+#endif
+
+#if #TYPE != "void"
+%typemap(default) int nbytes "$1 = (int) sizeof(TYPE);"
+#endif
+TYPE *malloc(int nbytes);
+%typemap(default) int nbytes;
+%enddef
+
+%define %calloc(TYPE,NAME...)
+#if #NAME != ""
+%rename(calloc_##NAME) ::calloc(int nobj, int sz);
+#else
+%rename(calloc_##TYPE) ::calloc(int nobj, int sz);
+#endif
+#if #TYPE != "void"
+%typemap(default) int sz "$1 = (int) sizeof(TYPE);"
+#else
+%typemap(default) int sz "$1 = 1;"
+#endif
+%typemap(default) int nobj "$1 = 1;"
+TYPE *calloc(int nobj, int sz);
+%typemap(default) int sz;
+%typemap(default) int nobj;
+%enddef
+
+%define %realloc(TYPE,NAME...)
+%insert("header") {
+#if #NAME != ""
+TYPE *realloc_##NAME(TYPE *ptr, int nitems)
+#else
+TYPE *realloc_##TYPE(TYPE *ptr, int nitems)
+#endif
+{
+#if #TYPE != "void"
+return (TYPE *) realloc(ptr, nitems*sizeof(TYPE));
+#else
+return (TYPE *) realloc(ptr, nitems);
+#endif
+}
+}
+#if #NAME != ""
+TYPE *realloc_##NAME(TYPE *ptr, int nitems);
+#else
+TYPE *realloc_##TYPE(TYPE *ptr, int nitems);
+#endif
+%enddef
+
+%define %free(TYPE,NAME...)
+#if #NAME != ""
+%rename(free_##NAME) ::free(TYPE *ptr);
+#else
+%rename(free_##TYPE) ::free(TYPE *ptr);
+#endif
+void free(TYPE *ptr);
+%enddef
+
+%define %sizeof(TYPE,NAME...)
+#if #NAME != ""
+%constant int sizeof_##NAME = sizeof(TYPE);
+#else
+%constant int sizeof_##TYPE = sizeof(TYPE);
+#endif
+%enddef
+
+%define %allocators(TYPE,NAME...)
+%malloc(TYPE,NAME)
+%calloc(TYPE,NAME)
+%realloc(TYPE,NAME)
+%free(TYPE,NAME)
+#if #TYPE != "void"
+%sizeof(TYPE,NAME)
+#endif
+%enddef
+
+
+
+
+
diff --git a/constraints.i b/constraints.i
new file mode 100644
index 0000000..2deb116
--- /dev/null
+++ b/constraints.i
@@ -0,0 +1,227 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * constraints.i
+ *
+ * SWIG constraints library.
+ *
+ * SWIG library file containing typemaps for implementing various kinds of
+ * constraints. Depends upon the SWIG exception library for generating
+ * errors in a language-independent manner.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef AUTODOC
+%text %{
+%include <constraints.i>
+
+This library provides support for applying constraints to function
+arguments. Using a constraint, you can restrict arguments to be
+positive numbers, non-NULL pointers, and so on. The following
+constraints are available :
+
+ Number POSITIVE - Positive number (not zero)
+ Number NEGATIVE - Negative number (not zero)
+ Number NONZERO - Nonzero number
+ Number NONNEGATIVE - Positive number (including zero)
+ Number NONPOSITIVE - Negative number (including zero)
+ Pointer NONNULL - Non-NULL pointer
+ Pointer ALIGN8 - 8-byte aligned pointer
+ Pointer ALIGN4 - 4-byte aligned pointer
+ Pointer ALIGN2 - 2-byte aligned pointer
+
+To use the constraints, you need to "apply" them to specific
+function arguments in your code. This is done using the %apply
+directive. For example :
+
+ %apply Number NONNEGATIVE { double nonneg };
+ double sqrt(double nonneg); // Name of argument must match
+
+ %apply Pointer NONNULL { void *ptr };
+ void *malloc(int POSITIVE); // May return a NULL pointer
+ void free(void *ptr); // May not accept a NULL pointer
+
+Any function argument of the type you specify with the %apply directive
+will be checked with the appropriate constraint. Multiple types may
+be specified as follows :
+
+ %apply Pointer NONNULL { void *, Vector *, List *, double *};
+
+In this case, all of the types listed would be checked for non-NULL
+pointers.
+
+The common datatypes of int, short, long, unsigned int, unsigned long,
+unsigned short, unsigned char, signed char, float, and double can be
+checked without using the %apply directive by simply using the
+constraint name as the parameter name. For example :
+
+ double sqrt(double NONNEGATIVE);
+ double log(double POSITIVE);
+
+If you have used typedef to change type-names, you can also do this :
+
+ %apply double { Real }; // Make everything defined for doubles
+ // work for Reals.
+ Real sqrt(Real NONNEGATIVE);
+ Real log(Real POSITIVE);
+
+%}
+#endif
+
+%include <exception.i>
+
+#ifdef SWIGCSHARP
+// Required attribute for C# exception handling
+#define SWIGCSHARPCANTHROW , canthrow=1
+#else
+#define SWIGCSHARPCANTHROW
+#endif
+
+
+// Positive numbers
+
+%typemap(check SWIGCSHARPCANTHROW)
+ int POSITIVE,
+ short POSITIVE,
+ long POSITIVE,
+ unsigned int POSITIVE,
+ unsigned short POSITIVE,
+ unsigned long POSITIVE,
+ signed char POSITIVE,
+ unsigned char POSITIVE,
+ float POSITIVE,
+ double POSITIVE,
+ Number POSITIVE
+{
+ if ($1 <= 0) {
+ SWIG_exception(SWIG_ValueError,"Expected a positive value.");
+ }
+}
+
+// Negative numbers
+
+%typemap(check SWIGCSHARPCANTHROW)
+ int NEGATIVE,
+ short NEGATIVE,
+ long NEGATIVE,
+ unsigned int NEGATIVE,
+ unsigned short NEGATIVE,
+ unsigned long NEGATIVE,
+ signed char NEGATIVE,
+ unsigned char NEGATIVE,
+ float NEGATIVE,
+ double NEGATIVE,
+ Number NEGATIVE
+{
+ if ($1 >= 0) {
+ SWIG_exception(SWIG_ValueError,"Expected a negative value.");
+ }
+}
+
+// Nonzero numbers
+
+%typemap(check SWIGCSHARPCANTHROW)
+ int NONZERO,
+ short NONZERO,
+ long NONZERO,
+ unsigned int NONZERO,
+ unsigned short NONZERO,
+ unsigned long NONZERO,
+ signed char NONZERO,
+ unsigned char NONZERO,
+ float NONZERO,
+ double NONZERO,
+ Number NONZERO
+{
+ if ($1 == 0) {
+ SWIG_exception(SWIG_ValueError,"Expected a nonzero value.");
+ }
+}
+
+// Nonnegative numbers
+
+%typemap(check SWIGCSHARPCANTHROW)
+ int NONNEGATIVE,
+ short NONNEGATIVE,
+ long NONNEGATIVE,
+ unsigned int NONNEGATIVE,
+ unsigned short NONNEGATIVE,
+ unsigned long NONNEGATIVE,
+ signed char NONNEGATIVE,
+ unsigned char NONNEGATIVE,
+ float NONNEGATIVE,
+ double NONNEGATIVE,
+ Number NONNEGATIVE
+{
+ if ($1 < 0) {
+ SWIG_exception(SWIG_ValueError,"Expected a non-negative value.");
+ }
+}
+
+// Nonpositive numbers
+
+%typemap(check SWIGCSHARPCANTHROW)
+ int NONPOSITIVE,
+ short NONPOSITIVE,
+ long NONPOSITIVE,
+ unsigned int NONPOSITIVE,
+ unsigned short NONPOSITIVE,
+ unsigned long NONPOSITIVE,
+ signed char NONPOSITIVE,
+ unsigned char NONPOSITIVE,
+ float NONPOSITIVE,
+ double NONPOSITIVE,
+ Number NONPOSITIVE
+{
+ if ($1 > 0) {
+ SWIG_exception(SWIG_ValueError,"Expected a non-positive value.");
+ }
+}
+
+// Non-NULL pointer
+
+%typemap(check SWIGCSHARPCANTHROW)
+ void * NONNULL,
+ Pointer NONNULL
+{
+ if (!$1) {
+ SWIG_exception(SWIG_ValueError,"Received a NULL pointer.");
+ }
+}
+
+// Aligned pointers
+
+%typemap(check SWIGCSHARPCANTHROW)
+ void * ALIGN8,
+ Pointer ALIGN8
+{
+ unsigned long long tmp;
+ tmp = (unsigned long long) $1;
+ if (tmp & 7) {
+ SWIG_exception(SWIG_ValueError,"Pointer must be 8-byte aligned.");
+ }
+}
+
+%typemap(check SWIGCSHARPCANTHROW)
+ void * ALIGN4,
+ Pointer ALIGN4
+{
+ unsigned long long tmp;
+ tmp = (unsigned long long) $1;
+ if (tmp & 3) {
+ SWIG_exception(SWIG_ValueError,"Pointer must be 4-byte aligned.");
+ }
+}
+
+%typemap(check SWIGCSHARPCANTHROW)
+ void * ALIGN2,
+ Pointer ALIGN2
+{
+ unsigned long long tmp;
+ tmp = (unsigned long long) $1;
+ if (tmp & 1) {
+ SWIG_exception(SWIG_ValueError,"Pointer must be 2-byte aligned.");
+ }
+}
+
+
diff --git a/cpointer.i b/cpointer.i
new file mode 100644
index 0000000..1a6e517
--- /dev/null
+++ b/cpointer.i
@@ -0,0 +1,183 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * cpointer.i
+ *
+ * SWIG library file containing macros that can be used to manipulate simple
+ * pointer objects.
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * %pointer_class(type,name)
+ *
+ * Places a simple proxy around a simple type like 'int', 'float', or whatever.
+ * The proxy provides this interface:
+ *
+ * class type {
+ * public:
+ * type();
+ * ~type();
+ * type value();
+ * void assign(type value);
+ * };
+ *
+ * Example:
+ *
+ * %pointer_class(int, intp);
+ *
+ * int add(int *x, int *y) { return *x + *y; }
+ *
+ * In python (with proxies)
+ *
+ * >>> a = intp()
+ * >>> a.assign(10)
+ * >>> a.value()
+ * 10
+ * >>> b = intp()
+ * >>> b.assign(20)
+ * >>> print add(a,b)
+ * 30
+ *
+ * As a general rule, this macro should not be used on class/structures that
+ * are already defined in the interface.
+ * ----------------------------------------------------------------------------- */
+
+
+%define %pointer_class(TYPE, NAME)
+%{
+typedef TYPE NAME;
+%}
+
+typedef struct {
+} NAME;
+
+%extend NAME {
+#ifdef __cplusplus
+NAME() {
+ return new TYPE();
+}
+~NAME() {
+ if (self) delete self;
+}
+#else
+NAME() {
+ return (TYPE *) calloc(1,sizeof(TYPE));
+}
+~NAME() {
+ if (self) free(self);
+}
+#endif
+}
+
+%extend NAME {
+
+void assign(TYPE value) {
+ *self = value;
+}
+TYPE value() {
+ return *self;
+}
+TYPE * cast() {
+ return self;
+}
+static NAME * frompointer(TYPE *t) {
+ return (NAME *) t;
+}
+
+}
+
+%types(NAME = TYPE);
+
+%enddef
+
+/* -----------------------------------------------------------------------------
+ * %pointer_functions(type,name)
+ *
+ * Create functions for allocating/deallocating pointers. This can be used
+ * if you don't want to create a proxy class or if the pointer is complex.
+ *
+ * %pointer_functions(int, intp)
+ *
+ * int add(int *x, int *y) { return *x + *y; }
+ *
+ * In python (with proxies)
+ *
+ * >>> a = copy_intp(10)
+ * >>> intp_value(a)
+ * 10
+ * >>> b = new_intp()
+ * >>> intp_assign(b,20)
+ * >>> print add(a,b)
+ * 30
+ * >>> delete_intp(a)
+ * >>> delete_intp(b)
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define %pointer_functions(TYPE,NAME)
+%{
+static TYPE *new_##NAME() { %}
+#ifdef __cplusplus
+%{ return new TYPE(); %}
+#else
+%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
+#endif
+%{}
+
+static TYPE *copy_##NAME(TYPE value) { %}
+#ifdef __cplusplus
+%{ return new TYPE(value); %}
+#else
+%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
+ *self = value;
+ return self; %}
+#endif
+%{}
+
+static void delete_##NAME(TYPE *self) { %}
+#ifdef __cplusplus
+%{ if (self) delete self; %}
+#else
+%{ if (self) free(self); %}
+#endif
+%{}
+
+static void NAME ##_assign(TYPE *self, TYPE value) {
+ *self = value;
+}
+
+static TYPE NAME ##_value(TYPE *self) {
+ return *self;
+}
+%}
+
+TYPE *new_##NAME();
+TYPE *copy_##NAME(TYPE value);
+void delete_##NAME(TYPE *self);
+void NAME##_assign(TYPE *self, TYPE value);
+TYPE NAME##_value(TYPE *self);
+
+%enddef
+
+/* -----------------------------------------------------------------------------
+ * %pointer_cast(type1,type2,name)
+ *
+ * Generates a pointer casting function.
+ * ----------------------------------------------------------------------------- */
+
+%define %pointer_cast(TYPE1,TYPE2,NAME)
+%inline %{
+TYPE2 NAME(TYPE1 x) {
+ return (TYPE2) x;
+}
+%}
+%enddef
+
+
+
+
+
+
+
+
diff --git a/cstring.i b/cstring.i
new file mode 100644
index 0000000..4ebdf68
--- /dev/null
+++ b/cstring.i
@@ -0,0 +1,15 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * cstring.i
+ * ----------------------------------------------------------------------------- */
+
+%echo "cstring.i not implemented for this target"
+#define SWIG_CSTRING_UNIMPL
+
+/* old name keep for compatibility */
+#define _CSTRING_UNIMPL
+
+
+
diff --git a/cwstring.i b/cwstring.i
new file mode 100644
index 0000000..a6b08ae
--- /dev/null
+++ b/cwstring.i
@@ -0,0 +1,14 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * cwstring.i
+ * ----------------------------------------------------------------------------- */
+
+%echo "cwstring.i not implemented for this target"
+#define SWIG_CWSTRING_UNIMPL
+
+
+
+
+
diff --git a/exception.i b/exception.i
new file mode 100644
index 0000000..a1a4755
--- /dev/null
+++ b/exception.i
@@ -0,0 +1,277 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * exception.i
+ *
+ * SWIG library file providing language independent exception handling
+ * ----------------------------------------------------------------------------- */
+
+#if defined(SWIGUTL)
+#error "This version of exception.i should not be used"
+#endif
+
+
+%insert("runtime") "swigerrors.swg"
+
+
+#ifdef SWIGPHP
+%{
+#if PHP_MAJOR_VERSION < 5
+# define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); }
+#else
+# include "zend_exceptions.h"
+# define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); }
+#endif
+%}
+#endif
+
+#ifdef SWIGGUILE
+%{
+ SWIGINTERN void SWIG_exception_ (int code, const char *msg,
+ const char *subr) {
+#define ERROR(scmerr) \
+ scm_error(gh_symbol2scm((char *) (scmerr)), \
+ (char *) subr, (char *) msg, \
+ SCM_EOL, SCM_BOOL_F)
+#define MAP(swigerr, scmerr) \
+ case swigerr: \
+ ERROR(scmerr); \
+ break
+ switch (code) {
+ MAP(SWIG_MemoryError, "swig-memory-error");
+ MAP(SWIG_IOError, "swig-io-error");
+ MAP(SWIG_RuntimeError, "swig-runtime-error");
+ MAP(SWIG_IndexError, "swig-index-error");
+ MAP(SWIG_TypeError, "swig-type-error");
+ MAP(SWIG_DivisionByZero, "swig-division-by-zero");
+ MAP(SWIG_OverflowError, "swig-overflow-error");
+ MAP(SWIG_SyntaxError, "swig-syntax-error");
+ MAP(SWIG_ValueError, "swig-value-error");
+ MAP(SWIG_SystemError, "swig-system-error");
+ default:
+ ERROR("swig-error");
+ }
+#undef ERROR
+#undef MAP
+ }
+
+#define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME)
+%}
+#endif
+
+#ifdef SWIGMZSCHEME
+
+%{
+SWIGINTERN void SWIG_exception_ (int code, const char *msg) {
+#define ERROR(errname) \
+ scheme_signal_error(errname " (%s)", msg);
+#define MAP(swigerr, errname) \
+ case swigerr: \
+ ERROR(errname); \
+ break
+ switch (code) {
+ MAP(SWIG_MemoryError, "swig-memory-error");
+ MAP(SWIG_IOError, "swig-io-error");
+ MAP(SWIG_RuntimeError, "swig-runtime-error");
+ MAP(SWIG_IndexError, "swig-index-error");
+ MAP(SWIG_TypeError, "swig-type-error");
+ MAP(SWIG_DivisionByZero, "swig-division-by-zero");
+ MAP(SWIG_OverflowError, "swig-overflow-error");
+ MAP(SWIG_SyntaxError, "swig-syntax-error");
+ MAP(SWIG_ValueError, "swig-value-error");
+ MAP(SWIG_SystemError, "swig-system-error");
+ default:
+ ERROR("swig-error");
+ }
+#undef ERROR
+#undef MAP
+ }
+
+#define SWIG_exception(a,b) SWIG_exception_(a, b)
+%}
+#endif
+
+#ifdef SWIGJAVA
+%{
+SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
+ SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError;
+ switch(code) {
+ case SWIG_MemoryError:
+ exception_code = SWIG_JavaOutOfMemoryError;
+ break;
+ case SWIG_IOError:
+ exception_code = SWIG_JavaIOException;
+ break;
+ case SWIG_SystemError:
+ case SWIG_RuntimeError:
+ exception_code = SWIG_JavaRuntimeException;
+ break;
+ case SWIG_OverflowError:
+ case SWIG_IndexError:
+ exception_code = SWIG_JavaIndexOutOfBoundsException;
+ break;
+ case SWIG_DivisionByZero:
+ exception_code = SWIG_JavaArithmeticException;
+ break;
+ case SWIG_SyntaxError:
+ case SWIG_ValueError:
+ case SWIG_TypeError:
+ exception_code = SWIG_JavaIllegalArgumentException;
+ break;
+ case SWIG_UnknownError:
+ default:
+ exception_code = SWIG_JavaUnknownError;
+ break;
+ }
+ SWIG_JavaThrowException(jenv, exception_code, msg);
+}
+%}
+
+#define SWIG_exception(code, msg)\
+{ SWIG_JavaException(jenv, code, msg); return $null; }
+#endif // SWIGJAVA
+
+#ifdef SWIGOCAML
+%{
+#define OCAML_MSG_BUF_LEN 1024
+SWIGINTERN void SWIG_exception_(int code, const char *msg) {
+ char msg_buf[OCAML_MSG_BUF_LEN];
+ sprintf( msg_buf, "Exception(%d): %s\n", code, msg );
+ failwith( msg_buf );
+}
+#define SWIG_exception(a,b) SWIG_exception_((a),(b))
+%}
+#endif
+
+
+#ifdef SWIGCHICKEN
+%{
+SWIGINTERN void SWIG_exception_(int code, const char *msg) {
+ C_word *a;
+ C_word scmmsg;
+ C_word list;
+
+ a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2));
+ scmmsg = C_string2 (&a, (char *) msg);
+ list = C_list(&a, 2, C_fix(code), scmmsg);
+ SWIG_ThrowException(list);
+}
+#define SWIG_exception(a,b) SWIG_exception_((a),(b))
+%}
+#endif
+
+#ifdef SWIGCSHARP
+%{
+SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
+ if (code == SWIG_ValueError) {
+ SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException;
+ SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0);
+ } else {
+ SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException;
+ switch(code) {
+ case SWIG_MemoryError:
+ exception_code = SWIG_CSharpOutOfMemoryException;
+ break;
+ case SWIG_IndexError:
+ exception_code = SWIG_CSharpIndexOutOfRangeException;
+ break;
+ case SWIG_DivisionByZero:
+ exception_code = SWIG_CSharpDivideByZeroException;
+ break;
+ case SWIG_IOError:
+ exception_code = SWIG_CSharpIOException;
+ break;
+ case SWIG_OverflowError:
+ exception_code = SWIG_CSharpOverflowException;
+ break;
+ case SWIG_RuntimeError:
+ case SWIG_TypeError:
+ case SWIG_SyntaxError:
+ case SWIG_SystemError:
+ case SWIG_UnknownError:
+ default:
+ exception_code = SWIG_CSharpApplicationException;
+ break;
+ }
+ SWIG_CSharpSetPendingException(exception_code, msg);
+ }
+}
+%}
+
+#define SWIG_exception(code, msg)\
+{ SWIG_CSharpException(code, msg); return $null; }
+#endif // SWIGCSHARP
+
+#ifdef SWIGLUA
+
+%{
+#define SWIG_exception(a,b)\
+{ lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; }
+%}
+
+#endif // SWIGLUA
+
+#ifdef __cplusplus
+/*
+ You can use the SWIG_CATCH_STDEXCEPT macro with the %exception
+ directive as follows:
+
+ %exception {
+ try {
+ $action
+ }
+ catch (my_except& e) {
+ ...
+ }
+ SWIG_CATCH_STDEXCEPT // catch std::exception
+ catch (...) {
+ SWIG_exception(SWIG_UnknownError, "Unknown exception");
+ }
+ }
+*/
+%{
+#include <stdexcept>
+%}
+%define SWIG_CATCH_STDEXCEPT
+ /* catching std::exception */
+ catch (std::invalid_argument& e) {
+ SWIG_exception(SWIG_ValueError, e.what() );
+ } catch (std::domain_error& e) {
+ SWIG_exception(SWIG_ValueError, e.what() );
+ } catch (std::overflow_error& e) {
+ SWIG_exception(SWIG_OverflowError, e.what() );
+ } catch (std::out_of_range& e) {
+ SWIG_exception(SWIG_IndexError, e.what() );
+ } catch (std::length_error& e) {
+ SWIG_exception(SWIG_IndexError, e.what() );
+ } catch (std::runtime_error& e) {
+ SWIG_exception(SWIG_RuntimeError, e.what() );
+ } catch (std::exception& e) {
+ SWIG_exception(SWIG_SystemError, e.what() );
+ }
+%enddef
+%define SWIG_CATCH_UNKNOWN
+ catch (std::exception& e) {
+ SWIG_exception(SWIG_SystemError, e.what() );
+ }
+ catch (...) {
+ SWIG_exception(SWIG_UnknownError, "unknown exception");
+ }
+%enddef
+
+/* rethrow the unknown exception */
+
+#ifdef SWIGCSHARP
+%typemap(throws,noblock=1, canthrow=1) (...) {
+ SWIG_exception(SWIG_RuntimeError,"unknown exception");
+}
+#else
+%typemap(throws,noblock=1) (...) {
+ SWIG_exception(SWIG_RuntimeError,"unknown exception");
+}
+#endif
+
+#endif /* __cplusplus */
+
+/* exception.i ends here */
diff --git a/intrusive_ptr.i b/intrusive_ptr.i
new file mode 100644
index 0000000..43e78f9
--- /dev/null
+++ b/intrusive_ptr.i
@@ -0,0 +1,95 @@
+// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1
+// For example for std::tr1, use:
+// #define SWIG_SHARED_PTR_NAMESPACE std
+// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
+// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost
+// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE
+
+#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE)
+# define SWIG_INTRUSIVE_PTR_NAMESPACE boost
+#endif
+
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE
+#else
+# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE
+#endif
+
+namespace SWIG_INTRUSIVE_PTR_NAMESPACE {
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+ namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE {
+#endif
+ template <class T> class intrusive_ptr {
+ };
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+ }
+#endif
+}
+
+%fragment("SWIG_intrusive_deleter", "header") {
+template<class T> struct SWIG_intrusive_deleter {
+ void operator()(T *p) {
+ if (p)
+ intrusive_ptr_release(p);
+ }
+};
+}
+
+%fragment("SWIG_null_deleter", "header") {
+struct SWIG_null_deleter {
+ void operator() (void const *) const {
+ }
+};
+%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
+%#define SWIG_NO_NULL_DELETER_1
+}
+
+// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
+// For plain classes, do not use for derived classes
+%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%enddef
+
+// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
+// For derived classes
+%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+ %}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
+// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
+// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
+// For plain classes, do not use for derived classes
+%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
+%enddef
+
+// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
+// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
+// For derived classes
+%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+%}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
+
diff --git a/inttypes.i b/inttypes.i
new file mode 100644
index 0000000..0cc8194
--- /dev/null
+++ b/inttypes.i
@@ -0,0 +1,94 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * inttypes.i
+ *
+ * SWIG library file for ISO C99 types: 7.8 Format conversion of integer types <inttypes.h>
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <inttypes.h>
+%}
+
+%include <stdint.i>
+%include <wchar.i>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef SWIGWORDSIZE64
+
+ /* We have to define the `uintmax_t' type using `ldiv_t'. */
+ typedef struct
+ {
+ long int quot; /* Quotient. */
+ long int rem; /* Remainder. */
+ } imaxdiv_t;
+
+#else
+
+ /* We have to define the `uintmax_t' type using `lldiv_t'. */
+ typedef struct
+ {
+ long long int quot; /* Quotient. */
+ long long int rem; /* Remainder. */
+ } imaxdiv_t;
+
+#endif
+
+ /* Compute absolute value of N. */
+ extern intmax_t imaxabs (intmax_t n);
+
+ /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
+ extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom);
+
+ /* Like `strtol' but convert to `intmax_t'. */
+ extern intmax_t strtoimax (const char *nptr, char **endptr, int base);
+
+ /* Like `strtoul' but convert to `uintmax_t'. */
+ extern uintmax_t strtoumax (const char *nptr, char ** endptr, int base);
+
+#ifdef SWIG_WCHAR
+ /* Like `wcstol' but convert to `intmax_t'. */
+ extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base);
+
+ /* Like `wcstoul' but convert to `uintmax_t'. */
+ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t ** endptr, int base);
+#endif
+
+#ifdef SWIGWORDSIZE64
+
+ /* Like `strtol' but convert to `intmax_t'. */
+ extern intmax_t strtoimax (const char *nptr, char **endptr, int base);
+
+ /* Like `strtoul' but convert to `uintmax_t'. */
+ extern uintmax_t strtoumax (const char *nptr, char **endptr,int base);
+
+#ifdef SWIG_WCHAR
+ /* Like `wcstol' but convert to `intmax_t'. */
+ extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base);
+
+ /* Like `wcstoul' but convert to `uintmax_t'. */
+ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base);
+#endif
+
+#else /* SWIGWORDSIZE32 */
+
+ /* Like `strtol' but convert to `intmax_t'. */
+ extern intmax_t strtoimax (const char *nptr, char **endptr, int base);
+
+ /* Like `strtoul' but convert to `uintmax_t'. */
+ extern uintmax_t strtoumax (const char *nptr, char **endptr, int base);
+
+#ifdef SWIG_WCHAR
+ /* Like `wcstol' but convert to `intmax_t'. */
+ extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base);
+#endif
+
+#endif /* SWIGWORDSIZE32 */
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/linkruntime.c b/linkruntime.c
new file mode 100644
index 0000000..ddc7812
--- /dev/null
+++ b/linkruntime.c
@@ -0,0 +1,22 @@
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
+#endif
+
+static void *ptr = 0;
+SWIGEXPORT void *
+SWIG_ReturnGlobalTypeList(void *t) {
+ if (!ptr && !t) ptr = t;
+ return ptr;
+}
diff --git a/math.i b/math.i
new file mode 100644
index 0000000..be931d7
--- /dev/null
+++ b/math.i
@@ -0,0 +1,85 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * math.i
+ *
+ * SWIG library file for floating point operations.
+ * ----------------------------------------------------------------------------- */
+
+%module math
+%{
+#include <math.h>
+%}
+
+extern double cos(double x);
+/* Cosine of x */
+
+extern double sin(double x);
+/* Sine of x */
+
+extern double tan(double x);
+/* Tangent of x */
+
+extern double acos(double x);
+/* Inverse cosine in range [-PI/2,PI/2], x in [-1,1]. */
+
+extern double asin(double x);
+/* Inverse sine in range [0,PI], x in [-1,1]. */
+
+extern double atan(double x);
+/* Inverse tangent in range [-PI/2,PI/2]. */
+
+extern double atan2(double y, double x);
+/* Inverse tangent of y/x in range [-PI,PI]. */
+
+extern double cosh(double x);
+/* Hyperbolic cosine of x */
+
+extern double sinh(double x);
+/* Hyperbolic sine of x */
+
+extern double tanh(double x);
+/* Hyperbolic tangent of x */
+
+extern double exp(double x);
+/* Natural exponential function e^x */
+
+extern double log(double x);
+/* Natural logarithm ln(x), x > 0 */
+
+extern double log10(double x);
+/* Base 10 logarithm, x > 0 */
+
+extern double pow(double x, double y);
+/* Power function x^y. */
+
+extern double sqrt(double x);
+/* Square root. x >= 0 */
+
+extern double fabs(double x);
+/* Absolute value of x */
+
+extern double ceil(double x);
+/* Smallest integer not less than x, as a double */
+
+extern double floor(double x);
+/* Largest integer not greater than x, as a double */
+
+extern double fmod(double x, double y);
+/* Floating-point remainder of x/y, with the same sign as x. */
+
+#define M_E 2.7182818284590452354
+#define M_LOG2E 1.4426950408889634074
+#define M_LOG10E 0.43429448190325182765
+#define M_LN2 0.69314718055994530942
+#define M_LN10 2.30258509299404568402
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
+#define M_PI_4 0.78539816339744830962
+#define M_1_PI 0.31830988618379067154
+#define M_2_PI 0.63661977236758134308
+#define M_2_SQRTPI 1.12837916709551257390
+#define M_SQRT2 1.41421356237309504880
+#define M_SQRT1_2 0.70710678118654752440
+
diff --git a/pointer.i b/pointer.i
new file mode 100644
index 0000000..16e11b7
--- /dev/null
+++ b/pointer.i
@@ -0,0 +1,14 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pointer.i
+ * ----------------------------------------------------------------------------- */
+
+
+%echo "pointer.i is deprecated. Use cpointer.i instead."
+%echo "See http://www.swig.org/Doc1.3/Library.html"
+
+
+
+
diff --git a/python/Makefile.in b/python/Makefile.in
new file mode 100644
index 0000000..3243b3d
--- /dev/null
+++ b/python/Makefile.in
@@ -0,0 +1,135 @@
+# ---------------------------------------------------------------
+# SWIG Python Makefile
+#
+# This file can be used to build various Python extensions with SWIG.
+# By default this file is set up for dynamic loading, but it can
+# be easily customized for static extensions by modifying various
+# portions of the file.
+#
+# SRCS = C source files
+# CXXSRCS = C++ source files
+# OBJCSRCS = Objective-C source files
+# OBJS = Additional .o files (compiled previously)
+# INTERFACE = SWIG interface file
+# TARGET = Name of target module or executable
+#
+# Many portions of this file were created by the SWIG configure
+# script and should already reflect your machine.
+#----------------------------------------------------------------
+
+SRCS =
+CXXSRCS =
+OBJCSRCS =
+OBJS =
+INTERFACE =
+WRAPFILE = $(INTERFACE:.i=_wrap.c)
+WRAPOBJ = $(INTERFACE:.i=_wrap.o)
+TARGET = module@SO@ # Use this kind of target for dynamic loading
+#TARGET = mypython # Use this target for static linking
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+CC = @CC@
+CXX = @CXX@
+OBJC = @CC@ -Wno-import # -Wno-import needed for gcc
+CFLAGS =
+INCLUDES =
+LIBS =
+
+# SWIG Options
+# SWIG = location of the SWIG executable
+# SWIGOPT = SWIG compiler options
+# SWIGCC = Compiler used to compile the wrapper file
+
+SWIG = $(exec_prefix)/bin/swig
+SWIGOPT = -python
+SWIGCC = $(CC)
+
+# SWIG Library files. Uncomment if rebuilding the Python interpreter
+#SWIGLIB = -lembed.i
+
+# Rules for creating .o files from source.
+
+COBJS = $(SRCS:.c=.o)
+CXXOBJS = $(CXXSRCS:.cxx=.o)
+OBJCOBJS = $(OBJCSRCS:.m=.o)
+ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS)
+
+# Command that will be used to build the final extension.
+BUILD = $(SWIGCC)
+
+# Uncomment the following if you are using dynamic loading
+CCSHARED = @CCSHARED@
+BUILD = @LDSHARED@
+
+# Uncomment the following if you are using dynamic loading with C++ and
+# need to provide additional link libraries (this is not always required).
+
+#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
+ -L/usr/local/lib -lg++ -lstdc++ -lgcc
+
+# X11 installation (needed if rebuilding Python + tkinter)
+
+XLIB = @XLIBSW@
+XINCLUDE = @XINCLUDES@
+
+# Python installation
+
+PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@
+PY_LIB = @PYLIB@
+
+# Tcl installation. Needed if rebuilding Python with tkinter.
+
+TCL_INCLUDE = @TCLINCLUDE@
+TCL_LIB = @TCLLIB@
+
+# Build libraries (needed for static builds)
+
+LIBM = @LIBM@
+LIBC = @LIBC@
+SYSLIBS = $(LIBM) $(LIBC) @LIBS@
+
+# Build options (uncomment only one these)
+
+#TKINTER = $(TCL_LIB) -ltk -ltcl $(XLIB)
+BUILD_LIBS = $(LIBS) # Dynamic loading
+#BUILD_LIBS = $(PY_LIB) @PYLINK@ $(TKINTER) $(LIBS) $(SYSLIBS)
+
+# Compilation rules for non-SWIG components
+
+.SUFFIXES: .c .cxx .m
+
+.c.o:
+ $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $<
+
+.cxx.o:
+ $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $<
+
+.m.o:
+ $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $<
+
+
+# ----------------------------------------------------------------------
+# Rules for building the extension
+# ----------------------------------------------------------------------
+
+all: $(TARGET)
+
+# Convert the wrapper file into an object file
+
+$(WRAPOBJ) : $(WRAPFILE)
+ $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE)
+
+$(WRAPFILE) : $(INTERFACE)
+ $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
+
+$(TARGET): $(WRAPOBJ) $(ALLOBJS)
+ $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)
+
+clean:
+ rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)
+
+
+
+
diff --git a/python/README b/python/README
new file mode 100644
index 0000000..98ec560
--- /dev/null
+++ b/python/README
@@ -0,0 +1,105 @@
+/* -----------------------------------------------------------------------------
+ *
+ * User interfaces: include these ones as needed
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * Special types and user helpers
+ * ----------------------------------------------------------------------------- */
+
+argcargv.i Handler for (int argc, char **argv)
+attribute.i Convert a pair of set/get methods into a "native" python attribute
+ccomplex.i C99 complex type
+complex.i C99 or C++ complex type
+cstring.i Various forms of C character string handling
+cwstring.i Various forms of C wchar_t string handling
+embed.i embedding the Python interpreter in something else
+embed15.i embedding the Python interpreter in something else
+file.i FILE C type
+implicit.i Allow the use of implicit C++ constructors
+wchar.i wchar_t C type
+
+/* -----------------------------------------------------------------------------
+ * C++ STD + STL
+ * ----------------------------------------------------------------------------- */
+
+std_alloc.i allocator
+std_basic_string.i basic string
+std_char_traits.i char traits
+std_complex.i complex
+std_deque.i deque
+std_except.i exceptions
+std_ios.i ios
+std_iostream.i istream/ostream
+std_list.i list
+std_map.i map
+std_multimap.i multimap
+std_multiset.i multiset
+std_pair.i pair
+std_set.i set
+std_sstream.i string stream
+std_streambuf.i streambuf
+std_string.i string
+std_vector.i vector
+std_wios.i wios
+std_wiostream.i wistream/wostream
+std_wsstream.i wstring stream
+std_wstreambuf.i wstreambuf
+std_wstring.i wstring
+
+
+
+/* -----------------------------------------------------------------------------
+/*
+ * Implementation files: don't look at them unless you are really drunk
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * Basic files
+ * ----------------------------------------------------------------------------- */
+
+python.swg Main language file, it just includes what is needed.
+pyuserdir.swg User visible directives (%pythonnondynamic, etc)
+pymacros.swg Internal macros used for typemaps
+pyfragments.swg Allow the user to overload the default fragments
+pyopers.swg Python operations (+=, *=, etc)
+pythonkw.swg Python keywords and special names
+pyinit.swg Python Init method
+
+/* -----------------------------------------------------------------------------
+ * The runtime part
+ * ----------------------------------------------------------------------------- */
+
+pyruntime.swg Main runtime file definition
+pyapi.swg SWIG/Python API declarations
+pyrun.swg Python run-time code
+
+/* -----------------------------------------------------------------------------
+ * Internal typemap specializations
+ * ----------------------------------------------------------------------------- */
+
+pyswigtype.swg SWIGTYPE
+pystrings.swg Char strings (char *)
+pywstrings.swg Wchar Strings (wchar_t *)
+pyprimtypes.swg Primitive types (shot,int,double,etc)
+pycomplex.swg PyComplex and helper for C/C++ complex types
+pydocs.swg Typemaps documentation
+
+/* -----------------------------------------------------------------------------
+ * C++ STD + STL
+ * ----------------------------------------------------------------------------- */
+
+pycontainer.swg python container iterators
+std_common.i general common code for the STD/STL implementation
+std_container.i general common code for the STD/STL containers
+
+
+/*-----------------------------------------------------------------------------
+ * Backward compatibility and deprecated
+ * ----------------------------------------------------------------------------- */
+
+std_vectora.i vector + allocator (allocators are now supported in STD/STL)
+typemaps.i old in/out typemaps (doesn't need to be included)
+defarg.swg for processing default arguments with shadow classes
diff --git a/python/argcargv.i b/python/argcargv.i
new file mode 100644
index 0000000..d5d008a
--- /dev/null
+++ b/python/argcargv.i
@@ -0,0 +1,92 @@
+/* ------------------------------------------------------------
+ * --- Argc & Argv ---
+ * ------------------------------------------------------------ */
+
+%fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") {
+SWIGINTERN int
+SWIG_AsArgcArgv(PyObject *input,
+ swig_type_info *ppchar_info,
+ size_t *argc, char ***argv, int *owner)
+{
+ void *vptr;
+ int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0);
+ if (!SWIG_IsOK(res)) {
+ int list = 0;
+ PyErr_Clear();
+ list = PyList_Check(input);
+ if (list || PyTuple_Check(input)) {
+ size_t i = 0;
+ size_t size = list ? PyList_Size(input) : PyTuple_Size(input);
+ if (argc) *argc = size;
+ if (argv) {
+ *argv = %new_array(size + 1, char*);
+ for (; i < size; ++i) {
+ PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i);
+ char *cptr = 0; size_t sz = 0; int alloc = 0;
+ res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc);
+ if (SWIG_IsOK(res)) {
+ if (cptr && sz) {
+ (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char);
+ } else {
+ (*argv)[i] = 0;
+ }
+ } else {
+ return SWIG_TypeError;
+ }
+ }
+ (*argv)[i] = 0;
+ if (owner) *owner = 1;
+ } else {
+ for (; i < size; ++i) {
+ PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i);
+ res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0);
+ if (!SWIG_IsOK(res)) return SWIG_TypeError;
+ }
+ if (owner) *owner = 0;
+ }
+ return SWIG_OK;
+ } else {
+ return SWIG_TypeError;
+ }
+ } else {
+ /* seems dangerous, but the user asked for it... */
+ size_t i = 0;
+ if (argv) { while (*argv[i] != 0) ++i;}
+ if (argc) *argc = i;
+ if (owner) *owner = 0;
+ return SWIG_OK;
+ }
+}
+}
+
+/*
+ This typemap works with either a char**, a python list or a python
+ tuple
+ */
+
+%typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) {
+ res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner);
+ if (!SWIG_IsOK(res)) {
+ $1 = 0; $2 = 0;
+ %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum);
+ } else {
+ $1 = %static_cast(argc,$1_ltype);
+ $2 = %static_cast(argv, $2_ltype);
+ }
+}
+
+%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) {
+ int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0);
+ $1 = SWIG_IsOK(res);
+}
+
+%typemap(freearg,noblock=1) (int ARGC, char **ARGV) {
+ if (owner$argnum) {
+ size_t i = argc$argnum;
+ while (i) {
+ %delete_array(argv$argnum[--i]);
+ }
+ %delete_array(argv$argnum);
+ }
+}
+
diff --git a/python/attribute.i b/python/attribute.i
new file mode 100644
index 0000000..779716c
--- /dev/null
+++ b/python/attribute.i
@@ -0,0 +1 @@
+%include <typemaps/attribute.swg>
diff --git a/python/boost_shared_ptr.i b/python/boost_shared_ptr.i
new file mode 100644
index 0000000..b4c0b5b
--- /dev/null
+++ b/python/boost_shared_ptr.i
@@ -0,0 +1,313 @@
+%include <shared_ptr.i>
+
+// Set SHARED_PTR_DISOWN to $disown if required, for example
+// #define SHARED_PTR_DISOWN $disown
+#if !defined(SHARED_PTR_DISOWN)
+#define SHARED_PTR_DISOWN 0
+#endif
+
+%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
+
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor mods
+%feature("unref") TYPE
+//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
+ "(void)arg1; delete smartarg1;"
+
+%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
+
+// plain value
+%typemap(in) CONST TYPE (void *argp, int res = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ }
+}
+%typemap(out) CONST TYPE {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ }
+}
+%typemap(varout) CONST TYPE {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain pointer
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
+%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
+ }
+}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE * {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
+ }
+}
+%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain reference
+%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
+ }
+}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE & {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = *%const_cast(tempshared.get(), $1_ltype);
+ } else {
+ $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
+ }
+}
+%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain pointer by reference
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
+%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ temp = %const_cast(tempshared.get(), $*1_ltype);
+ } else {
+ temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype);
+ }
+ $1 = &temp;
+}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE *& %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) CONST TYPE *& %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by value
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ int newmem = 0;
+ void *argp = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
+}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// shared_ptr by reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
+ delete %reinterpret_cast(argp, $ltype);
+ $1 = &tempshared;
+ } else {
+ $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
+ }
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by pointer
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
+ delete %reinterpret_cast(argp, $ltype);
+ $1 = &tempshared;
+ } else {
+ $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
+ }
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+ if ($owner) delete $1;
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by pointer reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
+ temp = &tempshared;
+ $1 = &temp;
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
+#error "varout typemap not implemented"
+%}
+
+// Typecheck typemaps
+// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
+// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
+ CONST TYPE,
+ CONST TYPE &,
+ CONST TYPE *,
+ CONST TYPE *&,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%enddef
+
diff --git a/python/carrays.i b/python/carrays.i
new file mode 100644
index 0000000..8d6d440
--- /dev/null
+++ b/python/carrays.i
@@ -0,0 +1,9 @@
+%define %array_class(TYPE,NAME)
+ %array_class_wrap(TYPE,NAME,__getitem__,__setitem__)
+%enddef
+
+%include <typemaps/carrays.swg>
+
+
+
+
diff --git a/python/ccomplex.i b/python/ccomplex.i
new file mode 100644
index 0000000..30f797d
--- /dev/null
+++ b/python/ccomplex.i
@@ -0,0 +1,29 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * ccomplex.i
+ *
+ * C complex typemaps
+ * ISO C99: 7.3 Complex arithmetic <complex.h>
+ * ----------------------------------------------------------------------------- */
+
+
+%include <pycomplex.swg>
+
+%{
+#include <complex.h>
+%}
+
+
+/* C complex constructor */
+#define CCplxConst(r, i) ((r) + I*(i))
+
+%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
+%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
+%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
+
+/* declaring the typemaps */
+%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
diff --git a/python/cdata.i b/python/cdata.i
new file mode 100644
index 0000000..3679659
--- /dev/null
+++ b/python/cdata.i
@@ -0,0 +1 @@
+%include <typemaps/cdata.swg>
diff --git a/python/cmalloc.i b/python/cmalloc.i
new file mode 100644
index 0000000..248f06b
--- /dev/null
+++ b/python/cmalloc.i
@@ -0,0 +1 @@
+%include <typemaps/cmalloc.swg>
diff --git a/python/cni.i b/python/cni.i
new file mode 100644
index 0000000..10a1403
--- /dev/null
+++ b/python/cni.i
@@ -0,0 +1,2 @@
+%include <gcj/cni.i>
+%include <jstring.i>
diff --git a/python/complex.i b/python/complex.i
new file mode 100644
index 0000000..4c3b3c5
--- /dev/null
+++ b/python/complex.i
@@ -0,0 +1,6 @@
+#ifdef __cplusplus
+%include <std_complex.i>
+#else
+%include <ccomplex.i>
+#endif
+
diff --git a/python/cpointer.i b/python/cpointer.i
new file mode 100644
index 0000000..d824792
--- /dev/null
+++ b/python/cpointer.i
@@ -0,0 +1 @@
+%include <typemaps/cpointer.swg>
diff --git a/python/cstring.i b/python/cstring.i
new file mode 100644
index 0000000..ede9c59
--- /dev/null
+++ b/python/cstring.i
@@ -0,0 +1 @@
+%include <typemaps/cstring.swg>
diff --git a/python/cwstring.i b/python/cwstring.i
new file mode 100644
index 0000000..2824d9c
--- /dev/null
+++ b/python/cwstring.i
@@ -0,0 +1,3 @@
+%include <pywstrings.swg>
+%include <typemaps/cwstring.swg>
+
diff --git a/python/defarg.swg b/python/defarg.swg
new file mode 100644
index 0000000..10c9916
--- /dev/null
+++ b/python/defarg.swg
@@ -0,0 +1,37 @@
+/* This file defines an internal function for processing default arguments
+ with proxy classes.
+
+ There seems to be no straightforward way to write proxy functions
+ involving default arguments. For example :
+
+ def foo(arg1,arg2,*args):
+ proxyc.foo(arg1,arg2,args)
+
+ This fails because args is now a tuple and SWIG doesn't know what to
+ do with it.
+
+ This file allows a different approach :
+
+ def foo(arg1,arg2,*args):
+ proxyc.__call_defarg(proxyc.foo,(arg1,arg2,)+args)
+
+ Basically, we form a new tuple from the object, call this special
+ __call_defarg method and it passes control to the real wrapper function.
+ An ugly hack, but it works.
+*/
+
+SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) {
+ PyObject *func;
+ PyObject *parms;
+
+ if (!PyArg_ParseTuple(args,"OO",&func,&parms))
+ return NULL;
+
+ if (!PyCallable_Check(func)) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ return PyEval_CallObject(func,parms);
+}
diff --git a/python/director.swg b/python/director.swg
new file mode 100644
index 0000000..ba91445
--- /dev/null
+++ b/python/director.swg
@@ -0,0 +1,475 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * director.swg
+ *
+ * This file contains support for director classes that proxy
+ * method calls from C++ to Python extensions.
+ * ----------------------------------------------------------------------------- */
+
+#ifndef SWIG_DIRECTOR_PYTHON_HEADER_
+#define SWIG_DIRECTOR_PYTHON_HEADER_
+
+#ifdef __cplusplus
+
+#include <string>
+#include <iostream>
+#include <exception>
+#include <vector>
+#include <map>
+
+
+/*
+ Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual
+ table', and avoid multiple GetAttr calls to retrieve the python
+ methods.
+*/
+
+#ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE
+#ifndef SWIG_PYTHON_DIRECTOR_VTABLE
+#define SWIG_PYTHON_DIRECTOR_VTABLE
+#endif
+#endif
+
+
+
+/*
+ Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the
+ Undefined Exception Handler provided by swift
+*/
+#ifndef SWIG_DIRECTOR_NO_UEH
+#ifndef SWIG_DIRECTOR_UEH
+#define SWIG_DIRECTOR_UEH
+#endif
+#endif
+
+
+/*
+ Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the
+ 'Swig' namespace. This could be useful for multi-modules projects.
+*/
+#ifdef SWIG_DIRECTOR_STATIC
+/* Force anonymous (static) namespace */
+#define Swig
+#endif
+
+
+/*
+ Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the
+ native C++ RTTI and dynamic_cast<>. But be aware that directors
+ could stop working when using this option.
+*/
+#ifdef SWIG_DIRECTOR_NORTTI
+/*
+ When we don't use the native C++ RTTI, we implement a minimal one
+ only for Directors.
+*/
+# ifndef SWIG_DIRECTOR_RTDIR
+# define SWIG_DIRECTOR_RTDIR
+#include <map>
+
+namespace Swig {
+ class Director;
+ SWIGINTERN std::map<void*,Director*>& get_rtdir_map() {
+ static std::map<void*,Director*> rtdir_map;
+ return rtdir_map;
+ }
+
+ SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) {
+ get_rtdir_map()[vptr] = rtdir;
+ }
+
+ SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
+ std::map<void*,Director*>::const_iterator pos = get_rtdir_map().find(vptr);
+ Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0;
+ return rtdir;
+ }
+}
+# endif /* SWIG_DIRECTOR_RTDIR */
+
+# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg))
+# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2)
+
+#else
+
+# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg)
+# define SWIG_DIRECTOR_RGTR(Arg1, Arg2)
+
+#endif /* SWIG_DIRECTOR_NORTTI */
+
+extern "C" {
+ struct swig_type_info;
+}
+
+namespace Swig {
+
+ /* memory handler */
+ struct GCItem
+ {
+ virtual ~GCItem() {}
+
+ virtual int get_own() const
+ {
+ return 0;
+ }
+ };
+
+ struct GCItem_var
+ {
+ GCItem_var(GCItem *item = 0) : _item(item)
+ {
+ }
+
+ GCItem_var& operator=(GCItem *item)
+ {
+ GCItem *tmp = _item;
+ _item = item;
+ delete tmp;
+ return *this;
+ }
+
+ ~GCItem_var()
+ {
+ delete _item;
+ }
+
+ GCItem * operator->() const
+ {
+ return _item;
+ }
+
+ private:
+ GCItem *_item;
+ };
+
+ struct GCItem_Object : GCItem
+ {
+ GCItem_Object(int own) : _own(own)
+ {
+ }
+
+ virtual ~GCItem_Object()
+ {
+ }
+
+ int get_own() const
+ {
+ return _own;
+ }
+
+ private:
+ int _own;
+ };
+
+ template <typename Type>
+ struct GCItem_T : GCItem
+ {
+ GCItem_T(Type *ptr) : _ptr(ptr)
+ {
+ }
+
+ virtual ~GCItem_T()
+ {
+ delete _ptr;
+ }
+
+ private:
+ Type *_ptr;
+ };
+
+ template <typename Type>
+ struct GCArray_T : GCItem
+ {
+ GCArray_T(Type *ptr) : _ptr(ptr)
+ {
+ }
+
+ virtual ~GCArray_T()
+ {
+ delete[] _ptr;
+ }
+
+ private:
+ Type *_ptr;
+ };
+
+ /* base class for director exceptions */
+ class DirectorException {
+ protected:
+ std::string swig_msg;
+ public:
+ DirectorException(PyObject *error, const char* hdr ="", const char* msg ="")
+ : swig_msg(hdr)
+ {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ if (strlen(msg)) {
+ swig_msg += " ";
+ swig_msg += msg;
+ }
+ if (!PyErr_Occurred()) {
+ PyErr_SetString(error, getMessage());
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+
+ const char *getMessage() const
+ {
+ return swig_msg.c_str();
+ }
+
+ static void raise(PyObject *error, const char *msg)
+ {
+ throw DirectorException(error, msg);
+ }
+
+ static void raise(const char *msg)
+ {
+ raise(PyExc_RuntimeError, msg);
+ }
+ };
+
+ /* unknown exception handler */
+ class UnknownExceptionHandler
+ {
+#ifdef SWIG_DIRECTOR_UEH
+ static void handler() {
+ try {
+ throw;
+ } catch (DirectorException& e) {
+ std::cerr << "Swig Director exception caught:" << std::endl
+ << e.getMessage() << std::endl;
+ } catch (std::exception& e) {
+ std::cerr << "std::exception caught: "<< e.what() << std::endl;
+ } catch (...) {
+ std::cerr << "Unknown exception caught." << std::endl;
+ }
+
+ std::cerr << std::endl
+ << "Python interpreter traceback:" << std::endl;
+ PyErr_Print();
+ std::cerr << std::endl;
+
+ std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
+ << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
+ << std::endl
+ << "Exception is being re-thrown, program will like abort/terminate." << std::endl;
+ throw;
+ }
+
+ public:
+
+ std::unexpected_handler old;
+ UnknownExceptionHandler(std::unexpected_handler nh = handler)
+ {
+ old = std::set_unexpected(nh);
+ }
+
+ ~UnknownExceptionHandler()
+ {
+ std::set_unexpected(old);
+ }
+#endif
+ };
+
+ /* type mismatch in the return value from a python method call */
+ class DirectorTypeMismatchException : public Swig::DirectorException {
+ public:
+ DirectorTypeMismatchException(PyObject *error, const char* msg="")
+ : Swig::DirectorException(error, "Swig director type mismatch", msg)
+ {
+ }
+
+ DirectorTypeMismatchException(const char* msg="")
+ : Swig::DirectorException(PyExc_TypeError, "Swig director type mismatch", msg)
+ {
+ }
+
+ static void raise(PyObject *error, const char *msg)
+ {
+ throw DirectorTypeMismatchException(error, msg);
+ }
+
+ static void raise(const char *msg)
+ {
+ throw DirectorTypeMismatchException(msg);
+ }
+ };
+
+ /* any python exception that occurs during a director method call */
+ class DirectorMethodException : public Swig::DirectorException {
+ public:
+ DirectorMethodException(const char* msg = "")
+ : DirectorException(PyExc_RuntimeError, "Swig director method error.", msg)
+ {
+ }
+
+ static void raise(const char *msg)
+ {
+ throw DirectorMethodException(msg);
+ }
+ };
+
+ /* attempt to call a pure virtual method via a director method */
+ class DirectorPureVirtualException : public Swig::DirectorException
+ {
+ public:
+ DirectorPureVirtualException(const char* msg = "")
+ : DirectorException(PyExc_RuntimeError, "Swig director pure virtual method called", msg)
+ {
+ }
+
+ static void raise(const char *msg)
+ {
+ throw DirectorPureVirtualException(msg);
+ }
+ };
+
+
+#if defined(SWIG_PYTHON_THREADS)
+/* __THREAD__ is the old macro to activate some thread support */
+# if !defined(__THREAD__)
+# define __THREAD__ 1
+# endif
+#endif
+
+#ifdef __THREAD__
+# include "pythread.h"
+ class Guard
+ {
+ PyThread_type_lock & mutex_;
+
+ public:
+ Guard(PyThread_type_lock & mutex) : mutex_(mutex)
+ {
+ PyThread_acquire_lock(mutex_, WAIT_LOCK);
+ }
+
+ ~Guard()
+ {
+ PyThread_release_lock(mutex_);
+ }
+ };
+# define SWIG_GUARD(mutex) Guard _guard(mutex)
+#else
+# define SWIG_GUARD(mutex)
+#endif
+
+ /* director base class */
+ class Director {
+ private:
+ /* pointer to the wrapped python object */
+ PyObject* swig_self;
+ /* flag indicating whether the object is owned by python or c++ */
+ mutable bool swig_disown_flag;
+
+ /* decrement the reference count of the wrapped python object */
+ void swig_decref() const {
+ if (swig_disown_flag) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ Py_DECREF(swig_self);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+ }
+
+ public:
+ /* wrap a python object, optionally taking ownership */
+ Director(PyObject* self) : swig_self(self), swig_disown_flag(false) {
+ swig_incref();
+ }
+
+
+ /* discard our reference at destruction */
+ virtual ~Director() {
+ swig_decref();
+ }
+
+
+ /* return a pointer to the wrapped python object */
+ PyObject *swig_get_self() const {
+ return swig_self;
+ }
+
+ /* acquire ownership of the wrapped python object (the sense of "disown"
+ * is from python) */
+ void swig_disown() const {
+ if (!swig_disown_flag) {
+ swig_disown_flag=true;
+ swig_incref();
+ }
+ }
+
+ /* increase the reference count of the wrapped python object */
+ void swig_incref() const {
+ if (swig_disown_flag) {
+ Py_INCREF(swig_self);
+ }
+ }
+
+ /* methods to implement pseudo protected director members */
+ virtual bool swig_get_inner(const char* /* name */) const {
+ return true;
+ }
+
+ virtual void swig_set_inner(const char* /* name */, bool /* val */) const {
+ }
+
+ /* ownership management */
+ private:
+ typedef std::map<void*, GCItem_var> ownership_map;
+ mutable ownership_map owner;
+#ifdef __THREAD__
+ static PyThread_type_lock swig_mutex_own;
+#endif
+
+ public:
+ template <typename Type>
+ void swig_acquire_ownership_array(Type *vptr) const
+ {
+ if (vptr) {
+ SWIG_GUARD(swig_mutex_own);
+ owner[vptr] = new GCArray_T<Type>(vptr);
+ }
+ }
+
+ template <typename Type>
+ void swig_acquire_ownership(Type *vptr) const
+ {
+ if (vptr) {
+ SWIG_GUARD(swig_mutex_own);
+ owner[vptr] = new GCItem_T<Type>(vptr);
+ }
+ }
+
+ void swig_acquire_ownership_obj(void *vptr, int own) const
+ {
+ if (vptr && own) {
+ SWIG_GUARD(swig_mutex_own);
+ owner[vptr] = new GCItem_Object(own);
+ }
+ }
+
+ int swig_release_ownership(void *vptr) const
+ {
+ int own = 0;
+ if (vptr) {
+ SWIG_GUARD(swig_mutex_own);
+ ownership_map::iterator iter = owner.find(vptr);
+ if (iter != owner.end()) {
+ own = iter->second->get_own();
+ owner.erase(iter);
+ }
+ }
+ return own;
+ }
+ };
+
+#ifdef __THREAD__
+ PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock();
+#endif
+}
+
+#endif /* __cplusplus */
+
+
+#endif
diff --git a/python/embed.i b/python/embed.i
new file mode 100644
index 0000000..c29e8fd
--- /dev/null
+++ b/python/embed.i
@@ -0,0 +1,115 @@
+//
+// embed.i
+// SWIG file embedding the Python interpreter in something else.
+// This file is based on Python-1.5. It will not work with
+// earlier versions.
+//
+// This file makes it possible to extend Python and all of its
+// built-in functions without having to hack its setup script.
+//
+
+
+#ifdef AUTODOC
+%subsection "embed.i"
+%text %{
+This module provides support for building a new version of the
+Python executable. This will be necessary on systems that do
+not support shared libraries and may be necessary with C++
+extensions. This file contains everything you need to build
+a new version of Python from include files and libraries normally
+installed with the Python language.
+
+This module will automatically grab all of the Python modules
+present in your current Python executable (including any special
+purpose modules you have enabled such as Tkinter). Thus, you
+may need to provide additional link libraries when compiling.
+
+This library file only works with Python 1.5. A version
+compatible with Python 1.4 is available as embed14.i and
+a Python1.3 version is available as embed13.i. As far as
+I know, this module is C++ safe.
+%}
+#else
+%echo "embed.i : Using Python 1.5"
+#endif
+
+%wrapper %{
+
+#include <Python.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void SWIG_init(); /* Forward reference */
+
+#define _PyImport_Inittab swig_inittab
+
+/* Grab Python's inittab[] structure */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <config.c>
+
+#undef _PyImport_Inittab
+
+/* Now define our own version of it.
+ Hopefully someone does not have more than 1000 built-in modules */
+
+struct _inittab SWIG_Import_Inittab[1000];
+
+static int swig_num_modules = 0;
+
+/* Function for adding modules to Python */
+
+static void swig_add_module(char *name, void (*initfunc)()) {
+ SWIG_Import_Inittab[swig_num_modules].name = name;
+ SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc;
+ swig_num_modules++;
+ SWIG_Import_Inittab[swig_num_modules].name = (char *) 0;
+ SWIG_Import_Inittab[swig_num_modules].initfunc = 0;
+}
+
+/* Function to add all of Python's build in modules to our interpreter */
+
+static void swig_add_builtin() {
+ int i = 0;
+ while (swig_inittab[i].name) {
+ swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc);
+ i++;
+ }
+#ifdef SWIGMODINIT
+ SWIGMODINIT
+#endif
+ /* Add SWIG builtin function */
+ swig_add_module(SWIG_name, SWIG_init);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int Py_Main(int, char **);
+
+#ifdef __cplusplus
+}
+#endif
+
+extern struct _inittab *PyImport_Inittab;
+
+int
+main(int argc, char **argv) {
+ swig_add_builtin();
+ PyImport_Inittab = SWIG_Import_Inittab;
+ return Py_Main(argc,argv);
+}
+
+%}
+
+
+
+
diff --git a/python/embed15.i b/python/embed15.i
new file mode 100644
index 0000000..32808b1
--- /dev/null
+++ b/python/embed15.i
@@ -0,0 +1,118 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * embed15.i
+ *
+ * SWIG file embedding the Python interpreter in something else.
+ * This file is based on Python-1.5. It will not work with
+ * earlier versions.
+ *
+ * This file makes it possible to extend Python and all of its
+ * built-in functions without having to hack its setup script.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef AUTODOC
+%subsection "embed.i"
+%text %{
+This module provides support for building a new version of the
+Python executable. This will be necessary on systems that do
+not support shared libraries and may be necessary with C++
+extensions. This file contains everything you need to build
+a new version of Python from include files and libraries normally
+installed with the Python language.
+
+This module will automatically grab all of the Python modules
+present in your current Python executable (including any special
+purpose modules you have enabled such as Tkinter). Thus, you
+may need to provide additional link libraries when compiling.
+
+This library file only works with Python 1.5. A version
+compatible with Python 1.4 is available as embed14.i and
+a Python1.3 version is available as embed13.i. As far as
+I know, this module is C++ safe.
+%}
+#else
+%echo "embed.i : Using Python 1.5"
+#endif
+
+%wrapper %{
+
+#include <Python.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void SWIG_init(); /* Forward reference */
+
+#define _PyImport_Inittab swig_inittab
+
+/* Grab Python's inittab[] structure */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <config.c>
+
+#undef _PyImport_Inittab
+
+/* Now define our own version of it.
+ Hopefully someone does not have more than 1000 built-in modules */
+
+struct _inittab SWIG_Import_Inittab[1000];
+
+static int swig_num_modules = 0;
+
+/* Function for adding modules to Python */
+
+static void swig_add_module(char *name, void (*initfunc)()) {
+ SWIG_Import_Inittab[swig_num_modules].name = name;
+ SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc;
+ swig_num_modules++;
+ SWIG_Import_Inittab[swig_num_modules].name = (char *) 0;
+ SWIG_Import_Inittab[swig_num_modules].initfunc = 0;
+}
+
+/* Function to add all of Python's build in modules to our interpreter */
+
+static void swig_add_builtin() {
+ int i = 0;
+ while (swig_inittab[i].name) {
+ swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc);
+ i++;
+ }
+#ifdef SWIGMODINIT
+ SWIGMODINIT
+#endif
+ /* Add SWIG builtin function */
+ swig_add_module(SWIG_name, SWIG_init);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int Py_Main(int, char **);
+
+#ifdef __cplusplus
+}
+#endif
+
+extern struct _inittab *PyImport_Inittab;
+
+int
+main(int argc, char **argv) {
+ swig_add_builtin();
+ PyImport_Inittab = SWIG_Import_Inittab;
+ return Py_Main(argc,argv);
+}
+
+%}
+
+
+
+
diff --git a/python/exception.i b/python/exception.i
new file mode 100644
index 0000000..bb0b15c
--- /dev/null
+++ b/python/exception.i
@@ -0,0 +1,6 @@
+%include <typemaps/exception.swg>
+
+
+%insert("runtime") {
+ %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; ))
+}
diff --git a/python/factory.i b/python/factory.i
new file mode 100644
index 0000000..46a0a87
--- /dev/null
+++ b/python/factory.i
@@ -0,0 +1 @@
+%include <typemaps/factory.swg>
diff --git a/python/file.i b/python/file.i
new file mode 100644
index 0000000..294ab91
--- /dev/null
+++ b/python/file.i
@@ -0,0 +1,45 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * file.i
+ *
+ * Typemaps for FILE*
+ * From the ideas of Luigi Ballabio
+ * ----------------------------------------------------------------------------- */
+
+%types(FILE *);
+
+/* defining basic methods */
+%fragment("SWIG_AsValFilePtr","header") {
+SWIGINTERN int
+SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
+ static swig_type_info* desc = 0;
+ void *vptr = 0;
+ if (!desc) desc = SWIG_TypeQuery("FILE *");
+ if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
+ if (val) *val = (FILE *)vptr;
+ return SWIG_OK;
+ }
+%#if PY_VERSION_HEX < 0x03000000
+ if (PyFile_Check(obj)) {
+ if (val) *val = PyFile_AsFile(obj);
+ return SWIG_OK;
+ }
+%#endif
+ return SWIG_TypeError;
+}
+}
+
+
+%fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") {
+SWIGINTERNINLINE FILE*
+SWIG_AsFilePtr(PyObject *obj) {
+ FILE *val = 0;
+ SWIG_AsValFilePtr(obj, &val);
+ return val;
+}
+}
+
+/* defining the typemaps */
+%typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*);
diff --git a/python/implicit.i b/python/implicit.i
new file mode 100644
index 0000000..152c2b0
--- /dev/null
+++ b/python/implicit.i
@@ -0,0 +1,7 @@
+%include <std_common.i>
+%include <typemaps/implicit.swg>
+
+#warning "This file provides the %implicit directive, which is an old and fragile"
+#warning "way to implement the C++ implicit conversion mechanism."
+#warning "Try using the more robust '%implicitconv Type;' directive instead."
+
diff --git a/python/jstring.i b/python/jstring.i
new file mode 100644
index 0000000..bda9523
--- /dev/null
+++ b/python/jstring.i
@@ -0,0 +1,72 @@
+%include <typemaps/valtypes.swg>
+
+%fragment(SWIG_AsVal_frag(jstring),"header") {
+SWIGINTERN int
+SWIG_AsVal(jstring)(PyObject *obj, jstring *val)
+{
+ if (obj == Py_None) {
+ if (val) *val = 0;
+ return SWIG_OK;
+ }
+
+ PyObject *tmp = 0;
+ int isunicode = PyUnicode_Check(obj);
+ if (!isunicode && PyString_Check(obj)) {
+ if (val) {
+ obj = tmp = PyUnicode_FromObject(obj);
+ }
+ isunicode = 1;
+ }
+ if (isunicode) {
+ if (val) {
+ if (sizeof(Py_UNICODE) == sizeof(jchar)) {
+ *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj));
+ return SWIG_NEWOBJ;
+ } else {
+ int len = PyUnicode_GET_SIZE(obj);
+ Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj);
+ *val = JvAllocString (len);
+ jchar *jchars = JvGetStringChars (*val);
+ for (int i = 0; i < len; ++i) {
+ jchars[i] = pchars[i];
+ }
+ return SWIG_NEWOBJ;
+ }
+ }
+ Py_XDECREF(tmp);
+ return SWIG_OK;
+ }
+ return SWIG_TypeError;
+}
+}
+
+%fragment(SWIG_From_frag(jstring),"header") {
+SWIGINTERNINLINE PyObject *
+SWIG_From(jstring)(jstring val)
+{
+ if (!val) {
+ return SWIG_Py_Void();
+ }
+ if (sizeof(Py_UNICODE) == sizeof(jchar)) {
+ return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val),
+ JvGetStringUTFLength(val));
+ } else {
+ int len = JvGetStringUTFLength(val);
+ Py_UNICODE pchars[len];
+ jchar *jchars = JvGetStringChars(val);
+
+ for (int i = 0; i < len; i++) {
+ pchars[i] = jchars[i];
+ }
+ return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len);
+ }
+}
+}
+
+%typemaps_asvalfrom(%checkcode(STRING),
+ %arg(SWIG_AsVal(jstring)),
+ %arg(SWIG_From(jstring)),
+ %arg(SWIG_AsVal_frag(jstring)),
+ %arg(SWIG_From_frag(jstring)),
+ java::lang::String *);
+
diff --git a/python/pyabc.i b/python/pyabc.i
new file mode 100644
index 0000000..3da06b5
--- /dev/null
+++ b/python/pyabc.i
@@ -0,0 +1,10 @@
+%define %pythonabc(Type, Abc)
+ %feature("python:abc", #Abc) Type;
+%enddef
+%pythoncode {import collections};
+%pythonabc(std::vector, collections.MutableSequence);
+%pythonabc(std::list, collections.MutableSequence);
+%pythonabc(std::map, collections.MutableMapping);
+%pythonabc(std::multimap, collections.MutableMapping);
+%pythonabc(std::set, collections.MutableSet);
+%pythonabc(std::multiset, collections.MutableSet);
diff --git a/python/pyapi.swg b/python/pyapi.swg
new file mode 100644
index 0000000..d980f92
--- /dev/null
+++ b/python/pyapi.swg
@@ -0,0 +1,50 @@
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Constant declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Constant Types */
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY 5
+
+/* Constant information structure */
+typedef struct swig_const_info {
+ int type;
+ char *name;
+ long lvalue;
+ double dvalue;
+ void *pvalue;
+ swig_type_info **ptype;
+} swig_const_info;
+
+
+/* -----------------------------------------------------------------------------
+ * Wrapper of PyInstanceMethod_New() used in Python 3
+ * It is exported to the generated module, used for -fastproxy
+ * ----------------------------------------------------------------------------- */
+SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ return PyInstanceMethod_New(func);
+#else
+ return NULL;
+#endif
+}
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
+
diff --git a/python/pybackward.swg b/python/pybackward.swg
new file mode 100644
index 0000000..8305fc7
--- /dev/null
+++ b/python/pybackward.swg
@@ -0,0 +1,45 @@
+/*
+ adding backward compatibility macros
+*/
+
+#define SWIG_arg(x...) %arg(x)
+#define SWIG_Mangle(x...) %mangle(x)
+
+#define SWIG_As_frag(Type...) %fragment_name(As, Type)
+#define SWIG_As_name(Type...) %symbol_name(As, Type)
+#define SWIG_As(Type...) SWIG_As_name(Type) SWIG_AS_CALL_ARGS
+
+#define SWIG_Check_frag(Type...) %fragment_name(Check, Type)
+#define SWIG_Check_name(Type...) %symbol_name(Check, Type)
+#define SWIG_Check(Type...) SWIG_Check_name(Type) SWIG_AS_CALL_ARGS
+
+%define %ascheck_methods(Code, Type...)
+%fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) {
+SWIGINTERNINLINE Type
+SWIG_As(Type)(PyObject* obj)
+{
+ Type v;
+ int res = SWIG_AsVal(Type)(obj, &v);
+ if (!SWIG_IsOK(res)) {
+ /*
+ this is needed to make valgrind/purify happier.
+ */
+ memset((void*)&v, 0, sizeof(Type));
+ SWIG_Error(res, "");
+ }
+ return v;
+}
+}
+
+%fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) {
+SWIGINTERNINLINE int
+SWIG_Check(Type)(PyObject* obj)
+{
+ int res = SWIG_AsVal(Type)(obj, (Type*)0);
+ return SWIG_IsOK(res);
+}
+}
+%enddef
+
+%apply_checkctypes(%ascheck_methods)
+
diff --git a/python/pybuffer.i b/python/pybuffer.i
new file mode 100644
index 0000000..121cd70
--- /dev/null
+++ b/python/pybuffer.i
@@ -0,0 +1,107 @@
+/* Implementing buffer protocol typemaps */
+
+/* %pybuffer_mutable_binary(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept mutable buffer pointer with a size.
+ * This can be used for both input and output. For example:
+ *
+ * %pybuffer_mutable_binary(char *buff, int size);
+ * void foo(char *buff, int size) {
+ * for(int i=0; i<size; ++i)
+ * buff[i]++;
+ * }
+ */
+
+%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
+%typemap(in) (TYPEMAP, SIZE)
+ (int res, Py_ssize_t size = 0, void *buf = 0) {
+ res = PyObject_AsWriteBuffer($input, &buf, &size);
+ if (res<0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) (size/sizeof($*1_type));
+}
+%enddef
+
+/* %pybuffer_mutable_string(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept mutable zero terminated string pointer.
+ * This can be used for both input and output. For example:
+ *
+ * %pybuffer_mutable_string(char *str);
+ * void foo(char *str) {
+ * while(*str) {
+ * *str = toupper(*str);
+ * str++;
+ * }
+ */
+
+%define %pybuffer_mutable_string(TYPEMAP)
+%typemap(in) (TYPEMAP)
+ (int res, Py_ssize_t size = 0, void *buf = 0) {
+ res = PyObject_AsWriteBuffer($input, &buf, &size);
+ if (res<0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+}
+%enddef
+
+/* pybuffer_binary(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept read only buffer pointer with a size.
+ * This must be used for input. For example:
+ *
+ * %pybuffer_binary(char *buff, int size);
+ * int foo(char *buff, int size) {
+ * int count = 0;
+ * for(int i=0; i<size; ++i)
+ * if (0==buff[i]) count++;
+ * return count;
+ * }
+ */
+
+%define %pybuffer_binary(TYPEMAP, SIZE)
+%typemap(in) (TYPEMAP, SIZE)
+ (int res, Py_ssize_t size = 0, const void *buf = 0) {
+ res = PyObject_AsReadBuffer($input, &buf, &size);
+ if (res<0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) (size / sizeof($*1_type));
+}
+%enddef
+
+/* %pybuffer_string(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept read only zero terminated string pointer.
+ * This can be used for input. For example:
+ *
+ * %pybuffer_string(char *str);
+ * int foo(char *str) {
+ * int count = 0;
+ * while(*str) {
+ * if (isalnum(*str))
+ * count++;
+ * str++;
+ * }
+ */
+
+%define %pybuffer_string(TYPEMAP)
+%typemap(in) (TYPEMAP)
+ (int res, Py_ssize_t size = 0, const void *buf = 0) {
+ res = PyObject_AsReadBuffer($input, &buf, &size);
+ if (res<0) {
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+}
+%enddef
+
+
+
diff --git a/python/pyclasses.swg b/python/pyclasses.swg
new file mode 100644
index 0000000..65f6dec
--- /dev/null
+++ b/python/pyclasses.swg
@@ -0,0 +1,146 @@
+#ifdef __cplusplus
+
+/*
+ SwigPtr_PyObject is used as a replacement of PyObject *, where
+ the INCREF/DECREF are applied as needed.
+
+ You can use SwigPtr_PyObject in a container, such as
+
+ std::vector<SwigPtr_PyObject>;
+
+ or as a member variable:
+
+ struct A {
+ SwigPtr_PyObject obj;
+ A(PyObject *o) : _obj(o) {
+ }
+ };
+
+ or as a input/output value
+
+ SwigPtr_PyObject func(SwigPtr_PyObject obj) {
+ SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj));
+ Py_DECREF(out);
+ return out;
+ }
+
+ just remember to pair the object creation with the proper DECREF,
+ the same as with plain PyObject *ptr, since SwigPtr_PyObject always add
+ one reference at construction.
+
+ SwigPtr_PyObject is 'visible' at the wrapped side, so you can do:
+
+
+ %template(pyvector) std::vector<swig::SwigPtr_PyObject>;
+
+ and all the proper typemaps will be used.
+
+*/
+
+namespace swig {
+ %ignore SwigPtr_PyObject;
+ struct SwigPtr_PyObject {};
+ %apply PyObject * {SwigPtr_PyObject};
+ %apply PyObject * const& {SwigPtr_PyObject const&};
+
+ /* For output */
+ %typemap(out,noblock=1) SwigPtr_PyObject {
+ $result = (PyObject *)$1;
+ Py_INCREF($result);
+ }
+
+ %typemap(out,noblock=1) SwigPtr_PyObject const & {
+ $result = (PyObject *)*$1;
+ Py_INCREF($result);
+ }
+
+}
+
+%{
+namespace swig {
+ class SwigPtr_PyObject {
+ protected:
+ PyObject *_obj;
+
+ public:
+ SwigPtr_PyObject() :_obj(0)
+ {
+ }
+
+ SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
+ {
+ Py_XINCREF(_obj);
+ }
+
+ SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
+ {
+ if (initial_ref) {
+ Py_XINCREF(_obj);
+ }
+ }
+
+ SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
+ {
+ Py_XINCREF(item._obj);
+ Py_XDECREF(_obj);
+ _obj = item._obj;
+ return *this;
+ }
+
+ ~SwigPtr_PyObject()
+ {
+ Py_XDECREF(_obj);
+ }
+
+ operator PyObject *() const
+ {
+ return _obj;
+ }
+
+ PyObject *operator->() const
+ {
+ return _obj;
+ }
+ };
+}
+%}
+
+/*
+ SwigVar_PyObject is used to manage 'in the scope' PyObject * variables,
+ as in
+
+ int func () {
+ SwigVar_PyObject obj = PyString_FromString("hello");
+ }
+
+ ie, 'obj' is created and destructed in the same scope from
+ a python object that carries at least one reference value.
+
+ SwigVar_PyObject just take care of applying the proper Py_DECREF.
+
+ Hence, this class is purely internal and not visible at the wrapped side.
+ */
+namespace swig {
+ %ignore SwigVar_PyObject;
+ struct SwigVar_PyObject {};
+ %apply PyObject * {SwigVar_PyObject};
+ %apply PyObject * const& {SwigVar_PyObject const&};
+}
+
+%{
+namespace swig {
+ struct SwigVar_PyObject : SwigPtr_PyObject {
+ SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
+
+ SwigVar_PyObject & operator = (PyObject* obj)
+ {
+ Py_XDECREF(_obj);
+ _obj = obj;
+ return *this;
+ }
+ };
+}
+%}
+
+
+#endif
diff --git a/python/pycomplex.swg b/python/pycomplex.swg
new file mode 100644
index 0000000..74be5b9
--- /dev/null
+++ b/python/pycomplex.swg
@@ -0,0 +1,86 @@
+/*
+ Defines the As/From converters for double/float complex, you need to
+ provide complex Type, the Name you want to use in the converters,
+ the complex Constructor method, and the Real and Imag complex
+ accessor methods.
+
+ See the std_complex.i and ccomplex.i for concret examples.
+*/
+
+/* the common from converter */
+%define %swig_fromcplx_conv(Type, Real, Imag)
+%fragment(SWIG_From_frag(Type),"header")
+{
+SWIGINTERNINLINE PyObject*
+SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
+{
+ return PyComplex_FromDoubles(Real(c), Imag(c));
+}
+}
+%enddef
+
+/* the double case */
+%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(double))
+{
+SWIGINTERN int
+SWIG_AsVal(Type) (PyObject *o, Type* val)
+{
+ if (PyComplex_Check(o)) {
+ if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o));
+ return SWIG_OK;
+ } else {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
+ if (SWIG_IsOK(res)) {
+ if (val) *val = Constructor(d, 0.0);
+ return res;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+%swig_fromcplx_conv(Type, Real, Imag);
+%enddef
+
+/* the float case */
+%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(float)) {
+SWIGINTERN int
+SWIG_AsVal(Type)(PyObject *o, Type *val)
+{
+ if (PyComplex_Check(o)) {
+ double re = PyComplex_RealAsDouble(o);
+ double im = PyComplex_ImagAsDouble(o);
+ if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
+ if (val) *val = Constructor(%numeric_cast(re, float),
+ %numeric_cast(im, float));
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else {
+ float re;
+ int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
+ if (SWIG_IsOK(res)) {
+ if (val) *val = Constructor(re, 0.0);
+ return res;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+%swig_fromcplx_conv(Type, Real, Imag);
+%enddef
+
+#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
+%swig_cplxflt_conv(Type, Constructor, Real, Imag)
+
+
+#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
+%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
+
+
diff --git a/python/pycontainer.swg b/python/pycontainer.swg
new file mode 100644
index 0000000..7d7fdfc
--- /dev/null
+++ b/python/pycontainer.swg
@@ -0,0 +1,824 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pycontainer.swg
+ *
+ * Python sequence <-> C++ container wrapper
+ *
+ * This wrapper, and its iterator, allows a general use (and reuse) of
+ * the the mapping between C++ and Python, thanks to the C++
+ * templates.
+ *
+ * Of course, it needs the C++ compiler to support templates, but
+ * since we will use this wrapper with the STL containers, that should
+ * be the case.
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <iostream>
+%}
+
+
+#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS)
+# if !defined(SWIG_EXPORT_ITERATOR_METHODS)
+# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS
+# endif
+#endif
+
+%include <pyiterators.swg>
+
+/**** The PySequence C++ Wrap ***/
+
+%insert(header) %{
+#include <stdexcept>
+%}
+
+%include <std_except.i>
+
+%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") {
+namespace swig {
+ template <> struct traits<SwigPtr_PyObject > {
+ typedef value_category category;
+ static const char* type_name() { return "SwigPtr_PyObject"; }
+ };
+
+ template <> struct traits_from<SwigPtr_PyObject> {
+ typedef SwigPtr_PyObject value_type;
+ static PyObject *from(const value_type& val) {
+ PyObject *obj = static_cast<PyObject *>(val);
+ Py_XINCREF(obj);
+ return obj;
+ }
+ };
+
+ template <>
+ struct traits_check<SwigPtr_PyObject, value_category> {
+ static bool check(SwigPtr_PyObject) {
+ return true;
+ }
+ };
+
+ template <> struct traits_asval<SwigPtr_PyObject > {
+ typedef SwigPtr_PyObject value_type;
+ static int asval(PyObject *obj, value_type *val) {
+ if (val) *val = obj;
+ return SWIG_OK;
+ }
+ };
+}
+}
+
+%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") {
+namespace swig {
+ template <> struct traits<SwigVar_PyObject > {
+ typedef value_category category;
+ static const char* type_name() { return "SwigVar_PyObject"; }
+ };
+
+ template <> struct traits_from<SwigVar_PyObject> {
+ typedef SwigVar_PyObject value_type;
+ static PyObject *from(const value_type& val) {
+ PyObject *obj = static_cast<PyObject *>(val);
+ Py_XINCREF(obj);
+ return obj;
+ }
+ };
+
+ template <>
+ struct traits_check<SwigVar_PyObject, value_category> {
+ static bool check(SwigVar_PyObject) {
+ return true;
+ }
+ };
+
+ template <> struct traits_asval<SwigVar_PyObject > {
+ typedef SwigVar_PyObject value_type;
+ static int asval(PyObject *obj, value_type *val) {
+ if (val) *val = obj;
+ return SWIG_OK;
+ }
+ };
+}
+}
+
+%fragment("SwigPySequence_Base","header")
+{
+%#include <functional>
+
+namespace std {
+ template <>
+ struct less <PyObject *>: public binary_function<PyObject *, PyObject *, bool>
+ {
+ bool
+ operator()(PyObject * v, PyObject *w) const
+ {
+ bool res;
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false;
+ /* This may fall into a case of inconsistent
+ eg. ObjA > ObjX > ObjB
+ but ObjA < ObjB
+ */
+ if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) )
+ {
+ /* Objects can't be compared, this mostly occurred in Python 3.0 */
+ /* Compare their ptr directly for a workaround */
+ res = (v < w);
+ PyErr_Clear();
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return res;
+ }
+ };
+
+ template <>
+ struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool>
+ {
+ bool
+ operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const
+ {
+ return std::less<PyObject *>()(v, w);
+ }
+ };
+
+ template <>
+ struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool>
+ {
+ bool
+ operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const
+ {
+ return std::less<PyObject *>()(v, w);
+ }
+ };
+
+}
+
+namespace swig {
+ template <> struct traits<PyObject *> {
+ typedef value_category category;
+ static const char* type_name() { return "PyObject *"; }
+ };
+
+ template <> struct traits_asval<PyObject * > {
+ typedef PyObject * value_type;
+ static int asval(PyObject *obj, value_type *val) {
+ if (val) *val = obj;
+ return SWIG_OK;
+ }
+ };
+
+ template <>
+ struct traits_check<PyObject *, value_category> {
+ static bool check(PyObject *) {
+ return true;
+ }
+ };
+
+ template <> struct traits_from<PyObject *> {
+ typedef PyObject * value_type;
+ static PyObject *from(const value_type& val) {
+ Py_XINCREF(val);
+ return val;
+ }
+ };
+
+}
+
+namespace swig {
+ inline size_t
+ check_index(ptrdiff_t i, size_t size, bool insert = false) {
+ if ( i < 0 ) {
+ if ((size_t) (-i) <= size)
+ return (size_t) (i + size);
+ } else if ( (size_t) i < size ) {
+ return (size_t) i;
+ } else if (insert && ((size_t) i == size)) {
+ return size;
+ }
+
+ throw std::out_of_range("index out of range");
+ }
+
+ inline size_t
+ slice_index(ptrdiff_t i, size_t size) {
+ if ( i < 0 ) {
+ if ((size_t) (-i) <= size) {
+ return (size_t) (i + size);
+ } else {
+ throw std::out_of_range("index out of range");
+ }
+ } else {
+ return ( (size_t) i < size ) ? ((size_t) i) : size;
+ }
+ }
+
+ template <class Sequence, class Difference>
+ inline typename Sequence::iterator
+ getpos(Sequence* self, Difference i) {
+ typename Sequence::iterator pos = self->begin();
+ std::advance(pos, check_index(i,self->size()));
+ return pos;
+ }
+
+ template <class Sequence, class Difference>
+ inline typename Sequence::const_iterator
+ cgetpos(const Sequence* self, Difference i) {
+ typename Sequence::const_iterator pos = self->begin();
+ std::advance(pos, check_index(i,self->size()));
+ return pos;
+ }
+
+ template <class Sequence, class Difference>
+ inline Sequence*
+ getslice(const Sequence* self, Difference i, Difference j) {
+ typename Sequence::size_type size = self->size();
+ typename Sequence::size_type ii = swig::check_index(i, size);
+ typename Sequence::size_type jj = swig::slice_index(j, size);
+
+ if (jj > ii) {
+ typename Sequence::const_iterator vb = self->begin();
+ typename Sequence::const_iterator ve = self->begin();
+ std::advance(vb,ii);
+ std::advance(ve,jj);
+ return new Sequence(vb, ve);
+ } else {
+ return new Sequence();
+ }
+ }
+
+ template <class Sequence, class Difference, class InputSeq>
+ inline void
+ setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) {
+ typename Sequence::size_type size = self->size();
+ typename Sequence::size_type ii = swig::check_index(i, size, true);
+ typename Sequence::size_type jj = swig::slice_index(j, size);
+ if (jj < ii) jj = ii;
+ size_t ssize = jj - ii;
+ if (ssize <= v.size()) {
+ typename Sequence::iterator sb = self->begin();
+ typename InputSeq::const_iterator vmid = v.begin();
+ std::advance(sb,ii);
+ std::advance(vmid, jj - ii);
+ self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end());
+ } else {
+ typename Sequence::iterator sb = self->begin();
+ typename Sequence::iterator se = self->begin();
+ std::advance(sb,ii);
+ std::advance(se,jj);
+ self->erase(sb,se);
+ self->insert(sb, v.begin(), v.end());
+ }
+ }
+
+ template <class Sequence, class Difference>
+ inline void
+ delslice(Sequence* self, Difference i, Difference j) {
+ typename Sequence::size_type size = self->size();
+ typename Sequence::size_type ii = swig::check_index(i, size, true);
+ typename Sequence::size_type jj = swig::slice_index(j, size);
+ if (jj > ii) {
+ typename Sequence::iterator sb = self->begin();
+ typename Sequence::iterator se = self->begin();
+ std::advance(sb,ii);
+ std::advance(se,jj);
+ self->erase(sb,se);
+ }
+ }
+}
+}
+
+%fragment("SwigPySequence_Cont","header",
+ fragment="StdTraits",
+ fragment="SwigPySequence_Base",
+ fragment="SwigPyIterator_T")
+{
+namespace swig
+{
+ template <class T>
+ struct SwigPySequence_Ref
+ {
+ SwigPySequence_Ref(PyObject* seq, int index)
+ : _seq(seq), _index(index)
+ {
+ }
+
+ operator T () const
+ {
+ swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
+ try {
+ return swig::as<T>(item, true);
+ } catch (std::exception& e) {
+ char msg[1024];
+ sprintf(msg, "in sequence element %d ", _index);
+ if (!PyErr_Occurred()) {
+ ::%type_error(swig::type_name<T>());
+ }
+ SWIG_Python_AddErrorMsg(msg);
+ SWIG_Python_AddErrorMsg(e.what());
+ throw;
+ }
+ }
+
+ SwigPySequence_Ref& operator=(const T& v)
+ {
+ PySequence_SetItem(_seq, _index, swig::from<T>(v));
+ return *this;
+ }
+
+ private:
+ PyObject* _seq;
+ int _index;
+ };
+
+ template <class T>
+ struct SwigPySequence_ArrowProxy
+ {
+ SwigPySequence_ArrowProxy(const T& x): m_value(x) {}
+ const T* operator->() const { return &m_value; }
+ operator const T*() const { return &m_value; }
+ T m_value;
+ };
+
+ template <class T, class Reference >
+ struct SwigPySequence_InputIterator
+ {
+ typedef SwigPySequence_InputIterator<T, Reference > self;
+
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef Reference reference;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef int difference_type;
+
+ SwigPySequence_InputIterator()
+ {
+ }
+
+ SwigPySequence_InputIterator(PyObject* seq, int index)
+ : _seq(seq), _index(index)
+ {
+ }
+
+ reference operator*() const
+ {
+ return reference(_seq, _index);
+ }
+
+ SwigPySequence_ArrowProxy<T>
+ operator->() const {
+ return SwigPySequence_ArrowProxy<T>(operator*());
+ }
+
+ bool operator==(const self& ri) const
+ {
+ return (_index == ri._index) && (_seq == ri._seq);
+ }
+
+ bool operator!=(const self& ri) const
+ {
+ return !(operator==(ri));
+ }
+
+ self& operator ++ ()
+ {
+ ++_index;
+ return *this;
+ }
+
+ self& operator -- ()
+ {
+ --_index;
+ return *this;
+ }
+
+ self& operator += (difference_type n)
+ {
+ _index += n;
+ return *this;
+ }
+
+ self operator +(difference_type n) const
+ {
+ return self(_seq, _index + n);
+ }
+
+ self& operator -= (difference_type n)
+ {
+ _index -= n;
+ return *this;
+ }
+
+ self operator -(difference_type n) const
+ {
+ return self(_seq, _index - n);
+ }
+
+ difference_type operator - (const self& ri) const
+ {
+ return _index - ri._index;
+ }
+
+ bool operator < (const self& ri) const
+ {
+ return _index < ri._index;
+ }
+
+ reference
+ operator[](difference_type n) const
+ {
+ return reference(_seq, _index + n);
+ }
+
+ private:
+ PyObject* _seq;
+ difference_type _index;
+ };
+
+ template <class T>
+ struct SwigPySequence_Cont
+ {
+ typedef SwigPySequence_Ref<T> reference;
+ typedef const SwigPySequence_Ref<T> const_reference;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef int difference_type;
+ typedef int size_type;
+ typedef const pointer const_pointer;
+ typedef SwigPySequence_InputIterator<T, reference> iterator;
+ typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
+
+ SwigPySequence_Cont(PyObject* seq) : _seq(0)
+ {
+ if (!PySequence_Check(seq)) {
+ throw std::invalid_argument("a sequence is expected");
+ }
+ _seq = seq;
+ Py_INCREF(_seq);
+ }
+
+ ~SwigPySequence_Cont()
+ {
+ Py_XDECREF(_seq);
+ }
+
+ size_type size() const
+ {
+ return static_cast<size_type>(PySequence_Size(_seq));
+ }
+
+ bool empty() const
+ {
+ return size() == 0;
+ }
+
+ iterator begin()
+ {
+ return iterator(_seq, 0);
+ }
+
+ const_iterator begin() const
+ {
+ return const_iterator(_seq, 0);
+ }
+
+ iterator end()
+ {
+ return iterator(_seq, size());
+ }
+
+ const_iterator end() const
+ {
+ return const_iterator(_seq, size());
+ }
+
+ reference operator[](difference_type n)
+ {
+ return reference(_seq, n);
+ }
+
+ const_reference operator[](difference_type n) const
+ {
+ return const_reference(_seq, n);
+ }
+
+ bool check(bool set_err = true) const
+ {
+ int s = size();
+ for (int i = 0; i < s; ++i) {
+ swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
+ if (!swig::check<value_type>(item)) {
+ if (set_err) {
+ char msg[1024];
+ sprintf(msg, "in sequence element %d", i);
+ SWIG_Error(SWIG_RuntimeError, msg);
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private:
+ PyObject* _seq;
+ };
+
+}
+}
+
+%define %swig_sequence_iterator(Sequence...)
+#if defined(SWIG_EXPORT_ITERATOR_METHODS)
+ class iterator;
+ class reverse_iterator;
+ class const_iterator;
+ class const_reverse_iterator;
+
+ %typemap(out,noblock=1,fragment="SwigPySequence_Cont")
+ iterator, reverse_iterator, const_iterator, const_reverse_iterator {
+ $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+ }
+ %typemap(out,noblock=1,fragment="SwigPySequence_Cont")
+ std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
+ $result = PyTuple_New(2);
+ PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
+ PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second),
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
+ }
+
+ %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {}
+
+ %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator")
+ std::pair<iterator, bool>, std::pair<const_iterator, bool> {
+ $result = PyTuple_New(2);
+ PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
+ PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second));
+ }
+
+ %typemap(in,noblock=1,fragment="SwigPySequence_Cont")
+ iterator(swig::SwigPyIterator *iter = 0, int res),
+ reverse_iterator(swig::SwigPyIterator *iter = 0, int res),
+ const_iterator(swig::SwigPyIterator *iter = 0, int res),
+ const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) {
+ res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+ if (!SWIG_IsOK(res) || !iter) {
+ %argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
+ } else {
+ swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter);
+ if (iter_t) {
+ $1 = iter_t->get_current();
+ } else {
+ %argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
+ }
+ }
+ }
+
+ %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont")
+ iterator, reverse_iterator, const_iterator, const_reverse_iterator {
+ swig::SwigPyIterator *iter = 0;
+ int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+ $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter) != 0));
+ }
+
+ %fragment("SwigPySequence_Cont");
+
+ %newobject iterator(PyObject **PYTHON_SELF);
+ %extend {
+ swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) {
+ return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+ }
+
+ %pythoncode {def __iter__(self): return self.iterator()}
+ }
+#endif //SWIG_EXPORT_ITERATOR_METHODS
+%enddef
+
+
+/**** The python container methods ****/
+
+
+%define %swig_container_methods(Container...)
+
+ %newobject __getslice__;
+
+ %extend {
+ bool __nonzero__() const {
+ return !(self->empty());
+ }
+
+ /* Alias for Python 3 compatibility */
+ bool __bool__() const {
+ return !(self->empty());
+ }
+
+ size_type __len__() const {
+ return self->size();
+ }
+ }
+%enddef
+
+%define %swig_sequence_methods_common(Sequence...)
+ %swig_sequence_iterator(%arg(Sequence))
+ %swig_container_methods(%arg(Sequence))
+
+ %fragment("SwigPySequence_Base");
+
+ %extend {
+ value_type pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty container");
+ Sequence::value_type x = self->back();
+ self->pop_back();
+ return x;
+ }
+
+ /* typemap for slice object support */
+ %typemap(in) PySliceObject* {
+ $1 = (PySliceObject *) $input;
+ }
+ %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* {
+ $1 = PySlice_Check($input);
+ }
+
+ Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
+ return swig::getslice(self, i, j);
+ }
+
+ void __setslice__(difference_type i, difference_type j, const Sequence& v)
+ throw (std::out_of_range, std::invalid_argument) {
+ swig::setslice(self, i, j, v);
+ }
+
+ void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) {
+ swig::delslice(self, i, j);
+ }
+
+ void __delitem__(difference_type i) throw (std::out_of_range) {
+ self->erase(swig::getpos(self,i));
+ }
+
+
+ /* Overloaded methods for Python 3 compatibility
+ * (Also useful in Python 2.x)
+ */
+ Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+ return NULL;
+ }
+ PySlice_GetIndices(slice, self->size(), &i, &j, &step);
+ return swig::getslice(self, i, j);
+ }
+
+ void __setitem__(PySliceObject *slice, const Sequence& v)
+ throw (std::out_of_range, std::invalid_argument) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+ return;
+ }
+ PySlice_GetIndices(slice, self->size(), &i, &j, &step);
+ swig::setslice(self, i, j, v);
+ }
+
+ void __delitem__(PySliceObject *slice)
+ throw (std::out_of_range) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+ return;
+ }
+ PySlice_GetIndices(slice, self->size(), &i, &j, &step);
+ swig::delslice(self, i,j);
+ }
+
+ }
+%enddef
+
+%define %swig_sequence_methods(Sequence...)
+ %swig_sequence_methods_common(%arg(Sequence))
+ %extend {
+ const value_type& __getitem__(difference_type i) const throw (std::out_of_range) {
+ return *(swig::cgetpos(self, i));
+ }
+
+ void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) {
+ *(swig::getpos(self,i)) = x;
+ }
+
+ void append(const value_type& x) {
+ self->push_back(x);
+ }
+ }
+%enddef
+
+%define %swig_sequence_methods_val(Sequence...)
+ %swig_sequence_methods_common(%arg(Sequence))
+ %extend {
+ value_type __getitem__(difference_type i) throw (std::out_of_range) {
+ return *(swig::cgetpos(self, i));
+ }
+
+ void __setitem__(difference_type i, value_type x) throw (std::out_of_range) {
+ *(swig::getpos(self,i)) = x;
+ }
+
+ void append(value_type x) {
+ self->push_back(x);
+ }
+ }
+%enddef
+
+
+
+//
+// Common fragments
+//
+
+%fragment("StdSequenceTraits","header",
+ fragment="StdTraits",
+ fragment="SwigPySequence_Cont")
+{
+namespace swig {
+ template <class SwigPySeq, class Seq>
+ inline void
+ assign(const SwigPySeq& swigpyseq, Seq* seq) {
+ // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+ }
+
+ template <class Seq, class T = typename Seq::value_type >
+ struct traits_asptr_stdseq {
+ typedef Seq sequence;
+ typedef T value_type;
+
+ static int asptr(PyObject *obj, sequence **seq) {
+ if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) {
+ sequence *p;
+ if (::SWIG_ConvertPtr(obj,(void**)&p,
+ swig::type_info<sequence>(),0) == SWIG_OK) {
+ if (seq) *seq = p;
+ return SWIG_OLDOBJ;
+ }
+ } else if (PySequence_Check(obj)) {
+ try {
+ SwigPySequence_Cont<value_type> swigpyseq(obj);
+ if (seq) {
+ sequence *pseq = new sequence();
+ assign(swigpyseq, pseq);
+ *seq = pseq;
+ return SWIG_NEWOBJ;
+ } else {
+ return swigpyseq.check() ? SWIG_OK : SWIG_ERROR;
+ }
+ } catch (std::exception& e) {
+ if (seq) {
+ if (!PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError, e.what());
+ }
+ }
+ return SWIG_ERROR;
+ }
+ }
+ return SWIG_ERROR;
+ }
+ };
+
+ template <class Seq, class T = typename Seq::value_type >
+ struct traits_from_stdseq {
+ typedef Seq sequence;
+ typedef T value_type;
+ typedef typename Seq::size_type size_type;
+ typedef typename sequence::const_iterator const_iterator;
+
+ static PyObject *from(const sequence& seq) {
+%#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS
+ swig_type_info *desc = swig::type_info<sequence>();
+ if (desc && desc->clientdata) {
+ return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
+ }
+%#endif
+ size_type size = seq.size();
+ if (size <= (size_type)INT_MAX) {
+ PyObject *obj = PyTuple_New((int)size);
+ int i = 0;
+ for (const_iterator it = seq.begin();
+ it != seq.end(); ++it, ++i) {
+ PyTuple_SetItem(obj,i,swig::from<value_type>(*it));
+ }
+ return obj;
+ } else {
+ PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python");
+ return NULL;
+ }
+ }
+ };
+}
+}
diff --git a/python/pydocs.swg b/python/pydocs.swg
new file mode 100644
index 0000000..0091a30
--- /dev/null
+++ b/python/pydocs.swg
@@ -0,0 +1,18 @@
+
+// basic doc for primitive types....
+
+#ifdef SWIG_DOC_DOXYGEN_STYLE
+%typemap(doc) SWIGTYPE "@param $1_name $1_type value";
+%typemap(doc) SWIGTYPE* "@param $1_name $1_type value";
+%typemap(doc) const SWIGTYPE& "@param $1_name $1_type value";
+%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type value";
+#else
+%typemap(doc) SWIGTYPE "$1_name: $1_type value";
+%typemap(doc) SWIGTYPE* "$1_name: $1_type value";
+%typemap(doc) const SWIGTYPE& "$1_name: $1_type value";
+%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type value";
+
+%typemap(doc) SWIGTYPE *INOUT "$1_name: $1_type input/ouput value";
+%typemap(doc) SWIGTYPE *INPUT "$1_name: $1_type input value";
+%typemap(doc) SWIGTYPE *OUTPUT "$1_name: $1_type output value";
+#endif
diff --git a/python/pyerrors.swg b/python/pyerrors.swg
new file mode 100644
index 0000000..fe73135
--- /dev/null
+++ b/python/pyerrors.swg
@@ -0,0 +1,70 @@
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIME PyObject*
+SWIG_Python_ErrorType(int code) {
+ PyObject* type = 0;
+ switch(code) {
+ case SWIG_MemoryError:
+ type = PyExc_MemoryError;
+ break;
+ case SWIG_IOError:
+ type = PyExc_IOError;
+ break;
+ case SWIG_RuntimeError:
+ type = PyExc_RuntimeError;
+ break;
+ case SWIG_IndexError:
+ type = PyExc_IndexError;
+ break;
+ case SWIG_TypeError:
+ type = PyExc_TypeError;
+ break;
+ case SWIG_DivisionByZero:
+ type = PyExc_ZeroDivisionError;
+ break;
+ case SWIG_OverflowError:
+ type = PyExc_OverflowError;
+ break;
+ case SWIG_SyntaxError:
+ type = PyExc_SyntaxError;
+ break;
+ case SWIG_ValueError:
+ type = PyExc_ValueError;
+ break;
+ case SWIG_SystemError:
+ type = PyExc_SystemError;
+ break;
+ case SWIG_AttributeError:
+ type = PyExc_AttributeError;
+ break;
+ default:
+ type = PyExc_RuntimeError;
+ }
+ return type;
+}
+
+
+SWIGRUNTIME void
+SWIG_Python_AddErrorMsg(const char* mesg)
+{
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+
+ if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ char *tmp;
+ PyObject *old_str = PyObject_Str(value);
+ PyErr_Clear();
+ Py_XINCREF(type);
+
+ PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+ SWIG_Python_str_DelForPy3(tmp);
+ Py_DECREF(old_str);
+ Py_DECREF(value);
+ } else {
+ PyErr_SetString(PyExc_RuntimeError, mesg);
+ }
+}
diff --git a/python/pyfragments.swg b/python/pyfragments.swg
new file mode 100644
index 0000000..535a45b
--- /dev/null
+++ b/python/pyfragments.swg
@@ -0,0 +1,23 @@
+/*
+
+ Create a file with this name, 'pyfragments.swg', in your working
+ directory and add all the %fragments you want to take precedence
+ over the default ones defined by swig.
+
+ For example, if you add:
+
+ %fragment(SWIG_AsVal_frag(int),"header") {
+ SWIGINTERNINLINE int
+ SWIG_AsVal(int)(PyObject *obj, int *val)
+ {
+ <your code here>;
+ }
+ }
+
+ this will replace the code used to retrieve an integer value for all
+ the typemaps that need it, including:
+
+ int, std::vector<int>, std::list<std::pair<int,int> >, etc.
+
+
+*/
diff --git a/python/pyhead.swg b/python/pyhead.swg
new file mode 100644
index 0000000..2edbf63
--- /dev/null
+++ b/python/pyhead.swg
@@ -0,0 +1,148 @@
+/* Compatibility macros for Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+
+#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
+#define PyInt_Check(x) PyLong_Check(x)
+#define PyInt_AsLong(x) PyLong_AsLong(x)
+#define PyInt_FromLong(x) PyLong_FromLong(x)
+#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
+
+#endif
+
+#ifndef Py_TYPE
+# define Py_TYPE(op) ((op)->ob_type)
+#endif
+
+/* SWIG APIs for compatibility of both Python 2 & 3 */
+
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_Python_str_FromFormat PyUnicode_FromFormat
+#else
+# define SWIG_Python_str_FromFormat PyString_FromFormat
+#endif
+
+
+/* Warning: This function will allocate a new string in Python 3,
+ * so please call SWIG_Python_str_DelForPy3(x) to free the space.
+ */
+SWIGINTERN char*
+SWIG_Python_str_AsChar(PyObject *str)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ char *cstr;
+ char *newstr;
+ Py_ssize_t len;
+ str = PyUnicode_AsUTF8String(str);
+ PyBytes_AsStringAndSize(str, &cstr, &len);
+ newstr = (char *) malloc(len+1);
+ memcpy(newstr, cstr, len+1);
+ Py_XDECREF(str);
+ return newstr;
+#else
+ return PyString_AsString(str);
+#endif
+}
+
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
+#else
+# define SWIG_Python_str_DelForPy3(x)
+#endif
+
+
+SWIGINTERN PyObject*
+SWIG_Python_str_FromChar(const char *c)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_FromString(c);
+#else
+ return PyString_FromString(c);
+#endif
+}
+
+/* Add PyOS_snprintf for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
+# define PyOS_snprintf _snprintf
+# else
+# define PyOS_snprintf snprintf
+# endif
+#endif
+
+/* A crude PyString_FromFormat implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+
+#ifndef SWIG_PYBUFFER_SIZE
+# define SWIG_PYBUFFER_SIZE 1024
+#endif
+
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+ va_list ap;
+ char buf[SWIG_PYBUFFER_SIZE * 2];
+ int res;
+ va_start(ap, fmt);
+ res = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
+}
+#endif
+
+/* Add PyObject_Del for old Pythons */
+#if PY_VERSION_HEX < 0x01060000
+# define PyObject_Del(op) PyMem_DEL((op))
+#endif
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
+
+/* A crude PyExc_StopIteration exception for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# ifndef PyExc_StopIteration
+# define PyExc_StopIteration PyExc_RuntimeError
+# endif
+# ifndef PyObject_GenericGetAttr
+# define PyObject_GenericGetAttr 0
+# endif
+#endif
+
+/* Py_NotImplemented is defined in 2.1 and up. */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef Py_NotImplemented
+# define Py_NotImplemented PyExc_RuntimeError
+# endif
+#endif
+
+/* A crude PyString_AsStringAndSize implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef PyString_AsStringAndSize
+# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
+# endif
+#endif
+
+/* PySequence_Size for old Pythons */
+#if PY_VERSION_HEX < 0x02000000
+# ifndef PySequence_Size
+# define PySequence_Size PySequence_Length
+# endif
+#endif
+
+/* PyBool_FromLong for old Pythons */
+#if PY_VERSION_HEX < 0x02030000
+static
+PyObject *PyBool_FromLong(long ok)
+{
+ PyObject *result = ok ? Py_True : Py_False;
+ Py_INCREF(result);
+ return result;
+}
+#endif
+
+/* Py_ssize_t for old Pythons */
+/* This code is as recommended by: */
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+#endif
diff --git a/python/pyinit.swg b/python/pyinit.swg
new file mode 100644
index 0000000..058934b
--- /dev/null
+++ b/python/pyinit.swg
@@ -0,0 +1,352 @@
+/* ------------------------------------------------------------
+ * The start of the Python initialization function
+ * ------------------------------------------------------------ */
+
+%insert(init) "swiginit.swg"
+
+%init %{
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Python-specific SWIG API */
+#define SWIG_newvarlink() SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
+
+/* -----------------------------------------------------------------------------
+ * global variable support code.
+ * ----------------------------------------------------------------------------- */
+
+typedef struct swig_globalvar {
+ char *name; /* Name of global variable */
+ PyObject *(*get_attr)(void); /* Return the current value */
+ int (*set_attr)(PyObject *); /* Set the value */
+ struct swig_globalvar *next;
+} swig_globalvar;
+
+typedef struct swig_varlinkobject {
+ PyObject_HEAD
+ swig_globalvar *vars;
+} swig_varlinkobject;
+
+SWIGINTERN PyObject *
+swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_InternFromString("<Swig global variables>");
+#else
+ return PyString_FromString("<Swig global variables>");
+#endif
+}
+
+SWIGINTERN PyObject *
+swig_varlink_str(swig_varlinkobject *v) {
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject *str = PyUnicode_InternFromString("(");
+ PyObject *tail;
+ PyObject *joined;
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ tail = PyUnicode_FromString(var->name);
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+ if (var->next) {
+ tail = PyUnicode_InternFromString(", ");
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+ }
+ }
+ tail = PyUnicode_InternFromString(")");
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+#else
+ PyObject *str = PyString_FromString("(");
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ PyString_ConcatAndDel(&str,PyString_FromString(var->name));
+ if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
+ }
+ PyString_ConcatAndDel(&str,PyString_FromString(")"));
+#endif
+ return str;
+}
+
+SWIGINTERN int
+swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+ char *tmp;
+ PyObject *str = swig_varlink_str(v);
+ fprintf(fp,"Swig global variables ");
+ fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
+ SWIG_Python_str_DelForPy3(tmp);
+ Py_DECREF(str);
+ return 0;
+}
+
+SWIGINTERN void
+swig_varlink_dealloc(swig_varlinkobject *v) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ swig_globalvar *n = var->next;
+ free(var->name);
+ free(var);
+ var = n;
+ }
+}
+
+SWIGINTERN PyObject *
+swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+ PyObject *res = NULL;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->get_attr)();
+ break;
+ }
+ var = var->next;
+ }
+ if (res == NULL && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+}
+
+SWIGINTERN int
+swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+ int res = 1;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->set_attr)(p);
+ break;
+ }
+ var = var->next;
+ }
+ if (res == 1 && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+}
+
+SWIGINTERN PyTypeObject*
+swig_varlink_type(void) {
+ static char varlink__doc__[] = "Swig var link object";
+ static PyTypeObject varlink_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* Number of items in variable part (ob_size) */
+#endif
+ (char *)"swigvarlink", /* Type name (tp_name) */
+ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
+ 0, /* Itemsize (tp_itemsize) */
+ (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
+ (printfunc) swig_varlink_print, /* Print (tp_print) */
+ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
+ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
+ 0, /* tp_compare */
+ (reprfunc) swig_varlink_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ (reprfunc) swig_varlink_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_flags */
+ varlink__doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ varlink_type = tmp;
+ /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
+#if PY_VERSION_HEX < 0x03000000
+ varlink_type.ob_type = &PyType_Type;
+#endif
+ type_init = 1;
+ }
+ return &varlink_type;
+}
+
+/* Create a variable linking object for use later */
+SWIGINTERN PyObject *
+SWIG_Python_newvarlink(void) {
+ swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+ if (result) {
+ result->vars = 0;
+ }
+ return ((PyObject*) result);
+}
+
+SWIGINTERN void
+SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+ swig_varlinkobject *v = (swig_varlinkobject *) p;
+ swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+ if (gv) {
+ size_t size = strlen(name)+1;
+ gv->name = (char *)malloc(size);
+ if (gv->name) {
+ strncpy(gv->name,name,size);
+ gv->get_attr = get_attr;
+ gv->set_attr = set_attr;
+ gv->next = v->vars;
+ }
+ }
+ v->vars = gv;
+}
+
+SWIGINTERN PyObject *
+SWIG_globals(void) {
+ static PyObject *_SWIG_globals = 0;
+ if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
+ return _SWIG_globals;
+}
+
+/* -----------------------------------------------------------------------------
+ * constants/methods manipulation
+ * ----------------------------------------------------------------------------- */
+
+/* Install Constants */
+SWIGINTERN void
+SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+ PyObject *obj = 0;
+ size_t i;
+ for (i = 0; constants[i].type; ++i) {
+ switch(constants[i].type) {
+ case SWIG_PY_POINTER:
+ obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+ break;
+ case SWIG_PY_BINARY:
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+ break;
+ default:
+ obj = 0;
+ break;
+ }
+ if (obj) {
+ PyDict_SetItemString(d, constants[i].name, obj);
+ Py_DECREF(obj);
+ }
+ }
+}
+
+/* -----------------------------------------------------------------------------*/
+/* Fix SwigMethods to carry the callback ptrs when needed */
+/* -----------------------------------------------------------------------------*/
+
+SWIGINTERN void
+SWIG_Python_FixMethods(PyMethodDef *methods,
+ swig_const_info *const_table,
+ swig_type_info **types,
+ swig_type_info **types_initial) {
+ size_t i;
+ for (i = 0; methods[i].ml_name; ++i) {
+ const char *c = methods[i].ml_doc;
+ if (c && (c = strstr(c, "swig_ptr: "))) {
+ int j;
+ swig_const_info *ci = 0;
+ const char *name = c + 10;
+ for (j = 0; const_table[j].type; ++j) {
+ if (strncmp(const_table[j].name, name,
+ strlen(const_table[j].name)) == 0) {
+ ci = &(const_table[j]);
+ break;
+ }
+ }
+ if (ci) {
+ size_t shift = (ci->ptype) - types;
+ swig_type_info *ty = types_initial[shift];
+ size_t ldoc = (c - methods[i].ml_doc);
+ size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+ char *ndoc = (char*)malloc(ldoc + lptr + 10);
+ if (ndoc) {
+ char *buff = ndoc;
+ void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+ if (ptr) {
+ strncpy(buff, methods[i].ml_doc, ldoc);
+ buff += ldoc;
+ strncpy(buff, "swig_ptr: ", 10);
+ buff += 10;
+ SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+ methods[i].ml_doc = ndoc;
+ }
+ }
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ * Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+SWIGEXPORT
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject*
+#else
+ void
+#endif
+SWIG_init(void) {
+ PyObject *m, *d;
+#if PY_VERSION_HEX >= 0x03000000
+ static struct PyModuleDef SWIG_module = {
+ PyModuleDef_HEAD_INIT,
+ (char *) SWIG_name,
+ NULL,
+ -1,
+ SwigMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+#endif
+
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+
+#if PY_VERSION_HEX >= 0x03000000
+ m = PyModule_Create(&SWIG_module);
+#else
+ m = Py_InitModule((char *) SWIG_name, SwigMethods);
+#endif
+ d = PyModule_GetDict(m);
+
+ SWIG_InitializeModule(0);
+ SWIG_InstallConstants(d,swig_const_table);
+
+%}
+
diff --git a/python/pyiterators.swg b/python/pyiterators.swg
new file mode 100644
index 0000000..8719f73
--- /dev/null
+++ b/python/pyiterators.swg
@@ -0,0 +1,393 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pyiterators.swg
+ *
+ * Implement a python 'output' iterator for Python 2.2 or higher.
+ *
+ * Users can derive form the SwigPyIterator to implement their
+ * own iterators. As an example (real one since we use it for STL/STD
+ * containers), the template SwigPyIterator_T does the
+ * implementation for generic C++ iterators.
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+%fragment("SwigPyIterator","header") {
+namespace swig {
+ struct stop_iteration {
+ };
+
+ struct SwigPyIterator {
+ private:
+ SwigPtr_PyObject _seq;
+
+ protected:
+ SwigPyIterator(PyObject *seq) : _seq(seq)
+ {
+ }
+
+ public:
+ virtual ~SwigPyIterator() {}
+
+ // Access iterator method, required by Python
+ virtual PyObject *value() const = 0;
+
+ // Forward iterator method, required by Python
+ virtual SwigPyIterator *incr(size_t n = 1) = 0;
+
+ // Backward iterator method, very common in C++, but not required in Python
+ virtual SwigPyIterator *decr(size_t /*n*/ = 1)
+ {
+ throw stop_iteration();
+ }
+
+ // Random access iterator methods, but not required in Python
+ virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const
+ {
+ throw std::invalid_argument("operation not supported");
+ }
+
+ virtual bool equal (const SwigPyIterator &/*x*/) const
+ {
+ throw std::invalid_argument("operation not supported");
+ }
+
+ // C++ common/needed methods
+ virtual SwigPyIterator *copy() const = 0;
+
+ PyObject *next()
+ {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads
+ PyObject *obj = value();
+ incr();
+ SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
+ return obj;
+ }
+
+ /* Make an alias for Python 3.x */
+ PyObject *__next__()
+ {
+ return next();
+ }
+
+ PyObject *previous()
+ {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads
+ decr();
+ PyObject *obj = value();
+ SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
+ return obj;
+ }
+
+ SwigPyIterator *advance(ptrdiff_t n)
+ {
+ return (n > 0) ? incr(n) : decr(-n);
+ }
+
+ bool operator == (const SwigPyIterator& x) const
+ {
+ return equal(x);
+ }
+
+ bool operator != (const SwigPyIterator& x) const
+ {
+ return ! operator==(x);
+ }
+
+ SwigPyIterator& operator += (ptrdiff_t n)
+ {
+ return *advance(n);
+ }
+
+ SwigPyIterator& operator -= (ptrdiff_t n)
+ {
+ return *advance(-n);
+ }
+
+ SwigPyIterator* operator + (ptrdiff_t n) const
+ {
+ return copy()->advance(n);
+ }
+
+ SwigPyIterator* operator - (ptrdiff_t n) const
+ {
+ return copy()->advance(-n);
+ }
+
+ ptrdiff_t operator - (const SwigPyIterator& x) const
+ {
+ return x.distance(*this);
+ }
+
+ static swig_type_info* descriptor() {
+ static int init = 0;
+ static swig_type_info* desc = 0;
+ if (!init) {
+ desc = SWIG_TypeQuery("swig::SwigPyIterator *");
+ init = 1;
+ }
+ return desc;
+ }
+ };
+}
+}
+
+%fragment("SwigPyIterator_T","header",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
+namespace swig {
+ template<typename OutIterator>
+ class SwigPyIterator_T : public SwigPyIterator
+ {
+ public:
+ typedef OutIterator out_iterator;
+ typedef typename std::iterator_traits<out_iterator>::value_type value_type;
+ typedef SwigPyIterator_T<out_iterator> self_type;
+
+ SwigPyIterator_T(out_iterator curr, PyObject *seq)
+ : SwigPyIterator(seq), current(curr)
+ {
+ }
+
+ const out_iterator& get_current() const
+ {
+ return current;
+ }
+
+
+ bool equal (const SwigPyIterator &iter) const
+ {
+ const self_type *iters = dynamic_cast<const self_type *>(&iter);
+ if (iters) {
+ return (current == iters->get_current());
+ } else {
+ throw std::invalid_argument("bad iterator type");
+ }
+ }
+
+ ptrdiff_t distance(const SwigPyIterator &iter) const
+ {
+ const self_type *iters = dynamic_cast<const self_type *>(&iter);
+ if (iters) {
+ return std::distance(current, iters->get_current());
+ } else {
+ throw std::invalid_argument("bad iterator type");
+ }
+ }
+
+ protected:
+ out_iterator current;
+ };
+
+ template <class ValueType>
+ struct from_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef PyObject *result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v);
+ }
+ };
+
+ template<typename OutIterator,
+ typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
+ typename FromOper = from_oper<ValueType> >
+ class SwigPyIteratorOpen_T : public SwigPyIterator_T<OutIterator>
+ {
+ public:
+ FromOper from;
+ typedef OutIterator out_iterator;
+ typedef ValueType value_type;
+ typedef SwigPyIterator_T<out_iterator> base;
+ typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
+
+ SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
+ : SwigPyIterator_T<OutIterator>(curr, seq)
+ {
+ }
+
+ PyObject *value() const {
+ return from(static_cast<const value_type&>(*(base::current)));
+ }
+
+ SwigPyIterator *copy() const
+ {
+ return new self_type(*this);
+ }
+
+ SwigPyIterator *incr(size_t n = 1)
+ {
+ while (n--) {
+ ++base::current;
+ }
+ return this;
+ }
+
+ SwigPyIterator *decr(size_t n = 1)
+ {
+ while (n--) {
+ --base::current;
+ }
+ return this;
+ }
+ };
+
+ template<typename OutIterator,
+ typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
+ typename FromOper = from_oper<ValueType> >
+ class SwigPyIteratorClosed_T : public SwigPyIterator_T<OutIterator>
+ {
+ public:
+ FromOper from;
+ typedef OutIterator out_iterator;
+ typedef ValueType value_type;
+ typedef SwigPyIterator_T<out_iterator> base;
+ typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
+
+ SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
+ : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
+ {
+ }
+
+ PyObject *value() const {
+ if (base::current == end) {
+ throw stop_iteration();
+ } else {
+ return from(static_cast<const value_type&>(*(base::current)));
+ }
+ }
+
+ SwigPyIterator *copy() const
+ {
+ return new self_type(*this);
+ }
+
+ SwigPyIterator *incr(size_t n = 1)
+ {
+ while (n--) {
+ if (base::current == end) {
+ throw stop_iteration();
+ } else {
+ ++base::current;
+ }
+ }
+ return this;
+ }
+
+ SwigPyIterator *decr(size_t n = 1)
+ {
+ while (n--) {
+ if (base::current == begin) {
+ throw stop_iteration();
+ } else {
+ --base::current;
+ }
+ }
+ return this;
+ }
+
+ private:
+ out_iterator begin;
+ out_iterator end;
+ };
+
+ template<typename OutIter>
+ inline SwigPyIterator*
+ make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
+ {
+ return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq);
+ }
+
+ template<typename OutIter>
+ inline SwigPyIterator*
+ make_output_iterator(const OutIter& current, PyObject *seq = 0)
+ {
+ return new SwigPyIteratorOpen_T<OutIter>(current, seq);
+ }
+}
+}
+
+
+%fragment("SwigPyIterator");
+namespace swig
+{
+ /*
+ Throw a StopIteration exception
+ */
+ %ignore stop_iteration;
+ struct stop_iteration {};
+
+ %typemap(throws) stop_iteration {
+ (void)$1;
+ SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+ SWIG_fail;
+ }
+
+ /*
+ Mark methods that return new objects
+ */
+ %newobject SwigPyIterator::copy;
+ %newobject SwigPyIterator::operator + (ptrdiff_t n) const;
+ %newobject SwigPyIterator::operator - (ptrdiff_t n) const;
+
+ %nodirector SwigPyIterator;
+ %extend SwigPyIterator {
+ %pythoncode {def __iter__(self): return self}
+ }
+
+ %catches(swig::stop_iteration) SwigPyIterator::value() const;
+ %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1);
+ %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1);
+ %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const;
+ %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const;
+ %catches(swig::stop_iteration) SwigPyIterator::__next__();
+ %catches(swig::stop_iteration) SwigPyIterator::next();
+ %catches(swig::stop_iteration) SwigPyIterator::previous();
+ %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n);
+ %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n);
+ %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n);
+ %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const;
+ %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const;
+
+
+ struct SwigPyIterator
+ {
+ protected:
+ SwigPyIterator(PyObject *seq);
+
+ public:
+ virtual ~SwigPyIterator();
+
+ // Access iterator method, required by Python
+ virtual PyObject *value() const = 0;
+
+ // Forward iterator method, required by Python
+ virtual SwigPyIterator *incr(size_t n = 1) = 0;
+
+ // Backward iterator method, very common in C++, but not required in Python
+ virtual SwigPyIterator *decr(size_t n = 1);
+
+ // Random access iterator methods, but not required in Python
+ virtual ptrdiff_t distance(const SwigPyIterator &x) const;
+
+ virtual bool equal (const SwigPyIterator &x) const;
+
+ // C++ common/needed methods
+ virtual SwigPyIterator *copy() const = 0;
+
+ PyObject *next();
+ PyObject *__next__();
+ PyObject *previous();
+ SwigPyIterator *advance(ptrdiff_t n);
+
+ bool operator == (const SwigPyIterator& x) const;
+ bool operator != (const SwigPyIterator& x) const;
+ SwigPyIterator& operator += (ptrdiff_t n);
+ SwigPyIterator& operator -= (ptrdiff_t n);
+ SwigPyIterator* operator + (ptrdiff_t n) const;
+ SwigPyIterator* operator - (ptrdiff_t n) const;
+ ptrdiff_t operator - (const SwigPyIterator& x) const;
+ };
+}
+
diff --git a/python/pymacros.swg b/python/pymacros.swg
new file mode 100644
index 0000000..ab7bace
--- /dev/null
+++ b/python/pymacros.swg
@@ -0,0 +1,4 @@
+%include <typemaps/swigmacros.swg>
+
+
+
diff --git a/python/pyname_compat.i b/python/pyname_compat.i
new file mode 100644
index 0000000..b5acca9
--- /dev/null
+++ b/python/pyname_compat.i
@@ -0,0 +1,88 @@
+/*
+* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py,
+* since they are inappropriate and discouraged in Python documentation
+* (from http://www.python.org/doc/2.5.2/api/includes.html):
+*
+* "All user visible names defined by Python.h (except those defined by the included
+* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with
+* "_Py" are for internal use by the Python implementation and should not be used
+* by extension writers. Structure member names do not have a reserved prefix.
+*
+* Important: user code should never define names that begin with "Py" or "_Py".
+* This confuses the reader, and jeopardizes the portability of the user code to
+* future Python versions, which may define additional names beginning with one
+* of these prefixes."
+*
+* This file defined macros to provide backward compatibility for these deprecated
+* symbols. In the case you have these symbols in your interface file, you can simply
+* include this file at beginning of it.
+*
+* However, this file may be removed in future release of SWIG, so using this file to
+* keep these inappropriate names in your SWIG interface file is also not recommended.
+* Instead, we provide a simple tool for converting your interface files to
+* the new naming convention. You can download the tool here:
+* https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py
+*/
+
+%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {}
+%fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {}
+%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {}
+%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {}
+%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {}
+%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {}
+
+%inline %{
+#define PyMapIterator_T SwigPyMapIterator_T
+#define PyMapKeyIterator_T SwigPyMapKeyIterator_T
+#define PyMapValueIterator_T SwigPyMapValueITerator_T
+#define PyObject_ptr SwigPtr_PyObject
+#define PyObject_var SwigVar_PyObject
+#define PyOper SwigPyOper
+#define PySeq SwigPySeq
+#define PySequence_ArrowProxy SwigPySequence_ArrowProxy
+#define PySequence_Cont SwigPySequence_Cont
+#define PySequence_InputIterator SwigPySequence_InputIterator
+#define PySequence_Ref SwigPySequence_Ref
+#define PySwigClientData SwigPyClientData
+#define PySwigClientData_Del SwigPyClientData_Del
+#define PySwigClientData_New SwigPyClientData_New
+#define PySwigIterator SwigPyIterator
+#define PySwigIteratorClosed_T SwigPyIteratorClosed_T
+#define PySwigIteratorOpen_T SwigPyIteratorOpen_T
+#define PySwigIterator_T SwigPyIterator_T
+#define PySwigObject SwigPyObject
+#define PySwigObject_Check SwigPyObject_Check
+#define PySwigObject_GetDesc SwigPyObject_GetDesc
+#define PySwigObject_New SwigPyObject_New
+#define PySwigObject_acquire SwigPyObject_acquire
+#define PySwigObject_append SwigPyObject_append
+#define PySwigObject_as_number SwigPyObject_as_number
+#define PySwigObject_compare SwigPyObject_compare
+#define PySwigObject_dealloc SwigPyObject_dealloc
+#define PySwigObject_disown SwigPyObject_disown
+#define PySwigObject_format SwigPyObject_format
+#define PySwigObject_getattr SwigPyObject_getattr
+#define PySwigObject_hex SwigPyObject_hex
+#define PySwigObject_long SwigPyObject_long
+#define PySwigObject_next SwigPyObject_next
+#define PySwigObject_oct SwigPyObject_oct
+#define PySwigObject_own SwigPyObject_own
+#define PySwigObject_print SwigPyObject_print
+#define PySwigObject_repr SwigPyObject_repr
+#define PySwigObject_richcompare SwigPyObject_richcompare
+#define PySwigObject_str SwigPyObject_str
+#define PySwigObject_type SwigPyObject_type
+#define PySwigPacked SwigPyPacked
+#define PySwigPacked_Check SwigPyPacked_Check
+#define PySwigPacked_New SwigPyPacked_New
+#define PySwigPacked_UnpackData SwigPyPacked_UnpackData
+#define PySwigPacked_compare SwigPyPacked_compare
+#define PySwigPacked_dealloc SwigPyPacked_dealloc
+#define PySwigPacked_print SwigPyPacked_print
+#define PySwigPacked_repr SwigPyPacked_repr
+#define PySwigPacked_str SwigPyPacked_str
+#define PySwigPacked_type SwigPyPacked_type
+#define pyseq swigpyseq
+#define pyswigobject_type swigpyobject_type
+#define pyswigpacked_type swigpypacked_type
+%}
diff --git a/python/pyopers.swg b/python/pyopers.swg
new file mode 100644
index 0000000..30775b8
--- /dev/null
+++ b/python/pyopers.swg
@@ -0,0 +1,136 @@
+/* ------------------------------------------------------------
+ * Overloaded operator support
+ * ------------------------------------------------------------ */
+
+
+#ifdef __cplusplus
+
+#define %pybinoperator(pyname,oper) %rename(pyname) oper; %pythonmaybecall oper
+
+%pybinoperator(__add__, *::operator+);
+%pybinoperator(__pos__, *::operator+());
+%pybinoperator(__pos__, *::operator+() const);
+%pybinoperator(__sub__, *::operator-);
+%pybinoperator(__neg__, *::operator-());
+%pybinoperator(__neg__, *::operator-() const);
+%pybinoperator(__mul__, *::operator*);
+%pybinoperator(__div__, *::operator/);
+%pybinoperator(__mod__, *::operator%);
+%pybinoperator(__lshift__, *::operator<<);
+%pybinoperator(__rshift__, *::operator>>);
+%pybinoperator(__and__, *::operator&);
+%pybinoperator(__or__, *::operator|);
+%pybinoperator(__xor__, *::operator^);
+%pybinoperator(__lt__, *::operator<);
+%pybinoperator(__le__, *::operator<=);
+%pybinoperator(__gt__, *::operator>);
+%pybinoperator(__ge__, *::operator>=);
+%pybinoperator(__eq__, *::operator==);
+%pybinoperator(__ne__, *::operator!=);
+
+
+
+/* Special cases */
+%rename(__invert__) *::operator~;
+%rename(__call__) *::operator();
+
+%feature("shadow") *::operator bool %{
+def __nonzero__(self):
+ return $action(self)
+__bool__ = __nonzero__
+%};
+%rename(__nonzero__) *::operator bool;
+
+/* Ignored operators */
+%ignoreoperator(LNOT) operator!;
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+%ignoreoperator(EQ) *::operator=;
+%ignoreoperator(PLUSPLUS) *::operator++;
+%ignoreoperator(MINUSMINUS) *::operator--;
+%ignoreoperator(ARROWSTAR) *::operator->*;
+%ignoreoperator(INDEX) *::operator[];
+
+/*
+ Inplace operator declarations.
+
+ They translate the inplace C++ operators (+=, -=, ...) into the
+ corresponding python equivalents(__iadd__,__isub__), etc,
+ disabling the ownership of the input 'self' pointer, and assigning
+ it to the returning object:
+
+ %feature("del") *::Operator;
+ %feature("new") *::Operator;
+
+ This makes the most common case safe, ie:
+
+ A& A::operator+=(int i) { ...; return *this; }
+ ^^^^ ^^^^^^
+
+ will work fine, even when the resulting python object shares the
+ 'this' pointer with the input one. The input object is usually
+ deleted after the operation, including the shared 'this' pointer,
+ producing 'strange' seg faults, as reported by Lucriz
+ (lucriz@sitilandia.it).
+
+ If you have an interface that already takes care of that, ie, you
+ already are using inplace operators and you are not getting
+ seg. faults, with the new scheme you could end with 'free' elements
+ that never get deleted (maybe, not sure, it depends). But if that is
+ the case, you could recover the old behaviour using
+
+ %feature("del","") A::operator+=;
+ %feature("new","") A::operator+=;
+
+ which recovers the old behaviour for the class 'A', or if you are
+ 100% sure your entire system works fine in the old way, use:
+
+ %feature("del","") *::operator+=;
+ %feature("new","") *::operator+=;
+
+*/
+
+#define %pyinplaceoper(SwigPyOper, Oper) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper
+
+%pyinplaceoper(__iadd__ , *::operator +=);
+%pyinplaceoper(__isub__ , *::operator -=);
+%pyinplaceoper(__imul__ , *::operator *=);
+%pyinplaceoper(__idiv__ , *::operator /=);
+%pyinplaceoper(__imod__ , *::operator %=);
+%pyinplaceoper(__iand__ , *::operator &=);
+%pyinplaceoper(__ior__ , *::operator |=);
+%pyinplaceoper(__ixor__ , *::operator ^=);
+%pyinplaceoper(__ilshift__, *::operator <<=);
+%pyinplaceoper(__irshift__, *::operator >>=);
+
+
+/* Finally, in python we need to mark the binary operations to fail as
+ 'maybecall' methods */
+
+#define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __
+
+%pybinopermaybecall(add);
+%pybinopermaybecall(pos);
+%pybinopermaybecall(pos);
+%pybinopermaybecall(sub);
+%pybinopermaybecall(neg);
+%pybinopermaybecall(neg);
+%pybinopermaybecall(mul);
+%pybinopermaybecall(div);
+%pybinopermaybecall(mod);
+%pybinopermaybecall(lshift);
+%pybinopermaybecall(rshift);
+%pybinopermaybecall(and);
+%pybinopermaybecall(or);
+%pybinopermaybecall(xor);
+%pybinopermaybecall(lt);
+%pybinopermaybecall(le);
+%pybinopermaybecall(gt);
+%pybinopermaybecall(ge);
+%pybinopermaybecall(eq);
+%pybinopermaybecall(ne);
+
+#endif
+
+
+
diff --git a/python/pyprimtypes.swg b/python/pyprimtypes.swg
new file mode 100644
index 0000000..63435ee
--- /dev/null
+++ b/python/pyprimtypes.swg
@@ -0,0 +1,292 @@
+/* ------------------------------------------------------------
+ * Primitive Types
+ * ------------------------------------------------------------ */
+
+/* boolean */
+
+%fragment(SWIG_From_frag(bool),"header") {
+SWIGINTERNINLINE PyObject*
+ SWIG_From_dec(bool)(bool value)
+{
+ return PyBool_FromLong(value ? 1 : 0);
+}
+}
+
+%fragment(SWIG_AsVal_frag(bool),"header",
+ fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(PyObject *obj, bool *val)
+{
+ int r = PyObject_IsTrue(obj);
+ if (r == -1)
+ return SWIG_ERROR;
+ if (val) *val = r ? true : false;
+ return SWIG_OK;
+}
+}
+
+/* long */
+
+%fragment(SWIG_From_frag(long),"header") {
+ %define_as(SWIG_From_dec(long), PyInt_FromLong)
+}
+
+%fragment(SWIG_AsVal_frag(long),"header",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN int
+SWIG_AsVal_dec(long)(PyObject *obj, long* val)
+{
+ if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else if (PyLong_Check(obj)) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+%#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ long v = PyInt_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
+ if (val) *val = (long)(d);
+ return res;
+ }
+ }
+ }
+%#endif
+ return SWIG_TypeError;
+}
+}
+
+/* unsigned long */
+
+%fragment(SWIG_From_frag(unsigned long),"header",
+ fragment=SWIG_From_frag(long)) {
+SWIGINTERNINLINE PyObject*
+SWIG_From_dec(unsigned long)(unsigned long value)
+{
+ return (value > LONG_MAX) ?
+ PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long),"header",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
+{
+ if (PyInt_Check(obj)) {
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else if (PyLong_Check(obj)) {
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+%#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+ if (val) *val = (unsigned long)(d);
+ return res;
+ }
+ }
+ }
+%#endif
+ return SWIG_TypeError;
+}
+}
+
+/* long long */
+
+%fragment(SWIG_From_frag(long long),"header",
+ fragment=SWIG_From_frag(long),
+ fragment="<limits.h>") {
+SWIGINTERNINLINE PyObject*
+SWIG_From_dec(long long)(long long value)
+{
+ return ((value < LONG_MIN) || (value > LONG_MAX)) ?
+ PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(long long),"header",
+ fragment=SWIG_AsVal_frag(long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="<limits.h>") {
+SWIGINTERN int
+SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
+{
+ int res = SWIG_TypeError;
+ if (PyLong_Check(obj)) {
+ long long v = PyLong_AsLongLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ } else {
+ long v;
+ res = SWIG_AsVal(long)(obj,&v);
+ if (SWIG_IsOK(res)) {
+ if (val) *val = v;
+ return res;
+ }
+ }
+%#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ const double mant_max = 1LL << DBL_MANT_DIG;
+ const double mant_min = -mant_max;
+ double d;
+ res = SWIG_AsVal(double)(obj,&d);
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
+ if (val) *val = (long long)(d);
+ return SWIG_AddCast(res);
+ }
+ res = SWIG_TypeError;
+ }
+%#endif
+ return res;
+}
+}
+
+/* unsigned long long */
+
+%fragment(SWIG_From_frag(unsigned long long),"header",
+ fragment=SWIG_From_frag(long long),
+ fragment="<limits.h>") {
+SWIGINTERNINLINE PyObject*
+SWIG_From_dec(unsigned long long)(unsigned long long value)
+{
+ return (value > LONG_MAX) ?
+ PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long long),"header",
+ fragment=SWIG_AsVal_frag(unsigned long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="<limits.h>") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
+{
+ int res = SWIG_TypeError;
+ if (PyLong_Check(obj)) {
+ unsigned long long v = PyLong_AsUnsignedLongLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ } else {
+ unsigned long v;
+ res = SWIG_AsVal(unsigned long)(obj,&v);
+ if (SWIG_IsOK(res)) {
+ if (val) *val = v;
+ return res;
+ }
+ }
+%#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ const double mant_max = 1LL << DBL_MANT_DIG;
+ double d;
+ res = SWIG_AsVal(double)(obj,&d);
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
+ if (val) *val = (unsigned long long)(d);
+ return SWIG_AddCast(res);
+ }
+ res = SWIG_TypeError;
+ }
+%#endif
+ return res;
+}
+}
+
+/* double */
+
+%fragment(SWIG_From_frag(double),"header") {
+ %define_as(SWIG_From_dec(double), PyFloat_FromDouble)
+}
+
+%fragment(SWIG_AsVal_frag(double),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(double)(PyObject *obj, double *val)
+{
+ int res = SWIG_TypeError;
+ if (PyFloat_Check(obj)) {
+ if (val) *val = PyFloat_AsDouble(obj);
+ return SWIG_OK;
+ } else if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else if (PyLong_Check(obj)) {
+ double v = PyLong_AsDouble(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+%#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ double d = PyFloat_AsDouble(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = d;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
+ } else {
+ PyErr_Clear();
+ }
+ }
+ }
+%#endif
+ return res;
+}
+}
+
+
+
diff --git a/python/pyrun.swg b/python/pyrun.swg
new file mode 100644
index 0000000..21fddb6
--- /dev/null
+++ b/python/pyrun.swg
@@ -0,0 +1,1584 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* Common SWIG API */
+
+/* for raw pointers */
+#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
+#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
+#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
+#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
+#define swig_owntype int
+
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
+
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
+
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
+
+
+/* Runtime API */
+
+#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
+#define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
+
+#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
+#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
+#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
+#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
+#define SWIG_fail goto fail
+
+
+/* Runtime API implementation */
+
+/* Error manipulation */
+
+SWIGINTERN void
+SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetObject(errtype, obj);
+ Py_DECREF(obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+SWIGINTERN void
+SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(errtype, (char *) msg);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
+
+/* Set a constant value */
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
+ PyDict_SetItemString(d, (char*) name, obj);
+ Py_DECREF(obj);
+}
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyList_Check(result)) {
+ PyObject *o2 = result;
+ result = PyList_New(1);
+ PyList_SetItem(result, 0, o2);
+ }
+ PyList_Append(result,obj);
+ Py_DECREF(obj);
+ }
+ return result;
+#else
+ PyObject* o2;
+ PyObject* o3;
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyTuple_Check(result)) {
+ o2 = result;
+ result = PyTuple_New(1);
+ PyTuple_SET_ITEM(result, 0, o2);
+ }
+ o3 = PyTuple_New(1);
+ PyTuple_SET_ITEM(o3, 0, obj);
+ o2 = result;
+ result = PySequence_Concat(o2, o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
+ return result;
+#endif
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN int
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+{
+ if (!args) {
+ if (!min && !max) {
+ return 1;
+ } else {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
+ name, (min == max ? "" : "at least "), (int)min);
+ return 0;
+ }
+ }
+ if (!PyTuple_Check(args)) {
+ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+ return 0;
+ } else {
+ register Py_ssize_t l = PyTuple_GET_SIZE(args);
+ if (l < min) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at least "), (int)min, (int)l);
+ return 0;
+ } else if (l > max) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at most "), (int)max, (int)l);
+ return 0;
+ } else {
+ register int i;
+ for (i = 0; i < l; ++i) {
+ objs[i] = PyTuple_GET_ITEM(args, i);
+ }
+ for (; l < max; ++l) {
+ objs[l] = 0;
+ }
+ return i + 1;
+ }
+ }
+}
+
+/* A functor is a function object with one single object argument */
+#if PY_VERSION_HEX >= 0x02020000
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
+#else
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
+#endif
+
+/*
+ Helper for static pointer initialization for both C and C++ code, for example
+ static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
+*/
+#ifdef __cplusplus
+#define SWIG_STATIC_POINTER(var) var
+#else
+#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
+#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
+
+#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/* How to access Py_None */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# ifndef SWIG_PYTHON_NO_BUILD_NONE
+# ifndef SWIG_PYTHON_BUILD_NONE
+# define SWIG_PYTHON_BUILD_NONE
+# endif
+# endif
+#endif
+
+#ifdef SWIG_PYTHON_BUILD_NONE
+# ifdef Py_None
+# undef Py_None
+# define Py_None SWIG_Py_None()
+# endif
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_Py_None(void)
+{
+ PyObject *none = Py_BuildValue((char*)"");
+ Py_DECREF(none);
+ return none;
+}
+SWIGRUNTIME PyObject *
+SWIG_Py_None(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
+ return none;
+}
+#endif
+
+/* The python void return value */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Py_Void(void)
+{
+ PyObject *none = Py_None;
+ Py_INCREF(none);
+ return none;
+}
+
+/* SwigPyClientData */
+
+typedef struct {
+ PyObject *klass;
+ PyObject *newraw;
+ PyObject *newargs;
+ PyObject *destroy;
+ int delargs;
+ int implicitconv;
+} SwigPyClientData;
+
+SWIGRUNTIMEINLINE int
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+ SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
+ return data ? data->implicitconv : 0;
+}
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+ SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
+ PyObject *klass = data ? data->klass : 0;
+ return (klass ? klass : PyExc_RuntimeError);
+}
+
+
+SWIGRUNTIME SwigPyClientData *
+SwigPyClientData_New(PyObject* obj)
+{
+ if (!obj) {
+ return 0;
+ } else {
+ SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
+ /* the klass element */
+ data->klass = obj;
+ Py_INCREF(data->klass);
+ /* the newraw method and newargs arguments used to create a new raw instance */
+ if (PyClass_Check(obj)) {
+ data->newraw = 0;
+ data->newargs = obj;
+ Py_INCREF(obj);
+ } else {
+#if (PY_VERSION_HEX < 0x02020000)
+ data->newraw = 0;
+#else
+ data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
+#endif
+ if (data->newraw) {
+ Py_INCREF(data->newraw);
+ data->newargs = PyTuple_New(1);
+ PyTuple_SetItem(data->newargs, 0, obj);
+ } else {
+ data->newargs = obj;
+ }
+ Py_INCREF(data->newargs);
+ }
+ /* the destroy method, aka as the C++ delete method */
+ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ data->destroy = 0;
+ }
+ if (data->destroy) {
+ int flags;
+ Py_INCREF(data->destroy);
+ flags = PyCFunction_GET_FLAGS(data->destroy);
+#ifdef METH_O
+ data->delargs = !(flags & (METH_O));
+#else
+ data->delargs = 0;
+#endif
+ } else {
+ data->delargs = 0;
+ }
+ data->implicitconv = 0;
+ return data;
+ }
+}
+
+SWIGRUNTIME void
+SwigPyClientData_Del(SwigPyClientData* data)
+{
+ Py_XDECREF(data->newraw);
+ Py_XDECREF(data->newargs);
+ Py_XDECREF(data->destroy);
+}
+
+/* =============== SwigPyObject =====================*/
+
+typedef struct {
+ PyObject_HEAD
+ void *ptr;
+ swig_type_info *ty;
+ int own;
+ PyObject *next;
+} SwigPyObject;
+
+SWIGRUNTIME PyObject *
+SwigPyObject_long(SwigPyObject *v)
+{
+ return PyLong_FromVoidPtr(v->ptr);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_format(const char* fmt, SwigPyObject *v)
+{
+ PyObject *res = NULL;
+ PyObject *args = PyTuple_New(1);
+ if (args) {
+ if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
+ PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
+ if (ofmt) {
+#if PY_VERSION_HEX >= 0x03000000
+ res = PyUnicode_Format(ofmt,args);
+#else
+ res = PyString_Format(ofmt,args);
+#endif
+ Py_DECREF(ofmt);
+ }
+ Py_DECREF(args);
+ }
+ }
+ return res;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_oct(SwigPyObject *v)
+{
+ return SwigPyObject_format("%o",v);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_hex(SwigPyObject *v)
+{
+ return SwigPyObject_format("%x",v);
+}
+
+SWIGRUNTIME PyObject *
+#ifdef METH_NOARGS
+SwigPyObject_repr(SwigPyObject *v)
+#else
+SwigPyObject_repr(SwigPyObject *v, PyObject *args)
+#endif
+{
+ const char *name = SWIG_TypePrettyName(v->ty);
+ PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, v);
+ if (v->next) {
+#ifdef METH_NOARGS
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
+#else
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
+#endif
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject *joined = PyUnicode_Concat(repr, nrep);
+ Py_DecRef(repr);
+ Py_DecRef(nrep);
+ repr = joined;
+#else
+ PyString_ConcatAndDel(&repr,nrep);
+#endif
+ }
+ return repr;
+}
+
+SWIGRUNTIME int
+SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+ char *str;
+#ifdef METH_NOARGS
+ PyObject *repr = SwigPyObject_repr(v);
+#else
+ PyObject *repr = SwigPyObject_repr(v, NULL);
+#endif
+ if (repr) {
+ str = SWIG_Python_str_AsChar(repr);
+ fputs(str, fp);
+ SWIG_Python_str_DelForPy3(str);
+ Py_DECREF(repr);
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_str(SwigPyObject *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
+ SWIG_Python_str_FromChar(result) : 0;
+}
+
+SWIGRUNTIME int
+SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
+{
+ void *i = v->ptr;
+ void *j = w->ptr;
+ return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
+
+/* Added for Python 3.x, would it also be useful for Python 2.x? */
+SWIGRUNTIME PyObject*
+SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
+{
+ PyObject* res;
+ if( op != Py_EQ && op != Py_NE ) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+ if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) )
+ res = Py_True;
+ else
+ res = Py_False;
+ Py_INCREF(res);
+ return res;
+}
+
+
+SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
+
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+SwigPyObject_Check(PyObject *op) {
+ return (Py_TYPE(op) == SwigPyObject_type())
+ || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
+
+SWIGRUNTIME void
+SwigPyObject_dealloc(PyObject *v)
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ PyObject *next = sobj->next;
+ if (sobj->own == SWIG_POINTER_OWN) {
+ swig_type_info *ty = sobj->ty;
+ SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+ PyObject *destroy = data ? data->destroy : 0;
+ if (destroy) {
+ /* destroy is always a VARARGS method */
+ PyObject *res;
+ if (data->delargs) {
+ /* we need to create a temporary object to carry the destroy operation */
+ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
+ res = SWIG_Python_CallFunctor(destroy, tmp);
+ Py_DECREF(tmp);
+ } else {
+ PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+ PyObject *mself = PyCFunction_GET_SELF(destroy);
+ res = ((*meth)(mself, v));
+ }
+ Py_XDECREF(res);
+ }
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
+ }
+#endif
+ }
+ Py_XDECREF(next);
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject*
+SwigPyObject_append(PyObject* v, PyObject* next)
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+#ifndef METH_O
+ PyObject *tmp = 0;
+ if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
+ next = tmp;
+#endif
+ if (!SwigPyObject_Check(next)) {
+ return NULL;
+ }
+ sobj->next = next;
+ Py_INCREF(next);
+ return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_next(PyObject* v)
+#else
+SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ if (sobj->next) {
+ Py_INCREF(sobj->next);
+ return sobj->next;
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_disown(PyObject *v)
+#else
+SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ sobj->own = 0;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+SwigPyObject_acquire(PyObject *v)
+#else
+SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ sobj->own = SWIG_POINTER_OWN;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+SwigPyObject_own(PyObject *v, PyObject *args)
+{
+ PyObject *val = 0;
+#if (PY_VERSION_HEX < 0x02020000)
+ if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
+#else
+ if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
+#endif
+ {
+ return NULL;
+ }
+ else
+ {
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ PyObject *obj = PyBool_FromLong(sobj->own);
+ if (val) {
+#ifdef METH_NOARGS
+ if (PyObject_IsTrue(val)) {
+ SwigPyObject_acquire(v);
+ } else {
+ SwigPyObject_disown(v);
+ }
+#else
+ if (PyObject_IsTrue(val)) {
+ SwigPyObject_acquire(v,args);
+ } else {
+ SwigPyObject_disown(v,args);
+ }
+#endif
+ }
+ return obj;
+ }
+}
+
+#ifdef METH_O
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#else
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#endif
+
+#if PY_VERSION_HEX < 0x02020000
+SWIGINTERN PyObject *
+SwigPyObject_getattr(SwigPyObject *sobj,char *name)
+{
+ return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
+}
+#endif
+
+SWIGRUNTIME PyTypeObject*
+_PySwigObject_type(void) {
+ static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
+
+ static PyNumberMethods SwigPyObject_as_number = {
+ (binaryfunc)0, /*nb_add*/
+ (binaryfunc)0, /*nb_subtract*/
+ (binaryfunc)0, /*nb_multiply*/
+ /* nb_divide removed in Python 3 */
+#if PY_VERSION_HEX < 0x03000000
+ (binaryfunc)0, /*nb_divide*/
+#endif
+ (binaryfunc)0, /*nb_remainder*/
+ (binaryfunc)0, /*nb_divmod*/
+ (ternaryfunc)0,/*nb_power*/
+ (unaryfunc)0, /*nb_negative*/
+ (unaryfunc)0, /*nb_positive*/
+ (unaryfunc)0, /*nb_absolute*/
+ (inquiry)0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*nb_coerce*/
+#endif
+ (unaryfunc)SwigPyObject_long, /*nb_int*/
+#if PY_VERSION_HEX < 0x03000000
+ (unaryfunc)SwigPyObject_long, /*nb_long*/
+#else
+ 0, /*nb_reserved*/
+#endif
+ (unaryfunc)0, /*nb_float*/
+#if PY_VERSION_HEX < 0x03000000
+ (unaryfunc)SwigPyObject_oct, /*nb_oct*/
+ (unaryfunc)SwigPyObject_hex, /*nb_hex*/
+#endif
+#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
+#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
+#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+#endif
+ };
+
+ static PyTypeObject swigpyobject_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ (char *)"SwigPyObject", /* tp_name */
+ sizeof(SwigPyObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyObject_dealloc, /* tp_dealloc */
+ (printfunc)SwigPyObject_print, /* tp_print */
+#if PY_VERSION_HEX < 0x02020000
+ (getattrfunc)SwigPyObject_getattr, /* tp_getattr */
+#else
+ (getattrfunc)0, /* tp_getattr */
+#endif
+ (setattrfunc)0, /* tp_setattr */
+#if PY_VERSION_HEX >= 0x03000000
+ 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
+#else
+ (cmpfunc)SwigPyObject_compare, /* tp_compare */
+#endif
+ (reprfunc)SwigPyObject_repr, /* tp_repr */
+ &SwigPyObject_as_number, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)SwigPyObject_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigobject_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ swigobject_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ swigpyobject_type = tmp;
+ /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
+#if PY_VERSION_HEX < 0x03000000
+ swigpyobject_type.ob_type = &PyType_Type;
+#endif
+ type_init = 1;
+ }
+ return &swigpyobject_type;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
+{
+ SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
+ if (sobj) {
+ sobj->ptr = ptr;
+ sobj->ty = ty;
+ sobj->own = own;
+ sobj->next = 0;
+ }
+ return (PyObject *)sobj;
+}
+
+/* -----------------------------------------------------------------------------
+ * Implements a simple Swig Packed type, and use it instead of string
+ * ----------------------------------------------------------------------------- */
+
+typedef struct {
+ PyObject_HEAD
+ void *pack;
+ swig_type_info *ty;
+ size_t size;
+} SwigPyPacked;
+
+SWIGRUNTIME int
+SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+ char result[SWIG_BUFFER_SIZE];
+ fputs("<Swig Packed ", fp);
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ fputs("at ", fp);
+ fputs(result, fp);
+ }
+ fputs(v->ty->name,fp);
+ fputs(">", fp);
+ return 0;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_repr(SwigPyPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+ } else {
+ return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
+ }
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_str(SwigPyPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
+ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
+ } else {
+ return SWIG_Python_str_FromChar(v->ty->name);
+ }
+}
+
+SWIGRUNTIME int
+SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
+{
+ size_t i = v->size;
+ size_t j = w->size;
+ int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+ return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
+
+SWIGRUNTIME PyTypeObject*
+SwigPyPacked_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+SwigPyPacked_Check(PyObject *op) {
+ return ((op)->ob_type == _PySwigPacked_type())
+ || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
+}
+
+SWIGRUNTIME void
+SwigPyPacked_dealloc(PyObject *v)
+{
+ if (SwigPyPacked_Check(v)) {
+ SwigPyPacked *sobj = (SwigPyPacked *) v;
+ free(sobj->pack);
+ }
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyTypeObject*
+_PySwigPacked_type(void) {
+ static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
+ static PyTypeObject swigpypacked_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX>=0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ (char *)"SwigPyPacked", /* tp_name */
+ sizeof(SwigPyPacked), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
+ (printfunc)SwigPyPacked_print, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+#if PY_VERSION_HEX>=0x03000000
+ 0, /* tp_reserved in 3.0.1 */
+#else
+ (cmpfunc)SwigPyPacked_compare, /* tp_compare */
+#endif
+ (reprfunc)SwigPyPacked_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)SwigPyPacked_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigpacked_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ swigpypacked_type = tmp;
+ /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */
+#if PY_VERSION_HEX < 0x03000000
+ swigpypacked_type.ob_type = &PyType_Type;
+#endif
+ type_init = 1;
+ }
+ return &swigpypacked_type;
+}
+
+SWIGRUNTIME PyObject *
+SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
+{
+ SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
+ if (sobj) {
+ void *pack = malloc(size);
+ if (pack) {
+ memcpy(pack, ptr, size);
+ sobj->pack = pack;
+ sobj->ty = ty;
+ sobj->size = size;
+ } else {
+ PyObject_DEL((PyObject *) sobj);
+ sobj = 0;
+ }
+ }
+ return (PyObject *) sobj;
+}
+
+SWIGRUNTIME swig_type_info *
+SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+{
+ if (SwigPyPacked_Check(obj)) {
+ SwigPyPacked *sobj = (SwigPyPacked *)obj;
+ if (sobj->size != size) return 0;
+ memcpy(ptr, sobj->pack, size);
+ return sobj->ty;
+ } else {
+ return 0;
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_This(void)
+{
+ return SWIG_Python_str_FromChar("this");
+}
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+ return swig_this;
+}
+
+/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
+
+/* TODO: I don't know how to implement the fast getset in Python 3 right now */
+#if PY_VERSION_HEX>=0x03000000
+#define SWIG_PYTHON_SLOW_GETSET_THIS
+#endif
+
+SWIGRUNTIME SwigPyObject *
+SWIG_Python_GetSwigThis(PyObject *pyobj)
+{
+ if (SwigPyObject_Check(pyobj)) {
+ return (SwigPyObject *) pyobj;
+ } else {
+ PyObject *obj = 0;
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+ if (PyInstance_Check(pyobj)) {
+ obj = _PyInstance_Lookup(pyobj, SWIG_This());
+ } else {
+ PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+ } else {
+#ifdef PyWeakref_CheckProxy
+ if (PyWeakref_CheckProxy(pyobj)) {
+ PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+ return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+ }
+#endif
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+ }
+ }
+#else
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+#endif
+ if (obj && !SwigPyObject_Check(obj)) {
+ /* a PyObject is called 'this', try to get the 'real this'
+ SwigPyObject from it */
+ return SWIG_Python_GetSwigThis(obj);
+ }
+ return (SwigPyObject *)obj;
+ }
+}
+
+/* Acquire a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_AcquirePtr(PyObject *obj, int own) {
+ if (own == SWIG_POINTER_OWN) {
+ SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (sobj) {
+ int oldown = sobj->own;
+ sobj->own = own;
+ return oldown;
+ }
+ }
+ return 0;
+}
+
+/* Convert a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
+ if (!obj) return SWIG_ERROR;
+ if (obj == Py_None) {
+ if (ptr) *ptr = 0;
+ return SWIG_OK;
+ } else {
+ SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
+ while (sobj) {
+ void *vptr = sobj->ptr;
+ if (ty) {
+ swig_type_info *to = sobj->ty;
+ if (to == ty) {
+ /* no type cast needed */
+ if (ptr) *ptr = vptr;
+ break;
+ } else {
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) {
+ sobj = (SwigPyObject *)sobj->next;
+ } else {
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
+ break;
+ }
+ }
+ } else {
+ if (ptr) *ptr = vptr;
+ break;
+ }
+ }
+ if (sobj) {
+ if (own)
+ *own = *own | sobj->own;
+ if (flags & SWIG_POINTER_DISOWN) {
+ sobj->own = 0;
+ }
+ return SWIG_OK;
+ } else {
+ int res = SWIG_ERROR;
+ if (flags & SWIG_POINTER_IMPLICIT_CONV) {
+ SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+ if (data && !data->implicitconv) {
+ PyObject *klass = data->klass;
+ if (klass) {
+ PyObject *impconv;
+ data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+ impconv = SWIG_Python_CallFunctor(klass, obj);
+ data->implicitconv = 0;
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ impconv = 0;
+ }
+ if (impconv) {
+ SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
+ if (iobj) {
+ void *vptr;
+ res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+ if (SWIG_IsOK(res)) {
+ if (ptr) {
+ *ptr = vptr;
+ /* transfer the ownership to 'ptr' */
+ iobj->own = 0;
+ res = SWIG_AddCast(res);
+ res = SWIG_AddNewMask(res);
+ } else {
+ res = SWIG_AddCast(res);
+ }
+ }
+ }
+ Py_DECREF(impconv);
+ }
+ }
+ }
+ }
+ return res;
+ }
+ }
+}
+
+/* Convert a function ptr value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
+ if (!PyCFunction_Check(obj)) {
+ return SWIG_ConvertPtr(obj, ptr, ty, 0);
+ } else {
+ void *vptr = 0;
+
+ /* here we get the method pointer for callbacks */
+ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+ const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
+ if (desc)
+ desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
+ if (!desc)
+ return SWIG_ERROR;
+ if (ty) {
+ swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
+ } else {
+ *ptr = vptr;
+ }
+ return SWIG_OK;
+ }
+}
+
+/* Convert a packed value value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
+ swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
+ if (!to) return SWIG_ERROR;
+ if (ty) {
+ if (to != ty) {
+ /* check type cast? */
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
+/*
+ Create a new instance object, without calling __init__, and set the
+ 'this' attribute.
+*/
+
+SWIGRUNTIME PyObject*
+SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
+{
+#if (PY_VERSION_HEX >= 0x02020000)
+ PyObject *inst = 0;
+ PyObject *newraw = data->newraw;
+ if (newraw) {
+ inst = PyObject_Call(newraw, data->newargs, NULL);
+ if (inst) {
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ }
+ }
+#else
+ PyObject *key = SWIG_This();
+ PyObject_SetAttr(inst, key, swig_this);
+#endif
+ }
+ } else {
+#if PY_VERSION_HEX >= 0x03000000
+ inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
+ PyObject_SetAttr(inst, SWIG_This(), swig_this);
+ Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+#else
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+#endif
+ }
+ return inst;
+#else
+#if (PY_VERSION_HEX >= 0x02010000)
+ PyObject *inst;
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ return (PyObject *) inst;
+#else
+ PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+ if (inst == NULL) {
+ return NULL;
+ }
+ inst->in_class = (PyClassObject *)data->newargs;
+ Py_INCREF(inst->in_class);
+ inst->in_dict = PyDict_New();
+ if (inst->in_dict == NULL) {
+ Py_DECREF(inst);
+ return NULL;
+ }
+#ifdef Py_TPFLAGS_HAVE_WEAKREFS
+ inst->in_weakreflist = NULL;
+#endif
+#ifdef Py_TPFLAGS_GC
+ PyObject_GC_Init(inst);
+#endif
+ PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
+ return (PyObject *) inst;
+#endif
+#endif
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+ PyObject *dict;
+#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ }
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ return;
+ }
+#endif
+ dict = PyObject_GetAttrString(inst, (char*)"__dict__");
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ Py_DECREF(dict);
+}
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+ PyObject *obj[2];
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
+ return NULL;
+ } else {
+ SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+ if (sthis) {
+ SwigPyObject_append((PyObject*) sthis, obj[1]);
+ } else {
+ SWIG_Python_SetSwigThis(obj[0], obj[1]);
+ }
+ return SWIG_Py_Void();
+ }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
+ if (!ptr) {
+ return SWIG_Py_Void();
+ } else {
+ int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+ PyObject *robj = SwigPyObject_New(ptr, type, own);
+ SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
+ if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+ PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+ if (inst) {
+ Py_DECREF(robj);
+ robj = inst;
+ }
+ }
+ return robj;
+ }
+}
+
+/* Create a new packed object */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
+ return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+}
+
+/* -----------------------------------------------------------------------------*
+ * Get type list
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void) {
+ static void *type_pointer = (void *)0;
+ /* first check if module already created */
+ if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
+ }
+#endif
+ }
+ return (swig_module_info *) type_pointer;
+}
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0. The following function
+ is copied out of Python/modsupport.c in python version 2.3.4 */
+SWIGINTERN int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+ PyObject *dict;
+ if (!PyModule_Check(m)) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs module as first arg");
+ return SWIG_ERROR;
+ }
+ if (!o) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs non-NULL value");
+ return SWIG_ERROR;
+ }
+
+ dict = PyModule_GetDict(m);
+ if (dict == NULL) {
+ /* Internal error -- modules must have a dict! */
+ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+ PyModule_GetName(m));
+ return SWIG_ERROR;
+ }
+ if (PyDict_SetItemString(dict, name, o))
+ return SWIG_ERROR;
+ Py_DECREF(o);
+ return SWIG_OK;
+}
+#endif
+
+SWIGRUNTIME void
+SWIG_Python_DestroyModule(void *vptr)
+{
+ swig_module_info *swig_module = (swig_module_info *) vptr;
+ swig_type_info **types = swig_module->types;
+ size_t i;
+ for (i =0; i < swig_module->size; ++i) {
+ swig_type_info *ty = types[i];
+ if (ty->owndata) {
+ SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
+ if (data) SwigPyClientData_Del(data);
+ }
+ }
+ Py_DECREF(SWIG_This());
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+
+#if PY_VERSION_HEX >= 0x03000000
+ /* Add a dummy module object into sys.modules */
+ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
+#else
+ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ swig_empty_runtime_method_table);
+#endif
+ PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+ if (pointer && module) {
+ PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+ } else {
+ Py_XDECREF(pointer);
+ }
+}
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache(void) {
+ static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
+ return cache;
+}
+
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *type)
+{
+ PyObject *cache = SWIG_Python_TypeCache();
+ PyObject *key = SWIG_Python_str_FromChar(type);
+ PyObject *obj = PyDict_GetItem(cache, key);
+ swig_type_info *descriptor;
+ if (obj) {
+ descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+ } else {
+ swig_module_info *swig_module = SWIG_Python_GetModule();
+ descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+ if (descriptor) {
+ obj = PyCObject_FromVoidPtr(descriptor, NULL);
+ PyDict_SetItem(cache, key, obj);
+ Py_DECREF(obj);
+ }
+ }
+ Py_DECREF(key);
+ return descriptor;
+}
+
+/*
+ For backward compatibility only
+*/
+#define SWIG_POINTER_EXCEPTION 0
+#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
+#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+SWIGRUNTIME int
+SWIG_Python_AddErrMesg(const char* mesg, int infront)
+{
+ if (PyErr_Occurred()) {
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+ PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ char *tmp;
+ PyObject *old_str = PyObject_Str(value);
+ Py_XINCREF(type);
+ PyErr_Clear();
+ if (infront) {
+ PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
+ } else {
+ PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+ }
+ SWIG_Python_str_DelForPy3(tmp);
+ Py_DECREF(old_str);
+ }
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME int
+SWIG_Python_ArgFail(int argnum)
+{
+ if (PyErr_Occurred()) {
+ /* add information about failing argument */
+ char mesg[256];
+ PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+ return SWIG_Python_AddErrMesg(mesg, 1);
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIMEINLINE const char *
+SwigPyObject_GetDesc(PyObject *self)
+{
+ SwigPyObject *v = (SwigPyObject *)self;
+ swig_type_info *ty = v ? v->ty : 0;
+ return ty ? ty->str : (char*)"";
+}
+
+SWIGRUNTIME void
+SWIG_Python_TypeError(const char *type, PyObject *obj)
+{
+ if (type) {
+#if defined(SWIG_COBJECT_TYPES)
+ if (obj && SwigPyObject_Check(obj)) {
+ const char *otype = (const char *) SwigPyObject_GetDesc(obj);
+ if (otype) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
+ type, otype);
+ return;
+ }
+ } else
+#endif
+ {
+ const char *otype = (obj ? obj->ob_type->tp_name : 0);
+ if (otype) {
+ PyObject *str = PyObject_Str(obj);
+ const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
+ if (cstr) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
+ type, otype, cstr);
+ SWIG_Python_str_DelForPy3(cstr);
+ } else {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
+ type, otype);
+ }
+ Py_XDECREF(str);
+ return;
+ }
+ }
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+ } else {
+ PyErr_Format(PyExc_TypeError, "unexpected type is received");
+ }
+}
+
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME void *
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
+ void *result;
+ if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+ PyErr_Clear();
+#if SWIG_POINTER_EXCEPTION
+ if (flags) {
+ SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+ SWIG_Python_ArgFail(argnum);
+ }
+#endif
+ }
+ return result;
+}
+
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
diff --git a/python/pyruntime.swg b/python/pyruntime.swg
new file mode 100644
index 0000000..00f15a1
--- /dev/null
+++ b/python/pyruntime.swg
@@ -0,0 +1,13 @@
+%insert(runtime) %{
+/* Python.h has to appear first */
+#include <Python.h>
+%}
+
+%insert(runtime) "swigrun.swg"; /* SWIG API */
+%insert(runtime) "swigerrors.swg"; /* SWIG errors */
+%insert(runtime) "pyhead.swg"; /* Python includes and fixes */
+%insert(runtime) "pyerrors.swg"; /* Python errors */
+%insert(runtime) "pythreads.swg"; /* Python thread code */
+%insert(runtime) "pyapi.swg"; /* Python API */
+%insert(runtime) "pyrun.swg"; /* Python run-time code */
+
diff --git a/python/pystdcommon.swg b/python/pystdcommon.swg
new file mode 100644
index 0000000..7e9720c
--- /dev/null
+++ b/python/pystdcommon.swg
@@ -0,0 +1,259 @@
+%fragment("StdTraits","header",fragment="StdTraitsCommon")
+{
+namespace swig {
+ /*
+ Traits that provides the from method
+ */
+ template <class Type> struct traits_from_ptr {
+ static PyObject *from(Type *val, int owner = 0) {
+ return SWIG_NewPointerObj(val, type_info<Type>(), owner);
+ }
+ };
+
+ template <class Type> struct traits_from {
+ static PyObject *from(const Type& val) {
+ return traits_from_ptr<Type>::from(new Type(val), 1);
+ }
+ };
+
+ template <class Type> struct traits_from<Type *> {
+ static PyObject *from(Type* val) {
+ return traits_from_ptr<Type>::from(val, 0);
+ }
+ };
+
+ template <class Type> struct traits_from<const Type *> {
+ static PyObject *from(const Type* val) {
+ return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0);
+ }
+ };
+
+
+ template <class Type>
+ inline PyObject *from(const Type& val) {
+ return traits_from<Type>::from(val);
+ }
+
+ template <class Type>
+ inline PyObject *from_ptr(Type* val, int owner) {
+ return traits_from_ptr<Type>::from(val, owner);
+ }
+
+ /*
+ Traits that provides the asval/as/check method
+ */
+ template <class Type>
+ struct traits_asptr {
+ static int asptr(PyObject *obj, Type **val) {
+ Type *p;
+ int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ return res;
+ }
+ };
+
+ template <class Type>
+ inline int asptr(PyObject *obj, Type **vptr) {
+ return traits_asptr<Type>::asptr(obj, vptr);
+ }
+
+ template <class Type>
+ struct traits_asval {
+ static int asval(PyObject *obj, Type *val) {
+ if (val) {
+ Type *p = 0;
+ int res = traits_asptr<Type>::asptr(obj, &p);
+ if (!SWIG_IsOK(res)) return res;
+ if (p) {
+ typedef typename noconst_traits<Type>::noconst_type noconst_type;
+ *(const_cast<noconst_type*>(val)) = *p;
+ if (SWIG_IsNewObj(res)){
+ %delete(p);
+ res = SWIG_DelNewMask(res);
+ }
+ return res;
+ } else {
+ return SWIG_ERROR;
+ }
+ } else {
+ return traits_asptr<Type>::asptr(obj, (Type **)(0));
+ }
+ }
+ };
+
+ template <class Type> struct traits_asval<Type*> {
+ static int asval(PyObject *obj, Type **val) {
+ if (val) {
+ typedef typename noconst_traits<Type>::noconst_type noconst_type;
+ noconst_type *p = 0;
+ int res = traits_asptr<noconst_type>::asptr(obj, &p);
+ if (SWIG_IsOK(res)) {
+ *(const_cast<noconst_type**>(val)) = p;
+ }
+ return res;
+ } else {
+ return traits_asptr<Type>::asptr(obj, (Type **)(0));
+ }
+ }
+ };
+
+ template <class Type>
+ inline int asval(PyObject *obj, Type *val) {
+ return traits_asval<Type>::asval(obj, val);
+ }
+
+ template <class Type>
+ struct traits_as<Type, value_category> {
+ static Type as(PyObject *obj, bool throw_error) {
+ Type v;
+ int res = asval(obj, &v);
+ if (!obj || !SWIG_IsOK(res)) {
+ if (!PyErr_Occurred()) {
+ ::%type_error(swig::type_name<Type>());
+ }
+ if (throw_error) throw std::invalid_argument("bad type");
+ }
+ return v;
+ }
+ };
+
+ template <class Type>
+ struct traits_as<Type, pointer_category> {
+ static Type as(PyObject *obj, bool throw_error) {
+ Type *v = 0;
+ int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
+ if (SWIG_IsOK(res) && v) {
+ if (SWIG_IsNewObj(res)) {
+ Type r(*v);
+ %delete(v);
+ return r;
+ } else {
+ return *v;
+ }
+ } else {
+ // Uninitialized return value, no Type() constructor required.
+ static Type *v_def = (Type*) malloc(sizeof(Type));
+ if (!PyErr_Occurred()) {
+ %type_error(swig::type_name<Type>());
+ }
+ if (throw_error) throw std::invalid_argument("bad type");
+ memset(v_def,0,sizeof(Type));
+ return *v_def;
+ }
+ }
+ };
+
+ template <class Type>
+ struct traits_as<Type*, pointer_category> {
+ static Type* as(PyObject *obj, bool throw_error) {
+ Type *v = 0;
+ int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
+ if (SWIG_IsOK(res)) {
+ return v;
+ } else {
+ if (!PyErr_Occurred()) {
+ %type_error(swig::type_name<Type>());
+ }
+ if (throw_error) throw std::invalid_argument("bad type");
+ return 0;
+ }
+ }
+ };
+
+ template <class Type>
+ inline Type as(PyObject *obj, bool te = false) {
+ return traits_as<Type, typename traits<Type>::category>::as(obj, te);
+ }
+
+ template <class Type>
+ struct traits_check<Type, value_category> {
+ static bool check(PyObject *obj) {
+ int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR;
+ return SWIG_IsOK(res) ? true : false;
+ }
+ };
+
+ template <class Type>
+ struct traits_check<Type, pointer_category> {
+ static bool check(PyObject *obj) {
+ int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR;
+ return SWIG_IsOK(res) ? true : false;
+ }
+ };
+
+ template <class Type>
+ inline bool check(PyObject *obj) {
+ return traits_check<Type, typename traits<Type>::category>::check(obj);
+ }
+}
+}
+
+//
+// Backward compatibility
+//
+
+#ifdef SWIG_PYTHON_BACKWARD_COMP
+%{
+#include <string>
+
+PyObject* SwigInt_FromBool(bool b) {
+ return PyInt_FromLong(b ? 1L : 0L);
+}
+double SwigNumber_Check(PyObject* o) {
+ return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o);
+}
+double SwigNumber_AsDouble(PyObject* o) {
+ return PyFloat_Check(o) ? PyFloat_AsDouble(o)
+ : (PyInt_Check(o) ? double(PyInt_AsLong(o))
+ : double(PyLong_AsLong(o)));
+}
+PyObject* SwigString_FromString(const std::string& s) {
+ return PyString_FromStringAndSize(s.data(),s.size());
+}
+std::string SwigString_AsString(PyObject* o) {
+ return std::string(PyString_AsString(o));
+}
+%}
+
+#endif
+
+
+%define %specialize_std_container(Type,Check,As,From)
+%{
+namespace swig {
+ template <> struct traits_asval<Type > {
+ typedef Type value_type;
+ static int asval(PyObject *obj, value_type *val) {
+ if (Check(obj)) {
+ if (val) *val = As(obj);
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+ }
+ };
+ template <> struct traits_from<Type > {
+ typedef Type value_type;
+ static PyObject *from(const value_type& val) {
+ return From(val);
+ }
+ };
+
+ template <>
+ struct traits_check<Type, value_category> {
+ static int check(PyObject *obj) {
+ int res = Check(obj);
+ return obj && res ? res : 0;
+ }
+ };
+}
+%}
+%enddef
+
+
+#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
diff --git a/python/pystrings.swg b/python/pystrings.swg
new file mode 100644
index 0000000..1983037
--- /dev/null
+++ b/python/pystrings.swg
@@ -0,0 +1,103 @@
+/* ------------------------------------------------------------
+ * utility methods for char strings
+ * ------------------------------------------------------------ */
+%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
+{
+%#if PY_VERSION_HEX>=0x03000000
+ if (PyUnicode_Check(obj))
+%#else
+ if (PyString_Check(obj))
+%#endif
+ {
+ char *cstr; Py_ssize_t len;
+%#if PY_VERSION_HEX>=0x03000000
+ if (!alloc && cptr) {
+ /* We can't allow converting without allocation, since the internal
+ representation of string in Python 3 is UCS-2/UCS-4 but we require
+ a UTF-8 representation.
+ TODO(bhy) More detailed explanation */
+ return SWIG_RuntimeError;
+ }
+ obj = PyUnicode_AsUTF8String(obj);
+ PyBytes_AsStringAndSize(obj, &cstr, &len);
+ if(alloc) *alloc = SWIG_NEWOBJ;
+%#else
+ PyString_AsStringAndSize(obj, &cstr, &len);
+%#endif
+ if (cptr) {
+ if (alloc) {
+ /*
+ In python the user should not be able to modify the inner
+ string representation. To warranty that, if you define
+ SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
+ buffer is always returned.
+
+ The default behavior is just to return the pointer value,
+ so, be careful.
+ */
+%#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
+ if (*alloc != SWIG_OLDOBJ)
+%#else
+ if (*alloc == SWIG_NEWOBJ)
+%#endif
+ {
+ *cptr = %new_copy_array(cstr, len + 1, char);
+ *alloc = SWIG_NEWOBJ;
+ }
+ else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ } else {
+ %#if PY_VERSION_HEX>=0x03000000
+ assert(0); /* Should never reach here in Python 3 */
+ %#endif
+ *cptr = SWIG_Python_str_AsChar(obj);
+ }
+ }
+ if (psize) *psize = len + 1;
+%#if PY_VERSION_HEX>=0x03000000
+ Py_XDECREF(obj);
+%#endif
+ return SWIG_OK;
+ } else {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ if (pchar_descriptor) {
+ void* vptr = 0;
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = (char *) vptr;
+ if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
+SWIGINTERNINLINE PyObject *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+ if (carray) {
+ if (size > INT_MAX) {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ return pchar_descriptor ?
+ SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
+ } else {
+%#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
+%#else
+ return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
+%#endif
+ }
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+}
+
+
diff --git a/python/python.swg b/python/python.swg
new file mode 100644
index 0000000..769d9e1
--- /dev/null
+++ b/python/python.swg
@@ -0,0 +1,59 @@
+/* ------------------------------------------------------------
+ * python.swg
+ *
+ * Python configuration module.
+ * ------------------------------------------------------------ */
+
+/* ------------------------------------------------------------
+ * Inner macros
+ * ------------------------------------------------------------ */
+%include <pymacros.swg>
+
+
+/* ------------------------------------------------------------
+ * The runtime part
+ * ------------------------------------------------------------ */
+%include <pyruntime.swg>
+
+/* ------------------------------------------------------------
+ * Special user directives
+ * ------------------------------------------------------------ */
+%include <pyuserdir.swg>
+
+/* ------------------------------------------------------------
+ * Typemap specializations
+ * ------------------------------------------------------------ */
+%include <pytypemaps.swg>
+
+/* ------------------------------------------------------------
+ * Overloaded operator support
+ * ------------------------------------------------------------ */
+%include <pyopers.swg>
+
+/* ------------------------------------------------------------
+ * Warnings for Python keywords
+ * ------------------------------------------------------------ */
+%include <pythonkw.swg>
+
+/* ------------------------------------------------------------
+ * The Python autodoc support
+ * ------------------------------------------------------------ */
+%include <pydocs.swg>
+
+/* ------------------------------------------------------------
+ * The Python classes, for C++
+ * ------------------------------------------------------------ */
+%include <pyclasses.swg>
+
+/* ------------------------------------------------------------
+ * The Python initialization function
+ * ------------------------------------------------------------ */
+%include <pyinit.swg>
+
+
+/* ------------------------------------------------------------
+ * For backward compatibility
+ * ------------------------------------------------------------ */
+%include <pybackward.swg>
+
+
diff --git a/python/pythonkw.swg b/python/pythonkw.swg
new file mode 100644
index 0000000..2ee2335
--- /dev/null
+++ b/python/pythonkw.swg
@@ -0,0 +1,136 @@
+/*
+ Warnings for Python keywords, built-in names and bad names.
+*/
+
+#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x`
+#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") "::"`x`
+
+
+/*
+ Warnings for Python keywords
+ http://www.fnorb.org/docs/1.2/Fnorb-Guide/node62.html
+*/
+
+PYTHONKW(and);
+PYTHONKW(assert);
+PYTHONKW(break);
+PYTHONKW(class);
+PYTHONKW(continue);
+PYTHONKW(def);
+PYTHONKW(del);
+PYTHONKW(elif);
+PYTHONKW(else);
+PYTHONKW(except);
+PYTHONKW(exec);
+PYTHONKW(finally);
+PYTHONKW(for);
+PYTHONKW(from);
+PYTHONKW(global);
+PYTHONKW(if);
+PYTHONKW(import);
+PYTHONKW(in);
+PYTHONKW(is);
+PYTHONKW(lambda);
+PYTHONKW(not);
+PYTHONKW(or);
+PYTHONKW(pass);
+PYTHONKW(print);
+PYTHONKW(raise);
+PYTHONKW(return);
+PYTHONKW(try);
+PYTHONKW(while);
+PYTHONKW(yield);
+
+/*
+ built-in functions
+ http://www.zvon.org/other/python/doc21/lib/built-in-funcs.html
+ */
+
+PYTHONBN(abs);
+PYTHONBN(apply);
+PYTHONBN(bool);
+PYTHONBN(buffer);
+PYTHONBN(callable);
+PYTHONBN(chr);
+PYTHONBN(classmethod);
+PYTHONBN(cmp);
+PYTHONBN(coerce);
+PYTHONBN(compile);
+PYTHONBN(complex);
+PYTHONBN(delattr);
+PYTHONBN(dict);
+PYTHONBN(dir);
+PYTHONBN(divmod);
+PYTHONBN(enumerate);
+PYTHONBN(eval);
+PYTHONBN(execfile);
+PYTHONBN(file);
+PYTHONBN(filter);
+PYTHONBN(float);
+PYTHONBN(frozenset);
+PYTHONBN(getattr);
+PYTHONBN(globals);
+PYTHONBN(hasattr);
+PYTHONBN(hash);
+PYTHONBN(hex);
+PYTHONBN(id);
+PYTHONBN(input);
+PYTHONBN(int);
+PYTHONBN(intern);
+PYTHONBN(isinstance);
+PYTHONBN(issubclass);
+PYTHONBN(iter);
+PYTHONBN(len);
+PYTHONBN(list);
+PYTHONBN(locals);
+PYTHONBN(long);
+PYTHONBN(map);
+PYTHONBN(max);
+PYTHONBN(min);
+PYTHONBN(object);
+PYTHONBN(oct);
+PYTHONBN(open);
+PYTHONBN(ord);
+PYTHONBN(pow);
+PYTHONBN(property);
+PYTHONBN(range);
+PYTHONBN(raw_input);
+PYTHONBN(reduce);
+PYTHONBN(reload);
+PYTHONBN(repr);
+PYTHONBN(reversed);
+PYTHONBN(round);
+PYTHONBN(set);
+PYTHONBN(setattr);
+PYTHONBN(slice);
+PYTHONBN(sorted);
+PYTHONBN(staticmethod);
+PYTHONBN(staticmethod);
+PYTHONBN(str);
+PYTHONBN(sum);
+PYTHONBN(super);
+PYTHONBN(tuple);
+PYTHONBN(type);
+PYTHONBN(unichr);
+PYTHONBN(unicode);
+PYTHONBN(vars);
+PYTHONBN(xrange);
+PYTHONBN(zip);
+
+
+/*
+ built-in names
+ boolean type and None
+*/
+PYTHONBN(True);
+PYTHONBN(False);
+PYTHONBN(None);
+
+
+/*
+ 'self' is also a bad Name
+*/
+PYTHONBN(self);
+
+#undef PYTHONBN
+#undef PYTHONKW
diff --git a/python/pythreads.swg b/python/pythreads.swg
new file mode 100644
index 0000000..a7552f1
--- /dev/null
+++ b/python/pythreads.swg
@@ -0,0 +1,66 @@
+#if defined(SWIG_PYTHON_NO_THREADS)
+# if defined(SWIG_PYTHON_THREADS)
+# undef SWIG_PYTHON_THREADS
+# endif
+#endif
+#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
+# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
+# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
+# define SWIG_PYTHON_USE_GIL
+# endif
+# endif
+# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+# ifndef SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# endif
+# ifdef __cplusplus /* C++ code */
+ class SWIG_Python_Thread_Block {
+ bool status;
+ PyGILState_STATE state;
+ public:
+ void end() { if (status) { PyGILState_Release(state); status = false;} }
+ SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
+ ~SWIG_Python_Thread_Block() { end(); }
+ };
+ class SWIG_Python_Thread_Allow {
+ bool status;
+ PyThreadState *save;
+ public:
+ void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
+ SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
+ ~SWIG_Python_Thread_Allow() { end(); }
+ };
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
+# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
+# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
+# else /* C code */
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
+# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
+# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
+# endif
+# else /* Old thread way, not implemented, user must provide it */
+# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
+# define SWIG_PYTHON_THREAD_END_ALLOW
+# endif
+# endif
+#else /* No thread support */
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# define SWIG_PYTHON_THREAD_END_ALLOW
+#endif
diff --git a/python/pytuplehlp.swg b/python/pytuplehlp.swg
new file mode 100644
index 0000000..32e1580
--- /dev/null
+++ b/python/pytuplehlp.swg
@@ -0,0 +1,8 @@
+/*
+ Helper function to return output types, now we need to use a list
+ instead of a tuple since all the other types
+ (std::pair,std::vector,std::list,etc) return tuples.
+*/
+
+#warning "Deprecated file: Don't use t_output_helper anymore,"
+#warning "use SWIG_Python_AppendOutput or %append_output instead."
diff --git a/python/pytypemaps.swg b/python/pytypemaps.swg
new file mode 100644
index 0000000..e8df069
--- /dev/null
+++ b/python/pytypemaps.swg
@@ -0,0 +1,98 @@
+/* ------------------------------------------------------------
+ * Typemap specializations for Python
+ * ------------------------------------------------------------ */
+
+/* ------------------------------------------------------------
+ * Fragment section
+ * ------------------------------------------------------------ */
+/* bool is dangerous in Python, change precedence */
+#undef SWIG_TYPECHECK_BOOL
+%define SWIG_TYPECHECK_BOOL 10000 %enddef
+
+/* Include fundamental fragemt definitions */
+%include <typemaps/fragments.swg>
+
+/* Look for user fragments file. */
+%include <pyfragments.swg>
+
+/* Python fragments for fundamental types */
+%include <pyprimtypes.swg>
+
+/* Python fragments for char* strings */
+%include <pystrings.swg>
+
+/* Backward compatibility output helper */
+%fragment("t_output_helper","header") %{
+#define t_output_helper SWIG_Python_AppendOutput
+%}
+
+
+/* ------------------------------------------------------------
+ * Unified typemap section
+ * ------------------------------------------------------------ */
+
+/* directors are supported in Python */
+#ifndef SWIG_DIRECTOR_TYPEMAPS
+#define SWIG_DIRECTOR_TYPEMAPS
+#endif
+
+
+/* Python types */
+#define SWIG_Object PyObject *
+#define VOID_Object SWIG_Py_Void()
+
+/* Python allows implicit conversion */
+#define %implicitconv_flag $implicitconv
+
+
+/* Overload of the output/constant/exception/dirout handling */
+
+/* append output */
+#define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj)
+
+/* set constant */
+#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj)
+
+/* raise */
+#define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc)
+
+/* Include the unified typemap library */
+%include <typemaps/swigtypemaps.swg>
+
+
+/* ------------------------------------------------------------
+ * Python extra typemaps
+ * ------------------------------------------------------------ */
+
+/* Get the address of the 'python self' object */
+
+%typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF {
+ $1 = &$self;
+}
+
+
+/* Consttab, needed for callbacks, it should be removed later */
+
+%typemap(consttab) SWIGTYPE ((*)(ANY))
+{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
+
+%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
+
+
+/* Smart Pointers */
+%typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER {
+ $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags);
+}
+
+%typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER {
+ if ($result) {
+ PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL);
+ if (robj && !PyErr_Occurred()) {
+ SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result),
+ (PyObject *) SWIG_Python_GetSwigThis(robj));
+ Py_DECREF(robj);
+ }
+ }
+}
+
+
diff --git a/python/pyuserdir.swg b/python/pyuserdir.swg
new file mode 100644
index 0000000..5247ee6
--- /dev/null
+++ b/python/pyuserdir.swg
@@ -0,0 +1,245 @@
+/* -------------------------------------------------------------------------
+ * Special user directives
+ * ------------------------------------------------------------------------- */
+
+/* ------------------------------------------------------------------------- */
+
+/* shadow code */
+#define %shadow %insert("shadow")
+#define %pythoncode %insert("python")
+
+
+/* ------------------------------------------------------------------------- */
+/*
+Use the "nondynamic" feature to make a wrapped class behave as a "nondynamic"
+one, ie, a python class that doesn't dynamically add new attributes.
+
+For example, for the class
+
+%pythonnondynamic A;
+struct A
+{
+ int a;
+ int b;
+};
+
+you will get:
+
+ aa = A()
+ aa.a = 1 # Ok
+ aa.b = 1 # Ok
+ aa.c = 3 # error
+
+Since nondynamic is a feature, if you use it like
+
+ %pythonnondynamic;
+
+it will make all the wrapped classes nondynamic ones.
+
+The implementation is based on this recipe:
+
+ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
+
+and works for modern (-modern) and plain python. We do not use __slots__,
+so, it works with old python versions.
+
+*/
+
+#define %pythonnondynamic %feature("python:nondynamic", "1")
+#define %nopythonnondynamic %feature("python:nondynamic", "0")
+#define %clearpythonnondynamic %feature("python:nondynamic", "")
+#define %pythondynamic %nopythonnondynamic
+
+
+/* ------------------------------------------------------------------------- */
+/*
+
+Use %pythonmaybecall to flag a method like __add__ or __radd__. These
+don't produce an error when called, they just return NotImplemented.
+
+These methods "may be called" if needed.
+
+*/
+
+#define %pythonmaybecall %feature("python:maybecall", "1")
+#define %nopythonmaybecall %feature("python:maybecall", "0")
+#define %clearpythonmaybecall %feature("python:maybecall", "")
+
+/* ------------------------------------------------------------------------- */
+/*
+ The %pythoncallback feature produce a more natural callback wrapper
+ than the %callback mechanism, ie, it uses the original name for
+ the callback and callable objects.
+
+ Just use it as
+
+ %pythoncallback(1) foo;
+ int foo(int a);
+
+ %pythoncallback(1) A::foo;
+ struct A {
+ static int foo(int a);
+ };
+
+ int bar(int, int (*pf)(int));
+
+ then, you can use it as:
+
+ a = foo(1)
+ b = bar(2, foo)
+
+ c = A.foo(3)
+ d = bar(4, A.foo)
+
+
+ If you use it with a member method
+ %pythoncallback(1) A::foom;
+ struct A {
+ int foom(int a);
+ };
+
+ then you can use it as
+
+ r = a.foom(3) # eval the method
+ mptr = A.foom_cb_ptr # returns the callback pointer
+
+ where the '_cb_ptr' suffix is added for the callback pointer.
+
+*/
+
+#define %pythoncallback %feature("python:callback")
+#define %nopythoncallback %feature("python:callback","0")
+#define %clearpythoncallback %feature("python:callback","")
+
+/* ------------------------------------------------------------------------- */
+/*
+ Support for the old %callback directive name
+*/
+#ifdef %callback
+#undef %callback
+#endif
+
+#ifdef %nocallback
+#undef %nocallback
+#endif
+
+#ifdef %clearcallback
+#undef %clearcallback
+#endif
+
+#define %callback(x) %feature("python:callback",`x`)
+#define %nocallback %nopythoncallback
+#define %clearcallback %clearpythoncallback
+
+/* ------------------------------------------------------------------------- */
+/*
+ Thread support - Advance control
+
+*/
+
+#define %nothread %feature("nothread")
+#define %thread %feature("nothread","0")
+#define %clearnothread %feature("nothread","")
+
+#define %nothreadblock %feature("nothreadblock")
+#define %threadblock %feature("nothreadblock","0")
+#define %clearnothreadblock %feature("nothreadblock","")
+
+#define %nothreadallow %feature("nothreadallow")
+#define %threadallow %feature("nothreadallow","0")
+#define %clearnothreadallow %feature("nothreadallow","")
+
+
+/* ------------------------------------------------------------------------- */
+/*
+ Implicit Conversion using the C++ constructor mechanism
+*/
+
+#define %implicitconv %feature("implicitconv")
+#define %noimplicitconv %feature("implicitconv", "0")
+#define %clearimplicitconv %feature("implicitconv", "")
+
+
+/* ------------------------------------------------------------------------- */
+/*
+ Enable keywords paramaters
+*/
+
+#define %kwargs %feature("kwargs")
+#define %nokwargs %feature("kwargs", "0")
+#define %clearkwargs %feature("kwargs", "")
+
+/* ------------------------------------------------------------------------- */
+/*
+ Add python code to the proxy/shadow code
+
+ %pythonprepend - Add code before the C++ function is called
+ %pythonappend - Add code after the C++ function is called
+*/
+
+#define %pythonprepend %feature("pythonprepend")
+#define %clearpythonprepend %feature("pythonprepend","")
+
+#define %pythonappend %feature("pythonappend")
+#define %clearpythonappend %feature("pythonappend","")
+
+
+
+/* ------------------------------------------------------------------------- */
+/*
+ %extend_smart_pointer extend the smart pointer support.
+
+ For example, if you have a smart pointer as:
+
+ template <class Type> class RCPtr {
+ public:
+ ...
+ RCPtr(Type *p);
+ Type * operator->() const;
+ ...
+ };
+
+ you use the %extend_smart_pointer directive as:
+
+ %extend_smart_pointer(RCPtr<A>);
+ %template(RCPtr_A) RCPtr<A>;
+
+ then, if you have something like:
+
+ RCPtr<A> make_ptr();
+ int foo(A *);
+
+ you can do the following:
+
+ a = make_ptr();
+ b = foo(a);
+
+ ie, swig will accept a RCPtr<A> object where a 'A *' is
+ expected.
+
+ Also, when using vectors
+
+ %extend_smart_pointer(RCPtr<A>);
+ %template(RCPtr_A) RCPtr<A>;
+ %template(vector_A) std::vector<RCPtr<A> >;
+
+ you can type
+
+ a = A();
+ v = vector_A(2)
+ v[0] = a
+
+ ie, an 'A *' object is accepted, via implicit conversion,
+ where a RCPtr<A> object is expected. Additionally
+
+ x = v[0]
+
+ returns (and sets 'x' as) a copy of v[0], making reference
+ counting possible and consistent.
+*/
+
+%define %extend_smart_pointer(Type...)
+%implicitconv Type;
+%apply const SWIGTYPE& SMARTPOINTER { const Type& };
+%apply SWIGTYPE SMARTPOINTER { Type };
+%enddef
diff --git a/python/pywstrings.swg b/python/pywstrings.swg
new file mode 100644
index 0000000..7c36f24
--- /dev/null
+++ b/python/pywstrings.swg
@@ -0,0 +1,63 @@
+/* ------------------------------------------------------------
+ * utility methods for wchar_t strings
+ * ------------------------------------------------------------ */
+
+%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
+SWIGINTERN int
+SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
+{
+ PyObject *tmp = 0;
+ int isunicode = PyUnicode_Check(obj);
+%#if PY_VERSION_HEX < 0x03000000
+ if (!isunicode && PyString_Check(obj)) {
+ if (cptr) {
+ obj = tmp = PyUnicode_FromObject(obj);
+ }
+ isunicode = 1;
+ }
+%#endif
+ if (isunicode) {
+ Py_ssize_t len = PyUnicode_GetSize(obj);
+ if (cptr) {
+ *cptr = %new_array(len + 1, wchar_t);
+ PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
+ (*cptr)[len] = 0;
+ }
+ if (psize) *psize = (size_t) len + 1;
+ if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
+ Py_XDECREF(tmp);
+ return SWIG_OK;
+ } else {
+ swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
+ if (pwchar_descriptor) {
+ void * vptr = 0;
+ if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = (wchar_t *)vptr;
+ if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
+ return SWIG_OK;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
+SWIGINTERNINLINE PyObject *
+SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
+{
+ if (carray) {
+ if (size > INT_MAX) {
+ swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
+ return pwchar_descriptor ?
+ SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void();
+ } else {
+ return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
+ }
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+}
+
+
diff --git a/python/std_alloc.i b/python/std_alloc.i
new file mode 100644
index 0000000..35dc051
--- /dev/null
+++ b/python/std_alloc.i
@@ -0,0 +1 @@
+%include <std/std_alloc.i>
diff --git a/python/std_basic_string.i b/python/std_basic_string.i
new file mode 100644
index 0000000..7d3366d
--- /dev/null
+++ b/python/std_basic_string.i
@@ -0,0 +1,103 @@
+#if !defined(SWIG_STD_STRING)
+#define SWIG_STD_BASIC_STRING
+
+%include <pycontainer.swg>
+
+#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type)
+
+
+%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header",
+ fragment="SWIG_AsCharPtrAndSize") {
+SWIGINTERN int
+SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val)
+{
+ static swig_type_info* string_info =
+ SWIG_TypeQuery("std::basic_string<char> *");
+ std::string *vptr;
+ if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) {
+ if (val) *val = vptr;
+ return SWIG_OLDOBJ;
+ } else {
+ PyErr_Clear();
+ char* buf = 0 ; size_t size = 0; int alloc = 0;
+ if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
+ if (buf) {
+ if (val) *val = new std::string(buf, size - 1);
+ if (alloc == SWIG_NEWOBJ) %delete_array(buf);
+ return SWIG_NEWOBJ;
+ }
+ } else {
+ PyErr_Clear();
+ }
+ if (val) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_TypeError,"a string is expected");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+ return 0;
+ }
+}
+}
+
+%fragment(SWIG_From_frag(std::basic_string<char>),"header",
+ fragment="SWIG_FromCharPtrAndSize") {
+SWIGINTERNINLINE PyObject*
+ SWIG_From(std::basic_string<char>)(const std::string& s)
+ {
+ return SWIG_FromCharPtrAndSize(s.data(), s.size());
+ }
+}
+
+%include <std/std_basic_string.i>
+%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>);
+
+#endif
+
+
+#if !defined(SWIG_STD_WSTRING)
+
+%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header",
+ fragment="SWIG_AsWCharPtrAndSize") {
+SWIGINTERN int
+ SWIG_AsPtr(std::basic_string<wchar_t>)(PyObject* obj, std::wstring **val)
+ {
+ static swig_type_info* string_info =
+ SWIG_TypeQuery("std::basic_string<wchar_t> *");
+ std::wstring *vptr;
+ if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) {
+ if (val) *val = vptr;
+ return SWIG_OLDOBJ;
+ } else {
+ PyErr_Clear();
+ wchar_t *buf = 0 ; size_t size = 0; int alloc = 0;
+ if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
+ if (buf) {
+ if (val) *val = new std::wstring(buf, size - 1);
+ if (alloc == SWIG_NEWOBJ) %delete_array(buf);
+ return SWIG_NEWOBJ;
+ }
+ } else {
+ PyErr_Clear();
+ }
+ if (val) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_TypeError,"a wstring is expected");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+ return 0;
+ }
+ }
+}
+
+%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header",
+ fragment="SWIG_FromWCharPtrAndSize") {
+SWIGINTERNINLINE PyObject*
+ SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s)
+ {
+ return SWIG_FromWCharPtrAndSize(s.data(), s.size());
+ }
+}
+
+%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>);
+
+#endif
diff --git a/python/std_carray.i b/python/std_carray.i
new file mode 100644
index 0000000..680d671
--- /dev/null
+++ b/python/std_carray.i
@@ -0,0 +1,54 @@
+%include <pycontainer.swg>
+
+
+%fragment("StdCarrayTraits","header",fragment="StdSequenceTraits")
+{
+namespace swig {
+ template <class T, size_t S>
+ struct traits_asptr<std::carray<T, S> > {
+ static int asptr(PyObject *obj, std::carray<T, S> **array) {
+ return traits_asptr_stdseq<std::carray<T, S> >::asptr(obj, array);
+ }
+ };
+}
+}
+
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[];
+
+%extend std::carray {
+ %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
+ fragment="SwigPyIterator_T",
+ fragment=SWIG_Traits_frag(_Type),
+ fragment="StdCarrayTraits") {
+ namespace swig {
+ template <> struct traits<std::carray<_Type, _Size > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::carray<" #_Type "," #_Size " >";
+ }
+ };
+ }
+ }
+
+ %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr,
+ SWIG_Traits_frag(std::carray<_Type, _Size >),
+ std::carray<_Type, _Size >);
+
+ %typemap(out,noblock=1) iterator, const_iterator {
+ $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+ }
+
+ inline size_t __len__() const { return self->size(); }
+
+ inline const _Type& __getitem__(size_t i) const { return (*self)[i]; }
+
+ inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
+
+
+ swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
+ return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+ }
+}
+
+%include <std/std_carray.swg>
diff --git a/python/std_char_traits.i b/python/std_char_traits.i
new file mode 100644
index 0000000..bf4e6c4
--- /dev/null
+++ b/python/std_char_traits.i
@@ -0,0 +1 @@
+%include <std/std_char_traits.i>
diff --git a/python/std_common.i b/python/std_common.i
new file mode 100644
index 0000000..3290e21
--- /dev/null
+++ b/python/std_common.i
@@ -0,0 +1,44 @@
+%include <std/std_except.i>
+%include <pystdcommon.swg>
+
+
+/*
+ Generate the traits for a 'primitive' type, such as 'double',
+ for which the SWIG_AsVal and SWIG_From methods are already defined.
+*/
+
+%define %traits_ptypen(Type...)
+ %fragment(SWIG_Traits_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(Type),
+ fragment=SWIG_From_frag(Type),
+ fragment="StdTraits") {
+namespace swig {
+ template <> struct traits<Type > {
+ typedef value_category category;
+ static const char* type_name() { return #Type; }
+ };
+ template <> struct traits_asval<Type > {
+ typedef Type value_type;
+ static int asval(PyObject *obj, value_type *val) {
+ return SWIG_AsVal(Type)(obj, val);
+ }
+ };
+ template <> struct traits_from<Type > {
+ typedef Type value_type;
+ static PyObject *from(const value_type& val) {
+ return SWIG_From(Type)(val);
+ }
+ };
+}
+}
+%enddef
+
+
+%include <std/std_common.i>
+
+//
+// Generates the traits for all the known primitive
+// C++ types (int, double, ...)
+//
+%apply_cpptypes(%traits_ptypen);
+
diff --git a/python/std_complex.i b/python/std_complex.i
new file mode 100644
index 0000000..4e8fed3
--- /dev/null
+++ b/python/std_complex.i
@@ -0,0 +1,22 @@
+/*
+ * STD C++ complex typemaps
+ */
+
+%include <pycomplex.swg>
+
+%{
+#include <complex>
+%}
+
+/* defining the complex as/from converters */
+
+%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
+%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag)
+
+/* defining the typemaps */
+
+%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
+%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);
+
+
+
diff --git a/python/std_container.i b/python/std_container.i
new file mode 100644
index 0000000..d24c157
--- /dev/null
+++ b/python/std_container.i
@@ -0,0 +1,2 @@
+%include <pycontainer.swg>
+%include <std/std_container.i>
diff --git a/python/std_deque.i b/python/std_deque.i
new file mode 100644
index 0000000..b193756
--- /dev/null
+++ b/python/std_deque.i
@@ -0,0 +1,27 @@
+/*
+ Deques
+*/
+
+%fragment("StdDequeTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T>
+ struct traits_asptr<std::deque<T> > {
+ static int asptr(PyObject *obj, std::deque<T> **vec) {
+ return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::deque<T> > {
+ static PyObject *from(const std::deque<T> & vec) {
+ return traits_from_stdseq<std::deque<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+#define %swig_deque_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_deque.i>
diff --git a/python/std_except.i b/python/std_except.i
new file mode 100644
index 0000000..af98428
--- /dev/null
+++ b/python/std_except.i
@@ -0,0 +1 @@
+%include <typemaps/std_except.swg>
diff --git a/python/std_ios.i b/python/std_ios.i
new file mode 100644
index 0000000..aa6f099
--- /dev/null
+++ b/python/std_ios.i
@@ -0,0 +1,3 @@
+%rename(ios_base_in) std::ios_base::in;
+
+%include <std/std_ios.i>
diff --git a/python/std_iostream.i b/python/std_iostream.i
new file mode 100644
index 0000000..43d6b0c
--- /dev/null
+++ b/python/std_iostream.i
@@ -0,0 +1,8 @@
+namespace std
+{
+%callback(1) endl;
+%callback(1) ends;
+%callback(1) flush;
+}
+
+%include <std/std_iostream.i>
diff --git a/python/std_list.i b/python/std_list.i
new file mode 100644
index 0000000..baf66d9
--- /dev/null
+++ b/python/std_list.i
@@ -0,0 +1,28 @@
+/*
+ Lists
+*/
+
+%fragment("StdListTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T >
+ struct traits_asptr<std::list<T> > {
+ static int asptr(PyObject *obj, std::list<T> **lis) {
+ return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::list<T> > {
+ static PyObject *from(const std::list<T> & vec) {
+ return traits_from_stdseq<std::list<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_list.i>
+
diff --git a/python/std_map.i b/python/std_map.i
new file mode 100644
index 0000000..074c431
--- /dev/null
+++ b/python/std_map.i
@@ -0,0 +1,257 @@
+/*
+ Maps
+*/
+
+%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
+{
+ namespace swig {
+ template <class SwigPySeq, class K, class T >
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::map<K,T > *map) {
+ typedef typename std::map<K,T>::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ map->insert(value_type(it->first, it->second));
+ }
+ }
+
+ template <class K, class T>
+ struct traits_asptr<std::map<K,T> > {
+ typedef std::map<K,T> map_type;
+ static int asptr(PyObject *obj, map_type **val) {
+ int res = SWIG_ERROR;
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ if (PyDict_Check(obj)) {
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
+%#if PY_VERSION_HEX >= 0x03000000
+ /* In Python 3.x the ".items()" method returns a dict_items object */
+ items = PySequence_Fast(items, ".items() didn't return a sequence!");
+%#endif
+ res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
+ } else {
+ map_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = p;
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return res;
+ }
+ };
+
+ template <class K, class T >
+ struct traits_from<std::map<K,T> > {
+ typedef std::map<K,T> map_type;
+ typedef typename map_type::const_iterator const_iterator;
+ typedef typename map_type::size_type size_type;
+
+ static PyObject *from(const map_type& map) {
+ swig_type_info *desc = swig::type_info<map_type>();
+ if (desc && desc->clientdata) {
+ return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
+ } else {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ size_type size = map.size();
+ int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject *obj = PyDict_New();
+ for (const_iterator i= map.begin(); i!= map.end(); ++i) {
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
+ PyDict_SetItem(obj, key, val);
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return obj;
+ }
+ }
+ };
+
+ template <class ValueType>
+ struct from_key_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef PyObject *result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v.first);
+ }
+ };
+
+ template <class ValueType>
+ struct from_value_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef PyObject *result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v.second);
+ }
+ };
+
+ template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
+ struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
+ {
+ SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
+ {
+ }
+ };
+
+
+ template<class OutIterator,
+ class FromOper = from_key_oper<typename OutIterator::value_type> >
+ struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
+ {
+ SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+ {
+ }
+ };
+
+ template<typename OutIter>
+ inline SwigPyIterator*
+ make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
+ {
+ return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
+ }
+
+ template<class OutIterator,
+ class FromOper = from_value_oper<typename OutIterator::value_type> >
+ struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
+ {
+ SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+ {
+ }
+ };
+
+
+ template<typename OutIter>
+ inline SwigPyIterator*
+ make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
+ {
+ return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
+ }
+ }
+}
+
+%define %swig_map_common(Map...)
+ %swig_sequence_iterator(Map);
+ %swig_container_methods(Map)
+
+ %extend {
+ mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) {
+ Map::const_iterator i = self->find(key);
+ if (i != self->end())
+ return i->second;
+ else
+ throw std::out_of_range("key not found");
+ }
+
+ void __delitem__(const key_type& key) throw (std::out_of_range) {
+ Map::iterator i = self->find(key);
+ if (i != self->end())
+ self->erase(i);
+ else
+ throw std::out_of_range("key not found");
+ }
+
+ bool has_key(const key_type& key) const {
+ Map::const_iterator i = self->find(key);
+ return i != self->end();
+ }
+
+ PyObject* keys() {
+ Map::size_type size = self->size();
+ int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ if (pysize < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject* keyList = PyList_New(pysize);
+ Map::const_iterator i = self->begin();
+ for (int j = 0; j < pysize; ++i, ++j) {
+ PyList_SET_ITEM(keyList, j, swig::from(i->first));
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return keyList;
+ }
+
+ PyObject* values() {
+ Map::size_type size = self->size();
+ int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ if (pysize < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject* valList = PyList_New(pysize);
+ Map::const_iterator i = self->begin();
+ for (int j = 0; j < pysize; ++i, ++j) {
+ PyList_SET_ITEM(valList, j, swig::from(i->second));
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return valList;
+ }
+
+ PyObject* items() {
+ Map::size_type size = self->size();
+ int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ if (pysize < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject* itemList = PyList_New(pysize);
+ Map::const_iterator i = self->begin();
+ for (int j = 0; j < pysize; ++i, ++j) {
+ PyList_SET_ITEM(itemList, j, swig::from(*i));
+ }
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return itemList;
+ }
+
+ // Python 2.2 methods
+ bool __contains__(const key_type& key) {
+ return self->find(key) != self->end();
+ }
+
+ %newobject key_iterator(PyObject **PYTHON_SELF);
+ swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) {
+ return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+ }
+
+ %newobject value_iterator(PyObject **PYTHON_SELF);
+ swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) {
+ return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+ }
+
+ %pythoncode {def __iter__(self): return self.key_iterator()}
+ %pythoncode {def iterkeys(self): return self.key_iterator()}
+ %pythoncode {def itervalues(self): return self.value_iterator()}
+ %pythoncode {def iteritems(self): return self.iterator()}
+ }
+%enddef
+
+%define %swig_map_methods(Map...)
+ %swig_map_common(Map)
+ %extend {
+ void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
+ (*self)[key] = x;
+ }
+ }
+%enddef
+
+
+%include <std/std_map.i>
diff --git a/python/std_multimap.i b/python/std_multimap.i
new file mode 100644
index 0000000..58336bc
--- /dev/null
+++ b/python/std_multimap.i
@@ -0,0 +1,79 @@
+/*
+ Multimaps
+*/
+%include <std_map.i>
+
+%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
+{
+ namespace swig {
+ template <class SwigPySeq, class K, class T >
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::multimap<K,T > *multimap) {
+ typedef typename std::multimap<K,T>::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ multimap->insert(value_type(it->first, it->second));
+ }
+ }
+
+ template <class K, class T>
+ struct traits_asptr<std::multimap<K,T> > {
+ typedef std::multimap<K,T> multimap_type;
+ static int asptr(PyObject *obj, std::multimap<K,T> **val) {
+ int res = SWIG_ERROR;
+ if (PyDict_Check(obj)) {
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
+ return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
+ } else {
+ multimap_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = p;
+ }
+ return res;
+ }
+ };
+
+ template <class K, class T >
+ struct traits_from<std::multimap<K,T> > {
+ typedef std::multimap<K,T> multimap_type;
+ typedef typename multimap_type::const_iterator const_iterator;
+ typedef typename multimap_type::size_type size_type;
+
+ static PyObject *from(const multimap_type& multimap) {
+ swig_type_info *desc = swig::type_info<multimap_type>();
+ if (desc && desc->clientdata) {
+ return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN);
+ } else {
+ size_type size = multimap.size();
+ int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_OverflowError,
+ "multimap size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject *obj = PyDict_New();
+ for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) {
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
+ PyDict_SetItem(obj, key, val);
+ }
+ return obj;
+ }
+ }
+ };
+ }
+}
+
+%define %swig_multimap_methods(Type...)
+ %swig_map_common(Type);
+ %extend {
+ void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
+ self->insert(Type::value_type(key,x));
+ }
+ }
+%enddef
+
+%include <std/std_multimap.i>
+
diff --git a/python/std_multiset.i b/python/std_multiset.i
new file mode 100644
index 0000000..ac43033
--- /dev/null
+++ b/python/std_multiset.i
@@ -0,0 +1,41 @@
+/*
+ Multisets
+*/
+
+%include <std_set.i>
+
+%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class SwigPySeq, class T>
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::multiset<T>* seq) {
+ // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+ }
+
+ template <class T>
+ struct traits_asptr<std::multiset<T> > {
+ static int asptr(PyObject *obj, std::multiset<T> **m) {
+ return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, m);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::multiset<T> > {
+ static PyObject *from(const std::multiset<T>& vec) {
+ return traits_from_stdseq<std::multiset<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+#define %swig_multiset_methods(Set...) %swig_set_methods(Set)
+
+
+
+%include <std/std_multiset.i>
diff --git a/python/std_pair.i b/python/std_pair.i
new file mode 100644
index 0000000..bc8ccaa
--- /dev/null
+++ b/python/std_pair.i
@@ -0,0 +1,139 @@
+/*
+ Pairs
+*/
+%include <pystdcommon.swg>
+
+//#define SWIG_STD_PAIR_ASVAL
+
+%fragment("StdPairTraits","header",fragment="StdTraits") {
+ namespace swig {
+#ifdef SWIG_STD_PAIR_ASVAL
+ template <class T, class U >
+ struct traits_asval<std::pair<T,U> > {
+ typedef std::pair<T,U> value_type;
+
+ static int get_pair(PyObject* first, PyObject* second,
+ std::pair<T,U> *val)
+ {
+ if (val) {
+ T *pfirst = &(val->first);
+ int res1 = swig::asval((PyObject*)first, pfirst);
+ if (!SWIG_IsOK(res1)) return res1;
+ U *psecond = &(val->second);
+ int res2 = swig::asval((PyObject*)second, psecond);
+ if (!SWIG_IsOK(res2)) return res2;
+ return res1 > res2 ? res1 : res2;
+ } else {
+ T *pfirst = 0;
+ int res1 = swig::asval((PyObject*)first, 0);
+ if (!SWIG_IsOK(res1)) return res1;
+ U *psecond = 0;
+ int res2 = swig::asval((PyObject*)second, psecond);
+ if (!SWIG_IsOK(res2)) return res2;
+ return res1 > res2 ? res1 : res2;
+ }
+ }
+
+ static int asval(PyObject *obj, std::pair<T,U> *val) {
+ int res = SWIG_ERROR;
+ if (PyTuple_Check(obj)) {
+ if (PyTuple_GET_SIZE(obj) == 2) {
+ res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val);
+ }
+ } else if (PySequence_Check(obj)) {
+ if (PySequence_Size(obj) == 2) {
+ swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
+ swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
+ res = get_pair(first, second, val);
+ }
+ } else {
+ value_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = *p;
+ }
+ return res;
+ }
+ };
+
+#else
+ template <class T, class U >
+ struct traits_asptr<std::pair<T,U> > {
+ typedef std::pair<T,U> value_type;
+
+ static int get_pair(PyObject* first, PyObject* second,
+ std::pair<T,U> **val)
+ {
+ if (val) {
+ value_type *vp = %new_instance(std::pair<T,U>);
+ T *pfirst = &(vp->first);
+ int res1 = swig::asval((PyObject*)first, pfirst);
+ if (!SWIG_IsOK(res1)) return res1;
+ U *psecond = &(vp->second);
+ int res2 = swig::asval((PyObject*)second, psecond);
+ if (!SWIG_IsOK(res2)) return res2;
+ *val = vp;
+ return SWIG_AddNewMask(res1 > res2 ? res1 : res2);
+ } else {
+ T *pfirst = 0;
+ int res1 = swig::asval((PyObject*)first, pfirst);
+ if (!SWIG_IsOK(res1)) return res1;
+ U *psecond = 0;
+ int res2 = swig::asval((PyObject*)second, psecond);
+ if (!SWIG_IsOK(res2)) return res2;
+ return res1 > res2 ? res1 : res2;
+ }
+ }
+
+ static int asptr(PyObject *obj, std::pair<T,U> **val) {
+ int res = SWIG_ERROR;
+ if (PyTuple_Check(obj)) {
+ if (PyTuple_GET_SIZE(obj) == 2) {
+ res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val);
+ }
+ } else if (PySequence_Check(obj)) {
+ if (PySequence_Size(obj) == 2) {
+ swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
+ swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
+ res = get_pair(first, second, val);
+ }
+ } else {
+ value_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = p;
+ }
+ return res;
+ }
+ };
+
+#endif
+ template <class T, class U >
+ struct traits_from<std::pair<T,U> > {
+ static PyObject *from(const std::pair<T,U>& val) {
+ PyObject* obj = PyTuple_New(2);
+ PyTuple_SetItem(obj,0,swig::from(val.first));
+ PyTuple_SetItem(obj,1,swig::from(val.second));
+ return obj;
+ }
+ };
+ }
+}
+
+%define %swig_pair_methods(pair...)
+%extend {
+%pythoncode {def __len__(self): return 2
+def __repr__(self): return str((self.first, self.second))
+def __getitem__(self, index):
+ if not (index % 2):
+ return self.first
+ else:
+ return self.second
+def __setitem__(self, index, val):
+ if not (index % 2):
+ self.first = val
+ else:
+ self.second = val}
+}
+%enddef
+
+%include <std/std_pair.i>
+
diff --git a/python/std_set.i b/python/std_set.i
new file mode 100644
index 0000000..59f69cd
--- /dev/null
+++ b/python/std_set.i
@@ -0,0 +1,55 @@
+/*
+ Sets
+*/
+
+%fragment("StdSetTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class SwigPySeq, class T>
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::set<T>* seq) {
+ // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+ }
+
+ template <class T>
+ struct traits_asptr<std::set<T> > {
+ static int asptr(PyObject *obj, std::set<T> **s) {
+ return traits_asptr_stdseq<std::set<T> >::asptr(obj, s);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::set<T> > {
+ static PyObject *from(const std::set<T>& vec) {
+ return traits_from_stdseq<std::set<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+%define %swig_set_methods(set...)
+ %swig_sequence_iterator(set);
+ %swig_container_methods(set);
+
+ %extend {
+ void append(value_type x) {
+ self->insert(x);
+ }
+
+ bool __contains__(value_type x) {
+ return self->find(x) != self->end();
+ }
+
+ value_type __getitem__(difference_type i) const throw (std::out_of_range) {
+ return *(swig::cgetpos(self, i));
+ }
+
+ };
+%enddef
+
+%include <std/std_set.i>
diff --git a/python/std_sstream.i b/python/std_sstream.i
new file mode 100644
index 0000000..6647df8
--- /dev/null
+++ b/python/std_sstream.i
@@ -0,0 +1 @@
+%include <std/std_sstream.i>
diff --git a/python/std_streambuf.i b/python/std_streambuf.i
new file mode 100644
index 0000000..44b9bb4
--- /dev/null
+++ b/python/std_streambuf.i
@@ -0,0 +1 @@
+%include <std/std_streambuf.i>
diff --git a/python/std_string.i b/python/std_string.i
new file mode 100644
index 0000000..dc1378a
--- /dev/null
+++ b/python/std_string.i
@@ -0,0 +1 @@
+%include <typemaps/std_string.swg>
diff --git a/python/std_vector.i b/python/std_vector.i
new file mode 100644
index 0000000..3f04a30
--- /dev/null
+++ b/python/std_vector.i
@@ -0,0 +1,27 @@
+/*
+ Vectors
+*/
+
+%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T>
+ struct traits_asptr<std::vector<T> > {
+ static int asptr(PyObject *obj, std::vector<T> **vec) {
+ return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::vector<T> > {
+ static PyObject *from(const std::vector<T>& vec) {
+ return traits_from_stdseq<std::vector<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_vector.i>
diff --git a/python/std_vectora.i b/python/std_vectora.i
new file mode 100644
index 0000000..3f084bd
--- /dev/null
+++ b/python/std_vectora.i
@@ -0,0 +1,31 @@
+/*
+ Vectors + allocators
+*/
+
+%fragment("StdVectorATraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T, class A>
+ struct traits_asptr<std::vector<T,A> > {
+ typedef std::vector<T,A> vector_type;
+ typedef T value_type;
+ static int asptr(PyObject *obj, vector_type **vec) {
+ return traits_asptr_stdseq<vector_type>::asptr(obj, vec);
+ }
+ };
+
+ template <class T, class A>
+ struct traits_from<std::vector<T,A> > {
+ typedef std::vector<T,A> vector_type;
+ static PyObject *from(const vector_type& vec) {
+ return traits_from_stdseq<vector_type>::from(vec);
+ }
+ };
+ }
+%}
+
+
+#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_vectora.i>
diff --git a/python/std_wios.i b/python/std_wios.i
new file mode 100644
index 0000000..930a57d
--- /dev/null
+++ b/python/std_wios.i
@@ -0,0 +1 @@
+%include <std/std_wios.i>
diff --git a/python/std_wiostream.i b/python/std_wiostream.i
new file mode 100644
index 0000000..d3a5ee7
--- /dev/null
+++ b/python/std_wiostream.i
@@ -0,0 +1,10 @@
+namespace std
+{
+%callback(1) wendl;
+%callback(1) wends;
+%callback(1) wflush;
+}
+
+%include <std_basic_string.i>
+%include <std_wstring.i>
+%include <std/std_wiostream.i>
diff --git a/python/std_wsstream.i b/python/std_wsstream.i
new file mode 100644
index 0000000..8843f56
--- /dev/null
+++ b/python/std_wsstream.i
@@ -0,0 +1 @@
+%include <std/std_wsstream.i>
diff --git a/python/std_wstreambuf.i b/python/std_wstreambuf.i
new file mode 100644
index 0000000..c0f0920
--- /dev/null
+++ b/python/std_wstreambuf.i
@@ -0,0 +1 @@
+%include <std/std_wstreambuf.i>
diff --git a/python/std_wstring.i b/python/std_wstring.i
new file mode 100644
index 0000000..ef86281
--- /dev/null
+++ b/python/std_wstring.i
@@ -0,0 +1,3 @@
+%include <pywstrings.swg>
+%include <typemaps/std_wstring.swg>
+
diff --git a/python/stl.i b/python/stl.i
new file mode 100644
index 0000000..a3566db
--- /dev/null
+++ b/python/stl.i
@@ -0,0 +1,7 @@
+/* initial STL definition. extended as needed in each language */
+%include <std_common.i>
+%include <std_string.i>
+%include <std_vector.i>
+%include <std_map.i>
+%include <std_pair.i>
+
diff --git a/python/typemaps.i b/python/typemaps.i
new file mode 100644
index 0000000..1c87de6
--- /dev/null
+++ b/python/typemaps.i
@@ -0,0 +1,151 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * typemaps.i
+ *
+ * Pointer handling
+ * These mappings provide support for input/output arguments and common
+ * uses for C/C++ pointers.
+ * ----------------------------------------------------------------------------- */
+
+// INPUT typemaps.
+// These remap a C pointer to be an "INPUT" value which is passed by value
+// instead of reference.
+
+/*
+The following methods can be applied to turn a pointer into a simple
+"input" value. That is, instead of passing a pointer to an object,
+you would use a real value instead.
+
+ int *INPUT
+ short *INPUT
+ long *INPUT
+ long long *INPUT
+ unsigned int *INPUT
+ unsigned short *INPUT
+ unsigned long *INPUT
+ unsigned long long *INPUT
+ unsigned char *INPUT
+ bool *INPUT
+ float *INPUT
+ double *INPUT
+
+To use these, suppose you had a C function like this :
+
+ double fadd(double *a, double *b) {
+ return *a+*b;
+ }
+
+You could wrap it with SWIG as follows :
+
+ %include <typemaps.i>
+ double fadd(double *INPUT, double *INPUT);
+
+or you can use the %apply directive :
+
+ %include <typemaps.i>
+ %apply double *INPUT { double *a, double *b };
+ double fadd(double *a, double *b);
+
+*/
+
+// OUTPUT typemaps. These typemaps are used for parameters that
+// are output only. The output value is appended to the result as
+// a list element.
+
+/*
+The following methods can be applied to turn a pointer into an "output"
+value. When calling a function, no input value would be given for
+a parameter, but an output value would be returned. In the case of
+multiple output values, they are returned in the form of a Python tuple.
+
+ int *OUTPUT
+ short *OUTPUT
+ long *OUTPUT
+ long long *OUTPUT
+ unsigned int *OUTPUT
+ unsigned short *OUTPUT
+ unsigned long *OUTPUT
+ unsigned long long *OUTPUT
+ unsigned char *OUTPUT
+ bool *OUTPUT
+ float *OUTPUT
+ double *OUTPUT
+
+For example, suppose you were trying to wrap the modf() function in the
+C math library which splits x into integral and fractional parts (and
+returns the integer part in one of its parameters).K:
+
+ double modf(double x, double *ip);
+
+You could wrap it with SWIG as follows :
+
+ %include <typemaps.i>
+ double modf(double x, double *OUTPUT);
+
+or you can use the %apply directive :
+
+ %include <typemaps.i>
+ %apply double *OUTPUT { double *ip };
+ double modf(double x, double *ip);
+
+The Python output of the function would be a tuple containing both
+output values.
+
+*/
+
+// INOUT
+// Mappings for an argument that is both an input and output
+// parameter
+
+/*
+The following methods can be applied to make a function parameter both
+an input and output value. This combines the behavior of both the
+"INPUT" and "OUTPUT" methods described earlier. Output values are
+returned in the form of a Python tuple.
+
+ int *INOUT
+ short *INOUT
+ long *INOUT
+ long long *INOUT
+ unsigned int *INOUT
+ unsigned short *INOUT
+ unsigned long *INOUT
+ unsigned long long *INOUT
+ unsigned char *INOUT
+ bool *INOUT
+ float *INOUT
+ double *INOUT
+
+For example, suppose you were trying to wrap the following function :
+
+ void neg(double *x) {
+ *x = -(*x);
+ }
+
+You could wrap it with SWIG as follows :
+
+ %include <typemaps.i>
+ void neg(double *INOUT);
+
+or you can use the %apply directive :
+
+ %include <typemaps.i>
+ %apply double *INOUT { double *x };
+ void neg(double *x);
+
+Unlike C, this mapping does not directly modify the input value (since
+this makes no sense in Python). Rather, the modified input value shows
+up as the return value of the function. Thus, to apply this function
+to a Python variable you might do this :
+
+ x = neg(x)
+
+Note : previous versions of SWIG used the symbol 'BOTH' to mark
+input/output arguments. This is still supported, but will be slowly
+phased out in future releases.
+
+*/
+
+%include <typemaps/typemaps.swg>
diff --git a/python/wchar.i b/python/wchar.i
new file mode 100644
index 0000000..308139a
--- /dev/null
+++ b/python/wchar.i
@@ -0,0 +1,21 @@
+#ifdef __cplusplus
+
+%{
+#include <cwchar>
+%}
+
+#else
+
+%{
+#include <wchar.h>
+%}
+
+#endif
+
+%types(wchar_t *);
+%include <pywstrings.swg>
+
+/*
+ Enable swig wchar support.
+*/
+#define SWIG_WCHAR
diff --git a/runtime.swg b/runtime.swg
new file mode 100644
index 0000000..1528a52
--- /dev/null
+++ b/runtime.swg
@@ -0,0 +1,38 @@
+/* -----------------------------------------------------------------------------*
+ Standard SWIG API for use inside user code.
+
+ Don't include this file directly, run the command
+ swig -python -external-runtime
+ Also, read the Modules chapter of the SWIG Manual.
+
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_MODULE_CLIENTDATA_TYPE
+
+SWIGRUNTIMEINLINE swig_type_info *
+SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
+ swig_module_info *module = SWIG_GetModule(clientdata);
+ return SWIG_TypeQueryModule(module, module, name);
+}
+
+SWIGRUNTIMEINLINE swig_type_info *
+SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
+ swig_module_info *module = SWIG_GetModule(clientdata);
+ return SWIG_MangledTypeQueryModule(module, module, name);
+}
+
+#else
+
+SWIGRUNTIMEINLINE swig_type_info *
+SWIG_TypeQuery(const char *name) {
+ swig_module_info *module = SWIG_GetModule(NULL);
+ return SWIG_TypeQueryModule(module, module, name);
+}
+
+SWIGRUNTIMEINLINE swig_type_info *
+SWIG_MangledTypeQuery(const char *name) {
+ swig_module_info *module = SWIG_GetModule(NULL);
+ return SWIG_MangledTypeQueryModule(module, module, name);
+}
+
+#endif
diff --git a/shared_ptr.i b/shared_ptr.i
new file mode 100644
index 0000000..7097915
--- /dev/null
+++ b/shared_ptr.i
@@ -0,0 +1,61 @@
+// shared_ptr namespaces could be boost or std or std::tr1
+// For example for std::tr1, use:
+// #define SWIG_SHARED_PTR_NAMESPACE std
+// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
+
+#if !defined(SWIG_SHARED_PTR_NAMESPACE)
+# define SWIG_SHARED_PTR_NAMESPACE boost
+#endif
+
+#if defined(SWIG_SHARED_PTR_SUBNAMESPACE)
+# define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE::SWIG_SHARED_PTR_SUBNAMESPACE
+#else
+# define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE
+#endif
+
+namespace SWIG_SHARED_PTR_NAMESPACE {
+#if defined(SWIG_SHARED_PTR_SUBNAMESPACE)
+ namespace SWIG_SHARED_PTR_SUBNAMESPACE {
+#endif
+ template <class T> class shared_ptr {
+ };
+#if defined(SWIG_SHARED_PTR_SUBNAMESPACE)
+ }
+#endif
+}
+
+%fragment("SWIG_null_deleter", "header") {
+struct SWIG_null_deleter {
+ void operator() (void const *) const {
+ }
+};
+%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
+%#define SWIG_NO_NULL_DELETER_1
+%#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW
+%#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN
+}
+
+
+// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
+// For plain classes, do not use for derived classes
+%define SWIG_SHARED_PTR(PROXYCLASS, TYPE...)
+SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%enddef
+
+// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
+// For derived classes
+%define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+%}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
diff --git a/std/README b/std/README
new file mode 100644
index 0000000..5cd759d
--- /dev/null
+++ b/std/README
@@ -0,0 +1,22 @@
+/* -----------------------------------------------------------------------------
+ * C++ STD + STL
+ * ----------------------------------------------------------------------------- */
+
+std_common.i general common code
+std_container.i general container code
+std_basic_string.i basic string
+std_char_traits.i char traits
+std_complex.i complex
+std_deque.i deque
+std_except.i exceptions
+std_ios.i ios
+std_iostream.i istream/ostream
+std_list.i list
+std_map.i map
+std_multimap.i multimap
+std_multiset.i multiset
+std_pair.i pair
+std_set.i set
+std_streambuf.i streambuf
+std_vector.i vector
+std_vectora.i vector + allocator
diff --git a/std/_std_deque.i b/std/_std_deque.i
new file mode 100644
index 0000000..026f373
--- /dev/null
+++ b/std/_std_deque.i
@@ -0,0 +1,126 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * _std_deque.i
+ *
+ * This file contains a generic definition of std::deque along with
+ * some helper functions. Specific language modules should include
+ * this file to generate wrappers.
+ * ----------------------------------------------------------------------------- */
+
+%include <std_except.i>
+
+%{
+#include <deque>
+#include <stdexcept>
+%}
+
+
+/* This macro defines all of the standard methods for a deque. This
+ is defined as a macro to simplify the task of specialization. For
+ example,
+
+ template<> class deque<int> {
+ public:
+ %std_deque_methods(int);
+ };
+*/
+
+%define %std_deque_methods(T)
+ typedef T &reference;
+ typedef const T& const_reference;
+
+ deque();
+ deque(unsigned int size, const T& value=T());
+ deque(const deque<T> &);
+ ~deque();
+
+ void assign(unsigned int n, const T& value);
+ void swap(deque<T> &x);
+ unsigned int size() const;
+ unsigned int max_size() const;
+ void resize(unsigned int n, T c = T());
+ bool empty() const;
+ const_reference front();
+ const_reference back();
+ void push_front(const T& x);
+ void push_back(const T& x);
+ void pop_front();
+ void pop_back();
+ void clear();
+
+ /* Some useful extensions */
+ %extend {
+ const_reference getitem(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("deque index out of range");
+ }
+ void setitem(int i, const T& x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("deque index out of range");
+ }
+ void delitem(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size) {
+ self->erase(self->begin()+i);
+ } else {
+ throw std::out_of_range("deque index out of range");
+ }
+ }
+ std::deque<T> getslice(int i, int j) {
+ int size = int(self->size());
+ if (i<0) i = size+i;
+ if (j<0) j = size+j;
+ if (i<0) i = 0;
+ if (j>size) j = size;
+ std::deque<T > tmp(j-i);
+ std::copy(self->begin()+i,self->begin()+j,tmp.begin());
+ return tmp;
+ }
+ void setslice(int i, int j, const std::deque<T>& v) {
+ int size = int(self->size());
+ if (i<0) i = size+i;
+ if (j<0) j = size+j;
+ if (i<0) i = 0;
+ if (j>size) j = size;
+ if (int(v.size()) == j-i) {
+ std::copy(v.begin(),v.end(),self->begin()+i);
+ } else {
+ self->erase(self->begin()+i,self->begin()+j);
+ if (i+1 <= size)
+ self->insert(self->begin()+i+1,v.begin(),v.end());
+ else
+ self->insert(self->end(),v.begin(),v.end());
+ }
+ }
+ void delslice(int i, int j) {
+ int size = int(self->size());
+ if (i<0) i = size+i;
+ if (j<0) j = size+j;
+ if (i<0) i = 0;
+ if (j>size) j = size;
+ self->erase(self->begin()+i,self->begin()+j);
+ }
+ };
+
+%enddef
+
+namespace std {
+ template<class T> class deque {
+ public:
+ %std_deque_methods(T);
+ };
+}
+
+
+
diff --git a/std/std_alloc.i b/std/std_alloc.i
new file mode 100644
index 0000000..44dc8dc
--- /dev/null
+++ b/std/std_alloc.i
@@ -0,0 +1,77 @@
+namespace std
+{
+ /**
+ * @brief The "standard" allocator, as per [20.4].
+ *
+ * The private _Alloc is "SGI" style. (See comments at the top
+ * of stl_alloc.h.)
+ *
+ * The underlying allocator behaves as follows.
+ * - __default_alloc_template is used via two typedefs
+ * - "__single_client_alloc" typedef does no locking for threads
+ * - "__alloc" typedef is threadsafe via the locks
+ * - __new_alloc is used for memory requests
+ *
+ * (See @link Allocators allocators info @endlink for more.)
+ */
+ template<typename _Tp>
+ class allocator
+ {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp* pointer;
+ typedef const _Tp* const_pointer;
+ typedef _Tp& reference;
+ typedef const _Tp& const_reference;
+ typedef _Tp value_type;
+
+ template<typename _Tp1>
+ struct rebind;
+
+ allocator() throw();
+
+ allocator(const allocator&) throw();
+ template<typename _Tp1>
+ allocator(const allocator<_Tp1>&) throw();
+ ~allocator() throw();
+
+
+ pointer
+ address(reference __x) const;
+
+
+ const_pointer
+ address(const_reference __x) const;
+
+
+ // NB: __n is permitted to be 0. The C++ standard says nothing
+ // about what the return value is when __n == 0.
+ _Tp*
+ allocate(size_type __n, const void* = 0);
+
+ // __p is not permitted to be a null pointer.
+ void
+ deallocate(pointer __p, size_type __n);
+
+ size_type
+ max_size() const throw();
+
+ void construct(pointer __p, const _Tp& __val);
+ void destroy(pointer __p);
+ };
+
+ template<>
+ class allocator<void>
+ {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+
+ template<typename _Tp1>
+ struct rebind;
+ };
+} // namespace std
diff --git a/std/std_basic_string.i b/std/std_basic_string.i
new file mode 100644
index 0000000..7b0898a
--- /dev/null
+++ b/std/std_basic_string.i
@@ -0,0 +1,270 @@
+%include <exception.i>
+%include <std_container.i>
+%include <std_alloc.i>
+%include <std_char_traits.i>
+
+
+%{
+#include <string>
+%}
+
+namespace std
+{
+ %naturalvar basic_string;
+}
+
+
+namespace std {
+
+ template <class _CharT, class _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> >
+ class basic_string
+ {
+#if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL)
+ %ignore push_back;
+ %ignore clear;
+ %ignore compare;
+ %ignore append;
+#endif
+
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _CharT value_type;
+ typedef value_type reference;
+ typedef value_type const_reference;
+ typedef _Alloc allocator_type;
+
+ static const size_type npos;
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ class iterator;
+ class reverse_iterator;
+ class const_iterator;
+ class const_reverse_iterator;
+#endif
+
+
+ %traits_swigtype(_CharT);
+ %fragment(SWIG_Traits_frag(_CharT));
+
+
+ basic_string(const _CharT* __s, size_type __n);
+
+ // Capacity:
+
+ size_type length() const;
+
+ size_type max_size() const;
+
+ size_type capacity() const;
+
+ void reserve(size_type __res_arg = 0);
+
+
+ // Modifiers:
+
+ basic_string&
+ append(const basic_string& __str);
+
+ basic_string&
+ append(const basic_string& __str, size_type __pos, size_type __n);
+
+ basic_string&
+ append(const _CharT* __s, size_type __n);
+
+ basic_string&
+ append(size_type __n, _CharT __c);
+
+ basic_string&
+ assign(const basic_string& __str);
+
+ basic_string&
+ assign(const basic_string& __str, size_type __pos, size_type __n);
+
+ basic_string&
+ assign(const _CharT* __s, size_type __n);
+
+ basic_string&
+ insert(size_type __pos1, const basic_string& __str);
+
+ basic_string&
+ insert(size_type __pos1, const basic_string& __str,
+ size_type __pos2, size_type __n);
+
+ basic_string&
+ insert(size_type __pos, const _CharT* __s, size_type __n);
+
+ basic_string&
+ insert(size_type __pos, size_type __n, _CharT __c);
+
+ basic_string&
+ erase(size_type __pos = 0, size_type __n = npos);
+
+ basic_string&
+ replace(size_type __pos, size_type __n, const basic_string& __str);
+
+ basic_string&
+ replace(size_type __pos1, size_type __n1, const basic_string& __str,
+ size_type __pos2, size_type __n2);
+
+ basic_string&
+ replace(size_type __pos, size_type __n1, const _CharT* __s,
+ size_type __n2);
+
+ basic_string&
+ replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c);
+
+
+ size_type
+ copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
+
+ // String operations:
+ const _CharT* c_str() const;
+
+ size_type
+ find(const _CharT* __s, size_type __pos, size_type __n) const;
+
+ size_type
+ find(const basic_string& __str, size_type __pos = 0) const;
+
+ size_type
+ find(_CharT __c, size_type __pos = 0) const;
+
+ size_type
+ rfind(const basic_string& __str, size_type __pos = npos) const;
+
+ size_type
+ rfind(const _CharT* __s, size_type __pos, size_type __n) const;
+
+ size_type
+ rfind(_CharT __c, size_type __pos = npos) const;
+
+ size_type
+ find_first_of(const basic_string& __str, size_type __pos = 0) const;
+
+ size_type
+ find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
+
+ size_type
+ find_first_of(_CharT __c, size_type __pos = 0) const;
+
+ size_type
+ find_last_of(const basic_string& __str, size_type __pos = npos) const;
+
+ size_type
+ find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
+
+ size_type
+ find_last_of(_CharT __c, size_type __pos = npos) const;
+
+ size_type
+ find_first_not_of(const basic_string& __str, size_type __pos = 0) const;
+
+ size_type
+ find_first_not_of(const _CharT* __s, size_type __pos,
+ size_type __n) const;
+
+ size_type
+ find_first_not_of(_CharT __c, size_type __pos = 0) const;
+
+ size_type
+ find_last_not_of(const basic_string& __str, size_type __pos = npos) const;
+
+ size_type
+ find_last_not_of(const _CharT* __s, size_type __pos,
+ size_type __n) const;
+
+ size_type
+ find_last_not_of(_CharT __c, size_type __pos = npos) const;
+
+ basic_string
+ substr(size_type __pos = 0, size_type __n = npos) const;
+
+ int
+ compare(const basic_string& __str) const;
+
+ int
+ compare(size_type __pos, size_type __n, const basic_string& __str) const;
+
+ int
+ compare(size_type __pos1, size_type __n1, const basic_string& __str,
+ size_type __pos2, size_type __n2) const;
+
+
+ %ignore pop_back();
+ %ignore front() const;
+ %ignore back() const;
+ %ignore basic_string(size_type n);
+ %std_sequence_methods_val(basic_string);
+
+
+ %ignore pop();
+
+
+#ifdef %swig_basic_string
+ // Add swig/language extra methods
+ %swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >);
+#endif
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+
+
+ class iterator;
+ class reverse_iterator;
+ class const_iterator;
+ class const_reverse_iterator;
+
+
+ void
+ insert(iterator __p, size_type __n, _CharT __c);
+
+ basic_string&
+ replace(iterator __i1, iterator __i2, const basic_string& __str);
+
+ basic_string&
+ replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n);
+
+ basic_string&
+ replace(iterator __i1, iterator __i2, size_type __n, _CharT __c);
+
+
+ basic_string&
+ replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2);
+
+ basic_string&
+ replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2);
+#endif
+
+ basic_string& operator +=(const basic_string& v);
+
+ %newobject __add__;
+ %newobject __radd__;
+ %extend {
+
+ std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) {
+ std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self);
+ *res += v;
+ return res;
+ }
+
+ std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) {
+ std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v);
+ *res += *self;
+ return res;
+ }
+
+ std::basic_string<_CharT,_Traits,_Alloc > __str__() {
+ return *self;
+ }
+
+ std::basic_ostream<_CharT, std::char_traits<_CharT> >&
+ __rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) {
+ out << *self;
+ return out;
+ }
+ }
+
+ };
+}
+
+
diff --git a/std/std_carray.swg b/std/std_carray.swg
new file mode 100644
index 0000000..ebb20ce
--- /dev/null
+++ b/std/std_carray.swg
@@ -0,0 +1,64 @@
+%{
+#include <algorithm>
+%}
+
+//
+// std::carray - is really an extension to the 'std' namespace.
+//
+// A simple fix C array wrapper, more or less as presented in
+//
+// "The C++ Standarf Library", by Nicolai M. Josuttis
+//
+// which is also derived from the example in
+//
+// "The C++ Programming Language", by Bjarne Stroustup.
+//
+
+%inline %{
+namespace std {
+ template <class _Type, size_t _Size>
+ class carray
+ {
+ public:
+ typedef _Type value_type;
+ typedef size_t size_type;
+
+ typedef _Type * iterator;
+ typedef const _Type * const_iterator;
+
+ carray() { }
+
+ carray(const carray& c) {
+ std::copy(c.v, c.v + size(), v);
+ }
+
+ template <class _Iterator>
+ carray(_Iterator first, _Iterator last) {
+ assign(first, last);
+ }
+
+ iterator begin() { return v; }
+ iterator end() { return v + _Size; }
+
+ const_iterator begin() const { return v; }
+ const_iterator end() const { return v + _Size; }
+
+ _Type& operator[](size_t i) { return v[i]; }
+ const _Type& operator[](size_t i) const { return v[i]; }
+
+ static size_t size() { return _Size; }
+
+ template <class _Iterator>
+ void assign(_Iterator first, _Iterator last) {
+ if (std::distance(first,last) == size()) {
+ std::copy(first, last, v);
+ } else {
+ throw std::length_error("bad range length");
+ }
+ }
+
+ private:
+ _Type v[_Size];
+ };
+}
+%}
diff --git a/std/std_char_traits.i b/std/std_char_traits.i
new file mode 100644
index 0000000..b9b4def
--- /dev/null
+++ b/std/std_char_traits.i
@@ -0,0 +1,140 @@
+%include <std_common.i>
+#if defined(SWIG_WCHAR)
+%include <wchar.i>
+#endif
+
+namespace std
+{
+
+ /// 21.1.2 Basis for explicit _Traits specialization
+ /// NB: That for any given actual character type this definition is
+ /// probably wrong.
+ template<class _CharT>
+ struct char_traits
+ {
+ };
+
+
+ /// 21.1.4 char_traits specializations
+ template<>
+ struct char_traits<char> {
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+ typedef mbstate_t state_type;
+
+ static void
+ assign(char_type& __c1, const char_type& __c2);
+
+ static bool
+ eq(const char_type& __c1, const char_type& __c2);
+
+ static bool
+ lt(const char_type& __c1, const char_type& __c2);
+
+ static int
+ compare(const char_type* __s1, const char_type* __s2, size_t __n);
+
+ static size_t
+ length(const char_type* __s);
+
+ static const char_type*
+ find(const char_type* __s, size_t __n, const char_type& __a);
+
+ static char_type*
+ move(char_type* __s1, const char_type* __s2, size_t __n);
+
+ static char_type*
+ copy(char_type* __s1, const char_type* __s2, size_t __n);
+
+ static char_type*
+ assign(char_type* __s, size_t __n, char_type __a);
+
+ static char_type
+ to_char_type(const int_type& __c);
+
+ // To keep both the byte 0xff and the eof symbol 0xffffffff
+ // from ending up as 0xffffffff.
+ static int_type
+ to_int_type(const char_type& __c);
+
+ static bool
+ eq_int_type(const int_type& __c1, const int_type& __c2);
+
+ static int_type
+ eof() ;
+
+ static int_type
+ not_eof(const int_type& __c);
+ };
+
+
+#if defined(SWIG_WCHAR)
+ template<>
+ struct char_traits<wchar_t>
+ {
+ typedef wchar_t char_type;
+ typedef wint_t int_type;
+ typedef streamoff off_type;
+ typedef wstreampos pos_type;
+ typedef mbstate_t state_type;
+
+ static void
+ assign(char_type& __c1, const char_type& __c2);
+
+ static bool
+ eq(const char_type& __c1, const char_type& __c2);
+
+ static bool
+ lt(const char_type& __c1, const char_type& __c2);
+
+ static int
+ compare(const char_type* __s1, const char_type* __s2, size_t __n);
+
+ static size_t
+ length(const char_type* __s);
+
+ static const char_type*
+ find(const char_type* __s, size_t __n, const char_type& __a);
+
+ static char_type*
+ move(char_type* __s1, const char_type* __s2, int_type __n);
+
+ static char_type*
+ copy(char_type* __s1, const char_type* __s2, size_t __n);
+
+ static char_type*
+ assign(char_type* __s, size_t __n, char_type __a);
+
+ static char_type
+ to_char_type(const int_type& __c) ;
+
+ static int_type
+ to_int_type(const char_type& __c) ;
+
+ static bool
+ eq_int_type(const int_type& __c1, const int_type& __c2);
+
+ static int_type
+ eof() ;
+
+ static int_type
+ not_eof(const int_type& __c);
+ };
+#endif
+}
+
+namespace std {
+#ifndef SWIG_STL_WRAP_TRAITS
+%template() char_traits<char>;
+#if defined(SWIG_WCHAR)
+%template() char_traits<wchar_t>;
+#endif
+#else
+%template(char_traits_c) char_traits<char>;
+#if defined(SWIG_WCHAR)
+%template(char_traits_w) char_traits<wchar_t>;
+#endif
+#endif
+}
diff --git a/std/std_common.i b/std/std_common.i
new file mode 100644
index 0000000..8b133c2
--- /dev/null
+++ b/std/std_common.i
@@ -0,0 +1,238 @@
+%include <std/std_except.i>
+
+//
+// Use the following macro with modern STL implementations
+//
+//#define SWIG_STD_MODERN_STL
+//
+// Use this to deactive the previous definition, when using gcc-2.95
+// or similar old compilers.
+//
+//#define SWIG_STD_NOMODERN_STL
+
+// Here, we identify compilers we know have problems with STL.
+%{
+#if defined(__GNUC__)
+# if __GNUC__ == 2 && __GNUC_MINOR <= 96
+# define SWIG_STD_NOMODERN_STL
+# endif
+#endif
+%}
+
+//
+// Common code for supporting the STD C++ namespace
+//
+
+%{
+#include <string>
+#include <stdexcept>
+%}
+
+
+%fragment("StdIteratorTraits","header") %{
+#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
+# if !defined(SWIG_NO_STD_NOITERATOR_TRAITS_STL)
+# define SWIG_STD_NOITERATOR_TRAITS_STL
+# endif
+#endif
+
+#if !defined(SWIG_STD_NOITERATOR_TRAITS_STL)
+#include <iterator>
+#else
+namespace std {
+ template <class Iterator>
+ struct iterator_traits {
+ typedef ptrdiff_t difference_type;
+ typedef typename Iterator::value_type value_type;
+ };
+
+ template <class Iterator, class Category,class T, class Reference, class Pointer, class Distance>
+ struct iterator_traits<__reverse_bi_iterator<Iterator,Category,T,Reference,Pointer,Distance> > {
+ typedef Distance difference_type;
+ typedef T value_type;
+ };
+
+ template <class T>
+ struct iterator_traits<T*> {
+ typedef T value_type;
+ typedef ptrdiff_t difference_type;
+ };
+
+ template<typename _InputIterator>
+ inline typename iterator_traits<_InputIterator>::difference_type
+ distance(_InputIterator __first, _InputIterator __last)
+ {
+ typename iterator_traits<_InputIterator>::difference_type __n = 0;
+ while (__first != __last) {
+ ++__first; ++__n;
+ }
+ return __n;
+ }
+}
+#endif
+%}
+
+%fragment("StdTraitsCommon","header") %{
+namespace swig {
+ template <class Type>
+ struct noconst_traits {
+ typedef Type noconst_type;
+ };
+
+ template <class Type>
+ struct noconst_traits<const Type> {
+ typedef Type noconst_type;
+ };
+
+ /*
+ type categories
+ */
+ struct pointer_category { };
+ struct value_category { };
+
+ /*
+ General traits that provides type_name and type_info
+ */
+ template <class Type> struct traits { };
+
+ template <class Type>
+ inline const char* type_name() {
+ return traits<typename noconst_traits<Type >::noconst_type >::type_name();
+ }
+
+ template <class Type>
+ struct traits_info {
+ static swig_type_info *type_query(std::string name) {
+ name += " *";
+ return SWIG_TypeQuery(name.c_str());
+ }
+ static swig_type_info *type_info() {
+ static swig_type_info *info = type_query(type_name<Type>());
+ return info;
+ }
+ };
+
+ template <class Type>
+ inline swig_type_info *type_info() {
+ return traits_info<Type>::type_info();
+ }
+
+ /*
+ Partial specialization for pointers
+ */
+ template <class Type> struct traits <Type *> {
+ typedef pointer_category category;
+ static std::string make_ptr_name(const char* name) {
+ std::string ptrname = name;
+ ptrname += " *";
+ return ptrname;
+ }
+ static const char* type_name() {
+ static std::string name = make_ptr_name(swig::type_name<Type>());
+ return name.c_str();
+ }
+ };
+
+ template <class Type, class Category>
+ struct traits_as { };
+
+ template <class Type, class Category>
+ struct traits_check { };
+
+}
+%}
+
+/*
+ Generate the traits for a swigtype
+*/
+
+%define %traits_swigtype(Type...)
+%fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") {
+ namespace swig {
+ template <> struct traits<Type > {
+ typedef pointer_category category;
+ static const char* type_name() { return #Type; }
+ };
+ }
+}
+%enddef
+
+
+
+/*
+ Generate the typemaps for a class that has 'value' traits
+*/
+
+%define %typemap_traits(Code,Type...)
+ %typemaps_asvalfrom(%arg(Code),
+ %arg(swig::asval<Type >),
+ %arg(swig::from),
+ %arg(SWIG_Traits_frag(Type)),
+ %arg(SWIG_Traits_frag(Type)),
+ Type);
+%enddef
+
+/*
+ Generate the typemaps for a class that behaves more like a 'pointer' or
+ plain wrapped Swigtype.
+*/
+
+%define %typemap_traits_ptr(Code,Type...)
+ %typemaps_asptrfrom(%arg(Code),
+ %arg(swig::asptr),
+ %arg(swig::from),
+ %arg(SWIG_Traits_frag(Type)),
+ %arg(SWIG_Traits_frag(Type)),
+ Type);
+%enddef
+
+
+/*
+ Equality methods
+*/
+%define %std_equal_methods(Type...)
+%extend Type {
+ bool operator == (const Type& v) {
+ return *self == v;
+ }
+
+ bool operator != (const Type& v) {
+ return *self != v;
+ }
+}
+
+%enddef
+
+/*
+ Order methods
+*/
+
+%define %std_order_methods(Type...)
+%extend Type {
+ bool operator > (const Type& v) {
+ return *self > v;
+ }
+
+ bool operator < (const Type& v) {
+ return *self < v;
+ }
+
+ bool operator >= (const Type& v) {
+ return *self >= v;
+ }
+
+ bool operator <= (const Type& v) {
+ return *self <= v;
+ }
+}
+%enddef
+
+/*
+ Comparison methods
+*/
+
+%define %std_comp_methods(Type...)
+%std_equal_methods(Type )
+%std_order_methods(Type )
+%enddef
+
diff --git a/std/std_container.i b/std/std_container.i
new file mode 100644
index 0000000..66a9efa
--- /dev/null
+++ b/std/std_container.i
@@ -0,0 +1,109 @@
+%include <std_common.i>
+%include <exception.i>
+%include <std_alloc.i>
+
+%{
+#include <algorithm>
+%}
+
+// Common container methods
+
+%define %std_container_methods(container...)
+ container();
+ container(const container&);
+
+ bool empty() const;
+ size_type size() const;
+ void clear();
+
+ void swap(container& v);
+
+ allocator_type get_allocator() const;
+
+ #ifdef SWIG_EXPORT_ITERATOR_METHODS
+ class iterator;
+ class reverse_iterator;
+ class const_iterator;
+ class const_reverse_iterator;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+ const_reverse_iterator rbegin() const;
+ const_reverse_iterator rend() const;
+ #endif
+
+%enddef
+
+// Common sequence
+
+%define %std_sequence_methods_common(sequence)
+
+ %std_container_methods(%arg(sequence));
+
+ sequence(size_type size);
+ void pop_back();
+
+ void resize(size_type new_size);
+
+ #ifdef SWIG_EXPORT_ITERATOR_METHODS
+ iterator erase(iterator pos);
+ iterator erase(iterator first, iterator last);
+ #endif
+
+%enddef
+
+
+%define %std_sequence_methods(sequence)
+
+ %std_sequence_methods_common(%arg(sequence));
+
+ sequence(size_type size, const value_type& value);
+ void push_back(const value_type& x);
+
+ const value_type& front() const;
+ const value_type& back() const;
+
+ void assign(size_type n, const value_type& x);
+
+ void resize(size_type new_size, const value_type& x);
+
+ #ifdef SWIG_EXPORT_ITERATOR_METHODS
+ iterator insert(iterator pos, const value_type& x);
+ void insert(iterator pos, size_type n, const value_type& x);
+ #endif
+
+%enddef
+
+%define %std_sequence_methods_val(sequence...)
+
+ %std_sequence_methods_common(%arg(sequence));
+
+ sequence(size_type size, value_type value);
+ void push_back(value_type x);
+
+ value_type front() const;
+ value_type back() const;
+
+ void assign(size_type n, value_type x);
+
+ void resize(size_type new_size, value_type x);
+
+ #ifdef SWIG_EXPORT_ITERATOR_METHODS
+ iterator insert(iterator pos, value_type x);
+ void insert(iterator pos, size_type n, value_type x);
+ #endif
+
+%enddef
+
+
+//
+// Ignore member methods for Type with no default constructor
+//
+%define %std_nodefconst_type(Type...)
+%feature("ignore") std::vector<Type >::vector(size_type size);
+%feature("ignore") std::vector<Type >::resize(size_type size);
+%feature("ignore") std::deque<Type >::deque(size_type size);
+%feature("ignore") std::deque<Type >::resize(size_type size);
+%feature("ignore") std::list<Type >::list(size_type size);
+%feature("ignore") std::list<Type >::resize(size_type size);
+%enddef
diff --git a/std/std_deque.i b/std/std_deque.i
new file mode 100644
index 0000000..a99763b
--- /dev/null
+++ b/std/std_deque.i
@@ -0,0 +1,127 @@
+//
+// std::deque
+
+%include <std_container.i>
+
+// Deque
+
+%define %std_deque_methods(deque...)
+ %std_sequence_methods(deque)
+
+ void pop_front();
+ void push_front(const value_type& x);
+%enddef
+
+%define %std_deque_methods_val(deque...)
+ %std_sequence_methods_val(deque)
+
+ void pop_front();
+ void push_front(value_type x);
+%enddef
+
+// ------------------------------------------------------------------------
+// std::deque
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::deque<T>), f(const std::deque<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::deque<T> can be passed.
+// -- f(std::deque<T>&), f(std::deque<T>*):
+// the parameter may be modified; therefore, only a wrapped std::deque
+// can be passed.
+// -- std::deque<T> f(), const std::deque<T>& f():
+// the deque is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::deque<T>& f(), std::deque<T>* f():
+// the deque is returned by reference; therefore, a wrapped std::deque
+// is returned
+// -- const std::deque<T>* f(), f(const std::deque<T>*):
+// for consistency, they expect and return a plain deque pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <deque>
+%}
+
+// exported classes
+
+namespace std {
+
+ template<class _Tp, class _Alloc = allocator<_Tp> >
+ class deque {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdDequeTraits") {
+ namespace swig {
+ template <> struct traits<std::deque<_Tp, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::deque<" #_Tp " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >);
+
+#ifdef %swig_deque_methods
+ // Add swig/language extra methods
+ %swig_deque_methods(std::deque<_Tp, _Alloc >);
+#endif
+
+ %std_deque_methods(deque);
+ };
+
+ template<class _Tp, class _Alloc >
+ class deque<_Tp*, _Alloc > {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp* value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type reference;
+ typedef value_type const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdDequeTraits") {
+ namespace swig {
+ template <> struct traits<std::deque<_Tp*, _Alloc > > {
+ typedef value_category category;
+ static const char* type_name() {
+ return "std::deque<" #_Tp " * >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >);
+
+#ifdef %swig_deque_methods_val
+ // Add swig/language extra methods
+ %swig_deque_methods_val(std::deque<_Tp*, _Alloc >);
+#endif
+
+ %std_deque_methods_val(std::deque<_Tp*, _Alloc >);
+ };
+
+}
+
diff --git a/std/std_except.i b/std/std_except.i
new file mode 100644
index 0000000..75b8d0f
--- /dev/null
+++ b/std/std_except.i
@@ -0,0 +1,68 @@
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+#error "do not use this version of std_except.i"
+#endif
+
+%{
+#include <stdexcept>
+%}
+
+#if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES)
+
+namespace std {
+ struct exception
+ {
+ virtual ~exception() throw();
+ virtual const char* what() const throw();
+ };
+
+ struct bad_exception : exception
+ {
+ };
+
+ struct logic_error : exception
+ {
+ logic_error(const string& msg);
+ };
+
+ struct domain_error : logic_error
+ {
+ domain_error(const string& msg);
+ };
+
+ struct invalid_argument : logic_error
+ {
+ invalid_argument(const string& msg);
+ };
+
+ struct length_error : logic_error
+ {
+ length_error(const string& msg);
+ };
+
+ struct out_of_range : logic_error
+ {
+ out_of_range(const string& msg);
+ };
+
+ struct runtime_error : exception
+ {
+ runtime_error(const string& msg);
+ };
+
+ struct range_error : runtime_error
+ {
+ range_error(const string& msg);
+ };
+
+ struct overflow_error : runtime_error
+ {
+ overflow_error(const string& msg);
+ };
+
+ struct underflow_error : runtime_error
+ {
+ underflow_error(const string& msg);
+ };
+}
+
+#endif
diff --git a/std/std_ios.i b/std/std_ios.i
new file mode 100644
index 0000000..75484f3
--- /dev/null
+++ b/std/std_ios.i
@@ -0,0 +1,260 @@
+%include <std_char_traits.i>
+%include <std_basic_string.i>
+%include <std_except.i>
+%{
+#ifndef SWIG_STD_NOMODERN_STL
+# include <ios>
+#else
+# include <streambuf.h>
+#endif
+%}
+
+namespace std {
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_streambuf;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_istream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ostream;
+
+ // 27.4.2 Class ios_base
+ typedef size_t streamsize;
+
+ class locale;
+
+
+ class ios_base
+ {
+ public:
+
+#ifdef SWIG_NESTED_CLASSES
+ // 27.4.2.1.1 Class ios_base::failure
+ class failure : public exception
+ {
+ public:
+ explicit failure(const string& __str) throw();
+ };
+#endif
+
+ // 27.4.2.1.2 Type ios_base::fmtflags
+ typedef int fmtflags;
+ // 27.4.2.1.2 Type fmtflags
+ static const fmtflags boolalpha ;
+ static const fmtflags dec ;
+ static const fmtflags fixed ;
+ static const fmtflags hex ;
+ static const fmtflags internal ;
+ static const fmtflags left ;
+ static const fmtflags oct ;
+ static const fmtflags right ;
+ static const fmtflags scientific ;
+ static const fmtflags showbase ;
+ static const fmtflags showpoint ;
+ static const fmtflags showpos ;
+ static const fmtflags skipws ;
+ static const fmtflags unitbuf ;
+ static const fmtflags uppercase ;
+ static const fmtflags adjustfield ;
+ static const fmtflags basefield ;
+ static const fmtflags floatfield ;
+
+ // 27.4.2.1.3 Type ios_base::iostate
+ typedef int iostate;
+ static const iostate badbit ;
+ static const iostate eofbit ;
+ static const iostate failbit ;
+ static const iostate goodbit ;
+
+ // 27.4.2.1.4 Type openmode
+ typedef int openmode;
+ static const openmode app ;
+ static const openmode ate ;
+ static const openmode binary ;
+ static const openmode in ;
+ static const openmode out ;
+ static const openmode trunc ;
+
+ // 27.4.2.1.5 Type seekdir
+ typedef int seekdir;
+ static const seekdir beg ;
+ static const seekdir cur ;
+ static const seekdir end ;
+
+
+ // Callbacks;
+ enum event
+ {
+ erase_event,
+ imbue_event,
+ copyfmt_event
+ };
+
+ typedef void (*event_callback) (event, ios_base&, int);
+
+ void
+ register_callback(event_callback __fn, int __index);
+
+ // Fmtflags state:
+ inline fmtflags
+ flags() const ;
+
+ inline fmtflags
+ flags(fmtflags __fmtfl);
+
+ inline fmtflags
+ setf(fmtflags __fmtfl);
+
+ inline fmtflags
+ setf(fmtflags __fmtfl, fmtflags __mask);
+
+ inline void
+ unsetf(fmtflags __mask) ;
+
+ inline streamsize
+ precision() const ;
+
+ inline streamsize
+ precision(streamsize __prec);
+
+ inline streamsize
+ width() const ;
+
+ inline streamsize
+ width(streamsize __wide);
+
+ static bool
+ sync_with_stdio(bool __sync = true);
+
+ // Locales:
+ locale
+ imbue(const locale& __loc);
+
+ inline locale
+ getloc() const { return _M_ios_locale; }
+
+ // Storage:
+ static int
+ xalloc() throw();
+
+ inline long&
+ iword(int __ix);
+
+ inline void*&
+ pword(int __ix);
+
+ // Destructor
+ ~ios_base();
+
+ protected:
+ ios_base();
+
+ //50. Copy constructor and assignment operator of ios_base
+ private:
+ ios_base(const ios_base&);
+
+ ios_base&
+ operator=(const ios_base&);
+ };
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ios : public ios_base
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+ public:
+
+ iostate
+ rdstate() const;
+
+ void
+ clear(iostate __state = goodbit);
+
+ void
+ setstate(iostate __state);
+
+ bool
+ good() const;
+
+ bool
+ eof() const;
+
+ bool
+ fail() const;
+
+ bool
+ bad() const;
+
+ iostate
+ exceptions() const;
+
+ void
+ exceptions(iostate __except);
+
+ // Constructor/destructor:
+ explicit
+ basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base();
+
+ virtual
+ ~basic_ios() ;
+
+ // Members:
+ basic_ostream<_CharT, _Traits>*
+ tie() const;
+
+ basic_ostream<_CharT, _Traits>*
+ tie(basic_ostream<_CharT, _Traits>* __tiestr);
+
+ basic_streambuf<_CharT, _Traits>*
+ rdbuf() const;
+
+ basic_streambuf<_CharT, _Traits>*
+ rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
+
+ basic_ios&
+ copyfmt(const basic_ios& __rhs);
+
+ char_type
+ fill() const;
+
+ char_type
+ fill(char_type __ch);
+
+ // Locales:
+ locale
+ imbue(const locale& __loc);
+
+ char
+ narrow(char_type __c, char __dfault) const;
+
+ char_type
+ widen(char __c) const;
+
+ protected:
+ // 27.4.5.1 basic_ios constructors
+ basic_ios();
+ private:
+ ios_base(const ios_base&);
+
+ ios_base&
+ operator=(const ios_base&);
+ };
+
+}
+
+namespace std {
+ %template(ios) basic_ios<char>;
+#if defined(SWIG_WCHAR)
+ %template(wios) basic_ios<wchar_t>;
+#endif
+}
+
+
diff --git a/std/std_iostream.i b/std/std_iostream.i
new file mode 100644
index 0000000..7a33afe
--- /dev/null
+++ b/std/std_iostream.i
@@ -0,0 +1,339 @@
+/*
+ For wchar support, you need to include the wchar.i file
+ before this file, ie:
+
+ %include <wchar.i>
+ %include <std_iostream.i>
+
+ or equivalently, just include
+
+ %include <std_wiostream.i>
+*/
+
+%include <std_ios.i>
+%include <std_basic_string.i>
+%include <std_string.i>
+#if defined(SWIG_WCHAR)
+%include <std_wstring.i>
+#endif
+
+%{
+#include <iostream>
+%}
+
+
+namespace std
+{
+ // 27.6.2.1 Template class basic_ostream
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ostream : virtual public basic_ios<_CharT, _Traits>
+ {
+ public:
+ // Types (inherited from basic_ios (27.4.4)):
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+ // 27.6.2.2 Constructor/destructor:
+ explicit
+ basic_ostream(basic_streambuf<_CharT, _Traits>* __sb);
+
+ virtual
+ ~basic_ostream();
+
+ // 27.6.2.5 Formatted output:
+ // 27.6.2.5.3 basic_ostream::operator<<
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&));
+
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&));
+
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(ios_base& (*__pf) (ios_base&));
+
+ // 27.6.2.5.2 Arithmetic Inserters
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(long __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(unsigned long __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(bool __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(short __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(unsigned short __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(int __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(unsigned int __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(long long __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(unsigned long long __n);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(double __f);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(float __f);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(long double __f);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(const void* __p);
+
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_streambuf<_CharT, _Traits>* __sb);
+
+ %extend {
+ std::basic_ostream<_CharT, _Traits >&
+ operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s)
+ {
+ *self << s;
+ return *self;
+ }
+ }
+
+ // Unformatted output:
+ basic_ostream<_CharT, _Traits>&
+ put(char_type __c);
+
+ basic_ostream<_CharT, _Traits>&
+ write(const char_type* __s, streamsize __n);
+
+ basic_ostream<_CharT, _Traits>&
+ flush();
+
+ // Seeks:
+ pos_type
+ tellp();
+
+ basic_ostream<_CharT, _Traits>&
+ seekp(pos_type);
+
+ basic_ostream<_CharT, _Traits>&
+ seekp(off_type, ios_base::seekdir);
+
+ };
+
+ // 27.6.1.1 Template class basic_istream
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_istream : virtual public basic_ios<_CharT, _Traits>
+ {
+ public:
+ // Types (inherited from basic_ios (27.4.4)):
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+
+ public:
+ // 27.6.1.1.1 Constructor/destructor:
+ explicit
+ basic_istream(basic_streambuf<_CharT, _Traits>* __sb);
+
+ virtual
+ ~basic_istream();
+
+ // 27.6.1.2.3 basic_istream::operator>>
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& (*__pf)(basic_istream<_CharT, _Traits>&));
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&));
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(ios_base& (*__pf)(ios_base&));
+
+ // 27.6.1.2.2 Arithmetic Extractors
+ basic_istream<_CharT, _Traits>&
+ operator>>(bool& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(short& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(unsigned short& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(int& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(unsigned int& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(long& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(unsigned long& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(long long& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(unsigned long long& __n);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(float& __f);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(double& __f);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(long double& __f);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(void*& __p);
+
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_streambuf<_CharT, _Traits>* __sb);
+
+ // 27.6.1.3 Unformatted input:
+ inline streamsize
+ gcount(void) const;
+
+ int_type
+ get(void);
+
+ basic_istream<_CharT, _Traits>&
+ get(char_type& __c);
+
+ basic_istream<_CharT, _Traits>&
+ get(char_type* __s, streamsize __n, char_type __delim);
+
+ inline basic_istream<_CharT, _Traits>&
+ get(char_type* __s, streamsize __n);
+
+ basic_istream<_CharT, _Traits>&
+ get(basic_streambuf<_CharT, _Traits>& __sb, char_type __delim);
+
+ inline basic_istream<_CharT, _Traits>&
+ get(basic_streambuf<_CharT, _Traits>& __sb);
+
+ basic_istream<_CharT, _Traits>&
+ getline(char_type* __s, streamsize __n, char_type __delim);
+
+ inline basic_istream<_CharT, _Traits>&
+ getline(char_type* __s, streamsize __n);
+
+ basic_istream<_CharT, _Traits>&
+ ignore(streamsize __n = 1, int_type __delim = _Traits::eof());
+
+ int_type
+ peek(void);
+
+ basic_istream<_CharT, _Traits>&
+ read(char_type* __s, streamsize __n);
+
+ streamsize
+ readsome(char_type* __s, streamsize __n);
+
+ basic_istream<_CharT, _Traits>&
+ putback(char_type __c);
+
+ basic_istream<_CharT, _Traits>&
+ unget(void);
+
+ int
+ sync(void);
+
+ pos_type
+ tellg(void);
+
+ basic_istream<_CharT, _Traits>&
+ seekg(pos_type);
+
+ basic_istream<_CharT, _Traits>&
+ seekg(off_type, ios_base::seekdir);
+ };
+
+ // 27.6.1.5 Template class basic_iostream
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_iostream
+ : public basic_istream<_CharT, _Traits>,
+ public basic_ostream<_CharT, _Traits>
+ {
+ public:
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+ explicit
+ basic_iostream(basic_streambuf<_CharT, _Traits>* __sb);
+
+ virtual
+ ~basic_iostream();
+ };
+
+ typedef basic_ostream<char> ostream ;
+ typedef basic_istream<char> istream;
+ typedef basic_iostream<char> iostream;
+
+ extern istream cin;
+ extern ostream cout;
+ extern ostream cerr;
+ extern ostream clog;
+
+#if defined(SWIG_WCHAR)
+ typedef basic_ostream<wchar_t> wostream;
+ typedef basic_istream<wchar_t> wistream;
+ typedef basic_iostream<wchar_t> wiostream;
+
+ extern wistream wcin;
+ extern wostream wcout;
+ extern wostream wcerr;
+ extern wostream wclog;
+#endif
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ std::basic_ostream<_CharT, _Traits>&
+ endl(std::basic_ostream<_CharT, _Traits>&);
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ std::basic_ostream<_CharT, _Traits>&
+ ends(std::basic_ostream<_CharT, _Traits>&);
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ std::basic_ostream<_CharT, _Traits>&
+ flush(std::basic_ostream<_CharT, _Traits>&);
+}
+
+namespace std {
+ %template(ostream) basic_ostream<char>;
+ %template(istream) basic_istream<char>;
+ %template(iostream) basic_iostream<char>;
+
+ %template(endl) endl<char, std::char_traits<char> >;
+ %template(ends) ends<char, std::char_traits<char> >;
+ %template(flush) flush<char, std::char_traits<char> >;
+
+#if defined(SWIG_WCHAR)
+ %template(wostream) basic_ostream<wchar_t>;
+ %template(wistream) basic_istream<wchar_t>;
+ %template(wiostream) basic_iostream<wchar_t>;
+
+ %template(wendl) endl<wchar_t, std::char_traits<wchar_t> >;
+ %template(wends) ends<wchar_t, std::char_traits<wchar_t> >;
+ %template(wflush) flush<wchar_t, std::char_traits<wchar_t> >;
+#endif
+}
+
diff --git a/std/std_list.i b/std/std_list.i
new file mode 100644
index 0000000..e089351
--- /dev/null
+++ b/std/std_list.i
@@ -0,0 +1,148 @@
+//
+// std::list
+//
+
+%include <std_container.i>
+
+// List
+
+%define %std_list_methods(list)
+ %std_sequence_methods(list)
+
+ void pop_front();
+ void push_front(const value_type& x);
+
+ void reverse();
+
+%enddef
+
+
+%define %std_list_methods_val(list)
+ %std_sequence_methods_val(list)
+
+ void pop_front();
+ void push_front(value_type x);
+
+ void remove(value_type x);
+ void unique();
+ void reverse();
+ void sort();
+
+ void merge(list& x);
+%enddef
+
+// ------------------------------------------------------------------------
+// std::list
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::list<T>), f(const std::list<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::list<T> can be passed.
+// -- f(std::list<T>&), f(std::list<T>*):
+// the parameter may be modified; therefore, only a wrapped std::list
+// can be passed.
+// -- std::list<T> f(), const std::list<T>& f():
+// the list is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::list<T>& f(), std::list<T>* f():
+// the list is returned by reference; therefore, a wrapped std::list
+// is returned
+// -- const std::list<T>* f(), f(const std::list<T>*):
+// for consistency, they expect and return a plain list pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <list>
+%}
+
+// exported classes
+
+namespace std {
+
+ template<class _Tp, class _Alloc = allocator<_Tp> >
+ class list {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::list<_Tp, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdListTraits") {
+ namespace swig {
+ template <> struct traits<std::list<_Tp, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::list<" #_Tp ", " #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp, _Alloc >);
+
+#ifdef %swig_list_methods
+ // Add swig/language extra methods
+ %swig_list_methods(std::list<_Tp, _Alloc >);
+#endif
+
+ %std_list_methods(list);
+ };
+
+ template<class _Tp, class _Alloc >
+ class list<_Tp*, _Alloc> {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp* value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type reference;
+ typedef value_type const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::list<_Tp*, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdListTraits") {
+ namespace swig {
+ template <> struct traits<std::list<_Tp*, _Alloc > > {
+ typedef value_category category;
+ static const char* type_name() {
+ return "std::list<" #_Tp " *," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp*, _Alloc >);
+
+#ifdef %swig_list_methods_val
+ // Add swig/language extra methods
+ %swig_list_methods_val(std::list<_Tp*, _Alloc >);
+#endif
+
+ %std_list_methods_val(list);
+ };
+
+}
+
+%define %std_extequal_list(...)
+%extend std::list<__VA_ARGS__ > {
+ void remove(const value_type& x) { self->remove(x); }
+ void merge(std::list<__VA_ARGS__ >& x){ self->merge(x); }
+ void unique() { self->unique(); }
+ void sort() { self->sort(); }
+}
+%enddef
+
diff --git a/std/std_map.i b/std/std_map.i
new file mode 100644
index 0000000..0520841
--- /dev/null
+++ b/std/std_map.i
@@ -0,0 +1,124 @@
+//
+// std::map
+//
+
+%include <std_pair.i>
+%include <std_container.i>
+
+%define %std_map_methods_common(map...)
+ %std_container_methods(map);
+
+ size_type erase(const key_type& x);
+ size_type count(const key_type& x) const;
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+// iterator insert(iterator position, const value_type& x);
+ void erase(iterator position);
+ void erase(iterator first, iterator last);
+
+ iterator find(const key_type& x);
+ iterator lower_bound(const key_type& x);
+ iterator upper_bound(const key_type& x);
+#endif
+%enddef
+
+%define %std_map_methods(map...)
+ %std_map_methods_common(map);
+
+ #ifdef SWIG_EXPORT_ITERATOR_METHODS
+// iterator insert(const value_type& x);
+ #endif
+%enddef
+
+
+// ------------------------------------------------------------------------
+// std::map
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::map<T>), f(const std::map<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::map<T> can be passed.
+// -- f(std::map<T>&), f(std::map<T>*):
+// the parameter may be modified; therefore, only a wrapped std::map
+// can be passed.
+// -- std::map<T> f(), const std::map<T>& f():
+// the map is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::map<T>& f(), std::map<T>* f():
+// the map is returned by reference; therefore, a wrapped std::map
+// is returned
+// -- const std::map<T>* f(), f(const std::map<T>*):
+// for consistency, they expect and return a plain map pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <map>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+ template<class _Key, class _Tp, class _Compare = std::less<_Key >,
+ class _Alloc = allocator<std::pair<const _Key, _Tp > > >
+ class map {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef std::pair<const _Key, _Tp> value_type;
+
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header",
+ fragment=SWIG_Traits_frag(_Key),
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdPairTraits") {
+ namespace swig {
+ template <> struct traits<std::pair< _Key, _Tp > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::pair<" #_Key "," #_Tp " >";
+ }
+ };
+ }
+ }
+
+ %fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
+ fragment="StdMapTraits") {
+ namespace swig {
+ template <> struct traits<std::map<_Key, _Tp, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >);
+
+ map( const _Compare& );
+
+#ifdef %swig_map_methods
+ // Add swig/language extra methods
+ %swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >);
+#endif
+
+ %std_map_methods(map);
+ };
+
+}
diff --git a/std/std_multimap.i b/std/std_multimap.i
new file mode 100644
index 0000000..f165e5f
--- /dev/null
+++ b/std/std_multimap.i
@@ -0,0 +1,87 @@
+//
+// std::map
+//
+
+%include <std_map.i>
+
+
+%define %std_multimap_methods(mmap...)
+ %std_map_methods_common(mmap);
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ std::pair<iterator,iterator> equal_range(const key_type& x);
+ std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
+#endif
+%enddef
+
+// ------------------------------------------------------------------------
+// std::multimap
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::multimap<T>), f(const std::multimap<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::multimap<T> can be passed.
+// -- f(std::multimap<T>&), f(std::multimap<T>*):
+// the parameter may be modified; therefore, only a wrapped std::multimap
+// can be passed.
+// -- std::multimap<T> f(), const std::multimap<T>& f():
+// the map is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::multimap<T>& f(), std::multimap<T>* f():
+// the map is returned by reference; therefore, a wrapped std::multimap
+// is returned
+// -- const std::multimap<T>* f(), f(const std::multimap<T>*):
+// for consistency, they expect and return a plain map pointer.
+// ------------------------------------------------------------------------
+
+
+// exported class
+
+
+namespace std {
+ template<class _Key, class _Tp, class _Compare = std::less<_Key >,
+ class _Alloc = allocator<std::pair<const _Key, _Tp > > >
+ class multimap {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef std::pair<const _Key, _Tp> value_type;
+
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
+ fragment="StdMultimapTraits") {
+ namespace swig {
+ template <> struct traits<std::multimap<_Key, _Tp, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<_Key, _Tp, _Compare, _Alloc >);
+
+ multimap( const _Compare& );
+
+#ifdef %swig_multimap_methods
+ // Add swig/language extra methods
+ %swig_multimap_methods(std::multimap<_Key, _Tp, _Compare, _Alloc >);
+#endif
+
+ %std_multimap_methods(multimap);
+ };
+}
diff --git a/std/std_multiset.i b/std/std_multiset.i
new file mode 100644
index 0000000..98a7fb9
--- /dev/null
+++ b/std/std_multiset.i
@@ -0,0 +1,83 @@
+//
+// std::set
+//
+
+%include <std_set.i>
+
+// Multiset
+
+%define %std_multiset_methods(multiset...)
+ %std_set_methods_common(multiset);
+%enddef
+
+
+// ------------------------------------------------------------------------
+// std::multiset
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::multiset<T>), f(const std::multiset<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::multiset<T> can be passed.
+// -- f(std::multiset<T>&), f(std::multiset<T>*):
+// the parameter may be modified; therefore, only a wrapped std::multiset
+// can be passed.
+// -- std::multiset<T> f(), const std::multiset<T>& f():
+// the set is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::multiset<T>& f(), std::multiset<T>* f():
+// the set is returned by reference; therefore, a wrapped std::multiset
+// is returned
+// -- const std::multiset<T>* f(), f(const std::multiset<T>*):
+// for consistency, they expect and return a plain set pointer.
+// ------------------------------------------------------------------------
+
+
+// exported classes
+
+namespace std {
+
+ //multiset
+
+ template <class _Key, class _Compare = std::less<_Key>,
+ class _Alloc = allocator<_Key> >
+ class multiset {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key value_type;
+ typedef _Key key_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+
+ %fragment(SWIG_Traits_frag(std::multiset<_Key, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Key),
+ fragment="StdMultisetTraits") {
+ namespace swig {
+ template <> struct traits<std::multiset<_Key, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::multiset<" #_Key "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<_Key, _Compare, _Alloc >);
+
+ multiset( const _Compare& );
+
+#ifdef %swig_multiset_methods
+ // Add swig/language extra methods
+ %swig_multiset_methods(std::multiset<_Key, _Compare, _Alloc >);
+#endif
+
+ %std_multiset_methods(multiset);
+ };
+}
diff --git a/std/std_pair.i b/std/std_pair.i
new file mode 100644
index 0000000..7c83277
--- /dev/null
+++ b/std/std_pair.i
@@ -0,0 +1,163 @@
+%include <std_common.i>
+
+%{
+#include <utility>
+%}
+
+
+namespace std {
+ template <class T, class U > struct pair {
+ typedef T first_type;
+ typedef U second_type;
+
+ %traits_swigtype(T);
+ %traits_swigtype(U);
+
+ %fragment(SWIG_Traits_frag(std::pair<T,U >), "header",
+ fragment=SWIG_Traits_frag(T),
+ fragment=SWIG_Traits_frag(U),
+ fragment="StdPairTraits") {
+ namespace swig {
+ template <> struct traits<std::pair<T,U > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::pair<" #T "," #U " >";
+ }
+ };
+ }
+ }
+
+#ifndef SWIG_STD_PAIR_ASVAL
+ %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T,U >);
+#else
+ %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair<T,U >);
+#endif
+
+ pair();
+ pair(T first, U second);
+ pair(const pair& p);
+
+ template <class U1, class U2> pair(const pair<U1, U2> &p);
+
+ T first;
+ U second;
+
+#ifdef %swig_pair_methods
+ // Add swig/language extra methods
+ %swig_pair_methods(std::pair<T,U >)
+#endif
+ };
+
+ // ***
+ // The following specializations should dissapear or get
+ // simplified when a 'const SWIGTYPE*&' can be defined
+ // ***
+ template <class T, class U > struct pair<T, U*> {
+ typedef T first_type;
+ typedef U* second_type;
+
+ %traits_swigtype(T);
+ %traits_swigtype(U);
+
+ %fragment(SWIG_Traits_frag(std::pair<T,U* >), "header",
+ fragment=SWIG_Traits_frag(T),
+ fragment=SWIG_Traits_frag(U),
+ fragment="StdPairTraits") {
+ namespace swig {
+ template <> struct traits<std::pair<T,U* > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::pair<" #T "," #U " * >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T,U* >);
+
+ pair();
+ pair(T __a, U* __b);
+ pair(const pair& __p);
+
+ T first;
+ U* second;
+
+#ifdef %swig_pair_methods
+ // Add swig/language extra methods
+ %swig_pair_methods(std::pair<T,U*>)
+#endif
+ };
+
+ template <class T, class U > struct pair<T*, U> {
+ typedef T* first_type;
+ typedef U second_type;
+
+ %traits_swigtype(T);
+ %traits_swigtype(U);
+
+ %fragment(SWIG_Traits_frag(std::pair<T*,U >), "header",
+ fragment=SWIG_Traits_frag(T),
+ fragment=SWIG_Traits_frag(U),
+ fragment="StdPairTraits") {
+ namespace swig {
+ template <> struct traits<std::pair<T*,U > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::pair<" #T " *," #U " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T*,U >);
+
+ pair();
+ pair(T* __a, U __b);
+ pair(const pair& __p);
+
+ T* first;
+ U second;
+
+#ifdef %swig_pair_methods
+ // Add swig/language extra methods
+ %swig_pair_methods(std::pair<T*,U >)
+#endif
+ };
+
+ template <class T, class U > struct pair<T*, U*> {
+ typedef T* first_type;
+ typedef U* second_type;
+
+ %traits_swigtype(T);
+ %traits_swigtype(U);
+
+ %fragment(SWIG_Traits_frag(std::pair<T*,U* >), "header",
+ fragment=SWIG_Traits_frag(T),
+ fragment=SWIG_Traits_frag(U),
+ fragment="StdPairTraits") {
+ namespace swig {
+ template <> struct traits<std::pair<T*,U* > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::pair<" #T " *," #U " * >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair<T*,U* >);
+
+ pair();
+ pair(T* __a, U* __b);
+ pair(const pair& __p);
+
+ T* first;
+ U* second;
+
+#ifdef %swig_pair_methods
+ // Add swig/language extra methods
+ %swig_pair_methods(std::pair<T*,U*>)
+#endif
+ };
+
+}
diff --git a/std/std_queue.i b/std/std_queue.i
new file mode 100644
index 0000000..42273ee
--- /dev/null
+++ b/std/std_queue.i
@@ -0,0 +1,129 @@
+/**
+ * @file std_queue.i
+ * @date Sun May 6 01:48:07 2007
+ *
+ * @brief A wrapping of std::queue for Ruby.
+ *
+ *
+ */
+
+%include <std_container.i>
+
+// Queue
+
+%define %std_queue_methods(queue...)
+ queue();
+ queue( const _Sequence& );
+
+ bool empty() const;
+ size_type size() const;
+ const value_type& front() const;
+ const value_type& back() const;
+ void pop();
+ void push( const value_type& );
+%enddef
+
+%define %std_queue_methods_val(queue...)
+ %std_queue_methods(queue)
+%enddef
+
+// ------------------------------------------------------------------------
+// std::queue
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::queue<T>), f(const std::queue<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::queue<T> can be passed.
+// -- f(std::queue<T>&), f(std::queue<T>*):
+// the parameter may be modified; therefore, only a wrapped std::queue
+// can be passed.
+// -- std::queue<T> f(), const std::queue<T>& f():
+// the queue is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::queue<T>& f(), std::queue<T>* f():
+// the queue is returned by reference; therefore, a wrapped std::queue
+// is returned
+// -- const std::queue<T>* f(), f(const std::queue<T>*):
+// for consistency, they expect and return a plain queue pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <queue>
+%}
+
+// exported classes
+
+namespace std {
+
+ template<class _Tp, class _Sequence = std::deque<_Tp> >
+ class queue {
+ public:
+ typedef size_t size_type;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Sequence container_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::queue<_Tp, _Sequence >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdQueueTraits") {
+ namespace swig {
+ template <> struct traits<std::queue<_Tp, _Sequence > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::queue<" #_Tp "," #_Sequence " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp, _Sequence >);
+
+#ifdef %swig_queue_methods
+ // Add swig/language extra methods
+ %swig_queue_methods(std::queue<_Tp, _Sequence >);
+#endif
+
+ %std_queue_methods(queue);
+ };
+
+ template<class _Tp, class _Sequence >
+ class queue<_Tp*, _Sequence > {
+ public:
+ typedef size_t size_type;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Sequence container_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::queue<_Tp*, _Sequence >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdQueueTraits") {
+ namespace swig {
+ template <> struct traits<std::queue<_Tp*, _Sequence > > {
+ typedef value_category category;
+ static const char* type_name() {
+ return "std::queue<" #_Tp "," #_Sequence " * >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp*, _Sequence >);
+
+#ifdef %swig_queue_methods_val
+ // Add swig/language extra methods
+ %swig_queue_methods_val(std::queue<_Tp*, _Sequence >);
+#endif
+
+ %std_queue_methods_val(std::queue<_Tp*, _Sequence >);
+ };
+
+}
+
diff --git a/std/std_set.i b/std/std_set.i
new file mode 100644
index 0000000..16f0f14
--- /dev/null
+++ b/std/std_set.i
@@ -0,0 +1,119 @@
+//
+// std::set
+//
+
+%include <std_container.i>
+%include <std_pair.i>
+
+// Set
+%define %std_set_methods_common(set...)
+ set();
+ set( const set& );
+
+ bool empty() const;
+ size_type size() const;
+ void clear();
+
+ void swap(set& v);
+
+
+ size_type erase(const key_type& x);
+ size_type count(const key_type& x) const;
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ class iterator;
+ class reverse_iterator;
+
+ iterator begin();
+ iterator end();
+ reverse_iterator rbegin();
+ reverse_iterator rend();
+
+ void erase(iterator pos);
+ void erase(iterator first, iterator last);
+
+ iterator find(const key_type& x);
+ iterator lower_bound(const key_type& x);
+ iterator upper_bound(const key_type& x);
+ std::pair<iterator,iterator> equal_range(const key_type& x);
+#endif
+%enddef
+
+%define %std_set_methods(set...)
+ %std_set_methods_common(set);
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ std::pair<iterator,bool> insert(const value_type& __x);
+#endif
+%enddef
+
+// ------------------------------------------------------------------------
+// std::set
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::set<T>), f(const std::set<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::set<T> can be passed.
+// -- f(std::set<T>&), f(std::set<T>*):
+// the parameter may be modified; therefore, only a wrapped std::set
+// can be passed.
+// -- std::set<T> f(), const std::set<T>& f():
+// the set is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::set<T>& f(), std::set<T>* f():
+// the set is returned by reference; therefore, a wrapped std::set
+// is returned
+// -- const std::set<T>* f(), f(const std::set<T>*):
+// for consistency, they expect and return a plain set pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <set>
+%}
+
+// exported classes
+
+namespace std {
+
+ template <class _Key, class _Compare = std::less<_Key>,
+ class _Alloc = allocator<_Key> >
+ class set {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key value_type;
+ typedef _Key key_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+
+ %fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Key),
+ fragment="StdSetTraits") {
+ namespace swig {
+ template <> struct traits<std::set<_Key, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::set<" #_Key "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >);
+
+ set( const _Compare& );
+
+#ifdef %swig_set_methods
+ // Add swig/language extra methods
+ %swig_set_methods(std::set<_Key, _Compare, _Alloc >);
+#endif
+
+ %std_set_methods(set);
+ };
+}
diff --git a/std/std_sstream.i b/std/std_sstream.i
new file mode 100644
index 0000000..12bccef
--- /dev/null
+++ b/std/std_sstream.i
@@ -0,0 +1,195 @@
+/*
+ For wchar support, you need to include the wchar.i file
+ before this file, ie:
+
+ %include <wchar.i>
+ %include <std_sstream.i>
+
+ or equivalently, just include
+
+ %include <std_wsstream.i>
+*/
+
+%include <std_alloc.i>
+%include <std_basic_string.i>
+%include <std_string.i>
+%include <std_ios.i>
+#if defined(SWIG_WCHAR)
+%include <std_wstring.i>
+#endif
+%include <std_streambuf.i>
+%include <std_iostream.i>
+
+%{
+#include <sstream>
+%}
+
+
+namespace std
+{
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+// 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ public:
+ // Constructors:
+ explicit
+ basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+ explicit
+ basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __str,
+ ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+ // Get and set:
+ basic_string<_CharT, _Traits, _Alloc>
+ str() const;
+
+ void
+ str(const basic_string<_CharT, _Traits, _Alloc>& __s);
+
+ };
+
+
+ // 27.7.2 Template class basic_istringstream
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_istringstream : public basic_istream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+// 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+
+ public:
+ // Constructors:
+ explicit
+ basic_istringstream(ios_base::openmode __mode = ios_base::in);
+
+ explicit
+ basic_istringstream(const basic_string<_CharT, _Traits, _Alloc>& __str,
+ ios_base::openmode __mode = ios_base::in);
+
+ ~basic_istringstream();
+
+ // Members:
+ basic_stringbuf<_CharT, _Traits, _Alloc>*
+ rdbuf() const;
+
+ basic_string<_CharT, _Traits, _Alloc>
+ str() const;
+
+ void
+ str(const basic_string<_CharT, _Traits, _Alloc>& __s);
+ };
+
+
+ // 27.7.3 Template class basic_ostringstream
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_ostringstream : public basic_ostream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+// 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+
+ public:
+ // Constructors/destructor:
+ explicit
+ basic_ostringstream(ios_base::openmode __mode = ios_base::out);
+
+ explicit
+ basic_ostringstream(const basic_string<_CharT, _Traits, _Alloc>& __str,
+ ios_base::openmode __mode = ios_base::out);
+
+ ~basic_ostringstream();
+
+ // Members:
+ basic_stringbuf<_CharT, _Traits, _Alloc>*
+ rdbuf() const;
+
+ basic_string<_CharT, _Traits, _Alloc>
+ str() const;
+
+#if 0
+ void
+ str(const basic_string<_CharT, _Traits, _Alloc>& __s);
+#endif
+ };
+
+
+ // 27.7.4 Template class basic_stringstream
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_stringstream : public basic_iostream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+// 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ public:
+ // Constructors/destructors
+ explicit
+ basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in);
+
+ explicit
+ basic_stringstream(const basic_string<_CharT, _Traits, _Alloc>& __str,
+ ios_base::openmode __m = ios_base::out | ios_base::in);
+
+ ~basic_stringstream();
+
+ // Members:
+ basic_stringbuf<_CharT, _Traits, _Alloc>*
+ rdbuf() const;
+
+ basic_string<_CharT, _Traits, _Alloc>
+ str() const;
+
+ void
+ str(const basic_string<_CharT, _Traits, _Alloc>& __s);
+ };
+
+
+} // namespace std
+
+
+namespace std {
+ %template(istringstream) basic_istringstream<char>;
+ %template(ostringstream) basic_ostringstream<char>;
+ %template(stringstream) basic_stringstream<char>;
+
+
+#if defined(SWIG_WCHAR)
+ %template(wistringstream) basic_istringstream<wchar_t>;
+ %template(wostringstream) basic_ostringstream<wchar_t>;
+ %template(wstringstream) basic_stringstream<wchar_t>;
+#endif
+}
diff --git a/std/std_stack.i b/std/std_stack.i
new file mode 100644
index 0000000..fb900a5
--- /dev/null
+++ b/std/std_stack.i
@@ -0,0 +1,128 @@
+/**
+ * @file std_stack.i
+ * @date Sun May 6 01:48:07 2007
+ *
+ * @brief A wrapping of std::stack for Ruby.
+ *
+ *
+ */
+
+%include <std_container.i>
+
+// Stack
+
+%define %std_stack_methods(stack...)
+ stack();
+ stack( const _Sequence& );
+
+ bool empty() const;
+ size_type size() const;
+ const value_type& top() const;
+ void pop();
+ void push( const value_type& );
+%enddef
+
+%define %std_stack_methods_val(stack...)
+ %std_stack_methods(stack)
+%enddef
+
+// ------------------------------------------------------------------------
+// std::stack
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::stack<T>), f(const std::stack<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::stack<T> can be passed.
+// -- f(std::stack<T>&), f(std::stack<T>*):
+// the parameter may be modified; therefore, only a wrapped std::stack
+// can be passed.
+// -- std::stack<T> f(), const std::stack<T>& f():
+// the stack is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::stack<T>& f(), std::stack<T>* f():
+// the stack is returned by reference; therefore, a wrapped std::stack
+// is returned
+// -- const std::stack<T>* f(), f(const std::stack<T>*):
+// for consistency, they expect and return a plain stack pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <stack>
+%}
+
+// exported classes
+
+namespace std {
+
+ template<class _Tp, class _Sequence = std::deque<_Tp> >
+ class stack {
+ public:
+ typedef size_t size_type;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Sequence container_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::stack<_Tp, _Sequence >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdStackTraits") {
+ namespace swig {
+ template <> struct traits<std::stack<_Tp, _Sequence > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::stack<" #_Tp "," #_Sequence " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp, _Sequence >);
+
+#ifdef %swig_stack_methods
+ // Add swig/language extra methods
+ %swig_stack_methods(std::stack<_Tp, _Sequence >);
+#endif
+
+ %std_stack_methods(stack);
+ };
+
+ template<class _Tp, class _Sequence >
+ class stack<_Tp*, _Sequence > {
+ public:
+ typedef size_t size_type;
+ typedef _Sequence::value_type value_type;
+ typedef value_type reference;
+ typedef value_type const_reference;
+ typedef _Sequence container_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::stack<_Tp*, _Sequence >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdStackTraits") {
+ namespace swig {
+ template <> struct traits<std::stack<_Tp*, _Sequence > > {
+ typedef value_category category;
+ static const char* type_name() {
+ return "std::stack<" #_Tp "," #_Sequence " * >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp*, _Sequence >);
+
+#ifdef %swig_stack_methods_val
+ // Add swig/language extra methods
+ %swig_stack_methods_val(std::stack<_Tp*, _Sequence >);
+#endif
+
+ %std_stack_methods_val(std::stack<_Tp*, _Sequence >);
+ };
+
+}
+
diff --git a/std/std_streambuf.i b/std/std_streambuf.i
new file mode 100644
index 0000000..7efb19c
--- /dev/null
+++ b/std/std_streambuf.i
@@ -0,0 +1,94 @@
+%include <std_ios.i>
+%{
+#ifndef SWIG_STD_NOMODERN_STL
+#include <streambuf>
+#else
+#include <streambuf.h>
+#endif
+%}
+
+namespace std {
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_streambuf
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ public:
+ virtual
+ ~basic_streambuf();
+
+ // Locales:
+ locale
+ pubimbue(const locale &__loc);
+
+ locale
+ getloc() const;
+
+ // Buffer and positioning:
+ basic_streambuf<_CharT, _Traits>*
+ pubsetbuf(char_type* __s, streamsize __n);
+
+ pos_type
+ pubseekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __mode = std::ios_base::in | std::ios_base::out);
+
+ pos_type
+ pubseekpos(pos_type __sp,
+ ios_base::openmode __mode = std::ios_base::in | std::ios_base::out);
+
+ int
+ pubsync() ;
+
+ // Get and put areas:
+ // Get area:
+ streamsize
+ in_avail();
+
+ int_type
+ snextc();
+
+ int_type
+ sbumpc();
+
+ int_type
+ sgetc();
+
+ streamsize
+ sgetn(char_type* __s, streamsize __n);
+
+ // Putback:
+ int_type
+ sputbackc(char_type __c);
+
+ int_type
+ sungetc();
+
+ // Put area:
+ int_type
+ sputc(char_type __c);
+
+ streamsize
+ sputn(const char_type* __s, streamsize __n);
+
+ protected:
+ basic_streambuf();
+
+ private:
+ basic_streambuf(const basic_streambuf&);
+
+ };
+}
+
+namespace std {
+ %template(streambuf) basic_streambuf<char>;
+#if defined(SWIG_WCHAR)
+ %template(wstreambuf) basic_streambuf<wchar_t>;
+#endif
+}
diff --git a/std/std_string.i b/std/std_string.i
new file mode 100644
index 0000000..35fcdd1
--- /dev/null
+++ b/std/std_string.i
@@ -0,0 +1,13 @@
+%include <std/std_basic_string.i>
+
+/* plain strings */
+
+namespace std
+{
+ %std_comp_methods(basic_string<char>);
+ %naturalvar string;
+ typedef basic_string<char> string;
+}
+
+
+%template(string) std::basic_string<char>;
diff --git a/std/std_vector.i b/std/std_vector.i
new file mode 100644
index 0000000..ab1435b
--- /dev/null
+++ b/std/std_vector.i
@@ -0,0 +1,184 @@
+//
+// std::vector
+//
+
+%include <std_container.i>
+
+// Vector
+
+%define %std_vector_methods(vector...)
+ %std_sequence_methods(vector)
+
+ void reserve(size_type n);
+ size_type capacity() const;
+%enddef
+
+
+%define %std_vector_methods_val(vector...)
+ %std_sequence_methods_val(vector)
+
+ void reserve(size_type n);
+ size_type capacity() const;
+%enddef
+
+
+// ------------------------------------------------------------------------
+// std::vector
+//
+// The aim of all that follows would be to integrate std::vector with
+// as much as possible, namely, to allow the user to pass and
+// be returned tuples or lists.
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::vector<T>), f(const std::vector<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::vector<T> can be passed.
+// -- f(std::vector<T>&), f(std::vector<T>*):
+// the parameter may be modified; therefore, only a wrapped std::vector
+// can be passed.
+// -- std::vector<T> f(), const std::vector<T>& f():
+// the vector is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::vector<T>& f(), std::vector<T>* f():
+// the vector is returned by reference; therefore, a wrapped std::vector
+// is returned
+// -- const std::vector<T>* f(), f(const std::vector<T>*):
+// for consistency, they expect and return a plain vector pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <vector>
+%}
+
+// exported classes
+
+
+namespace std {
+
+ template<class _Tp, class _Alloc = allocator< _Tp > >
+ class vector {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef _Tp& reference;
+ typedef const _Tp& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdVectorTraits") {
+ namespace swig {
+ template <> struct traits<std::vector<_Tp, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::vector<" #_Tp "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >);
+
+#ifdef %swig_vector_methods
+ // Add swig/language extra methods
+ %swig_vector_methods(std::vector<_Tp, _Alloc >);
+#endif
+
+ %std_vector_methods(vector);
+ };
+
+ // ***
+ // This specialization should dissapear or get simplified when
+ // a 'const SWIGTYPE*&' can be defined
+ // ***
+ template<class _Tp, class _Alloc >
+ class vector<_Tp*, _Alloc > {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp* value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type reference;
+ typedef value_type const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdVectorTraits") {
+ namespace swig {
+ template <> struct traits<std::vector<_Tp*, _Alloc > > {
+ typedef value_category category;
+ static const char* type_name() {
+ return "std::vector<" #_Tp " *," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >);
+
+#ifdef %swig_vector_methods_val
+ // Add swig/language extra methods
+ %swig_vector_methods_val(std::vector<_Tp*, _Alloc >);
+#endif
+
+ %std_vector_methods_val(vector);
+ };
+
+ // ***
+ // ***
+ // bool specialization
+
+ template<class _Alloc >
+ class vector<bool,_Alloc > {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef bool value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type reference;
+ typedef value_type const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(bool);
+
+ %fragment(SWIG_Traits_frag(std::vector<bool, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(bool),
+ fragment="StdVectorTraits") {
+ namespace swig {
+ template <> struct traits<std::vector<bool, _Alloc > > {
+ typedef value_category category;
+ static const char* type_name() {
+ return "std::vector<bool, _Alloc >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool, _Alloc >);
+
+
+#ifdef %swig_vector_methods_val
+ // Add swig/language extra methods
+ %swig_vector_methods_val(std::vector<bool, _Alloc >);
+#endif
+
+ %std_vector_methods_val(vector);
+
+#if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL)
+ void flip();
+#endif
+
+ };
+
+}
diff --git a/std/std_vectora.i b/std/std_vectora.i
new file mode 100644
index 0000000..0e83dc9
--- /dev/null
+++ b/std/std_vectora.i
@@ -0,0 +1,7 @@
+//
+// We keep this file only for backward compatibility, since std_vector.i
+// now uses the std::allocator parameter.
+//
+
+%include <std_vector.i>
+
diff --git a/std/std_wios.i b/std/std_wios.i
new file mode 100644
index 0000000..e9c5dd4
--- /dev/null
+++ b/std/std_wios.i
@@ -0,0 +1,7 @@
+/*
+ Provide 'std_ios.i' with wchar support.
+*/
+
+%include <wchar.i>
+%include <std_ios.i>
+
diff --git a/std/std_wiostream.i b/std/std_wiostream.i
new file mode 100644
index 0000000..b9bef90
--- /dev/null
+++ b/std/std_wiostream.i
@@ -0,0 +1,7 @@
+/*
+ Provide 'std_iostream.i' with wchar support.
+*/
+
+%include <wchar.i>
+%include <std_iostream.i>
+
diff --git a/std/std_wsstream.i b/std/std_wsstream.i
new file mode 100644
index 0000000..4c663fc
--- /dev/null
+++ b/std/std_wsstream.i
@@ -0,0 +1,7 @@
+/*
+ Provide 'std_sstream.i' with wchar support.
+*/
+
+%include <wchar.i>
+%include <std_sstream.i>
+
diff --git a/std/std_wstreambuf.i b/std/std_wstreambuf.i
new file mode 100644
index 0000000..86ac6af
--- /dev/null
+++ b/std/std_wstreambuf.i
@@ -0,0 +1,7 @@
+/*
+ Provide 'std_streambuf.i' with wchar support.
+*/
+
+%include <wchar.i>
+%include <std_streambuf.i>
+
diff --git a/std/std_wstring.i b/std/std_wstring.i
new file mode 100644
index 0000000..e54d212
--- /dev/null
+++ b/std/std_wstring.i
@@ -0,0 +1,14 @@
+%include <wchar.i>
+%include <std/std_basic_string.i>
+
+/* wide strings */
+
+namespace std
+{
+ %std_comp_methods(basic_string<wchar_t>);
+ %naturalvar wstring;
+ typedef basic_string<wchar_t> wstring;
+}
+
+%template(wstring) std::basic_string<wchar_t>;
+
diff --git a/std_except.i b/std_except.i
new file mode 100644
index 0000000..af9803a
--- /dev/null
+++ b/std_except.i
@@ -0,0 +1,58 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * std_except.i
+ *
+ * SWIG library file with typemaps to handle and throw STD exceptions in a
+ * language and STL independent way, i.e., the target language doesn't
+ * require to support STL but only the 'exception.i' mechanism.
+ *
+ * These typemaps are used when methods are declared with an STD
+ * exception specification, such as
+ *
+ * size_t at() const throw (std::out_of_range);
+ *
+ * The typemaps here are based on the language independent
+ * 'exception.i' library. If that is working in your target language,
+ * this file will work.
+ *
+ * If the target language doesn't implement a robust 'exception.i'
+ * mechanism, or you prefer other ways to map the STD exceptions, write
+ * a new std_except.i file in the target library directory.
+ * ----------------------------------------------------------------------------- */
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL)
+#error "This version of std_except.i should not be used"
+#endif
+
+%{
+#include <stdexcept>
+%}
+
+%include <exception.i>
+
+
+%define %std_exception_map(Exception, Code)
+ %typemap(throws,noblock=1) Exception {
+ SWIG_exception(Code, $1.what());
+ }
+ %ignore Exception;
+ struct Exception {
+ };
+%enddef
+
+namespace std {
+ %std_exception_map(bad_exception, SWIG_SystemError);
+ %std_exception_map(domain_error, SWIG_ValueError);
+ %std_exception_map(exception, SWIG_SystemError);
+ %std_exception_map(invalid_argument, SWIG_ValueError);
+ %std_exception_map(length_error, SWIG_IndexError);
+ %std_exception_map(logic_error, SWIG_RuntimeError);
+ %std_exception_map(out_of_range, SWIG_IndexError);
+ %std_exception_map(overflow_error, SWIG_OverflowError);
+ %std_exception_map(range_error, SWIG_OverflowError);
+ %std_exception_map(runtime_error, SWIG_RuntimeError);
+ %std_exception_map(underflow_error, SWIG_OverflowError);
+}
+
diff --git a/stdint.i b/stdint.i
new file mode 100644
index 0000000..7b48ca3
--- /dev/null
+++ b/stdint.i
@@ -0,0 +1,109 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * stdint.i
+ *
+ * SWIG library file for ISO C99 types: 7.18 Integer types <stdint.h>
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <stdint.h> // Use the C99 official header
+%}
+
+%include <swigarch.i>
+
+/* Exact integral types. */
+
+/* Signed. */
+
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+#if defined(SWIGWORDSIZE64)
+typedef long int int64_t;
+#else
+typedef long long int int64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+#if defined(SWIGWORDSIZE64)
+typedef unsigned long int uint64_t;
+#else
+typedef unsigned long long int uint64_t;
+#endif
+
+
+/* Small types. */
+
+/* Signed. */
+typedef signed char int_least8_t;
+typedef short int int_least16_t;
+typedef int int_least32_t;
+#if defined(SWIGWORDSIZE64)
+typedef long int int_least64_t;
+#else
+typedef long long int int_least64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint_least8_t;
+typedef unsigned short int uint_least16_t;
+typedef unsigned int uint_least32_t;
+#if defined(SWIGWORDSIZE64)
+typedef unsigned long int uint_least64_t;
+#else
+typedef unsigned long long int uint_least64_t;
+#endif
+
+
+/* Fast types. */
+
+/* Signed. */
+typedef signed char int_fast8_t;
+#if defined(SWIGWORDSIZE64)
+typedef long int int_fast16_t;
+typedef long int int_fast32_t;
+typedef long int int_fast64_t;
+#else
+typedef int int_fast16_t;
+typedef int int_fast32_t;
+typedef long long int int_fast64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint_fast8_t;
+#if defined(SWIGWORDSIZE64)
+typedef unsigned long int uint_fast16_t;
+typedef unsigned long int uint_fast32_t;
+typedef unsigned long int uint_fast64_t;
+#else
+typedef unsigned int uint_fast16_t;
+typedef unsigned int uint_fast32_t;
+typedef unsigned long long int uint_fast64_t;
+#endif
+
+
+/* Types for `void *' pointers. */
+#if defined(SWIGWORDSIZE64)
+typedef long int intptr_t;
+typedef unsigned long int uintptr_t;
+#else
+typedef int intptr_t;
+typedef unsigned int uintptr_t;
+#endif
+
+
+/* Largest integral types. */
+#if defined(SWIGWORDSIZE64)
+typedef long int intmax_t;
+typedef unsigned long int uintmax_t;
+#else
+typedef long long int intmax_t;
+typedef unsigned long long int uintmax_t;
+#endif
+
+
diff --git a/stl.i b/stl.i
new file mode 100644
index 0000000..c3ade01
--- /dev/null
+++ b/stl.i
@@ -0,0 +1,10 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * stl.i
+ * ----------------------------------------------------------------------------- */
+
+#warning "stl.i not implemented for this target"
+#define SWIG_STL_UNIMPL
+
diff --git a/swig.swg b/swig.swg
new file mode 100644
index 0000000..c0ecad9
--- /dev/null
+++ b/swig.swg
@@ -0,0 +1,686 @@
+/* -----------------------------------------------------------------------------
+ * swig.swg
+ *
+ * Common macro definitions for various SWIG directives. This file is always
+ * included at the top of each input file.
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * User Directives
+ * ----------------------------------------------------------------------------- */
+
+/* Deprecated SWIG directives */
+
+#define %disabledoc %warn "104:%disabledoc is deprecated"
+#define %enabledoc %warn "105:%enabledoc is deprecated"
+#define %doconly %warn "106:%doconly is deprecated"
+#define %style %warn "107:%style is deprecated" /##/
+#define %localstyle %warn "108:%localstyle is deprecated" /##/
+#define %title %warn "109:%title is deprecated" /##/
+#define %section %warn "110:%section is deprecated" /##/
+#define %subsection %warn "111:%subsection is deprecated" /##/
+#define %subsubsection %warn "112:%subsubsection is deprecated" /##/
+#define %new %warn "117:%new is deprecated. Use %newobject"
+#define %text %insert("null")
+
+/* Code insertion directives such as %wrapper %{ ... %} */
+
+#define %begin %insert("begin")
+#define %runtime %insert("runtime")
+#define %header %insert("header")
+#define %wrapper %insert("wrapper")
+#define %init %insert("init")
+
+/* Class extension */
+
+#define %addmethods %warn "113:%addmethods is now %extend" %extend
+
+/* %ignore directive */
+
+#define %ignore %rename($ignore)
+#define %ignorewarn(x) %rename("$ignore:" x)
+
+/* Access control directives */
+
+#define %readonly %warn "114:%readonly is deprecated. Use %immutable; " %feature("immutable");
+#define %readwrite %warn "115:%readwrite is deprecated. Use %mutable; " %feature("immutable","");
+
+#define %immutable %feature("immutable")
+#define %noimmutable %feature("immutable","0")
+#define %clearimmutable %feature("immutable","")
+#define %mutable %clearimmutable
+
+/* Generation of default constructors/destructors (old form, don't use) */
+#define %nodefault %feature("nodefault","1")
+#define %default %feature("nodefault","0")
+#define %clearnodefault %feature("nodefault","")
+#define %makedefault %clearnodefault
+
+/* Disable the generation of implicit default constructor */
+#define %nodefaultctor %feature("nodefaultctor","1")
+#define %defaultctor %feature("nodefaultctor","0")
+#define %clearnodefaultctor %feature("nodefaultctor","")
+
+/* Disable the generation of implicit default destructor (dangerous) */
+#define %nodefaultdtor %feature("nodefaultdtor","1")
+#define %defaultdtor %feature("nodefaultdtor","0")
+#define %clearnodefaultdtor %feature("nodefaultdtor","")
+
+/* Enable the generation of copy constructor */
+#define %copyctor %feature("copyctor","1")
+#define %nocopyctor %feature("copyctor","0")
+#define %clearcopyctor %feature("copyctor","")
+
+/* Force the old nodefault behavior, ie disable both constructor and destructor */
+#define %oldnodefault %feature("oldnodefault","1")
+#define %nooldnodefault %feature("oldnodefault","0")
+#define %clearoldnodefault %feature("oldnodefault","")
+
+/* the %exception directive */
+#ifdef SWIGCSHARP
+#define %exception %feature("except", canthrow=1)
+#else
+#define %exception %feature("except")
+#endif
+#define %noexception %feature("except","0")
+#define %clearexception %feature("except","")
+
+/* the %allowexception directive allows the %exception feature to
+ be applied to set/get variable methods */
+#define %allowexception %feature("allowexcept")
+#define %noallowexception %feature("allowexcept","0")
+#define %clearallowexception %feature("allowexcept","")
+
+/* the %exceptionvar directive, as %exception but it is only applied
+ to set/get variable methods. You don't need to use the
+ %allowexception directive when using %exceptionvar.
+*/
+#ifdef SWIGCSHARP
+#define %exceptionvar %feature("exceptvar", canthrow=1)
+#else
+#define %exceptionvar %feature("exceptvar")
+#endif
+#define %noexceptionvar %feature("exceptvar","0")
+#define %clearexceptionvar %feature("exceptvar","")
+
+/* the %catches directive */
+#define %catches(tlist...) %feature("catches","("`tlist`")")
+#define %clearcatches %feature("catches","")
+
+/* the %exceptionclass directive */
+#define %exceptionclass %feature("exceptionclass")
+#define %noexceptionclass %feature("exceptionclass","0")
+#define %clearexceptionclass %feature("exceptionclass","")
+
+/* the %newobject directive */
+#define %newobject %feature("new")
+#define %nonewobject %feature("new","0")
+#define %clearnewobject %feature("new","")
+
+/* the %delobject directive */
+#define %delobject %feature("del")
+#define %nodelobject %feature("del","0")
+#define %cleardelobject %feature("del","")
+
+/* the %refobject/%unrefobject directives */
+#define %refobject %feature("ref")
+#define %norefobject %feature("ref","0")
+#define %clearrefobject %feature("ref","")
+
+#define %unrefobject %feature("unref")
+#define %nounrefobject %feature("unref","0")
+#define %clearunrefobject %feature("unref","")
+
+/* Directives for callback functions (experimental) */
+#define %callback(x) %feature("callback",`x`)
+#define %nocallback %feature("callback","0")
+#define %clearcallback %feature("callback","")
+
+/* the %fastdispatch directive */
+#define %fastdispatch %feature("fastdispatch")
+#define %nofastdispatch %feature("fastdispatch","0")
+#define %clearfastdispatch %feature("fastdispatch","")
+
+/* directors directives */
+#define %director %feature("director")
+#define %nodirector %feature("director","0")
+#define %cleardirector %feature("director","")
+
+/* naturalvar directives */
+#define %naturalvar %feature("naturalvar")
+#define %nonaturalvar %feature("naturalvar","0")
+#define %clearnaturalvar %feature("naturalvar","")
+
+/* valuewrapper directives */
+#define %valuewrapper %feature("valuewrapper")
+#define %clearvaluewrapper %feature("valuewrapper","")
+#define %novaluewrapper %feature("novaluewrapper")
+#define %clearnovaluewrapper %feature("novaluewrapper","")
+
+/* Contract support - Experimental and undocumented */
+#define %contract %feature("contract")
+#define %nocontract %feature("contract","0")
+#define %clearcontract %feature("contract","")
+
+/* Macro for setting a dynamic cast function */
+%define DYNAMIC_CAST(mangle,func)
+%init %{
+ mangle->dcast = (swig_dycast_func) func;
+%}
+%enddef
+
+/* aggregation support */
+/*
+ This macro performs constant aggregation. Basically the idea of
+ constant aggregation is that you can group a collection of constants
+ together. For example, suppose you have some code like this:
+
+ #define UP 1
+ #define DOWN 2
+ #define LEFT 3
+ #define RIGHT 4
+
+ Now, suppose you had a function like this:
+
+ int move(int direction)
+
+ In this case, you might want to restrict the direction argument to
+ one of the supplied constant names. To do this, you could write some
+ typemap code by hand. Alternatively, you can use the
+ %aggregate_check macro defined here to create a simple check
+ function for you. Here is an example:
+
+ %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);
+
+ Now, using a typemap
+
+ %typemap(check) int direction {
+ if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction.");
+ }
+
+ or a contract (better)
+
+ %contract move(int x) {
+ require:
+ check_direction(x);
+ }
+
+*/
+
+%define %aggregate_check(TYPE, NAME, FIRST, ...)
+%wrapper %{
+static int NAME(TYPE x) {
+ static TYPE values[] = { FIRST, ##__VA_ARGS__ };
+ static int size = sizeof(values);
+ int i,j;
+ for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) {
+ if (x == values[j]) return 1;
+ }
+ return 0;
+}
+%}
+%enddef
+
+
+/* -----------------------------------------------------------------------------
+ * %rename predicates
+ * ----------------------------------------------------------------------------- */
+/*
+ Predicates to be used with %rename, for example:
+
+ - to rename all the functions:
+
+ %rename("%(utitle)s", %$isfunction) "";
+
+ - to rename only the member methods:
+
+ %rename("m_%(utitle)s", %$isfunction, %$ismember) "";
+
+ - to rename only the global functions:
+
+ %rename("m_%(utitle)s", %$isfunction, %$not %$ismember) "";
+
+ or
+
+ %rename("g_%(utitle)s", %$isfunction, %$isglobal) "";
+
+ - to ignore the enumitems in a given class:
+
+ %rename("$ignore", %$isenumitem, %$classname="MyClass") "";
+
+ we use the prefix '%$' to avoid clashings with other swig
+ macros/directives.
+
+*/
+
+%define %$not "not" %enddef
+%define %$isenum "match"="enum" %enddef
+%define %$isenumitem "match"="enumitem" %enddef
+%define %$isaccess "match"="access" %enddef
+%define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef
+%define %$isextend "match"="extend" %enddef
+%define %$isextend "match"="extend" %enddef
+%define %$isconstructor "match"="constructor" %enddef
+%define %$isdestructor "match"="destructor" %enddef
+%define %$isnamespace "match"="namespace" %enddef
+%define %$istemplate "match"="template" %enddef
+%define %$isconstant "match"="constant" %enddef /* %constant definition */
+
+%define %$isunion "match$kind"="union" %enddef
+%define %$isfunction "match$kind"="function" %enddef
+%define %$isvariable "match$kind"="variable" %enddef
+%define %$isimmutable "match$feature:immutable"="1" %enddef
+%define %$hasconsttype "match$hasconsttype"="1" %enddef
+%define %$hasvalue "match$hasvalue"="1" %enddef
+%define %$isextension "match$isextension"="1" %enddef
+
+%define %$isstatic "match$storage"="static" %enddef
+%define %$isfriend "match$storage"="friend" %enddef
+%define %$istypedef "match$storage"="typedef" %enddef
+%define %$isvirtual "match$storage"="virtual" %enddef
+%define %$isexplicit "match$storage"="explicit" %enddef
+%define %$isextern "match$storage"="extern" %enddef
+
+%define %$ismember "match$ismember"="1" %enddef
+%define %$isglobal %not %ismember %enddef
+%define %$innamespace "match$parentNode$nodeType"="namespace" %enddef
+
+%define %$ispublic "match$access"="public" %enddef
+%define %$isprotected "match$access"="protected" %enddef
+%define %$isprivate "match$access"="private" %enddef
+
+%define %$ismemberget "match$memberget"="1" %enddef
+%define %$ismemberset "match$memberset"="1" %enddef
+
+%define %$classname %ismember,match$parentNode$name %enddef
+
+/* -----------------------------------------------------------------------------
+ * Include all the warnings labels and macros
+ * ----------------------------------------------------------------------------- */
+
+%include <swigwarnings.swg>
+
+/* -----------------------------------------------------------------------------
+ * Default handling of certain overloaded operators
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+%ignoreoperator(NEW) operator new;
+%ignoreoperator(DELETE) operator delete;
+%ignoreoperator(NEWARR) operator new[];
+%ignoreoperator(DELARR) operator delete[];
+
+/* add C++ operator aliases */
+%rename("operator &&") operator and; // `and' `&&'
+%rename("operator ||") operator or; // `or' `||'
+%rename("operator !") operator not; // `not' `!'
+%rename("operator &=") operator and_eq; // `and_eq' `&='
+%rename("operator &") operator bitand; // `bitand' `&'
+%rename("operator |") operator bitor; // `bitor' `|'
+%rename("operator ~") operator compl; // `compl' `~'
+%rename("operator !=") operator not_eq; // `not_eq' `!='
+%rename("operator |=") operator or_eq; // `or_eq' `|='
+%rename("operator ^") operator xor; // `xor' `^'
+%rename("operator ^=") operator xor_eq; // `xor_eq' `^='
+
+/* Smart pointer handling */
+
+%rename(__deref__) *::operator->;
+%rename(__ref__) *::operator*();
+%rename(__ref__) *::operator*() const;
+
+/* Define std namespace */
+namespace std {
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Default char * and C array typemaps
+ * ----------------------------------------------------------------------------- */
+
+/* Set up the typemap for handling new return strings */
+
+#ifdef __cplusplus
+%typemap(newfree) char * "delete [] $1;";
+#else
+%typemap(newfree) char * "free($1);";
+#endif
+
+/* Default typemap for handling char * members */
+
+#ifdef __cplusplus
+%typemap(memberin) char * {
+ if ($1) delete [] $1;
+ if ($input) {
+ $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
+ if ($input) {
+ $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(globalin) char * {
+ if ($1) delete [] $1;
+ if ($input) {
+ $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
+ if ($input) {
+ $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+#else
+%typemap(memberin) char * {
+ if ($1) free((char *)$1);
+ if ($input) {
+ $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
+ if ($input) {
+ $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(globalin) char * {
+ if ($1) free((char *)$1);
+ if ($input) {
+ $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
+ if ($input) {
+ $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+
+#endif
+
+/* Character array handling */
+
+%typemap(memberin) char [ANY] {
+ if($input) {
+ strncpy((char*)$1, (const char *)$input, $1_dim0-1);
+ $1[$1_dim0-1] = 0;
+ } else {
+ $1[0] = 0;
+ }
+}
+
+%typemap(globalin) char [ANY] {
+ if($input) {
+ strncpy((char*)$1, (const char *)$input, $1_dim0-1);
+ $1[$1_dim0-1] = 0;
+ } else {
+ $1[0] = 0;
+ }
+}
+
+%typemap(memberin) char [] {
+ if ($input) strcpy((char *)$1, (const char *)$input);
+ else $1[0] = 0;
+}
+
+%typemap(globalin) char [] {
+ if ($input) strcpy((char *)$1, (const char *)$input);
+ else $1[0] = 0;
+}
+
+/* memberin/globalin typemap for arrays. */
+
+%typemap(memberin) SWIGTYPE [ANY] {
+ size_t ii;
+ $1_basetype *b = ($1_basetype *) $1;
+ for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
+}
+
+%typemap(globalin) SWIGTYPE [ANY] {
+ size_t ii;
+ $1_basetype *b = ($1_basetype *) $1;
+ for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
+}
+
+/* memberin/globalin typemap for double arrays. */
+
+%typemap(memberin) SWIGTYPE [ANY][ANY] {
+ $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
+ $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
+ size_t ii = 0;
+ for (; ii < $1_dim0; ++ii) {
+ $basetype *ip = inp[ii];
+ $basetype *dp = dest[ii];
+ size_t jj = 0;
+ for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj];
+ }
+}
+
+%typemap(globalin) SWIGTYPE [ANY][ANY] {
+ $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
+ $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
+ size_t ii = 0;
+ for (; ii < $1_dim0; ++ii) {
+ $basetype *ip = inp[ii];
+ $basetype *dp = dest[ii];
+ size_t jj = 0;
+ for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj];
+ }
+}
+
+/* Typemap for variable length arguments sentinel value. Used
+ by the %varargs directive. */
+
+%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
+
+
+/* -----------------------------------------------------------------------------
+ * Overloading support
+ * ----------------------------------------------------------------------------- */
+
+/*
+ * Function/method overloading support. This is done through typemaps,
+ * but also involve a precedence level.
+ */
+
+/* Macro for overload resolution */
+
+%define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef
+
+/* Macros for precedence levels */
+
+%define SWIG_TYPECHECK_POINTER 0 %enddef
+%define SWIG_TYPECHECK_ITERATOR 5 %enddef
+%define SWIG_TYPECHECK_VOIDPTR 10 %enddef
+%define SWIG_TYPECHECK_BOOL 15 %enddef
+%define SWIG_TYPECHECK_UINT8 20 %enddef
+%define SWIG_TYPECHECK_INT8 25 %enddef
+%define SWIG_TYPECHECK_UINT16 30 %enddef
+%define SWIG_TYPECHECK_INT16 35 %enddef
+%define SWIG_TYPECHECK_UINT32 40 %enddef
+%define SWIG_TYPECHECK_INT32 45 %enddef
+%define SWIG_TYPECHECK_SIZE 47 %enddef
+%define SWIG_TYPECHECK_PTRDIFF 48 %enddef
+%define SWIG_TYPECHECK_UINT64 50 %enddef
+%define SWIG_TYPECHECK_INT64 55 %enddef
+%define SWIG_TYPECHECK_UINT128 60 %enddef
+%define SWIG_TYPECHECK_INT128 65 %enddef
+%define SWIG_TYPECHECK_INTEGER 70 %enddef
+%define SWIG_TYPECHECK_FLOAT 80 %enddef
+%define SWIG_TYPECHECK_DOUBLE 90 %enddef
+%define SWIG_TYPECHECK_CPLXFLT 95 %enddef
+%define SWIG_TYPECHECK_CPLXDBL 100 %enddef
+%define SWIG_TYPECHECK_COMPLEX 105 %enddef
+%define SWIG_TYPECHECK_UNICHAR 110 %enddef
+%define SWIG_TYPECHECK_STDUNISTRING 115 %enddef
+%define SWIG_TYPECHECK_UNISTRING 120 %enddef
+%define SWIG_TYPECHECK_CHAR 130 %enddef
+%define SWIG_TYPECHECK_STDSTRING 135 %enddef
+%define SWIG_TYPECHECK_STRING 140 %enddef
+%define SWIG_TYPECHECK_PAIR 150 %enddef
+%define SWIG_TYPECHECK_VECTOR 160 %enddef
+%define SWIG_TYPECHECK_DEQUE 170 %enddef
+%define SWIG_TYPECHECK_LIST 180 %enddef
+%define SWIG_TYPECHECK_SET 190 %enddef
+%define SWIG_TYPECHECK_MULTISET 200 %enddef
+%define SWIG_TYPECHECK_MAP 210 %enddef
+%define SWIG_TYPECHECK_MULTIMAP 220 %enddef
+%define SWIG_TYPECHECK_STACK 230 %enddef
+%define SWIG_TYPECHECK_QUEUE 240 %enddef
+
+%define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef
+%define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef
+%define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef
+%define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef
+%define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef
+%define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef
+%define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef
+%define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef
+%define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef
+%define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef
+%define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef
+
+%define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef
+%define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef
+%define SWIG_TYPECHECK_INT8_PTR 2025 %enddef
+%define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef
+%define SWIG_TYPECHECK_INT16_PTR 2035 %enddef
+%define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef
+%define SWIG_TYPECHECK_INT32_PTR 2045 %enddef
+%define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef
+%define SWIG_TYPECHECK_INT64_PTR 2055 %enddef
+%define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef
+%define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef
+%define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef
+
+
+%define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef
+
+
+/* -----------------------------------------------------------------------------
+ * Runtime code
+ * ----------------------------------------------------------------------------- */
+
+/* The SwigValueWrapper class */
+
+/*
+ * This template wrapper is used to handle C++ objects that are passed or
+ * returned by value. This is necessary to handle objects that define
+ * no default-constructor (making it difficult for SWIG to properly declare
+ * local variables).
+ *
+ * The wrapper is used as follows. First consider a function like this:
+ *
+ * Vector cross_product(Vector a, Vector b)
+ *
+ * Now, if Vector is defined as a C++ class with no default constructor,
+ * code is generated as follows:
+ *
+ * Vector *wrap_cross_product(Vector *inarg1, Vector *inarg2) {
+ * SwigValueWrapper<Vector> arg1;
+ * SwigValueWrapper<Vector> arg2;
+ * SwigValueWrapper<Vector> result;
+ *
+ * arg1 = *inarg1;
+ * arg2 = *inarg2;
+ * ...
+ * result = cross_product(arg1,arg2);
+ * ...
+ * return new Vector(result);
+ * }
+ *
+ * In the wrappers, the template SwigValueWrapper simply provides a thin
+ * layer around a Vector *. However, it does this in a way that allows
+ * the object to be bound after the variable declaration (which is not possible
+ * with the bare object when it lacks a default constructor).
+ *
+ * An observant reader will notice that the code after the variable declarations
+ * is *identical* to the code used for classes that do define default constructors.
+ * Thus, this neat trick allows us to fix this special case without having to
+ * make massive changes to typemaps and other parts of the SWIG code generator.
+ *
+ * Note: this code is not included when SWIG runs in C-mode, when classes
+ * define default constructors, or when pointers and references are used.
+ * SWIG tries to avoid doing this except in very special circumstances.
+ *
+ * Note: This solution suffers from making a large number of copies
+ * of the underlying object. However, this is needed in the interest of
+ * safety and in order to cover all of the possible ways in which a value
+ * might be assigned. For example:
+ *
+ * arg1 = *inarg1; // Assignment from a pointer
+ * arg1 = Vector(1,2,3); // Assignment from a value
+ *
+ * The class offers a strong guarantee of exception safety.
+ * With regards to the implementation, the private SwigMovePointer nested class is
+ * a simple smart pointer with move semantics, much like std::auto_ptr.
+ *
+ * This wrapping technique was suggested by William Fulton and is henceforth
+ * known as the "Fulton Transform" :-).
+ */
+
+#ifdef __cplusplus
+%insert("runtime") %{
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+ struct SwigMovePointer {
+ T *ptr;
+ SwigMovePointer(T *p) : ptr(p) { }
+ ~SwigMovePointer() { delete ptr; }
+ SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+ } pointer;
+ SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+ SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+ SwigValueWrapper() : pointer(0) { }
+ SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+ operator T&() const { return *pointer.ptr; }
+ T *operator&() { return pointer.ptr; }
+};%}
+
+/*
+ * SwigValueInit() is a generic initialisation solution as the following approach:
+ *
+ * T c_result = T();
+ *
+ * doesn't compile for all types for example:
+ *
+ * unsigned int c_result = unsigned int();
+ */
+%insert("runtime") %{
+template <typename T> T SwigValueInit() {
+ return T();
+}
+#endif
+%}
+#endif
+
+/* The swiglabels */
+
+%insert("runtime") "swiglabels.swg"
+
+
diff --git a/swigarch.i b/swigarch.i
new file mode 100644
index 0000000..260b608
--- /dev/null
+++ b/swigarch.i
@@ -0,0 +1,65 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * swigarch.i
+ *
+ * SWIG library file for 32bit/64bit code specialization and checking.
+ *
+ * Use only in extreme cases, when no arch. independent code can be
+ * generated
+ *
+ * To activate architecture specific code, use
+ *
+ * swig -DSWIGWORDSIZE32
+ *
+ * or
+ *
+ * swig -DSWIGWORDSIZE64
+ *
+ * Note that extra checking code will be added to the wrapped code,
+ * which will prevent the compilation in a different architecture.
+ *
+ * If you don't specify the SWIGWORDSIZE (the default case), swig will
+ * generate architecture independent and/or 32bits code, with no extra
+ * checking code added.
+ * ----------------------------------------------------------------------------- */
+
+#if !defined(SWIGWORDSIZE32) && !defined(SWIGWORDSIZE64)
+# if (__WORDSIZE == 32)
+# define SWIGWORDSIZE32
+# endif
+#endif
+
+#if !defined(SWIGWORDSIZE64) && !defined(SWIGWORDSIZE32)
+# if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64)
+# define SWIGWORDSIZE64
+# endif
+#endif
+
+
+#ifdef SWIGWORDSIZE32
+%{
+#define SWIGWORDSIZE32
+#ifndef LONG_MAX
+#include <limits.h>
+#endif
+#if (__WORDSIZE == 64) || (LONG_MAX != INT_MAX)
+# error "SWIG wrapped code invalid in 64 bit architecture, regenarete code using -DSWIGWORDSIZE64"
+#endif
+%}
+#endif
+
+#ifdef SWIGWORDSIZE64
+%{
+#define SWIGWORDSIZE64
+#ifndef LONG_MAX
+#include <limits.h>
+#endif
+#if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX)
+# error "SWIG wrapped code invalid in 32 bit architecture, regenarete code using -DSWIGWORDSIZE32"
+#endif
+%}
+#endif
+
+
diff --git a/swigerrors.swg b/swigerrors.swg
new file mode 100644
index 0000000..32857c4
--- /dev/null
+++ b/swigerrors.swg
@@ -0,0 +1,16 @@
+/* Errors in SWIG */
+#define SWIG_UnknownError -1
+#define SWIG_IOError -2
+#define SWIG_RuntimeError -3
+#define SWIG_IndexError -4
+#define SWIG_TypeError -5
+#define SWIG_DivisionByZero -6
+#define SWIG_OverflowError -7
+#define SWIG_SyntaxError -8
+#define SWIG_ValueError -9
+#define SWIG_SystemError -10
+#define SWIG_AttributeError -11
+#define SWIG_MemoryError -12
+#define SWIG_NullReferenceError -13
+
+
diff --git a/swiginit.swg b/swiginit.swg
new file mode 100644
index 0000000..903ac54
--- /dev/null
+++ b/swiginit.swg
@@ -0,0 +1,236 @@
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial
+ * array. We just loop through that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded.
+ * There are three cases to handle:
+ * 1) If the cast->type has already been loaded AND the type we are adding
+ * casting info to has not been loaded (it is in this module), THEN we
+ * replace the cast->type pointer with the type pointer that has already
+ * been loaded.
+ * 2) If BOTH types (the one we are adding casting info to, and the
+ * cast->type) are loaded, THEN the cast info has already been loaded by
+ * the previous module so we just ignore it.
+ * 3) Finally, if cast->type has not already been loaded, then we add that
+ * swig_cast_info to the linked list (because the cast->type) pointer will
+ * be correct.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+ size_t i;
+ swig_module_info *module_head, *iter;
+ int found, init;
+
+ clientdata = clientdata;
+
+ /* check to see if the circular list has been setup, if not, set it up */
+ if (swig_module.next==0) {
+ /* Initialize the swig_module */
+ swig_module.type_initial = swig_type_initial;
+ swig_module.cast_initial = swig_cast_initial;
+ swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
+ }
+
+ /* Try and load any already created modules */
+ module_head = SWIG_GetModule(clientdata);
+ if (!module_head) {
+ /* This is the first module loaded for this interpreter */
+ /* so set the swig module into the interpreter */
+ SWIG_SetModule(clientdata, &swig_module);
+ module_head = &swig_module;
+ } else {
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+ found=0;
+ iter=module_head;
+ do {
+ if (iter==&swig_module) {
+ found=1;
+ break;
+ }
+ iter=iter->next;
+ } while (iter!= module_head);
+
+ /* if the is found in the list, then all is done and we may leave */
+ if (found) return;
+ /* otherwise we must add out module into the list */
+ swig_module.next = module_head->next;
+ module_head->next = &swig_module;
+ }
+
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
+ /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+ for (i = 0; i < swig_module.size; ++i) {
+ swig_type_info *type = 0;
+ swig_type_info *ret;
+ swig_cast_info *cast;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+
+ /* if there is another module already loaded */
+ if (swig_module.next != &swig_module) {
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+ }
+ if (type) {
+ /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+ if (swig_module.type_initial[i]->clientdata) {
+ type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+ }
+ } else {
+ type = swig_module.type_initial[i];
+ }
+
+ /* Insert casting types */
+ cast = swig_module.cast_initial[i];
+ while (cast->type) {
+
+ /* Don't need to add information already in the list */
+ ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+ if (swig_module.next != &swig_module) {
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+ }
+ if (ret) {
+ if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+ cast->type = ret;
+ ret = 0;
+ } else {
+ /* Check for casting already in the list */
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+ if (!ocast) ret = 0;
+ }
+ }
+
+ if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+ if (type->cast) {
+ type->cast->prev = cast;
+ cast->next = type->cast;
+ }
+ type->cast = cast;
+ }
+ cast++;
+ }
+ /* Set entry in modules->types array equal to the type */
+ swig_module.types[i] = type;
+ }
+ swig_module.types[i] = 0;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+ for (i = 0; i < swig_module.size; ++i) {
+ int j = 0;
+ swig_cast_info *cast = swig_module.cast_initial[i];
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+ while (cast->type) {
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+ cast++;
+ ++j;
+ }
+ printf("---- Total casts: %d\n",j);
+ }
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types. It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+ size_t i;
+ swig_cast_info *equiv;
+ static int init_run = 0;
+
+ if (init_run) return;
+ init_run = 1;
+
+ for (i = 0; i < swig_module.size; i++) {
+ if (swig_module.types[i]->clientdata) {
+ equiv = swig_module.types[i]->cast;
+ while (equiv) {
+ if (!equiv->converter) {
+ if (equiv->type && !equiv->type->clientdata)
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+ }
+ equiv = equiv->next;
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+#if 0
+{ /* c-mode */
+#endif
+}
+#endif
diff --git a/swiglabels.swg b/swiglabels.swg
new file mode 100644
index 0000000..b943afb
--- /dev/null
+++ b/swiglabels.swg
@@ -0,0 +1,108 @@
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define SWIGSTDCALL __stdcall
+# else
+# define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
diff --git a/swigrun.i b/swigrun.i
new file mode 100644
index 0000000..17a1409
--- /dev/null
+++ b/swigrun.i
@@ -0,0 +1,11 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * swigrun.i
+ *
+ * Empty module (for now). Placeholder for runtime libs
+ * ----------------------------------------------------------------------------- */
+
+%module swigrun
+
diff --git a/swigrun.swg b/swigrun.swg
new file mode 100644
index 0000000..a8e9ad7
--- /dev/null
+++ b/swigrun.swg
@@ -0,0 +1,583 @@
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic C API SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+ or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "4"
+
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
+#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
+
+/*
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+ creating a static or dynamic library from the SWIG runtime code.
+ In 99.9% of the cases, SWIG just needs to declare them as 'static'.
+
+ But only do this if strictly necessary, ie, if you have problems
+ with your compiler or suchlike.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/* Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN 0x1
+
+
+/*
+ Flags/methods for returning states.
+
+ The SWIG conversion methods, as ConvertPtr, return and integer
+ that tells if the conversion was successful or not. And if not,
+ an error code can be returned (see swigerrors.swg for the codes).
+
+ Use the following macros/flags to set or process the returning
+ states.
+
+ In old versions of SWIG, code such as the following was usually written:
+
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+ // success code
+ } else {
+ //fail code
+ }
+
+ Now you can be more explicit:
+
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ } else {
+ // fail code
+ }
+
+ which is the same really, but now you can also do
+
+ Type *ptr;
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ if (SWIG_IsNewObj(res) {
+ ...
+ delete *ptr;
+ } else {
+ ...
+ }
+ } else {
+ // fail code
+ }
+
+ I.e., now SWIG_ConvertPtr can return new objects and you can
+ identify the case and take care of the deallocation. Of course that
+ also requires SWIG_ConvertPtr to return new result values, such as
+
+ int SWIG_ConvertPtr(obj, ptr,...) {
+ if (<obj is ok>) {
+ if (<need new object>) {
+ *ptr = <ptr to new allocated object>;
+ return SWIG_NEWOBJ;
+ } else {
+ *ptr = <ptr to old object>;
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_BADOBJ;
+ }
+ }
+
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+ SWIG errors code.
+
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+ allows to return the 'cast rank', for example, if you have this
+
+ int food(double)
+ int fooi(int);
+
+ and you call
+
+ food(1) // cast rank '1' (1 -> 1.0)
+ fooi(1) // cast rank '0'
+
+ just use the SWIG_AddCast()/SWIG_CheckState()
+*/
+
+#define SWIG_OK (0)
+#define SWIG_ERROR (-1)
+#define SWIG_IsOK(r) (r >= 0)
+#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ (SWIG_ERROR)
+#define SWIG_OLDOBJ (SWIG_OK)
+#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+# ifndef SWIG_TypeRank
+# define SWIG_TypeRank unsigned long
+# endif
+# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
+# define SWIG_MAXCASTRANK (2)
+# endif
+# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
+# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+}
+#else /* no cast-rank mode */
+# define SWIG_AddCast
+# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *, int *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store information on one type */
+typedef struct swig_type_info {
+ const char *name; /* mangled name of this type */
+ const char *str; /* human readable name of this type */
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
+ void *clientdata; /* language specific type data */
+ int owndata; /* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
+ swig_converter_func converter; /* function to cast the void pointers */
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
+ struct swig_cast_info *prev; /* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
+ size_t size; /* Number of types in this module */
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
+ swig_type_info **type_initial; /* Array of initially generated type structures */
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
+ void *clientdata; /* Language specific module data */
+} swig_module_info;
+
+/*
+ Compare two type names skipping the space characters, therefore
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+ Return 0 when the two name types are equivalent, as in
+ strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+ const char *f2, const char *l2) {
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+ }
+ return (int)((l1 - f1) - (l2 - f2));
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+ Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCompare(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+
+/*
+ Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if (strcmp(iter->type->name, c) == 0) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
+}
+
+/*
+ Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if (iter->type == from) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
+}
+
+/*
+ Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+}
+
+/*
+ Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+ swig_type_info *lastty = ty;
+ if (!ty || !ty->dcast) return ty;
+ while (ty && (ty->dcast)) {
+ ty = (*ty->dcast)(ptr);
+ if (ty) lastty = ty;
+ }
+ return lastty;
+}
+
+/*
+ Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+ return ty->name;
+}
+
+/*
+ Return the pretty name associated with this type,
+ that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+ /* The "str" field contains the equivalent pretty names of the
+ type, separated by vertical-bar characters. We choose
+ to print the last name, as it is often (?) the most
+ specific. */
+ if (!type) return NULL;
+ if (type->str != NULL) {
+ const char *last_name = type->str;
+ const char *s;
+ for (s = type->str; *s; s++)
+ if (*s == '|') last_name = s+1;
+ return last_name;
+ }
+ else
+ return type->name;
+}
+
+/*
+ Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+ swig_cast_info *cast = ti->cast;
+ /* if (ti->clientdata == clientdata) return; */
+ ti->clientdata = clientdata;
+
+ while (cast) {
+ if (!cast->converter) {
+ swig_type_info *tc = cast->type;
+ if (!tc->clientdata) {
+ SWIG_TypeClientData(tc, clientdata);
+ }
+ }
+ cast = cast->next;
+ }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+ SWIG_TypeClientData(ti, clientdata);
+ ti->owndata = 1;
+}
+
+/*
+ Search for a swig_type_info structure only by mangled name
+ Search is a O(log #types)
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ swig_module_info *iter = start;
+ do {
+ if (iter->size) {
+ register size_t l = 0;
+ register size_t r = iter->size - 1;
+ do {
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+ register size_t i = (l + r) >> 1;
+ const char *iname = iter->types[i]->name;
+ if (iname) {
+ register int compare = strcmp(name, iname);
+ if (compare == 0) {
+ return iter->types[i];
+ } else if (compare < 0) {
+ if (i) {
+ r = i - 1;
+ } else {
+ break;
+ }
+ } else if (compare > 0) {
+ l = i + 1;
+ }
+ } else {
+ break; /* should never happen */
+ }
+ } while (l <= r);
+ }
+ iter = iter->next;
+ } while (iter != end);
+ return 0;
+}
+
+/*
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
+ It first searches the mangled names of the types, which is a O(log #types)
+ If a type is not found it then searches the human readable names, which is O(#types).
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ /* STEP 1: Search the name field using binary search */
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+ if (ret) {
+ return ret;
+ } else {
+ /* STEP 2: If the type hasn't been found, do a complete search
+ of the str field (the human readable name) */
+ swig_module_info *iter = start;
+ do {
+ register size_t i = 0;
+ for (; i < iter->size; ++i) {
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+ return iter->types[i];
+ }
+ iter = iter->next;
+ } while (iter != end);
+ }
+
+ /* neither found a match */
+ return 0;
+}
+
+/*
+ Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static const char hex[17] = "0123456789abcdef";
+ register const unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register unsigned char uu = *u;
+ *(c++) = hex[(uu & 0xf0) >> 4];
+ *(c++) = hex[uu & 0xf];
+ }
+ return c;
+}
+
+/*
+ Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+ register unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register char d = *(c++);
+ register unsigned char uu;
+ if ((d >= '0') && (d <= '9'))
+ uu = ((d - '0') << 4);
+ else if ((d >= 'a') && (d <= 'f'))
+ uu = ((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
+ d = *(c++);
+ if ((d >= '0') && (d <= '9'))
+ uu |= (d - '0');
+ else if ((d >= 'a') && (d <= 'f'))
+ uu |= (d - ('a'-10));
+ else
+ return (char *) 0;
+ *u = uu;
+ }
+ return c;
+}
+
+/*
+ Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+ char *r = buff;
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+ strcpy(r,name);
+ return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ *ptr = (void *) 0;
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
+}
+
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+ char *r = buff;
+ size_t lname = (name ? strlen(name) : 0);
+ if ((2*sz + 2 + lname) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,ptr,sz);
+ if (lname) {
+ strncpy(r,name,lname+1);
+ } else {
+ *r = 0;
+ }
+ return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ memset(ptr,0,sz);
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sz);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/swigwarn.swg b/swigwarn.swg
new file mode 100644
index 0000000..3650e9d
--- /dev/null
+++ b/swigwarn.swg
@@ -0,0 +1,262 @@
+/* Automatically generated file containing all the swig warning codes. */
+/* Do not modify this file by hand, change 'Source/Include/swigwarn.h' */
+/* and use the command 'make Lib/swigwarn.swg' instead. */
+
+
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * swigwarn.h
+ *
+ * SWIG warning message numbers
+ * This file serves as the main registry of warning message numbers. Some of these
+ * numbers are used internally in the C/C++ source code of SWIG. However, some
+ * of the numbers are used in SWIG configuration files (swig.swg and others).
+ *
+ * The numbers are roughly organized into a few different classes by functionality.
+ *
+ * Even though symbolic constants are used in the SWIG source, this is
+ * not always the case in SWIG interface files. Do not change the
+ * numbers in this file.
+ * ----------------------------------------------------------------------------- */
+
+/* $Id: swigwarn.h 11459 2009-07-28 11:47:36Z vmiklos $ */
+
+
+%define SWIGWARN_NONE 0 %enddef
+
+/* -- Deprecated features -- */
+
+%define SWIGWARN_DEPRECATED_EXTERN 101 %enddef
+%define SWIGWARN_DEPRECATED_VAL 102 %enddef
+%define SWIGWARN_DEPRECATED_OUT 103 %enddef
+%define SWIGWARN_DEPRECATED_DISABLEDOC 104 %enddef
+%define SWIGWARN_DEPRECATED_ENABLEDOC 105 %enddef
+%define SWIGWARN_DEPRECATED_DOCONLY 106 %enddef
+%define SWIGWARN_DEPRECATED_STYLE 107 %enddef
+%define SWIGWARN_DEPRECATED_LOCALSTYLE 108 %enddef
+%define SWIGWARN_DEPRECATED_TITLE 109 %enddef
+%define SWIGWARN_DEPRECATED_SECTION 110 %enddef
+%define SWIGWARN_DEPRECATED_SUBSECTION 111 %enddef
+%define SWIGWARN_DEPRECATED_SUBSUBSECTION 112 %enddef
+%define SWIGWARN_DEPRECATED_ADDMETHODS 113 %enddef
+%define SWIGWARN_DEPRECATED_READONLY 114 %enddef
+%define SWIGWARN_DEPRECATED_READWRITE 115 %enddef
+%define SWIGWARN_DEPRECATED_EXCEPT 116 %enddef
+%define SWIGWARN_DEPRECATED_NEW 117 %enddef
+%define SWIGWARN_DEPRECATED_EXCEPT_TM 118 %enddef
+%define SWIGWARN_DEPRECATED_IGNORE_TM 119 %enddef
+%define SWIGWARN_DEPRECATED_OPTC 120 %enddef
+%define SWIGWARN_DEPRECATED_NAME 121 %enddef
+%define SWIGWARN_DEPRECATED_NOEXTERN 122 %enddef
+%define SWIGWARN_DEPRECATED_NODEFAULT 123 %enddef
+%define SWIGWARN_DEPRECATED_TYPEMAP_LANG 124 %enddef
+%define SWIGWARN_DEPRECATED_INPUT_FILE 125 %enddef
+
+/* -- Preprocessor -- */
+
+%define SWIGWARN_PP_MISSING_FILE 201 %enddef
+%define SWIGWARN_PP_EVALUATION 202 %enddef
+%define SWIGWARN_PP_INCLUDEALL_IMPORTALL 203 %enddef
+%define SWIGWARN_PP_CPP_WARNING 204 %enddef
+%define SWIGWARN_PP_CPP_ERROR 205 %enddef
+
+/* -- C/C++ Parser -- */
+
+%define SWIGWARN_PARSE_CLASS_KEYWORD 301 %enddef
+%define SWIGWARN_PARSE_REDEFINED 302 %enddef
+%define SWIGWARN_PARSE_EXTEND_UNDEF 303 %enddef
+%define SWIGWARN_PARSE_UNSUPPORTED_VALUE 304 %enddef
+%define SWIGWARN_PARSE_BAD_VALUE 305 %enddef
+%define SWIGWARN_PARSE_PRIVATE 306 %enddef
+%define SWIGWARN_PARSE_BAD_DEFAULT 307 %enddef
+%define SWIGWARN_PARSE_NAMESPACE_ALIAS 308 %enddef
+%define SWIGWARN_PARSE_PRIVATE_INHERIT 309 %enddef
+%define SWIGWARN_PARSE_TEMPLATE_REPEAT 310 %enddef
+%define SWIGWARN_PARSE_TEMPLATE_PARTIAL 311 %enddef
+%define SWIGWARN_PARSE_NESTED_CLASS 312 %enddef
+%define SWIGWARN_PARSE_UNDEFINED_EXTERN 313 %enddef
+%define SWIGWARN_PARSE_KEYWORD 314 %enddef
+%define SWIGWARN_PARSE_USING_UNDEF 315 %enddef
+%define SWIGWARN_PARSE_MODULE_REPEAT 316 %enddef
+%define SWIGWARN_PARSE_TEMPLATE_SP_UNDEF 317 %enddef
+%define SWIGWARN_PARSE_TEMPLATE_AMBIG 318 %enddef
+%define SWIGWARN_PARSE_NO_ACCESS 319 %enddef
+%define SWIGWARN_PARSE_EXPLICIT_TEMPLATE 320 %enddef
+%define SWIGWARN_PARSE_BUILTIN_NAME 321 %enddef
+%define SWIGWARN_PARSE_REDUNDANT 322 %enddef
+%define SWIGWARN_PARSE_REC_INHERITANCE 323 %enddef
+
+%define SWIGWARN_IGNORE_OPERATOR_NEW 350 %enddef /* new */
+%define SWIGWARN_IGNORE_OPERATOR_DELETE 351 %enddef /* delete */
+%define SWIGWARN_IGNORE_OPERATOR_PLUS 352 %enddef /* + */
+%define SWIGWARN_IGNORE_OPERATOR_MINUS 353 %enddef /* - */
+%define SWIGWARN_IGNORE_OPERATOR_MUL 354 %enddef /* * */
+%define SWIGWARN_IGNORE_OPERATOR_DIV 355 %enddef /* / */
+%define SWIGWARN_IGNORE_OPERATOR_MOD 356 %enddef /* % */
+%define SWIGWARN_IGNORE_OPERATOR_XOR 357 %enddef /* ^ */
+%define SWIGWARN_IGNORE_OPERATOR_AND 358 %enddef /* & */
+%define SWIGWARN_IGNORE_OPERATOR_OR 359 %enddef /* | */
+%define SWIGWARN_IGNORE_OPERATOR_NOT 360 %enddef /* ~ */
+%define SWIGWARN_IGNORE_OPERATOR_LNOT 361 %enddef /* ! */
+%define SWIGWARN_IGNORE_OPERATOR_EQ 362 %enddef /* = */
+%define SWIGWARN_IGNORE_OPERATOR_LT 363 %enddef /* < */
+%define SWIGWARN_IGNORE_OPERATOR_GT 364 %enddef /* > */
+%define SWIGWARN_IGNORE_OPERATOR_PLUSEQ 365 %enddef /* += */
+%define SWIGWARN_IGNORE_OPERATOR_MINUSEQ 366 %enddef /* -= */
+%define SWIGWARN_IGNORE_OPERATOR_MULEQ 367 %enddef /* *= */
+%define SWIGWARN_IGNORE_OPERATOR_DIVEQ 368 %enddef /* /= */
+%define SWIGWARN_IGNORE_OPERATOR_MODEQ 369 %enddef /* %= */
+%define SWIGWARN_IGNORE_OPERATOR_XOREQ 370 %enddef /* ^= */
+%define SWIGWARN_IGNORE_OPERATOR_ANDEQ 371 %enddef /* &= */
+%define SWIGWARN_IGNORE_OPERATOR_OREQ 372 %enddef /* |= */
+%define SWIGWARN_IGNORE_OPERATOR_LSHIFT 373 %enddef /* << */
+%define SWIGWARN_IGNORE_OPERATOR_RSHIFT 374 %enddef /* >> */
+%define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ 375 %enddef /* <<= */
+%define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ 376 %enddef /* >>= */
+%define SWIGWARN_IGNORE_OPERATOR_EQUALTO 377 %enddef /* == */
+%define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL 378 %enddef /* != */
+%define SWIGWARN_IGNORE_OPERATOR_LTEQUAL 379 %enddef /* <= */
+%define SWIGWARN_IGNORE_OPERATOR_GTEQUAL 380 %enddef /* >= */
+%define SWIGWARN_IGNORE_OPERATOR_LAND 381 %enddef /* && */
+%define SWIGWARN_IGNORE_OPERATOR_LOR 382 %enddef /* || */
+%define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS 383 %enddef /* ++ */
+%define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS 384 %enddef /* -- */
+%define SWIGWARN_IGNORE_OPERATOR_COMMA 385 %enddef /* , */
+%define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR 386 %enddef /* ->* */
+%define SWIGWARN_IGNORE_OPERATOR_ARROW 387 %enddef /* -> */
+%define SWIGWARN_IGNORE_OPERATOR_CALL 388 %enddef /* () */
+%define SWIGWARN_IGNORE_OPERATOR_INDEX 389 %enddef /* [] */
+%define SWIGWARN_IGNORE_OPERATOR_UPLUS 390 %enddef /* + */
+%define SWIGWARN_IGNORE_OPERATOR_UMINUS 391 %enddef /* - */
+%define SWIGWARN_IGNORE_OPERATOR_UMUL 392 %enddef /* * */
+%define SWIGWARN_IGNORE_OPERATOR_UAND 393 %enddef /* & */
+%define SWIGWARN_IGNORE_OPERATOR_NEWARR 394 %enddef /* new [] */
+%define SWIGWARN_IGNORE_OPERATOR_DELARR 395 %enddef /* delete [] */
+%define SWIGWARN_IGNORE_OPERATOR_REF 396 %enddef /* operator *() */
+
+/* 394-399 are reserved */
+
+/* -- Type system and typemaps -- */
+
+%define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef
+%define SWIGWARN_TYPE_INCOMPLETE 402 %enddef
+%define SWIGWARN_TYPE_ABSTRACT 403 %enddef
+%define SWIGWARN_TYPE_REDEFINED 404 %enddef
+
+%define SWIGWARN_TYPEMAP_SOURCETARGET 450 %enddef
+%define SWIGWARN_TYPEMAP_CHARLEAK 451 %enddef
+%define SWIGWARN_TYPEMAP_SWIGTYPE 452 %enddef
+%define SWIGWARN_TYPEMAP_APPLY_UNDEF 453 %enddef
+%define SWIGWARN_TYPEMAP_SWIGTYPELEAK 454 %enddef
+
+%define SWIGWARN_TYPEMAP_IN_UNDEF 460 %enddef
+%define SWIGWARN_TYPEMAP_OUT_UNDEF 461 %enddef
+%define SWIGWARN_TYPEMAP_VARIN_UNDEF 462 %enddef
+%define SWIGWARN_TYPEMAP_VAROUT_UNDEF 463 %enddef
+%define SWIGWARN_TYPEMAP_CONST_UNDEF 464 %enddef
+%define SWIGWARN_TYPEMAP_UNDEF 465 %enddef
+%define SWIGWARN_TYPEMAP_VAR_UNDEF 466 %enddef
+%define SWIGWARN_TYPEMAP_TYPECHECK 467 %enddef
+%define SWIGWARN_TYPEMAP_THROW 468 %enddef
+%define SWIGWARN_TYPEMAP_DIRECTORIN_UNDEF 469 %enddef
+%define SWIGWARN_TYPEMAP_THREAD_UNSAFE 470 %enddef /* mostly used in directorout typemaps */
+%define SWIGWARN_TYPEMAP_DIRECTOROUT_UNDEF 471 %enddef
+%define SWIGWARN_TYPEMAP_TYPECHECK_UNDEF 472 %enddef
+%define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR 473 %enddef
+%define SWIGWARN_TYPEMAP_OUT_OPTIMAL_IGNORED 474 %enddef
+%define SWIGWARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE 475 %enddef
+
+/* -- Fragments -- */
+%define SWIGWARN_FRAGMENT_NOT_FOUND 490 %enddef
+
+/* -- General code generation -- */
+
+%define SWIGWARN_LANG_OVERLOAD_DECL 501 %enddef
+%define SWIGWARN_LANG_OVERLOAD_CONSTRUCT 502 %enddef
+%define SWIGWARN_LANG_IDENTIFIER 503 %enddef
+%define SWIGWARN_LANG_RETURN_TYPE 504 %enddef
+%define SWIGWARN_LANG_VARARGS 505 %enddef
+%define SWIGWARN_LANG_VARARGS_KEYWORD 506 %enddef
+%define SWIGWARN_LANG_NATIVE_UNIMPL 507 %enddef
+%define SWIGWARN_LANG_DEREF_SHADOW 508 %enddef
+%define SWIGWARN_LANG_OVERLOAD_SHADOW 509 %enddef
+%define SWIGWARN_LANG_FRIEND_IGNORE 510 %enddef
+%define SWIGWARN_LANG_OVERLOAD_KEYWORD 511 %enddef
+%define SWIGWARN_LANG_OVERLOAD_CONST 512 %enddef
+%define SWIGWARN_LANG_CLASS_UNNAMED 513 %enddef
+%define SWIGWARN_LANG_DIRECTOR_VDESTRUCT 514 %enddef
+%define SWIGWARN_LANG_DISCARD_CONST 515 %enddef
+%define SWIGWARN_LANG_OVERLOAD_IGNORED 516 %enddef
+%define SWIGWARN_LANG_DIRECTOR_ABSTRACT 517 %enddef
+%define SWIGWARN_LANG_PORTABILITY_FILENAME 518 %enddef
+%define SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE 519 %enddef
+
+/* -- Reserved (600-799) -- */
+
+/* -- Language module specific warnings (800 - 999) -- */
+
+%define SWIGWARN_RUBY_WRONG_NAME 801 %enddef
+%define SWIGWARN_RUBY_MULTIPLE_INHERITANCE 802 %enddef
+
+%define SWIGWARN_JAVA_TYPEMAP_JNI_UNDEF 810 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JTYPE_UNDEF 811 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812 %enddef
+%define SWIGWARN_JAVA_MULTIPLE_INHERITANCE 813 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_GETCPTR_UNDEF 814 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_CLASSMOD_UNDEF 815 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JAVABODY_UNDEF 816 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820 %enddef
+%define SWIGWARN_JAVA_COVARIANT_RET 822 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824 %enddef
+%define SWIGWARN_JAVA_NO_DIRECTORCONNECT_ATTR 825 %enddef
+
+/* please leave 810-829 free for Java */
+
+%define SWIGWARN_CSHARP_TYPEMAP_CTYPE_UNDEF 830 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSTYPE_UNDEF 831 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF 832 %enddef
+%define SWIGWARN_CSHARP_MULTIPLE_INHERITANCE 833 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_GETCPTR_UNDEF 834 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF 835 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSBODY_UNDEF 836 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSOUT_UNDEF 837 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSIN_UNDEF 838 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840 %enddef
+%define SWIGWARN_CSHARP_COVARIANT_RET 842 %enddef
+%define SWIGWARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843 %enddef
+%define SWIGWARN_CSHARP_EXCODE 844 %enddef
+%define SWIGWARN_CSHARP_CANTHROW 845 %enddef
+%define SWIGWARN_CSHARP_NO_DIRECTORCONNECT_ATTR 846 %enddef
+
+
+%define SWIGWARN_MODULA3_TYPEMAP_TYPE_UNDEF 850 %enddef
+%define SWIGWARN_MODULA3_TYPEMAP_GETCPTR_UNDEF 851 %enddef
+%define SWIGWARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF 852 %enddef
+%define SWIGWARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF 853 %enddef
+%define SWIGWARN_MODULA3_TYPEMAP_MULTIPLE_RETURN 854 %enddef
+%define SWIGWARN_MODULA3_MULTIPLE_INHERITANCE 855 %enddef
+%define SWIGWARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN 856 %enddef
+%define SWIGWARN_MODULA3_UNKNOWN_PRAGMA 857 %enddef
+%define SWIGWARN_MODULA3_BAD_ENUMERATION 858 %enddef
+%define SWIGWARN_MODULA3_DOUBLE_ID 859 %enddef
+%define SWIGWARN_MODULA3_BAD_IMPORT 860 %enddef
+
+/* please leave 850-869 free for Modula 3 */
+
+%define SWIGWARN_PHP_MULTIPLE_INHERITANCE 870 %enddef
+%define SWIGWARN_PHP_UNKNOWN_PRAGMA 871 %enddef
+%define SWIGWARN_PHP_PUBLIC_BASE 872 %enddef
+
+/* please leave 870-889 free for PHP */
+
+
+/* Feel free to claim any number in this space that's not currently being used. Just make sure you
+ add an entry here */
+
diff --git a/swigwarnings.swg b/swigwarnings.swg
new file mode 100644
index 0000000..21498eb
--- /dev/null
+++ b/swigwarnings.swg
@@ -0,0 +1,128 @@
+/*
+ Include the internal swig macro codes. These macros correspond to
+ the one found in Source/Include/swigwarn.h plus the 'SWIG' prefix.
+
+ For example, in the include file 'swigwarn.h' you will find
+
+ #define WARN_TYPEMAP_CHARLEAK ...
+
+ and in the 'swigwarn.swg' interface, you will see
+
+ %define SWIGWARN_TYPEMAP_CHARLEAK ...
+
+ This code can be used in warning filters as follows:
+
+ %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+
+ Warnings messages used in typemaps. Message names will be the same
+ as those in Lib/swigwarn.swg but with the suffix _MSG.
+
+ For example, for the code SWIGWARN_TYPEMAP_CHARLEAK, once you use
+
+ %typemapmsg(CHARLEAK,<msg>);
+
+ you use the message in your typemap as
+
+ %typemap(varin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) char *
+
+ while you suppress the warning using
+
+ %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+
+ as described above.
+*/
+
+/* -----------------------------------------------------------------------------
+ * SWIG warning codes
+ * ----------------------------------------------------------------------------- */
+
+%include <swigwarn.swg>
+
+/* -----------------------------------------------------------------------------
+ * Auxiliary macros
+ * ----------------------------------------------------------------------------- */
+
+/* Macro to define warning messages */
+#define %_warningmsg(Val, Msg...) `Val`":"Msg
+#define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg)
+
+/* -----------------------------------------------------------------------------
+ * Typemap related warning messages
+ * ----------------------------------------------------------------------------- */
+
+%define SWIGWARN_TYPEMAP_CHARLEAK_MSG "451:Setting a const char * variable may leak memory." %enddef
+%define SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG "454:Setting a pointer/reference variable may leak memory." %enddef
+%define SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG "470:Thread/reentrant unsafe wrapping, consider returning by value instead." %enddef
+%define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG "473:Returning a pointer or reference in a director method is not recommended." %enddef
+
+/* -----------------------------------------------------------------------------
+ * Operator related warning messages
+ * ----------------------------------------------------------------------------- */
+
+%define SWIGWARN_IGNORE_OPERATOR_NEW_MSG "350:operator new ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_DELETE_MSG "351:operator delete ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_PLUS_MSG "352:operator+ ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MINUS_MSG "353:operator- ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MUL_MSG "354:operator* ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_DIV_MSG "355:operator/ ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MOD_MSG "356:operator% ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_XOR_MSG "357:operator^ ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_AND_MSG "358:operator& ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_OR_MSG "359:operator| ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_NOT_MSG "360:operator~ ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LNOT_MSG "361:operator! ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_EQ_MSG "362:operator= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LT_MSG "363:operator< ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_GT_MSG "364:operator> ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_PLUSEQ_MSG "365:operator+= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MINUSEQ_MSG "366:operator-= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MULEQ_MSG "367:operator*= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_DIVEQ_MSG "368:operator/= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MODEQ_MSG "369:operator%= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_XOREQ_MSG "370:operator^= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_ANDEQ_MSG "371:operator&= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_OREQ_MSG "372:operator|= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LSHIFT_MSG "373:operator<< ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_RSHIFT_MSG "374:operator>> ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ_MSG "375:operator<<= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ_MSG "376:operator>>= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_EQUALTO_MSG "377:operator== ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL_MSG "378:operator!= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LTEQUAL_MSG "379:operator<= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_GTEQUAL_MSG "380:operator>= ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LAND_MSG "381:operator&& ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_LOR_MSG "382:operator|| ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS_MSG "383:operator++ ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS_MSG "384:operator-- ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_COMMA_MSG "385:operator-- ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR_MSG "386:operator->* ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_ARROW_MSG "387:operator-> ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_CALL_MSG "388:operator() ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_INDEX_MSG "389:operator[] ignored (consider using %%extend)" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_UPLUS_MSG "390:operator+ ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_UMINUS_MSG "391:operator- ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_UMUL_MSG "392:operator* ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_UAND_MSG "393:operator& ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_NEWARR_MSG "394:operator new[] ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_DELARR_MSG "395:operator delete[] ignored" %enddef
+%define SWIGWARN_IGNORE_OPERATOR_REF_MSG "396:operator*() ignored" %enddef
+
+#define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG)
+
+/* -----------------------------------------------------------------------------
+ * Macros for keyword and built-in names
+ * ----------------------------------------------------------------------------- */
+
+#define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg))
+#define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg), %$isfunction)
+
+
+/* -----------------------------------------------------------------------------
+ * Warning filter feature
+ * ----------------------------------------------------------------------------- */
+
+#define %_warnfilter(filter...) %feature("warnfilter",`filter`)
+#define %warnfilter(filter...) %_warnfilter(filter)
+
+
+
diff --git a/typemaps/README b/typemaps/README
new file mode 100644
index 0000000..6513457
--- /dev/null
+++ b/typemaps/README
@@ -0,0 +1,54 @@
+Still in development, but if you are interested into looking around,
+start with
+
+
+ swigtypemaps.swg
+
+which is the head file. Also read the docs for %fragments in
+
+ fragments.swg
+
+and follow the definitions in one of the supported languages:
+
+ python, perl, ruby, tcl
+
+
+
+
+/* -----------------------------------------------------------------------------
+ * Internal typemap specializations
+ * ----------------------------------------------------------------------------- */
+
+
+carrays.swg Implement the carrays.i library
+cdata.swg Implement the cdata.i library
+cmalloc.swg Implement the cmalloc.i library
+cpointer.swg Implement the cpointer.i library
+cstring.swg Implement the cstring.i library typemaps for char *
+cwstring.swg Implement the cstring.i library typemaps for wchar_t *
+exception.swg Implement the exception.i library
+implicit.swg Allow the use of implicit C++ constructors
+
+string.swg Typemaps for char * string
+wstring.swg Typemaps for wchar_t * string
+std_string.swg Typemaps for std::string
+std_wstring.swg Typemaps for std::wstring
+swigtype.swg Typemaps for the SWIGTYPE type
+void.swg Typemaps for the 'void' type
+enumint.swg Typemaps for enums treated as 'int'
+swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc.
+misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc)
+ptrtypes.swg Typemaps for types with a 'ptr' behavior
+valtypes.swg Typemaps for 'by value' types
+inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list
+primtypes.swg Common macros to manage primitive types (short,int,double,etc)
+
+cstrings.swg Common macros to implemented the cstring/cwstring libraries
+std_strings.swg Common macros to implemented the std::string/std::wstring typemaps
+strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *)
+
+swigmacros.swg Basic macros
+fragments.swg Macros for fragment manipulations
+
+
+typemaps.swg The old typemaps.i library, not needed anymore
diff --git a/typemaps/attribute.swg b/typemaps/attribute.swg
new file mode 100644
index 0000000..4bc6315
--- /dev/null
+++ b/typemaps/attribute.swg
@@ -0,0 +1,286 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * attribute.swg
+ *
+ * Attribute implementation
+ * ----------------------------------------------------------------------------- */
+
+/*
+ The following macros convert a pair of set/get methods
+ into a "native" attribute.
+
+ Use %attribute when you have a pair of get/set methods to a primitive type
+ like in:
+
+ %attribute(A, int, a, get_a, set_a);
+
+ struct A
+ {
+ int get_a() const;
+ void set_a(int aa);
+ };
+
+ If you don't provide a 'set' method, a 'read-only' attribute
+ is generated, ie, like in:
+
+ %attribute(A, int, c, get_c);
+
+ Use %attributeref when you have const/non-const reference access methods
+ for primitive types or class/structs, like in:
+
+ %attributeref(A, int, b);
+
+ struct A
+ {
+ const int& b() const;
+ int& b();
+ };
+
+ %attributeref(B, int, c);
+
+ struct B
+ {
+ int& c();
+ };
+
+ You can also use
+
+ %attributeref(Class, AttributeType, AttributeName, AccessorMethod)
+
+ if the internal C++ reference methods have a different name from the
+ attribute you want, so
+
+ %attributeref(B, int, d, c);
+
+ is the same as the last example, but instead of the attribute 'c' being
+ called 'c', it is called 'd'.
+
+ Now you can use the attributes like so:
+
+ x = A()
+ x.a = 3 # calls A::set_a
+ print x.a # calls A::get_a
+
+ x.b = 3 # calls A::b()
+ print x.b # calls A::b() const
+
+ Use %attribute2 instead of %attribute to indicate that reference-pointer
+ translation is required. You use %attribute2 instead of %attribute in
+ cases like this:
+
+ %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo);
+ %inline %{
+ struct MyFoo {
+ int x;
+ };
+ class MyClass {
+ MyFoo foo;
+ public:
+ MyFoo& GetFoo() { return foo; }
+ void SetFoo(const MyFoo& other) { foo = other; }
+ };
+ %}
+
+ Here, the data type of the property is a wrapped type (MyFoo) and on the
+ C++ side it is passed by reference. The problem is that the SWIG wrapper will
+ pass around a pointer (MyFoo *) which is not compatible with the reference
+ type of the accessors (MyFoo &). Therefore, if you use %attribute, you'll get
+ an error from your C/C++ compiler. %attribute2 translates between a pointer
+ and a reference to eliminate the error. In case you're confused, let's make it
+ simple: just use %attribute at first, but if the C/C++ compiler gives an error
+ while compiling the wrapper, try %attribute2 instead.
+
+ NOTE: remember that if the type contains commas, such as 'std::pair<int,int>',
+ you need to use the macro like:
+
+ %attributeref(A, %arg(std::pair<int,int>), pval);
+
+ where %arg() 'normalizes' the type to be understood as a single
+ argument, otherwise the macro will get confused by the comma.
+
+ The %attributeval is the same as %attribute, but should be used when the type
+ is a class/struct (ie a non-primitive type) and when the get and set methods
+ return/pass by value. The following is very similar to the above example, but
+ note that the access is by value rather than reference.
+
+ %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo);