aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/swig/Lib
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2023-10-03 11:19:48 +0300
committerthegeorg <thegeorg@yandex-team.com>2023-10-03 11:43:28 +0300
commitcda0c13f23f6b169fb0a49dc504b40a0aaecea09 (patch)
tree26476e92e5af2c856e017afb1df8f8dff42495bf /contrib/tools/swig/Lib
parent4854116da9c5e3c95bb8440f2ea997c54b6e1a61 (diff)
downloadydb-cda0c13f23f6b169fb0a49dc504b40a0aaecea09.tar.gz
Move contrib/tools/jdk to build/platform/java/jdk/testing
Diffstat (limited to 'contrib/tools/swig/Lib')
-rw-r--r--contrib/tools/swig/Lib/go/go.swg744
-rw-r--r--contrib/tools/swig/Lib/go/gokw.swg33
-rw-r--r--contrib/tools/swig/Lib/go/goruntime.swg217
-rw-r--r--contrib/tools/swig/Lib/go/gostring.swg29
-rw-r--r--contrib/tools/swig/Lib/go/typemaps.i298
-rw-r--r--contrib/tools/swig/Lib/java/enumtypesafe.swg117
-rw-r--r--contrib/tools/swig/Lib/java/java.swg1458
-rw-r--r--contrib/tools/swig/Lib/java/javahead.swg91
-rw-r--r--contrib/tools/swig/Lib/java/javakw.swg70
-rw-r--r--contrib/tools/swig/Lib/java/typemaps.i529
-rw-r--r--contrib/tools/swig/Lib/perl5/extra-install.list2
-rw-r--r--contrib/tools/swig/Lib/perl5/perl5.swg42
-rw-r--r--contrib/tools/swig/Lib/perl5/perlfragments.swg23
-rw-r--r--contrib/tools/swig/Lib/perl5/perlinit.swg78
-rw-r--r--contrib/tools/swig/Lib/perl5/perlkw.swg251
-rw-r--r--contrib/tools/swig/Lib/perl5/perlmacros.swg2
-rw-r--r--contrib/tools/swig/Lib/perl5/perlopers.swg54
-rw-r--r--contrib/tools/swig/Lib/perl5/perlprimtypes.swg364
-rw-r--r--contrib/tools/swig/Lib/perl5/perlruntime.swg8
-rw-r--r--contrib/tools/swig/Lib/perl5/perlstrings.swg59
-rw-r--r--contrib/tools/swig/Lib/perl5/perltypemaps.swg104
-rw-r--r--contrib/tools/swig/Lib/perl5/perluserdir.swg2
-rw-r--r--contrib/tools/swig/Lib/perl5/reference.i261
-rw-r--r--contrib/tools/swig/Lib/perl5/typemaps.i371
-rw-r--r--contrib/tools/swig/Lib/python/README103
-rw-r--r--contrib/tools/swig/Lib/python/builtin.swg764
-rw-r--r--contrib/tools/swig/Lib/python/pyapi.swg30
-rw-r--r--contrib/tools/swig/Lib/python/pybackward.swg45
-rw-r--r--contrib/tools/swig/Lib/python/pyclasses.swg157
-rw-r--r--contrib/tools/swig/Lib/python/pydocs.swg45
-rw-r--r--contrib/tools/swig/Lib/python/pyerrors.swg107
-rw-r--r--contrib/tools/swig/Lib/python/pyfragments.swg23
-rw-r--r--contrib/tools/swig/Lib/python/pyhead.swg75
-rw-r--r--contrib/tools/swig/Lib/python/pyinit.swg325
-rw-r--r--contrib/tools/swig/Lib/python/pymacros.swg4
-rw-r--r--contrib/tools/swig/Lib/python/pyopers.swg264
-rw-r--r--contrib/tools/swig/Lib/python/pyprimtypes.swg353
-rw-r--r--contrib/tools/swig/Lib/python/pyrun.swg1913
-rw-r--r--contrib/tools/swig/Lib/python/pyruntime.swg49
-rw-r--r--contrib/tools/swig/Lib/python/pystrings.swg139
-rw-r--r--contrib/tools/swig/Lib/python/python.swg59
-rw-r--r--contrib/tools/swig/Lib/python/pythonkw.swg140
-rw-r--r--contrib/tools/swig/Lib/python/pythreads.swg68
-rw-r--r--contrib/tools/swig/Lib/python/pytypemaps.swg105
-rw-r--r--contrib/tools/swig/Lib/python/pyuserdir.swg242
-rw-r--r--contrib/tools/swig/Lib/python/typemaps.i148
-rw-r--r--contrib/tools/swig/Lib/python/ya.make22
-rw-r--r--contrib/tools/swig/Lib/std/README22
-rw-r--r--contrib/tools/swig/Lib/swig.swg729
-rw-r--r--contrib/tools/swig/Lib/swigerrors.swg15
-rw-r--r--contrib/tools/swig/Lib/swigfragments.swg90
-rw-r--r--contrib/tools/swig/Lib/swiginit.swg233
-rw-r--r--contrib/tools/swig/Lib/swiglabels.swg123
-rw-r--r--contrib/tools/swig/Lib/swigrun.swg581
-rw-r--r--contrib/tools/swig/Lib/swigwarn.swg300
-rw-r--r--contrib/tools/swig/Lib/swigwarnings.swg131
-rw-r--r--contrib/tools/swig/Lib/typemaps/README54
-rw-r--r--contrib/tools/swig/Lib/typemaps/enumint.swg39
-rw-r--r--contrib/tools/swig/Lib/typemaps/exception.swg87
-rw-r--r--contrib/tools/swig/Lib/typemaps/fragments.swg231
-rw-r--r--contrib/tools/swig/Lib/typemaps/inoutlist.swg296
-rw-r--r--contrib/tools/swig/Lib/typemaps/misctypes.swg21
-rw-r--r--contrib/tools/swig/Lib/typemaps/primtypes.swg367
-rw-r--r--contrib/tools/swig/Lib/typemaps/ptrtypes.swg208
-rw-r--r--contrib/tools/swig/Lib/typemaps/string.swg36
-rw-r--r--contrib/tools/swig/Lib/typemaps/strings.swg658
-rw-r--r--contrib/tools/swig/Lib/typemaps/swigmacros.swg228
-rw-r--r--contrib/tools/swig/Lib/typemaps/swigobject.swg37
-rw-r--r--contrib/tools/swig/Lib/typemaps/swigtype.swg710
-rw-r--r--contrib/tools/swig/Lib/typemaps/swigtypemaps.swg168
-rw-r--r--contrib/tools/swig/Lib/typemaps/typemaps.swg157
-rw-r--r--contrib/tools/swig/Lib/typemaps/valtypes.swg215
-rw-r--r--contrib/tools/swig/Lib/typemaps/void.swg84
73 files changed, 16207 insertions, 0 deletions
diff --git a/contrib/tools/swig/Lib/go/go.swg b/contrib/tools/swig/Lib/go/go.swg
new file mode 100644
index 0000000000..348ae5f0d9
--- /dev/null
+++ b/contrib/tools/swig/Lib/go/go.swg
@@ -0,0 +1,744 @@
+/* ------------------------------------------------------------
+ * go.swg
+ *
+ * Go configuration module.
+ * ------------------------------------------------------------ */
+
+%include <gostring.swg>
+
+/* Code insertion directives */
+#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%}
+
+/* Basic types */
+
+%typemap(gotype) bool, const bool & "bool"
+%typemap(gotype) char, const char & "byte"
+%typemap(gotype) signed char, const signed char & "int8"
+%typemap(gotype) unsigned char, const unsigned char & "byte"
+%typemap(gotype) short, const short & "int16"
+%typemap(gotype) unsigned short, const unsigned short & "uint16"
+%typemap(gotype) int, const int & "int"
+%typemap(gotype) unsigned int, const unsigned int & "uint"
+%typemap(gotype) long, const long & "int64"
+%typemap(gotype) unsigned long, const unsigned long & "uint64"
+%typemap(gotype) long long, const long long & "int64"
+%typemap(gotype) unsigned long long, const unsigned long long & "uint64"
+%typemap(gotype) float, const float & "float32"
+%typemap(gotype) double, const double & "float64"
+
+%typemap(in) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+%{ $1 = ($1_ltype)$input; %}
+
+%typemap(in) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+%{ $1 = ($1_ltype)&$input; %}
+
+%typemap(in) const long & ($*1_ltype temp),
+ const unsigned long & ($*1_ltype temp)
+%{ temp = ($*1_ltype)$input;
+ $1 = ($1_ltype)&temp; %}
+
+%typemap(out) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+%{ $result = $1; %}
+
+%typemap(goout) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+""
+
+%typemap(out) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+%{ $result = ($*1_ltype)*$1; %}
+
+%typemap(goout) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+""
+
+%typemap(out) void ""
+
+%typemap(goout) void ""
+
+%typemap(directorin) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+%{ $input = ($1_ltype)$1; %}
+
+%typemap(godirectorin) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+""
+
+%typemap(directorin) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+%{ $input = ($*1_ltype)$1; %}
+
+%typemap(godirectorin) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+""
+
+%typemap(directorout) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+%{ $result = ($1_ltype)$input; %}
+
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+%{
+ $result = new $*1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
+%}
+
+/* The size_t type. */
+
+%typemap(gotype) size_t, const size_t & %{int64%}
+
+%typemap(in) size_t
+%{ $1 = (size_t)$input; %}
+
+%typemap(in) const size_t &
+%{ $1 = ($1_ltype)&$input; %}
+
+%typemap(out) size_t
+%{ $result = $1; %}
+
+%typemap(goout) size_t ""
+
+%typemap(out) const size_t &
+%{ $result = ($*1_ltype)*$1; %}
+
+%typemap(goout) const size_t & ""
+
+%typemap(directorin) size_t
+%{ $input = (size_t)$1; %}
+
+%typemap(godirectorin) size_t ""
+
+%typemap(directorin) const size_t &
+%{ $input = ($*1_ltype)$1; %}
+
+%typemap(godirectorin) const size_t & ""
+
+%typemap(directorout) size_t
+%{ $result = ($1_ltype)$input; %}
+
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t &
+%{
+ $result = new $*1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
+%}
+
+/* Member pointers. */
+
+%typemap(gotype) SWIGTYPE (CLASS::*)
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE (CLASS::*)
+%{ $1 = *($&1_ltype)$input; %}
+
+%typemap(out) SWIGTYPE (CLASS::*)
+%{
+ struct swig_out_type { intgo size; void* val; } *swig_out;
+ swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out));
+ if (swig_out) {
+ swig_out->size = sizeof($1_ltype);
+ swig_out->val = malloc(swig_out->size);
+ if (swig_out->val) {
+ *($&1_ltype)(swig_out->val) = $1;
+ }
+ }
+ $result = swig_out;
+%}
+
+%typemap(goout) SWIGTYPE (CLASS::*)
+%{
+ {
+ type swig_out_type struct { size int; val uintptr }
+ p := (*swig_out_type)(unsafe.Pointer($1))
+ if p == nil || p.val == 0 {
+ $result = nil
+ } else {
+ m := make([]byte, p.size)
+ a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size]
+ copy(m, a)
+ Swig_free(p.val)
+ Swig_free(uintptr(unsafe.Pointer(p)))
+ $result = &m[0]
+ }
+ }
+%}
+
+%typemap(directorin) SWIGTYPE (CLASS::*)
+%{ $input = *($&1_ltype)$1; %}
+
+%typemap(godirectorin) SWIGTYPE (CLASS::*) ""
+
+%typemap(directorout) SWIGTYPE (CLASS::*)
+%{
+ $result = new $1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
+%}
+
+/* Pointers. */
+
+/* We can't translate pointers using a typemap, so that is handled in
+ the C++ code. */
+%typemap(gotype) SWIGTYPE *
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE *
+%{ $1 = *($&1_ltype)&$input; %}
+
+%typemap(out) SWIGTYPE *
+%{ *($&1_ltype)&$result = ($1_ltype)$1; %}
+
+%typemap(goout) SWIGTYPE * ""
+
+%typemap(directorin) SWIGTYPE *
+%{ *($&1_ltype)&$input = ($1_ltype)$1; %}
+
+%typemap(godirectorin) SWIGTYPE * ""
+
+%typemap(directorout) SWIGTYPE *
+%{ $result = *($&1_ltype)&$input; %}
+
+/* Pointer references. */
+
+%typemap(gotype) SWIGTYPE *const&
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
+%{
+ temp = *($1_ltype)&$input;
+ $1 = ($1_ltype)&temp;
+%}
+
+%typemap(out) SWIGTYPE *const&
+%{ *($1_ltype)&$result = *$1; %}
+
+%typemap(goout) SWIGTYPE *const& ""
+
+/* References. */
+
+/* Converting a C++ reference to Go has to be handled in the C++
+ code. */
+%typemap(gotype) SWIGTYPE &
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE &
+%{ $1 = *($&1_ltype)&$input; %}
+
+%typemap(out) SWIGTYPE &
+%{ *($&1_ltype)&$result = $1; %}
+
+%typemap(goout) SWIGTYPE & ""
+
+%typemap(directorin) SWIGTYPE &
+%{ $input = ($1_ltype)&$1; %}
+
+%typemap(godirectorin) SWIGTYPE & ""
+
+%typemap(directorout) SWIGTYPE &
+%{ *($&1_ltype)&$result = $input; %}
+
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
+%{ static $*1_ltype swig_temp;
+ swig_temp = *($1_ltype)&$input;
+ $result = &swig_temp; %}
+
+%typemap(gotype) SWIGTYPE &&
+%{$gotypename%}
+
+%typemap(in, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter)
+%{ $1 = *($&1_ltype)&$input;
+rvrdeleter.reset($1); %}
+
+%typemap(out) SWIGTYPE &&
+%{ *($&1_ltype)&$result = $1; %}
+
+%typemap(goout) SWIGTYPE && ""
+
+%typemap(directorin) SWIGTYPE &&
+%{ $input = ($1_ltype)&$1_name; %}
+
+%typemap(godirectorin) SWIGTYPE && ""
+
+%typemap(directorout) SWIGTYPE &&
+%{ *($&1_ltype)&$result = $input; %}
+
+/* C arrays turn into Go pointers. If we know the length we can use a
+ slice. */
+
+%typemap(gotype) SWIGTYPE []
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE []
+%{ $1 = *($&1_ltype)&$input; %}
+
+%typemap(out) SWIGTYPE []
+%{ *($&1_ltype)&$result = $1; %}
+
+%typemap(goout) SWIGTYPE [] ""
+
+%typemap(directorin) SWIGTYPE []
+%{ $input = *($1_ltype)&$1; %}
+
+%typemap(godirectorin) SWIGTYPE [] ""
+
+%typemap(directorout) SWIGTYPE []
+%{ *($&1_ltype)&$result = $input; %}
+
+/* Strings. */
+
+%typemap(gotype)
+ char *, char *&, char[ANY], char[] "string"
+
+/* Needed to avoid confusion with the way the go module handles
+ references. */
+%typemap(gotype) char&, unsigned char& "*byte"
+%typemap(gotype) signed char& "*int8"
+
+%typemap(in)
+ char *, char[ANY], char[]
+%{
+ $1 = ($1_ltype)malloc($input.n + 1);
+ memcpy($1, $input.p, $input.n);
+ $1[$input.n] = '\0';
+%}
+
+%typemap(in) char *& (char *temp)
+%{
+ temp = (char *)malloc($input.n + 1);
+ memcpy(temp, $input.p, $input.n);
+ temp[$input.n] = '\0';
+ $1 = ($1_ltype)&temp;
+%}
+
+%typemap(freearg)
+ char *, char[ANY], char[]
+%{ free($1); %}
+
+%typemap(freearg) char *&
+%{ free(temp$argnum); %}
+
+%typemap(out,fragment="AllocateString")
+ char *, char *&, char[ANY], char[]
+%{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %}
+
+%typemap(goout,fragment="CopyString")
+ char *, char *&, char[ANY], char[]
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString")
+ char *, char *&, char[ANY], char[]
+%{
+ $input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0);
+%}
+
+%typemap(godirectorin,fragment="CopyString")
+ char *, char *&, char[ANY], char[]
+%{
+ $result = swigCopyString($input)
+%}
+
+%typemap(godirectorout)
+ char *, char *&, char[ANY], char[]
+%{
+ {
+ p := Swig_malloc(len($input) + 1)
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input) + 1]
+ copy(s, $input)
+ s[len($input)] = 0
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ char *, char *&, char[ANY], char[]
+%{ $result = ($1_ltype)$input.p; %}
+
+/* String & length */
+
+%typemap(gotype) (char *STRING, size_t LENGTH) "string"
+
+%typemap(in) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
+%typemap(out,fragment="AllocateString") (char *STRING, size_t LENGTH)
+%{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %}
+
+%typemap(goout,fragment="CopyString") (char *STRING, size_t LENGTH)
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString") (char *STRING, size_t LENGTH)
+%{ $input = Swig_AllocateString((char*)$1, $2); %}
+
+%typemap(godirectorin,fragment="CopyString") (char *STRING, size_t LENGTH)
+%{ $result = swigCopyString($input) %}
+
+%typemap(directorout) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
+/* The int & type needs to convert to intgo. */
+
+%typemap(gotype) int & "*int"
+
+%typemap(in) int & (int e)
+%{
+ e = (int)*$input;
+ $1 = &e;
+%}
+
+%typemap(out) int &
+%{ $result = new intgo(*$1); %}
+
+%typemap(argout) int &
+%{ *$input = (intgo)e$argnum; %}
+
+%typemap(goout) int & ""
+
+%typemap(directorin) int & (intgo e)
+%{
+ e = (intgo)$1;
+ $input = &e;
+%}
+
+%typemap(godirectorin) int & ""
+
+%typemap(directorout) int &
+%{
+ $*1_ltype f = ($*1_ltype)*$input;
+ $result = ($1_ltype)&f;
+%}
+
+%typemap(directorargout) int &
+%{ $1 = (int)*$input; %}
+
+%typemap(argout) const int & ""
+%typemap(directorargout) const int & ""
+
+/* Enums. We can't do the right thing for enums in typemap(gotype) so
+ we deliberately don't define them. The right thing would be to
+ capitalize the name. This is instead done in go.cxx. */
+
+%typemap(gotype) enum SWIGTYPE
+%{$gotypename%}
+
+%typemap(in) enum SWIGTYPE
+%{ $1 = ($1_ltype)$input; %}
+
+%typemap(out) enum SWIGTYPE
+%{ $result = (intgo)$1; %}
+
+%typemap(goout) enum SWIGTYPE ""
+
+%typemap(directorin) enum SWIGTYPE
+%{ $input = (intgo)$1; %}
+
+%typemap(godirectorin) enum SWIGTYPE ""
+
+%typemap(directorout) enum SWIGTYPE
+%{ $result = ($1_ltype)$input; %}
+
+%typemap(directorin) enum SWIGTYPE & (intgo e)
+%{
+ e = (intgo)$1;
+ $input = ($1_ltype)&e;
+%}
+
+%typemap(godirectorin) enum SWIGTYPE & ""
+
+%typemap(directorout) enum SWIGTYPE &
+%{ $result = $input; %}
+
+/* Arbitrary type. This is a type passed by value in the C/C++ code.
+ We convert it to a pointer for the Go code. Note that all basic
+ types are explicitly handled above. */
+
+%typemap(gotype) SWIGTYPE
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE ($&1_type argp)
+%{
+ argp = ($&1_ltype)$input;
+ if (argp == NULL) {
+ _swig_gopanic("Attempt to dereference null $1_type");
+ }
+ $1 = ($1_ltype)*argp;
+%}
+
+%typemap(out) SWIGTYPE
+#ifdef __cplusplus
+%{ *($&1_ltype*)&$result = new $1_ltype($1); %}
+#else
+{
+ $&1_ltype $1ptr = ($&1_ltype)malloc(sizeof($1_ltype));
+ memmove($1ptr, &$1, sizeof($1_type));
+ *($&1_ltype*)&$result = $1ptr;
+}
+#endif
+
+%typemap(goout) SWIGTYPE ""
+
+%typemap(directorin) SWIGTYPE
+%{ $input = new $1_ltype(SWIG_STD_MOVE($1)); %}
+
+%typemap(godirectorin) SWIGTYPE ""
+
+%typemap(directorout) SWIGTYPE
+%{ $result = *($&1_ltype)$input; %}
+
+/* Exception handling */
+
+%typemap(throws) char *
+%{ _swig_gopanic($1); %}
+
+%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
+%{
+ (void)$1;
+ _swig_gopanic("C++ $1_type exception thrown");
+%}
+
+/* Typecheck typemaps. The purpose of these is merely to issue a
+ warning for overloaded C++ functions that cannot be overloaded in
+ Go as more than one C++ type maps to a single Go type. */
+
+%typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */
+ bool,
+ const bool &
+ ""
+
+%typecheck(SWIG_TYPECHECK_CHAR) /* Go byte */
+ char,
+ const char &,
+ unsigned char,
+ const unsigned char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT8) /* Go int8 */
+ signed char,
+ const signed char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT16) /* Go int16 */
+ short,
+ const short &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT16) /* Go uint16 */
+ unsigned short,
+ const unsigned short &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT32) /* Go int */
+ int,
+ const int &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT32) /* Go uint */
+ unsigned int,
+ const unsigned int &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */
+ long,
+ const long &,
+ long long,
+ const long long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */
+ unsigned long,
+ const unsigned long &,
+ unsigned long long,
+ const unsigned long long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_FLOAT) /* Go float32 */
+ float,
+ const float &
+ ""
+
+%typecheck(SWIG_TYPECHECK_DOUBLE) /* Go float64 */
+ double,
+ const double &
+ ""
+
+%typecheck(SWIG_TYPECHECK_STRING) /* Go string */
+ char *,
+ char *&,
+ char[ANY],
+ char [],
+ signed char *,
+ signed char *&,
+ signed char[ANY],
+ signed char [],
+ unsigned char *,
+ unsigned char *&,
+ unsigned char[ANY],
+ unsigned char []
+ ""
+
+%typecheck(SWIG_TYPECHECK_POINTER)
+ SWIGTYPE,
+ SWIGTYPE *,
+ SWIGTYPE &,
+ SWIGTYPE &&,
+ SWIGTYPE *const&,
+ SWIGTYPE [],
+ SWIGTYPE (CLASS::*)
+ ""
+
+%apply SWIGTYPE * { SWIGTYPE *const }
+%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
+%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
+
+/* Go keywords. */
+%include <gokw.swg>
+
+%include <goruntime.swg>
diff --git a/contrib/tools/swig/Lib/go/gokw.swg b/contrib/tools/swig/Lib/go/gokw.swg
new file mode 100644
index 0000000000..3542830024
--- /dev/null
+++ b/contrib/tools/swig/Lib/go/gokw.swg
@@ -0,0 +1,33 @@
+/* Rename keywords. */
+
+#define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword",rename="X%s") `x`
+#define GOBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in Go") "::"`x`
+
+GOKW(break);
+GOKW(case);
+GOKW(chan);
+GOKW(const);
+GOKW(continue);
+GOKW(default);
+GOKW(defer);
+GOKW(else);
+GOKW(fallthrough);
+GOKW(for);
+GOKW(func);
+GOKW(go);
+GOKW(goto);
+GOKW(if);
+GOKW(import);
+GOKW(interface);
+GOKW(package);
+GOKW(range);
+GOKW(return);
+GOKW(select);
+GOKW(struct);
+GOKW(switch);
+GOKW(type);
+GOKW(var);
+
+GOBN(map);
+
+#undef GOKW
diff --git a/contrib/tools/swig/Lib/go/goruntime.swg b/contrib/tools/swig/Lib/go/goruntime.swg
new file mode 100644
index 0000000000..7bf083bd3d
--- /dev/null
+++ b/contrib/tools/swig/Lib/go/goruntime.swg
@@ -0,0 +1,217 @@
+/* ------------------------------------------------------------
+ * goruntime.swg
+ *
+ * Go runtime code for the various generated files.
+ * ------------------------------------------------------------ */
+
+%inline %{
+static void Swig_free(void* p) {
+ free(p);
+}
+
+static void* Swig_malloc(int c) {
+ return malloc(c);
+}
+%}
+
+%insert(runtime) %{
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+%}
+
+%insert(cgo_comment_typedefs) %{
+#include <stddef.h>
+#include <stdint.h>
+%}
+
+#if SWIGGO_INTGO_SIZE == 32
+%insert(runtime) %{
+typedef int intgo;
+typedef unsigned int uintgo;
+%}
+%insert(cgo_comment_typedefs) %{
+typedef int intgo;
+typedef unsigned int uintgo;
+%}
+#elif SWIGGO_INTGO_SIZE == 64
+%insert(runtime) %{
+typedef long long intgo;
+typedef unsigned long long uintgo;
+%}
+%insert(cgo_comment_typedefs) %{
+typedef long long intgo;
+typedef unsigned long long uintgo;
+%}
+#else
+%insert(runtime) %{
+typedef ptrdiff_t intgo;
+typedef size_t uintgo;
+%}
+%insert(cgo_comment_typedefs) %{
+typedef ptrdiff_t intgo;
+typedef size_t uintgo;
+%}
+#endif
+
+#ifndef SWIGGO_GCCGO
+// Set the host compiler struct attribute that will be
+// used to match gc's struct layout. For example, on 386 Windows,
+// gcc wants to 8-align int64s, but gc does not.
+// Use __gcc_struct__ to work around http://gcc.gnu.org/PR52991 on x86,
+// and https://golang.org/issue/5603.
+// See: https://github.com/golang/go/blob/fcbf04f9b93b4cd8addd05c2ed784118eb50a46c/src/cmd/cgo/out.go#L663
+%insert(runtime) %{
+# if !defined(__clang__) && (defined(__i386__) || defined(__x86_64__))
+# define SWIGSTRUCTPACKED __attribute__((__packed__, __gcc_struct__))
+# else
+# define SWIGSTRUCTPACKED __attribute__((__packed__))
+# endif
+%}
+#else
+# define SWIGSTRUCTPACKED
+#endif
+
+%insert(runtime) %{
+
+typedef struct { char *p; intgo n; } _gostring_;
+typedef struct { void* array; intgo len; intgo cap; } _goslice_;
+
+%}
+
+%insert(cgo_comment_typedefs) %{
+
+typedef struct { char *p; intgo n; } _gostring_;
+typedef struct { void* array; intgo len; intgo cap; } _goslice_;
+
+%}
+
+#ifdef SWIGGO_GCCGO
+
+/* Boilerplate for C/C++ code when using gccgo. */
+%insert(runtime) %{
+#define SWIGGO_GCCGO
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void *_cgo_allocate(size_t);
+extern void _cgo_panic(const char *);
+#ifdef __cplusplus
+}
+#endif
+
+#define _swig_goallocate _cgo_allocate
+#define _swig_gopanic _cgo_panic
+%}
+
+#endif
+
+#ifndef SWIGGO_GCCGO
+
+%go_import("unsafe", _ "runtime/cgo")
+
+#else
+
+%go_import("syscall", "unsafe")
+
+%insert(go_header) %{
+
+type _ syscall.Sockaddr
+
+%}
+
+#endif
+
+%insert(go_header) %{
+
+type _ unsafe.Pointer
+
+%}
+
+/* Swig_always_false is used to conditionally assign parameters to
+ Swig_escape_val so that the compiler thinks that they escape. We
+ only assign them if Swig_always_false is true, which it never is.
+ We export the variable so that the compiler doesn't realize that it
+ is never set. */
+%insert(go_header) %{
+var Swig_escape_always_false bool
+var Swig_escape_val interface{}
+%}
+
+/* Function pointers are translated by the code in go.cxx into
+ _swig_fnptr. Member pointers are translated to _swig_memberptr. */
+
+%insert(go_header) %{
+type _swig_fnptr *byte
+type _swig_memberptr *byte
+%}
+
+/* Convert a Go interface value into a C++ pointer. */
+
+%insert(go_header) %{
+func getSwigcptr(v interface { Swigcptr() uintptr }) uintptr {
+ if v == nil {
+ return 0
+ }
+ return v.Swigcptr()
+}
+%}
+
+/* For directors we need C++ to track a Go pointer. Since we can't
+ pass a Go pointer into C++, we use a map to track the pointers on
+ the Go side. */
+
+%go_import("sync")
+
+%insert(go_header) %{
+type _ sync.Mutex
+%}
+
+%insert(go_director) %{
+
+var swigDirectorTrack struct {
+ sync.Mutex
+ m map[int]interface{}
+ c int
+}
+
+func swigDirectorAdd(v interface{}) int {
+ swigDirectorTrack.Lock()
+ defer swigDirectorTrack.Unlock()
+ if swigDirectorTrack.m == nil {
+ swigDirectorTrack.m = make(map[int]interface{})
+ }
+ swigDirectorTrack.c++
+ ret := swigDirectorTrack.c
+ swigDirectorTrack.m[ret] = v
+ return ret
+}
+
+func swigDirectorLookup(c int) interface{} {
+ swigDirectorTrack.Lock()
+ defer swigDirectorTrack.Unlock()
+ ret := swigDirectorTrack.m[c]
+ if ret == nil {
+ panic("C++ director pointer not found (possible use-after-free)")
+ }
+ return ret
+}
+
+func swigDirectorDelete(c int) {
+ swigDirectorTrack.Lock()
+ defer swigDirectorTrack.Unlock()
+ if swigDirectorTrack.m[c] == nil {
+ if c > swigDirectorTrack.c {
+ panic("C++ director pointer invalid (possible memory corruption")
+ } else {
+ panic("C++ director pointer not found (possible use-after-free)")
+ }
+ }
+ delete(swigDirectorTrack.m, c)
+}
+
+%}
diff --git a/contrib/tools/swig/Lib/go/gostring.swg b/contrib/tools/swig/Lib/go/gostring.swg
new file mode 100644
index 0000000000..d9c47d2858
--- /dev/null
+++ b/contrib/tools/swig/Lib/go/gostring.swg
@@ -0,0 +1,29 @@
+/* ------------------------------------------------------------
+ * gostring.swg
+ *
+ * Support for returning strings from C to Go.
+ * ------------------------------------------------------------ */
+
+// C/C++ code to convert a memory buffer into a Go string allocated in
+// C/C++ memory.
+%fragment("AllocateString", "runtime") %{
+static _gostring_ Swig_AllocateString(const char *p, size_t l) {
+ _gostring_ ret;
+ ret.p = (char*)malloc(l);
+ memcpy(ret.p, p, l);
+ ret.n = l;
+ return ret;
+}
+%}
+
+// Go code to convert a string allocated in C++ memory to one
+// allocated in Go memory.
+%fragment("CopyString", "go_runtime") %{
+type swig_gostring struct { p unsafe.Pointer; n int }
+func swigCopyString(s string) string {
+ p := *(*swig_gostring)(unsafe.Pointer(&s))
+ r := string((*[0x7fffffff]byte)(p.p)[:p.n])
+ Swig_free(uintptr(p.p))
+ return r
+}
+%}
diff --git a/contrib/tools/swig/Lib/go/typemaps.i b/contrib/tools/swig/Lib/go/typemaps.i
new file mode 100644
index 0000000000..d2e60d37c8
--- /dev/null
+++ b/contrib/tools/swig/Lib/go/typemaps.i
@@ -0,0 +1,298 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.i
+ *
+ * Pointer and reference handling typemap library
+ *
+ * These mappings provide support for input/output arguments and common
+ * uses for C/C++ pointers and C++ references.
+ * ----------------------------------------------------------------------------- */
+
+/*
+INPUT typemaps
+--------------
+
+These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is
+passed by value instead of reference.
+
+The following typemaps can be applied to turn a pointer or reference into a simple
+input value. That is, instead of passing a pointer or reference to an object,
+you would use a real value instead.
+
+ bool *INPUT, bool &INPUT
+ signed char *INPUT, signed char &INPUT
+ unsigned char *INPUT, unsigned char &INPUT
+ short *INPUT, short &INPUT
+ unsigned short *INPUT, unsigned short &INPUT
+ int *INPUT, int &INPUT
+ unsigned int *INPUT, unsigned int &INPUT
+ long *INPUT, long &INPUT
+ unsigned long *INPUT, unsigned long &INPUT
+ long long *INPUT, long long &INPUT
+ unsigned long long *INPUT, unsigned long long &INPUT
+ float *INPUT, float &INPUT
+ double *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);
+
+In Go you could then use it like this:
+ answer := modulename.Fadd(10.0, 20.0)
+
+There are no char *INPUT typemaps, however you can apply the signed
+char * typemaps instead:
+ %include <typemaps.i>
+ %apply signed char *INPUT {char *input};
+ void f(char *input);
+*/
+
+%define INPUT_TYPEMAP(TYPE, GOTYPE)
+%typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE"
+
+ %typemap(in) TYPE *INPUT, TYPE &INPUT
+%{ $1 = ($1_ltype)&$input; %}
+
+%typemap(out) TYPE *INPUT, TYPE &INPUT ""
+
+%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
+
+%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
+
+%typemap(argout) TYPE *INPUT, TYPE &INPUT ""
+
+// %typemap(typecheck) TYPE *INPUT = TYPE;
+// %typemap(typecheck) TYPE &INPUT = TYPE;
+%enddef
+
+INPUT_TYPEMAP(bool, bool);
+INPUT_TYPEMAP(signed char, int8);
+INPUT_TYPEMAP(char, byte);
+INPUT_TYPEMAP(unsigned char, byte);
+INPUT_TYPEMAP(short, int16);
+INPUT_TYPEMAP(unsigned short, uint16);
+INPUT_TYPEMAP(int, int);
+INPUT_TYPEMAP(unsigned int, uint);
+INPUT_TYPEMAP(long, int64);
+INPUT_TYPEMAP(unsigned long, uint64);
+INPUT_TYPEMAP(long long, int64);
+INPUT_TYPEMAP(unsigned long long, uint64);
+INPUT_TYPEMAP(float, float32);
+INPUT_TYPEMAP(double, float64);
+
+#undef INPUT_TYPEMAP
+
+// OUTPUT typemaps. These typemaps are used for parameters that
+// are output only. An array replaces the c pointer or reference parameter.
+// The output value is returned in this array passed in.
+
+/*
+OUTPUT typemaps
+---------------
+
+The following typemaps can be applied to turn a pointer or reference
+into an "output" value. When calling a function, no input value would
+be given for a parameter, but an output value would be returned. This
+works by a Go slice being passed as a parameter where a c pointer or
+reference is required. As with any Go function, the array is passed
+by reference so that any modifications to the array will be picked up
+in the calling function. Note that the array passed in MUST have at
+least one element, but as the c function does not require any input,
+the value can be set to anything.
+
+ bool *OUTPUT, bool &OUTPUT
+ signed char *OUTPUT, signed char &OUTPUT
+ unsigned char *OUTPUT, unsigned char &OUTPUT
+ short *OUTPUT, short &OUTPUT
+ unsigned short *OUTPUT, unsigned short &OUTPUT
+ int *OUTPUT, int &OUTPUT
+ unsigned int *OUTPUT, unsigned int &OUTPUT
+ long *OUTPUT, long &OUTPUT
+ unsigned long *OUTPUT, unsigned long &OUTPUT
+ long long *OUTPUT, long long &OUTPUT
+ unsigned long long *OUTPUT, unsigned long long &OUTPUT
+ float *OUTPUT, float &OUTPUT
+ double *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):
+
+ 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 Go output of the function would be the function return value and the
+value in the single element array. In Go you would use it like this:
+
+ ptr := []float64{0.0}
+ fraction := modulename.Modf(5.0,ptr)
+
+There are no char *OUTPUT typemaps, however you can apply the signed
+char * typemaps instead:
+ %include <typemaps.i>
+ %apply signed char *OUTPUT {char *output};
+ void f(char *output);
+*/
+
+%define OUTPUT_TYPEMAP(TYPE, GOTYPE)
+%typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%}
+
+%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp)
+{
+ if ($input.len == 0) {
+ _swig_gopanic("array must contain at least 1 element");
+ }
+ $1 = &temp;
+}
+
+%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT ""
+
+%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
+
+%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
+
+%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
+{
+ TYPE* a = (TYPE *) $input.array;
+ a[0] = temp$argnum;
+}
+
+%enddef
+
+OUTPUT_TYPEMAP(bool, bool);
+OUTPUT_TYPEMAP(signed char, int8);
+OUTPUT_TYPEMAP(char, byte);
+OUTPUT_TYPEMAP(unsigned char, byte);
+OUTPUT_TYPEMAP(short, int16);
+OUTPUT_TYPEMAP(unsigned short, uint16);
+OUTPUT_TYPEMAP(int, int);
+OUTPUT_TYPEMAP(unsigned int, uint);
+OUTPUT_TYPEMAP(long, int64);
+OUTPUT_TYPEMAP(unsigned long, uint64);
+OUTPUT_TYPEMAP(long long, int64);
+OUTPUT_TYPEMAP(unsigned long long, uint64);
+OUTPUT_TYPEMAP(float, float32);
+OUTPUT_TYPEMAP(double, float64);
+
+#undef OUTPUT_TYPEMAP
+
+/*
+INOUT typemaps
+--------------
+
+Mappings for a parameter that is both an input and an output parameter
+
+The following typemaps can be applied to make a function parameter both
+an input and output value. This combines the behavior of both the
+"INPUT" and "OUTPUT" typemaps described earlier. Output values are
+returned as an element in a Go slice.
+
+ bool *INOUT, bool &INOUT
+ signed char *INOUT, signed char &INOUT
+ unsigned char *INOUT, unsigned char &INOUT
+ short *INOUT, short &INOUT
+ unsigned short *INOUT, unsigned short &INOUT
+ int *INOUT, int &INOUT
+ unsigned int *INOUT, unsigned int &INOUT
+ long *INOUT, long &INOUT
+ unsigned long *INOUT, unsigned long &INOUT
+ long long *INOUT, long long &INOUT
+ unsigned long long *INOUT, unsigned long long &INOUT
+ float *INOUT, float &INOUT
+ double *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);
+
+This works similarly to C in that the mapping directly modifies the
+input value - the input must be an array with a minimum of one element.
+The element in the array is the input and the output is the element in
+the array.
+
+ x := []float64{5.0}
+ Neg(x);
+
+The implementation of the OUTPUT and INOUT typemaps is different to
+other languages in that other languages will return the output value
+as part of the function return value. This difference is due to Go
+being a typed language.
+
+There are no char *INOUT typemaps, however you can apply the signed
+char * typemaps instead:
+ %include <typemaps.i>
+ %apply signed char *INOUT {char *inout};
+ void f(char *inout);
+*/
+
+%define INOUT_TYPEMAP(TYPE, GOTYPE)
+%typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%}
+
+%typemap(in) TYPE *INOUT, TYPE &INOUT {
+ if ($input.len == 0) {
+ _swig_gopanic("array must contain at least 1 element");
+ }
+ $1 = ($1_ltype) $input.array;
+}
+
+%typemap(out) TYPE *INOUT, TYPE &INOUT ""
+
+%typemap(goout) TYPE *INOUT, TYPE &INOUT ""
+
+%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
+
+%typemap(argout) TYPE *INOUT, TYPE &INOUT ""
+
+%enddef
+
+INOUT_TYPEMAP(bool, bool);
+INOUT_TYPEMAP(signed char, int8);
+INOUT_TYPEMAP(char, byte);
+INOUT_TYPEMAP(unsigned char, byte);
+INOUT_TYPEMAP(short, int16);
+INOUT_TYPEMAP(unsigned short, uint16);
+INOUT_TYPEMAP(int, int);
+INOUT_TYPEMAP(unsigned int, uint);
+INOUT_TYPEMAP(long, int64);
+INOUT_TYPEMAP(unsigned long, uint64);
+INOUT_TYPEMAP(long long, int64);
+INOUT_TYPEMAP(unsigned long long, uint64);
+INOUT_TYPEMAP(float, float32);
+INOUT_TYPEMAP(double, float64);
+
+#undef INOUT_TYPEMAP
diff --git a/contrib/tools/swig/Lib/java/enumtypesafe.swg b/contrib/tools/swig/Lib/java/enumtypesafe.swg
new file mode 100644
index 0000000000..c2012f568b
--- /dev/null
+++ b/contrib/tools/swig/Lib/java/enumtypesafe.swg
@@ -0,0 +1,117 @@
+/* -----------------------------------------------------------------------------
+ * enumtypesafe.swg
+ *
+ * Include this file in order for C/C++ enums to be wrapped by the so called
+ * typesafe enum pattern. Each enum has an equivalent Java class named after the
+ * enum and each enum item is a static instance of this class.
+ * ----------------------------------------------------------------------------- */
+
+// const enum SWIGTYPE & typemaps
+%typemap(jni) const enum SWIGTYPE & "jint"
+%typemap(jtype) const enum SWIGTYPE & "int"
+%typemap(jstype) const enum SWIGTYPE & "$*javaclassname"
+
+%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
+%{ temp = ($*1_ltype)$input;
+ $1 = &temp; %}
+%typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %}
+
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
+%{ static $*1_ltype temp = ($*1_ltype)$input;
+ $result = &temp; %}
+%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1;"
+%typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)"
+%typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()"
+
+%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & ""
+
+%typemap(throws) const enum SWIGTYPE &
+%{ (void)$1;
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %}
+
+%typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()"
+%typemap(javaout) const enum SWIGTYPE & {
+ return $*javaclassname.swigToEnum($jnicall);
+ }
+
+// enum SWIGTYPE typemaps
+%typemap(jni) enum SWIGTYPE "jint"
+%typemap(jtype) enum SWIGTYPE "int"
+%typemap(jstype) enum SWIGTYPE "$javaclassname"
+
+%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
+%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %}
+
+%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
+%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;"
+%typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)"
+%typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()"
+
+%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
+
+%typemap(throws) enum SWIGTYPE
+%{ (void)$1;
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %}
+
+%typemap(javain) enum SWIGTYPE "$javainput.swigValue()"
+%typemap(javaout) enum SWIGTYPE {
+ return $javaclassname.swigToEnum($jnicall);
+ }
+
+// '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not
+%typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class"
+%typemap(javabase) enum SWIGTYPE ""
+%typemap(javacode) enum SWIGTYPE ""
+%typemap(javaimports) enum SWIGTYPE ""
+%typemap(javainterfaces) enum SWIGTYPE ""
+
+/*
+ * The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes
+ * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial
+ * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be
+ * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum.
+ * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values.
+ */
+%typemap(javabody) enum SWIGTYPE %{
+ public final int swigValue() {
+ return swigValue;
+ }
+
+ public String toString() {
+ return swigName;
+ }
+
+ public static $javaclassname swigToEnum(int swigValue) {
+ if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
+ return swigValues[swigValue];
+ for (int i = 0; i < swigValues.length; i++)
+ if (swigValues[i].swigValue == swigValue)
+ return swigValues[i];
+ throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue);
+ }
+
+ private $javaclassname(String swigName) {
+ this.swigName = swigName;
+ this.swigValue = swigNext++;
+ }
+
+ private $javaclassname(String swigName, int swigValue) {
+ this.swigName = swigName;
+ this.swigValue = swigValue;
+ swigNext = swigValue+1;
+ }
+
+ private $javaclassname(String swigName, $javaclassname swigEnum) {
+ this.swigName = swigName;
+ this.swigValue = swigEnum.swigValue;
+ swigNext = this.swigValue+1;
+ }
+
+ private static $javaclassname[] swigValues = { $enumvalues };
+ private static int swigNext = 0;
+ private final int swigValue;
+ private final String swigName;
+%}
+
+%javaenum(typesafe);
+
diff --git a/contrib/tools/swig/Lib/java/java.swg b/contrib/tools/swig/Lib/java/java.swg
new file mode 100644
index 0000000000..8719818bb8
--- /dev/null
+++ b/contrib/tools/swig/Lib/java/java.swg
@@ -0,0 +1,1458 @@
+/* -----------------------------------------------------------------------------
+ * java.swg
+ *
+ * Java typemaps
+ * ----------------------------------------------------------------------------- */
+
+%include <javahead.swg>
+
+/* The jni, jtype and jstype typemaps work together and so there should be one of each.
+ * The jni typemap contains the JNI type used in the JNI (C/C++) code.
+ * The jtype typemap contains the Java type used in the JNI intermediary class.
+ * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */
+
+/* Fragments */
+%fragment("SWIG_PackData", "header") {
+/* Pack binary data into a string */
+SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static const char hex[17] = "0123456789abcdef";
+ const unsigned char *u = (unsigned char *) ptr;
+ const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ unsigned char uu = *u;
+ *(c++) = hex[(uu & 0xf0) >> 4];
+ *(c++) = hex[uu & 0xf];
+ }
+ return c;
+}
+}
+
+%fragment("SWIG_UnPackData", "header") {
+/* Unpack binary data from a string */
+SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+ unsigned char *u = (unsigned char *) ptr;
+ const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ char d = *(c++);
+ 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;
+}
+}
+
+%fragment("SWIG_JavaIntFromSize_t", "header") {
+/* Check for overflow converting to Java int (always signed 32-bit) from (unsigned variable-bit) size_t */
+SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) {
+ static const jint JINT_MAX = 0x7FFFFFFF;
+ return (size > (size_t)JINT_MAX) ? -1 : (jint)size;
+}
+}
+
+/* Primitive types */
+%typemap(jni) bool, const bool & "jboolean"
+%typemap(jni) char, const char & "jchar"
+%typemap(jni) signed char, const signed char & "jbyte"
+%typemap(jni) unsigned char, const unsigned char & "jshort"
+%typemap(jni) short, const short & "jshort"
+%typemap(jni) unsigned short, const unsigned short & "jint"
+%typemap(jni) int, const int & "jint"
+%typemap(jni) unsigned int, const unsigned int & "jlong"
+%typemap(jni) long, const long & "jint"
+%typemap(jni) unsigned long, const unsigned long & "jlong"
+%typemap(jni) long long, const long long & "jlong"
+%typemap(jni) unsigned long long, const unsigned long long & "jobject"
+%typemap(jni) float, const float & "jfloat"
+%typemap(jni) double, const double & "jdouble"
+%typemap(jni) void "void"
+
+%typemap(jtype) bool, const bool & "boolean"
+%typemap(jtype) char, const char & "char"
+%typemap(jtype) signed char, const signed char & "byte"
+%typemap(jtype) unsigned char, const unsigned char & "short"
+%typemap(jtype) short, const short & "short"
+%typemap(jtype) unsigned short, const unsigned short & "int"
+%typemap(jtype) int, const int & "int"
+%typemap(jtype) unsigned int, const unsigned int & "long"
+%typemap(jtype) long, const long & "int"
+%typemap(jtype) unsigned long, const unsigned long & "long"
+%typemap(jtype) long long, const long long & "long"
+%typemap(jtype) unsigned long long, const unsigned long long & "java.math.BigInteger"
+%typemap(jtype) float, const float & "float"
+%typemap(jtype) double, const double & "double"
+%typemap(jtype) void "void"
+
+%typemap(jstype) bool, const bool & "boolean"
+%typemap(jstype) char, const char & "char"
+%typemap(jstype) signed char, const signed char & "byte"
+%typemap(jstype) unsigned char, const unsigned char & "short"
+%typemap(jstype) short, const short & "short"
+%typemap(jstype) unsigned short, const unsigned short & "int"
+%typemap(jstype) int, const int & "int"
+%typemap(jstype) unsigned int, const unsigned int & "long"
+%typemap(jstype) long, const long & "int"
+%typemap(jstype) unsigned long, const unsigned long & "long"
+%typemap(jstype) long long, const long long & "long"
+%typemap(jstype) unsigned long long, const unsigned long long & "java.math.BigInteger"
+%typemap(jstype) float, const float & "float"
+%typemap(jstype) double, const double & "double"
+%typemap(jstype) void "void"
+
+%typemap(jboxtype) bool, const bool & "Boolean"
+%typemap(jboxtype) char, const char & "Character"
+%typemap(jboxtype) signed char, const signed char & "Byte"
+%typemap(jboxtype) unsigned char, const unsigned char & "Short"
+%typemap(jboxtype) short, const short & "Short"
+%typemap(jboxtype) unsigned short, const unsigned short & "Integer"
+%typemap(jboxtype) int, const int & "Integer"
+%typemap(jboxtype) unsigned int, const unsigned int & "Long"
+%typemap(jboxtype) long, const long & "Integer"
+%typemap(jboxtype) unsigned long, const unsigned long & "Long"
+%typemap(jboxtype) long long, const long long & "Long"
+%typemap(jboxtype) unsigned long long, const unsigned long long & "java.math.BigInteger"
+%typemap(jboxtype) float, const float & "Float"
+%typemap(jboxtype) double, const double & "Double"
+
+%typemap(jni) char *, char *&, char[ANY], char[] "jstring"
+%typemap(jtype) char *, char *&, char[ANY], char[] "String"
+%typemap(jstype) char *, char *&, char[ANY], char[] "String"
+
+/* JNI types */
+%typemap(jni) jboolean "jboolean"
+%typemap(jni) jchar "jchar"
+%typemap(jni) jbyte "jbyte"
+%typemap(jni) jshort "jshort"
+%typemap(jni) jint "jint"
+%typemap(jni) jlong "jlong"
+%typemap(jni) jfloat "jfloat"
+%typemap(jni) jdouble "jdouble"
+%typemap(jni) jstring "jstring"
+%typemap(jni) jobject "jobject"
+%typemap(jni) jbooleanArray "jbooleanArray"
+%typemap(jni) jcharArray "jcharArray"
+%typemap(jni) jbyteArray "jbyteArray"
+%typemap(jni) jshortArray "jshortArray"
+%typemap(jni) jintArray "jintArray"
+%typemap(jni) jlongArray "jlongArray"
+%typemap(jni) jfloatArray "jfloatArray"
+%typemap(jni) jdoubleArray "jdoubleArray"
+%typemap(jni) jobjectArray "jobjectArray"
+
+%typemap(jtype) jboolean "boolean"
+%typemap(jtype) jchar "char"
+%typemap(jtype) jbyte "byte"
+%typemap(jtype) jshort "short"
+%typemap(jtype) jint "int"
+%typemap(jtype) jlong "long"
+%typemap(jtype) jfloat "float"
+%typemap(jtype) jdouble "double"
+%typemap(jtype) jstring "String"
+%typemap(jtype) jobject "java.lang.Object"
+%typemap(jtype) jbooleanArray "boolean[]"
+%typemap(jtype) jcharArray "char[]"
+%typemap(jtype) jbyteArray "byte[]"
+%typemap(jtype) jshortArray "short[]"
+%typemap(jtype) jintArray "int[]"
+%typemap(jtype) jlongArray "long[]"
+%typemap(jtype) jfloatArray "float[]"
+%typemap(jtype) jdoubleArray "double[]"
+%typemap(jtype) jobjectArray "java.lang.Object[]"
+
+%typemap(jstype) jboolean "boolean"
+%typemap(jstype) jchar "char"
+%typemap(jstype) jbyte "byte"
+%typemap(jstype) jshort "short"
+%typemap(jstype) jint "int"
+%typemap(jstype) jlong "long"
+%typemap(jstype) jfloat "float"
+%typemap(jstype) jdouble "double"
+%typemap(jstype) jstring "String"
+%typemap(jstype) jobject "java.lang.Object"
+%typemap(jstype) jbooleanArray "boolean[]"
+%typemap(jstype) jcharArray "char[]"
+%typemap(jstype) jbyteArray "byte[]"
+%typemap(jstype) jshortArray "short[]"
+%typemap(jstype) jintArray "int[]"
+%typemap(jstype) jlongArray "long[]"
+%typemap(jstype) jfloatArray "float[]"
+%typemap(jstype) jdoubleArray "double[]"
+%typemap(jstype) jobjectArray "java.lang.Object[]"
+
+/* Non primitive types */
+%typemap(jni) SWIGTYPE "jlong"
+%typemap(jtype) SWIGTYPE "long"
+%typemap(jstype) SWIGTYPE "$&javaclassname"
+%typemap(jboxtype) SWIGTYPE "$typemap(jstype, $1_type)"
+
+%typemap(jni) SWIGTYPE [] "jlong"
+%typemap(jtype) SWIGTYPE [] "long"
+%typemap(jstype) SWIGTYPE [] "$javaclassname"
+
+%typemap(jni) SWIGTYPE * "jlong"
+%typemap(jtype) SWIGTYPE * "long"
+%typemap(jstype) SWIGTYPE * "$javaclassname"
+
+%typemap(jni) SWIGTYPE & "jlong"
+%typemap(jtype) SWIGTYPE & "long"
+%typemap(jstype) SWIGTYPE & "$javaclassname"
+
+%typemap(jni) SWIGTYPE && "jlong"
+%typemap(jtype) SWIGTYPE && "long"
+%typemap(jstype) SWIGTYPE && "$javaclassname"
+
+/* pointer to a class member */
+%typemap(jni) SWIGTYPE (CLASS::*) "jstring"
+%typemap(jtype) SWIGTYPE (CLASS::*) "String"
+%typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname"
+
+/* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */
+
+/* primitive types */
+%typemap(in) bool
+%{ $1 = $input ? true : false; %}
+
+%typemap(directorout) bool
+%{ $result = $input ? true : false; %}
+
+%typemap(javadirectorin) bool "$jniinput"
+%typemap(javadirectorout) bool "$javacall"
+
+%typemap(in) char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ float,
+ double
+%{ $1 = ($1_ltype)$input; %}
+
+%typemap(directorout) char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ float,
+ double
+%{ $result = ($1_ltype)$input; %}
+
+%typemap(directorin, descriptor="Z") bool "$input = (jboolean) $1;"
+%typemap(directorin, descriptor="C") char "$input = (jint) $1;"
+%typemap(directorin, descriptor="B") signed char "$input = (jbyte) $1;"
+%typemap(directorin, descriptor="S") unsigned char "$input = (jshort) $1;"
+%typemap(directorin, descriptor="S") short "$input = (jshort) $1;"
+%typemap(directorin, descriptor="I") unsigned short "$input = (jint) $1;"
+%typemap(directorin, descriptor="I") int "$input = (jint) $1;"
+%typemap(directorin, descriptor="J") unsigned int "$input = (jlong) $1;"
+%typemap(directorin, descriptor="I") long "$input = (jint) $1;"
+%typemap(directorin, descriptor="J") unsigned long "$input = (jlong) $1;"
+%typemap(directorin, descriptor="J") long long "$input = (jlong) $1;"
+%typemap(directorin, descriptor="F") float "$input = (jfloat) $1;"
+%typemap(directorin, descriptor="D") double "$input = (jdouble) $1;"
+
+%typemap(javadirectorin) char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ float,
+ double
+ "$jniinput"
+
+%typemap(javadirectorout) char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ float,
+ double
+ "$javacall"
+
+%typemap(out) bool %{ $result = (jboolean)$1; %}
+%typemap(out) char %{ $result = (jchar)$1; %}
+%typemap(out) signed char %{ $result = (jbyte)$1; %}
+%typemap(out) unsigned char %{ $result = (jshort)$1; %}
+%typemap(out) short %{ $result = (jshort)$1; %}
+%typemap(out) unsigned short %{ $result = (jint)$1; %}
+%typemap(out) int %{ $result = (jint)$1; %}
+%typemap(out) unsigned int %{ $result = (jlong)$1; %}
+%typemap(out) long %{ $result = (jint)$1; %}
+%typemap(out) unsigned long %{ $result = (jlong)$1; %}
+%typemap(out) long long %{ $result = (jlong)$1; %}
+%typemap(out) float %{ $result = (jfloat)$1; %}
+%typemap(out) double %{ $result = (jdouble)$1; %}
+
+/* unsigned long long */
+/* Convert from BigInteger using the toByteArray member function */
+%typemap(in) unsigned long long {
+ jclass clazz;
+ jmethodID mid;
+ jbyteArray ba;
+ jbyte* bae;
+ jsize sz;
+ int i;
+
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
+ return $null;
+ }
+ clazz = JCALL1(GetObjectClass, jenv, $input);
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ sz = JCALL1(GetArrayLength, jenv, ba);
+ $1 = 0;
+ if (sz > 0) {
+ $1 = ($1_type)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ $1 = ($1 << 8) | ($1_type)(unsigned char)bae[i];
+ }
+ }
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+}
+
+%typemap(directorout) unsigned long long {
+ jclass clazz;
+ jmethodID mid;
+ jbyteArray ba;
+ jbyte* bae;
+ jsize sz;
+ int i;
+
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
+ return $null;
+ }
+ clazz = JCALL1(GetObjectClass, jenv, $input);
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ sz = JCALL1(GetArrayLength, jenv, ba);
+ $result = 0;
+ if (sz > 0) {
+ $result = ($1_type)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ $result = ($result << 8) | ($1_type)(unsigned char)bae[i];
+ }
+ }
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+}
+
+
+/* Convert to BigInteger - byte array holds number in 2's complement big endian format */
+%typemap(out) unsigned long long {
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
+ jobject bigint;
+ int i;
+
+ bae[0] = 0;
+ for(i=1; i<9; i++ ) {
+ bae[i] = (jbyte)($1>>8*(8-i));
+ }
+
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
+ JCALL1(DeleteLocalRef, jenv, ba);
+ $result = bigint;
+}
+
+/* Convert to BigInteger (see out typemap) */
+%typemap(directorin, descriptor="Ljava/math/BigInteger;", noblock=1) unsigned long long, const unsigned long long & {
+{
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
+ jobject bigint;
+ int swig_i;
+
+ bae[0] = 0;
+ for(swig_i=1; swig_i<9; swig_i++ ) {
+ bae[swig_i] = (jbyte)($1>>8*(8-swig_i));
+ }
+
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
+ JCALL1(DeleteLocalRef, jenv, ba);
+ $input = bigint;
+}
+Swig::LocalRefGuard $1_refguard(jenv, $input); }
+
+%typemap(javadirectorin) unsigned long long "$jniinput"
+%typemap(javadirectorout) unsigned long long "$javacall"
+
+/* char * - treat as String */
+%typemap(in, noblock=1) char * {
+ $1 = 0;
+ if ($input) {
+ $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
+ if (!$1) return $null;
+ }
+}
+
+%typemap(directorout, noblock=1, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * {
+ $1 = 0;
+ if ($input) {
+ $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
+ if (!$result) return $null;
+ }
+}
+
+%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * {
+ $input = 0;
+ if ($1) {
+ $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
+ if (!$input) return $null;
+ }
+ Swig::LocalRefGuard $1_refguard(jenv, $input);
+}
+
+%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
+%typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
+%typemap(javadirectorin) char * "$jniinput"
+%typemap(javadirectorout) char * "$javacall"
+
+/* char *& - treat as String */
+%typemap(in, noblock=1) char *& ($*1_ltype temp = 0) {
+ $1 = 0;
+ if ($input) {
+ temp = ($*1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
+ if (!temp) return $null;
+ }
+ $1 = &temp;
+}
+%typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); }
+%typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); }
+
+%typemap(out) void ""
+%typemap(javadirectorin) void "$jniinput"
+%typemap(javadirectorout) void "$javacall"
+%typemap(directorin, descriptor="V") void ""
+
+/* primitive types by reference */
+%typemap(in) const bool & ($*1_ltype temp)
+%{ temp = $input ? true : false;
+ $1 = &temp; %}
+
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool &
+%{ static $*1_ltype temp;
+ temp = $input ? true : false;
+ $result = &temp; %}
+
+%typemap(javadirectorin) const bool & "$jniinput"
+%typemap(javadirectorout) const bool & "$javacall"
+
+%typemap(in) const char & ($*1_ltype temp),
+ const signed char & ($*1_ltype temp),
+ const unsigned char & ($*1_ltype temp),
+ const short & ($*1_ltype temp),
+ const unsigned short & ($*1_ltype temp),
+ const int & ($*1_ltype temp),
+ const unsigned int & ($*1_ltype temp),
+ const long & ($*1_ltype temp),
+ const unsigned long & ($*1_ltype temp),
+ const long long & ($*1_ltype temp),
+ const float & ($*1_ltype temp),
+ const double & ($*1_ltype temp)
+%{ temp = ($*1_ltype)$input;
+ $1 = &temp; %}
+
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const float &,
+ const double &
+%{ static $*1_ltype temp;
+ temp = ($*1_ltype)$input;
+ $result = &temp; %}
+
+%typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1;"
+%typemap(directorin, descriptor="C") const char & "$input = (jchar)$1;"
+%typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1;"
+%typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1;"
+%typemap(directorin, descriptor="S") const short & "$input = (jshort)$1;"
+%typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1;"
+%typemap(directorin, descriptor="I") const int & "$input = (jint)$1;"
+%typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1;"
+%typemap(directorin, descriptor="I") const long & "$input = (jint)$1;"
+%typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1;"
+%typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1;"
+%typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1;"
+%typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1;"
+
+%typemap(javadirectorin) const char & ($*1_ltype temp),
+ const signed char & ($*1_ltype temp),
+ const unsigned char & ($*1_ltype temp),
+ const short & ($*1_ltype temp),
+ const unsigned short & ($*1_ltype temp),
+ const int & ($*1_ltype temp),
+ const unsigned int & ($*1_ltype temp),
+ const long & ($*1_ltype temp),
+ const unsigned long & ($*1_ltype temp),
+ const long long & ($*1_ltype temp),
+ const float & ($*1_ltype temp),
+ const double & ($*1_ltype temp)
+ "$jniinput"
+
+%typemap(javadirectorout) const char & ($*1_ltype temp),
+ const signed char & ($*1_ltype temp),
+ const unsigned char & ($*1_ltype temp),
+ const short & ($*1_ltype temp),
+ const unsigned short & ($*1_ltype temp),
+ const int & ($*1_ltype temp),
+ const unsigned int & ($*1_ltype temp),
+ const long & ($*1_ltype temp),
+ const unsigned long & ($*1_ltype temp),
+ const long long & ($*1_ltype temp),
+ const float & ($*1_ltype temp),
+ const double & ($*1_ltype temp)
+ "$javacall"
+
+
+%typemap(out) const bool & %{ $result = (jboolean)*$1; %}
+%typemap(out) const char & %{ $result = (jchar)*$1; %}
+%typemap(out) const signed char & %{ $result = (jbyte)*$1; %}
+%typemap(out) const unsigned char & %{ $result = (jshort)*$1; %}
+%typemap(out) const short & %{ $result = (jshort)*$1; %}
+%typemap(out) const unsigned short & %{ $result = (jint)*$1; %}
+%typemap(out) const int & %{ $result = (jint)*$1; %}
+%typemap(out) const unsigned int & %{ $result = (jlong)*$1; %}
+%typemap(out) const long & %{ $result = (jint)*$1; %}
+%typemap(out) const unsigned long & %{ $result = (jlong)*$1; %}
+%typemap(out) const long long & %{ $result = (jlong)*$1; %}
+%typemap(out) const float & %{ $result = (jfloat)*$1; %}
+%typemap(out) const double & %{ $result = (jdouble)*$1; %}
+
+/* const unsigned long long & */
+/* Similar to unsigned long long */
+%typemap(in) const unsigned long long & ($*1_ltype temp) {
+ jclass clazz;
+ jmethodID mid;
+ jbyteArray ba;
+ jbyte* bae;
+ jsize sz;
+ int i;
+
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
+ return $null;
+ }
+ clazz = JCALL1(GetObjectClass, jenv, $input);
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ sz = JCALL1(GetArrayLength, jenv, ba);
+ $1 = &temp;
+ temp = 0;
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
+ }
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+}
+
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const unsigned long long & {
+ static $*1_ltype temp;
+ jclass clazz;
+ jmethodID mid;
+ jbyteArray ba;
+ jbyte* bae;
+ jsize sz;
+ int i;
+
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
+ return $null;
+ }
+ clazz = JCALL1(GetObjectClass, jenv, $input);
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ sz = JCALL1(GetArrayLength, jenv, ba);
+ $result = &temp;
+ temp = 0;
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
+ }
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+}
+
+%typemap(out) const unsigned long long & {
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
+ jobject bigint;
+ int i;
+
+ bae[0] = 0;
+ for(i=1; i<9; i++ ) {
+ bae[i] = (jbyte)(*$1>>8*(8-i));
+ }
+
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
+ JCALL1(DeleteLocalRef, jenv, ba);
+ $result = bigint;
+}
+
+%typemap(javadirectorin) const unsigned long long & "$jniinput"
+%typemap(javadirectorout) const unsigned long long & "$javacall"
+
+/* Default handling. Object passed by value. Convert to a pointer */
+%typemap(in) SWIGTYPE ($&1_type argp)
+%{ argp = *($&1_ltype*)&$input;
+ if (!argp) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
+ return $null;
+ }
+ $1 = *argp; %}
+
+%typemap(directorout) SWIGTYPE ($&1_type argp)
+%{ argp = *($&1_ltype*)&$input;
+ if (!argp) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
+ return $null;
+ }
+ $result = *argp; %}
+
+%typemap(out) SWIGTYPE
+#ifdef __cplusplus
+%{ *($&1_ltype*)&$result = new $1_ltype($1); %}
+#else
+{
+ $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
+ memmove($1ptr, &$1, sizeof($1_type));
+ *($&1_ltype*)&$result = $1ptr;
+}
+#endif
+
+%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE
+%{ $input = 0;
+ *(($&1_ltype*)&$input) = new $1_ltype(SWIG_STD_MOVE($1)); %}
+%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, true)"
+%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
+
+/* Generic pointers and references */
+%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}
+%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) {
+ const char *temp = 0;
+ if ($input) {
+ temp = JCALL2(GetStringUTFChars, jenv, $input, 0);
+ if (!temp) return $null;
+ }
+ SWIG_UnpackData(temp, (void *)&$1, sizeof($1));
+}
+%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
+ if (!$1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type is null");
+ return $null;
+ } %}
+%typemap(in, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = *($&1_ltype)&$input;
+ if (!$1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type is null");
+ return $null;
+ }
+ rvrdeleter.reset($1); %}
+%typemap(out) SWIGTYPE *
+%{ *($&1_ltype)&$result = $1; %}
+%typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
+ char buf[128];
+ char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
+ *data = '\0';
+ $result = JCALL1(NewStringUTF, jenv, buf);
+}
+%typemap(out) SWIGTYPE &
+%{ *($&1_ltype)&$result = $1; %}
+%typemap(out) SWIGTYPE &&
+%{ *($&1_ltype)&$result = $1; %}
+
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
+%{ $result = *($&1_ltype)&$input; %}
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
+%{ $result = *($&1_ltype)&$input; %}
+
+%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *
+%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
+%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*)
+%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
+
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
+%{ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
+ return $null;
+ }
+ $result = *($&1_ltype)&$input; %}
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
+%{ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
+ return $null;
+ }
+ $result = *($&1_ltype)&$input; %}
+%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &
+%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
+%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &&
+%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
+
+%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)"
+%typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)"
+%typemap(javadirectorin) SWIGTYPE && "new $javaclassname($jniinput, false)"
+%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$javaclassname.getCPtr($javacall)"
+
+/* Default array handling */
+%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
+%typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %}
+%typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] ""
+
+/* char arrays - treat as String */
+%typemap(in, noblock=1) char[ANY], char[] {
+ $1 = 0;
+ if ($input) {
+ $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
+ if (!$1) return $null;
+ }
+}
+
+%typemap(directorout, noblock=1) char[ANY], char[] {
+ $1 = 0;
+ if ($input) {
+ $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
+ if (!$result) return $null;
+ }
+}
+
+%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] {
+ $input = 0;
+ if ($1) {
+ $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
+ if (!$input) return $null;
+ }
+ Swig::LocalRefGuard $1_refguard(jenv, $input);
+}
+
+%typemap(argout) char[ANY], char[] ""
+%typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
+%typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
+%typemap(javadirectorin) char[ANY], char[] "$jniinput"
+%typemap(javadirectorout) char[ANY], char[] "$javacall"
+
+/* JNI types */
+%typemap(in) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray
+%{ $1 = $input; %}
+
+%typemap(directorout) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray
+%{ $result = $input; %}
+
+%typemap(out) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray
+%{ $result = $1; %}
+
+%typemap(directorin,descriptor="Z") jboolean "$input = $1;"
+%typemap(directorin,descriptor="C") jchar "$input = $1;"
+%typemap(directorin,descriptor="B") jbyte "$input = $1;"
+%typemap(directorin,descriptor="S") jshort "$input = $1;"
+%typemap(directorin,descriptor="I") jint "$input = $1;"
+%typemap(directorin,descriptor="J") jlong "$input = $1;"
+%typemap(directorin,descriptor="F") jfloat "$input = $1;"
+%typemap(directorin,descriptor="D") jdouble "$input = $1;"
+%typemap(directorin,descriptor="Ljava/lang/String;") jstring "$input = $1;"
+%typemap(directorin,descriptor="Ljava/lang/Object;",nouse="1") jobject "$input = $1;"
+%typemap(directorin,descriptor="[Z") jbooleanArray "$input = $1;"
+%typemap(directorin,descriptor="[C") jcharArray "$input = $1;"
+%typemap(directorin,descriptor="[B") jbyteArray "$input = $1;"
+%typemap(directorin,descriptor="[S") jshortArray "$input = $1;"
+%typemap(directorin,descriptor="[I") jintArray "$input = $1;"
+%typemap(directorin,descriptor="[J") jlongArray "$input = $1;"
+%typemap(directorin,descriptor="[F") jfloatArray "$input = $1;"
+%typemap(directorin,descriptor="[D") jdoubleArray "$input = $1;"
+%typemap(directorin,descriptor="[Ljava/lang/Object;",nouse="1") jobjectArray "$input = $1;"
+
+%typemap(javadirectorin) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray
+ "$jniinput"
+
+%typemap(javadirectorout) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray
+ "$javacall"
+
+/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions
+ * that cannot be overloaded in Java as more than one C++ type maps to a single Java type */
+
+%typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */
+ jboolean,
+ bool,
+ const bool &
+ ""
+
+%typecheck(SWIG_TYPECHECK_CHAR) /* Java char */
+ jchar,
+ char,
+ const char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT8) /* Java byte */
+ jbyte,
+ signed char,
+ const signed char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT16) /* Java short */
+ jshort,
+ unsigned char,
+ short,
+ const unsigned char &,
+ const short &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT32) /* Java int */
+ jint,
+ unsigned short,
+ int,
+ long,
+ const unsigned short &,
+ const int &,
+ const long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT64) /* Java long */
+ jlong,
+ unsigned int,
+ unsigned long,
+ long long,
+ const unsigned int &,
+ const unsigned long &,
+ const long long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */
+ unsigned long long,
+ const unsigned long long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */
+ jfloat,
+ float,
+ const float &
+ ""
+
+%typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */
+ jdouble,
+ double,
+ const double &
+ ""
+
+%typecheck(SWIG_TYPECHECK_STRING) /* Java String */
+ jstring,
+ char *,
+ char *&,
+ char[ANY],
+ char []
+ ""
+
+%typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */
+ jbooleanArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_CHAR_ARRAY) /* Java char[] */
+ jcharArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */
+ jbyteArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */
+ jshortArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */
+ jintArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */
+ jlongArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */
+ jfloatArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */
+ jdoubleArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) /* Java jobject[] */
+ jobjectArray
+ ""
+
+%typecheck(SWIG_TYPECHECK_POINTER) /* Default */
+ SWIGTYPE,
+ SWIGTYPE *,
+ SWIGTYPE &,
+ SWIGTYPE &&,
+ SWIGTYPE *const&,
+ SWIGTYPE [],
+ SWIGTYPE (CLASS::*)
+ ""
+
+
+/* Exception handling */
+
+%typemap(throws) int,
+ long,
+ short,
+ unsigned int,
+ unsigned long,
+ unsigned short
+%{ char error_msg[256];
+ sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg);
+ return $null; %}
+
+%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
+%{ (void)$1;
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
+ return $null; %}
+
+%typemap(throws) char *
+%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1);
+ return $null; %}
+
+/* For methods to raise/throw the original Java exception thrown in a director method */
+%typemap(throws) Swig::DirectorException
+%{ $1.throwException(jenv);
+ return $null; %}
+
+/* Java to C++ DirectorException should already be handled. Suppress warning and do nothing in the
+ event a user specifies a global: %catches(Swig::DirectorException); */
+%typemap(directorthrows) Swig::DirectorException ""
+
+/* Typemaps for code generation in proxy classes and Java type wrapper classes */
+
+/* The javain typemap is used for converting function parameter types from the type
+ * used in the proxy, module or type wrapper class to the type used in the JNI class. */
+%typemap(javain) bool, const bool &,
+ char, const char &,
+ signed char, const signed char &,
+ unsigned char, const unsigned char &,
+ short, const short &,
+ unsigned short, const unsigned short &,
+ int, const int &,
+ unsigned int, const unsigned int &,
+ long, const long &,
+ unsigned long, const unsigned long &,
+ long long, const long long &,
+ unsigned long long, const unsigned long long &,
+ float, const float &,
+ double, const double &
+ "$javainput"
+%typemap(javain) char *, char *&, char[ANY], char[] "$javainput"
+%typemap(javain) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray
+ "$javainput"
+%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
+%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
+%typemap(javain) SWIGTYPE && "$javaclassname.swigRelease($javainput)"
+%typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
+
+/* The javaout typemap is used for converting function return types from the return type
+ * used in the JNI class to the type returned by the proxy, module or type wrapper class. */
+%typemap(javaout) bool, const bool &,
+ char, const char &,
+ signed char, const signed char &,
+ unsigned char, const unsigned char &,
+ short, const short &,
+ unsigned short, const unsigned short &,
+ int, const int &,
+ unsigned int, const unsigned int &,
+ long, const long &,
+ unsigned long, const unsigned long &,
+ long long, const long long &,
+ unsigned long long, const unsigned long long &,
+ float, const float &,
+ double, const double & {
+ return $jnicall;
+ }
+%typemap(javaout) char *, char *&, char[ANY], char[] {
+ return $jnicall;
+ }
+%typemap(javaout) jboolean,
+ jchar,
+ jbyte,
+ jshort,
+ jint,
+ jlong,
+ jfloat,
+ jdouble,
+ jstring,
+ jobject,
+ jbooleanArray,
+ jcharArray,
+ jbyteArray,
+ jshortArray,
+ jintArray,
+ jlongArray,
+ jfloatArray,
+ jdoubleArray,
+ jobjectArray {
+ return $jnicall;
+ }
+%typemap(javaout) void {
+ $jnicall;
+ }
+%typemap(javaout) SWIGTYPE {
+ return new $&javaclassname($jnicall, true);
+ }
+%typemap(javaout) SWIGTYPE & {
+ return new $javaclassname($jnicall, $owner);
+ }
+%typemap(javaout) SWIGTYPE && {
+ return new $javaclassname($jnicall, $owner);
+ }
+%typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
+ }
+%typemap(javaout) SWIGTYPE (CLASS::*) {
+ String cMemberPtr = $jnicall;
+ return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner);
+ }
+
+/* Pointer reference typemaps */
+%typemap(jni) SWIGTYPE *const& "jlong"
+%typemap(jtype) SWIGTYPE *const& "long"
+%typemap(jstype) SWIGTYPE *const& "$*javaclassname"
+%typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)"
+%typemap(javaout) SWIGTYPE *const& {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner);
+ }
+%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
+%{ temp = *($1_ltype)&$input;
+ $1 = ($1_ltype)&temp; %}
+%typemap(out) SWIGTYPE *const&
+%{ *($1_ltype)&$result = *$1; %}
+%typemap(directorin,descriptor="L$packagepath/$*javaclassname;") SWIGTYPE *const&
+%{ *(($1_ltype)&$input) = ($*1_ltype) $1; %}
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) SWIGTYPE *const&
+%{ static $*1_ltype swig_temp;
+ swig_temp = *($1_ltype)&$input;
+ $result = &swig_temp; %}
+%typemap(javadirectorin) SWIGTYPE *const& "($jniinput == 0) ? null : new $*javaclassname($jniinput, false)"
+%typemap(javadirectorout) SWIGTYPE *const& "$*javaclassname.getCPtr($javacall)"
+
+/* Typemaps used for the generation of proxy and type wrapper class code */
+%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
+%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javainterfacemodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
+
+/* javabody typemaps */
+
+%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE) %enddef // legacy name
+
+%define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
+// Base proxy classes
+%typemap(javabody) TYPE %{
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
+
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+
+ CPTR_VISIBILITY static long swigRelease($javaclassname obj) {
+ long ptr = 0;
+ if (obj != null) {
+ if (!obj.swigCMemOwn)
+ throw new RuntimeException("Cannot release ownership as memory is not owned");
+ ptr = obj.swigCPtr;
+ obj.swigCMemOwn = false;
+ obj.delete();
+ }
+ return ptr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(javabody_derived) TYPE %{
+ private transient long swigCPtr;
+
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
+ super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn);
+ swigCPtr = cPtr;
+ }
+
+ CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+
+ CPTR_VISIBILITY static long swigRelease($javaclassname obj) {
+ long ptr = 0;
+ if (obj != null) {
+ if (!obj.swigCMemOwn)
+ throw new RuntimeException("Cannot release ownership as memory is not owned");
+ ptr = obj.swigCPtr;
+ obj.swigCMemOwn = false;
+ obj.delete();
+ }
+ return ptr;
+ }
+%}
+%enddef
+
+%define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
+// Typewrapper classes
+%typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
+ private transient long swigCPtr;
+
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
+ swigCPtr = cPtr;
+ }
+
+ DEFAULTCTOR_VISIBILITY $javaclassname() {
+ swigCPtr = 0;
+ }
+
+ CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+
+ CPTR_VISIBILITY static long swigRelease($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+%typemap(javabody) TYPE (CLASS::*) %{
+ private transient String swigCMemberPtr;
+
+ PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, @SuppressWarnings("unused") boolean futureUse) {
+ swigCMemberPtr = cMemberPtr;
+ }
+
+ DEFAULTCTOR_VISIBILITY $javaclassname() {
+ swigCMemberPtr = null;
+ }
+
+ CPTR_VISIBILITY static String getCMemberPtr($javaclassname obj) {
+ return obj.swigCMemberPtr;
+ }
+%}
+%enddef
+
+/* Set the default javabody typemaps to use protected visibility.
+ Use the macros to change to public if using multiple modules. */
+SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE)
+SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE)
+
+%typemap(javafinalize) SWIGTYPE %{
+ @SuppressWarnings("deprecation")
+ protected void finalize() {
+ delete();
+ }
+%}
+
+/*
+ * Java constructor typemaps:
+ *
+ * The javaconstruct typemap is inserted when a proxy class's constructor is generated.
+ * This typemap allows control over what code is executed in the constructor as
+ * well as specifying who owns the underlying C/C++ object. Normally, Java has
+ * ownership and the underlying C/C++ object is deallocated when the Java object
+ * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is
+ * ultimately responsible for deallocating the underlying object's memory.
+ *
+ * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy
+ * class for a particular TYPENAME. OWNERSHIP is passed as the value of
+ * swigCMemOwn to the pointer constructor method. WEAKREF determines which kind
+ * of Java object reference will be used by the C++ director class (WeakGlobalRef
+ * vs. GlobalRef.)
+ *
+ * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy
+ * classes and the weak reference flag to false, meaning that the underlying C++
+ * object will be reclaimed by C++.
+ */
+
+%define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...)
+%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, OWNERSHIP, WEAKREF);") TYPENAME {
+ this($imcall, OWNERSHIP);$directorconnect
+ }
+%enddef
+
+%define SWIG_DIRECTOR_OWNED(TYPENAME...)
+SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME)
+%enddef
+
+// Set the default for SWIGTYPE: Java owns the C/C++ object.
+SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
+
+%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE {
+ if (swigCPtr != 0) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
+ }
+ }
+
+%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE {
+ if (swigCPtr != 0) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
+ }
+ super.delete();
+ }
+
+%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{
+ protected void $methodname() {
+ swigCMemOwn = false;
+ $jnicall;
+ }
+%}
+
+%typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{
+ public void $methodname() {
+ swigCMemOwn = false;
+ $jnicall;
+ }
+%}
+
+%typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{
+ public void $methodname() {
+ swigCMemOwn = true;
+ $jnicall;
+ }
+%}
+
+/* Java specific directives */
+#define %javaconst(flag) %feature("java:const","flag")
+#define %javaconstvalue(value) %feature("java:constvalue",value)
+#define %javaenum(wrapapproach) %feature("java:enum","wrapapproach")
+#define %javamethodmodifiers %feature("java:methodmodifiers")
+#define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses)
+#define %nojavaexception %feature("except","0",throws="")
+#define %clearjavaexception %feature("except","",throws="")
+#define %proxycode %insert("proxycode")
+
+%pragma(java) jniclassclassmodifiers="public class"
+%pragma(java) moduleclassmodifiers="public class"
+
+/* Some ANSI C typemaps */
+
+%apply unsigned long { size_t };
+%apply const unsigned long & { const size_t & };
+
+/* Array reference typemaps */
+%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
+
+/* const pointers */
+%apply SWIGTYPE * { SWIGTYPE *const }
+%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
+%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
+
+/* String & length */
+%typemap(jni) (const char *STRING, size_t LENGTH) "jbyteArray"
+%typemap(jtype) (const char *STRING, size_t LENGTH) "byte[]"
+%typemap(jstype) (const char *STRING, size_t LENGTH) "byte[]"
+%typemap(javain) (const char *STRING, size_t LENGTH) "$javainput"
+%typemap(freearg) (const char *STRING, size_t LENGTH) ""
+%typemap(in) (const char *STRING, size_t LENGTH) {
+ if ($input) {
+ $1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0);
+ $2 = ($2_type) JCALL1(GetArrayLength, jenv, $input);
+ } else {
+ $1 = 0;
+ $2 = 0;
+ }
+}
+%typemap(argout) (const char *STRING, size_t LENGTH) {
+ if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, JNI_ABORT);
+}
+%typemap(directorin, descriptor="[B", noblock=1) (const char *STRING, size_t LENGTH) {
+ $input = 0;
+ if ($1) {
+ $input = JCALL1(NewByteArray, jenv, (jsize)$2);
+ if (!$input) return $null;
+ JCALL4(SetByteArrayRegion, jenv, $input, 0, (jsize)$2, (jbyte *)$1);
+ }
+ Swig::LocalRefGuard $1_refguard(jenv, $input);
+}
+%typemap(javadirectorin, descriptor="[B") (const char *STRING, size_t LENGTH) "$jniinput"
+%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) }
+/* Enable write-back for non-const version */
+%typemap(argout) (char *STRING, size_t LENGTH) {
+ if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
+}
+%typemap(directorargout, noblock=1) (char *STRING, size_t LENGTH)
+{ if ($input && $1) JCALL4(GetByteArrayRegion, jenv, $input, 0, (jsize)$2, (jbyte *)$1); }
+%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
+
+/* java keywords */
+%include <javakw.swg>
+
+// Default enum handling
+%include <enumtypesafe.swg>
+
diff --git a/contrib/tools/swig/Lib/java/javahead.swg b/contrib/tools/swig/Lib/java/javahead.swg
new file mode 100644
index 0000000000..758a037d17
--- /dev/null
+++ b/contrib/tools/swig/Lib/java/javahead.swg
@@ -0,0 +1,91 @@
+/* -----------------------------------------------------------------------------
+ * javahead.swg
+ *
+ * Java support code
+ * ----------------------------------------------------------------------------- */
+
+
+/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so
+ * that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand
+ * the macros thereby generating the correct calling convention. It is thus essential that all typemaps that
+ * use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */
+#ifdef __cplusplus
+# define JCALL0(func, jenv) jenv->func()
+# define JCALL1(func, jenv, ar1) jenv->func(ar1)
+# define JCALL2(func, jenv, ar1, ar2) jenv->func(ar1, ar2)
+# define JCALL3(func, jenv, ar1, ar2, ar3) jenv->func(ar1, ar2, ar3)
+# define JCALL4(func, jenv, ar1, ar2, ar3, ar4) jenv->func(ar1, ar2, ar3, ar4)
+# define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) jenv->func(ar1, ar2, ar3, ar4, ar5)
+# define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6)
+# define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6, ar7)
+#else
+# define JCALL0(func, jenv) (*jenv)->func(jenv)
+# define JCALL1(func, jenv, ar1) (*jenv)->func(jenv, ar1)
+# define JCALL2(func, jenv, ar1, ar2) (*jenv)->func(jenv, ar1, ar2)
+# define JCALL3(func, jenv, ar1, ar2, ar3) (*jenv)->func(jenv, ar1, ar2, ar3)
+# define JCALL4(func, jenv, ar1, ar2, ar3, ar4) (*jenv)->func(jenv, ar1, ar2, ar3, ar4)
+# define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5)
+# define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6)
+# define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7)
+#endif
+
+%insert(runtime) %{
+#include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+%}
+
+%insert(runtime) %{
+/* Support for throwing Java exceptions */
+typedef enum {
+ SWIG_JavaOutOfMemoryError = 1,
+ SWIG_JavaIOException,
+ SWIG_JavaRuntimeException,
+ SWIG_JavaIndexOutOfBoundsException,
+ SWIG_JavaArithmeticException,
+ SWIG_JavaIllegalArgumentException,
+ SWIG_JavaNullPointerException,
+ SWIG_JavaDirectorPureVirtual,
+ SWIG_JavaUnknownError,
+ SWIG_JavaIllegalStateException,
+} SWIG_JavaExceptionCodes;
+
+typedef struct {
+ SWIG_JavaExceptionCodes code;
+ const char *java_exception;
+} SWIG_JavaExceptions_t;
+%}
+
+%insert(runtime) {
+static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
+ jclass excep;
+ static const SWIG_JavaExceptions_t java_exceptions[] = {
+ { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
+ { SWIG_JavaIOException, "java/io/IOException" },
+ { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
+ { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
+ { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
+ { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
+ { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
+ { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
+ { SWIG_JavaUnknownError, "java/lang/UnknownError" },
+ { SWIG_JavaIllegalStateException, "java/lang/IllegalStateException" },
+ { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" }
+ };
+ const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
+
+ while (except_ptr->code != code && except_ptr->code)
+ except_ptr++;
+
+ JCALL0(ExceptionClear, jenv);
+ excep = JCALL1(FindClass, jenv, except_ptr->java_exception);
+ if (excep)
+ JCALL2(ThrowNew, jenv, excep, msg);
+}
+}
+
+%insert(runtime) %{
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) do { if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } } while (0)
+%}
diff --git a/contrib/tools/swig/Lib/java/javakw.swg b/contrib/tools/swig/Lib/java/javakw.swg
new file mode 100644
index 0000000000..8a5b76eef2
--- /dev/null
+++ b/contrib/tools/swig/Lib/java/javakw.swg
@@ -0,0 +1,70 @@
+#ifndef JAVA_JAVAKW_SWG_
+#define JAVA_JAVAKW_SWG_
+
+/* Warnings for Java keywords */
+#define JAVAKW(x) %keywordwarn("'" `x` "' is a java keyword",rename="_%s") `x`
+
+/*
+ from
+ http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
+*/
+
+JAVAKW(abstract);
+JAVAKW(double);
+JAVAKW(int);
+JAVAKW(strictfp);
+JAVAKW(boolean);
+JAVAKW(else);
+JAVAKW(interface);
+JAVAKW(super);
+JAVAKW(break);
+JAVAKW(extends);
+JAVAKW(long);
+JAVAKW(switch);
+JAVAKW(byte);
+JAVAKW(final);
+JAVAKW(native);
+JAVAKW(synchronized);
+JAVAKW(case);
+JAVAKW(finally);
+JAVAKW(new);
+JAVAKW(this);
+JAVAKW(catch);
+JAVAKW(float);
+JAVAKW(package);
+JAVAKW(throw);
+JAVAKW(char);
+JAVAKW(for);
+JAVAKW(private);
+JAVAKW(throws);
+JAVAKW(class);
+JAVAKW(goto);
+JAVAKW(protected);
+JAVAKW(transient);
+JAVAKW(const);
+JAVAKW(if);
+JAVAKW(public);
+JAVAKW(try);
+JAVAKW(continue);
+JAVAKW(implements);
+JAVAKW(return);
+JAVAKW(void);
+JAVAKW(default);
+JAVAKW(import);
+JAVAKW(short);
+JAVAKW(volatile);
+JAVAKW(do);
+JAVAKW(instanceof);
+JAVAKW(static);
+JAVAKW(while);
+
+
+/* others bad names */
+
+/* Note here that only *::clone() is bad, and *::clone(int) is ok */
+%namewarn("321:clone() is a java bad method name") *::clone();
+
+
+#undef JAVAKW
+
+#endif //JAVA_JAVAKW_SWG_
diff --git a/contrib/tools/swig/Lib/java/typemaps.i b/contrib/tools/swig/Lib/java/typemaps.i
new file mode 100644
index 0000000000..e130c1930b
--- /dev/null
+++ b/contrib/tools/swig/Lib/java/typemaps.i
@@ -0,0 +1,529 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.i
+ *
+ * Pointer and reference handling typemap library
+ *
+ * These mappings provide support for input/output arguments and common
+ * uses for C/C++ pointers and C++ references.
+ * ----------------------------------------------------------------------------- */
+
+/*
+INPUT typemaps
+--------------
+
+These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is
+passed by value instead of reference.
+
+The following typemaps can be applied to turn a pointer or reference into a simple
+input value. That is, instead of passing a pointer or reference to an object,
+you would use a real value instead.
+
+ bool *INPUT, bool &INPUT
+ signed char *INPUT, signed char &INPUT
+ unsigned char *INPUT, unsigned char &INPUT
+ short *INPUT, short &INPUT
+ unsigned short *INPUT, unsigned short &INPUT
+ int *INPUT, int &INPUT
+ unsigned int *INPUT, unsigned int &INPUT
+ long *INPUT, long &INPUT
+ unsigned long *INPUT, unsigned long &INPUT
+ long long *INPUT, long long &INPUT
+ unsigned long long *INPUT, unsigned long long &INPUT
+ float *INPUT, float &INPUT
+ double *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);
+
+In Java you could then use it like this:
+ double answer = modulename.fadd(10.0, 20.0);
+
+There are no char *INPUT typemaps, however you can apply the signed char * typemaps instead:
+ %include <typemaps.i>
+ %apply signed char *INPUT {char *input};
+ void f(char *input);
+*/
+
+%define INPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JNIDESC)
+%typemap(jni) TYPE *INPUT, TYPE &INPUT "JNITYPE"
+%typemap(jtype) TYPE *INPUT, TYPE &INPUT "JTYPE"
+%typemap(jstype) TYPE *INPUT, TYPE &INPUT "JTYPE"
+%typemap(javain) TYPE *INPUT, TYPE &INPUT "$javainput"
+
+%typemap(in) TYPE *INPUT, TYPE &INPUT
+%{ $1 = ($1_ltype)&$input; %}
+
+%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
+
+%typemap(typecheck) TYPE *INPUT = TYPE;
+%typemap(typecheck) TYPE &INPUT = TYPE;
+%enddef
+
+INPUT_TYPEMAP(bool, jboolean, boolean, "Z");
+INPUT_TYPEMAP(signed char, jbyte, byte, "B");
+INPUT_TYPEMAP(unsigned char, jshort, short, "S");
+INPUT_TYPEMAP(short, jshort, short, "S");
+INPUT_TYPEMAP(unsigned short, jint, int, "I");
+INPUT_TYPEMAP(int, jint, int, "I");
+INPUT_TYPEMAP(unsigned int, jlong, long, "J");
+INPUT_TYPEMAP(long, jint, int, "I");
+INPUT_TYPEMAP(unsigned long, jlong, long, "J");
+INPUT_TYPEMAP(long long, jlong, long, "J");
+INPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, "Ljava/math/BigInteger;");
+INPUT_TYPEMAP(float, jfloat, float, "F");
+INPUT_TYPEMAP(double, jdouble, double, "D");
+
+#undef INPUT_TYPEMAP
+
+/* Convert from BigInteger using the toByteArray member function */
+/* Overrides the typemap in the INPUT_TYPEMAP macro */
+%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) {
+ jclass clazz;
+ jmethodID mid;
+ jbyteArray ba;
+ jbyte* bae;
+ jsize sz;
+ int i;
+
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
+ return $null;
+ }
+ clazz = JCALL1(GetObjectClass, jenv, $input);
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ sz = JCALL1(GetArrayLength, jenv, ba);
+ temp = 0;
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
+ }
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+ $1 = &temp;
+}
+
+// OUTPUT typemaps. These typemaps are used for parameters that
+// are output only. An array replaces the c pointer or reference parameter.
+// The output value is returned in this array passed in.
+
+/*
+OUTPUT typemaps
+---------------
+
+The following typemaps can be applied to turn a pointer or reference into an "output"
+value. When calling a function, no input value would be given for
+a parameter, but an output value would be returned. This works by a
+Java array being passed as a parameter where a c pointer or reference is required.
+As with any Java function, the array is passed by reference so that
+any modifications to the array will be picked up in the calling function.
+Note that the array passed in MUST have at least one element, but as the
+c function does not require any input, the value can be set to anything.
+
+ bool *OUTPUT, bool &OUTPUT
+ signed char *OUTPUT, signed char &OUTPUT
+ unsigned char *OUTPUT, unsigned char &OUTPUT
+ short *OUTPUT, short &OUTPUT
+ unsigned short *OUTPUT, unsigned short &OUTPUT
+ int *OUTPUT, int &OUTPUT
+ unsigned int *OUTPUT, unsigned int &OUTPUT
+ long *OUTPUT, long &OUTPUT
+ unsigned long *OUTPUT, unsigned long &OUTPUT
+ long long *OUTPUT, long long &OUTPUT
+ unsigned long long *OUTPUT, unsigned long long &OUTPUT
+ float *OUTPUT, float &OUTPUT
+ double *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):
+
+ 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 Java output of the function would be the function return value and the
+value in the single element array. In Java you would use it like this:
+
+ double[] ptr = {0.0};
+ double fraction = modulename.modf(5.0,ptr);
+
+There are no char *OUTPUT typemaps, however you can apply the signed char * typemaps instead:
+ %include <typemaps.i>
+ %apply signed char *OUTPUT {char *output};
+ void f(char *output);
+*/
+
+/* Java BigInteger[] */
+%typecheck(SWIG_TYPECHECK_INT128_ARRAY) SWIGBIGINTEGERARRAY ""
+
+%define OUTPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE)
+%typemap(jni) TYPE *OUTPUT, TYPE &OUTPUT %{JNITYPE##Array%}
+%typemap(jtype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]"
+%typemap(jstype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]"
+%typemap(javain) TYPE *OUTPUT, TYPE &OUTPUT "$javainput"
+%typemap(javadirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$jniinput"
+%typemap(javadirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$javacall"
+
+%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp)
+{
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return $null;
+ }
+ if (JCALL1(GetArrayLength, jenv, $input) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return $null;
+ }
+ temp = ($*1_ltype)0;
+ $1 = &temp;
+}
+
+%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
+
+%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
+{
+ JNITYPE jvalue = (JNITYPE)temp$argnum;
+ JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue);
+}
+
+%typemap(directorin,descriptor=JNIDESC) TYPE &OUTPUT %{
+ $input = JCALL1(New##JAVATYPE##Array, jenv, 1);
+ if (!$input) return $null;
+ Swig::LocalRefGuard $1_refguard(jenv, $input); %}
+
+%typemap(directorin,descriptor=JNIDESC) TYPE *OUTPUT %{
+ if ($1) {
+ $input = JCALL1(New##JAVATYPE##Array, jenv, 1);
+ if (!$input) return $null;
+ }
+ Swig::LocalRefGuard $1_refguard(jenv, $input); %}
+
+%typemap(directorargout, noblock=1) TYPE &OUTPUT
+{
+ JNITYPE $1_jvalue;
+ JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ $result = ($*1_ltype)$1_jvalue;
+}
+
+%typemap(directorargout, noblock=1) TYPE *OUTPUT
+{
+ if ($result) {
+ JNITYPE $1_jvalue;
+ JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ *$result = ($*1_ltype)$1_jvalue;
+ }
+}
+
+%typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE;
+%typemap(typecheck) TYPE &OUTPUT = TYPECHECKTYPE;
+%enddef
+
+OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Z", jbooleanArray);
+OUTPUT_TYPEMAP(signed char, jbyte, byte, Byte, "[B", jbyteArray);
+OUTPUT_TYPEMAP(unsigned char, jshort, short, Short, "[S", jshortArray);
+OUTPUT_TYPEMAP(short, jshort, short, Short, "[S", jshortArray);
+OUTPUT_TYPEMAP(unsigned short, jint, int, Int, "[I", jintArray);
+OUTPUT_TYPEMAP(int, jint, int, Int, "[I", jintArray);
+OUTPUT_TYPEMAP(unsigned int, jlong, long, Long, "[J", jlongArray);
+OUTPUT_TYPEMAP(long, jint, int, Int, "[I", jintArray);
+OUTPUT_TYPEMAP(unsigned long, jlong, long, Long, "[J", jlongArray);
+OUTPUT_TYPEMAP(long long, jlong, long, Long, "[J", jlongArray);
+OUTPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, Object, "[Ljava/math/BigInteger;", jobjectArray);
+OUTPUT_TYPEMAP(float, jfloat, float, Float, "[F", jfloatArray);
+OUTPUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray);
+
+#undef OUTPUT_TYPEMAP
+
+%typemap(in) bool *OUTPUT($*1_ltype temp), bool &OUTPUT($*1_ltype temp)
+{
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return $null;
+ }
+ if (JCALL1(GetArrayLength, jenv, $input) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return $null;
+ }
+ temp = false;
+ $1 = &temp;
+}
+
+%typemap(directorargout, noblock=1) bool &OUTPUT
+{
+ jboolean $1_jvalue;
+ JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ $result = $1_jvalue ? true : false;
+}
+
+%typemap(directorargout, noblock=1) bool *OUTPUT
+{
+ if ($result) {
+ jboolean $1_jvalue;
+ JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ *$result = $1_jvalue ? true : false;
+ }
+}
+
+
+/* Convert to BigInteger - byte array holds number in 2's complement big endian format */
+/* Use first element in BigInteger array for output */
+/* Overrides the typemap in the OUTPUT_TYPEMAP macro */
+%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT {
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
+ jobject bigint;
+ int i;
+
+ bae[0] = 0;
+ for(i=1; i<9; i++ ) {
+ bae[i] = (jbyte)(temp$argnum>>8*(8-i));
+ }
+
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
+ JCALL1(DeleteLocalRef, jenv, ba);
+ JCALL3(SetObjectArrayElement, jenv, $input, 0, bigint);
+}
+
+/*
+INOUT typemaps
+--------------
+
+Mappings for a parameter that is both an input and an output parameter
+
+The following typemaps can be applied to make a function parameter both
+an input and output value. This combines the behavior of both the
+"INPUT" and "OUTPUT" typemaps described earlier. Output values are
+returned as an element in a Java array.
+
+ bool *INOUT, bool &INOUT
+ signed char *INOUT, signed char &INOUT
+ unsigned char *INOUT, unsigned char &INOUT
+ short *INOUT, short &INOUT
+ unsigned short *INOUT, unsigned short &INOUT
+ int *INOUT, int &INOUT
+ unsigned int *INOUT, unsigned int &INOUT
+ long *INOUT, long &INOUT
+ unsigned long *INOUT, unsigned long &INOUT
+ long long *INOUT, long long &INOUT
+ unsigned long long *INOUT, unsigned long long &INOUT
+ float *INOUT, float &INOUT
+ double *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);
+
+This works similarly to C in that the mapping directly modifies the
+input value - the input must be an array with a minimum of one element.
+The element in the array is the input and the output is the element in
+the array.
+
+ double x[] = {5.0};
+ neg(x);
+
+The implementation of the OUTPUT and INOUT typemaps is different to other
+languages in that other languages will return the output value as part
+of the function return value. This difference is due to Java being a typed language.
+
+There are no char *INOUT typemaps, however you can apply the signed char * typemaps instead:
+ %include <typemaps.i>
+ %apply signed char *INOUT {char *inout};
+ void f(char *inout);
+*/
+
+%define INOUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE)
+%typemap(jni) TYPE *INOUT, TYPE &INOUT %{JNITYPE##Array%}
+%typemap(jtype) TYPE *INOUT, TYPE &INOUT "JTYPE[]"
+%typemap(jstype) TYPE *INOUT, TYPE &INOUT "JTYPE[]"
+%typemap(javain) TYPE *INOUT, TYPE &INOUT "$javainput"
+%typemap(javadirectorin) TYPE *INOUT, TYPE &INOUT "$jniinput"
+%typemap(javadirectorout) TYPE *INOUT, TYPE &INOUT "$javacall"
+
+%typemap(in) TYPE *INOUT, TYPE &INOUT {
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return $null;
+ }
+ if (JCALL1(GetArrayLength, jenv, $input) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return $null;
+ }
+ $1 = ($1_ltype) JCALL2(Get##JAVATYPE##ArrayElements, jenv, $input, 0);
+}
+
+%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
+
+%typemap(argout) TYPE *INOUT, TYPE &INOUT
+{ JCALL3(Release##JAVATYPE##ArrayElements, jenv, $input, (JNITYPE *)$1, 0); }
+
+%typemap(directorin,descriptor=JNIDESC) TYPE &INOUT %{
+ $input = JCALL1(New##JAVATYPE##Array, jenv, 1);
+ if (!$input) return $null;
+ JNITYPE $1_jvalue = (JNITYPE)$1;
+ JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ Swig::LocalRefGuard $1_refguard(jenv, $input); %}
+
+%typemap(directorin,descriptor=JNIDESC) TYPE *INOUT %{
+ if ($1) {
+ $input = JCALL1(New##JAVATYPE##Array, jenv, 1);
+ if (!$input) return $null;
+ JNITYPE $1_jvalue = (JNITYPE)*$1;
+ JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ }
+ Swig::LocalRefGuard $1_refguard(jenv, $input); %}
+
+%typemap(directorargout, noblock=1) TYPE &INOUT
+{
+ JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ $result = ($*1_ltype)$1_jvalue;
+}
+
+%typemap(directorargout, noblock=1) TYPE *INOUT
+{
+ if ($result) {
+ JNITYPE $1_jvalue;
+ JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ *$result = ($*1_ltype)$1_jvalue;
+ }
+}
+
+%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE;
+%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE;
+%enddef
+
+INOUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Z", jbooleanArray);
+INOUT_TYPEMAP(signed char, jbyte, byte, Byte, "[B", jbyteArray);
+INOUT_TYPEMAP(unsigned char, jshort, short, Short, "[S", jshortArray);
+INOUT_TYPEMAP(short, jshort, short, Short, "[S", jshortArray);
+INOUT_TYPEMAP(unsigned short, jint, int, Int, "[I", jintArray);
+INOUT_TYPEMAP(int, jint, int, Int, "[I", jintArray);
+INOUT_TYPEMAP(unsigned int, jlong, long, Long, "[J", jlongArray);
+INOUT_TYPEMAP(long, jint, int, Int, "[I", jintArray);
+INOUT_TYPEMAP(unsigned long, jlong, long, Long, "[J", jlongArray);
+INOUT_TYPEMAP(long long, jlong, long, Long, "[J", jlongArray);
+INOUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, Object, "[java/math/BigInteger;", jobjectArray);
+INOUT_TYPEMAP(float, jfloat, float, Float, "[F", jfloatArray);
+INOUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray);
+
+#undef INOUT_TYPEMAP
+
+/* Override typemaps in the INOUT_TYPEMAP macro for booleans to fix casts
+ as a jboolean isn't always the same size as a bool */
+%typemap(in) bool *INOUT (bool btemp, jboolean *jbtemp), bool &INOUT (bool btemp, jboolean *jbtemp) {
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return $null;
+ }
+ if (JCALL1(GetArrayLength, jenv, $input) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return $null;
+ }
+ jbtemp = JCALL2(GetBooleanArrayElements, jenv, $input, 0);
+ btemp = (*jbtemp) ? true : false;
+ $1 = &btemp;
+}
+
+%typemap(argout) bool *INOUT, bool &INOUT {
+ *jbtemp$argnum = btemp$argnum ? (jboolean)1 : (jboolean)0;
+ JCALL3(ReleaseBooleanArrayElements, jenv, $input , (jboolean *)jbtemp$argnum, 0);
+}
+
+%typemap(directorargout, noblock=1) bool &INOUT
+{
+ JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ $result = $1_jvalue ? true : false;
+}
+
+%typemap(directorargout, noblock=1) bool *INOUT
+{
+ if ($result) {
+ jboolean $1_jvalue;
+ JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
+ *$result = $1_jvalue ? true : false;
+ }
+}
+
+
+/* Override the typemap in the INOUT_TYPEMAP macro for unsigned long long */
+%typemap(in) unsigned long long *INOUT ($*1_ltype temp), unsigned long long &INOUT ($*1_ltype temp) {
+ jobject bigint;
+ jclass clazz;
+ jmethodID mid;
+ jbyteArray ba;
+ jbyte* bae;
+ jsize sz;
+ int i;
+
+ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return $null;
+ }
+ if (JCALL1(GetArrayLength, jenv, $input) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return $null;
+ }
+ bigint = JCALL2(GetObjectArrayElement, jenv, $input, 0);
+ if (!bigint) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array element null");
+ return $null;
+ }
+ clazz = JCALL1(GetObjectClass, jenv, bigint);
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, bigint, mid);
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
+ sz = JCALL1(GetArrayLength, jenv, ba);
+ temp = 0;
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
+ }
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
+ $1 = &temp;
+}
+
+%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
+%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT;
diff --git a/contrib/tools/swig/Lib/perl5/extra-install.list b/contrib/tools/swig/Lib/perl5/extra-install.list
new file mode 100644
index 0000000000..db93830aab
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/extra-install.list
@@ -0,0 +1,2 @@
+# see top-level Makefile.in
+Makefile.pl noembed.h
diff --git a/contrib/tools/swig/Lib/perl5/perl5.swg b/contrib/tools/swig/Lib/perl5/perl5.swg
new file mode 100644
index 0000000000..693c2b9457
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perl5.swg
@@ -0,0 +1,42 @@
+/* ------------------------------------------------------------
+ * perl.swg
+ *
+ * Perl configuration module.
+ * ------------------------------------------------------------ */
+
+/* ------------------------------------------------------------
+ * Inner macros
+ * ------------------------------------------------------------ */
+%include <perlmacros.swg>
+
+/* ------------------------------------------------------------
+ * The runtime part
+ * ------------------------------------------------------------ */
+%include <perlruntime.swg>
+
+/* ------------------------------------------------------------
+ * Special user directives
+ * ------------------------------------------------------------ */
+%include <perluserdir.swg>
+
+/* ------------------------------------------------------------
+ * Typemap specializations
+ * ------------------------------------------------------------ */
+%include <perltypemaps.swg>
+
+/* ------------------------------------------------------------
+ * Overloaded operator support
+ * ------------------------------------------------------------ */
+%include <perlopers.swg>
+
+/* ------------------------------------------------------------
+ * Warnings for Perl keywords
+ * ------------------------------------------------------------ */
+%include <perlkw.swg>
+
+/* ------------------------------------------------------------
+ * The Perl initialization function
+ * ------------------------------------------------------------ */
+%include <perlinit.swg>
+
+
diff --git a/contrib/tools/swig/Lib/perl5/perlfragments.swg b/contrib/tools/swig/Lib/perl5/perlfragments.swg
new file mode 100644
index 0000000000..45d25d1f6c
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlfragments.swg
@@ -0,0 +1,23 @@
+/*
+
+ Create a file with this name, 'perlfragments.swg', in your working
+ directory and add all the %fragments you want to take precedence
+ over the ones defined by default 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/contrib/tools/swig/Lib/perl5/perlinit.swg b/contrib/tools/swig/Lib/perl5/perlinit.swg
new file mode 100644
index 0000000000..c26b93fadb
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlinit.swg
@@ -0,0 +1,78 @@
+
+/* Export the SWIG initialization function */
+%header %{
+#ifdef __cplusplus
+extern "C"
+#endif
+#ifndef MULTIPLICITY
+SWIGEXPORT void SWIG_init (CV* cv);
+#else
+SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
+#endif
+%}
+
+/* Module initialization function */
+
+%insert(init) "swiginit.swg"
+
+%init %{
+
+#if defined(__cplusplus) && ! defined(XSPROTO)
+extern "C"
+#endif
+
+XS(SWIG_init) {
+ dXSARGS;
+ int i;
+ (void)items;
+
+ SWIG_InitializeModule(0);
+
+ /* Install commands */
+ for (i = 0; swig_commands[i].name; i++) {
+ /* Casts only needed for Perl < 5.10. */
+#ifdef __cplusplus
+ newXS(const_cast<char*>(swig_commands[i].name), swig_commands[i].wrapper, const_cast<char*>(__FILE__));
+#else
+ newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__);
+#endif
+ }
+
+ /* Install variables */
+ for (i = 0; swig_variables[i].name; i++) {
+ SV *sv;
+ sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI);
+ if (swig_variables[i].type) {
+ SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
+ } else {
+ sv_setiv(sv,(IV) 0);
+ }
+ swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
+ }
+
+ /* Install constant */
+ for (i = 0; swig_constants[i].type; i++) {
+ SV *sv;
+ sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI);
+ switch(swig_constants[i].type) {
+ case SWIG_INT:
+ sv_setiv(sv, (IV) swig_constants[i].lvalue);
+ break;
+ case SWIG_FLOAT:
+ sv_setnv(sv, (double) swig_constants[i].dvalue);
+ break;
+ case SWIG_STRING:
+ sv_setpv(sv, (const char *) swig_constants[i].pvalue);
+ break;
+ case SWIG_POINTER:
+ SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
+ break;
+ case SWIG_BINARY:
+ SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
+ break;
+ default:
+ break;
+ }
+ SvREADONLY_on(sv);
+ }
+%}
diff --git a/contrib/tools/swig/Lib/perl5/perlkw.swg b/contrib/tools/swig/Lib/perl5/perlkw.swg
new file mode 100644
index 0000000000..00648e0bf3
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlkw.swg
@@ -0,0 +1,251 @@
+/* Warnings for Perl keywords */
+#define PERLKW(x) %keywordwarn("'" `x` "' is a perl keyword") `x`
+#define PERLBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in perl") "::" `x`
+
+
+/*
+
+ From http://www.rocketaware.com/perl/perlfunc/
+
+*/
+
+/* Functions for SCALARs or strings*/
+PERLBN(chomp);
+PERLBN(chop);
+PERLBN(chr);
+PERLBN(crypt);
+PERLBN(hex);
+PERLBN(index);
+PERLBN(lc);
+PERLBN(lcfirst);
+PERLBN(length);
+PERLBN(oct);
+PERLBN(ord);
+PERLBN(pack);
+PERLBN(reverse);
+PERLBN(rindex);
+PERLBN(sprintf);
+PERLBN(substr);
+PERLBN(uc);
+PERLBN(ucfirst);
+
+/* Regular expressions and pattern matching */
+PERLBN(m);
+PERLBN(pos);
+PERLBN(quotemeta);
+PERLBN(split);
+PERLBN(study);
+
+/* Numeric functions */
+PERLBN(abs);
+PERLBN(atan2);
+PERLBN(cos);
+PERLBN(exp);
+PERLBN(hex);
+PERLBN(int);
+PERLBN(log);
+PERLBN(oct);
+PERLBN(rand);
+PERLBN(sin);
+PERLBN(sqrt);
+PERLBN(srand);
+
+
+/* Functions for real @ARRAYs*/
+PERLBN(pop);
+PERLBN(push);
+PERLBN(shift);
+PERLBN(splice);
+PERLBN(unshift);
+
+/* Functions for list data*/
+PERLBN(grep);
+PERLBN(join);
+PERLBN(map);
+PERLBN(qw);
+PERLBN(reverse);
+PERLBN(sort);
+PERLBN(unpack);
+
+
+/* Functions for real %HASHes*/
+PERLBN(delete);
+PERLBN(each);
+PERLBN(exists);
+PERLBN(keys);
+PERLBN(values);
+
+
+/* Input and output functions*/
+
+PERLBN(binmode);
+PERLBN(close);
+PERLBN(closedir);
+PERLBN(dbmclose);
+PERLBN(dbmopen);
+PERLBN(die);
+PERLBN(eof);
+PERLBN(fileno);
+PERLBN(flock);
+PERLBN(format);
+PERLBN(getc);
+PERLBN(print);
+PERLBN(printf);
+PERLBN(read);
+PERLBN(readdir);
+PERLBN(rewinddir);
+PERLBN(seek);
+PERLBN(seekdir);
+PERLBN(select);
+PERLBN(syscall);
+PERLBN(sysread);
+PERLBN(sysseek);
+PERLBN(syswrite);
+PERLBN(tell);
+PERLBN(telldir);
+PERLBN(truncate);
+PERLBN(warn);
+PERLBN(write);
+
+
+/* Functions for fixed length data or records*/
+PERLBN(pack);
+PERLBN(read);
+PERLBN(syscall);
+PERLBN(sysread);
+PERLBN(syswrite);
+PERLBN(unpack);
+PERLBN(vec);
+
+
+/* Functions for filehandles, files, or directories */
+PERLBN(chdir);
+PERLBN(chmod);
+PERLBN(chown);
+PERLBN(chroot);
+PERLBN(fcntl);
+PERLBN(glob);
+PERLBN(ioctl);
+PERLBN(link);
+PERLBN(lstat);
+PERLBN(mkdir);
+PERLBN(open);
+PERLBN(opendir);
+PERLBN(readlink);
+PERLBN(rename);
+PERLBN(rmdir);
+PERLBN(stat);
+PERLBN(symlink);
+PERLBN(umask);
+PERLBN(unlink);
+PERLBN(utime);
+
+
+/* Keywords related to the control flow of your perl program */
+PERLKW(caller);
+PERLKW(continue);
+PERLKW(die);
+PERLKW(do);
+PERLKW(dump);
+PERLKW(eval);
+PERLKW(exit);
+PERLKW(goto);
+PERLKW(last);
+PERLKW(next);
+PERLKW(redo);
+PERLKW(return);
+PERLKW(sub);
+PERLKW(wantarray);
+
+
+/* Keywords related to scoping */
+PERLKW(caller);
+PERLKW(import);
+PERLKW(local);
+PERLKW(my);
+PERLKW(package);
+PERLKW(use);
+
+
+/* Miscellaneous functions */
+PERLBN("defined");
+PERLBN(dump);
+PERLBN(eval);
+PERLBN(formline);
+PERLBN(local);
+PERLBN(my);
+PERLBN(reset);
+PERLBN(scalar);
+PERLBN(undef);
+PERLBN(wantarray);
+
+
+/* Functions for processes and process groups */
+PERLBN(alarm);
+PERLBN(exec);
+PERLBN(fork);
+PERLBN(getpgrp);
+PERLBN(getppid);
+PERLBN(getpriority);
+PERLBN(kill);
+PERLBN(pipe);
+PERLBN(setpgrp);
+PERLBN(setpriority);
+PERLBN(sleep);
+PERLBN(system);
+PERLBN(times);
+PERLBN(wait);
+PERLBN(waitpid);
+
+
+/* Keywords related to perl modules */
+PERLKW(do);
+PERLKW(import);
+PERLKW(no);
+PERLKW(package);
+PERLKW(require);
+PERLKW(use);
+
+
+/* Keywords related to classes and object-orientedness */
+PERLKW(bless);
+PERLKW(dbmclose);
+PERLKW(dbmopen);
+PERLKW(package);
+PERLKW(ref);
+PERLKW(tie);
+PERLKW(tied);
+PERLKW(untie);
+PERLKW(use);
+
+/* Functions new in perl5 */
+PERLBN(abs);
+PERLBN(bless);
+PERLBN(chomp);
+PERLBN(chr);
+PERLBN(exists);
+PERLBN(formline);
+PERLBN(glob);
+PERLBN(import);
+PERLBN(lc);
+PERLBN(lcfirst);
+PERLBN(map);
+PERLBN(my);
+PERLBN(no);
+PERLBN(prototype);
+PERLBN(qx);
+PERLBN(qw);
+PERLBN(readline);
+PERLBN(readpipe);
+PERLBN(ref);
+PERLBN(sub);
+PERLBN(sysopen);
+PERLBN(tie);
+PERLBN(tied);
+PERLBN(uc);
+PERLBN(ucfirst);
+PERLBN(untie);
+PERLBN(use);
+
+#undef PERLKW
+#undef PERLBN
diff --git a/contrib/tools/swig/Lib/perl5/perlmacros.swg b/contrib/tools/swig/Lib/perl5/perlmacros.swg
new file mode 100644
index 0000000000..4917f6efc5
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlmacros.swg
@@ -0,0 +1,2 @@
+%include <typemaps/swigmacros.swg>
+
diff --git a/contrib/tools/swig/Lib/perl5/perlopers.swg b/contrib/tools/swig/Lib/perl5/perlopers.swg
new file mode 100644
index 0000000000..e7d13b678a
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlopers.swg
@@ -0,0 +1,54 @@
+/* ------------------------------------------------------------
+ * Overloaded operator support
+ * ------------------------------------------------------------ */
+
+#ifdef __cplusplus
+
+// These are auto-supported by the Perl-module
+%rename(__plusplus__) *::operator++;
+%rename(__minmin__) *::operator--;
+%rename(__add__) *::operator+;
+%rename(__sub__) *::operator-;
+%rename(__neg__) *::operator-();
+%rename(__neg__) *::operator-() const;
+%rename(__mul__) *::operator*;
+%rename(__div__) *::operator/;
+%rename(__eq__) *::operator==;
+%rename(__ne__) *::operator!=;
+%rename(__mod__) *::operator%;
+%rename(__gt__) *::operator>;
+%rename(__lt__) *::operator<;
+%rename(__not__) *::operator!;
+%rename(__le__) *::operator<=;
+%rename(__ge__) *::operator>=;
+%rename(__and__) *::operator&;
+%rename(__or__) *::operator|;
+%rename(__iadd__) *::operator+=;
+%rename(__isub__) *::operator-=;
+
+// These are renamed, but no test exists in operator_overload_runme.pl
+%ignoreoperator(EQ) operator=;
+
+// These are renamed, but no 'use overload...' is added
+%rename(__lshift__) *::operator<<;
+%rename(__rshift__) *::operator>>;
+%rename(__xor__) *::operator^;
+%rename(__invert__) *::operator~;
+%rename(__call__) *::operator();
+
+/* Ignored operators */
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+%ignoreoperator(MULEQ) operator*=;
+%ignoreoperator(DIVEQ) operator/=;
+%ignoreoperator(MODEQ) operator%=;
+%ignoreoperator(LSHIFTEQ) operator<<=;
+%ignoreoperator(RSHIFTEQ) operator>>=;
+%ignoreoperator(ANDEQ) operator&=;
+%ignoreoperator(OREQ) operator|=;
+%ignoreoperator(XOREQ) operator^=;
+%ignoreoperator(ARROWSTAR) operator->*;
+%ignoreoperator(INDEX) operator[];
+
+
+#endif /* __cplusplus */
diff --git a/contrib/tools/swig/Lib/perl5/perlprimtypes.swg b/contrib/tools/swig/Lib/perl5/perlprimtypes.swg
new file mode 100644
index 0000000000..4cb675671c
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlprimtypes.swg
@@ -0,0 +1,364 @@
+/* ------------------------------------------------------------
+ * Primitive Types
+ * ------------------------------------------------------------ */
+
+/* bool */
+
+%fragment(SWIG_From_frag(bool),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(bool)(bool value)
+{
+ return boolSV(value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(bool),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(SV *obj, bool* val)
+{
+ if (obj == &PL_sv_yes) {
+ if (val) *val = true;
+ return SWIG_OK;
+ } else if (obj == &PL_sv_no) {
+ if (val) *val = false;
+ return SWIG_OK;
+ } else {
+ if (val) *val = SvTRUE(obj) ? true : false;
+ return SWIG_AddCast(SWIG_OK);
+ }
+}
+}
+
+
+/* long */
+
+%fragment(SWIG_From_frag(long),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(long)(long value)
+{
+ SV *sv;
+ if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX))
+ sv = newSViv(value);
+ else
+ sv = newSVpvf("%ld", value);
+ return sv_2mortal(sv);
+}
+}
+
+%fragment(SWIG_AsVal_frag(long),"header",
+ fragment="<limits.h>",
+ fragment="<stdlib.h>",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN int
+SWIG_AsVal_dec(long)(SV *obj, long* val)
+{
+ if (SvUOK(obj)) {
+ UV v = SvUV(obj);
+ if (UVSIZE < sizeof(*val) || v <= LONG_MAX) {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ return SWIG_OverflowError;
+ } else if (SvIOK(obj)) {
+ IV v = SvIV(obj);
+ if (IVSIZE <= sizeof(*val) || (v >= LONG_MIN && v <= LONG_MAX)) {
+ if(val) *val = v;
+ return SWIG_OK;
+ }
+ return SWIG_OverflowError;
+ } else {
+ int dispatch = 0;
+ const char *nptr = SvPV_nolen(obj);
+ if (nptr) {
+ char *endptr;
+ long v;
+ errno = 0;
+ v = strtol(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_Str2NumCast(SWIG_OK);
+ }
+ }
+ }
+ 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;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* unsigned long */
+
+%fragment(SWIG_From_frag(unsigned long),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(unsigned long)(unsigned long value)
+{
+ SV *sv;
+ if (UVSIZE >= sizeof(value) || value <= UV_MAX)
+ sv = newSVuv(value);
+ else
+ sv = newSVpvf("%lu", value);
+ return sv_2mortal(sv);
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long),"header",
+ fragment="<limits.h>",
+ fragment="<stdlib.h>",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val)
+{
+ if (SvUOK(obj)) {
+ UV v = SvUV(obj);
+ if (UVSIZE <= sizeof(*val) || v <= ULONG_MAX) {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ return SWIG_OverflowError;
+ } else if (SvIOK(obj)) {
+ IV v = SvIV(obj);
+ if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULONG_MAX)) {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ return SWIG_OverflowError;
+ } else {
+ int dispatch = 0;
+ const char *nptr = SvPV_nolen(obj);
+ if (nptr) {
+ char *endptr;
+ unsigned long v;
+ errno = 0;
+ v = strtoul(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_Str2NumCast(SWIG_OK);
+ }
+ }
+ }
+ 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;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* long long */
+
+%fragment(SWIG_From_frag(long long),"header",
+ fragment="SWIG_LongLongAvailable",
+ fragment="<stdio.h>") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+SWIGINTERNINLINE SV *
+SWIG_From_dec(long long)(long long value)
+{
+ SV *sv;
+ if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX))
+ sv = newSViv((IV)(value));
+ else {
+ //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl
+ char temp[256];
+ sprintf(temp, "%lld", value);
+ sv = newSVpv(temp, 0);
+ }
+ return sv_2mortal(sv);
+}
+%#endif
+}
+
+%fragment(SWIG_AsVal_frag(long long),"header",
+ fragment="SWIG_LongLongAvailable",
+ fragment="<stdlib.h>",
+ fragment="SWIG_CanCastAsInteger") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+SWIGINTERN int
+SWIG_AsVal_dec(long long)(SV *obj, long long *val)
+{
+ if (SvUOK(obj)) {
+ UV v = SvUV(obj);
+ /* pretty sure this could allow v == LLONG MAX */
+ if (UVSIZE < sizeof(*val) || v < LLONG_MAX) {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ return SWIG_OverflowError;
+ } else if (SvIOK(obj)) {
+ IV v = SvIV(obj);
+ if (IVSIZE <= sizeof(*val) || (v >= LLONG_MIN && v <= LLONG_MAX)) {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ return SWIG_OverflowError;
+ } else {
+ int dispatch = 0;
+ const char *nptr = SvPV_nolen(obj);
+ if (nptr) {
+ char *endptr;
+ long long v;
+ errno = 0;
+ v = strtoll(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_Str2NumCast(SWIG_OK);
+ }
+ }
+ }
+ if (!dispatch) {
+ const double mant_max = 1LL << DBL_MANT_DIG;
+ const double mant_min = -mant_max;
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
+ if (val) *val = (long long)(d);
+ return res;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+%#endif
+}
+
+/* unsigned long long */
+
+%fragment(SWIG_From_frag(unsigned long long),"header",
+ fragment="SWIG_LongLongAvailable",
+ fragment="<stdio.h>") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+SWIGINTERNINLINE SV *
+SWIG_From_dec(unsigned long long)(unsigned long long value)
+{
+ SV *sv;
+ if (UVSIZE >= sizeof(value) || value <= UV_MAX)
+ sv = newSVuv((UV)(value));
+ else {
+ //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl
+ char temp[256];
+ sprintf(temp, "%llu", value);
+ sv = newSVpv(temp, 0);
+ }
+ return sv_2mortal(sv);
+}
+%#endif
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long long),"header",
+ fragment="SWIG_LongLongAvailable",
+ fragment="<stdlib.h>",
+ fragment="SWIG_CanCastAsInteger") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val)
+{
+ if (SvUOK(obj)) {
+ /* pretty sure this should be conditional on
+ * (UVSIZE <= sizeof(*val) || v <= ULLONG_MAX) */
+ if (val) *val = SvUV(obj);
+ return SWIG_OK;
+ } else if (SvIOK(obj)) {
+ IV v = SvIV(obj);
+ if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULLONG_MAX)) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else {
+ int dispatch = 0;
+ const char *nptr = SvPV_nolen(obj);
+ if (nptr) {
+ char *endptr;
+ unsigned long long v;
+ errno = 0;
+ v = strtoull(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_Str2NumCast(SWIG_OK);
+ }
+ }
+ }
+ if (!dispatch) {
+ const double mant_max = 1LL << DBL_MANT_DIG;
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
+ if (val) *val = (unsigned long long)(d);
+ return res;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+%#endif
+}
+
+/* double */
+
+%fragment(SWIG_From_frag(double),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(double)(double value)
+{
+ return sv_2mortal(newSVnv(value));
+}
+}
+
+%fragment(SWIG_AsVal_frag(double),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(double)(SV *obj, double *val)
+{
+ if (SvNIOK(obj)) {
+ if (val) *val = SvNV(obj);
+ return SWIG_OK;
+ } else if (SvIOK(obj)) {
+ if (val) *val = (double) SvIV(obj);
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ const char *nptr = SvPV_nolen(obj);
+ if (nptr) {
+ char *endptr;
+ double v;
+ errno = 0;
+ v = strtod(nptr, &endptr);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_Str2NumCast(SWIG_OK);
+ }
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
diff --git a/contrib/tools/swig/Lib/perl5/perlruntime.swg b/contrib/tools/swig/Lib/perl5/perlruntime.swg
new file mode 100644
index 0000000000..f948023de7
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlruntime.swg
@@ -0,0 +1,8 @@
+
+%runtime "swigrun.swg" // Common C API type-checking code
+%runtime "swigerrors.swg" // SWIG errors
+%runtime "perlhead.swg" // Perl includes and fixes
+%runtime "perlerrors.swg" // Perl errors
+%runtime "perlrun.swg" // Perl runtime functions
+%runtime "noembed.h" // undefine Perl5 macros
+
diff --git a/contrib/tools/swig/Lib/perl5/perlstrings.swg b/contrib/tools/swig/Lib/perl5/perlstrings.swg
new file mode 100644
index 0000000000..242a9c9673
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perlstrings.swg
@@ -0,0 +1,59 @@
+/* ------------------------------------------------------------
+ * utility methods for char strings
+ * ------------------------------------------------------------ */
+
+%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
+{
+ if (SvMAGICAL(obj)) {
+ SV *tmp = sv_newmortal();
+ SvSetSV(tmp, obj);
+ obj = tmp;
+ }
+ if (SvPOK(obj)) {
+ STRLEN len = 0;
+ char *cstr = SvPV(obj, len);
+ size_t size = len + 1;
+ if (cptr) {
+ if (alloc) {
+ if (*alloc == SWIG_NEWOBJ) {
+ *cptr = %new_copy_array(cstr, size, char);
+ } else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ }
+ }
+ if (psize) *psize = size;
+ return SWIG_OK;
+ } else {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ if (pchar_descriptor) {
+ char* vptr = 0;
+ if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = vptr;
+ if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+%fragment("SWIG_FromCharPtrAndSize","header") {
+SWIGINTERNINLINE SV *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+ SV *obj = sv_newmortal();
+ if (carray) {
+ sv_setpvn(obj, carray, size);
+ } else {
+ sv_setsv(obj, &PL_sv_undef);
+ }
+ return obj;
+}
+}
+
diff --git a/contrib/tools/swig/Lib/perl5/perltypemaps.swg b/contrib/tools/swig/Lib/perl5/perltypemaps.swg
new file mode 100644
index 0000000000..42f8887bef
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perltypemaps.swg
@@ -0,0 +1,104 @@
+/* ------------------------------------------------------------
+ * Typemap specializations for Perl
+ * ------------------------------------------------------------ */
+
+/* ------------------------------------------------------------
+ * Fragment section
+ * ------------------------------------------------------------ */
+
+/*
+ in Perl we need to pass the CPerlObj value, sometimes, so, we define
+ the decl/call macros as needed.
+*/
+
+#define SWIG_AS_DECL_ARGS SWIG_PERL_DECL_ARGS_2
+#define SWIG_AS_CALL_ARGS SWIG_PERL_CALL_ARGS_2
+
+#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1
+#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1
+
+
+/* Include fundamental fragment definitions */
+%include <typemaps/fragments.swg>
+
+/* Look for user fragments file. */
+%include <perlfragments.swg>
+
+/* Perl fragments for primitive types */
+%include <perlprimtypes.swg>
+
+/* Perl fragments for char* strings */
+%include <perlstrings.swg>
+
+
+/* ------------------------------------------------------------
+ * Unified typemap section
+ * ------------------------------------------------------------ */
+
+/* director support in Perl is experimental */
+#ifndef SWIG_DIRECTOR_TYPEMAPS
+#define SWIG_DIRECTOR_TYPEMAPS
+#endif
+
+
+/* Perl types */
+#define SWIG_Object SV *
+#define VOID_Object &PL_sv_undef
+
+/* Perl $shadow flag */
+#define %newpointer_flags $shadow
+#define %newinstance_flags $shadow
+
+
+/* Complete overload of the output/constant/exception macros */
+
+/* output */
+%define %set_output(obj) $result = obj; argvi++ %enddef
+
+/* append output */
+%define %append_output(obj)
+if (argvi >= items) EXTEND(sp, argvi+1);
+%set_output(obj) %enddef
+
+/* variable output */
+%define %set_varoutput(obj) sv_setsv($result,obj) %enddef
+
+/* constant */
+%define %set_constant(name, obj) %begin_block
+ SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2 | GV_ADDMULTI);
+ sv_setsv(sv, obj);
+ SvREADONLY_on(sv);
+%end_block %enddef
+
+/* raise exception */
+%define %raise(obj, type, desc) sv_setsv(get_sv("@", GV_ADD), obj); SWIG_fail %enddef
+
+/* For directors to raise/throw the original exception */
+%typemap(throws) Swig::DirectorException
+%{ sv_setsv(ERRSV, $1.getNative()); SWIG_fail; %}
+
+/* Include the unified typemap library */
+%include <typemaps/swigtypemaps.swg>
+
+/* ------------------------------------------------------------
+ * Perl extra typemaps / typemap overrides
+ * ------------------------------------------------------------ */
+
+%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE []
+ "sv_setiv(SvRV($result),PTR2IV($1));";
+
+%typemap(varout,type="$1_descriptor") SWIGTYPE &
+ "sv_setiv(SvRV($result),PTR2IV(&$1));";
+
+%typemap(varout,type="$1_descriptor") SWIGTYPE &&
+ "sv_setiv(SvRV($result),PTR2IV(&$1));";
+
+%typemap(varout,type="$&1_descriptor") SWIGTYPE
+ "sv_setiv(SvRV($result), PTR2IV(&$1));";
+
+%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
+ SWIG_MakePackedObj($result, (void *) &$1, sizeof($1), $1_descriptor);
+}
+
+%typemap(varout) SWIGTYPE *const = SWIGTYPE *;
+
diff --git a/contrib/tools/swig/Lib/perl5/perluserdir.swg b/contrib/tools/swig/Lib/perl5/perluserdir.swg
new file mode 100644
index 0000000000..718440e837
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/perluserdir.swg
@@ -0,0 +1,2 @@
+#define %perlcode %insert("perl")
+
diff --git a/contrib/tools/swig/Lib/perl5/reference.i b/contrib/tools/swig/Lib/perl5/reference.i
new file mode 100644
index 0000000000..b424c533b1
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/reference.i
@@ -0,0 +1,261 @@
+/* -----------------------------------------------------------------------------
+ * reference.i
+ *
+ * Accept Perl references as pointers
+ * ----------------------------------------------------------------------------- */
+
+/*
+The following methods make Perl references work like simple C
+pointers. References can only be used for simple input/output
+values, not C arrays however. It should also be noted that
+REFERENCES are specific to Perl and not supported in other
+scripting languages at this time.
+
+ int *REFERENCE
+ short *REFERENCE
+ long *REFERENCE
+ unsigned int *REFERENCE
+ unsigned short *REFERENCE
+ unsigned long *REFERENCE
+ unsigned char *REFERENCE
+ float *REFERENCE
+ double *REFERENCE
+
+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 reference.i
+ void neg(double *REFERENCE);
+
+or you can use the %apply directive :
+
+ %include reference.i
+ %apply double *REFERENCE { double *x };
+ void neg(double *x);
+
+Unlike the INOUT mapping described in typemaps.i, this approach directly
+modifies the value of a Perl reference. Thus, you could use it
+as follows :
+
+ $x = 3;
+ neg(\$x);
+ print "$x\n"; # Should print out -3.
+
+*/
+
+%typemap(in) double *REFERENCE (double dvalue), double &REFERENCE(double dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
+ printf("Received %d\n", SvTYPE(tempsv));
+ SWIG_croak("Expected a double reference.");
+ }
+ dvalue = SvNV(tempsv);
+ $1 = &dvalue;
+}
+
+%typemap(in) float *REFERENCE (float dvalue), float &REFERENCE(float dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
+ SWIG_croak("expected a double reference");
+ }
+ dvalue = (float) SvNV(tempsv);
+ $1 = &dvalue;
+}
+
+%typemap(in) int *REFERENCE (int dvalue), int &REFERENCE (int dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = SvIV(tempsv);
+ $1 = &dvalue;
+}
+
+%typemap(in) short *REFERENCE (short dvalue), short &REFERENCE(short dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (short) SvIV(tempsv);
+ $1 = &dvalue;
+}
+%typemap(in) long *REFERENCE (long dvalue), long &REFERENCE(long dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (long) SvIV(tempsv);
+ $1 = &dvalue;
+}
+%typemap(in) unsigned int *REFERENCE (unsigned int dvalue), unsigned int &REFERENCE(unsigned int dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (unsigned int) SvUV(tempsv);
+ $1 = &dvalue;
+}
+%typemap(in) unsigned short *REFERENCE (unsigned short dvalue), unsigned short &REFERENCE(unsigned short dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (unsigned short) SvUV(tempsv);
+ $1 = &dvalue;
+}
+%typemap(in) unsigned long *REFERENCE (unsigned long dvalue), unsigned long &REFERENCE(unsigned long dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (unsigned long) SvUV(tempsv);
+ $1 = &dvalue;
+}
+
+%typemap(in) unsigned char *REFERENCE (unsigned char dvalue), unsigned char &REFERENCE(unsigned char dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (unsigned char) SvUV(tempsv);
+ $1 = &dvalue;
+}
+
+%typemap(in) signed char *REFERENCE (signed char dvalue), signed char &REFERENCE(signed char dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = (signed char) SvIV(tempsv);
+ $1 = &dvalue;
+}
+
+%typemap(in) bool *REFERENCE (bool dvalue), bool &REFERENCE(bool dvalue)
+{
+ SV *tempsv;
+ if (!SvROK($input)) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV($input);
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected an integer reference");
+ }
+ dvalue = SvIV(tempsv) ? true : false;
+ $1 = &dvalue;
+}
+
+%typemap(typecheck) int *REFERENCE, int &REFERENCE,
+ short *REFERENCE, short &REFERENCE,
+ long *REFERENCE, long &REFERENCE,
+ signed char *REFERENCE, signed char &REFERENCE,
+ bool *REFERENCE, bool &REFERENCE
+{
+ $1 = SvROK($input) && SvIOK(SvRV($input));
+}
+%typemap(typecheck) double *REFERENCE, double &REFERENCE,
+ float *REFERENCE, float &REFERENCE
+{
+ $1 = SvROK($input);
+ if($1) {
+ SV *tmpsv = SvRV($input);
+ $1 = SvNOK(tmpsv) || SvIOK(tmpsv);
+ }
+}
+%typemap(typecheck) unsigned int *REFERENCE, unsigned int &REFERENCE,
+ unsigned short *REFERENCE, unsigned short &REFERENCE,
+ unsigned long *REFERENCE, unsigned long &REFERENCE,
+ unsigned char *REFERENCE, unsigned char &REFERENCE
+{
+ $1 = SvROK($input);
+ if($1) {
+ SV *tmpsv = SvRV($input);
+ $1 = SvUOK(tmpsv) || SvIOK(tmpsv);
+ }
+}
+
+%typemap(argout) double *REFERENCE, double &REFERENCE,
+ float *REFERENCE, float &REFERENCE
+{
+ SV *tempsv;
+ tempsv = SvRV($arg);
+ if (!$1) SWIG_croak("expected a reference");
+ sv_setnv(tempsv, (double) *$1);
+}
+
+%typemap(argout) int *REFERENCE, int &REFERENCE,
+ short *REFERENCE, short &REFERENCE,
+ long *REFERENCE, long &REFERENCE,
+ signed char *REFERENCE, signed char &REFERENCE,
+ bool *REFERENCE, bool &REFERENCE
+{
+ SV *tempsv;
+ tempsv = SvRV($input);
+ if (!$1) SWIG_croak("expected a reference");
+ sv_setiv(tempsv, (IV) *$1);
+}
+
+%typemap(argout) unsigned int *REFERENCE, unsigned int &REFERENCE,
+ unsigned short *REFERENCE, unsigned short &REFERENCE,
+ unsigned long *REFERENCE, unsigned long &REFERENCE,
+ unsigned char *REFERENCE, unsigned char &REFERENCE
+{
+ SV *tempsv;
+ tempsv = SvRV($input);
+ if (!$1) SWIG_croak("expected a reference");
+ sv_setuv(tempsv, (UV) *$1);
+}
diff --git a/contrib/tools/swig/Lib/perl5/typemaps.i b/contrib/tools/swig/Lib/perl5/typemaps.i
new file mode 100644
index 0000000000..3e1f60d904
--- /dev/null
+++ b/contrib/tools/swig/Lib/perl5/typemaps.i
@@ -0,0 +1,371 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.i
+ *
+ * The SWIG typemap library provides a language independent mechanism for
+ * supporting output arguments, input values, and other C function
+ * calling mechanisms. The primary use of the library is to provide a
+ * better interface to certain C function--especially those involving
+ * pointers.
+ * ----------------------------------------------------------------------------- */
+
+#if !defined(SWIG_USE_OLD_TYPEMAPS)
+%include <typemaps/typemaps.swg>
+#else
+
+
+// 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);
+
+*/
+
+%define INPUT_TYPEMAP(type, converter)
+%typemap(in) type *INPUT(type temp), type &INPUT(type temp) {
+ temp = (type) converter($input);
+ $1 = &temp;
+}
+%typemap(typecheck) type *INPUT = type;
+%typemap(typecheck) type &INPUT = type;
+%enddef
+
+INPUT_TYPEMAP(float, SvNV);
+INPUT_TYPEMAP(double, SvNV);
+INPUT_TYPEMAP(int, SvIV);
+INPUT_TYPEMAP(long, SvIV);
+INPUT_TYPEMAP(short, SvIV);
+INPUT_TYPEMAP(signed char, SvIV);
+INPUT_TYPEMAP(unsigned int, SvUV);
+INPUT_TYPEMAP(unsigned long, SvUV);
+INPUT_TYPEMAP(unsigned short, SvUV);
+INPUT_TYPEMAP(unsigned char, SvUV);
+
+%typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) {
+ temp = SvIV($input) ? true : false;
+ $1 = &temp;
+}
+%typemap(typecheck) bool *INPUT = bool;
+%typemap(typecheck) bool &INPUT = bool;
+
+%typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) {
+ temp = strtoll(SvPV_nolen($input), 0, 0);
+ $1 = &temp;
+}
+%typemap(typecheck) long long *INPUT = long long;
+%typemap(typecheck) long long &INPUT = long long;
+
+%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) {
+ temp = strtoull(SvPV_nolen($input), 0, 0);
+ $1 = &temp;
+}
+%typemap(typecheck) unsigned long long *INPUT = unsigned long long;
+%typemap(typecheck) unsigned long long &INPUT = unsigned long long;
+
+
+#undef INPUT_TYPEMAP
+
+// 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, functions will return a Perl array.
+
+ 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).:
+
+ 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 Perl output of the function would be an array containing both
+output values.
+
+*/
+
+// Force the argument to be ignored.
+
+%typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp),
+ short *OUTPUT(short temp), short &OUTPUT(short temp),
+ long *OUTPUT(long temp), long &OUTPUT(long temp),
+ unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp),
+ unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp),
+ unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp),
+ unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp),
+ signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp),
+ bool *OUTPUT(bool temp), bool &OUTPUT(bool temp),
+ float *OUTPUT(float temp), float &OUTPUT(float temp),
+ double *OUTPUT(double temp), double &OUTPUT(double temp),
+ long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp),
+ unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp)
+"$1 = &temp;";
+
+%typemap(argout) int *OUTPUT, int &OUTPUT,
+ short *OUTPUT, short &OUTPUT,
+ long *OUTPUT, long &OUTPUT,
+ signed char *OUTPUT, signed char &OUTPUT,
+ bool *OUTPUT, bool &OUTPUT
+{
+ if (argvi >= items) {
+ EXTEND(sp, argvi+1);
+ }
+ $result = sv_newmortal();
+ sv_setiv($result,(IV) *($1));
+ argvi++;
+}
+
+%typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT,
+ unsigned short *OUTPUT, unsigned short &OUTPUT,
+ unsigned long *OUTPUT, unsigned long &OUTPUT,
+ unsigned char *OUTPUT, unsigned char &OUTPUT
+{
+ if (argvi >= items) {
+ EXTEND(sp, argvi+1);
+ }
+ $result = sv_newmortal();
+ sv_setuv($result,(UV) *($1));
+ argvi++;
+}
+
+
+
+%typemap(argout) float *OUTPUT, float &OUTPUT,
+ double *OUTPUT, double &OUTPUT
+{
+ if (argvi >= items) {
+ EXTEND(sp, argvi+1);
+ }
+ $result = sv_newmortal();
+ sv_setnv($result,(double) *($1));
+ argvi++;
+}
+
+%typemap(argout) long long *OUTPUT, long long &OUTPUT {
+ char temp[256];
+ if (argvi >= items) {
+ EXTEND(sp, argvi+1);
+ }
+ sprintf(temp,"%lld", (long long)*($1));
+ $result = sv_newmortal();
+ sv_setpv($result,temp);
+ argvi++;
+}
+
+%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT {
+ char temp[256];
+ if (argvi >= items) {
+ EXTEND(sp, argvi+1);
+ }
+ sprintf(temp,"%llu", (unsigned long long)*($1));
+ $result = sv_newmortal();
+ sv_setpv($result,temp);
+ argvi++;
+}
+
+// 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 Perl array.
+
+ 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.
+Rather, the modified input value shows up as the return value of the
+function. Thus, to apply this function to a Perl variable you might
+do this :
+
+ $x = neg($x);
+
+*/
+
+%typemap(in) int *INOUT = int *INPUT;
+%typemap(in) short *INOUT = short *INPUT;
+%typemap(in) long *INOUT = long *INPUT;
+%typemap(in) unsigned *INOUT = unsigned *INPUT;
+%typemap(in) unsigned short *INOUT = unsigned short *INPUT;
+%typemap(in) unsigned long *INOUT = unsigned long *INPUT;
+%typemap(in) unsigned char *INOUT = unsigned char *INPUT;
+%typemap(in) signed char *INOUT = signed char *INPUT;
+%typemap(in) bool *INOUT = bool *INPUT;
+%typemap(in) float *INOUT = float *INPUT;
+%typemap(in) double *INOUT = double *INPUT;
+%typemap(in) long long *INOUT = long long *INPUT;
+%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT;
+
+%typemap(in) int &INOUT = int &INPUT;
+%typemap(in) short &INOUT = short &INPUT;
+%typemap(in) long &INOUT = long &INPUT;
+%typemap(in) unsigned &INOUT = unsigned &INPUT;
+%typemap(in) unsigned short &INOUT = unsigned short &INPUT;
+%typemap(in) unsigned long &INOUT = unsigned long &INPUT;
+%typemap(in) unsigned char &INOUT = unsigned char &INPUT;
+%typemap(in) signed char &INOUT = signed char &INPUT;
+%typemap(in) bool &INOUT = bool &INPUT;
+%typemap(in) float &INOUT = float &INPUT;
+%typemap(in) double &INOUT = double &INPUT;
+%typemap(in) long long &INOUT = long long &INPUT;
+%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT;
+
+
+%typemap(argout) int *INOUT = int *OUTPUT;
+%typemap(argout) short *INOUT = short *OUTPUT;
+%typemap(argout) long *INOUT = long *OUTPUT;
+%typemap(argout) unsigned *INOUT = unsigned *OUTPUT;
+%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT;
+%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
+%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
+%typemap(argout) signed char *INOUT = signed char *OUTPUT;
+%typemap(argout) bool *INOUT = bool *OUTPUT;
+%typemap(argout) float *INOUT = float *OUTPUT;
+%typemap(argout) double *INOUT = double *OUTPUT;
+%typemap(argout) long long *INOUT = long long *OUTPUT;
+%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
+
+
+%typemap(argout) int &INOUT = int &OUTPUT;
+%typemap(argout) short &INOUT = short &OUTPUT;
+%typemap(argout) long &INOUT = long &OUTPUT;
+%typemap(argout) unsigned &INOUT = unsigned &OUTPUT;
+%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT;
+%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT;
+%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT;
+%typemap(argout) signed char &INOUT = signed char &OUTPUT;
+%typemap(argout) bool &INOUT = bool &OUTPUT;
+%typemap(argout) float &INOUT = float &OUTPUT;
+%typemap(argout) double &INOUT = double &OUTPUT;
+%typemap(argout) long long &INOUT = long long &OUTPUT;
+%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT;
+
+
+/* Overloading information */
+
+%typemap(typecheck) double *INOUT = double;
+%typemap(typecheck) bool *INOUT = bool;
+%typemap(typecheck) signed char *INOUT = signed char;
+%typemap(typecheck) unsigned char *INOUT = unsigned char;
+%typemap(typecheck) unsigned long *INOUT = unsigned long;
+%typemap(typecheck) unsigned short *INOUT = unsigned short;
+%typemap(typecheck) unsigned int *INOUT = unsigned int;
+%typemap(typecheck) long *INOUT = long;
+%typemap(typecheck) short *INOUT = short;
+%typemap(typecheck) int *INOUT = int;
+%typemap(typecheck) float *INOUT = float;
+%typemap(typecheck) long long *INOUT = long long;
+%typemap(typecheck) unsigned long long *INOUT = unsigned long long;
+
+%typemap(typecheck) double &INOUT = double;
+%typemap(typecheck) bool &INOUT = bool;
+%typemap(typecheck) signed char &INOUT = signed char;
+%typemap(typecheck) unsigned char &INOUT = unsigned char;
+%typemap(typecheck) unsigned long &INOUT = unsigned long;
+%typemap(typecheck) unsigned short &INOUT = unsigned short;
+%typemap(typecheck) unsigned int &INOUT = unsigned int;
+%typemap(typecheck) long &INOUT = long;
+%typemap(typecheck) short &INOUT = short;
+%typemap(typecheck) int &INOUT = int;
+%typemap(typecheck) float &INOUT = float;
+%typemap(typecheck) long long &INOUT = long long;
+%typemap(typecheck) unsigned long long &INOUT = unsigned long long;
+
+#endif
+
+// --------------------------------------------------------------------
+// Special types
+// --------------------------------------------------------------------
+
+
+%include <reference.i>
diff --git a/contrib/tools/swig/Lib/python/README b/contrib/tools/swig/Lib/python/README
new file mode 100644
index 0000000000..70968e7dd5
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/README
@@ -0,0 +1,103 @@
+/* -----------------------------------------------------------------------------
+ *
+ * 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
+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)
diff --git a/contrib/tools/swig/Lib/python/builtin.swg b/contrib/tools/swig/Lib/python/builtin.swg
new file mode 100644
index 0000000000..5cff6835f8
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/builtin.swg
@@ -0,0 +1,764 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGINTERN Py_hash_t
+SwigPyObject_hash(PyObject *obj) {
+ SwigPyObject *sobj = (SwigPyObject *)obj;
+ void *ptr = sobj->ptr;
+#if PY_VERSION_HEX < 0x03020000
+ return (Py_hash_t)(Py_ssize_t)ptr;
+#else
+ return (Py_hash_t)ptr;
+#endif
+}
+
+SWIGINTERN Py_hash_t
+SWIG_PyNumber_AsPyHash(PyObject *obj) {
+ Py_hash_t result = -1;
+#if PY_VERSION_HEX < 0x03020000
+ if (PyInt_Check(obj))
+ result = PyInt_AsLong(obj);
+ else if (PyLong_Check(obj))
+ result = PyLong_AsLong(obj);
+#else
+ if (PyNumber_Check(obj))
+ result = PyNumber_AsSsize_t(obj, NULL);
+#endif
+ else
+ PyErr_Format(PyExc_TypeError, "Wrong type for hash function");
+ return PyErr_Occurred() ? -1 : result;
+}
+
+SWIGINTERN int
+SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) {
+ PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name);
+ return -1;
+}
+
+SWIGINTERN void
+SwigPyBuiltin_BadDealloc(PyObject *obj) {
+ SwigPyObject *sobj = (SwigPyObject *)obj;
+ if (sobj->own) {
+ PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name);
+ }
+}
+
+typedef struct {
+ PyCFunction get;
+ PyCFunction set;
+} SwigPyGetSet;
+
+SWIGINTERN PyObject *
+SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) {
+ SwigPyGetSet *getset;
+ PyObject *tuple, *result;
+ if (!closure)
+ return SWIG_Py_Void();
+ getset = (SwigPyGetSet *)closure;
+ if (!getset->get)
+ return SWIG_Py_Void();
+ tuple = PyTuple_New(0);
+ assert(tuple);
+ result = (*getset->get)(obj, tuple);
+ Py_DECREF(tuple);
+ return result;
+}
+
+SWIGINTERN PyObject *
+SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) {
+ SwigPyGetSet *getset;
+ PyObject *result;
+ if (!closure)
+ return SWIG_Py_Void();
+ getset = (SwigPyGetSet *)closure;
+ if (!getset->get)
+ return SWIG_Py_Void();
+ result = (*getset->get)(obj, NULL);
+ return result;
+}
+
+SWIGINTERN int
+SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) {
+ SwigPyGetSet *getset;
+ PyObject *tuple, *result;
+ if (!closure) {
+ PyErr_Format(PyExc_TypeError, "Missing getset closure");
+ return -1;
+ }
+ getset = (SwigPyGetSet *)closure;
+ if (!getset->set) {
+ PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
+ return -1;
+ }
+ tuple = PyTuple_New(1);
+ assert(tuple);
+ Py_INCREF(val);
+ PyTuple_SET_ITEM(tuple, 0, val);
+ result = (*getset->set)(obj, tuple);
+ Py_DECREF(tuple);
+ Py_XDECREF(result);
+ return result ? 0 : -1;
+}
+
+SWIGINTERN int
+SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) {
+ SwigPyGetSet *getset;
+ PyObject *result;
+ if (!closure) {
+ PyErr_Format(PyExc_TypeError, "Missing getset closure");
+ return -1;
+ }
+ getset = (SwigPyGetSet *)closure;
+ if (!getset->set) {
+ PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
+ return -1;
+ }
+ result = (*getset->set)(obj, val);
+ Py_XDECREF(result);
+ return result ? 0 : -1;
+}
+
+SWIGINTERN void
+SwigPyStaticVar_dealloc(PyDescrObject *descr) {
+ PyObject_GC_UnTrack(descr);
+ Py_XDECREF(PyDescr_TYPE(descr));
+ Py_XDECREF(PyDescr_NAME(descr));
+ PyObject_GC_Del(descr);
+}
+
+SWIGINTERN PyObject *
+SwigPyStaticVar_repr(PyGetSetDescrObject *descr) {
+#if PY_VERSION_HEX >= 0x03000000
+
+ return PyUnicode_FromFormat("<class attribute '%S' of type '%s'>", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
+#else
+ return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
+#endif
+}
+
+SWIGINTERN int
+SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) {
+ PyDescrObject *descr;
+ descr = (PyDescrObject *)self;
+ Py_VISIT((PyObject*) PyDescr_TYPE(descr));
+ return 0;
+}
+
+SWIGINTERN PyObject *
+SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) {
+ if (descr->d_getset->get != NULL)
+ return descr->d_getset->get(obj, descr->d_getset->closure);
+#if PY_VERSION_HEX >= 0x03000000
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
+#else
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
+#endif
+ return NULL;
+}
+
+SWIGINTERN int
+SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) {
+ if (descr->d_getset->set != NULL)
+ return descr->d_getset->set(obj, value, descr->d_getset->closure);
+#if PY_VERSION_HEX >= 0x03000000
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
+#else
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
+#endif
+ return -1;
+}
+
+SWIGINTERN int
+SwigPyObjectType_setattro(PyObject *typeobject, PyObject *name, PyObject *value) {
+ PyObject *attribute;
+ PyTypeObject *type;
+ descrsetfunc local_set;
+
+ assert(PyType_Check(typeobject));
+ type = (PyTypeObject *)typeobject;
+ attribute = _PyType_Lookup(type, name);
+ if (attribute != NULL) {
+ /* Implement descriptor functionality, if any */
+ local_set = attribute->ob_type->tp_descr_set;
+ if (local_set != NULL)
+ return local_set(attribute, (PyObject *)type, value);
+#if PY_VERSION_HEX >= 0x03000000
+ PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name);
+#else
+ PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name));
+#endif
+ } else {
+#if PY_VERSION_HEX >= 0x03000000
+ PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name);
+#else
+ PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name));
+#endif
+ }
+
+ return -1;
+}
+
+SWIGINTERN PyTypeObject*
+SwigPyStaticVar_Type(void) {
+ static PyTypeObject staticvar_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp = {
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /* ob_size */
+#endif
+ "swig_static_var_getset_descriptor", /* tp_name */
+ sizeof(PyGetSetDescrObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX < 0x030800b4
+ (printfunc)0, /* tp_print */
+#else
+ (Py_ssize_t)0, /* tp_vectorcall_offset */
+#endif
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ (reprfunc)SwigPyStaticVar_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */
+ 0, /* tp_doc */
+ SwigPyStaticVar_traverse, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */
+ (descrsetfunc)SwigPyStaticVar_set, /* 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 */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
+ 0, /* tp_print */
+#endif
+#ifdef COUNT_ALLOCS
+ 0, /* tp_allocs */
+ 0, /* tp_frees */
+ 0, /* tp_maxalloc */
+ 0, /* tp_prev */
+ 0 /* tp_next */
+#endif
+ };
+ staticvar_type = tmp;
+ type_init = 1;
+ if (PyType_Ready(&staticvar_type) < 0)
+ return NULL;
+ }
+ return &staticvar_type;
+}
+
+SWIGINTERN PyTypeObject*
+SwigPyObjectType(void) {
+ static char swigpyobjecttype_doc[] = "Metaclass for SWIG wrapped types";
+ static PyTypeObject swigpyobjecttype_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp = {
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /* ob_size */
+#endif
+ "SwigPyObjectType", /* tp_name */
+ PyType_Type.tp_basicsize, /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+#if PY_VERSION_HEX < 0x030800b4
+ (printfunc)0, /* tp_print */
+#else
+ (Py_ssize_t)0, /* tp_vectorcall_offset */
+#endif
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ SwigPyObjectType_setattro, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */
+ swigpyobjecttype_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 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 */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
+ 0, /* tp_print */
+#endif
+#ifdef COUNT_ALLOCS
+ 0, /* tp_allocs */
+ 0, /* tp_frees */
+ 0, /* tp_maxalloc */
+ 0, /* tp_prev */
+ 0 /* tp_next */
+#endif
+ };
+ swigpyobjecttype_type = tmp;
+ type_init = 1;
+ swigpyobjecttype_type.tp_base = &PyType_Type;
+ if (PyType_Ready(&swigpyobjecttype_type) < 0)
+ return NULL;
+ }
+ return &swigpyobjecttype_type;
+}
+
+SWIGINTERN PyGetSetDescrObject *
+SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
+
+ PyGetSetDescrObject *descr;
+ descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0);
+ assert(descr);
+ Py_XINCREF(type);
+ PyDescr_TYPE(descr) = type;
+ PyDescr_NAME(descr) = PyString_InternFromString(getset->name);
+ descr->d_getset = getset;
+ if (PyDescr_NAME(descr) == NULL) {
+ Py_DECREF(descr);
+ descr = NULL;
+ }
+ return descr;
+}
+
+SWIGINTERN void
+SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) {
+ Py_ssize_t base_count = 0;
+ PyTypeObject **b;
+ PyObject *tuple;
+ Py_ssize_t i;
+
+ if (!bases[0]) {
+ bases[0] = SwigPyObject_type();
+ bases[1] = NULL;
+ }
+ type->tp_base = bases[0];
+ Py_INCREF((PyObject *)bases[0]);
+ for (b = bases; *b != NULL; ++b)
+ ++base_count;
+ tuple = PyTuple_New(base_count);
+ for (i = 0; i < base_count; ++i) {
+ Py_INCREF((PyObject *)bases[i]);
+ PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]);
+ }
+ type->tp_bases = tuple;
+}
+
+SWIGINTERN PyObject *
+SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) {
+ PyObject *result;
+ result = (PyObject *)SWIG_Python_GetSwigThis(self);
+ Py_XINCREF(result);
+ return result;
+}
+
+SWIGINTERN void
+SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype)
+{
+#if PY_VERSION_HEX >= 0x030900a4
+ Py_SET_TYPE(type, metatype);
+#else
+ Py_TYPE(type) = metatype;
+#endif
+}
+
+
+/* Start of callback function macros for use in PyTypeObject */
+
+typedef PyObject *(*SwigPyWrapperFunction)(PyObject *, PyObject *);
+
+#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_unaryfunc_closure(PyObject *a) { \
+ return SwigPyBuiltin_unaryfunc_closure(wrapper, a); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_unaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ return wrapper(a, NULL);
+}
+
+#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \
+SWIGINTERN void \
+wrapper##_destructor_closure(PyObject *a) { \
+ SwigPyBuiltin_destructor_closure(wrapper, #wrapper, a); \
+}
+SWIGINTERN void
+SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrappername, PyObject *a) {
+ SwigPyObject *sobj;
+ sobj = (SwigPyObject *)a;
+ Py_XDECREF(sobj->dict);
+ if (sobj->own) {
+ PyObject *o;
+ PyObject *type = 0, *value = 0, *traceback = 0;
+ PyErr_Fetch(&type, &value, &traceback);
+ o = wrapper(a, NULL);
+ if (!o) {
+ PyObject *deallocname = PyString_FromString(wrappername);
+ PyErr_WriteUnraisable(deallocname);
+ Py_DECREF(deallocname);
+ }
+ PyErr_Restore(type, value, traceback);
+ Py_XDECREF(o);
+ }
+ if (PyType_IS_GC(a->ob_type)) {
+ PyObject_GC_Del(a);
+ } else {
+ PyObject_Del(a);
+ }
+}
+
+#define SWIGPY_INQUIRY_CLOSURE(wrapper) \
+SWIGINTERN int \
+wrapper##_inquiry_closure(PyObject *a) { \
+ return SwigPyBuiltin_inquiry_closure(wrapper, a); \
+}
+SWIGINTERN int
+SwigPyBuiltin_inquiry_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ PyObject *pyresult;
+ int result;
+ pyresult = wrapper(a, NULL);
+ result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0;
+ Py_XDECREF(pyresult);
+ return result;
+}
+
+#define SWIGPY_GETITERFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_getiterfunc_closure(PyObject *a) { \
+ return SwigPyBuiltin_getiterfunc_closure(wrapper, a); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_getiterfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ return wrapper(a, NULL);
+}
+
+#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_binaryfunc_closure(PyObject *a, PyObject *b) { \
+ return SwigPyBuiltin_binaryfunc_closure(wrapper, a, b); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) {
+ PyObject *tuple, *result;
+ tuple = PyTuple_New(1);
+ assert(tuple);
+ Py_INCREF(b);
+ PyTuple_SET_ITEM(tuple, 0, b);
+ result = wrapper(a, tuple);
+ Py_DECREF(tuple);
+ return result;
+}
+
+typedef ternaryfunc ternarycallfunc;
+
+#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_ternaryfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \
+ return SwigPyBuiltin_ternaryfunc_closure(wrapper, a, b, c); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
+ PyObject *tuple, *result;
+ tuple = PyTuple_New(2);
+ assert(tuple);
+ Py_INCREF(b);
+ PyTuple_SET_ITEM(tuple, 0, b);
+ Py_INCREF(c);
+ PyTuple_SET_ITEM(tuple, 1, c);
+ result = wrapper(a, tuple);
+ Py_DECREF(tuple);
+ return result;
+}
+
+#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_ternarycallfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \
+ return SwigPyBuiltin_ternarycallfunc_closure(wrapper, a, b, c); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_ternarycallfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
+ (void) c;
+ return wrapper(a, b);
+}
+
+#define SWIGPY_LENFUNC_CLOSURE(wrapper) \
+SWIGINTERN Py_ssize_t \
+wrapper##_lenfunc_closure(PyObject *a) { \
+ return SwigPyBuiltin_lenfunc_closure(wrapper, a); \
+}
+SWIGINTERN Py_ssize_t
+SwigPyBuiltin_lenfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ PyObject *resultobj;
+ Py_ssize_t result;
+ resultobj = wrapper(a, NULL);
+ result = PyNumber_AsSsize_t(resultobj, NULL);
+ Py_DECREF(resultobj);
+ return result;
+}
+
+#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_ssizessizeargfunc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \
+ return SwigPyBuiltin_ssizessizeargfunc_closure(wrapper, a, b, c); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_ssizessizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c) {
+ PyObject *tuple, *result;
+ tuple = PyTuple_New(2);
+ assert(tuple);
+ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
+ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));
+ result = wrapper(a, tuple);
+ Py_DECREF(tuple);
+ return result;
+}
+
+#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \
+SWIGINTERN int \
+wrapper##_ssizessizeobjargproc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \
+ return SwigPyBuiltin_ssizessizeobjargproc_closure(wrapper, a, b, c, d); \
+}
+SWIGINTERN int
+SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) {
+ PyObject *tuple, *resultobj;
+ int result;
+ tuple = PyTuple_New(d ? 3 : 2);
+ assert(tuple);
+ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
+ PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));
+ if (d) {
+ Py_INCREF(d);
+ PyTuple_SET_ITEM(tuple, 2, d);
+ }
+ resultobj = wrapper(a, tuple);
+ result = resultobj ? 0 : -1;
+ Py_DECREF(tuple);
+ Py_XDECREF(resultobj);
+ return result;
+}
+
+#define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \
+ return SwigPyBuiltin_funpack_ssizeargfunc_closure(wrapper, a, b); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_funpack_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) {
+ PyObject *tuple, *result;
+ tuple = PyTuple_New(1);
+ assert(tuple);
+ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
+ result = wrapper(a, tuple);
+ Py_DECREF(tuple);
+ return result;
+}
+
+#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \
+ return SwigPyBuiltin_ssizeargfunc_closure(wrapper, a, b); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) {
+ PyObject *arg, *result;
+ arg = _PyLong_FromSsize_t(b);
+ result = wrapper(a, arg);
+ Py_DECREF(arg);
+ return result;
+}
+
+#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \
+SWIGINTERN int \
+wrapper##_ssizeobjargproc_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \
+ return SwigPyBuiltin_ssizeobjargproc_closure(wrapper, a, b, c); \
+}
+SWIGINTERN int
+SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, PyObject *c) {
+ PyObject *tuple, *resultobj;
+ int result;
+ tuple = PyTuple_New(2);
+ assert(tuple);
+ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
+ Py_INCREF(c);
+ PyTuple_SET_ITEM(tuple, 1, c);
+ resultobj = wrapper(a, tuple);
+ result = resultobj ? 0 : -1;
+ Py_XDECREF(resultobj);
+ Py_DECREF(tuple);
+ return result;
+}
+
+#define SWIGPY_OBJOBJPROC_CLOSURE(wrapper) \
+SWIGINTERN int \
+wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \
+ return SwigPyBuiltin_objobjproc_closure(wrapper, a, b); \
+}
+SWIGINTERN int
+SwigPyBuiltin_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) {
+ int result;
+ PyObject *pyresult;
+ PyObject *tuple;
+ tuple = PyTuple_New(1);
+ assert(tuple);
+ Py_INCREF(b);
+ PyTuple_SET_ITEM(tuple, 0, b);
+ pyresult = wrapper(a, tuple);
+ result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1;
+ Py_XDECREF(pyresult);
+ Py_DECREF(tuple);
+ return result;
+}
+
+#define SWIGPY_FUNPACK_OBJOBJPROC_CLOSURE(wrapper) \
+SWIGINTERN int \
+wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \
+ return SwigPyBuiltin_funpack_objobjproc_closure(wrapper, a, b); \
+}
+SWIGINTERN int
+SwigPyBuiltin_funpack_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) {
+ int result;
+ PyObject *pyresult;
+ pyresult = wrapper(a, b);
+ result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1;
+ Py_XDECREF(pyresult);
+ return result;
+}
+
+#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \
+SWIGINTERN int \
+wrapper##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \
+ return SwigPyBuiltin_objobjargproc_closure(wrapper, a, b, c); \
+}
+SWIGINTERN int
+SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
+ PyObject *tuple, *resultobj;
+ int result;
+ tuple = PyTuple_New(c ? 2 : 1);
+ assert(tuple);
+ Py_INCREF(b);
+ PyTuple_SET_ITEM(tuple, 0, b);
+ if (c) {
+ Py_INCREF(c);
+ PyTuple_SET_ITEM(tuple, 1, c);
+ }
+ resultobj = wrapper(a, tuple);
+ result = resultobj ? 0 : -1;
+ Py_XDECREF(resultobj);
+ Py_DECREF(tuple);
+ return result;
+}
+
+#define SWIGPY_REPRFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_reprfunc_closure(PyObject *a) { \
+ return SwigPyBuiltin_reprfunc_closure(wrapper, a); \
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_reprfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ return wrapper(a, NULL);
+}
+
+#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \
+SWIGINTERN Py_hash_t \
+wrapper##_hashfunc_closure(PyObject *a) { \
+ return SwigPyBuiltin_hashfunc_closure(wrapper, a); \
+}
+SWIGINTERN Py_hash_t
+SwigPyBuiltin_hashfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ PyObject *pyresult;
+ Py_hash_t result;
+ pyresult = wrapper(a, NULL);
+ if (!pyresult)
+ return -1;
+ result = SWIG_PyNumber_AsPyHash(pyresult);
+ Py_DECREF(pyresult);
+ return result;
+}
+
+#define SWIGPY_ITERNEXTFUNC_CLOSURE(wrapper) \
+SWIGINTERN PyObject * \
+wrapper##_iternextfunc_closure(PyObject *a) { \
+ return SwigPyBuiltin_iternextfunc_closure(wrapper, a);\
+}
+SWIGINTERN PyObject *
+SwigPyBuiltin_iternextfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
+ return wrapper(a, NULL);
+}
+
+/* End of callback function macros for use in PyTypeObject */
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/contrib/tools/swig/Lib/python/pyapi.swg b/contrib/tools/swig/Lib/python/pyapi.swg
new file mode 100644
index 0000000000..19e6979b56
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyapi.swg
@@ -0,0 +1,30 @@
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#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;
+ const char *name;
+ long lvalue;
+ double dvalue;
+ void *pvalue;
+ swig_type_info **ptype;
+} swig_const_info;
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/contrib/tools/swig/Lib/python/pybackward.swg b/contrib/tools/swig/Lib/python/pybackward.swg
new file mode 100644
index 0000000000..8305fc78b7
--- /dev/null
+++ b/contrib/tools/swig/Lib/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/contrib/tools/swig/Lib/python/pyclasses.swg b/contrib/tools/swig/Lib/python/pyclasses.swg
new file mode 100644
index 0000000000..31ebdd2a15
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyclasses.swg
@@ -0,0 +1,157 @@
+#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&};
+
+ %typemap(typecheck,precedence=SWIG_TYPECHECK_SWIGOBJECT,noblock=1) SwigPtr_PyObject const& "$1 = ($input != 0);"
+
+
+ /* 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)
+ {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ Py_XINCREF(_obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+
+ SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
+ {
+ if (initial_ref) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ Py_XINCREF(_obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+ }
+
+ SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
+ {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ Py_XINCREF(item._obj);
+ Py_XDECREF(_obj);
+ _obj = item._obj;
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return *this;
+ }
+
+ ~SwigPtr_PyObject()
+ {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ Py_XDECREF(_obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+
+ 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/contrib/tools/swig/Lib/python/pydocs.swg b/contrib/tools/swig/Lib/python/pydocs.swg
new file mode 100644
index 0000000000..5a25423d4c
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pydocs.swg
@@ -0,0 +1,45 @@
+
+// Documentation for use with the autodoc feature.
+
+#ifdef SWIG_DOC_DOXYGEN_STYLE
+%typemap(doc) SWIGTYPE "@param $1_name $1_type"
+%typemap(doc) SWIGTYPE * "@param $1_name $1_type"
+%typemap(doc) const SWIGTYPE & "@param $1_name $1_type"
+%typemap(doc) const SWIGTYPE && "@param $1_name $1_type"
+%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type"
+
+%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "@param $1_name $1_type (input/output)"
+%typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "@param $1_name $1_type (input)"
+%typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "@param $1_name $1_type (output)"
+#else
+%typemap(doc) SWIGTYPE "$1_name: $1_type"
+%typemap(doc) SWIGTYPE * "$1_name: $1_type"
+%typemap(doc) const SWIGTYPE & "$1_name: $1_type"
+%typemap(doc) const SWIGTYPE && "$1_name: $1_type"
+%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type"
+
+%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "$1_name: $1_type (input/output)"
+%typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "$1_name: $1_type (input)"
+%typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "$1_name: $1_type (output)"
+#endif
+
+
+// Types to use in Python documentation for the parameters of the given C++ type.
+%typemap(doctype) bool "boolean"
+
+%define int_doctype_for_cppint_type(cppint_type)
+ %typemap(doctype) cppint_type, unsigned cppint_type "int"
+%enddef
+%formacro(int_doctype_for_cppint_type, short, int, long, long long)
+
+%typemap(doctype) size_t "int"
+
+%typemap(doctype) enum SWIGTYPE "int"
+
+%typemap(doctype) float, double, long double "float"
+
+%typemap(doctype) char*, std::string "string"
+
+%typemap(doctype) SWIGTYPE "$1_basetype"
+%typemap(doctype) SWIGTYPE * "$typemap(doctype, $*1_ltype)"
+%typemap(doctype) SWIGTYPE & "$typemap(doctype, $*1_ltype)"
diff --git a/contrib/tools/swig/Lib/python/pyerrors.swg b/contrib/tools/swig/Lib/python/pyerrors.swg
new file mode 100644
index 0000000000..10b694cde6
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyerrors.swg
@@ -0,0 +1,107 @@
+/* -----------------------------------------------------------------------------
+ * 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) {
+ PyObject *old_str = PyObject_Str(value);
+ const char *tmp = SWIG_Python_str_AsChar(old_str);
+ PyErr_Clear();
+ Py_XINCREF(type);
+ if (tmp)
+ PyErr_Format(type, "%s %s", tmp, mesg);
+ else
+ PyErr_Format(type, "%s", mesg);
+ Py_DECREF(old_str);
+ Py_DECREF(value);
+ } else {
+ PyErr_SetString(PyExc_RuntimeError, mesg);
+ }
+}
+
+SWIGRUNTIME int
+SWIG_Python_TypeErrorOccurred(PyObject *obj)
+{
+ PyObject *error;
+ if (obj)
+ return 0;
+ error = PyErr_Occurred();
+ return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError);
+}
+
+SWIGRUNTIME void
+SWIG_Python_RaiseOrModifyTypeError(const char *message)
+{
+ if (SWIG_Python_TypeErrorOccurred(NULL)) {
+ /* Use existing TypeError to preserve stacktrace and enhance with given message */
+ PyObject *newvalue;
+ PyObject *type = NULL, *value = NULL, *traceback = NULL;
+ PyErr_Fetch(&type, &value, &traceback);
+#if PY_VERSION_HEX >= 0x03000000
+ newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message);
+#else
+ newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message);
+#endif
+ if (newvalue) {
+ Py_XDECREF(value);
+ PyErr_Restore(type, newvalue, traceback);
+ } else {
+ PyErr_Restore(type, value, traceback);
+ }
+ } else {
+ /* Raise TypeError using given message */
+ PyErr_SetString(PyExc_TypeError, message);
+ }
+}
diff --git a/contrib/tools/swig/Lib/python/pyfragments.swg b/contrib/tools/swig/Lib/python/pyfragments.swg
new file mode 100644
index 0000000000..535a45bdf2
--- /dev/null
+++ b/contrib/tools/swig/Lib/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/contrib/tools/swig/Lib/python/pyhead.swg b/contrib/tools/swig/Lib/python/pyhead.swg
new file mode 100644
index 0000000000..6f37160bb2
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyhead.swg
@@ -0,0 +1,75 @@
+/* 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 PyInt_FromSize_t(x) PyLong_FromSize_t(x)
+#define PyString_Check(name) PyBytes_Check(name)
+#define PyString_FromString(x) PyUnicode_FromString(x)
+#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
+#define PyString_AsString(str) PyBytes_AsString(str)
+#define PyString_Size(str) PyBytes_Size(str)
+#define PyString_InternFromString(key) PyUnicode_InternFromString(key)
+#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
+#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)
+
+#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
+
+
+SWIGINTERN char*
+SWIG_Python_str_AsChar(PyObject *str)
+{
+#if PY_VERSION_HEX >= 0x03030000
+ return (char *)PyUnicode_AsUTF8(str);
+#else
+ return PyString_AsString(str);
+#endif
+}
+
+/* Was useful for Python 3.0.x-3.2.x - now provided only for compatibility
+ * with any uses in user interface files. */
+#define SWIG_Python_str_DelForPy3(x)
+
+
+SWIGINTERN PyObject*
+SWIG_Python_str_FromChar(const char *c)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_FromString(c);
+#else
+ return PyString_FromString(c);
+#endif
+}
+
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
+
+/* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */
+# define SWIGPY_USE_CAPSULE
+#ifdef SWIGPYTHON_BUILTIN
+# define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule_builtin" SWIG_TYPE_TABLE_NAME
+#else
+# define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule" SWIG_TYPE_TABLE_NAME
+#endif
+# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION "." SWIGPY_CAPSULE_ATTR_NAME)
+
+#if PY_VERSION_HEX < 0x03020000
+#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
+#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
+#define Py_hash_t long
+#endif
diff --git a/contrib/tools/swig/Lib/python/pyinit.swg b/contrib/tools/swig/Lib/python/pyinit.swg
new file mode 100644
index 0000000000..6833b455aa
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyinit.swg
@@ -0,0 +1,325 @@
+/* ------------------------------------------------------------
+ * The start of the Python initialization function
+ * ------------------------------------------------------------ */
+
+%insert(init) "swiginit.swg"
+
+#if defined(SWIGPYTHON_BUILTIN)
+%fragment("<stddef.h>"); // For offsetof
+#endif
+
+#if defined SWIGPYTHON_FASTPROXY && !defined SWIGPYTHON_BUILTIN
+
+%insert(runtime) %{
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Method creation and docstring support functions */
+
+SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name);
+SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
+SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
+
+#ifdef __cplusplus
+}
+#endif
+%}
+
+#endif
+
+%init %{
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 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_InternalNewPointerObj(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);
+ }
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * Patch %callback methods' docstrings to hold the callback ptrs
+ * -----------------------------------------------------------------------------*/
+
+SWIGINTERN void
+SWIG_Python_FixMethods(PyMethodDef *methods, const 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) continue;
+ c = strstr(c, "swig_ptr: ");
+ if (c) {
+ int j;
+ const 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) {
+ void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+ if (ptr) {
+ 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;
+ memcpy(buff, methods[i].ml_doc, ldoc);
+ buff += ldoc;
+ memcpy(buff, "swig_ptr: ", 10);
+ buff += 10;
+ SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+ methods[i].ml_doc = ndoc;
+ }
+ }
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+%}
+
+#if defined SWIGPYTHON_FASTPROXY && !defined SWIGPYTHON_BUILTIN
+
+%init %{
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Method creation and docstring support functions
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * Function to find the method definition with the correct docstring for the
+ * proxy module as opposed to the low-level API
+ * ----------------------------------------------------------------------------- */
+
+SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) {
+ /* Find the function in the modified method table */
+ size_t offset = 0;
+ int found = 0;
+ while (SwigMethods_proxydocs[offset].ml_meth != NULL) {
+ if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {
+ found = 1;
+ break;
+ }
+ offset++;
+ }
+ /* Use the copy with the modified docstring if available */
+ return found ? &SwigMethods_proxydocs[offset] : NULL;
+}
+
+/* -----------------------------------------------------------------------------
+ * Wrapper of PyInstanceMethod_New() used in Python 3
+ * It is exported to the generated module, used for -fastproxy
+ * ----------------------------------------------------------------------------- */
+
+SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
+ if (PyCFunction_Check(func)) {
+ PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
+ PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
+ if (ml)
+ func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
+ }
+#if PY_VERSION_HEX >= 0x03000000
+ return PyInstanceMethod_New(func);
+#else
+ return PyMethod_New(func, NULL, NULL);
+#endif
+}
+
+/* -----------------------------------------------------------------------------
+ * Wrapper of PyStaticMethod_New()
+ * It is exported to the generated module, used for -fastproxy
+ * ----------------------------------------------------------------------------- */
+
+SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
+ if (PyCFunction_Check(func)) {
+ PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
+ PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
+ if (ml)
+ func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
+ }
+ return PyStaticMethod_New(func);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+%}
+
+#endif
+
+%init %{
+
+/* -----------------------------------------------------------------------------*
+ * Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+SWIGEXPORT
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject*
+#else
+ void
+#endif
+SWIG_init(void) {
+ PyObject *m, *d, *md, *globals;
+
+#if PY_VERSION_HEX >= 0x03000000
+ static struct PyModuleDef SWIG_module = {
+ PyModuleDef_HEAD_INIT,
+ SWIG_name,
+ NULL,
+ -1,
+ SwigMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+#endif
+
+#if defined(SWIGPYTHON_BUILTIN)
+ static SwigPyClientData SwigPyObject_clientdata = {0, 0, 0, 0, 0, 0, 0};
+ static PyGetSetDef this_getset_def = {
+ (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
+ };
+ static SwigPyGetSet thisown_getset_closure = {
+ SwigPyObject_own,
+ SwigPyObject_own
+ };
+ static PyGetSetDef thisown_getset_def = {
+ (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
+ };
+ PyTypeObject *builtin_pytype;
+ int builtin_base_count;
+ swig_type_info *builtin_basetype;
+ PyObject *tuple;
+ PyGetSetDescrObject *static_getset;
+ PyTypeObject *metatype;
+ PyTypeObject *swigpyobject;
+ SwigPyClientData *cd;
+ PyObject *public_interface, *public_symbol;
+ PyObject *this_descr;
+ PyObject *thisown_descr;
+ PyObject *self = 0;
+ int i;
+
+ (void)builtin_pytype;
+ (void)builtin_base_count;
+ (void)builtin_basetype;
+ (void)tuple;
+ (void)static_getset;
+ (void)self;
+
+ /* Metaclass is used to implement static member variables */
+ metatype = SwigPyObjectType();
+ assert(metatype);
+#endif
+
+ (void)globals;
+
+ /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */
+ SWIG_This();
+ SWIG_Python_TypeCache();
+ SwigPyPacked_type();
+#ifndef SWIGPYTHON_BUILTIN
+ SwigPyObject_type();
+#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(SWIG_name, SwigMethods);
+#endif
+
+ md = d = PyModule_GetDict(m);
+ (void)md;
+
+ SWIG_InitializeModule(0);
+
+#ifdef SWIGPYTHON_BUILTIN
+ swigpyobject = SwigPyObject_TypeOnce();
+
+ SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
+ assert(SwigPyObject_stype);
+ cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
+ if (!cd) {
+ SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
+ SwigPyObject_clientdata.pytype = swigpyobject;
+ } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) {
+ PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
+# if PY_VERSION_HEX >= 0x03000000
+ return NULL;
+# else
+ return;
+# endif
+ }
+
+ /* All objects have a 'this' attribute */
+ this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
+ (void)this_descr;
+
+ /* All objects have a 'thisown' attribute */
+ thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
+ (void)thisown_descr;
+
+ public_interface = PyList_New(0);
+ public_symbol = 0;
+ (void)public_symbol;
+
+ PyDict_SetItemString(md, "__all__", public_interface);
+ Py_DECREF(public_interface);
+ for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
+ SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
+ for (i = 0; swig_const_table[i].name != 0; ++i)
+ SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
+#endif
+
+ SWIG_InstallConstants(d,swig_const_table);
+%}
+
diff --git a/contrib/tools/swig/Lib/python/pymacros.swg b/contrib/tools/swig/Lib/python/pymacros.swg
new file mode 100644
index 0000000000..ab7bace5ba
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pymacros.swg
@@ -0,0 +1,4 @@
+%include <typemaps/swigmacros.swg>
+
+
+
diff --git a/contrib/tools/swig/Lib/python/pyopers.swg b/contrib/tools/swig/Lib/python/pyopers.swg
new file mode 100644
index 0000000000..fd2fcc5812
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyopers.swg
@@ -0,0 +1,264 @@
+/* ------------------------------------------------------------
+ * Overloaded operator support
+
+ The directives in this file apply whether or not you use the
+ -builtin option to SWIG, but operator overloads are particularly
+ attractive when using -builtin, because they are much faster
+ than named methods.
+
+ If you're using the -builtin option to SWIG, and you want to define
+ python operator overloads beyond the defaults defined in this file,
+ here's what you need to know:
+
+ There are two ways to define a python slot function: dispatch to a
+ statically defined function; or dispatch to a method defined on the
+ operand.
+
+ To dispatch to a statically defined function, use %feature("python:<slot>"),
+ where <slot> is the name of a field in a PyTypeObject, PyNumberMethods,
+ PyMappingMethods, PySequenceMethods, or PyBufferProcs. For example:
+
+ %feature("python:tp_hash") MyClass "myHashFunc";
+
+ class MyClass {
+ public:
+ ...
+ };
+
+ %{
+ // Note: Py_hash_t was introduced in Python 3.2
+ static Py_hash_t myHashFunc(PyObject *pyobj) {
+ MyClass *cobj;
+ // Convert pyobj to cobj
+ return (cobj->field1 * (cobj->field2 << 7));
+ }
+ %}
+
+ NOTE: It is the responsibility of the programmer (that's you) to ensure
+ that a statically defined slot function has the correct signature.
+
+ If, instead, you want to dispatch to an instance method, you can
+ use %feature("python:slot"). For example:
+
+ %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
+
+ class MyClass {
+ public:
+ Py_hash_t myHashFunc () const;
+ ...
+ };
+
+ NOTE: Some python slots use a method signature which does not
+ match the signature of SWIG-wrapped methods. For those slots,
+ SWIG will automatically generate a "closure" function to re-marshall
+ the arguments before dispatching to the wrapped method. Setting
+ the "functype" attribute of the feature enables SWIG to generate
+ a correct closure function.
+
+ --------------------------------------------------------------
+
+ The tp_richcompare slot is a special case: SWIG automatically generates
+ a rich compare function for all wrapped types. If a type defines C++
+ operator overloads for comparison (operator==, operator<, etc.), they
+ will be called from the generated rich compare function. If you
+ want to explicitly choose a method to handle a certain comparison
+ operation, you may use a different feature, %feature("python:compare")
+ like this:
+
+ %feature("python:compare", "Py_LT") MyClass::lessThan;
+
+ class MyClass {
+ public:
+ bool lessThan(const MyClass& other) const;
+ ...
+ };
+
+ ... where "Py_LT" is one of the rich comparison opcodes defined in the
+ python header file object.h.
+
+ If there's no method defined to handle a particular comparison operation,
+ the default behavior is to compare pointer values of the wrapped
+ C++ objects.
+
+ --------------------------------------------------------------
+
+
+ For more information about python slots, including their names and
+ signatures, you may refer to the python documentation :
+
+ http://docs.python.org/c-api/typeobj.html
+
+ * ------------------------------------------------------------ */
+
+
+#ifdef __cplusplus
+
+#if defined(SWIGPYTHON_BUILTIN)
+#define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:slot", #slt, functype=#functp) oper; %feature("python:slot", #slt, functype=#functp) pyname;
+#define %pycompare(pyname,oper,comptype) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:compare", #comptype) oper; %feature("python:compare", #comptype) pyname;
+#else
+#define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper
+#define %pycompare(pyname,oper,comptype) %pybinoperator(pyname,oper,,comptype)
+#endif
+
+%pybinoperator(__add__, *::operator+, binaryfunc, nb_add);
+%pybinoperator(__pos__, *::operator+(), unaryfunc, nb_positive);
+%pybinoperator(__pos__, *::operator+() const, unaryfunc, nb_positive);
+%pybinoperator(__sub__, *::operator-, binaryfunc, nb_subtract);
+%pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative);
+%pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative);
+%pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply);
+%pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder);
+%pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift);
+%pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift);
+%pybinoperator(__and__, *::operator&, binaryfunc, nb_and);
+%pybinoperator(__or__, *::operator|, binaryfunc, nb_or);
+%pybinoperator(__xor__, *::operator^, binaryfunc, nb_xor);
+%pycompare(__lt__, *::operator<, Py_LT);
+%pycompare(__le__, *::operator<=, Py_LE);
+%pycompare(__gt__, *::operator>, Py_GT);
+%pycompare(__ge__, *::operator>=, Py_GE);
+%pycompare(__eq__, *::operator==, Py_EQ);
+%pycompare(__ne__, *::operator!=, Py_NE);
+
+/* Special cases */
+%rename(__invert__) *::operator~;
+%feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~;
+%rename(__call__) *::operator();
+%feature("python:slot", "tp_call", functype="ternarycallfunc") *::operator();
+
+#if defined(SWIGPYTHON_BUILTIN)
+%pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero);
+%pybinoperator(__truediv__, *::operator/ , binaryfunc, nb_divide);
+#else
+%feature("shadow") *::operator bool %{
+def __nonzero__(self):
+ return $action(self)
+__bool__ = __nonzero__
+%};
+%rename(__nonzero__) *::operator bool;
+%feature("shadow") *::operator/ %{
+def __truediv__(self, *args):
+ return $action(self, *args)
+__div__ = __truediv__
+%};
+%rename(__truediv__) *::operator/;
+%pythonmaybecall *::operator/;
+#endif
+
+/* 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 'this' pointer, and assigning
+ it to the returning object:
+
+ %feature("del") *::Operator; // disables ownership by generating SWIG_POINTER_DISOWN
+ %feature("new") *::Operator; // claims ownership by generating SWIG_POINTER_OWN
+
+ 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","0") A::operator+=;
+ %feature("new","0") 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+=;
+
+ The default behaviour assumes that the 'this' pointer's memory is
+ already owned by the SWIG object; it relinquishes ownership then
+ takes it back. This may not be the case though as the SWIG object
+ might be owned by memory managed elsewhere, eg after calling a
+ function that returns a C++ reference. In such case you will need
+ to use the features above to recover the old behaviour too.
+*/
+
+#if defined(SWIGPYTHON_BUILTIN)
+#define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %feature("python:slot", #slt, functype=#functp) Oper; %rename(SwigPyOper) Oper
+#else
+#define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper
+#endif
+
+%pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add);
+%pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract);
+%pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply);
+%pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder);
+%pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and);
+%pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or);
+%pyinplaceoper(__ixor__ , *::operator ^=, binaryfunc, nb_inplace_xor);
+%pyinplaceoper(__ilshift__, *::operator <<=, binaryfunc, nb_inplace_lshift);
+%pyinplaceoper(__irshift__, *::operator >>=, binaryfunc, nb_inplace_rshift);
+
+/* Special cases */
+#if defined(SWIGPYTHON_BUILTIN)
+%pyinplaceoper(__itruediv__ , *::operator /=, binaryfunc, nb_inplace_divide);
+#else
+%delobject *::operator /=;
+%newobject *::operator /=;
+%feature("shadow") *::operator /= %{
+def __itruediv__(self, *args):
+ return $action(self, *args)
+__idiv__ = __itruediv__
+%};
+%rename(__itruediv__) *::operator /=;
+#endif
+
+/* 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(truediv);
+%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/contrib/tools/swig/Lib/python/pyprimtypes.swg b/contrib/tools/swig/Lib/python/pyprimtypes.swg
new file mode 100644
index 0000000000..6a01af17cf
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyprimtypes.swg
@@ -0,0 +1,353 @@
+/* ------------------------------------------------------------
+ * Primitive Types
+ * ------------------------------------------------------------ */
+
+/* boolean */
+
+%fragment(SWIG_From_frag(bool),"header") {
+SWIGINTERNINLINE PyObject*
+ SWIG_From_dec(bool)(bool value)
+{
+ return PyBool_FromLong(value ? 1 : 0);
+}
+}
+
+#ifdef SWIG_PYTHON_LEGACY_BOOL
+// Default prior to SWIG 3.0.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;
+}
+}
+#else
+%fragment(SWIG_AsVal_frag(bool),"header",
+ fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(PyObject *obj, bool *val)
+{
+ int r;
+ if (!PyBool_Check(obj))
+ return SWIG_ERROR;
+ r = PyObject_IsTrue(obj);
+ if (r == -1)
+ return SWIG_ERROR;
+ if (val) *val = r ? true : false;
+ return SWIG_OK;
+}
+}
+#endif
+
+/* int */
+
+%fragment(SWIG_From_frag(int),"header") {
+SWIGINTERNINLINE PyObject*
+ SWIG_From_dec(int)(int value)
+{
+ return PyInt_FromLong((long) value);
+}
+}
+
+/* unsigned int */
+
+%fragment(SWIG_From_frag(unsigned int),"header") {
+SWIGINTERNINLINE PyObject*
+ SWIG_From_dec(unsigned int)(unsigned int value)
+{
+ return PyInt_FromSize_t((size_t) value);
+}
+}
+
+/* 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 PY_VERSION_HEX < 0x03000000
+ if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else
+%#endif
+ if (PyLong_Check(obj)) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ return SWIG_OverflowError;
+ }
+ }
+%#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 PY_VERSION_HEX < 0x03000000
+ if (PyInt_Check(obj)) {
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else
+%#endif
+ if (PyLong_Check(obj)) {
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ return SWIG_OverflowError;
+ }
+ }
+%#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_LongLongAvailable") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+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));
+}
+%#endif
+}
+
+%fragment(SWIG_AsVal_frag(long long),"header",
+ fragment=SWIG_AsVal_frag(long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="SWIG_LongLongAvailable") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+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();
+ res = SWIG_OverflowError;
+ }
+ } 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))
+ return SWIG_OverflowError;
+ 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;
+}
+%#endif
+}
+
+/* unsigned long long */
+
+%fragment(SWIG_From_frag(unsigned long long),"header",
+ fragment="SWIG_LongLongAvailable") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+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));
+}
+%#endif
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long long),"header",
+ fragment=SWIG_AsVal_frag(unsigned long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="SWIG_LongLongAvailable") {
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+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();
+ res = SWIG_OverflowError;
+ }
+ } 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))
+ return SWIG_OverflowError;
+ 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;
+}
+%#endif
+}
+
+/* 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;
+%#if PY_VERSION_HEX < 0x03000000
+ } else if (PyInt_Check(obj)) {
+ if (val) *val = (double) PyInt_AsLong(obj);
+ return SWIG_OK;
+%#endif
+ } 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/contrib/tools/swig/Lib/python/pyrun.swg b/contrib/tools/swig/Lib/python/pyrun.swg
new file mode 100644
index 0000000000..6b119be1c4
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyrun.swg
@@ -0,0 +1,1913 @@
+/* -----------------------------------------------------------------------------
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
+
+#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */
+# error "This version of SWIG only supports Python >= 2.7"
+#endif
+
+#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03030000
+# error "This version of SWIG only supports Python 3 >= 3.3"
+#endif
+
+/* 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)
+
+#ifdef SWIGPYTHON_BUILTIN
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags)
+#else
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
+#endif
+
+#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, 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(NULL, 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(clientdata)
+#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, 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 */
+
+#if defined(SWIGPYTHON_BUILTIN)
+
+SWIGINTERN void
+SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
+ PyObject *s = PyString_InternFromString(key);
+ PyList_Append(seq, s);
+ Py_DECREF(s);
+}
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
+ PyDict_SetItemString(d, name, obj);
+ Py_DECREF(obj);
+ if (public_interface)
+ SwigPyBuiltin_AddPublicSymbol(public_interface, name);
+}
+
+#else
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
+ PyDict_SetItemString(d, name, obj);
+ Py_DECREF(obj);
+}
+
+#endif
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+ 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);
+ if (result) {
+ PyList_SET_ITEM(result, 0, o2);
+ } else {
+ Py_DECREF(obj);
+ return o2;
+ }
+ }
+ PyList_Append(result,obj);
+ Py_DECREF(obj);
+ }
+ return result;
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN Py_ssize_t
+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)) {
+ if (min <= 1 && max >= 1) {
+ Py_ssize_t i;
+ objs[0] = args;
+ for (i = 1; i < max; ++i) {
+ objs[i] = 0;
+ }
+ return 2;
+ }
+ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+ return 0;
+ } else {
+ 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 {
+ Py_ssize_t i;
+ for (i = 0; i < l; ++i) {
+ objs[i] = PyTuple_GET_ITEM(args, i);
+ }
+ for (; l < max; ++l) {
+ objs[l] = 0;
+ }
+ return i + 1;
+ }
+ }
+}
+
+SWIGINTERN int
+SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) {
+ int no_kwargs = 1;
+ if (kwargs) {
+ assert(PyDict_Check(kwargs));
+ if (PyDict_Size(kwargs) > 0) {
+ PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name);
+ no_kwargs = 0;
+ }
+ }
+ return no_kwargs;
+}
+
+/* A functor is a function object with one single object argument */
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
+
+/*
+ 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
+
+#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(PyObject *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(PyObject *o) {
+ swig_varlinkobject *v = (swig_varlinkobject *) o;
+#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 void
+swig_varlink_dealloc(PyObject *o) {
+ swig_varlinkobject *v = (swig_varlinkobject *) o;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ swig_globalvar *n = var->next;
+ free(var->name);
+ free(var);
+ var = n;
+ }
+}
+
+SWIGINTERN PyObject *
+swig_varlink_getattr(PyObject *o, char *n) {
+ swig_varlinkobject *v = (swig_varlinkobject *) o;
+ 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_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
+ }
+ return res;
+}
+
+SWIGINTERN int
+swig_varlink_setattr(PyObject *o, char *n, PyObject *p) {
+ swig_varlinkobject *v = (swig_varlinkobject *) o;
+ 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_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
+ }
+ 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 = {
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ "swigvarlink", /* tp_name */
+ sizeof(swig_varlinkobject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor) swig_varlink_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX < 0x030800b4
+ (printfunc)0, /*tp_print*/
+#else
+ (Py_ssize_t)0, /*tp_vectorcall_offset*/
+#endif
+ (getattrfunc) swig_varlink_getattr, /* tp_getattr */
+ (setattrfunc) swig_varlink_setattr, /* 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 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
+ 0, /* tp_print */
+#endif
+#ifdef COUNT_ALLOCS
+ 0, /* tp_allocs */
+ 0, /* tp_frees */
+ 0, /* tp_maxalloc */
+ 0, /* tp_prev */
+ 0 /* tp_next */
+#endif
+ };
+ varlink_type = tmp;
+ type_init = 1;
+ if (PyType_Ready(&varlink_type) < 0)
+ return NULL;
+ }
+ 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, const 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) {
+ memcpy(gv->name, name, size);
+ gv->get_attr = get_attr;
+ gv->set_attr = set_attr;
+ gv->next = v->vars;
+ }
+ }
+ v->vars = gv;
+}
+
+
+static PyObject *Swig_Globals_global = NULL;
+
+SWIGINTERN PyObject *
+SWIG_globals(void) {
+ if (Swig_Globals_global == NULL) {
+ Swig_Globals_global = SWIG_newvarlink();
+ }
+ return Swig_Globals_global;
+}
+
+#ifdef __cplusplus
+}
+#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)
+
+#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
+#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
+
+#ifdef __cplusplus
+extern "C" {
+#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;
+ PyTypeObject *pytype;
+} SwigPyClientData;
+
+SWIGRUNTIMEINLINE int
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+ SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
+ int fail = data ? data->implicitconv : 0;
+ if (fail)
+ PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors.");
+ return fail;
+}
+
+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;
+ Py_INCREF(obj);
+ data->newargs = obj;
+ } else {
+ data->newraw = PyObject_GetAttrString(data->klass, "__new__");
+ if (data->newraw) {
+ data->newargs = PyTuple_New(1);
+ if (data->newargs) {
+ Py_INCREF(obj);
+ PyTuple_SET_ITEM(data->newargs, 0, obj);
+ } else {
+ Py_DECREF(data->newraw);
+ Py_DECREF(data->klass);
+ free(data);
+ return 0;
+ }
+ } else {
+ Py_INCREF(obj);
+ data->newargs = obj;
+ }
+ }
+ /* the destroy method, aka as the C++ delete method */
+ data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__");
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ data->destroy = 0;
+ }
+ if (data->destroy) {
+ data->delargs = !(PyCFunction_GET_FLAGS(data->destroy) & METH_O);
+ } else {
+ data->delargs = 0;
+ }
+ data->implicitconv = 0;
+ data->pytype = 0;
+ return data;
+ }
+}
+
+SWIGRUNTIME void
+SwigPyClientData_Del(SwigPyClientData *data)
+{
+ Py_XDECREF(data->klass);
+ Py_XDECREF(data->newraw);
+ Py_XDECREF(data->newargs);
+ Py_XDECREF(data->destroy);
+ free(data);
+}
+
+/* =============== SwigPyObject =====================*/
+
+typedef struct {
+ PyObject_HEAD
+ void *ptr;
+ swig_type_info *ty;
+ int own;
+ PyObject *next;
+#ifdef SWIGPYTHON_BUILTIN
+ PyObject *dict;
+#endif
+} SwigPyObject;
+
+
+#ifdef SWIGPYTHON_BUILTIN
+
+SWIGRUNTIME PyObject *
+SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
+{
+ SwigPyObject *sobj = (SwigPyObject *)v;
+
+ if (!sobj->dict)
+ sobj->dict = PyDict_New();
+
+ Py_XINCREF(sobj->dict);
+ return sobj->dict;
+}
+
+#endif
+
+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) {
+ PyObject *val = SwigPyObject_long(v);
+ if (val) {
+ PyObject *ofmt;
+ PyTuple_SET_ITEM(args, 0, val);
+ 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 *
+SwigPyObject_repr(SwigPyObject *v)
+{
+ const char *name = SWIG_TypePrettyName(v->ty);
+ PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
+ if (repr && v->next) {
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
+ if (nrep) {
+# 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
+ } else {
+ Py_DecRef(repr);
+ repr = NULL;
+ }
+ }
+ return repr;
+}
+
+/* We need a version taking two PyObject* parameters so it's a valid
+ * PyCFunction to use in swigobject_methods[]. */
+SWIGRUNTIME PyObject *
+SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
+{
+ return SwigPyObject_repr((SwigPyObject*)v);
+}
+
+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;
+ }
+ res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
+ return res;
+}
+
+
+SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
+
+#ifdef SWIGPYTHON_BUILTIN
+static swig_type_info *SwigPyObject_stype = 0;
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+ SwigPyClientData *cd;
+ assert(SwigPyObject_stype);
+ cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
+ assert(cd);
+ assert(cd->pytype);
+ return cd->pytype;
+}
+#else
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
+ return type;
+}
+#endif
+
+SWIGRUNTIMEINLINE int
+SwigPyObject_Check(PyObject *op) {
+#ifdef SWIGPYTHON_BUILTIN
+ PyTypeObject *target_tp = SwigPyObject_type();
+ if (PyType_IsSubtype(op->ob_type, target_tp))
+ return 1;
+ return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
+#else
+ return (Py_TYPE(op) == SwigPyObject_type())
+ || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
+#endif
+}
+
+SWIGRUNTIME PyObject *
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
+
+static PyObject* Swig_Capsule_global = NULL;
+
+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;
+
+ /* PyObject_CallFunction() has the potential to silently drop
+ the active exception. In cases of unnamed temporary
+ variable or where we just finished iterating over a generator
+ StopIteration will be active right now, and this needs to
+ remain true upon return from SwigPyObject_dealloc. So save
+ and restore. */
+
+ PyObject *type = NULL, *value = NULL, *traceback = NULL;
+ PyErr_Fetch(&type, &value, &traceback);
+
+ if (data->delargs) {
+ /* we need to create a temporary object to carry the destroy operation */
+ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
+ if (tmp) {
+ res = SWIG_Python_CallFunctor(destroy, tmp);
+ } else {
+ res = 0;
+ }
+ Py_XDECREF(tmp);
+ } else {
+ PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+ PyObject *mself = PyCFunction_GET_SELF(destroy);
+ res = ((*meth)(mself, v));
+ }
+ if (!res)
+ PyErr_WriteUnraisable(destroy);
+
+ PyErr_Restore(type, value, traceback);
+
+ 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(Swig_Capsule_global);
+ }
+ Py_XDECREF(next);
+#ifdef SWIGPYTHON_BUILTIN
+ Py_XDECREF(sobj->dict);
+#endif
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject*
+SwigPyObject_append(PyObject* v, PyObject* next)
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ if (!SwigPyObject_Check(next)) {
+ PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
+ return NULL;
+ }
+ ((SwigPyObject *)next)->next = sobj->next;
+ sobj->next = next;
+ Py_INCREF(next);
+ return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject*
+SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ if (sobj->next) {
+ Py_INCREF(sobj->next);
+ return sobj->next;
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+SWIGINTERN PyObject*
+SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+{
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ sobj->own = 0;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+{
+ 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 (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) {
+ return NULL;
+ } else {
+ SwigPyObject *sobj = (SwigPyObject *)v;
+ PyObject *obj = PyBool_FromLong(sobj->own);
+ if (val) {
+ if (PyObject_IsTrue(val)) {
+ Py_DECREF(SwigPyObject_acquire(v,args));
+ } else {
+ Py_DECREF(SwigPyObject_disown(v,args));
+ }
+ }
+ return obj;
+ }
+}
+
+static PyMethodDef
+swigobject_methods[] = {
+ {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"},
+ {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"},
+ {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"},
+ {"append", SwigPyObject_append, METH_O, "appends another 'this' object"},
+ {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"},
+ {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"},
+ {0, 0, 0, 0}
+};
+
+SWIGRUNTIME PyTypeObject*
+SwigPyObject_TypeOnce(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 >= 0x03050000 /* 3.5 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */
+#elif 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 */
+#else
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
+#endif
+ };
+
+ static PyTypeObject swigpyobject_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp = {
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ "SwigPyObject", /* tp_name */
+ sizeof(SwigPyObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyObject_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX < 0x030800b4
+ (printfunc)0, /*tp_print*/
+#else
+ (Py_ssize_t)0, /*tp_vectorcall_offset*/
+#endif
+ (getattrfunc)0, /* tp_getattr */
+ (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 */
+ 0, /* 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 */
+ 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 */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
+ 0, /* tp_print */
+#endif
+#ifdef COUNT_ALLOCS
+ 0, /* tp_allocs */
+ 0, /* tp_frees */
+ 0, /* tp_maxalloc */
+ 0, /* tp_prev */
+ 0 /* tp_next */
+#endif
+ };
+ swigpyobject_type = tmp;
+ type_init = 1;
+ if (PyType_Ready(&swigpyobject_type) != 0)
+ return NULL;
+ }
+ 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;
+#ifdef SWIGPYTHON_BUILTIN
+ sobj->dict = 0;
+#endif
+ if (own == SWIG_POINTER_OWN) {
+ /* Obtain a reference to the Python capsule wrapping the module information, so that the
+ * module information is correctly destroyed after all SWIG python objects have been freed
+ * by the GC (and corresponding destructors invoked) */
+ Py_XINCREF(Swig_Capsule_global);
+ }
+ }
+ 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 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((const char *)v->pack, (const char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
+
+SWIGRUNTIME PyTypeObject*
+SwigPyPacked_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+SwigPyPacked_Check(PyObject *op) {
+ return ((op)->ob_type == SwigPyPacked_TypeOnce())
+ || (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*
+SwigPyPacked_TypeOnce(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 = {
+#if PY_VERSION_HEX>=0x03000000
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+#endif
+ "SwigPyPacked", /* tp_name */
+ sizeof(SwigPyPacked), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX < 0x030800b4
+ (printfunc)0, /*tp_print*/
+#else
+ (Py_ssize_t)0, /*tp_vectorcall_offset*/
+#endif
+ (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 */
+ 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 */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
+ 0, /* tp_print */
+#endif
+#ifdef COUNT_ALLOCS
+ 0, /* tp_allocs */
+ 0, /* tp_frees */
+ 0, /* tp_maxalloc */
+ 0, /* tp_prev */
+ 0 /* tp_next */
+#endif
+ };
+ swigpypacked_type = tmp;
+ type_init = 1;
+ if (PyType_Ready(&swigpypacked_type) != 0)
+ return NULL;
+ }
+ 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
+ * ----------------------------------------------------------------------------- */
+
+static PyObject *Swig_This_global = NULL;
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+ if (Swig_This_global == NULL)
+ Swig_This_global = SWIG_Python_str_FromChar("this");
+ return Swig_This_global;
+}
+
+/* #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)
+{
+ PyObject *obj;
+
+ if (SwigPyObject_Check(pyobj))
+ return (SwigPyObject *) pyobj;
+
+#ifdef SWIGPYTHON_BUILTIN
+ (void)obj;
+# ifdef PyWeakref_CheckProxy
+ if (PyWeakref_CheckProxy(pyobj)) {
+ pyobj = PyWeakref_GET_OBJECT(pyobj);
+ if (pyobj && SwigPyObject_Check(pyobj))
+ return (SwigPyObject*) pyobj;
+ }
+# endif
+ return NULL;
+#else
+
+ obj = 0;
+
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ 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;
+#endif
+}
+
+/* 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) {
+ int res;
+ SwigPyObject *sobj;
+ int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
+
+ if (!obj)
+ return SWIG_ERROR;
+ if (obj == Py_None && !implicit_conv) {
+ if (ptr)
+ *ptr = 0;
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
+ }
+
+ res = SWIG_ERROR;
+
+ 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); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
+ break;
+ }
+ }
+ } else {
+ if (ptr) *ptr = vptr;
+ break;
+ }
+ }
+ if (sobj) {
+ if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !sobj->own) {
+ res = SWIG_ERROR_RELEASE_NOT_OWNED;
+ } else {
+ if (own)
+ *own = *own | sobj->own;
+ if (flags & SWIG_POINTER_DISOWN) {
+ sobj->own = 0;
+ }
+ if (flags & SWIG_POINTER_CLEAR) {
+ sobj->ptr = 0;
+ }
+ res = SWIG_OK;
+ }
+ } else {
+ if (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);
+ }
+ }
+ }
+ if (!SWIG_IsOK(res) && obj == Py_None) {
+ if (ptr)
+ *ptr = 0;
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ res = SWIG_OK;
+ }
+ }
+ }
+ 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;
+ swig_cast_info *tc;
+
+ /* 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;
+ 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;
+ }
+ return SWIG_OK;
+ }
+}
+
+/* Convert a packed pointer 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)
+{
+ 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;
+ }
+ if (dict) {
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ } else{
+ Py_DECREF(inst);
+ inst = 0;
+ }
+ }
+#else
+ if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) {
+ Py_DECREF(inst);
+ inst = 0;
+ }
+#endif
+ }
+ } else {
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject *empty_args = PyTuple_New(0);
+ if (empty_args) {
+ PyObject *empty_kwargs = PyDict_New();
+ if (empty_kwargs) {
+ inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs);
+ Py_DECREF(empty_kwargs);
+ if (inst) {
+ if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) {
+ Py_DECREF(inst);
+ inst = 0;
+ } else {
+ PyType_Modified(Py_TYPE(inst));
+ }
+ }
+ }
+ Py_DECREF(empty_args);
+ }
+#else
+ PyObject *dict = PyDict_New();
+ if (dict) {
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ }
+#endif
+ }
+ return inst;
+}
+
+SWIGRUNTIME int
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+#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;
+ }
+ if (dict) {
+ return PyDict_SetItem(dict, SWIG_This(), swig_this);
+ } else{
+ return -1;
+ }
+ }
+#endif
+ return PyObject_SetAttr(inst, SWIG_This(), swig_this);
+}
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+ PyObject *obj[2];
+ if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
+ return NULL;
+ } else {
+ SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+ if (sthis) {
+ Py_DECREF(SwigPyObject_append((PyObject*) sthis, obj[1]));
+ } else {
+ if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0)
+ return NULL;
+ }
+ return SWIG_Py_Void();
+ }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
+ SwigPyClientData *clientdata;
+ PyObject * robj;
+ int own;
+
+ if (!ptr)
+ return SWIG_Py_Void();
+
+ clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
+ own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+ if (clientdata && clientdata->pytype) {
+ SwigPyObject *newobj;
+ if (flags & SWIG_BUILTIN_TP_INIT) {
+ newobj = (SwigPyObject*) self;
+ if (newobj->ptr) {
+ PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
+ while (newobj->next)
+ newobj = (SwigPyObject *) newobj->next;
+ newobj->next = next_self;
+ newobj = (SwigPyObject *)next_self;
+#ifdef SWIGPYTHON_BUILTIN
+ newobj->dict = 0;
+#endif
+ }
+ } else {
+ newobj = PyObject_New(SwigPyObject, clientdata->pytype);
+#ifdef SWIGPYTHON_BUILTIN
+ if (newobj) {
+ newobj->dict = 0;
+ }
+#endif
+ }
+ if (newobj) {
+ newobj->ptr = ptr;
+ newobj->ty = type;
+ newobj->own = own;
+ newobj->next = 0;
+ return (PyObject*) newobj;
+ }
+ return SWIG_Py_Void();
+ }
+
+ assert(!(flags & SWIG_BUILTIN_TP_INIT));
+
+ robj = SwigPyObject_New(ptr, type, own);
+ if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+ PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+ 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
+
+static PyObject *Swig_TypeCache_global = NULL;
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache(void) {
+ if (Swig_TypeCache_global == NULL) {
+ Swig_TypeCache_global = PyDict_New();
+ }
+ return Swig_TypeCache_global;
+}
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
+#ifdef SWIG_LINK_RUNTIME
+ static void *type_pointer = (void *)0;
+ /* first check if module already created */
+ if (!type_pointer) {
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+ }
+#else
+ void *type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
+ }
+#endif
+ return (swig_module_info *) type_pointer;
+}
+
+
+static int interpreter_counter = 0; // how many (sub-)interpreters are using swig_module's types
+
+SWIGRUNTIME void
+SWIG_Python_DestroyModule(PyObject *obj)
+{
+ swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
+ swig_type_info **types = swig_module->types;
+ size_t i;
+ if (--interpreter_counter != 0) // another sub-interpreter may still be using the swig_module's types
+ return;
+ for (i =0; i < swig_module->size; ++i) {
+ swig_type_info *ty = types[i];
+ if (ty->owndata) {
+ SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
+ ty->clientdata = 0;
+ if (data) SwigPyClientData_Del(data);
+ }
+ }
+ Py_DECREF(SWIG_This());
+ Swig_This_global = NULL;
+ Py_DECREF(SWIG_globals());
+ Swig_Globals_global = NULL;
+ Py_DECREF(SWIG_Python_TypeCache());
+ Swig_TypeCache_global = NULL;
+ Swig_Capsule_global = NULL;
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+#if PY_VERSION_HEX >= 0x03000000
+ /* Add a dummy module object into sys.modules */
+ PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION);
+#else
+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
+ PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
+#endif
+ PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
+ if (pointer && module) {
+ if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) {
+ ++interpreter_counter;
+ Swig_Capsule_global = pointer;
+ } else {
+ Py_DECREF(pointer);
+ }
+ } else {
+ Py_XDECREF(pointer);
+ }
+}
+
+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 *) PyCapsule_GetPointer(obj, NULL);
+ } else {
+ swig_module_info *swig_module = SWIG_GetModule(0);
+ descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+ if (descriptor) {
+ obj = PyCapsule_New((void*) descriptor, NULL, NULL);
+ if (obj) {
+ 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) {
+ PyObject *old_str = PyObject_Str(value);
+ const char *tmp = SWIG_Python_str_AsChar(old_str);
+ const char *errmesg = tmp ? tmp : "Invalid error message";
+ Py_XINCREF(type);
+ PyErr_Clear();
+ if (infront) {
+ PyErr_Format(type, "%s %s", mesg, errmesg);
+ } else {
+ PyErr_Format(type, "%s %s", errmesg, mesg);
+ }
+ 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 : "";
+}
+
+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);
+ } 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 SWIGUNUSEDPARM(argnum), int flags) {
+ void *result;
+ if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+ PyErr_Clear();
+ }
+ return result;
+}
+
+#ifdef SWIGPYTHON_BUILTIN
+SWIGRUNTIME int
+SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
+ PyTypeObject *tp = obj->ob_type;
+ PyObject *descr;
+ PyObject *encoded_name;
+ descrsetfunc f;
+ int res = -1;
+
+# ifdef Py_USING_UNICODE
+ if (PyString_Check(name)) {
+ name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
+ if (!name)
+ return -1;
+ } else if (!PyUnicode_Check(name))
+# else
+ if (!PyString_Check(name))
+# endif
+ {
+ PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
+ return -1;
+ } else {
+ Py_INCREF(name);
+ }
+
+ if (!tp->tp_dict) {
+ if (PyType_Ready(tp) != 0)
+ goto done;
+ }
+
+ descr = _PyType_Lookup(tp, name);
+ f = NULL;
+ if (descr != NULL)
+ f = descr->ob_type->tp_descr_set;
+ if (!f) {
+ if (PyString_Check(name)) {
+ encoded_name = name;
+ Py_INCREF(name);
+ } else {
+ encoded_name = PyUnicode_AsUTF8String(name);
+ if (!encoded_name)
+ goto done;
+ }
+ PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
+ Py_DECREF(encoded_name);
+ } else {
+ res = f(descr, obj, value);
+ }
+
+ done:
+ Py_DECREF(name);
+ return res;
+}
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/contrib/tools/swig/Lib/python/pyruntime.swg b/contrib/tools/swig/Lib/python/pyruntime.swg
new file mode 100644
index 0000000000..1d028adaf0
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyruntime.swg
@@ -0,0 +1,49 @@
+%insert(runtime) %{
+#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND)
+/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */
+# include <math.h>
+#endif
+
+#if !defined(PY_SSIZE_T_CLEAN) && !defined(SWIG_NO_PY_SSIZE_T_CLEAN)
+#define PY_SSIZE_T_CLEAN
+#endif
+
+#if __GNUC__ >= 7
+#pragma GCC diagnostic push
+#if defined(__cplusplus) && __cplusplus >=201703L
+#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */
+#endif
+#endif
+
+#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
+/* Use debug wrappers with the Python release dll */
+
+#if defined(_MSC_VER) && _MSC_VER >= 1929
+/* Workaround compilation errors when redefining _DEBUG in MSVC 2019 version 16.10 and later
+ * See https://github.com/swig/swig/issues/2090 */
+# include <corecrt.h>
+#endif
+
+# undef _DEBUG
+# include <Python.h>
+# define _DEBUG 1
+#else
+# include <Python.h>
+#endif
+
+#if __GNUC__ >= 7
+#pragma GCC diagnostic pop
+#endif
+%}
+
+%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 */
+
+#if defined(SWIGPYTHON_BUILTIN)
+%insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */
+#endif
diff --git a/contrib/tools/swig/Lib/python/pystrings.swg b/contrib/tools/swig/Lib/python/pystrings.swg
new file mode 100644
index 0000000000..64ed685e8c
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pystrings.swg
@@ -0,0 +1,139 @@
+/* ------------------------------------------------------------
+ * 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 defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
+ if (PyBytes_Check(obj))
+%#else
+ if (PyUnicode_Check(obj))
+%#endif
+%#else
+ if (PyString_Check(obj))
+%#endif
+ {
+ char *cstr; Py_ssize_t len;
+ int ret = SWIG_OK;
+%#if PY_VERSION_HEX>=0x03000000
+%#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
+ 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);
+ if (!obj)
+ return SWIG_TypeError;
+ if (alloc)
+ *alloc = SWIG_NEWOBJ;
+%#endif
+ if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1)
+ return SWIG_TypeError;
+%#else
+ if (PyString_AsStringAndSize(obj, &cstr, &len) == -1)
+ return SWIG_TypeError;
+%#endif
+ if (cptr) {
+ if (alloc) {
+ if (*alloc == SWIG_NEWOBJ) {
+ *cptr = %new_copy_array(cstr, len + 1, char);
+ *alloc = SWIG_NEWOBJ;
+ } else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ } else {
+%#if PY_VERSION_HEX>=0x03000000
+%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
+ *cptr = PyBytes_AsString(obj);
+%#else
+ assert(0); /* Should never reach here with Unicode strings in Python 3 */
+%#endif
+%#else
+ *cptr = SWIG_Python_str_AsChar(obj);
+ if (!*cptr)
+ ret = SWIG_TypeError;
+%#endif
+ }
+ }
+ if (psize) *psize = len + 1;
+%#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
+ Py_XDECREF(obj);
+%#endif
+ return ret;
+ } else {
+%#if defined(SWIG_PYTHON_2_UNICODE)
+%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
+%#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once"
+%#endif
+%#if PY_VERSION_HEX<0x03000000
+ if (PyUnicode_Check(obj)) {
+ char *cstr; Py_ssize_t len;
+ if (!alloc && cptr) {
+ return SWIG_RuntimeError;
+ }
+ obj = PyUnicode_AsUTF8String(obj);
+ if (!obj)
+ return SWIG_TypeError;
+ if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) {
+ if (cptr) {
+ if (alloc) *alloc = SWIG_NEWOBJ;
+ *cptr = %new_copy_array(cstr, len + 1, char);
+ }
+ if (psize) *psize = len + 1;
+
+ Py_XDECREF(obj);
+ return SWIG_OK;
+ } else {
+ Py_XDECREF(obj);
+ }
+ }
+%#endif
+%#endif
+
+ 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_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
+ } else {
+%#if PY_VERSION_HEX >= 0x03000000
+%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
+ return PyBytes_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
+%#else
+ return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape");
+%#endif
+%#else
+ return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
+%#endif
+ }
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+}
+
diff --git a/contrib/tools/swig/Lib/python/python.swg b/contrib/tools/swig/Lib/python/python.swg
new file mode 100644
index 0000000000..769d9e104a
--- /dev/null
+++ b/contrib/tools/swig/Lib/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/contrib/tools/swig/Lib/python/pythonkw.swg b/contrib/tools/swig/Lib/python/pythonkw.swg
new file mode 100644
index 0000000000..a21034524f
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pythonkw.swg
@@ -0,0 +1,140 @@
+/*
+ Warnings for Python keywords, built-in names and bad names.
+*/
+
+#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword", rename="_%s") `x`
+#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") `x`
+
+
+/*
+ Warnings for Python keywords
+ https://docs.python.org/2/reference/lexical_analysis.html#keywords
+*/
+
+PYTHONKW(and);
+PYTHONKW(as);
+PYTHONKW(assert);
+PYTHONKW(async);
+PYTHONKW(await);
+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(with);
+PYTHONKW(yield);
+
+/*
+ built-in functions
+ https://docs.python.org/2/library/functions.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(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);
+
+PYTHONKW(None);
+
+
+/*
+ 'self' is also a bad Name
+*/
+PYTHONKW(self);
+
+#undef PYTHONBN
+#undef PYTHONKW
diff --git a/contrib/tools/swig/Lib/python/pythreads.swg b/contrib/tools/swig/Lib/python/pythreads.swg
new file mode 100644
index 0000000000..8d6c5ab49e
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pythreads.swg
@@ -0,0 +1,68 @@
+#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)
+# define SWIG_PYTHON_USE_GIL
+# endif
+# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+# if PY_VERSION_HEX < 0x03070000
+# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# else
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# endif
+# 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/contrib/tools/swig/Lib/python/pytypemaps.swg b/contrib/tools/swig/Lib/python/pytypemaps.swg
new file mode 100644
index 0000000000..0ae25a686e
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pytypemaps.swg
@@ -0,0 +1,105 @@
+/* ------------------------------------------------------------
+ * Typemap specializations for Python
+ * ------------------------------------------------------------ */
+
+/* ------------------------------------------------------------
+ * Fragment section
+ * ------------------------------------------------------------ */
+#ifdef SWIG_PYTHON_LEGACY_BOOL
+// Default prior to SWIG 3.0.0
+#undef SWIG_TYPECHECK_BOOL
+%define SWIG_TYPECHECK_BOOL 10000 %enddef
+#endif
+
+/* Include fundamental fragment 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 */
+#if defined(SWIGPYTHON_BUILTIN)
+#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, name,obj)
+#else
+#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj)
+#endif
+
+/* 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 / typemap overrides
+ * ------------------------------------------------------------ */
+
+/* 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, "$symname", 0, 0, (void *)($value), &$descriptor }
+%typemap(consttab) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
+
+%typemap(constcode) SWIGTYPE ((*)(ANY)) ""
+%typemap(constcode) SWIGTYPE ((* const)(ANY)) = 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/contrib/tools/swig/Lib/python/pyuserdir.swg b/contrib/tools/swig/Lib/python/pyuserdir.swg
new file mode 100644
index 0000000000..3110760793
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/pyuserdir.swg
@@ -0,0 +1,242 @@
+/* -------------------------------------------------------------------------
+ * Special user directives
+ * ------------------------------------------------------------------------- */
+
+/* ------------------------------------------------------------------------- */
+
+/* shadow code */
+#define %shadow %insert("shadow")
+#define %pythoncode %insert("python")
+#define %pythonbegin %insert("pythonbegin")
+
+
+/* ------------------------------------------------------------------------- */
+/*
+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
+
+*/
+
+#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 parameters
+*/
+
+#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/contrib/tools/swig/Lib/python/typemaps.i b/contrib/tools/swig/Lib/python/typemaps.i
new file mode 100644
index 0000000000..dba63dd59e
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/typemaps.i
@@ -0,0 +1,148 @@
+/* -----------------------------------------------------------------------------
+ * 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) :
+
+ 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/contrib/tools/swig/Lib/python/ya.make b/contrib/tools/swig/Lib/python/ya.make
new file mode 100644
index 0000000000..e843bff498
--- /dev/null
+++ b/contrib/tools/swig/Lib/python/ya.make
@@ -0,0 +1,22 @@
+# Generated by devtools/yamaker.
+
+LIBRARY()
+
+LICENSE(LicenseRef-scancode-swig)
+
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+
+VERSION(4.1.1)
+
+ORIGINAL_SOURCE(https://github.com/swig/swig/archive/v4.1.1.tar.gz)
+
+ADDINCL(
+ GLOBAL FOR
+ swig
+ contrib/tools/swig/Lib/python
+ GLOBAL FOR
+ swig
+ contrib/tools/swig/Lib
+)
+
+END()
diff --git a/contrib/tools/swig/Lib/std/README b/contrib/tools/swig/Lib/std/README
new file mode 100644
index 0000000000..5cd759dda1
--- /dev/null
+++ b/contrib/tools/swig/Lib/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/contrib/tools/swig/Lib/swig.swg b/contrib/tools/swig/Lib/swig.swg
new file mode 100644
index 0000000000..9f9d533498
--- /dev/null
+++ b/contrib/tools/swig/Lib/swig.swg
@@ -0,0 +1,729 @@
+/* -----------------------------------------------------------------------------
+ * 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-1.1 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 */
+#if defined(SWIGCSHARP) || defined(SWIGD)
+#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.
+*/
+#if defined(SWIGCSHARP) || defined(SWIGD)
+#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 %nestedworkaround directive (deprecated) */
+#define %nestedworkaround %feature("nestedworkaround")
+#define %nonestedworkaround %feature("nestedworkaround","0")
+#define %clearnestedworkaround %feature("nestedworkaround","")
+
+/* the %flatnested directive */
+#define %flatnested %feature("flatnested")
+#define %noflatnested %feature("flatnested","0")
+#define %clearflatnested %feature("flatnested","")
+
+/* 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","")
+
+/* nspace directives */
+#define %nspace %feature("nspace")
+#define %nonspace %feature("nspace","0")
+#define %clearnspace %feature("nspace","")
+
+/* valuewrapper directives */
+#define %valuewrapper %feature("valuewrapper")
+#define %clearvaluewrapper %feature("valuewrapper","")
+#define %novaluewrapper %feature("novaluewrapper")
+#define %clearnovaluewrapper %feature("novaluewrapper","")
+
+/* Contract support - Experimental */
+#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 clashes with other swig
+ macros/directives.
+
+*/
+
+/* Note that when %$not is used with another macro, say %enum as follows: %$not %$enum, the result is "notmatch=enum" */
+%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 %$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 %$isusing "match"="using" %enddef
+
+%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 %$isextendmember "match$isextendmember"="1" %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
+%define %$isnested "match$nested"="1" %enddef
+
+/* -----------------------------------------------------------------------------
+ * Common includes for warning labels, macros, fragments etc
+ * ----------------------------------------------------------------------------- */
+
+%include <swigwarnings.swg>
+%include <swigfragments.swg>
+
+/* -----------------------------------------------------------------------------
+ * Overloading support
+ * ----------------------------------------------------------------------------- */
+
+/*
+ * Function/method overloading support. This is done through typemaps,
+ * but also involves 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_STDARRAY 155 %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
+
+
+/* -----------------------------------------------------------------------------
+ * 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 {
+ /* Warn about std::initializer_list usage. The constructor/method where used should probably be ignored. See docs. */
+ template<typename T> class initializer_list {};
+ %typemap(in, warning=SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG) initializer_list<T> ""
+ %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) initializer_list<T> ""
+}
+#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,fragment="<string.h>") char * {
+ 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,fragment="<string.h>") 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,fragment="<string.h>") char * {
+ 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,fragment="<string.h>") 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,fragment="<string.h>") char * {
+ free($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,fragment="<string.h>") const char * {
+ if ($input) {
+ $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ strcpy((char *)$1, (const char *)$input);
+ } else {
+ $1 = 0;
+ }
+}
+%typemap(globalin,fragment="<string.h>") char * {
+ free($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,fragment="<string.h>") 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,fragment="<string.h>") char [ANY] {
+ if($input) {
+ strncpy((char*)$1, (const char *)$input, $1_dim0-1);
+ $1[$1_dim0-1] = 0;
+ } else {
+ $1[0] = 0;
+ }
+}
+
+%typemap(globalin,fragment="<string.h>") char [ANY] {
+ if($input) {
+ strncpy((char*)$1, (const char *)$input, $1_dim0-1);
+ $1[$1_dim0-1] = 0;
+ } else {
+ $1[0] = 0;
+ }
+}
+
+%typemap(memberin,fragment="<string.h>") char [] {
+ if ($input) strcpy((char *)$1, (const char *)$input);
+ else $1[0] = 0;
+}
+
+%typemap(globalin,fragment="<string.h>") char [] {
+ if ($input) strcpy((char *)$1, (const char *)$input);
+ else $1[0] = 0;
+}
+
+/* memberin/globalin typemap for arrays. */
+
+%typemap(memberin,fragment="<string.h>") 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,fragment="<string.h>") 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,fragment="<string.h>") 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,fragment="<string.h>") 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];
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * Runtime code
+ * ----------------------------------------------------------------------------- */
+
+
+%insert("runtime") "swiglabels.swg"
+
+
+/* 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
+ *
+ * SwigValueWrapper is a drop in replacement to modify normal value semantics by
+ * using the heap instead of the stack to copy/move the underlying object it is
+ * managing. Smart pointers also manage an underlying object on the heap, so
+ * SwigValueWrapper has characteristics of a smart pointer. The reset function
+ * is specific smart pointer functionality, but cannot be a non-static member as
+ * when SWIG modifies typemap code it assumes non-static member function calls
+ * are routed to the underlying object, changing for example $1.f() to (&x)->f().
+ * The reset function was added as an optimisation to avoid some copying/moving
+ * and to take ownership of an object already created on the heap.
+ *
+ * The class offers a strong guarantee of exception safety.
+ * With regards to the implementation, the private SwigSmartPointer nested class is
+ * a simple smart pointer providing exception safety, much like std::auto_ptr.
+ *
+ * This wrapping technique was suggested by William Fulton and is henceforth
+ * known as the "Fulton Transform" :-).
+ */
+
+#ifdef __cplusplus
+// Placed in the header section to ensure the language specific header files are
+// the first included headers and not <utility>
+%insert("header") %{
+#ifdef __cplusplus
+#include <utility>
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+ struct SwigSmartPointer {
+ T *ptr;
+ SwigSmartPointer(T *p) : ptr(p) { }
+ ~SwigSmartPointer() { delete ptr; }
+ SwigSmartPointer& operator=(SwigSmartPointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+ void reset(T *p) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = p; }
+ } pointer;
+ SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+ SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+ SwigValueWrapper() : pointer(0) { }
+ SwigValueWrapper& operator=(const T& t) { SwigSmartPointer tmp(new T(t)); pointer = tmp; return *this; }
+#if __cplusplus >=201103L
+ SwigValueWrapper& operator=(T&& t) { SwigSmartPointer tmp(new T(std::move(t))); pointer = tmp; return *this; }
+ operator T&&() const { return std::move(*pointer.ptr); }
+#else
+ operator T&() const { return *pointer.ptr; }
+#endif
+ T *operator&() const { return pointer.ptr; }
+ static void reset(SwigValueWrapper& t, T *p) { t.pointer.reset(p); }
+};
+
+/*
+ * 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();
+ */
+template <typename T> T SwigValueInit() {
+ return T();
+}
+
+#if __cplusplus >=201103L
+# define SWIG_STD_MOVE(OBJ) std::move(OBJ)
+#else
+# define SWIG_STD_MOVE(OBJ) OBJ
+#endif
+
+#endif
+%}
+#endif
+
diff --git a/contrib/tools/swig/Lib/swigerrors.swg b/contrib/tools/swig/Lib/swigerrors.swg
new file mode 100644
index 0000000000..4d5a8e473d
--- /dev/null
+++ b/contrib/tools/swig/Lib/swigerrors.swg
@@ -0,0 +1,15 @@
+/* SWIG Errors applicable to all language modules, values are reserved from -1 to -99 */
+#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/contrib/tools/swig/Lib/swigfragments.swg b/contrib/tools/swig/Lib/swigfragments.swg
new file mode 100644
index 0000000000..28aa1180f9
--- /dev/null
+++ b/contrib/tools/swig/Lib/swigfragments.swg
@@ -0,0 +1,90 @@
+/* -----------------------------------------------------------------------------
+ * swigfragments.swg
+ *
+ * Common fragments
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * Fragments for C header files
+ * ----------------------------------------------------------------------------- */
+
+%fragment("<float.h>", "header") %{
+#include <float.h>
+%}
+
+/* Default compiler options for gcc allow long_long but not LLONG_MAX.
+ * Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */
+%fragment("<limits.h>", "header") %{
+#include <limits.h>
+#if !defined(SWIG_NO_LLONG_MAX)
+# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
+# define LLONG_MAX __LONG_LONG_MAX__
+# define LLONG_MIN (-LLONG_MAX - 1LL)
+# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
+# endif
+#endif
+%}
+
+%fragment("<math.h>", "header") %{
+#include <math.h>
+%}
+
+%fragment("<string.h>", "header") %{
+#include <string.h>
+%}
+
+%fragment("<stddef.h>", "header") %{
+#include <stddef.h>
+%}
+
+%fragment("<stdio.h>", "header") %{
+#include <stdio.h>
+#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__BORLANDC__) || defined(_WATCOM)
+# ifndef snprintf
+# define snprintf _snprintf
+# endif
+#endif
+%}
+
+%fragment("<stdlib.h>", "header") %{
+#include <stdlib.h>
+#ifdef _MSC_VER
+# ifndef strtoull
+# define strtoull _strtoui64
+# endif
+# ifndef strtoll
+# define strtoll _strtoi64
+# endif
+#endif
+%}
+
+%fragment("<wchar.h>", "header") %{
+#include <wchar.h>
+#include <limits.h>
+#ifndef WCHAR_MIN
+# define WCHAR_MIN 0
+#endif
+#ifndef WCHAR_MAX
+# define WCHAR_MAX 65535
+#endif
+%}
+
+/* -----------------------------------------------------------------------------
+ * Fragments for C++ header files
+ * ----------------------------------------------------------------------------- */
+
+%fragment("<algorithm>", "header") %{
+#include <algorithm>
+%}
+
+%fragment("<stdexcept>", "header") %{
+#include <stdexcept>
+%}
+
+%fragment("<string>", "header") %{
+#include <string>
+%}
+
+%fragment("<memory>", "header") %{
+#include <memory>
+%}
diff --git a/contrib/tools/swig/Lib/swiginit.swg b/contrib/tools/swig/Lib/swiginit.swg
new file mode 100644
index 0000000000..e50b1b46dc
--- /dev/null
+++ b/contrib/tools/swig/Lib/swiginit.swg
@@ -0,0 +1,233 @@
+/* -----------------------------------------------------------------------------
+ * 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 statically 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
+
+#ifndef SWIG_INIT_CLIENT_DATA_TYPE
+#define SWIG_INIT_CLIENT_DATA_TYPE void *
+#endif
+
+SWIGRUNTIME void
+SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) {
+ size_t i;
+ swig_module_info *module_head, *iter;
+ int init;
+
+ /* 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);
+ } else {
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+ iter=module_head;
+ do {
+ if (iter==&swig_module) {
+ /* Our module is already in the list, so there's nothing more to do. */
+ return;
+ }
+ iter=iter->next;
+ } while (iter!= module_head);
+
+ /* otherwise we must add our module into the list */
+ swig_module.next = module_head->next;
+ module_head->next = &swig_module;
+ }
+
+ /* When multiple interpreters 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 %lu\n", (unsigned long)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 %lu %s\n", (unsigned long)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 %lu %s\n", (unsigned long)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/contrib/tools/swig/Lib/swiglabels.swg b/contrib/tools/swig/Lib/swiglabels.swg
new file mode 100644
index 0000000000..b3855665e2
--- /dev/null
+++ b/contrib/tools/swig/Lib/swiglabels.swg
@@ -0,0 +1,123 @@
+/* -----------------------------------------------------------------------------
+ * 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 defined(__GNUC__)
+# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+# 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
+
+/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
+#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
+# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
+#endif
+
+/* Intel's compiler complains if a variable which was never initialised is
+ * cast to void, which is a common idiom which we use to indicate that we
+ * are aware a variable isn't used. So we just silence that warning.
+ * See: https://github.com/swig/swig/issues/192 for more discussion.
+ */
+#ifdef __INTEL_COMPILER
+# pragma warning disable 592
+#endif
diff --git a/contrib/tools/swig/Lib/swigrun.swg b/contrib/tools/swig/Lib/swigrun.swg
new file mode 100644
index 0000000000..f632c4cb6d
--- /dev/null
+++ b/contrib/tools/swig/Lib/swigrun.swg
@@ -0,0 +1,581 @@
+/* -----------------------------------------------------------------------------
+ * 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
+#define SWIG_POINTER_NO_NULL 0x4
+#define SWIG_POINTER_CLEAR 0x8
+#define SWIG_POINTER_RELEASE (SWIG_POINTER_CLEAR | SWIG_POINTER_DISOWN)
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN 0x1
+
+
+/*
+ Flags/methods for returning states.
+
+ The SWIG conversion methods, as ConvertPtr, return an 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 returning 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)
+/* Runtime errors are < 0 */
+#define SWIG_ERROR (-1)
+/* Errors in range -1 to -99 are in swigerrors.swg (errors for all languages including those not using the runtime) */
+/* Errors in range -100 to -199 are language specific errors defined in *errors.swg */
+/* Errors < -200 are generic runtime specific errors */
+#define SWIG_ERROR_RELEASE_NOT_OWNED (-200)
+
+#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 object 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(r) (r)
+# 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 equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCmp(const char *nb, const char *tb) {
+ int equiv = 1;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (equiv != 0 && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = SWIG_TypeNameComp(nb, ne, tb, te);
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+/*
+ 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) {
+ return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
+}
+
+/*
+ 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(const 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. Choose the last
+ name. It should be the most specific; a fully resolved name
+ but not necessarily with default template parameters expanded. */
+ 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) {
+ size_t l = 0;
+ size_t r = iter->size - 1;
+ do {
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+ size_t i = (l + r) >> 1;
+ const char *iname = iter->types[i]->name;
+ if (iname) {
+ 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 {
+ 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";
+ const unsigned char *u = (unsigned char *) ptr;
+ const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ 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) {
+ unsigned char *u = (unsigned char *) ptr;
+ const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ char d = *(c++);
+ unsigned char uu;
+ if ((d >= '0') && (d <= '9'))
+ uu = (unsigned char)((d - '0') << 4);
+ else if ((d >= 'a') && (d <= 'f'))
+ uu = (unsigned char)((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
+ d = *(c++);
+ if ((d >= '0') && (d <= '9'))
+ uu |= (unsigned char)(d - '0');
+ else if ((d >= 'a') && (d <= 'f'))
+ uu |= (unsigned char)(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/contrib/tools/swig/Lib/swigwarn.swg b/contrib/tools/swig/Lib/swigwarn.swg
new file mode 100644
index 0000000000..6a069220ef
--- /dev/null
+++ b/contrib/tools/swig/Lib/swigwarn.swg
@@ -0,0 +1,300 @@
+/* SWIG warning codes - generated from swigwarn.h - do not edit */
+
+
+%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
+/* Unused since 4.1.0: #define WARN_DEPRECATED_TYPEMAP_LANG 124 */
+%define SWIGWARN_DEPRECATED_INPUT_FILE 125 %enddef
+%define SWIGWARN_DEPRECATED_NESTED_WORKAROUND 126 %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
+%define SWIGWARN_PP_UNEXPECTED_TOKENS 206 %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_UNNAMED_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_PARSE_NESTED_TEMPLATE 324 %enddef
+%define SWIGWARN_PARSE_NAMED_NESTED_CLASS 325 %enddef
+%define SWIGWARN_PARSE_EXTEND_NAME 326 %enddef
+%define SWIGWARN_PARSE_EXTERN_TEMPLATE 327 %enddef
+
+%define SWIGWARN_CPP11_LAMBDA 340 %enddef
+%define SWIGWARN_CPP11_ALIAS_DECLARATION 341 %enddef /* redundant now */
+%define SWIGWARN_CPP11_ALIAS_TEMPLATE 342 %enddef /* redundant now */
+%define SWIGWARN_CPP11_VARIADIC_TEMPLATE 343 %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 *() */
+%define SWIGWARN_IGNORE_OPERATOR_LTEQUALGT 397 %enddef /* <=> */
+
+/* please leave 350-399 free for WARN_IGNORE_OPERATOR_* */
+
+/* -- 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_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405 %enddef
+
+%define SWIGWARN_TYPEMAP_SOURCETARGET 450 %enddef /* No longer issued */
+%define SWIGWARN_TYPEMAP_CHARLEAK 451 %enddef
+%define SWIGWARN_TYPEMAP_SWIGTYPE 452 %enddef /* No longer issued */
+%define SWIGWARN_TYPEMAP_APPLY_UNDEF 453 %enddef
+%define SWIGWARN_TYPEMAP_SWIGTYPELEAK 454 %enddef
+%define SWIGWARN_TYPEMAP_WCHARLEAK 455 %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
+%define SWIGWARN_TYPEMAP_INITIALIZER_LIST 476 %enddef
+%define SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF 477 %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
+%define SWIGWARN_LANG_SMARTPTR_MISSING 520 %enddef
+%define SWIGWARN_LANG_ILLEGAL_DESTRUCTOR 521 %enddef
+%define SWIGWARN_LANG_EXTEND_CONSTRUCTOR 522 %enddef
+%define SWIGWARN_LANG_EXTEND_DESTRUCTOR 523 %enddef
+%define SWIGWARN_LANG_EXPERIMENTAL 524 %enddef
+%define SWIGWARN_LANG_DIRECTOR_FINAL 525 %enddef
+%define SWIGWARN_LANG_USING_NAME_DIFFERENT 526 %enddef
+
+/* -- Doxygen comments -- */
+
+%define SWIGWARN_DOXYGEN_UNKNOWN_COMMAND 560 %enddef
+%define SWIGWARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 561 %enddef
+%define SWIGWARN_DOXYGEN_COMMAND_EXPECTED 562 %enddef
+%define SWIGWARN_DOXYGEN_HTML_ERROR 563 %enddef
+%define SWIGWARN_DOXYGEN_COMMAND_ERROR 564 %enddef
+%define SWIGWARN_DOXYGEN_UNKNOWN_CHARACTER 565 %enddef
+%define SWIGWARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE 566 %enddef
+
+/* -- Reserved (600-699) -- */
+
+/* -- Language module specific warnings (700 - 899) -- */
+
+
+%define SWIGWARN_D_TYPEMAP_CTYPE_UNDEF 700 %enddef
+%define SWIGWARN_D_TYPEMAP_IMTYPE_UNDEF 701 %enddef
+%define SWIGWARN_D_TYPEMAP_DTYPE_UNDEF 702 %enddef
+%define SWIGWARN_D_MULTIPLE_INHERITANCE 703 %enddef
+%define SWIGWARN_D_TYPEMAP_CLASSMOD_UNDEF 704 %enddef
+%define SWIGWARN_D_TYPEMAP_DBODY_UNDEF 705 %enddef
+%define SWIGWARN_D_TYPEMAP_DOUT_UNDEF 706 %enddef
+%define SWIGWARN_D_TYPEMAP_DIN_UNDEF 707 %enddef
+%define SWIGWARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708 %enddef
+%define SWIGWARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709 %enddef
+%define SWIGWARN_D_EXCODE_MISSING 710 %enddef
+%define SWIGWARN_D_CANTHROW_MISSING 711 %enddef
+%define SWIGWARN_D_NO_DIRECTORCONNECT_ATTR 712 %enddef
+%define SWIGWARN_D_NAME_COLLISION 713 %enddef
+
+/* please leave 700-719 free for D */
+
+%define SWIGWARN_SCILAB_TRUNCATED_NAME 720 %enddef
+
+/* please leave 720-739 free for Scilab */
+
+%define SWIGWARN_PYTHON_INDENT_MISMATCH 740 %enddef
+
+/* please leave 740-749 free for Python */
+
+%define SWIGWARN_R_MISSING_RTYPECHECK_TYPEMAP 750 %enddef
+
+/* please leave 750-759 free for R */
+
+%define SWIGWARN_RUBY_WRONG_NAME 801 %enddef
+%define SWIGWARN_RUBY_MULTIPLE_INHERITANCE 802 %enddef
+
+/* please leave 800-809 free for Ruby */
+
+%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_TYPEMAP_INTERFACECODE_UNDEF 821 %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
+%define SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE 826 %enddef
+%define SWIGWARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF 827 %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_TYPEMAP_INTERFACECODE_UNDEF 841 %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_CSHARP_TYPEMAP_INTERFACEMODIFIERS_UNDEF 847 %enddef
+
+/* please leave 830-849 free for C# */
+
+/* 850-860 were used by Modula 3 (removed in SWIG 4.1.0) - avoid reusing for now */
+
+%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 */
+
+%define SWIGWARN_GO_NAME_CONFLICT 890 %enddef
+
+/* please leave 890-899 free for Go */
+
+/* -- User defined warnings (900 - 999) -- */
+
diff --git a/contrib/tools/swig/Lib/swigwarnings.swg b/contrib/tools/swig/Lib/swigwarnings.swg
new file mode 100644
index 0000000000..63ae4c65a9
--- /dev/null
+++ b/contrib/tools/swig/Lib/swigwarnings.swg
@@ -0,0 +1,131 @@
+/*
+ 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_WCHARLEAK_MSG "455:Setting a const wchar_t * 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
+%define SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG "476:Initialization using std::initializer_list." %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 SWIGWARN_IGNORE_OPERATOR_LTEQUALGT_MSG "397: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/contrib/tools/swig/Lib/typemaps/README b/contrib/tools/swig/Lib/typemaps/README
new file mode 100644
index 0000000000..65134578d3
--- /dev/null
+++ b/contrib/tools/swig/Lib/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/contrib/tools/swig/Lib/typemaps/enumint.swg b/contrib/tools/swig/Lib/typemaps/enumint.swg
new file mode 100644
index 0000000000..d048bb6bf7
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/enumint.swg
@@ -0,0 +1,39 @@
+/* ------------------------------------------------------------
+ * Enums mapped as integer values
+ * ------------------------------------------------------------ */
+
+%apply int { enum SWIGTYPE };
+%apply const int& { const enum SWIGTYPE & };
+%apply const int& { const enum SWIGTYPE && };
+
+%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE & (int val, int ecode, $basetype temp) {
+ ecode = SWIG_AsVal(int)($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$type", $symname, $argnum);
+ } else {
+ temp = %static_cast(val,$basetype);
+ $1 = &temp;
+ }
+}
+
+%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE && (int val, int ecode, $basetype temp) {
+ ecode = SWIG_AsVal(int)($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$type", $symname, $argnum);
+ } else {
+ temp = %static_cast(val,$basetype);
+ $1 = &temp;
+ }
+}
+
+%typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE {
+ if (sizeof(int) != sizeof($1)) {
+ %variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name");
+ } else {
+ int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*));
+ if (!SWIG_IsOK(ecode)) {
+ %variable_fail(ecode, "$type", "$name");
+ }
+ }
+}
+
diff --git a/contrib/tools/swig/Lib/typemaps/exception.swg b/contrib/tools/swig/Lib/typemaps/exception.swg
new file mode 100644
index 0000000000..aece8326f5
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/exception.swg
@@ -0,0 +1,87 @@
+/* -----------------------------------------------------------------------------
+ * exceptions.swg
+ *
+ * This SWIG library file provides language independent exception handling
+ * ----------------------------------------------------------------------------- */
+
+%include <typemaps/swigmacros.swg>
+
+
+/* macros for error manipulation */
+#define %nullref_fmt() "invalid null reference "
+#define %varfail_fmt(_type,_name) "in variable '"`_name`"' of type '"`_type`"'"
+#ifndef %argfail_fmt
+#define %argfail_fmt(_type,_name,_argn) "in method '" `_name` "', argument " `_argn`" of type '" `_type`"'"
+#endif
+#define %outfail_fmt(_type) "in output value of type '"_type"'"
+#ifndef %argnullref_fmt
+#define %argnullref_fmt(_type,_name,_argn) %nullref_fmt() %argfail_fmt(_type, _name, _argn)
+#endif
+#define %varnullref_fmt(_type,_name) %nullref_fmt() %varfail_fmt(_type, _name)
+#define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type)
+#define %releasenotownedfail_fmt(_type,_name,_argn) "in method '" `_name` "', cannot release ownership as memory is not owned for argument " `_argn`" of type '" `_type`"'"
+
+/* setting an error */
+#define %error(code,msg...) SWIG_Error(code, msg)
+#define %type_error(msg...) SWIG_Error(SWIG_TypeError, msg)
+
+
+
+%insert("runtime") {
+
+%define_as(SWIG_exception_fail(code, msg), %block(%error(code, msg); SWIG_fail))
+
+%define_as(SWIG_contract_assert(expr, msg), do { if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } } while (0))
+
+}
+
+#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_fail(SWIG_UnknownError, "Unknown exception");
+ }
+ }
+*/
+
+%fragment("<stdexcept>");
+
+%define SWIG_CATCH_STDEXCEPT
+ /* catching std::exception */
+ catch (std::invalid_argument& e) {
+ SWIG_exception_fail(SWIG_ValueError, e.what() );
+ } catch (std::domain_error& e) {
+ SWIG_exception_fail(SWIG_ValueError, e.what() );
+ } catch (std::overflow_error& e) {
+ SWIG_exception_fail(SWIG_OverflowError, e.what() );
+ } catch (std::out_of_range& e) {
+ SWIG_exception_fail(SWIG_IndexError, e.what() );
+ } catch (std::length_error& e) {
+ SWIG_exception_fail(SWIG_IndexError, e.what() );
+ } catch (std::runtime_error& e) {
+ SWIG_exception_fail(SWIG_RuntimeError, e.what() );
+ } catch (std::exception& e) {
+ SWIG_exception_fail(SWIG_SystemError, e.what() );
+ }
+%enddef
+%define SWIG_CATCH_UNKNOWN
+ catch (std::exception& e) {
+ SWIG_exception_fail(SWIG_SystemError, e.what() );
+ }
+ catch (...) {
+ SWIG_exception_fail(SWIG_UnknownError, "unknown exception");
+ }
+%enddef
+
+
+#endif /* __cplusplus */
diff --git a/contrib/tools/swig/Lib/typemaps/fragments.swg b/contrib/tools/swig/Lib/typemaps/fragments.swg
new file mode 100644
index 0000000000..e76a694eea
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/fragments.swg
@@ -0,0 +1,231 @@
+/*
+ Fragments
+ =========
+ See the "Typemap fragments" section in the documentation for understanding
+ fragments. Below is some info on how fragments and automatic type
+ specialization is used.
+
+ Macros that make the automatic generation of typemaps easier are provided.
+
+ Consider the following code:
+
+ %fragment(SWIG_From_frag(bool), "header") {
+ static PyObject*
+ SWIG_From_dec(bool)(bool value)
+ {
+ PyObject *obj = value ? Py_True : Py_False;
+ Py_INCREF(obj);
+ return obj;
+ }
+ }
+
+ %typemap(out, fragment=SWIG_From_frag(bool)) bool {
+ $result = SWIG_From(bool)($1));
+ }
+
+ Here the macros
+
+ SWIG_From_frag => fragment
+ SWIG_From_dec => declaration
+ SWIG_From => call
+
+ allow you to define/include a fragment, and declare and call the
+ 'from-bool' method as needed. In the simpler case, these macros
+ just return something like
+
+ SWIG_From_frag(bool) => "SWIG_From_bool"
+ SWIG_From_dec(bool) => SWIG_From_bool
+ SWIG_From(bool) => SWIG_From_bool
+
+ But they are specialized for the different languages requirements,
+ such as perl or tcl that requires passing the interpreter pointer,
+ and also they can manage C++ ugly types, for example:
+
+ SWIG_From_frag(std::complex<double>) => "SWIG_From_std_complex_Sl_double_Sg_"
+ SWIG_From_dec(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_
+ SWIG_From(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_
+
+
+ Hence, to declare methods to use with typemaps, always use the
+ SWIG_From* macros. In the same way, the SWIG_AsVal* and SWIG_AsPtr*
+ set of macros are provided.
+
+*/
+
+
+/* -----------------------------------------------------------------------------
+ * Define the basic macros to 'normalize' the type fragments
+ * ----------------------------------------------------------------------------- */
+
+#ifndef SWIG_AS_DECL_ARGS
+#define SWIG_AS_DECL_ARGS
+#endif
+
+#ifndef SWIG_FROM_DECL_ARGS
+#define SWIG_FROM_DECL_ARGS
+#endif
+
+#ifndef SWIG_AS_CALL_ARGS
+#define SWIG_AS_CALL_ARGS
+#endif
+
+#ifndef SWIG_FROM_CALL_ARGS
+#define SWIG_FROM_CALL_ARGS
+#endif
+
+#define %fragment_name(Name, Type...) %string_name(Name) "_" {Type}
+
+#define SWIG_Traits_frag(Type...) %fragment_name(Traits, Type)
+#define SWIG_AsPtr_frag(Type...) %fragment_name(AsPtr, Type)
+#define SWIG_AsVal_frag(Type...) %fragment_name(AsVal, Type)
+#define SWIG_From_frag(Type...) %fragment_name(From, Type)
+
+#define SWIG_AsVal_name(Type...) %symbol_name(AsVal, Type)
+#define SWIG_AsPtr_name(Type...) %symbol_name(AsPtr, Type)
+#define SWIG_From_name(Type...) %symbol_name(From, Type)
+
+#define SWIG_AsVal_dec(Type...) SWIG_AsVal_name(Type) SWIG_AS_DECL_ARGS
+#define SWIG_AsPtr_dec(Type...) SWIG_AsPtr_name(Type) SWIG_AS_DECL_ARGS
+#define SWIG_From_dec(Type...) SWIG_From_name(Type) SWIG_FROM_DECL_ARGS
+
+#define SWIG_AsVal(Type...) SWIG_AsVal_name(Type) SWIG_AS_CALL_ARGS
+#define SWIG_AsPtr(Type...) SWIG_AsPtr_name(Type) SWIG_AS_CALL_ARGS
+#define SWIG_From(Type...) SWIG_From_name(Type) SWIG_FROM_CALL_ARGS
+
+/* ------------------------------------------------------------
+ * common fragments
+ * ------------------------------------------------------------ */
+
+%fragment("SWIG_isfinite","header",fragment="<math.h>,<float.h>") %{
+/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */
+#ifndef SWIG_isfinite
+/* isfinite() is a macro for C99 */
+# if defined(isfinite)
+# define SWIG_isfinite(X) (isfinite(X))
+# elif defined(__cplusplus) && __cplusplus >= 201103L
+/* Use a template so that this works whether isfinite() is std::isfinite() or
+ * in the global namespace. The reality seems to vary between compiler
+ * versions.
+ *
+ * Make sure namespace std exists to avoid compiler warnings.
+ *
+ * extern "C++" is required as this fragment can end up inside an extern "C" { } block
+ */
+namespace std { }
+extern "C++" template<typename T>
+inline int SWIG_isfinite_func(T x) {
+ using namespace std;
+ return isfinite(x);
+}
+# define SWIG_isfinite(X) (SWIG_isfinite_func(X))
+# elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
+# define SWIG_isfinite(X) (__builtin_isfinite(X))
+# elif defined(_MSC_VER)
+# define SWIG_isfinite(X) (_finite(X))
+# elif defined(__sun) && defined(__SVR4)
+# include <ieeefp.h>
+# define SWIG_isfinite(X) (finite(X))
+# endif
+#endif
+%}
+
+%fragment("SWIG_Float_Overflow_Check","header",fragment="<float.h>,SWIG_isfinite") %{
+/* Accept infinite as a valid float value unless we are unable to check if a value is finite */
+#ifdef SWIG_isfinite
+# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X))
+#else
+# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX))
+#endif
+%}
+
+/* -----------------------------------------------------------------------------
+ * special macros for fragments
+ * ----------------------------------------------------------------------------- */
+
+/* Macros to derive numeric types */
+
+%define %numeric_type_from(Type, Base)
+%fragment(SWIG_From_frag(Type),"header",
+ fragment=SWIG_From_frag(Base)) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(Type)(Type value)
+{
+ return SWIG_From(Base)(value);
+}
+}
+%enddef
+
+%define %numeric_type_asval(Type, Base, Frag, OverflowCond)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=Frag,
+ fragment=SWIG_AsVal_frag(Base)) {
+SWIGINTERN int
+SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
+{
+ Base v;
+ int res = SWIG_AsVal(Base)(obj, &v);
+ if (SWIG_IsOK(res)) {
+ if (OverflowCond) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = %numeric_cast(v, Type);
+ }
+ }
+ return res;
+}
+}
+%enddef
+
+#define %numeric_signed_type_asval(Type, Base, Frag, Min, Max) \
+%numeric_type_asval(Type, Base, Frag, (v < Min || v > Max))
+
+#define %numeric_unsigned_type_asval(Type, Base, Frag, Max) \
+%numeric_type_asval(Type, Base, Frag, (v > Max))
+
+
+/* Macro for 'signed long' derived types */
+
+%define %numeric_slong(Type, Frag, Min, Max)
+%numeric_type_from(Type, long)
+%numeric_signed_type_asval(Type, long, Frag , Min, Max)
+%enddef
+
+/* Macro for 'unsigned long' derived types */
+
+%define %numeric_ulong(Type, Frag, Max)
+%numeric_type_from(Type, unsigned long)
+%numeric_unsigned_type_asval(Type, unsigned long, Frag, Max)
+%enddef
+
+
+/* Macro for floating point derived types (original macro) */
+
+%define %numeric_double(Type, Frag, Min, Max)
+%numeric_type_from(Type, double)
+%numeric_signed_type_asval(Type, double, Frag , Min, Max)
+%enddef
+
+/* Macro for floating point derived types */
+
+%define %numeric_float(Type, Frag, OverflowCond)
+%numeric_type_from(Type, double)
+%numeric_type_asval(Type, double, Frag, OverflowCond)
+%enddef
+
+
+/* Macros for missing fragments */
+
+%define %ensure_fragment(Fragment)
+%fragment(`Fragment`,"header") {
+%#error "SWIG language implementation must provide the Fragment fragment"
+}
+%enddef
+
+%define %ensure_type_fragments(Type)
+%fragment(SWIG_From_frag(Type),"header") {
+%#error "SWIG language implementation must provide a SWIG_From_frag(Type) fragment"
+}
+%fragment(SWIG_AsVal_frag(Type),"header") {
+%#error "SWIG language implementation must provide a SWIG_AsVal_frag(Type) fragment"
+}
+%enddef
diff --git a/contrib/tools/swig/Lib/typemaps/inoutlist.swg b/contrib/tools/swig/Lib/typemaps/inoutlist.swg
new file mode 100644
index 0000000000..23fda85f3a
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/inoutlist.swg
@@ -0,0 +1,296 @@
+/* ------------------------------------------------------------
+ *
+ * Define the IN/OUTPUT typemaps assuming the output parameters are
+ * returned in a list, i.e., they are not directly modified.
+ *
+ * The user should provide the %append_output(result, obj) method,
+ * via a macro, which append a particular object to the result.
+ *
+ *
+ * In Tcl, for example, the file is used as:
+ *
+ * #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj);
+ * %include <typemaps/inoutlist.swg>
+ *
+ * while in Python it is used as:
+ *
+ * #define %append_output(obj) $result = SWIG_Python_AppendResult($result, obj)
+ * %include <typemaps/inoutlist.swg>
+ *
+ * where the method SWIG_Python_AppendResult is defined inside the
+ * %append_output fragment.
+ *
+ * If you forget to define %append_output, this file will generate
+ * an error.
+ *
+ * ------------------------------------------------------------ */
+
+
+//
+// Uncomment the following definition if you don't want the in/out
+// typemaps by default, ie, you prefer to use typemaps.i.
+//
+//#define SWIG_INOUT_NODEF
+
+//
+// Use the following definition to enable the INPUT parameters to
+// accept both 'by value' and 'pointer' objects.
+//
+#define SWIG_INPUT_ACCEPT_PTRS
+
+// ------------------------------------------------------------------------
+// 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.
+
+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 :
+
+ double fadd(double *INPUT, double *INPUT);
+
+or you can use the %apply directive :
+
+ %apply double *INPUT { double *a, double *b };
+ double fadd(double *a, double *b);
+
+*/
+#if defined(SWIG_INPUT_ACCEPT_PTRS)
+#define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown))))
+#else
+#define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ERROR)))
+#endif
+
+%define %_value_input_typemap(code, asval_meth, asval_frag, Type)
+ %typemap(in,noblock=1,fragment=asval_frag) Type *INPUT ($*ltype temp, int res = 0) {
+ if (!%check_input_ptr($input,&$1,$descriptor,$disown)) {
+ Type val;
+ int ecode = asval_meth($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$*ltype",$symname, $argnum);
+ }
+ temp = %static_cast(val, $*ltype);
+ $1 = &temp;
+ res = SWIG_AddTmpMask(ecode);
+ }
+ }
+ %typemap(in,noblock=1,fragment=asval_frag) Type &INPUT($*ltype temp, int res = 0) {
+ if (!%check_input_ptr($input,&$1,$descriptor,$disown)) {
+ Type val;
+ int ecode = asval_meth($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$*ltype",$symname, $argnum);
+ }
+ temp = %static_cast(val, $*ltype);
+ $1 = &temp;
+ res = SWIG_AddTmpMask(ecode);
+ }
+ }
+ %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT {
+ if (SWIG_IsNewObj(res$argnum)) %delete($1);
+ }
+ %typemap(typecheck,noblock=1,precedence=code,fragment=asval_frag) Type *INPUT, Type &INPUT {
+ void *ptr = 0;
+ int res = asval_meth($input, 0);
+ $1 = SWIG_CheckState(res);
+ if (!$1) {
+ $1 = %check_input_ptr($input,&ptr,$1_descriptor,0);
+ }
+ }
+%enddef
+
+%define %_ptr_input_typemap(code,asptr_meth,asptr_frag,Type)
+ %typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res = 0) {
+ res = asptr_meth($input, &$1);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ res = SWIG_AddTmpMask(res);
+ }
+ %typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res = 0) {
+ res = asptr_meth($input, &$1);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ if (!$1) {
+ %argument_nullref("$type",$symname, $argnum);
+ }
+ res = SWIG_AddTmpMask(res);
+ }
+ %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT {
+ if (SWIG_IsNewObj(res$argnum)) %delete($1);
+ }
+ %typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT {
+ int res = asptr_meth($input, (Type**)0);
+ $1 = SWIG_CheckState(res);
+ }
+%enddef
+
+// 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 list.
+
+
+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):
+
+ double modf(double x, double *ip);
+
+You could wrap it with SWIG as follows :
+
+ double modf(double x, double *OUTPUT);
+
+or you can use the %apply directive :
+
+ %apply double *OUTPUT { double *ip };
+ double modf(double x, double *ip);
+
+The output of the function would be a list containing both output
+values.
+
+*/
+
+%define %_value_output_typemap(from_meth, from_frag, Type)
+ %typemap(in,numinputs=0,noblock=1)
+ Type *OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ),
+ Type &OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ) {
+ $1 = &temp;
+ }
+ %typemap(argout,noblock=1,fragment=from_frag) Type *OUTPUT, Type &OUTPUT {
+ if (SWIG_IsTmpObj(res$argnum)) {
+ %append_output(from_meth((*$1)));
+ } else {
+ int new_flags = SWIG_IsNewObj(res$argnum) ? (SWIG_POINTER_OWN | %newpointer_flags) : %newpointer_flags;
+ %append_output(SWIG_NewPointerObj((void*)($1), $1_descriptor, new_flags));
+ }
+ }
+%enddef
+
+
+// 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 list.
+
+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 :
+
+ void neg(double *INOUT);
+
+or you can use the %apply directive :
+
+ %apply double *INOUT { double *x };
+ void neg(double *x);
+
+Unlike C, this mapping does not directly modify the input value.
+Rather, the modified input value shows up as the return value of the
+function. Thus, to apply this function to a 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.
+
+*/
+
+%define %_value_inout_typemap(Type)
+ %typemap(in) Type *INOUT = Type *INPUT;
+ %typemap(in) Type &INOUT = Type &INPUT;
+ %typemap(typecheck) Type *INOUT = Type *INPUT;
+ %typemap(typecheck) Type &INOUT = Type &INPUT;
+ %typemap(argout) Type *INOUT = Type *OUTPUT;
+ %typemap(argout) Type &INOUT = Type &OUTPUT;
+%enddef
+
+
+%define %_ptr_inout_typemap(Type)
+ %_value_inout_typemap(%arg(Type))
+ %typemap(typecheck) Type *INOUT = Type *INPUT;
+ %typemap(typecheck) Type &INOUT = Type &INPUT;
+ %typemap(freearg) Type *INOUT = Type *INPUT;
+ %typemap(freearg) Type &INOUT = Type &INPUT;
+%enddef
+
+#ifndef SWIG_INOUT_NODEF
+
+%define %value_input_typemap(code,asval_meth, asval_frag, Type...)
+ %_value_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type))
+%enddef
+
+%define %ptr_input_typemap(code,asval_meth,asval_frag,Type...)
+ %_ptr_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type))
+%enddef
+
+%define %value_output_typemap(from_meth,from_frag,Type...)
+ %_value_output_typemap(%arg(from_meth),%arg(from_frag),%arg(Type))
+%enddef
+
+#define %value_inout_typemap(Type...) %_value_inout_typemap(%arg(Type))
+#define %ptr_inout_typemap(Type...) %_ptr_inout_typemap(%arg(Type))
+
+#else /* You need to include typemaps.i */
+
+
+#define %value_output_typemap(Type...)
+#define %value_input_typemap(Type...)
+#define %value_inout_typemap(Type...)
+#define %ptr_input_typemap(Type...)
+#define %ptr_inout_typemap(Type...)
+
+#endif /* SWIG_INOUT_DEFAULT */
+
+/*----------------------------------------------------------------------
+ Front ends.
+
+ use the following macros to define your own IN/OUTPUT/INOUT typemaps
+
+ ------------------------------------------------------------------------*/
+%define %typemaps_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...)
+ %_value_input_typemap(%arg(Code), %arg(AsValMeth),
+ %arg(AsValFrag), %arg(Type));
+ %_value_output_typemap(%arg(FromMeth), %arg(FromFrag), %arg(Type));
+ %_value_inout_typemap(%arg(Type));
+%enddef
+
+%define %typemaps_inoutn(Code,Type...)
+ %typemaps_inout(%arg(Code),
+ %arg(SWIG_AsVal(Type)),
+ %arg(SWIG_From(Type)),
+ %arg(SWIG_AsVal_frag(Type)),
+ %arg(SWIG_From_frag(Type)),
+ %arg(Type));
+%enddef
diff --git a/contrib/tools/swig/Lib/typemaps/misctypes.swg b/contrib/tools/swig/Lib/typemaps/misctypes.swg
new file mode 100644
index 0000000000..09c81d7433
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/misctypes.swg
@@ -0,0 +1,21 @@
+
+/* ------------------------------------------------------------
+ * --- ANSI/Posix C/C++ types ---
+ * ------------------------------------------------------------ */
+
+
+#ifdef __cplusplus
+
+%apply size_t { std::size_t };
+%apply const size_t& { const std::size_t& };
+
+%apply ptrdiff_t { std::ptrdiff_t };
+%apply const ptrdiff_t& { const std::ptrdiff_t& };
+
+#ifndef SWIG_INOUT_NODEF
+%apply size_t& { std::size_t& };
+%apply ptrdiff_t& { std::ptrdiff_t& };
+#endif
+
+#endif
+
diff --git a/contrib/tools/swig/Lib/typemaps/primtypes.swg b/contrib/tools/swig/Lib/typemaps/primtypes.swg
new file mode 100644
index 0000000000..dd80eb775e
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/primtypes.swg
@@ -0,0 +1,367 @@
+/* ------------------------------------------------------------
+ * Primitive type fragments and macros
+ * ------------------------------------------------------------ */
+
+/*
+ This file provide fragments and macros for the C/C++ primitive types.
+
+ The file defines default fragments for the following types:
+
+ bool
+ signed char
+ unsigned char
+ signed wchar_t // in C++
+ unsigned wchar_t // in C++
+ short
+ unsigned short
+ int
+ unsigned int
+ float
+ size_t
+ ptrdiff_t
+
+ which can always be redefined in the swig target language if needed.
+
+ The fragments for the following types, however, always need to be
+ defined in the target language:
+
+ long
+ unsigned long
+ long long
+ unsigned long long
+ double
+
+ If they are not provided, an #error directive will appear in the
+ wrapped code.
+
+ --------------------------------------------------------------------
+
+ This file provides the macro
+
+ %typemaps_primitive(CheckCode, Type)
+
+ which generates the typemaps for a primitive type with a given
+ checkcode. It is assumed that the primitive type is 'normalized' and
+ the corresponding SWIG_AsVal(Type) and SWIG_From(Type) methods are
+ provided via fragments.
+
+
+ The following auxiliary macros (explained with bash pseudo code) are
+ also defined:
+
+ %apply_ctypes(Macro)
+ for i in C Type
+ do
+ Macro($i)
+ done
+
+ %apply_cpptypes(Macro)
+ for i in C++ Type
+ do
+ Macro($i)
+ done
+
+ %apply_ctypes_2(Macro2)
+ for i in C Type
+ do
+ for j in C Type
+ do
+ Macro_2($i, $j)
+ done
+ done
+
+ %apply_cpptypes_2(Macro2)
+ for i in C++ Type
+ do
+ for j in C++ Type
+ do
+ Macro_2($i, $j)
+ done
+ done
+
+ %apply_checkctypes(Macro2)
+ for i in Check Type
+ do
+ Macro2(%checkcode($i), $i)
+ done
+
+*/
+
+
+/* ------------------------------------------------------------
+ * Primitive type fragments
+ * ------------------------------------------------------------ */
+/* boolean */
+
+%fragment(SWIG_From_frag(bool),"header",fragment=SWIG_From_frag(long)) {
+SWIGINTERN SWIG_Object
+SWIG_From_dec(bool)(bool value)
+{
+ return SWIG_From(long)(value ? 1 : 0);
+}
+}
+
+%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val)
+{
+ long v;
+ int res = SWIG_AsVal(long)(obj, val ? &v : 0);
+ if (SWIG_IsOK(res)) {
+ if (val) *val = v ? true : false;
+ return res;
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* signed/unsigned char */
+
+%numeric_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
+%numeric_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
+
+/* short/unsigned short */
+
+%numeric_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
+%numeric_ulong(unsigned short, "<limits.h>", USHRT_MAX)
+
+/* int/unsigned int */
+
+%numeric_slong(int, "<limits.h>", INT_MIN, INT_MAX)
+%numeric_ulong(unsigned int, "<limits.h>", UINT_MAX)
+
+/* signed/unsigned wchar_t */
+
+#ifdef __cplusplus
+%numeric_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
+%numeric_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
+#endif
+
+/* float */
+
+%numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v))
+
+/* long/unsigned long */
+
+%ensure_type_fragments(long)
+%ensure_type_fragments(unsigned long)
+
+/* long long/unsigned long long */
+
+%fragment("SWIG_LongLongAvailable","header", fragment="<limits.h>") %{
+#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE)
+# define SWIG_LONG_LONG_AVAILABLE
+#endif
+%}
+
+%ensure_type_fragments(long long)
+%ensure_type_fragments(unsigned long long)
+
+/* double */
+
+%ensure_type_fragments(double)
+
+/* size_t */
+
+%fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long),fragment=SWIG_From_frag(unsigned long long)) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(size_t)(size_t value)
+{
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ if (sizeof(size_t) <= sizeof(unsigned long)) {
+%#endif
+ return SWIG_From(unsigned long)(%numeric_cast(value, unsigned long));
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ } else {
+ /* assume sizeof(size_t) <= sizeof(unsigned long long) */
+ return SWIG_From(unsigned long long)(%numeric_cast(value, unsigned long long));
+ }
+%#endif
+}
+}
+
+%fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long),fragment=SWIG_AsVal_frag(unsigned long long)) {
+SWIGINTERNINLINE int
+SWIG_AsVal_dec(size_t)(SWIG_Object obj, size_t *val)
+{
+ int res = SWIG_TypeError;
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ if (sizeof(size_t) <= sizeof(unsigned long)) {
+%#endif
+ unsigned long v;
+ res = SWIG_AsVal(unsigned long)(obj, val ? &v : 0);
+ if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t);
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
+ unsigned long long v;
+ res = SWIG_AsVal(unsigned long long)(obj, val ? &v : 0);
+ if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t);
+ }
+%#endif
+ return res;
+}
+}
+
+/* ptrdiff_t */
+
+%fragment(SWIG_From_frag(ptrdiff_t),"header",fragment=SWIG_From_frag(long),fragment=SWIG_From_frag(long long)) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(ptrdiff_t)(ptrdiff_t value)
+{
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ if (sizeof(ptrdiff_t) <= sizeof(long)) {
+%#endif
+ return SWIG_From(long)(%numeric_cast(value, long));
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ } else {
+ /* assume sizeof(ptrdiff_t) <= sizeof(long long) */
+ return SWIG_From(long long)(%numeric_cast(value, long long));
+ }
+%#endif
+}
+}
+
+%fragment(SWIG_AsVal_frag(ptrdiff_t),"header",fragment=SWIG_AsVal_frag(long),fragment=SWIG_AsVal_frag(long long)) {
+SWIGINTERNINLINE int
+SWIG_AsVal_dec(ptrdiff_t)(SWIG_Object obj, ptrdiff_t *val)
+{
+ int res = SWIG_TypeError;
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ if (sizeof(ptrdiff_t) <= sizeof(long)) {
+%#endif
+ long v;
+ res = SWIG_AsVal(long)(obj, val ? &v : 0);
+ if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t);
+%#ifdef SWIG_LONG_LONG_AVAILABLE
+ } else if (sizeof(ptrdiff_t) <= sizeof(long long)) {
+ long long v;
+ res = SWIG_AsVal(long long)(obj, val ? &v : 0);
+ if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t);
+ }
+%#endif
+ return res;
+}
+}
+
+
+%fragment("SWIG_CanCastAsInteger","header",
+ fragment=SWIG_AsVal_frag(double),
+ fragment="<float.h>",
+ fragment="<math.h>") {
+SWIGINTERNINLINE int
+SWIG_CanCastAsInteger(double *d, double min, double max) {
+ double x = *d;
+ if ((min <= x && x <= max)) {
+ double fx = floor(x);
+ double cx = ceil(x);
+ double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+ if ((errno == EDOM) || (errno == ERANGE)) {
+ errno = 0;
+ } else {
+ double summ, reps, diff;
+ if (rd < x) {
+ diff = x - rd;
+ } else if (rd > x) {
+ diff = rd - x;
+ } else {
+ return 1;
+ }
+ summ = rd + x;
+ reps = diff/summ;
+ if (reps < 8*DBL_EPSILON) {
+ *d = rd;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+}
+
+/* ------------------------------------------------------------
+ * Generate the typemaps for primitive type
+ * ------------------------------------------------------------ */
+
+#define %typemaps_primitive(Code, Type) %typemaps_asvalfromn(%arg(Code), Type)
+
+/* ------------------------------------------------------------
+ * Primitive Type Macros
+ * ------------------------------------------------------------ */
+
+/* useful macros to derive typemap declarations from primitive types */
+
+%define _apply_macro(macro, arg2, arg1...)
+#if #arg1 != ""
+macro(%arg(arg1),arg2);
+#else
+macro(arg2);
+#endif
+%enddef
+
+/* Apply macro to the C-types */
+%define %apply_ctypes(Macro, Arg2...)
+_apply_macro(Macro, bool , Arg2);
+_apply_macro(Macro, signed char , Arg2);
+_apply_macro(Macro, unsigned char , Arg2);
+_apply_macro(Macro, short , Arg2);
+_apply_macro(Macro, unsigned short , Arg2);
+_apply_macro(Macro, int , Arg2);
+_apply_macro(Macro, unsigned int , Arg2);
+_apply_macro(Macro, long , Arg2);
+_apply_macro(Macro, unsigned long , Arg2);
+_apply_macro(Macro, long long , Arg2);
+_apply_macro(Macro, unsigned long long , Arg2);
+_apply_macro(Macro, float , Arg2);
+_apply_macro(Macro, double , Arg2);
+_apply_macro(Macro, char , Arg2);
+_apply_macro(Macro, wchar_t , Arg2);
+_apply_macro(Macro, size_t , Arg2);
+_apply_macro(Macro, ptrdiff_t , Arg2);
+%enddef
+
+/* apply the Macro2(Type1, Type2) to all C types */
+#define %apply_ctypes_2(Macro2) %apply_ctypes(%apply_ctypes, Macro2)
+
+
+/* apply the Macro(Type) to all C++ types */
+%define %apply_cpptypes(Macro, Arg2...)
+%apply_ctypes(Macro, Arg2)
+_apply_macro(Macro, std::size_t, Arg2);
+_apply_macro(Macro, std::ptrdiff_t, Arg2);
+_apply_macro(Macro, std::string, Arg2);
+_apply_macro(Macro, std::wstring, Arg2);
+_apply_macro(Macro, std::complex<float>, Arg2);
+_apply_macro(Macro, std::complex<double>, Arg2);
+%enddef
+
+/* apply the Macro2(Type1, Type2) to all C++ types */
+#define %apply_cpptypes_2(Macro2) %apply_cpptypes(%apply_cpptypes, Macro2)
+
+/* apply the Macro2(CheckCode,Type) to all Checked Types */
+%define %apply_checkctypes(Macro2)
+Macro2(%checkcode(BOOL), bool);
+Macro2(%checkcode(INT8), signed char);
+Macro2(%checkcode(UINT8), unsigned char);
+Macro2(%checkcode(INT16), short);
+Macro2(%checkcode(UINT16), unsigned short);
+Macro2(%checkcode(INT32), int);
+Macro2(%checkcode(UINT32), unsigned int);
+Macro2(%checkcode(INT64), long);
+Macro2(%checkcode(UINT64), unsigned long);
+Macro2(%checkcode(INT128), long long);
+Macro2(%checkcode(UINT128), unsigned long long);
+Macro2(%checkcode(FLOAT), float);
+Macro2(%checkcode(DOUBLE), double);
+Macro2(%checkcode(CHAR), char);
+Macro2(%checkcode(UNICHAR), wchar_t);
+Macro2(%checkcode(SIZE), size_t);
+Macro2(%checkcode(PTRDIFF), ptrdiff_t);
+%enddef
+
+
+/* ------------------------------------------------------------
+ * Generate the typemaps for all the primitive types with checkcode
+ * ------------------------------------------------------------ */
+
+%apply_checkctypes(%typemaps_primitive);
+
diff --git a/contrib/tools/swig/Lib/typemaps/ptrtypes.swg b/contrib/tools/swig/Lib/typemaps/ptrtypes.swg
new file mode 100644
index 0000000000..ca54fcdc26
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/ptrtypes.swg
@@ -0,0 +1,208 @@
+/* -----------------------------------------------------------------------------
+ * ptrtypes.swg
+ *
+ * Value typemaps (Type, const Type&) for "Ptr" types, such as swig
+ * wrapped classes, that define the AsPtr/From methods
+ *
+ * To apply them, just use one of the following macros:
+ *
+ * %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type)
+ * %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type)
+ *
+ * or the simpler and normalize form:
+ *
+ * %typemaps_asptrfromn(CheckCode, Type)
+ *
+ * Also, you can use the individual typemap definitions:
+ *
+ * %ptr_in_typemap(asptr_meth,frag,Type)
+ * %ptr_varin_typemap(asptr_meth,frag,Type)
+ * %ptr_typecheck_typemap(check,asptr_meth,frag,Type)
+ * %ptr_directorout_typemap(asptr_meth,frag,Type)
+ * ----------------------------------------------------------------------------- */
+
+%include <typemaps/valtypes.swg>
+
+/* in */
+
+%define %ptr_in_typemap(asptr_meth,frag,Type...)
+ %typemap(in,fragment=frag) Type {
+ Type *ptr = (Type *)0;
+ int res = asptr_meth($input, &ptr);
+ if (!SWIG_IsOK(res) || !ptr) {
+ %argument_fail((ptr ? res : SWIG_TypeError), "$type", $symname, $argnum);
+ }
+ $1 = *ptr;
+ if (SWIG_IsNewObj(res)) %delete(ptr);
+ }
+ %typemap(freearg) Type ""
+ %typemap(in,fragment=frag) const Type & (int res = SWIG_OLDOBJ) {
+ Type *ptr = (Type *)0;
+ res = asptr_meth($input, &ptr);
+ if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); }
+ if (!ptr) { %argument_nullref("$type",$symname, $argnum); }
+ $1 = ptr;
+ }
+ %typemap(freearg,noblock=1) const Type & {
+ if (SWIG_IsNewObj(res$argnum)) %delete($1);
+ }
+%enddef
+
+/* varin */
+
+%define %ptr_varin_typemap(asptr_meth,frag,Type...)
+ %typemap(varin,fragment=frag) Type {
+ Type *ptr = (Type *)0;
+ int res = asptr_meth($input, &ptr);
+ if (!SWIG_IsOK(res) || !ptr) {
+ %variable_fail((ptr ? res : SWIG_TypeError), "$type", "$name");
+ }
+ $1 = *ptr;
+ if (SWIG_IsNewObj(res)) %delete(ptr);
+ }
+%enddef
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+/* directorout */
+
+%define %ptr_directorout_typemap(asptr_meth,frag,Type...)
+ %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp, int swig_ores) {
+ Type *swig_optr = 0;
+ swig_ores = $result ? asptr_meth($result, &swig_optr) : 0;
+ if (!SWIG_IsOK(swig_ores) || !swig_optr) {
+ %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type");
+ }
+ temp = *swig_optr;
+ $1 = &temp;
+ if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr);
+ }
+
+ %typemap(directorout,noblock=1,fragment=frag) Type {
+ Type *swig_optr = 0;
+ int swig_ores = asptr_meth($input, &swig_optr);
+ if (!SWIG_IsOK(swig_ores) || !swig_optr) {
+ %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type");
+ }
+ $result = *swig_optr;
+ if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr);
+ }
+
+ %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type* {
+ Type *swig_optr = 0;
+ int swig_ores = asptr_meth($input, &swig_optr);
+ if (!SWIG_IsOK(swig_ores)) {
+ %dirout_fail(swig_ores,"$type");
+ }
+ $result = swig_optr;
+ if (SWIG_IsNewObj(swig_ores)) {
+ swig_acquire_ownership(swig_optr);
+ }
+ }
+ %typemap(directorfree,noblock=1) Type*
+ {
+ if (director) {
+ director->swig_release_ownership(%as_voidptr($input));
+ }
+ }
+
+ %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type& {
+ Type *swig_optr = 0;
+ int swig_ores = asptr_meth($input, &swig_optr);
+ if (!SWIG_IsOK(swig_ores)) {
+ %dirout_fail(swig_ores,"$type");
+ } else {
+ if (!swig_optr) {
+ %dirout_nullref("$type");
+ }
+ }
+ $result = swig_optr;
+ if (SWIG_IsNewObj(swig_ores)) {
+ swig_acquire_ownership(swig_optr);
+ }
+ }
+ %typemap(directorfree,noblock=1) Type&
+ {
+ if (director) {
+ director->swig_release_ownership(%as_voidptr($input));
+ }
+ }
+
+
+ %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
+
+%enddef
+
+#else
+
+#define %ptr_directorout_typemap(asptr_meth,frag,Type...)
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
+/* typecheck */
+
+%define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...)
+%typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type * {
+ int res = asptr_meth($input, (Type**)(0));
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type, const Type& {
+ int res = asptr_meth($input, (Type**)(0));
+ $1 = SWIG_CheckState(res);
+}
+%enddef
+
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with asptr method
+ *---------------------------------------------------------------------*/
+
+%define %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type...)
+ %fragment(SWIG_AsVal_frag(Type),"header",fragment=SWIG_AsPtr_frag(Type)) {
+ SWIGINTERNINLINE int
+ SWIG_AsVal(Type)(SWIG_Object obj, Type *val)
+ {
+ Type *v = (Type *)0;
+ int res = SWIG_AsPtr(Type)(obj, &v);
+ if (!SWIG_IsOK(res)) return res;
+ if (v) {
+ if (val) *val = *v;
+ if (SWIG_IsNewObj(res)) {
+ %delete(v);
+ res = SWIG_DelNewMask(res);
+ }
+ return res;
+ }
+ return SWIG_ERROR;
+ }
+ }
+ %ptr_in_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
+ %ptr_varin_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
+ %ptr_directorout_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
+ %ptr_typecheck_typemap(%arg(CheckCode), %arg(AsPtrMeth),%arg(AsPtrFrag), Type);
+ %ptr_input_typemap(%arg(CheckCode),%arg(AsPtrMeth),%arg(AsPtrFrag),Type);
+%enddef
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with asptr/from methods
+ *---------------------------------------------------------------------*/
+
+%define %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...)
+ %typemaps_asptr(%arg(CheckCode), %arg(AsPtrMeth), %arg(AsPtrFrag), Type)
+ %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %ptr_inout_typemap(Type);
+%enddef
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with for 'normalized' asptr/from methods
+ *---------------------------------------------------------------------*/
+
+%define %typemaps_asptrfromn(CheckCode, Type...)
+%typemaps_asptrfrom(%arg(CheckCode),
+ %arg(SWIG_AsPtr(Type)),
+ %arg(SWIG_From(Type)),
+ %arg(SWIG_AsPtr_frag(Type)),
+ %arg(SWIG_From_frag(Type)),
+ Type);
+%enddef
diff --git a/contrib/tools/swig/Lib/typemaps/string.swg b/contrib/tools/swig/Lib/typemaps/string.swg
new file mode 100644
index 0000000000..72f4aa5b56
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/string.swg
@@ -0,0 +1,36 @@
+%ensure_fragment(SWIG_AsCharPtrAndSize)
+%ensure_fragment(SWIG_FromCharPtrAndSize)
+
+%types(char *);
+
+%fragment("SWIG_pchar_descriptor","header") {
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor(void)
+{
+ static int init = 0;
+ static swig_type_info* info = 0;
+ if (!init) {
+ info = SWIG_TypeQuery("_p_char");
+ init = 1;
+ }
+ return info;
+}
+}
+
+%fragment("SWIG_strnlen","header",fragment="SWIG_FromCharPtrAndSize") {
+SWIGINTERN size_t
+SWIG_strnlen(const char* s, size_t maxlen)
+{
+ const char *p;
+ for (p = s; maxlen-- && *p; p++)
+ ;
+ return p - s;
+}
+}
+
+%include <typemaps/strings.swg>
+%typemaps_string(%checkcode(STRING), %checkcode(CHAR),
+ SWIGWARN_TYPEMAP_CHARLEAK_MSG,
+ char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize,
+ strlen, SWIG_strnlen,
+ "<limits.h>", CHAR_MIN, CHAR_MAX)
diff --git a/contrib/tools/swig/Lib/typemaps/strings.swg b/contrib/tools/swig/Lib/typemaps/strings.swg
new file mode 100644
index 0000000000..1237d98dfd
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/strings.swg
@@ -0,0 +1,658 @@
+//
+// Use the macro SWIG_PRESERVE_CARRAY_SIZE if you prefer to preserve
+// the size of char arrays, ie
+// ------------------------------------------
+// C Side => Language Side
+// ------------------------------------------
+// char name[5] = "hola" => 'hola\0'
+//
+// the default behaviour is
+//
+// char name[5] = "hola" => 'hola'
+//
+//
+//#define SWIG_PRESERVE_CARRAY_SIZE
+
+/* ------------------------------------------------------------
+ * String typemaps for type Char (char or wchar_t)
+ * ------------------------------------------------------------ */
+
+%define %_typemap_string(StringCode,
+ Char,
+ WarningLeakMsg,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ SWIG_AsCharPtr,
+ SWIG_FromCharPtr,
+ SWIG_AsCharArray,
+ SWIG_NewCopyCharArray,
+ SWIG_DeleteCharArray)
+
+/* in */
+
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr)
+ Char * (int res, Char *buf = 0, int alloc = 0),
+ const Char * (int res, Char *buf = 0, int alloc = 0) {
+ res = SWIG_AsCharPtr($input, &buf, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $1 = %reinterpret_cast(buf, $1_ltype);
+}
+%typemap(freearg,noblock=1,match="in") Char *, const Char * {
+ if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
+}
+
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (int res, Char *buf = 0, int alloc = 0) {
+ res = SWIG_AsCharPtr($input, &buf, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $1 = &buf;
+}
+%typemap(freearg, noblock=1,match="in") Char const*& {
+ if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
+}
+
+/* out */
+
+%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * {
+ %set_output(SWIG_FromCharPtr((const Char *)$1));
+}
+
+
+%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& {
+ %set_output(SWIG_FromCharPtr(*$1));
+}
+
+%typemap(newfree,noblock=1) Char * {
+ SWIG_DeleteCharArray($1);
+}
+
+/* varin */
+
+%typemap(varin,fragment=#SWIG_AsCharPtrAndSize) Char * {
+ Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
+ int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res,"$type","$name");
+ }
+ SWIG_DeleteCharArray($1);
+ if (alloc == SWIG_NEWOBJ) {
+ $1 = cptr;
+ } else {
+ $1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0;
+ }
+}
+
+%typemap(varin,fragment=#SWIG_AsCharPtrAndSize,warning=WarningLeakMsg) const Char * {
+ Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
+ int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (alloc == SWIG_NEWOBJ) {
+ $1 = cptr;
+ } else {
+ $1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0;
+ }
+}
+
+/* varout */
+
+%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * {
+ %set_varoutput(SWIG_FromCharPtr($1));
+}
+
+/* memberin */
+
+%typemap(memberin,noblock=1) Char * {
+ SWIG_DeleteCharArray($1);
+ if ($input) {
+ size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1;
+ $1 = ($1_type)SWIG_NewCopyCharArray(%reinterpret_cast($input, const Char *), size, Char);
+ } else {
+ $1 = 0;
+ }
+}
+
+%typemap(memberin,noblock=1,warning=WarningLeakMsg) const Char * {
+ if ($input) {
+ size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
+ $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
+ } else {
+ $1 = 0;
+ }
+}
+
+/* globalin */
+
+%typemap(globalin,noblock=1) Char * {
+ SWIG_DeleteCharArray($1);
+ if ($input) {
+ size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
+ $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
+ } else {
+ $1 = 0;
+ }
+}
+
+%typemap(globalin,noblock=1,warning=WarningLeakMsg) const Char * {
+ if ($input) {
+ size_t size = SWIG_CharPtrLen($input) + 1;
+ $1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
+ } else {
+ $1 = 0;
+ }
+}
+
+/* constant */
+
+%typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr)
+ Char *, Char const*, Char * const, Char const* const {
+ %set_constant("$symname", SWIG_FromCharPtr($value));
+}
+
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+
+%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr)
+ Char *, Char const*, Char *const, Char const *const,
+ Char const *&, Char *const &, Char const *const & {
+ $input = SWIG_FromCharPtr((const Char *)$1);
+}
+
+
+/* directorout */
+
+%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char * (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) {
+ res = SWIG_AsCharPtr($input, &buf, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %dirout_fail(res, "$type");
+ }
+ if (alloc == SWIG_NEWOBJ) {
+ swig_acquire_ownership_array(buf);
+ }
+ $result = %reinterpret_cast(buf, $1_ltype);
+}
+%typemap(directorfree,noblock=1) Char *
+{
+ if (director) {
+ director->swig_release_ownership(%as_voidptr($input));
+ }
+}
+
+
+%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char *const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ), Char const*const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) {
+ res = SWIG_AsCharPtr($input, &buf, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %dirout_fail(res, "$type");
+ }
+ static $*1_ltype tmp = buf;
+ $result = &tmp;
+ if (alloc == SWIG_NEWOBJ) {
+ swig_acquire_ownership_array(buf);
+ }
+}
+%typemap(directorfree,noblock=1)
+ Char * const&, Char const* const& {
+ if (director) {
+ director->swig_release_ownership(%as_voidptr(*$input));
+ }
+}
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
+/* typecheck */
+
+%typemap(typecheck,noblock=1,precedence=StringCode,
+ fragment=#SWIG_AsCharPtr) Char *, const Char *, Char const*& {
+ int res = SWIG_AsCharPtr($input, 0, 0);
+ $1 = SWIG_CheckState(res);
+}
+
+
+/* throws */
+
+%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * {
+ %raise(SWIG_FromCharPtr($1), "$type", 0);
+}
+
+
+/* ------------------------------------------------------------
+ * Unknown size const Character array Char[ANY] handling
+ * ------------------------------------------------------------ */
+
+%apply Char * { Char [] };
+%apply const Char * { const Char [] };
+
+%typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char []
+{
+ %variable_fail(SWIG_AttributeError, "$type", "read-only $name");
+}
+
+
+/* ------------------------------------------------------------
+ * Fixed size Character array Char[ANY] handling
+ * ------------------------------------------------------------ */
+
+/* memberin and globalin typemaps */
+
+%typemap(memberin,noblock=1) Char [ANY]
+{
+ if ($input) memcpy($1,$input,$1_dim0*sizeof(Char));
+ else memset($1,0,$1_dim0*sizeof(Char));
+}
+
+%typemap(globalin,noblock=1) Char [ANY]
+{
+ if ($input) memcpy($1,$input,$1_dim0*sizeof(Char));
+ else memset($1,0,$1_dim0*sizeof(Char));
+}
+
+/* in */
+
+%typemap(in,noblock=1,fragment=#SWIG_AsCharArray)
+ Char [ANY] (Char temp[$1_dim0], int res),
+ const Char [ANY](Char temp[$1_dim0], int res)
+{
+ res = SWIG_AsCharArray($input, temp, $1_dim0);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $1 = %reinterpret_cast(temp, $1_ltype);
+}
+%typemap(freearg) Char [ANY], const Char [ANY] ""
+
+%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0], int res)
+{
+ res = SWIG_AsCharArray($input, temp, $1_dim0);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $1 = &temp;
+}
+%typemap(freearg) const Char (&)[ANY] ""
+
+%typemap(out,fragment=#SWIG_FromCharPtrAndSize,fragment=#SWIG_CharBufLen)
+ Char [ANY], const Char[ANY]
+{
+%#ifndef SWIG_PRESERVE_CARRAY_SIZE
+ size_t size = SWIG_CharBufLen($1, $1_dim0);
+%#else
+ size_t size = $1_dim0;
+%#endif
+ %set_output(SWIG_FromCharPtrAndSize($1, size));
+}
+
+/* varin */
+
+%typemap(varin,fragment=#SWIG_AsCharArray) Char [ANY]
+{
+ int res = SWIG_AsCharArray($input, $1, $1_dim0);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+}
+
+/* varout */
+
+%typemap(varout,fragment=#SWIG_CharBufLen)
+ Char [ANY], const Char [ANY] {
+%#ifndef SWIG_PRESERVE_CARRAY_SIZE
+ size_t size = SWIG_CharBufLen($1, $1_dim0);
+%#else
+ size_t size = $1_dim0;
+%#endif
+ %set_varoutput(SWIG_FromCharPtrAndSize($1, size));
+}
+
+/* constant */
+
+%typemap(constcode,fragment=#SWIG_CharBufLen)
+ Char [ANY], const Char [ANY]
+{
+%#ifndef SWIG_PRESERVE_CARRAY_SIZE
+ size_t size = SWIG_CharBufLen($1, $1_dim0);
+%#else
+ size_t size = $value_dim0;
+%#endif
+ %set_constant("$symname", SWIG_FromCharPtrAndSize($value,size));
+}
+
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+%typemap(directorin,fragment=#SWIG_CharBufLen)
+ Char [ANY], const Char [ANY]
+{
+%#ifndef SWIG_PRESERVE_CARRAY_SIZE
+ size_t size = SWIG_CharBufLen($1, $1_dim0);
+%#else
+ size_t size = $1_dim0;
+%#endif
+ $input = SWIG_FromCharPtrAndSize($1, size);
+}
+
+/* directorout */
+
+%typemap(directorout,noblock=1,fragment=#SWIG_AsCharArray)
+ Char [ANY] (Char temp[$result_dim0]),
+ const Char [ANY] (Char temp[$result_dim0], int res)
+{
+ res = SWIG_AsCharArray($input, temp, $result_dim0);
+ if (!SWIG_IsOK(res)) {
+ %dirout_fail(res, "$type");
+ }
+ $result = temp;
+}
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
+/* typecheck */
+
+%typemap(typecheck,noblock=1,precedence=StringCode,
+ fragment=#SWIG_AsCharArray)
+ Char [ANY], const Char[ANY] {
+ int res = SWIG_AsCharArray($input, (Char *)0, $1_dim0);
+ $1 = SWIG_CheckState(res);
+}
+
+
+/* throws */
+
+%typemap(throws,fragment=#SWIG_CharBufLen)
+ Char [ANY], const Char[ANY]
+{
+%#ifndef SWIG_PRESERVE_CARRAY_SIZE
+ size_t size = SWIG_CharBufLen($1, $1_dim0);
+%#else
+ size_t size = $1_dim0;
+%#endif
+ %raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0);
+}
+
+/* -------------------------------------------------------------------
+ * --- Really fix size Char arrays, including '\0'chars at the end ---
+ * ------------------------------------------------------------------- */
+
+%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
+ Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
+{
+ %set_varoutput(SWIG_FromCharPtrAndSize($1, $1_dim0));
+}
+
+%typemap(out,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
+ Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
+{
+ %set_output(SWIG_FromCharPtrAndSize($1, $1_dim0));
+}
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
+ Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
+{
+ $input = SWIG_FromCharPtrAndSize($1, $1_dim0);
+}
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
+%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
+ Char FIXSIZE[ANY], const Char FIXSIZE[ANY] {
+ %raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0);
+}
+
+/* ------------------------------------------------------------
+ * --- String & length ---
+ * ------------------------------------------------------------ */
+
+/* Here len doesn't include the '0' terminator */
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
+ (Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
+ (const Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
+{
+ res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $1 = %reinterpret_cast(buf, $1_ltype);
+ $2 = %numeric_cast(size - 1, $2_ltype);
+}
+%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t LENGTH) {
+ if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
+}
+/* old 'int' form */
+%typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
+%typemap(freearg) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
+
+
+/* Here size includes the '0' terminator */
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
+ (Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
+ (const Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
+{
+ res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $1 = %reinterpret_cast(buf, $1_ltype);
+ $2 = %numeric_cast(size, $2_ltype);
+}
+%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t SIZE) {
+ if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
+}
+/* old 'int' form */
+%typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
+%typemap(freearg) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
+
+
+/* reverse order versions */
+
+/* Here len doesn't include the '0' terminator */
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
+ (size_t LENGTH, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
+ (size_t LENGTH, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
+{
+ res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+ $2 = %reinterpret_cast(buf, $2_ltype) ;
+ $1 = %numeric_cast(size - 1, $1_ltype) ;
+}
+%typemap(freearg, noblock=1, match="in") (size_t LENGTH, Char *STRING) {
+ if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
+}
+/* old 'int' form */
+%typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
+%typemap(freearg) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
+
+/* Here size includes the '0' terminator */
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
+ (size_t SIZE, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
+ (size_t SIZE, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
+{
+ res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type",$symname, $argnum);
+ }
+ $2 = %reinterpret_cast(buf, $2_ltype) ;
+ $1 = %numeric_cast(size, $1_ltype) ;
+}
+%typemap(freearg, noblock=1, match="in") (size_t SIZE, Char *STRING) {
+ if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
+}
+/* old 'int' form */
+%typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
+%typemap(freearg) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
+
+
+%enddef
+
+
+/* ------------------------------------------------------------
+ * --- String fragment methods ---
+ * ------------------------------------------------------------ */
+
+#ifndef %_typemap2_string
+%define %_typemap2_string(StringCode, CharCode,
+ WarningLeakMsg,
+ Char, CharName,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ SWIG_NewCopyCharArray,
+ SWIG_DeleteCharArray,
+ FragLimits, CHAR_MIN, CHAR_MAX)
+
+%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From##CharName##Ptr(const Char *cptr)
+{
+ return SWIG_FromCharPtrAndSize(cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0));
+}
+}
+
+%fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From##CharName##Array(const Char *cptr, size_t size)
+{
+ return SWIG_FromCharPtrAndSize(cptr, size);
+}
+}
+
+%fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) {
+%define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc))
+}
+
+%fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) {
+SWIGINTERN int
+SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
+{
+ Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ;
+ int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc);
+ if (SWIG_IsOK(res)) {
+ /* special case of single char conversion when we don't need space for NUL */
+ if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize;
+ if (csize <= size) {
+ if (val) {
+ if (csize) memcpy(val, cptr, csize*sizeof(Char));
+ if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
+ }
+ if (alloc == SWIG_NEWOBJ) {
+ SWIG_DeleteCharArray(cptr);
+ res = SWIG_DelNewMask(res);
+ }
+ return res;
+ }
+ if (alloc == SWIG_NEWOBJ) SWIG_DeleteCharArray(cptr);
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* Char */
+
+%fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(Char)(Char c)
+{
+ return SWIG_FromCharPtrAndSize(&c,1);
+}
+}
+
+%fragment(SWIG_AsVal_frag(Char),"header",
+ fragment="SWIG_As"#CharName"Array",
+ fragment=FragLimits,
+ fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN int
+SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
+{
+ int res = SWIG_As##CharName##Array(obj, val, 1);
+ if (!SWIG_IsOK(res)) {
+ long v;
+ res = SWIG_AddCast(SWIG_AsVal(long)(obj, &v));
+ if (SWIG_IsOK(res)) {
+ if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) {
+ if (val) *val = %numeric_cast(v, Char);
+ } else {
+ res = SWIG_OverflowError;
+ }
+ }
+ }
+ return res;
+}
+}
+
+%_typemap_string(StringCode,
+ Char,
+ WarningLeakMsg,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ SWIG_As##CharName##Ptr,
+ SWIG_From##CharName##Ptr,
+ SWIG_As##CharName##Array,
+ SWIG_NewCopyCharArray,
+ SWIG_DeleteCharArray)
+
+%enddef
+#endif
+
+/* ------------------------------------------------------------
+ * String typemaps and fragments, with default allocators
+ * ------------------------------------------------------------ */
+
+%define %typemaps_string(StringCode, CharCode,
+ WarningLeakMsg,
+ Char, CharName,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ FragLimits, CHAR_MIN, CHAR_MAX)
+%_typemap2_string(StringCode, CharCode,
+ WarningLeakMsg,
+ Char, CharName,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ %new_copy_array,
+ %delete_array,
+ FragLimits, CHAR_MIN, CHAR_MAX)
+%enddef
+
+/* ------------------------------------------------------------
+ * String typemaps and fragments, with custom allocators
+ * ------------------------------------------------------------ */
+
+%define %typemaps_string_alloc(StringCode, CharCode,
+ WarningLeakMsg,
+ Char, CharName,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ SWIG_NewCopyCharArray,
+ SWIG_DeleteCharArray,
+ FragLimits, CHAR_MIN, CHAR_MAX)
+%_typemap2_string(StringCode, CharCode,
+ WarningLeakMsg,
+ Char, CharName,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtrAndSize,
+ SWIG_CharPtrLen,
+ SWIG_CharBufLen,
+ SWIG_NewCopyCharArray,
+ SWIG_DeleteCharArray,
+ FragLimits, CHAR_MIN, CHAR_MAX)
+%enddef
diff --git a/contrib/tools/swig/Lib/typemaps/swigmacros.swg b/contrib/tools/swig/Lib/typemaps/swigmacros.swg
new file mode 100644
index 0000000000..b772eb04b3
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/swigmacros.swg
@@ -0,0 +1,228 @@
+/* -----------------------------------------------------------------------------
+ * SWIG API. Portion only visible from SWIG
+ * ----------------------------------------------------------------------------- */
+/*
+ This file implements the internal macros of the 'SWIG API', which
+ are useful to implement all the SWIG target languages.
+
+ Basic preprocessor macros:
+ --------------------------
+
+ %arg(Arg) Safe argument wrap
+ %str(Arg) Stringify the argument
+ %begin_block Begin an execution block
+ %end_block End an execution block
+ %block(Block) Execute Block as an execution block
+ %define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first
+ %ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi
+
+
+ Casting Operations:
+ -------------------
+
+ SWIG provides the following casting macros, which implement the
+ corresponding C++ casting operations:
+
+ %const_cast(a, Type) const_cast<Type >(a)
+ %static_cast(a, Type) static_cast<Type >(a)
+ %reinterpret_cast(a, Type) reinterpret_cast<Type >(a)
+ %numeric_cast(a, Type) static_cast<Type >(a)
+ %as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
+ %as_voidptrptr(a) reinterpret_cast<void **>(a)
+
+ or their C unsafe versions. In C++ we use the safe version unless
+ SWIG_NO_CPLUSPLUS_CAST is defined
+
+
+ Memory allocation:
+ ------------------
+
+ These allocation/freeing macros are safe to use in C or C++ and
+ dispatch the proper new/delete/delete[] or free/malloc calls as
+ needed.
+
+ %new_instance(Type) Allocate a new instance of given Type
+ %new_copy(value,Type) Allocate and initialize a new instance with 'value'
+ %new_array(size,Type) Allocate a new array with given size and Type and zero initialize
+ %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr'
+ %delete(cptr) Delete an instance
+ %delete_array(cptr) Delete an array
+
+
+ Auxiliary loop macros:
+ ----------------------
+
+ %formacro(Macro, Args...) or %formacro_1(Macro, Args...)
+ for i in Args
+ do
+ Macro($i)
+ done
+
+ %formacro_2(Macro2, Args...)
+ for i,j in Args
+ do
+ Macro2($i, $j)
+ done
+
+
+ Flags and conditional macros:
+ -----------------------------
+
+ %mark_flag(flag)
+ flag := True
+
+ %evalif(flag,expr)
+ if flag; then
+ expr
+ fi
+
+ %evalif_2(flag1 flag2,expr)
+ if flag1 and flag2; then
+ expr
+ fi
+
+
+*/
+/* -----------------------------------------------------------------------------
+ * Basic preprocessor macros
+ * ----------------------------------------------------------------------------- */
+
+#define %arg(Arg...) Arg
+#define %str(Arg) `Arg`
+#ifndef %begin_block
+# define %begin_block do {
+#endif
+#ifndef %end_block
+# define %end_block } while(0)
+#endif
+#define %block(Block...) %begin_block Block; %end_block
+
+/* define a new macro */
+%define %define_as(Def, Val...)%#define Def Val %enddef
+
+/* include C++ or else value */
+%define %ifcplusplus(cppval, nocppval)
+#ifdef __cplusplus
+cppval
+#else
+nocppval
+#endif
+%enddef
+
+/* -----------------------------------------------------------------------------
+ * Casting operators
+ * ----------------------------------------------------------------------------- */
+
+#if defined(__cplusplus) && !defined(SWIG_NO_CPLUSPLUS_CAST)
+# define %const_cast(a,Type...) const_cast< Type >(a)
+# define %static_cast(a,Type...) static_cast< Type >(a)
+# define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a)
+# define %numeric_cast(a,Type...) static_cast< Type >(a)
+#else /* C case */
+# define %const_cast(a,Type...) (Type)(a)
+# define %static_cast(a,Type...) (Type)(a)
+# define %reinterpret_cast(a,Type...) (Type)(a)
+# define %numeric_cast(a,Type...) (Type)(a)
+#endif /* __cplusplus */
+
+
+#define %as_voidptr(a) SWIG_as_voidptr(a)
+#define %as_voidptrptr(a) SWIG_as_voidptrptr(a)
+
+%insert("header") {
+%define_as(SWIG_as_voidptr(a), %const_cast(%static_cast(a,const void *), void *))
+%define_as(SWIG_as_voidptrptr(a), ((void)%as_voidptr(*a),%reinterpret_cast(a, void**)))
+}
+
+
+/* -----------------------------------------------------------------------------
+ * Allocating/freeing elements
+ * ----------------------------------------------------------------------------- */
+
+#if defined(__cplusplus)
+# define %new_instance(Type...) (new Type())
+# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&)))
+# define %new_array(size,Type...) (new Type[size]())
+# define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(new Type[size], ptr, sizeof(Type)*(size)), Type*)
+# define %delete(cptr) delete cptr
+# define %delete_array(cptr) delete[] cptr
+#else /* C case */
+# define %new_instance(Type...) (Type *)calloc(1,sizeof(Type))
+# define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type))
+# define %new_array(size,Type...) (Type *)calloc(size, sizeof(Type))
+# define %new_copy_array(ptr,size,Type...) (Type *)memcpy(malloc((size)*sizeof(Type)), ptr, sizeof(Type)*(size))
+# define %delete(cptr) free((char*)cptr)
+# define %delete_array(cptr) free((char*)cptr)
+#endif /* __cplusplus */
+
+/* -----------------------------------------------------------------------------
+ * SWIG names and mangling
+ * ----------------------------------------------------------------------------- */
+
+#define %mangle(Type...) #@Type
+#define %descriptor(Type...) SWIGTYPE_ ## #@Type
+#define %string_name(Name) "SWIG_" %str(Name)
+#define %symbol_name(Name, Type...) SWIG_ ## Name ## _ #@Type
+#define %checkcode(Code) SWIG_TYPECHECK_ ## Code
+
+
+/* -----------------------------------------------------------------------------
+ * Auxiliary loop macros
+ * ----------------------------------------------------------------------------- */
+
+
+/* for loop for macro with one argument */
+%define %_formacro_1(macro, arg1,...)macro(arg1)
+#if #__VA_ARGS__ != "__fordone__"
+%_formacro_1(macro, __VA_ARGS__)
+#endif
+%enddef
+
+/* for loop for macro with one argument */
+%define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef
+%define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef
+
+/* for loop for macro with two arguments */
+%define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2)
+#if #__VA_ARGS__ != "__fordone__"
+%_formacro_2(macro, __VA_ARGS__)
+#endif
+%enddef
+
+/* for loop for macro with two arguments */
+%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef
+
+/* -----------------------------------------------------------------------------
+ * SWIG flags
+ * ----------------------------------------------------------------------------- */
+
+/*
+ mark a flag, ie, define a macro name but ignore it in
+ the interface.
+
+ the flag can be later used with %evalif
+*/
+
+%define %mark_flag(x) %define x 1 %enddef %enddef
+
+
+/*
+ %evalif and %evalif_2 are use to evaluate or process
+ an expression if the given predicate is 'true' (1).
+*/
+%define %_evalif(_x,_expr)
+#if _x == 1
+_expr
+#endif
+%enddef
+
+%define %_evalif_2(_x,_y,_expr)
+#if _x == 1 && _y == 1
+_expr
+#endif
+%enddef
+
+%define %evalif(_x,_expr...) %_evalif(%arg(_x),%arg(_expr)) %enddef
+
+%define %evalif_2(_x,_y,_expr...) %_evalif_2(%arg(_x),%arg(_y),%arg(_expr)) %enddef
+
diff --git a/contrib/tools/swig/Lib/typemaps/swigobject.swg b/contrib/tools/swig/Lib/typemaps/swigobject.swg
new file mode 100644
index 0000000000..26c6ba8edf
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/swigobject.swg
@@ -0,0 +1,37 @@
+/* ------------------------------------------------------------
+ * Language Object * - Just pass straight through unmodified
+ * ------------------------------------------------------------ */
+
+%typemap(in) SWIG_Object "$1 = $input;"
+
+%typemap(in,noblock=1) SWIG_Object const & ($*ltype temp)
+{
+ temp = %static_cast($input, $*ltype);
+ $1 = &temp;
+}
+
+%typemap(out,noblock=1) SWIG_Object {
+ %set_output($1);
+}
+
+%typemap(out,noblock=1) SWIG_Object const & {
+ %set_output(*$1);
+}
+
+%typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = ($input != 0);";
+
+%typemap(throws,noblock=1) SWIG_Object {
+ %raise($1, "$type", 0);
+}
+
+%typemap(constcode,noblock=1) SWIG_Object {
+ %set_constant("$symname", $value);
+}
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+%typemap(directorin) SWIG_Object "$input = $1;"
+%typemap(directorout) SWIG_Object "$result = $input;"
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
diff --git a/contrib/tools/swig/Lib/typemaps/swigtype.swg b/contrib/tools/swig/Lib/typemaps/swigtype.swg
new file mode 100644
index 0000000000..69f83794d2
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/swigtype.swg
@@ -0,0 +1,710 @@
+/* -----------------------------------------------------------------------------
+ * --- Input arguments ---
+ * ----------------------------------------------------------------------------- */
+/* Pointers and arrays */
+%typemap(in, noblock=1) SWIGTYPE *(void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg) SWIGTYPE * ""
+
+%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg) SWIGTYPE [] ""
+
+
+%typemap(in, noblock=1) SWIGTYPE *const& (void *argp = 0, int res = 0, $*1_ltype temp) {
+ res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$*ltype", $symname, $argnum);
+ }
+ temp = %reinterpret_cast(argp, $*ltype);
+ $1 = %reinterpret_cast(&temp, $1_ltype);
+}
+%typemap(freearg) SWIGTYPE *const& ""
+
+
+/* Reference */
+%typemap(in, noblock=1) SWIGTYPE & (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg) SWIGTYPE & ""
+
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(in,noblock=1,implicitconv=1) const SWIGTYPE & (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE &
+{
+ if (SWIG_IsNewObj(res$argnum)) %delete($1);
+}
+#endif
+
+/* Rvalue reference */
+%typemap(in, noblock=1, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, SWIG_POINTER_RELEASE | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
+ %releasenotowned_fail(res, "$type", $symname, $argnum);
+ } else {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+ rvrdeleter.reset($1);
+}
+%typemap(freearg) SWIGTYPE && ""
+
+/* By value */
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(in,implicitconv=1) SWIGTYPE (void *argp, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $&ltype temp = %reinterpret_cast(argp, $&ltype);
+ $1 = *temp;
+ if (SWIG_IsNewObj(res)) %delete(temp);
+ }
+}
+#else
+%typemap(in) SWIGTYPE (void *argp, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, $&ltype));
+ }
+}
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * --- Output arguments ---
+ * ----------------------------------------------------------------------------- */
+
+/* Pointers, references */
+%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[] {
+ %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags));
+}
+
+%typemap(out, noblock=1) SWIGTYPE *const& {
+ %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags));
+}
+
+/* Return by value */
+#ifdef __cplusplus
+%typemap(out, noblock=1) SWIGTYPE {
+ %set_output(SWIG_NewPointerObj((new $1_ltype($1)), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
+}
+#else
+%typemap(out, noblock=1) SWIGTYPE {
+ %set_output(SWIG_NewPointerObj(%new_copy($1, $1_ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * --- Variable input ---
+ * ----------------------------------------------------------------------------- */
+
+/* memberin/globalin/varin, for fix arrays. */
+
+%typemap(memberin) SWIGTYPE [ANY] {
+ if ($input) {
+ size_t ii = 0;
+ for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)$input + ii);
+ } else {
+ %variable_nullref("$type","$name");
+ }
+}
+
+%typemap(globalin) SWIGTYPE [ANY] {
+ if ($input) {
+ size_t ii = 0;
+ for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)$input + ii);
+ } else {
+ %variable_nullref("$type","$name");
+ }
+}
+
+%typemap(varin) SWIGTYPE [ANY] {
+ $basetype *inp = 0;
+ int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ } else if (inp) {
+ size_t ii = 0;
+ for (; ii < (size_t)$1_dim0; ++ii) *($1_basetype *)&$1[ii] = *(($1_basetype *)inp + ii);
+ } else {
+ %variable_nullref("$type", "$name");
+ }
+}
+
+
+/* memberin/globalin/varin, for fix double arrays. */
+
+%typemap(memberin) SWIGTYPE [ANY][ANY] {
+ if ($input) {
+ size_t ii = 0;
+ for (; ii < (size_t)$1_dim0; ++ii) {
+ if ($input[ii]) {
+ size_t jj = 0;
+ for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj];
+ } else {
+ %variable_nullref("$type","$name");
+ }
+ }
+ } else {
+ %variable_nullref("$type","$name");
+ }
+}
+
+%typemap(globalin) SWIGTYPE [ANY][ANY] {
+ if ($input) {
+ size_t ii = 0;
+ for (; ii < (size_t)$1_dim0; ++ii) {
+ if ($input[ii]) {
+ size_t jj = 0;
+ for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj];
+ } else {
+ %variable_nullref("$type","$name");
+ }
+ }
+ } else {
+ %variable_nullref("$type","$name");
+ }
+}
+
+%typemap(varin) SWIGTYPE [ANY][ANY] {
+ $basetype (*inp)[$1_dim1] = 0;
+ int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ } else if (inp) {
+ size_t ii = 0;
+ for (; ii < (size_t)$1_dim0; ++ii) {
+ if (inp[ii]) {
+ size_t jj = 0;
+ for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj];
+ } else {
+ %variable_nullref("$type", "$name");
+ }
+ }
+ } else {
+ %variable_nullref("$type", "$name");
+ }
+}
+
+/* Pointers, references, and variable size arrays */
+
+%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE * {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+
+%typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE []
+{
+ %variable_fail(SWIG_AttributeError, "$type", "read-only $name");
+}
+
+%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE & {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %variable_nullref("$type", "$name");
+ }
+ $1 = *(%reinterpret_cast(argp, $ltype));
+}
+
+%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE && {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %variable_nullref("$type", "$name");
+ }
+ $1 = *(%reinterpret_cast(argp, $ltype));
+}
+
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(varin,implicitconv=1) SWIGTYPE {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %variable_nullref("$type", "$name");
+ } else {
+ $&type temp;
+ temp = %reinterpret_cast(argp, $&type);
+ $1 = *temp;
+ if (SWIG_IsNewObj(res)) %delete(temp);
+ }
+}
+#else
+%typemap(varin) SWIGTYPE {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %variable_nullref("$type", "$name");
+ } else {
+ $1 = *(%reinterpret_cast(argp, $&type));
+ }
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * --- Variable output ---
+ * ----------------------------------------------------------------------------- */
+
+/* Pointers and arrays */
+%typemap(varout, noblock=1) SWIGTYPE * {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags));
+}
+
+%typemap(varout, noblock=1) SWIGTYPE [] {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags));
+}
+
+/* References */
+%typemap(varout, noblock=1) SWIGTYPE & {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
+}
+
+%typemap(varout, noblock=1) SWIGTYPE && {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
+}
+
+/* Value */
+%typemap(varout, noblock=1) SWIGTYPE {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags));
+}
+
+/* ------------------------------------------------------------
+ * --- Typechecking rules ---
+ * ------------------------------------------------------------ */
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE * {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $*descriptor, 0);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
+ $1 = SWIG_CheckState(res);
+}
+
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE {
+ int res = SWIG_ConvertPtr($input, 0, $&descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag);
+ $1 = SWIG_CheckState(res);
+}
+#else
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE & {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
+ $1 = SWIG_CheckState(res);
+}
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, SWIG_POINTER_NO_NULL);
+ $1 = SWIG_CheckState(res);
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * --- Director typemaps --- *
+ * ----------------------------------------------------------------------------- */
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+
+%typemap(directorin,noblock=1) SWIGTYPE {
+ $input = SWIG_NewPointerObj((new $1_ltype(SWIG_STD_MOVE($1))), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags);
+}
+
+%typemap(directorin,noblock=1) SWIGTYPE * {
+ $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags);
+}
+
+%typemap(directorin,noblock=1) SWIGTYPE *const& {
+ $input = SWIG_NewPointerObj(%as_voidptr($1), $*descriptor, %newpointer_flags);
+}
+
+%typemap(directorin,noblock=1) SWIGTYPE & {
+ $input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags);
+}
+
+%typemap(directorin,noblock=1) SWIGTYPE && {
+ $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
+}
+
+/* directorout */
+
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) {
+ swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags | %implicitconv_flag);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ $result = *(%reinterpret_cast(swig_argp, $&ltype));
+ if (SWIG_IsNewObj(swig_res)) %delete(%reinterpret_cast(swig_argp, $&ltype));
+}
+#else
+%typemap(directorout,noblock=1) SWIGTYPE (void * swig_argp, int swig_res = 0) {
+ swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ $result = *(%reinterpret_cast(swig_argp, $&ltype));
+}
+#endif
+
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ SWIGTYPE *(void *swig_argp, int swig_res, swig_owntype own) {
+ swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ $result = %reinterpret_cast(swig_argp, $ltype);
+ swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */);
+}
+%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE * {
+ if (director) {
+ SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
+ }
+}
+
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ SWIGTYPE *const&(void *swig_argp, int swig_res, swig_owntype own) {
+ swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $*descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ $1_ltype swig_temp = new $*1_ltype(($*1_ltype)swig_argp);
+ swig_acquire_ownership(swig_temp);
+ $result = swig_temp;
+}
+%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE *const& {
+ if (director) {
+ SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr(*$input)));
+ }
+}
+
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ SWIGTYPE &(void *swig_argp, int swig_res, swig_owntype own) {
+ swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ if (!swig_argp) { %dirout_nullref("$type"); }
+ $result = %reinterpret_cast(swig_argp, $ltype);
+ swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */);
+}
+%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE & {
+ if (director) {
+ SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
+ }
+}
+
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ SWIGTYPE &&(void *swig_argp, int swig_res, swig_owntype own) {
+ swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ if (!swig_argp) { %dirout_nullref("$type"); }
+ $result = %reinterpret_cast(swig_argp, $ltype);
+ swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */);
+}
+%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE && {
+ if (director) {
+ SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
+ }
+}
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
+
+/* ------------------------------------------------------------
+ * --- Constants ---
+ * ------------------------------------------------------------ */
+
+%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
+ %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags));
+}
+
+%typemap(constcode,noblock=1) SWIGTYPE {
+ %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr(&$value),$&descriptor,%newpointer_flags));
+}
+
+/* ------------------------------------------------------------
+ * --- Exception handling ---
+ * ------------------------------------------------------------ */
+
+%typemap(throws,noblock=1) SWIGTYPE {
+ %raise(SWIG_NewPointerObj(%new_copy($1, $1_ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor);
+}
+
+%typemap(throws,noblock=1) SWIGTYPE * {
+ %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor);
+}
+
+%typemap(throws,noblock=1) SWIGTYPE [ANY] {
+ %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor);
+}
+
+%typemap(throws,noblock=1) SWIGTYPE & {
+ %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
+}
+
+%typemap(throws,noblock=1) SWIGTYPE && {
+ %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
+}
+
+%typemap(throws,noblock=1) (...) {
+ SWIG_exception_fail(SWIG_RuntimeError,"unknown exception");
+}
+
+/* ------------------------------------------------------------
+ * --- CLASS::* typemaps ---
+ * ------------------------------------------------------------ */
+
+%typemap(in) SWIGTYPE (CLASS::*) {
+ int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($1),$descriptor);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+}
+
+%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
+ %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
+}
+
+%typemap(varin) SWIGTYPE (CLASS::*) {
+ int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($1), $descriptor);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+}
+
+%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
+ %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
+}
+
+%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
+ %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($value), $descriptor));
+}
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+
+%typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) {
+ $input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor);
+}
+
+/* directorout */
+
+%typemap(directorout) SWIGTYPE (CLASS::*) {
+ int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($result), $descriptor);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+}
+#endif
+
+%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
+%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
+
+/* ------------------------------------------------------------
+ * --- function ptr typemaps ---
+ * ------------------------------------------------------------ */
+
+/*
+ ISO C++ doesn't allow direct casting of a function ptr to a object
+ ptr. So, maybe the ptr sizes are not the same, and we need to take
+ some providences.
+ */
+%typemap(in) SWIGTYPE ((*)(ANY)) {
+ int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type",$symname, $argnum);
+ }
+}
+
+%typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE ((*)(ANY)) {
+ void *ptr = 0;
+ int res = SWIG_ConvertFunctionPtr($input, &ptr, $descriptor);
+ $1 = SWIG_CheckState(res);
+}
+
+
+%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
+ %set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
+}
+
+%typemap(varin) SWIGTYPE ((*)(ANY)) {
+ int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+}
+
+%typemap(varout,noblock=1) SWIGTYPE ((*)(ANY)) {
+ %set_varoutput(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
+}
+
+%typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){
+ %set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor));
+}
+%typemap(constcode) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+
+%typemap(directorin,noblock=1) SWIGTYPE ((*)(ANY)) {
+ $input = SWIG_NewFunctionPtrObj((void*)($1), $descriptor);
+}
+
+/* directorout */
+
+%typemap(directorout) SWIGTYPE ((*)(ANY)) {
+ int swig_res = SWIG_ConvertFunctionPtr($input,(void**)(&$result),$descriptor);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+}
+#endif
+
+%apply SWIGTYPE ((*)(ANY)) { SWIGTYPE ((* const)(ANY)) }
+
+%apply SWIGTYPE * { SWIGTYPE *const }
+
+/* ------------------------------------------------------------
+ * --- Special typemaps ---
+ * ------------------------------------------------------------ */
+
+/* DISOWN typemap */
+
+%typemap(in, noblock=1) SWIGTYPE *DISOWN (int res = 0) {
+ res = SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res,"$type", $symname, $argnum);
+ }
+}
+
+%typemap(varin) SWIGTYPE *DISOWN {
+ void *temp = 0;
+ int res = SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = ($ltype) temp;
+}
+
+/* DYNAMIC typemap */
+
+%typemap(out,noblock=1) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
+ %set_output(SWIG_NewPointerObj(%as_voidptr($1), SWIG_TypeDynamicCast($descriptor, %as_voidptrptr(&$1)), $owner | %newpointer_flags));
+}
+
+/* INSTANCE typemap */
+
+#ifdef __cplusplus
+%typemap(out,noblock=1) SWIGTYPE INSTANCE {
+ %set_output(SWIG_NewInstanceObj((new $1_ltype($1)), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags));
+}
+#else
+%typemap(out,noblock=1) SWIGTYPE INSTANCE {
+ %set_output(SWIG_NewInstanceObj(%new_copy($1, $1_ltype), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags));
+}
+#endif
+
+%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] {
+ %set_output(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, $owner | %newinstance_flags));
+}
+
+%typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] {
+ %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags));
+}
+
+%typemap(varout,noblock=1) SWIGTYPE &INSTANCE {
+ %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags));
+}
+
+%typemap(varout,noblock=1) SWIGTYPE INSTANCE {
+ %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags));
+}
+
diff --git a/contrib/tools/swig/Lib/typemaps/swigtypemaps.swg b/contrib/tools/swig/Lib/typemaps/swigtypemaps.swg
new file mode 100644
index 0000000000..733e5acd0f
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/swigtypemaps.swg
@@ -0,0 +1,168 @@
+/* -----------------------------------------------------------------------------
+ * swigtypemaps.swg
+ *
+ * Unified Typemap Library frontend
+ * ----------------------------------------------------------------------------- */
+
+/*
+ This file provides the frontend to the Unified Typemap Library.
+
+ When using this library in a SWIG target language, you need to
+ define a minimum set of fragments, specialize a couple of macros,
+ and then include this file.
+
+ Typically you will create a 'mytypemaps.swg' file in each target
+ language, where you will have the following sections:
+
+ === mytypemaps.swg ===
+
+ // Fragment section
+ %include <typemaps/fragments.swg>
+ <include target language fragments>
+
+ // Unified typemap section
+ <specialized the typemap library macros>
+ %include <typemaps/swigtypemaps.swg>
+
+ // Local typemap section
+ <add/replace extra target language typemaps>
+
+ === mytypemaps.swg ===
+
+ While we add more docs, please take a look at the following cases
+ to see how you specialized the unified typemap library for a new
+ target language:
+
+ Lib/python/pytypemaps.swg
+ Lib/tcl/tcltypemaps.swg
+ Lib/ruby/rubytypemaps.swg
+ Lib/perl5/perltypemaps.swg
+
+*/
+
+#define SWIGUTL SWIGUTL
+
+/* -----------------------------------------------------------------------------
+ * Language specialization section.
+ *
+ * Tune these macros for each language as needed.
+ * ----------------------------------------------------------------------------- */
+
+/*
+ The SWIG target language object must be provided.
+ For example in python you define:
+
+ #define SWIG_Object PyObject *
+*/
+
+#if !defined(SWIG_Object)
+#error "SWIG_Object must be defined as the SWIG target language object"
+#endif
+
+/*==== flags for new/convert methods ====*/
+
+
+#ifndef %convertptr_flags
+%define %convertptr_flags 0 %enddef
+#endif
+
+#ifndef %newpointer_flags
+%define %newpointer_flags 0 %enddef
+#endif
+
+#ifndef %newinstance_flags
+%define %newinstance_flags 0 %enddef
+#endif
+
+/*==== set output ====*/
+
+#ifndef %set_output
+/* simple set output operation */
+#define %set_output(obj) $result = obj
+#endif
+
+/*==== set variable output ====*/
+
+#ifndef %set_varoutput
+/* simple set varoutput operation */
+#define %set_varoutput(obj) $result = obj
+#endif
+
+/*==== append output ====*/
+
+#ifndef %append_output
+#if defined(SWIG_AppendOutput)
+/* simple append operation */
+#define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
+#else
+#error "Language must define SWIG_AppendOutput or %append_output"
+#endif
+#endif
+
+/*==== set constant ====*/
+
+#ifndef %set_constant
+#if defined(SWIG_SetConstant)
+/* simple set constant operation */
+#define %set_constant(name,value) SWIG_SetConstant(name,value)
+#else
+#error "Language must define SWIG_SetConstant or %set_constant"
+#endif
+#endif
+
+/*==== raise an exception ====*/
+
+#ifndef %raise
+#if defined(SWIG_Raise)
+/* simple raise operation */
+#define %raise(obj, type, desc) SWIG_Raise(obj, type, desc); SWIG_fail
+#else
+#error "Language must define SWIG_Raise or %raise"
+#endif
+#endif
+
+/*==== director output exception ====*/
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+#ifndef SWIG_DirOutFail
+#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
+#endif
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * Language independent definitions
+ * ----------------------------------------------------------------------------- */
+
+#define %error_block(Block...) %block(Block)
+#define %default_code(code) SWIG_ArgError(code)
+#define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn))
+#define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn))
+#define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name))
+#define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name))
+#define %releasenotowned_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %releasenotownedfail_fmt(type, name, argn))
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+#define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))
+#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
+#endif
+
+/* -----------------------------------------------------------------------------
+ * All the typemaps
+ * ----------------------------------------------------------------------------- */
+
+
+%include <typemaps/fragments.swg>
+%include <typemaps/exception.swg>
+%include <typemaps/swigtype.swg>
+%include <typemaps/void.swg>
+%include <typemaps/swigobject.swg>
+%include <typemaps/valtypes.swg>
+%include <typemaps/ptrtypes.swg>
+%include <typemaps/inoutlist.swg>
+%include <typemaps/primtypes.swg>
+%include <typemaps/string.swg>
+%include <typemaps/misctypes.swg>
+%include <typemaps/enumint.swg>
+
+
diff --git a/contrib/tools/swig/Lib/typemaps/typemaps.swg b/contrib/tools/swig/Lib/typemaps/typemaps.swg
new file mode 100644
index 0000000000..4629e8dfa0
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/typemaps.swg
@@ -0,0 +1,157 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.swg
+ *
+ * Tcl 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 Tcl 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 Tcl 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 Tcl 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 Tcl). Rather, the modified input value shows
+up as the return value of the function. Thus, to apply this function
+to a Tcl 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.
+
+*/
+
+
+#if defined(SWIG_INOUT_NODEF)
+
+%apply_checkctypes(%typemaps_inoutn)
+
+%apply size_t& { std::size_t& };
+%apply ptrdiff_t& { std::ptrdiff_t& };
+
+#endif
diff --git a/contrib/tools/swig/Lib/typemaps/valtypes.swg b/contrib/tools/swig/Lib/typemaps/valtypes.swg
new file mode 100644
index 0000000000..f2f34acfca
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/valtypes.swg
@@ -0,0 +1,215 @@
+/*---------------------------------------------------------------------
+ * Value typemaps (Type, const Type&) for value types, such as
+ * fundamental types (int, double), that define the AsVal/From
+ * methods.
+ *
+ * To apply them, just use one of the following macros:
+ *
+ * %typemaps_from(FromMeth, FromFrag, Type)
+ * %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type)
+ * %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type)
+ *
+ * or the simpler and normalize form:
+ *
+ * %typemaps_asvalfromn(CheckCode, Type)
+ *
+ * Also, you can use the individual typemap definitions:
+ *
+ * %value_in_typemap(asval_meth,frag,Type)
+ * %value_varin_typemap(asval_meth,frag,Type)
+ * %value_typecheck_typemap(checkcode,asval_meth,frag,Type)
+ * %value_directorout_typemap(asval_meth,frag,Type)
+ *
+ * %value_out_typemap(from_meth,frag,Type)
+ * %value_varout_typemap(from_meth,frag,Type)
+ * %value_constcode_typemap(from_meth,frag,Type)
+ * %value_directorin_typemap(from_meth,frag,Type)
+ * %value_throws_typemap(from_meth,frag,Type)
+ *
+ *---------------------------------------------------------------------*/
+
+/* in */
+
+%define %value_in_typemap(asval_meth,frag,Type...)
+ %typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) {
+ ecode = asval_meth($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$ltype", $symname, $argnum);
+ }
+ $1 = %static_cast(val,$ltype);
+ }
+ %typemap(freearg) Type ""
+ %typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) {
+ ecode = asval_meth($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$*ltype", $symname, $argnum);
+ }
+ temp = %static_cast(val, $*ltype);
+ $1 = &temp;
+ }
+ %typemap(freearg) const Type& ""
+%enddef
+
+/* out */
+
+%define %value_out_typemap(from_meth,frag,Type...)
+ %typemap(out,noblock=1,fragment=frag) Type, const Type {
+ %set_output(from_meth(%static_cast($1,Type)));
+ }
+ %typemap(out,noblock=1,fragment=frag) const Type& {
+ %set_output(from_meth(%static_cast(*$1,Type)));
+ }
+%enddef
+
+/* varin */
+
+%define %value_varin_typemap(asval_meth,frag,Type...)
+ %typemap(varin,fragment=frag) Type {
+ Type val;
+ int res = asval_meth($input, &val);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = %static_cast(val,$ltype);
+ }
+%enddef
+
+/* varout */
+
+%define %value_varout_typemap(from_meth,frag,Type...)
+ %typemap(varout,noblock=1,fragment=frag) Type, const Type& {
+ %set_varoutput(from_meth(%static_cast($1,Type)));
+ }
+%enddef
+
+/* constant installation code */
+
+%define %value_constcode_typemap(from_meth,frag,Type...)
+ %typemap(constcode,noblock=1,fragment=frag) Type {
+ %set_constant("$symname", from_meth(%static_cast($value,Type)));
+ }
+%enddef
+
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+
+%define %value_directorin_typemap(from_meth,frag,Type...)
+ %typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN {
+ $input = from_meth(%static_cast(*$1,Type));
+ }
+ %typemap(directorin,noblock=1,fragment=frag) Type, const Type& {
+ $input = from_meth(%static_cast($1,Type));
+ }
+%enddef
+
+/* directorout */
+
+%define %value_directorout_typemap(asval_meth,frag,Type...)
+ %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT(Type swig_val, int swig_res) {
+ swig_res = asval_meth($result, &swig_val);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res, "$type");
+ }
+ *$1 = swig_val;
+ }
+ %typemap(directorout,noblock=1,fragment=frag) Type {
+ Type swig_val;
+ int swig_res = asval_meth($input, &swig_val);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res, "$type");
+ }
+ $result = %static_cast(swig_val,$type);
+ }
+ %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const Type& {
+ Type swig_val;
+ int swig_res = asval_meth($input, &swig_val);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res, "$type");
+ }
+ $basetype *temp = new $basetype(($basetype)swig_val);
+ swig_acquire_ownership(temp);
+ $result = temp;
+ }
+ %typemap(directorfree,noblock=1) const Type & {
+ if (director) {
+ director->swig_release_ownership(%as_voidptr($input));
+ }
+ }
+ %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
+%enddef
+
+#else
+
+#define %value_directorin_typemap(from_meth,frag,Type...)
+#define %value_directorout_typemap(asval_meth,frag,Type...)
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+
+
+/* throws */
+
+%define %value_throws_typemap(from_meth,frag,Type...)
+ %typemap(throws,noblock=1,fragment=frag) Type {
+ %raise(from_meth(%static_cast($1,Type)), "$type", 0);
+ }
+%enddef
+
+/* typecheck */
+
+%define %value_typecheck_typemap(check,asval_meth,frag,Type...)
+ %typemap(typecheck,precedence=check,fragment=frag) Type, const Type& {
+ int res = asval_meth($input, NULL);
+ $1 = SWIG_CheckState(res);
+ }
+%enddef
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with AsVal methods
+ *---------------------------------------------------------------------*/
+%define %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type...)
+ %value_in_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_varin_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_directorout_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_typecheck_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_input_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
+%enddef
+
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with from method
+ *---------------------------------------------------------------------*/
+%define %typemaps_from(FromMeth, FromFrag, Type...)
+ %value_out_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_varout_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_constcode_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_directorin_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_throws_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+%enddef
+
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with alval/from method
+ *---------------------------------------------------------------------*/
+
+%define %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth,
+ AsValFrag, FromFrag, Type...)
+ %typemaps_asval(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
+ %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_inout_typemap(Type);
+%enddef
+
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with for 'normalized' asval/from methods
+ *---------------------------------------------------------------------*/
+%define %typemaps_asvalfromn(CheckCode, Type...)
+ %typemaps_asvalfrom(%arg(CheckCode),
+ SWIG_AsVal(Type),
+ SWIG_From(Type),
+ %arg(SWIG_AsVal_frag(Type)),
+ %arg(SWIG_From_frag(Type)),
+ Type);
+%enddef
diff --git a/contrib/tools/swig/Lib/typemaps/void.swg b/contrib/tools/swig/Lib/typemaps/void.swg
new file mode 100644
index 0000000000..795992bf48
--- /dev/null
+++ b/contrib/tools/swig/Lib/typemaps/void.swg
@@ -0,0 +1,84 @@
+/* ------------------------------------------------------------
+ * Void * - Accepts any kind of pointer
+ * ------------------------------------------------------------ */
+
+/* in */
+
+%typemap(in,noblock=1) void * (int res) {
+ res = SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+}
+%typemap(freearg) void * ""
+
+%typemap(in,noblock=1) void * const& ($*ltype temp = 0, int res) {
+ res = SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "Stype", $symname, $argnum);
+ }
+ $1 = &temp;
+}
+%typemap(freearg) void * const& ""
+
+
+/* out */
+
+#if defined(VOID_Object)
+%typemap(out,noblock=1) void { $result = VOID_Object; }
+#else
+%typemap(out,noblock=1) void {}
+#endif
+
+/* varin */
+
+%typemap(varin) void * {
+ void *temp = 0;
+ int res = SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = ($1_ltype) temp;
+}
+
+/* typecheck */
+
+%typecheck(SWIG_TYPECHECK_VOIDPTR, noblock=1) void *
+{
+ void *ptr = 0;
+ int res = SWIG_ConvertPtr($input, &ptr, 0, 0);
+ $1 = SWIG_CheckState(res);
+}
+
+#if defined(SWIG_DIRECTOR_TYPEMAPS)
+
+/* directorin */
+
+%typemap(directorin,noblock=1) void *, void const*, void *const, void const *const,
+ void const *&, void *const &, void const *const & {
+ $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags);
+}
+
+/* directorout */
+
+%typemap(directorout,noblock=1) void * (void *argp, int res) {
+ res = SWIG_ConvertPtr($input, &argp, 0, 0);
+ if (!SWIG_IsOK(res)) {
+ %dirout_fail(res,"$type");
+ }
+ $result = %reinterpret_cast(argp, $ltype);
+}
+
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) void * const& (void *argp, int res) {
+ res = SWIG_ConvertPtr($input, &argp, 0, $disown);
+ if (!SWIG_IsOK(res)) {
+ %dirout_fail(res,"$type");
+ }
+ static $*ltype temp = %reinterpret_cast(argp, $*ltype);
+ $result = &temp;
+}
+
+
+
+#endif /* SWIG_DIRECTOR_TYPEMAPS */
+