diff options
author | Vince Harron <vharron@google.com> | 2015-06-07 21:43:05 -0700 |
---|---|---|
committer | Vince Harron <vharron@google.com> | 2015-06-08 08:33:11 -0700 |
commit | 330b6544424d02bcdf29653dd889d524d2e6f7d2 (patch) | |
tree | 4c40fd53e5c12fcc83aeaa06f27fa606bcfe3d3c /share/swig/2.0.11/python | |
parent | 7b7c39b73762eb3aa12d79a3893e156fd801468e (diff) | |
download | windows-x86-master.tar.gz |
Adding binaries for 2.0.11HEADstudio-master-dev_before_27917934studio-master-dev_before_26911779studio-3.1.2studio-2.3studio-2.0-rc1studio-2.0studio-1.5studio-1.4gradle_3.1.2gradle_2.3.0gradle_2.0.0studio-master-releasestudio-1.4-releasestudio-1.4-devstudio-1.3-releasestudio-1.3-devmastermain
Diffstat (limited to 'share/swig/2.0.11/python')
81 files changed, 9279 insertions, 0 deletions
diff --git a/share/swig/2.0.11/python/argcargv.i b/share/swig/2.0.11/python/argcargv.i new file mode 100644 index 0000000..717fe73 --- /dev/null +++ b/share/swig/2.0.11/python/argcargv.i @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------ + * --- Argc & Argv --- + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") { +SWIGINTERN int +SWIG_AsArgcArgv(PyObject *input, + swig_type_info *ppchar_info, + size_t *argc, char ***argv, int *owner) +{ + void *vptr; + int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0); + if (!SWIG_IsOK(res)) { + int list = 0; + PyErr_Clear(); + list = PyList_Check(input); + if (list || PyTuple_Check(input)) { + size_t i = 0; + size_t size = list ? PyList_Size(input) : PyTuple_Size(input); + if (argc) *argc = size; + if (argv) { + *argv = %new_array(size + 1, char*); + for (; i < size; ++i) { + PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); + char *cptr = 0; size_t sz = 0; int alloc = 0; + res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc); + if (SWIG_IsOK(res)) { + if (cptr && sz) { + (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char); + } else { + (*argv)[i] = 0; + } + } else { + return SWIG_TypeError; + } + } + (*argv)[i] = 0; + if (owner) *owner = 1; + } else { + for (; i < size; ++i) { + PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); + res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0); + if (!SWIG_IsOK(res)) return SWIG_TypeError; + } + if (owner) *owner = 0; + } + return SWIG_OK; + } else { + return SWIG_TypeError; + } + } else { + /* seems dangerous, but the user asked for it... */ + size_t i = 0; + if (argv) { while (*argv[i] != 0) ++i;} + if (argc) *argc = i; + if (owner) *owner = 0; + return SWIG_OK; + } +} +} + +/* + This typemap works with either a char **, a python list or a python + tuple + */ + +%typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) { + res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner); + if (!SWIG_IsOK(res)) { + $1 = 0; $2 = 0; + %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); + } else { + $1 = %static_cast(argc,$1_ltype); + $2 = %static_cast(argv, $2_ltype); + } +} + +%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { + int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0); + $1 = SWIG_IsOK(res); +} + +%typemap(freearg,noblock=1) (int ARGC, char **ARGV) { + if (owner$argnum) { + size_t i = argc$argnum; + while (i) { + %delete_array(argv$argnum[--i]); + } + %delete_array(argv$argnum); + } +} + diff --git a/share/swig/2.0.11/python/attribute.i b/share/swig/2.0.11/python/attribute.i new file mode 100644 index 0000000..779716c --- /dev/null +++ b/share/swig/2.0.11/python/attribute.i @@ -0,0 +1 @@ +%include <typemaps/attribute.swg> diff --git a/share/swig/2.0.11/python/boost_shared_ptr.i b/share/swig/2.0.11/python/boost_shared_ptr.i new file mode 100644 index 0000000..100ed3e --- /dev/null +++ b/share/swig/2.0.11/python/boost_shared_ptr.i @@ -0,0 +1,322 @@ +%include <shared_ptr.i> + +// Set SHARED_PTR_DISOWN to $disown if required, for example +// #define SHARED_PTR_DISOWN $disown +#if !defined(SHARED_PTR_DISOWN) +#define SHARED_PTR_DISOWN 0 +#endif + +%fragment("SWIG_null_deleter_python", "header", fragment="SWIG_null_deleter") { +%#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT +} + +// Language specific macro implementing all the customisations for handling the smart pointer +%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) + +// %naturalvar is as documented for member variables +%naturalvar TYPE; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor wrapper customisation +%feature("unref") TYPE +//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" + "(void)arg1; delete smartarg1;" + +// Typemap customisations... + +// plain value +%typemap(in) CONST TYPE (void *argp, int res = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + } +} +%typemap(out) CONST TYPE { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) CONST TYPE { + void *argp = 0; + int newmem = 0; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + } +} +%typemap(varout) CONST TYPE { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain pointer +// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); + } +} + +%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); +} + +%typemap(varin) CONST TYPE * { + void *argp = 0; + int newmem = 0; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); + } +} +%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain reference +%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); + } +} +%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) CONST TYPE & { + void *argp = 0; + int newmem = 0; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = *%const_cast(tempshared.get(), $1_ltype); + } else { + $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); + } +} +%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain pointer by reference +// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + temp = %const_cast(tempshared.get(), $*1_ltype); + } else { + temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); + } + $1 = &temp; +} +%typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) TYPE *CONST& %{ +#error "varin typemap not implemented" +%} +%typemap(varout) TYPE *CONST& %{ +#error "varout typemap not implemented" +%} + +// shared_ptr by value +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + int newmem = 0; + void *argp = 0; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); +} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// shared_ptr by reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; + } else { + $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; + } +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ +#error "varin typemap not implemented" +%} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ +#error "varout typemap not implemented" +%} + +// shared_ptr by pointer +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; + } else { + $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; + } +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); + if ($owner) delete $1; +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ +#error "varin typemap not implemented" +%} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ +#error "varout typemap not implemented" +%} + +// shared_ptr by pointer reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); + temp = &tempshared; + $1 = &temp; +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ +#error "varin typemap not implemented" +%} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ +#error "varout typemap not implemented" +%} + +// Typecheck typemaps +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) + TYPE CONST, + TYPE CONST &, + TYPE CONST *, + TYPE *CONST&, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); + $1 = SWIG_CheckState(res); +} + + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + + +%enddef + diff --git a/share/swig/2.0.11/python/builtin.swg b/share/swig/2.0.11/python/builtin.swg new file mode 100644 index 0000000..28c557a --- /dev/null +++ b/share/swig/2.0.11/python/builtin.swg @@ -0,0 +1,514 @@ +#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_closure(PyObject *a) { \ + return wrapper(a, NULL); \ +} + +#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ +SWIGINTERN void \ +wrapper##_closure(PyObject *a) { \ + SwigPyObject *sobj; \ + sobj = (SwigPyObject *)a; \ + if (sobj->own) { \ + PyObject *o = wrapper(a, NULL); \ + 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##_closure(PyObject *a) { \ + PyObject *pyresult; \ + int result; \ + pyresult = wrapper(a, NULL); \ + result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \ + Py_XDECREF(pyresult); \ + return result; \ +} + +#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_closure(PyObject *a, PyObject *b) { \ + PyObject *tuple, *result; \ + tuple = PyTuple_New(1); \ + assert(tuple); \ + PyTuple_SET_ITEM(tuple, 0, b); \ + Py_XINCREF(b); \ + result = wrapper(a, tuple); \ + Py_DECREF(tuple); \ + return result; \ +} + +typedef ternaryfunc ternarycallfunc; + +#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ + PyObject *tuple, *result; \ + tuple = PyTuple_New(2); \ + assert(tuple); \ + PyTuple_SET_ITEM(tuple, 0, b); \ + PyTuple_SET_ITEM(tuple, 1, c); \ + Py_XINCREF(b); \ + Py_XINCREF(c); \ + result = wrapper(a, tuple); \ + Py_DECREF(tuple); \ + return result; \ +} + +#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \ + return wrapper(callable_object, args); \ +} + +#define SWIGPY_LENFUNC_CLOSURE(wrapper) \ +SWIGINTERN Py_ssize_t \ +wrapper##_closure(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##_closure(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##_closure(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) { \ + PyTuple_SET_ITEM(tuple, 2, d); \ + Py_INCREF(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##_closure(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##_closure(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##_closure(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)); \ + PyTuple_SET_ITEM(tuple, 1, c); \ + Py_XINCREF(c); \ + resultobj = wrapper(a, tuple); \ + result = resultobj ? 0 : -1; \ + Py_XDECREF(resultobj); \ + Py_DECREF(tuple); \ + return result; \ +} + +#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ + PyObject *tuple, *resultobj; \ + int result; \ + tuple = PyTuple_New(c ? 2 : 1); \ + assert(tuple); \ + PyTuple_SET_ITEM(tuple, 0, b); \ + Py_XINCREF(b); \ + if (c) { \ + PyTuple_SET_ITEM(tuple, 1, c); \ + Py_XINCREF(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##_closure(PyObject *a) { \ + return wrapper(a, NULL); \ +} + +#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ +SWIGINTERN long \ +wrapper##_closure(PyObject *a) { \ + PyObject *pyresult; \ + long result; \ + pyresult = wrapper(a, NULL); \ + if (!pyresult || !PyLong_Check(pyresult)) \ + return -1; \ + result = PyLong_AsLong(pyresult); \ + Py_DECREF(pyresult); \ + return result; \ +} + +#define SWIGPY_ITERNEXT_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_closure(PyObject *a) { \ + PyObject *result; \ + result = wrapper(a, NULL); \ + if (result && result == Py_None) { \ + Py_DECREF(result); \ + result = NULL; \ + } \ + return result; \ +} + +#ifdef __cplusplus +extern "C" { +#endif + +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 *pyobj) { + SwigPyObject *sobj; + sobj = (SwigPyObject *)pyobj; + if (sobj->own) { + PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->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); + PyTuple_SET_ITEM(tuple, 0, val); + Py_XINCREF(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(PyTypeObject *type, PyObject *name, PyObject *value) { + PyObject *attribute; + descrsetfunc local_set; + 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 = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(&PyType_Type, 0) +#else + PyObject_HEAD_INIT(&PyType_Type) + 0, +#endif + "swig_static_var_getset_descriptor", + sizeof(PyGetSetDescrObject), + 0, + (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 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 */ +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + staticvar_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + staticvar_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&staticvar_type) < 0) + return NULL; +#endif + } + return &staticvar_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) { + int base_count = 0; + PyTypeObject **b; + PyObject *tuple; + int 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) { + PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); + Py_INCREF((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 >= 0x03000000 + type->ob_base.ob_base.ob_type = metatype; +#else + type->ob_type = metatype; +#endif +} + +#ifdef __cplusplus +} +#endif + diff --git a/share/swig/2.0.11/python/carrays.i b/share/swig/2.0.11/python/carrays.i new file mode 100644 index 0000000..e578c80 --- /dev/null +++ b/share/swig/2.0.11/python/carrays.i @@ -0,0 +1,53 @@ +%define %array_class(TYPE,NAME) +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "sq_item", functype="ssizeargfunc") NAME::__getitem__; + %feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") NAME::__setitem__; + +%inline %{ +typedef struct { + TYPE *el; +} NAME; +%} + +%extend NAME { + + NAME(size_t nelements) { + NAME *arr = %new_instance(NAME); + arr->el = %new_array(nelements, TYPE); + return arr; + } + + ~NAME() { + %delete_array(self->el); + %delete(self); + } + + TYPE __getitem__(size_t index) { + return self->el[index]; + } + + void __setitem__(size_t index, TYPE value) { + self->el[index] = value; + } + + TYPE * cast() { + return self->el; + } + + static NAME *frompointer(TYPE *t) { + return %reinterpret_cast(t, NAME *); + } +}; + +%types(NAME = TYPE); + +#else + %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) +#endif +%enddef + +%include <typemaps/carrays.swg> + + + + diff --git a/share/swig/2.0.11/python/ccomplex.i b/share/swig/2.0.11/python/ccomplex.i new file mode 100644 index 0000000..28872b9 --- /dev/null +++ b/share/swig/2.0.11/python/ccomplex.i @@ -0,0 +1,26 @@ +/* ----------------------------------------------------------------------------- + * ccomplex.i + * + * C complex typemaps + * ISO C99: 7.3 Complex arithmetic <complex.h> + * ----------------------------------------------------------------------------- */ + + +%include <pycomplex.swg> + +%{ +#include <complex.h> +%} + + +/* C complex constructor */ +#define CCplxConst(r, i) ((r) + I*(i)) + +%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); + +/* declaring the typemaps */ +%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/share/swig/2.0.11/python/cdata.i b/share/swig/2.0.11/python/cdata.i new file mode 100644 index 0000000..3679659 --- /dev/null +++ b/share/swig/2.0.11/python/cdata.i @@ -0,0 +1 @@ +%include <typemaps/cdata.swg> diff --git a/share/swig/2.0.11/python/cmalloc.i b/share/swig/2.0.11/python/cmalloc.i new file mode 100644 index 0000000..248f06b --- /dev/null +++ b/share/swig/2.0.11/python/cmalloc.i @@ -0,0 +1 @@ +%include <typemaps/cmalloc.swg> diff --git a/share/swig/2.0.11/python/cni.i b/share/swig/2.0.11/python/cni.i new file mode 100644 index 0000000..10a1403 --- /dev/null +++ b/share/swig/2.0.11/python/cni.i @@ -0,0 +1,2 @@ +%include <gcj/cni.i> +%include <jstring.i> diff --git a/share/swig/2.0.11/python/complex.i b/share/swig/2.0.11/python/complex.i new file mode 100644 index 0000000..4c3b3c5 --- /dev/null +++ b/share/swig/2.0.11/python/complex.i @@ -0,0 +1,6 @@ +#ifdef __cplusplus +%include <std_complex.i> +#else +%include <ccomplex.i> +#endif + diff --git a/share/swig/2.0.11/python/cpointer.i b/share/swig/2.0.11/python/cpointer.i new file mode 100644 index 0000000..d824792 --- /dev/null +++ b/share/swig/2.0.11/python/cpointer.i @@ -0,0 +1 @@ +%include <typemaps/cpointer.swg> diff --git a/share/swig/2.0.11/python/cstring.i b/share/swig/2.0.11/python/cstring.i new file mode 100644 index 0000000..ede9c59 --- /dev/null +++ b/share/swig/2.0.11/python/cstring.i @@ -0,0 +1 @@ +%include <typemaps/cstring.swg> diff --git a/share/swig/2.0.11/python/cwstring.i b/share/swig/2.0.11/python/cwstring.i new file mode 100644 index 0000000..2824d9c --- /dev/null +++ b/share/swig/2.0.11/python/cwstring.i @@ -0,0 +1,3 @@ +%include <pywstrings.swg> +%include <typemaps/cwstring.swg> + diff --git a/share/swig/2.0.11/python/defarg.swg b/share/swig/2.0.11/python/defarg.swg new file mode 100644 index 0000000..10c9916 --- /dev/null +++ b/share/swig/2.0.11/python/defarg.swg @@ -0,0 +1,37 @@ +/* This file defines an internal function for processing default arguments + with proxy classes. + + There seems to be no straightforward way to write proxy functions + involving default arguments. For example : + + def foo(arg1,arg2,*args): + proxyc.foo(arg1,arg2,args) + + This fails because args is now a tuple and SWIG doesn't know what to + do with it. + + This file allows a different approach : + + def foo(arg1,arg2,*args): + proxyc.__call_defarg(proxyc.foo,(arg1,arg2,)+args) + + Basically, we form a new tuple from the object, call this special + __call_defarg method and it passes control to the real wrapper function. + An ugly hack, but it works. +*/ + +SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) { + PyObject *func; + PyObject *parms; + + if (!PyArg_ParseTuple(args,"OO",&func,&parms)) + return NULL; + + if (!PyCallable_Check(func)) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + return PyEval_CallObject(func,parms); +} diff --git a/share/swig/2.0.11/python/director.swg b/share/swig/2.0.11/python/director.swg new file mode 100644 index 0000000..97edc7e --- /dev/null +++ b/share/swig/2.0.11/python/director.swg @@ -0,0 +1,484 @@ +/* ----------------------------------------------------------------------------- + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to Python extensions. + * ----------------------------------------------------------------------------- */ + +#ifndef SWIG_DIRECTOR_PYTHON_HEADER_ +#define SWIG_DIRECTOR_PYTHON_HEADER_ + +#ifdef __cplusplus + +#include <string> +#include <iostream> +#include <exception> +#include <vector> +#include <map> + + +/* + Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual + table', and avoid multiple GetAttr calls to retrieve the python + methods. +*/ + +#ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE +#ifndef SWIG_PYTHON_DIRECTOR_VTABLE +#define SWIG_PYTHON_DIRECTOR_VTABLE +#endif +#endif + + + +/* + Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the + Undefined Exception Handler provided by swig. +*/ +#ifndef SWIG_DIRECTOR_NO_UEH +#ifndef SWIG_DIRECTOR_UEH +#define SWIG_DIRECTOR_UEH +#endif +#endif + + +/* + Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the + 'Swig' namespace. This could be useful for multi-modules projects. +*/ +#ifdef SWIG_DIRECTOR_STATIC +/* Force anonymous (static) namespace */ +#define Swig +#endif + + +/* + Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the + native C++ RTTI and dynamic_cast<>. But be aware that directors + could stop working when using this option. +*/ +#ifdef SWIG_DIRECTOR_NORTTI +/* + When we don't use the native C++ RTTI, we implement a minimal one + only for Directors. +*/ +# ifndef SWIG_DIRECTOR_RTDIR +# define SWIG_DIRECTOR_RTDIR +#include <map> + +namespace Swig { + class Director; + SWIGINTERN std::map<void*,Director*>& get_rtdir_map() { + static std::map<void*,Director*> rtdir_map; + return rtdir_map; + } + + SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { + get_rtdir_map()[vptr] = rtdir; + } + + SWIGINTERNINLINE Director *get_rtdir(void *vptr) { + std::map<void*,Director*>::const_iterator pos = get_rtdir_map().find(vptr); + Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; + return rtdir; + } +} +# endif /* SWIG_DIRECTOR_RTDIR */ + +# define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast<void*>(ARG)) +# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast<void*>(ARG1), ARG2) + +#else + +# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG) +# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) + +#endif /* SWIG_DIRECTOR_NORTTI */ + +extern "C" { + struct swig_type_info; +} + +namespace Swig { + + /* memory handler */ + struct GCItem + { + virtual ~GCItem() {} + + virtual int get_own() const + { + return 0; + } + }; + + struct GCItem_var + { + GCItem_var(GCItem *item = 0) : _item(item) + { + } + + GCItem_var& operator=(GCItem *item) + { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() + { + delete _item; + } + + GCItem * operator->() const + { + return _item; + } + + private: + GCItem *_item; + }; + + struct GCItem_Object : GCItem + { + GCItem_Object(int own) : _own(own) + { + } + + virtual ~GCItem_Object() + { + } + + int get_own() const + { + return _own; + } + + private: + int _own; + }; + + template <typename Type> + struct GCItem_T : GCItem + { + GCItem_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCItem_T() + { + delete _ptr; + } + + private: + Type *_ptr; + }; + + template <typename Type> + struct GCArray_T : GCItem + { + GCArray_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCArray_T() + { + delete[] _ptr; + } + + private: + Type *_ptr; + }; + + /* base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + public: + DirectorException(PyObject *error, const char* hdr ="", const char* msg ="") + : swig_msg(hdr) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (strlen(msg)) { + swig_msg += " "; + swig_msg += msg; + } + if (!PyErr_Occurred()) { + PyErr_SetString(error, getMessage()); + } + SWIG_PYTHON_THREAD_END_BLOCK; + } + + const char *getMessage() const + { + return swig_msg.c_str(); + } + + static void raise(PyObject *error, const char *msg) + { + throw DirectorException(error, msg); + } + + static void raise(const char *msg) + { + raise(PyExc_RuntimeError, msg); + } + }; + + /* unknown exception handler */ + class UnknownExceptionHandler + { +#ifdef SWIG_DIRECTOR_UEH + static void handler() { + try { + throw; + } catch (DirectorException& e) { + std::cerr << "SWIG Director exception caught:" << std::endl + << e.getMessage() << std::endl; + } catch (std::exception& e) { + std::cerr << "std::exception caught: "<< e.what() << std::endl; + } catch (...) { + std::cerr << "Unknown exception caught." << std::endl; + } + + std::cerr << std::endl + << "Python interpreter traceback:" << std::endl; + PyErr_Print(); + std::cerr << std::endl; + + std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl + << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl + << std::endl + << "Exception is being re-thrown, program will likely abort/terminate." << std::endl; + throw; + } + + public: + + std::unexpected_handler old; + UnknownExceptionHandler(std::unexpected_handler nh = handler) + { + old = std::set_unexpected(nh); + } + + ~UnknownExceptionHandler() + { + std::set_unexpected(old); + } +#endif + }; + + /* type mismatch in the return value from a python method call */ + class DirectorTypeMismatchException : public Swig::DirectorException { + public: + DirectorTypeMismatchException(PyObject *error, const char* msg="") + : Swig::DirectorException(error, "SWIG director type mismatch", msg) + { + } + + DirectorTypeMismatchException(const char* msg="") + : Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) + { + } + + static void raise(PyObject *error, const char *msg) + { + throw DirectorTypeMismatchException(error, msg); + } + + static void raise(const char *msg) + { + throw DirectorTypeMismatchException(msg); + } + }; + + /* any python exception that occurs during a director method call */ + class DirectorMethodException : public Swig::DirectorException { + public: + DirectorMethodException(const char* msg = "") + : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorMethodException(msg); + } + }; + + /* attempt to call a pure virtual method via a director method */ + class DirectorPureVirtualException : public Swig::DirectorException + { + public: + DirectorPureVirtualException(const char* msg = "") + : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorPureVirtualException(msg); + } + }; + + +#if defined(SWIG_PYTHON_THREADS) +/* __THREAD__ is the old macro to activate some thread support */ +# if !defined(__THREAD__) +# define __THREAD__ 1 +# endif +#endif + +#ifdef __THREAD__ +# include "pythread.h" + class Guard + { + PyThread_type_lock & mutex_; + + public: + Guard(PyThread_type_lock & mutex) : mutex_(mutex) + { + PyThread_acquire_lock(mutex_, WAIT_LOCK); + } + + ~Guard() + { + PyThread_release_lock(mutex_); + } + }; +# define SWIG_GUARD(mutex) Guard _guard(mutex) +#else +# define SWIG_GUARD(mutex) +#endif + + /* director base class */ + class Director { + private: + /* pointer to the wrapped python object */ + PyObject* swig_self; + /* flag indicating whether the object is owned by python or c++ */ + mutable bool swig_disown_flag; + + /* decrement the reference count of the wrapped python object */ + void swig_decref() const { + if (swig_disown_flag) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_DECREF(swig_self); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + public: + /* wrap a python object, optionally taking ownership */ + Director(PyObject* self) : swig_self(self), swig_disown_flag(false) { + swig_incref(); + } + + + /* discard our reference at destruction */ + virtual ~Director() { + swig_decref(); + } + + + /* return a pointer to the wrapped python object */ + PyObject *swig_get_self() const { + return swig_self; + } + + /* acquire ownership of the wrapped python object (the sense of "disown" + * is from python) */ + void swig_disown() const { + if (!swig_disown_flag) { + swig_disown_flag=true; + swig_incref(); + } + } + + /* increase the reference count of the wrapped python object */ + void swig_incref() const { + if (swig_disown_flag) { + Py_INCREF(swig_self); + } + } + + /* methods to implement pseudo protected director members */ + virtual bool swig_get_inner(const char* /* swig_protected_method_name */) const { + return true; + } + + virtual void swig_set_inner(const char* /* swig_protected_method_name */, bool /* swig_val */) const { + } + + /* ownership management */ + private: + typedef std::map<void*, GCItem_var> swig_ownership_map; + mutable swig_ownership_map swig_owner; +#ifdef __THREAD__ + static PyThread_type_lock swig_mutex_own; +#endif + + public: + template <typename Type> + void swig_acquire_ownership_array(Type *vptr) const + { + if (vptr) { + SWIG_GUARD(swig_mutex_own); + swig_owner[vptr] = new GCArray_T<Type>(vptr); + } + } + + template <typename Type> + void swig_acquire_ownership(Type *vptr) const + { + if (vptr) { + SWIG_GUARD(swig_mutex_own); + swig_owner[vptr] = new GCItem_T<Type>(vptr); + } + } + + void swig_acquire_ownership_obj(void *vptr, int own) const + { + if (vptr && own) { + SWIG_GUARD(swig_mutex_own); + swig_owner[vptr] = new GCItem_Object(own); + } + } + + int swig_release_ownership(void *vptr) const + { + int own = 0; + if (vptr) { + SWIG_GUARD(swig_mutex_own); + swig_ownership_map::iterator iter = swig_owner.find(vptr); + if (iter != swig_owner.end()) { + own = iter->second->get_own(); + swig_owner.erase(iter); + } + } + return own; + } + + template <typename Type> + static PyObject* swig_pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args)) + { + SwigPyObject *sobj = (SwigPyObject *)pyobj; + sobj->own = 0; + Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<Type *>(sobj->ptr)); + if (d) + d->swig_disown(); + return PyWeakref_NewProxy(pyobj, NULL); + } + + }; + +#ifdef __THREAD__ + PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock(); +#endif +} + +#endif /* __cplusplus */ + + +#endif diff --git a/share/swig/2.0.11/python/embed.i b/share/swig/2.0.11/python/embed.i new file mode 100644 index 0000000..c29e8fd --- /dev/null +++ b/share/swig/2.0.11/python/embed.i @@ -0,0 +1,115 @@ +// +// embed.i +// SWIG file embedding the Python interpreter in something else. +// This file is based on Python-1.5. It will not work with +// earlier versions. +// +// This file makes it possible to extend Python and all of its +// built-in functions without having to hack its setup script. +// + + +#ifdef AUTODOC +%subsection "embed.i" +%text %{ +This module provides support for building a new version of the +Python executable. This will be necessary on systems that do +not support shared libraries and may be necessary with C++ +extensions. This file contains everything you need to build +a new version of Python from include files and libraries normally +installed with the Python language. + +This module will automatically grab all of the Python modules +present in your current Python executable (including any special +purpose modules you have enabled such as Tkinter). Thus, you +may need to provide additional link libraries when compiling. + +This library file only works with Python 1.5. A version +compatible with Python 1.4 is available as embed14.i and +a Python1.3 version is available as embed13.i. As far as +I know, this module is C++ safe. +%} +#else +%echo "embed.i : Using Python 1.5" +#endif + +%wrapper %{ + +#include <Python.h> + +#ifdef __cplusplus +extern "C" +#endif +void SWIG_init(); /* Forward reference */ + +#define _PyImport_Inittab swig_inittab + +/* Grab Python's inittab[] structure */ + +#ifdef __cplusplus +extern "C" { +#endif +#include <config.c> + +#undef _PyImport_Inittab + +/* Now define our own version of it. + Hopefully someone does not have more than 1000 built-in modules */ + +struct _inittab SWIG_Import_Inittab[1000]; + +static int swig_num_modules = 0; + +/* Function for adding modules to Python */ + +static void swig_add_module(char *name, void (*initfunc)()) { + SWIG_Import_Inittab[swig_num_modules].name = name; + SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; + swig_num_modules++; + SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; + SWIG_Import_Inittab[swig_num_modules].initfunc = 0; +} + +/* Function to add all of Python's build in modules to our interpreter */ + +static void swig_add_builtin() { + int i = 0; + while (swig_inittab[i].name) { + swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); + i++; + } +#ifdef SWIGMODINIT + SWIGMODINIT +#endif + /* Add SWIG builtin function */ + swig_add_module(SWIG_name, SWIG_init); +} + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int Py_Main(int, char **); + +#ifdef __cplusplus +} +#endif + +extern struct _inittab *PyImport_Inittab; + +int +main(int argc, char **argv) { + swig_add_builtin(); + PyImport_Inittab = SWIG_Import_Inittab; + return Py_Main(argc,argv); +} + +%} + + + + diff --git a/share/swig/2.0.11/python/embed15.i b/share/swig/2.0.11/python/embed15.i new file mode 100644 index 0000000..3c419b9 --- /dev/null +++ b/share/swig/2.0.11/python/embed15.i @@ -0,0 +1,115 @@ +/* ----------------------------------------------------------------------------- + * embed15.i + * + * SWIG file embedding the Python interpreter in something else. + * This file is based on Python-1.5. It will not work with + * earlier versions. + * + * This file makes it possible to extend Python and all of its + * built-in functions without having to hack its setup script. + * ----------------------------------------------------------------------------- */ + +#ifdef AUTODOC +%subsection "embed.i" +%text %{ +This module provides support for building a new version of the +Python executable. This will be necessary on systems that do +not support shared libraries and may be necessary with C++ +extensions. This file contains everything you need to build +a new version of Python from include files and libraries normally +installed with the Python language. + +This module will automatically grab all of the Python modules +present in your current Python executable (including any special +purpose modules you have enabled such as Tkinter). Thus, you +may need to provide additional link libraries when compiling. + +This library file only works with Python 1.5. A version +compatible with Python 1.4 is available as embed14.i and +a Python1.3 version is available as embed13.i. As far as +I know, this module is C++ safe. +%} +#else +%echo "embed.i : Using Python 1.5" +#endif + +%wrapper %{ + +#include <Python.h> + +#ifdef __cplusplus +extern "C" +#endif +void SWIG_init(); /* Forward reference */ + +#define _PyImport_Inittab swig_inittab + +/* Grab Python's inittab[] structure */ + +#ifdef __cplusplus +extern "C" { +#endif +#include <config.c> + +#undef _PyImport_Inittab + +/* Now define our own version of it. + Hopefully someone does not have more than 1000 built-in modules */ + +struct _inittab SWIG_Import_Inittab[1000]; + +static int swig_num_modules = 0; + +/* Function for adding modules to Python */ + +static void swig_add_module(char *name, void (*initfunc)()) { + SWIG_Import_Inittab[swig_num_modules].name = name; + SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; + swig_num_modules++; + SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; + SWIG_Import_Inittab[swig_num_modules].initfunc = 0; +} + +/* Function to add all of Python's build in modules to our interpreter */ + +static void swig_add_builtin() { + int i = 0; + while (swig_inittab[i].name) { + swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); + i++; + } +#ifdef SWIGMODINIT + SWIGMODINIT +#endif + /* Add SWIG builtin function */ + swig_add_module(SWIG_name, SWIG_init); +} + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int Py_Main(int, char **); + +#ifdef __cplusplus +} +#endif + +extern struct _inittab *PyImport_Inittab; + +int +main(int argc, char **argv) { + swig_add_builtin(); + PyImport_Inittab = SWIG_Import_Inittab; + return Py_Main(argc,argv); +} + +%} + + + + diff --git a/share/swig/2.0.11/python/exception.i b/share/swig/2.0.11/python/exception.i new file mode 100644 index 0000000..bb0b15c --- /dev/null +++ b/share/swig/2.0.11/python/exception.i @@ -0,0 +1,6 @@ +%include <typemaps/exception.swg> + + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) +} diff --git a/share/swig/2.0.11/python/factory.i b/share/swig/2.0.11/python/factory.i new file mode 100644 index 0000000..46a0a87 --- /dev/null +++ b/share/swig/2.0.11/python/factory.i @@ -0,0 +1 @@ +%include <typemaps/factory.swg> diff --git a/share/swig/2.0.11/python/file.i b/share/swig/2.0.11/python/file.i new file mode 100644 index 0000000..359c34d --- /dev/null +++ b/share/swig/2.0.11/python/file.i @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------------- + * file.i + * + * Typemaps for FILE* + * ----------------------------------------------------------------------------- */ + +%types(FILE *); + +/* defining basic methods */ +%fragment("SWIG_AsValFilePtr","header") { +SWIGINTERN int +SWIG_AsValFilePtr(PyObject *obj, FILE **val) { + static swig_type_info* desc = 0; + void *vptr = 0; + if (!desc) desc = SWIG_TypeQuery("FILE *"); + if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { + if (val) *val = (FILE *)vptr; + return SWIG_OK; + } +%#if PY_VERSION_HEX < 0x03000000 + if (PyFile_Check(obj)) { + if (val) *val = PyFile_AsFile(obj); + return SWIG_OK; + } +%#endif + return SWIG_TypeError; +} +} + + +%fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") { +SWIGINTERNINLINE FILE* +SWIG_AsFilePtr(PyObject *obj) { + FILE *val = 0; + SWIG_AsValFilePtr(obj, &val); + return val; +} +} + +/* defining the typemaps */ +%typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*); diff --git a/share/swig/2.0.11/python/implicit.i b/share/swig/2.0.11/python/implicit.i new file mode 100644 index 0000000..152c2b0 --- /dev/null +++ b/share/swig/2.0.11/python/implicit.i @@ -0,0 +1,7 @@ +%include <std_common.i> +%include <typemaps/implicit.swg> + +#warning "This file provides the %implicit directive, which is an old and fragile" +#warning "way to implement the C++ implicit conversion mechanism." +#warning "Try using the more robust '%implicitconv Type;' directive instead." + diff --git a/share/swig/2.0.11/python/jstring.i b/share/swig/2.0.11/python/jstring.i new file mode 100644 index 0000000..bda9523 --- /dev/null +++ b/share/swig/2.0.11/python/jstring.i @@ -0,0 +1,72 @@ +%include <typemaps/valtypes.swg> + +%fragment(SWIG_AsVal_frag(jstring),"header") { +SWIGINTERN int +SWIG_AsVal(jstring)(PyObject *obj, jstring *val) +{ + if (obj == Py_None) { + if (val) *val = 0; + return SWIG_OK; + } + + PyObject *tmp = 0; + int isunicode = PyUnicode_Check(obj); + if (!isunicode && PyString_Check(obj)) { + if (val) { + obj = tmp = PyUnicode_FromObject(obj); + } + isunicode = 1; + } + if (isunicode) { + if (val) { + if (sizeof(Py_UNICODE) == sizeof(jchar)) { + *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj)); + return SWIG_NEWOBJ; + } else { + int len = PyUnicode_GET_SIZE(obj); + Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj); + *val = JvAllocString (len); + jchar *jchars = JvGetStringChars (*val); + for (int i = 0; i < len; ++i) { + jchars[i] = pchars[i]; + } + return SWIG_NEWOBJ; + } + } + Py_XDECREF(tmp); + return SWIG_OK; + } + return SWIG_TypeError; +} +} + +%fragment(SWIG_From_frag(jstring),"header") { +SWIGINTERNINLINE PyObject * +SWIG_From(jstring)(jstring val) +{ + if (!val) { + return SWIG_Py_Void(); + } + if (sizeof(Py_UNICODE) == sizeof(jchar)) { + return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val), + JvGetStringUTFLength(val)); + } else { + int len = JvGetStringUTFLength(val); + Py_UNICODE pchars[len]; + jchar *jchars = JvGetStringChars(val); + + for (int i = 0; i < len; i++) { + pchars[i] = jchars[i]; + } + return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len); + } +} +} + +%typemaps_asvalfrom(%checkcode(STRING), + %arg(SWIG_AsVal(jstring)), + %arg(SWIG_From(jstring)), + %arg(SWIG_AsVal_frag(jstring)), + %arg(SWIG_From_frag(jstring)), + java::lang::String *); + diff --git a/share/swig/2.0.11/python/pyabc.i b/share/swig/2.0.11/python/pyabc.i new file mode 100644 index 0000000..3da06b5 --- /dev/null +++ b/share/swig/2.0.11/python/pyabc.i @@ -0,0 +1,10 @@ +%define %pythonabc(Type, Abc) + %feature("python:abc", #Abc) Type; +%enddef +%pythoncode {import collections}; +%pythonabc(std::vector, collections.MutableSequence); +%pythonabc(std::list, collections.MutableSequence); +%pythonabc(std::map, collections.MutableMapping); +%pythonabc(std::multimap, collections.MutableMapping); +%pythonabc(std::set, collections.MutableSet); +%pythonabc(std::multiset, collections.MutableSet); diff --git a/share/swig/2.0.11/python/pyapi.swg b/share/swig/2.0.11/python/pyapi.swg new file mode 100644 index 0000000..2da05f9 --- /dev/null +++ b/share/swig/2.0.11/python/pyapi.swg @@ -0,0 +1,47 @@ +/* ----------------------------------------------------------------------------- + * 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; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX >= 0x03000000 +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) +{ + return PyInstanceMethod_New(func); +} +#else +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) +{ + return NULL; +} +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/share/swig/2.0.11/python/pybackward.swg b/share/swig/2.0.11/python/pybackward.swg new file mode 100644 index 0000000..8305fc7 --- /dev/null +++ b/share/swig/2.0.11/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/share/swig/2.0.11/python/pybuffer.i b/share/swig/2.0.11/python/pybuffer.i new file mode 100644 index 0000000..121cd70 --- /dev/null +++ b/share/swig/2.0.11/python/pybuffer.i @@ -0,0 +1,107 @@ +/* Implementing buffer protocol typemaps */ + +/* %pybuffer_mutable_binary(TYPEMAP, SIZE) + * + * Macro for functions accept mutable buffer pointer with a size. + * This can be used for both input and output. For example: + * + * %pybuffer_mutable_binary(char *buff, int size); + * void foo(char *buff, int size) { + * for(int i=0; i<size; ++i) + * buff[i]++; + * } + */ + +%define %pybuffer_mutable_binary(TYPEMAP, SIZE) +%typemap(in) (TYPEMAP, SIZE) + (int res, Py_ssize_t size = 0, void *buf = 0) { + res = PyObject_AsWriteBuffer($input, &buf, &size); + if (res<0) { + PyErr_Clear(); + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1 = ($1_ltype) buf; + $2 = ($2_ltype) (size/sizeof($*1_type)); +} +%enddef + +/* %pybuffer_mutable_string(TYPEMAP, SIZE) + * + * Macro for functions accept mutable zero terminated string pointer. + * This can be used for both input and output. For example: + * + * %pybuffer_mutable_string(char *str); + * void foo(char *str) { + * while(*str) { + * *str = toupper(*str); + * str++; + * } + */ + +%define %pybuffer_mutable_string(TYPEMAP) +%typemap(in) (TYPEMAP) + (int res, Py_ssize_t size = 0, void *buf = 0) { + res = PyObject_AsWriteBuffer($input, &buf, &size); + if (res<0) { + PyErr_Clear(); + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1 = ($1_ltype) buf; +} +%enddef + +/* pybuffer_binary(TYPEMAP, SIZE) + * + * Macro for functions accept read only buffer pointer with a size. + * This must be used for input. For example: + * + * %pybuffer_binary(char *buff, int size); + * int foo(char *buff, int size) { + * int count = 0; + * for(int i=0; i<size; ++i) + * if (0==buff[i]) count++; + * return count; + * } + */ + +%define %pybuffer_binary(TYPEMAP, SIZE) +%typemap(in) (TYPEMAP, SIZE) + (int res, Py_ssize_t size = 0, const void *buf = 0) { + res = PyObject_AsReadBuffer($input, &buf, &size); + if (res<0) { + PyErr_Clear(); + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1 = ($1_ltype) buf; + $2 = ($2_ltype) (size / sizeof($*1_type)); +} +%enddef + +/* %pybuffer_string(TYPEMAP, SIZE) + * + * Macro for functions accept read only zero terminated string pointer. + * This can be used for input. For example: + * + * %pybuffer_string(char *str); + * int foo(char *str) { + * int count = 0; + * while(*str) { + * if (isalnum(*str)) + * count++; + * str++; + * } + */ + +%define %pybuffer_string(TYPEMAP) +%typemap(in) (TYPEMAP) + (int res, Py_ssize_t size = 0, const void *buf = 0) { + res = PyObject_AsReadBuffer($input, &buf, &size); + if (res<0) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1 = ($1_ltype) buf; +} +%enddef + + + diff --git a/share/swig/2.0.11/python/pyclasses.swg b/share/swig/2.0.11/python/pyclasses.swg new file mode 100644 index 0000000..b73ebdb --- /dev/null +++ b/share/swig/2.0.11/python/pyclasses.swg @@ -0,0 +1,149 @@ +#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) + { + Py_XINCREF(_obj); + } + + SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) + { + if (initial_ref) { + Py_XINCREF(_obj); + } + } + + SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) + { + Py_XINCREF(item._obj); + Py_XDECREF(_obj); + _obj = item._obj; + return *this; + } + + ~SwigPtr_PyObject() + { + Py_XDECREF(_obj); + } + + operator PyObject *() const + { + return _obj; + } + + PyObject *operator->() const + { + return _obj; + } + }; +} +%} + +/* + SwigVar_PyObject is used to manage 'in the scope' PyObject * variables, + as in + + int func () { + SwigVar_PyObject obj = PyString_FromString("hello"); + } + + ie, 'obj' is created and destructed in the same scope from + a python object that carries at least one reference value. + + SwigVar_PyObject just take care of applying the proper Py_DECREF. + + Hence, this class is purely internal and not visible at the wrapped side. + */ +namespace swig { + %ignore SwigVar_PyObject; + struct SwigVar_PyObject {}; + %apply PyObject * {SwigVar_PyObject}; + %apply PyObject * const& {SwigVar_PyObject const&}; +} + +%{ +namespace swig { + struct SwigVar_PyObject : SwigPtr_PyObject { + SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } + + SwigVar_PyObject & operator = (PyObject* obj) + { + Py_XDECREF(_obj); + _obj = obj; + return *this; + } + }; +} +%} + + +#endif diff --git a/share/swig/2.0.11/python/pycomplex.swg b/share/swig/2.0.11/python/pycomplex.swg new file mode 100644 index 0000000..74be5b9 --- /dev/null +++ b/share/swig/2.0.11/python/pycomplex.swg @@ -0,0 +1,86 @@ +/* + Defines the As/From converters for double/float complex, you need to + provide complex Type, the Name you want to use in the converters, + the complex Constructor method, and the Real and Imag complex + accessor methods. + + See the std_complex.i and ccomplex.i for concret examples. +*/ + +/* the common from converter */ +%define %swig_fromcplx_conv(Type, Real, Imag) +%fragment(SWIG_From_frag(Type),"header") +{ +SWIGINTERNINLINE PyObject* +SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) +{ + return PyComplex_FromDoubles(Real(c), Imag(c)); +} +} +%enddef + +/* the double case */ +%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=SWIG_AsVal_frag(double)) +{ +SWIGINTERN int +SWIG_AsVal(Type) (PyObject *o, Type* val) +{ + if (PyComplex_Check(o)) { + if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o)); + return SWIG_OK; + } else { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); + if (SWIG_IsOK(res)) { + if (val) *val = Constructor(d, 0.0); + return res; + } + } + return SWIG_TypeError; +} +} +%swig_fromcplx_conv(Type, Real, Imag); +%enddef + +/* the float case */ +%define %swig_cplxflt_conv(Type, Constructor, Real, Imag) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=SWIG_AsVal_frag(float)) { +SWIGINTERN int +SWIG_AsVal(Type)(PyObject *o, Type *val) +{ + if (PyComplex_Check(o)) { + double re = PyComplex_RealAsDouble(o); + double im = PyComplex_ImagAsDouble(o); + if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { + if (val) *val = Constructor(%numeric_cast(re, float), + %numeric_cast(im, float)); + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else { + float re; + int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); + if (SWIG_IsOK(res)) { + if (val) *val = Constructor(re, 0.0); + return res; + } + } + return SWIG_TypeError; +} +} + +%swig_fromcplx_conv(Type, Real, Imag); +%enddef + +#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ +%swig_cplxflt_conv(Type, Constructor, Real, Imag) + + +#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ +%swig_cplxdbl_conv(Type, Constructor, Real, Imag) + + diff --git a/share/swig/2.0.11/python/pycontainer.swg b/share/swig/2.0.11/python/pycontainer.swg new file mode 100644 index 0000000..d438662 --- /dev/null +++ b/share/swig/2.0.11/python/pycontainer.swg @@ -0,0 +1,992 @@ +/* ----------------------------------------------------------------------------- + * pycontainer.swg + * + * Python sequence <-> C++ container wrapper + * + * This wrapper, and its iterator, allows a general use (and reuse) of + * the mapping between C++ and Python, thanks to the C++ templates. + * + * Of course, it needs the C++ compiler to support templates, but + * since we will use this wrapper with the STL containers, that should + * be the case. + * ----------------------------------------------------------------------------- */ + +%{ +#include <iostream> + +#if PY_VERSION_HEX >= 0x03020000 +# define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj)) +#else +# define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj)) +#endif +%} + + +#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) +# if !defined(SWIG_EXPORT_ITERATOR_METHODS) +# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS +# endif +#endif + +%include <pyiterators.swg> + +/**** The PySequence C++ Wrap ***/ + +%insert(header) %{ +#include <stdexcept> +%} + +%include <std_except.i> + +%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { +namespace swig { + template <> struct traits<SwigPtr_PyObject > { + typedef value_category category; + static const char* type_name() { return "SwigPtr_PyObject"; } + }; + + template <> struct traits_from<SwigPtr_PyObject> { + typedef SwigPtr_PyObject value_type; + static PyObject *from(const value_type& val) { + PyObject *obj = static_cast<PyObject *>(val); + Py_XINCREF(obj); + return obj; + } + }; + + template <> + struct traits_check<SwigPtr_PyObject, value_category> { + static bool check(SwigPtr_PyObject) { + return true; + } + }; + + template <> struct traits_asval<SwigPtr_PyObject > { + typedef SwigPtr_PyObject value_type; + static int asval(PyObject *obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; +} +} + +%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") { +namespace swig { + template <> struct traits<SwigVar_PyObject > { + typedef value_category category; + static const char* type_name() { return "SwigVar_PyObject"; } + }; + + template <> struct traits_from<SwigVar_PyObject> { + typedef SwigVar_PyObject value_type; + static PyObject *from(const value_type& val) { + PyObject *obj = static_cast<PyObject *>(val); + Py_XINCREF(obj); + return obj; + } + }; + + template <> + struct traits_check<SwigVar_PyObject, value_category> { + static bool check(SwigVar_PyObject) { + return true; + } + }; + + template <> struct traits_asval<SwigVar_PyObject > { + typedef SwigVar_PyObject value_type; + static int asval(PyObject *obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; +} +} + +%fragment("SwigPySequence_Base","header",fragment="<stddef.h>") +{ +%#include <functional> + +namespace std { + template <> + struct less <PyObject *>: public binary_function<PyObject *, PyObject *, bool> + { + bool + operator()(PyObject * v, PyObject *w) const + { + bool res; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false; + /* This may fall into a case of inconsistent + eg. ObjA > ObjX > ObjB + but ObjA < ObjB + */ + if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) + { + /* Objects can't be compared, this mostly occurred in Python 3.0 */ + /* Compare their ptr directly for a workaround */ + res = (v < w); + PyErr_Clear(); + } + SWIG_PYTHON_THREAD_END_BLOCK; + return res; + } + }; + + template <> + struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool> + { + bool + operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const + { + return std::less<PyObject *>()(v, w); + } + }; + + template <> + struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool> + { + bool + operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const + { + return std::less<PyObject *>()(v, w); + } + }; + +} + +namespace swig { + template <> struct traits<PyObject *> { + typedef value_category category; + static const char* type_name() { return "PyObject *"; } + }; + + template <> struct traits_asval<PyObject * > { + typedef PyObject * value_type; + static int asval(PyObject *obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; + + template <> + struct traits_check<PyObject *, value_category> { + static bool check(PyObject *) { + return true; + } + }; + + template <> struct traits_from<PyObject *> { + typedef PyObject * value_type; + static PyObject *from(const value_type& val) { + Py_XINCREF(val); + return val; + } + }; + +} + +namespace swig { + template <class Difference> + inline size_t + check_index(Difference i, size_t size, bool insert = false) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) + return (size_t) (i + size); + } else if ( (size_t) i < size ) { + return (size_t) i; + } else if (insert && ((size_t) i == size)) { + return size; + } + throw std::out_of_range("index out of range"); + } + + template <class Difference> + void + slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) { + if (step == 0) { + throw std::invalid_argument("slice step cannot be zero"); + } else if (step > 0) { + // Required range: 0 <= i < size, 0 <= j < size + if (i < 0) { + ii = 0; + } else if (i < (Difference)size) { + ii = i; + } else if (insert && (i >= (Difference)size)) { + ii = (Difference)size; + } + if ( j < 0 ) { + jj = 0; + } else { + jj = (j < (Difference)size) ? j : (Difference)size; + } + } else { + // Required range: -1 <= i < size-1, -1 <= j < size-1 + if (i < -1) { + ii = -1; + } else if (i < (Difference) size) { + ii = i; + } else if (i >= (Difference)(size-1)) { + ii = (Difference)(size-1); + } + if (j < -1) { + jj = -1; + } else { + jj = (j < (Difference)size ) ? j : (Difference)(size-1); + } + } + } + + template <class Sequence, class Difference> + inline typename Sequence::iterator + getpos(Sequence* self, Difference i) { + typename Sequence::iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline typename Sequence::const_iterator + cgetpos(const Sequence* self, Difference i) { + typename Sequence::const_iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline Sequence* + getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) { + typename Sequence::size_type size = self->size(); + Difference ii = 0; + Difference jj = 0; + swig::slice_adjust(i, j, step, size, ii, jj); + + if (step > 0) { + typename Sequence::const_iterator sb = self->begin(); + typename Sequence::const_iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + if (step == 1) { + return new Sequence(sb, se); + } else { + Sequence *sequence = new Sequence(); + typename Sequence::const_iterator it = sb; + while (it!=se) { + sequence->push_back(*it); + for (Py_ssize_t c=0; c<step && it!=se; ++c) + it++; + } + return sequence; + } + } else { + Sequence *sequence = new Sequence(); + if (ii > jj) { + typename Sequence::const_reverse_iterator sb = self->rbegin(); + typename Sequence::const_reverse_iterator se = self->rbegin(); + std::advance(sb,size-ii-1); + std::advance(se,size-jj-1); + typename Sequence::const_reverse_iterator it = sb; + while (it!=se) { + sequence->push_back(*it); + for (Py_ssize_t c=0; c<-step && it!=se; ++c) + it++; + } + } + return sequence; + } + } + + template <class Sequence, class Difference, class InputSeq> + inline void + setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { + typename Sequence::size_type size = self->size(); + Difference ii = 0; + Difference jj = 0; + swig::slice_adjust(i, j, step, size, ii, jj, true); + if (step > 0) { + if (jj < ii) + jj = ii; + if (step == 1) { + size_t ssize = jj - ii; + if (ssize <= is.size()) { + // expanding/staying the same size + typename Sequence::iterator sb = self->begin(); + typename InputSeq::const_iterator isit = is.begin(); + std::advance(sb,ii); + std::advance(isit, jj - ii); + self->insert(std::copy(is.begin(), isit, sb), isit, is.end()); + } else { + // shrinking + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + sb = self->begin(); + std::advance(sb,ii); + self->insert(sb, is.begin(), is.end()); + } + } else { + size_t replacecount = (jj - ii + step - 1) / step; + if (is.size() != replacecount) { + char msg[1024]; + sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); + throw std::invalid_argument(msg); + } + typename Sequence::const_iterator isit = is.begin(); + typename Sequence::iterator it = self->begin(); + std::advance(it,ii); + for (size_t rc=0; rc<replacecount; ++rc) { + *it++ = *isit++; + for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) + it++; + } + } + } else { + if (jj > ii) + jj = ii; + size_t replacecount = (ii - jj - step - 1) / -step; + if (is.size() != replacecount) { + char msg[1024]; + sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); + throw std::invalid_argument(msg); + } + typename Sequence::const_iterator isit = is.begin(); + typename Sequence::reverse_iterator it = self->rbegin(); + std::advance(it,size-ii-1); + for (size_t rc=0; rc<replacecount; ++rc) { + *it++ = *isit++; + for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) + it++; + } + } + } + + template <class Sequence, class Difference> + inline void + delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) { + typename Sequence::size_type size = self->size(); + Difference ii = 0; + Difference jj = 0; + swig::slice_adjust(i, j, step, size, ii, jj, true); + if (step > 0) { + if (jj > ii) { + typename Sequence::iterator sb = self->begin(); + std::advance(sb,ii); + if (step == 1) { + typename Sequence::iterator se = self->begin(); + std::advance(se,jj); + self->erase(sb,se); + } else { + typename Sequence::iterator it = sb; + size_t delcount = (jj - ii + step - 1) / step; + while (delcount) { + it = self->erase(it); + for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) + it++; + delcount--; + } + } + } + } else { + if (ii > jj) { + typename Sequence::reverse_iterator sb = self->rbegin(); + std::advance(sb,size-ii-1); + typename Sequence::reverse_iterator it = sb; + size_t delcount = (ii - jj - step - 1) / -step; + while (delcount) { + it = typename Sequence::reverse_iterator(self->erase((++it).base())); + for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) + it++; + delcount--; + } + } + } + } +} +} + +%fragment("SwigPySequence_Cont","header", + fragment="StdTraits", + fragment="SwigPySequence_Base", + fragment="SwigPyIterator_T") +{ +namespace swig +{ + template <class T> + struct SwigPySequence_Ref + { + SwigPySequence_Ref(PyObject* seq, int index) + : _seq(seq), _index(index) + { + } + + operator T () const + { + swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index); + try { + return swig::as<T>(item, true); + } catch (std::exception& e) { + char msg[1024]; + sprintf(msg, "in sequence element %d ", _index); + if (!PyErr_Occurred()) { + ::%type_error(swig::type_name<T>()); + } + SWIG_Python_AddErrorMsg(msg); + SWIG_Python_AddErrorMsg(e.what()); + throw; + } + } + + SwigPySequence_Ref& operator=(const T& v) + { + PySequence_SetItem(_seq, _index, swig::from<T>(v)); + return *this; + } + + private: + PyObject* _seq; + int _index; + }; + + template <class T> + struct SwigPySequence_ArrowProxy + { + SwigPySequence_ArrowProxy(const T& x): m_value(x) {} + const T* operator->() const { return &m_value; } + operator const T*() const { return &m_value; } + T m_value; + }; + + template <class T, class Reference > + struct SwigPySequence_InputIterator + { + typedef SwigPySequence_InputIterator<T, Reference > self; + + typedef std::random_access_iterator_tag iterator_category; + typedef Reference reference; + typedef T value_type; + typedef T* pointer; + typedef int difference_type; + + SwigPySequence_InputIterator() + { + } + + SwigPySequence_InputIterator(PyObject* seq, int index) + : _seq(seq), _index(index) + { + } + + reference operator*() const + { + return reference(_seq, _index); + } + + SwigPySequence_ArrowProxy<T> + operator->() const { + return SwigPySequence_ArrowProxy<T>(operator*()); + } + + bool operator==(const self& ri) const + { + return (_index == ri._index) && (_seq == ri._seq); + } + + bool operator!=(const self& ri) const + { + return !(operator==(ri)); + } + + self& operator ++ () + { + ++_index; + return *this; + } + + self& operator -- () + { + --_index; + return *this; + } + + self& operator += (difference_type n) + { + _index += n; + return *this; + } + + self operator +(difference_type n) const + { + return self(_seq, _index + n); + } + + self& operator -= (difference_type n) + { + _index -= n; + return *this; + } + + self operator -(difference_type n) const + { + return self(_seq, _index - n); + } + + difference_type operator - (const self& ri) const + { + return _index - ri._index; + } + + bool operator < (const self& ri) const + { + return _index < ri._index; + } + + reference + operator[](difference_type n) const + { + return reference(_seq, _index + n); + } + + private: + PyObject* _seq; + difference_type _index; + }; + + template <class T> + struct SwigPySequence_Cont + { + typedef SwigPySequence_Ref<T> reference; + typedef const SwigPySequence_Ref<T> const_reference; + typedef T value_type; + typedef T* pointer; + typedef int difference_type; + typedef int size_type; + typedef const pointer const_pointer; + typedef SwigPySequence_InputIterator<T, reference> iterator; + typedef SwigPySequence_InputIterator<T, const_reference> const_iterator; + + SwigPySequence_Cont(PyObject* seq) : _seq(0) + { + if (!PySequence_Check(seq)) { + throw std::invalid_argument("a sequence is expected"); + } + _seq = seq; + Py_INCREF(_seq); + } + + ~SwigPySequence_Cont() + { + Py_XDECREF(_seq); + } + + size_type size() const + { + return static_cast<size_type>(PySequence_Size(_seq)); + } + + bool empty() const + { + return size() == 0; + } + + iterator begin() + { + return iterator(_seq, 0); + } + + const_iterator begin() const + { + return const_iterator(_seq, 0); + } + + iterator end() + { + return iterator(_seq, size()); + } + + const_iterator end() const + { + return const_iterator(_seq, size()); + } + + reference operator[](difference_type n) + { + return reference(_seq, n); + } + + const_reference operator[](difference_type n) const + { + return const_reference(_seq, n); + } + + bool check(bool set_err = true) const + { + int s = size(); + for (int i = 0; i < s; ++i) { + swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); + if (!swig::check<value_type>(item)) { + if (set_err) { + char msg[1024]; + sprintf(msg, "in sequence element %d", i); + SWIG_Error(SWIG_RuntimeError, msg); + } + return false; + } + } + return true; + } + + private: + PyObject* _seq; + }; + +} +} + +%define %swig_sequence_iterator(Sequence...) +#if defined(SWIG_EXPORT_ITERATOR_METHODS) + class iterator; + class reverse_iterator; + class const_iterator; + class const_reverse_iterator; + + %typemap(out,noblock=1,fragment="SwigPySequence_Cont") + iterator, reverse_iterator, const_iterator, const_reverse_iterator { + $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + } + %typemap(out,noblock=1,fragment="SwigPySequence_Cont") + std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> { + $result = PyTuple_New(2); + PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); + PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); + } + + %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {} + + %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator") + std::pair<iterator, bool>, std::pair<const_iterator, bool> { + $result = PyTuple_New(2); + PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); + PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); + } + + %typemap(in,noblock=1,fragment="SwigPySequence_Cont") + iterator(swig::SwigPyIterator *iter = 0, int res), + reverse_iterator(swig::SwigPyIterator *iter = 0, int res), + const_iterator(swig::SwigPyIterator *iter = 0, int res), + const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + if (!SWIG_IsOK(res) || !iter) { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } else { + swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter); + if (iter_t) { + $1 = iter_t->get_current(); + } else { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } + } + } + + %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont") + iterator, reverse_iterator, const_iterator, const_reverse_iterator { + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter) != 0)); + } + + %fragment("SwigPySequence_Cont"); + + %newobject iterator(PyObject **PYTHON_SELF); + %extend { + swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) { + return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "tp_iter", functype="getiterfunc") iterator; +#else + %pythoncode {def __iter__(self): return self.iterator()} +#endif + } + +#endif //SWIG_EXPORT_ITERATOR_METHODS +%enddef + + +/**** The python container methods ****/ + +%define %swig_container_methods(Container...) + +/* deprecated in Python 2 */ +#if 1 + %newobject __getslice__; +#endif + %newobject __getitem__(PySliceObject *slice); + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "nb_nonzero", functype="inquiry") __nonzero__; + %feature("python:slot", "sq_length", functype="lenfunc") __len__; +#endif // SWIGPYTHON_BUILTIN + + %extend { + bool __nonzero__() const { + return !(self->empty()); + } + + /* Alias for Python 3 compatibility */ + bool __bool__() const { + return !(self->empty()); + } + + size_type __len__() const { + return self->size(); + } + } + +%enddef + + + +%define %swig_sequence_methods_common(Sequence...) + %swig_sequence_iterator(%arg(Sequence)) + %swig_container_methods(%arg(Sequence)) + + %fragment("SwigPySequence_Base"); + +#if defined(SWIGPYTHON_BUILTIN) + //%feature("python:slot", "sq_item", functype="ssizeargfunc") __getitem__; + //%feature("python:slot", "sq_slice", functype="ssizessizeargfunc") __getslice__; + //%feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") __setitem__; + //%feature("python:slot", "sq_ass_slice", functype="ssizessizeobjargproc") __setslice__; + %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; + %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; +#endif // SWIGPYTHON_BUILTIN + + %extend { + value_type pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty container"); + Sequence::value_type x = self->back(); + self->pop_back(); + return x; + } + + /* typemap for slice object support */ + %typemap(in) PySliceObject* { + if (!PySlice_Check($input)) { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } + $1 = (PySliceObject *) $input; + } + %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* { + $1 = PySlice_Check($input); + } + +/* deprecated in Python 2 */ +#if 1 + Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { + return swig::getslice(self, i, j, 1); + } + + void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) throw (std::out_of_range, std::invalid_argument) { + swig::setslice(self, i, j, 1, v); + } + + void __delslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { + swig::delslice(self, i, j, 1); + } +#endif + + void __delitem__(difference_type i) throw (std::out_of_range) { + self->erase(swig::getpos(self,i)); + } + + + /* Overloaded methods for Python 3 compatibility + * (Also useful in Python 2.x) + */ + Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return NULL; + } + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + return swig::getslice(self, id, jd, step); + } + + void __setitem__(PySliceObject *slice, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + swig::setslice(self, id, jd, step, v); + } + + void __setitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + swig::delslice(self, id, jd, step); + } + + void __delitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + swig::delslice(self, id, jd, step); + } + + } + +%enddef + +%define %swig_sequence_methods(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { + *(swig::getpos(self,i)) = x; + } + + void append(const value_type& x) { + self->push_back(x); + } + } + +%enddef + +%define %swig_sequence_methods_val(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + value_type __getitem__(difference_type i) throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { + *(swig::getpos(self,i)) = x; + } + + void append(value_type x) { + self->push_back(x); + } + } + +%enddef + + + +// +// Common fragments +// + +%fragment("StdSequenceTraits","header", + fragment="StdTraits", + fragment="SwigPySequence_Cont") +{ +namespace swig { + template <class SwigPySeq, class Seq> + inline void + assign(const SwigPySeq& swigpyseq, Seq* seq) { + // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented + typedef typename SwigPySeq::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } + } + + template <class Seq, class T = typename Seq::value_type > + struct traits_asptr_stdseq { + typedef Seq sequence; + typedef T value_type; + + static int asptr(PyObject *obj, sequence **seq) { + if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) { + sequence *p; + if (::SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info<sequence>(),0) == SWIG_OK) { + if (seq) *seq = p; + return SWIG_OLDOBJ; + } + } else if (PySequence_Check(obj)) { + try { + SwigPySequence_Cont<value_type> swigpyseq(obj); + if (seq) { + sequence *pseq = new sequence(); + assign(swigpyseq, pseq); + *seq = pseq; + return SWIG_NEWOBJ; + } else { + return swigpyseq.check() ? SWIG_OK : SWIG_ERROR; + } + } catch (std::exception& e) { + if (seq) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, e.what()); + } + } + return SWIG_ERROR; + } + } + return SWIG_ERROR; + } + }; + + template <class Seq, class T = typename Seq::value_type > + struct traits_from_stdseq { + typedef Seq sequence; + typedef T value_type; + typedef typename Seq::size_type size_type; + typedef typename sequence::const_iterator const_iterator; + + static PyObject *from(const sequence& seq) { +%#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS + swig_type_info *desc = swig::type_info<sequence>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); + } +%#endif + size_type size = seq.size(); + if (size <= (size_type)INT_MAX) { + PyObject *obj = PyTuple_New((int)size); + int i = 0; + for (const_iterator it = seq.begin(); + it != seq.end(); ++it, ++i) { + PyTuple_SetItem(obj,i,swig::from<value_type>(*it)); + } + return obj; + } else { + PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python"); + return NULL; + } + } + }; +} +} diff --git a/share/swig/2.0.11/python/pydocs.swg b/share/swig/2.0.11/python/pydocs.swg new file mode 100644 index 0000000..f4ab9db --- /dev/null +++ b/share/swig/2.0.11/python/pydocs.swg @@ -0,0 +1,22 @@ + +// 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) 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) 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 diff --git a/share/swig/2.0.11/python/pyerrors.swg b/share/swig/2.0.11/python/pyerrors.swg new file mode 100644 index 0000000..fe73135 --- /dev/null +++ b/share/swig/2.0.11/python/pyerrors.swg @@ -0,0 +1,70 @@ +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} diff --git a/share/swig/2.0.11/python/pyfragments.swg b/share/swig/2.0.11/python/pyfragments.swg new file mode 100644 index 0000000..535a45b --- /dev/null +++ b/share/swig/2.0.11/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/share/swig/2.0.11/python/pyhead.swg b/share/swig/2.0.11/python/pyhead.swg new file mode 100644 index 0000000..cedd017 --- /dev/null +++ b/share/swig/2.0.11/python/pyhead.swg @@ -0,0 +1,218 @@ +/* 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 PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#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 + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *cstr; + char *newstr; + Py_ssize_t len; + str = PyUnicode_AsUTF8String(str); + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +/* Add PyObject_Del for old Pythons */ +#if PY_VERSION_HEX < 0x01060000 +# define PyObject_Del(op) PyMem_DEL((op)) +#endif +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif + +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +typedef inquiry lenfunc; +typedef intargfunc ssizeargfunc; +typedef intintargfunc ssizessizeargfunc; +typedef intobjargproc ssizeobjargproc; +typedef intintobjargproc ssizessizeobjargproc; +typedef getreadbufferproc readbufferproc; +typedef getwritebufferproc writebufferproc; +typedef getsegcountproc segcountproc; +typedef getcharbufferproc charbufferproc; +static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) +{ + long result = 0; + PyObject *i = PyNumber_Int(x); + if (i) { + result = PyInt_AsLong(i); + Py_DECREF(i); + } + return result; +} +#endif + +#if PY_VERSION_HEX < 0x02050000 +#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) +#endif + +#if PY_VERSION_HEX < 0x02040000 +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; + PyBufferProcs as_buffer; + PyObject *name, *slots; +} PyHeapTypeObject; +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef destructor freefunc; +#endif + +#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ + (PY_MAJOR_VERSION > 3)) +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +#endif + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#endif diff --git a/share/swig/2.0.11/python/pyinit.swg b/share/swig/2.0.11/python/pyinit.swg new file mode 100644 index 0000000..6a6de09 --- /dev/null +++ b/share/swig/2.0.11/python/pyinit.swg @@ -0,0 +1,443 @@ +/* ------------------------------------------------------------ + * The start of the Python initialization function + * ------------------------------------------------------------ */ + +%insert(init) "swiginit.swg" + +%init %{ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + +/* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + +typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; +} swig_globalvar; + +typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; +} swig_varlinkobject; + +SWIGINTERN PyObject * +swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString("<Swig global variables>"); +#else + return PyString_FromString("<Swig global variables>"); +#endif +} + +SWIGINTERN PyObject * +swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; +} + +SWIGINTERN int +swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *tmp; + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(str); + return 0; +} + +SWIGINTERN void +swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } +} + +SWIGINTERN PyObject * +swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; +} + +SWIGINTERN int +swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; +} + +SWIGINTERN PyTypeObject* +swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + (printfunc) swig_varlink_print, /* tp_print */ + (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 */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + varlink_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&varlink_type) < 0) + return NULL; +#endif + } + return &varlink_type; +} + +/* Create a variable linking object for use later */ +SWIGINTERN PyObject * +SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); +} + +SWIGINTERN void +SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; +} + +SWIGINTERN PyObject * +SWIG_globals(void) { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; +} + +/* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + +/* Install Constants */ +SWIGINTERN void +SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_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); + } + } +} + +/* -----------------------------------------------------------------------------*/ +/* Fix SwigMethods to carry the callback ptrs when needed */ +/* -----------------------------------------------------------------------------*/ + +SWIGINTERN void +SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + 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; + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } +} + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 + PyObject* +#else + void +#endif +SWIG_init(void) { + PyObject *m, *d, *md; +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { +# if PY_VERSION_HEX >= 0x03020000 + PyModuleDef_HEAD_INIT, +# else + { + PyObject_HEAD_INIT(NULL) + NULL, /* m_init */ + 0, /* m_index */ + NULL, /* m_copy */ + }, +# endif + (char *) 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 = { + (PyCFunction) SwigPyObject_own, + (PyCFunction) SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyObject *metatype_args; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + + /* metatype is used to implement static member variables. */ + metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); + assert(metatype_args); + metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); + assert(metatype); + Py_DECREF(metatype_args); + metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; + assert(PyType_Ready(metatype) >= 0); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule((char *) SWIG_name, SwigMethods); +#endif + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + 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_TypeOnce(); + } else if (SwigPyObject_TypeOnce()->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/share/swig/2.0.11/python/pyiterators.swg b/share/swig/2.0.11/python/pyiterators.swg new file mode 100644 index 0000000..f93594c --- /dev/null +++ b/share/swig/2.0.11/python/pyiterators.swg @@ -0,0 +1,404 @@ +/* ----------------------------------------------------------------------------- + * pyiterators.swg + * + * Implement a python 'output' iterator for Python 2.2 or higher. + * + * Users can derive form the SwigPyIterator to implement their + * own iterators. As an example (real one since we use it for STL/STD + * containers), the template SwigPyIterator_T does the + * implementation for generic C++ iterators. + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +%fragment("SwigPyIterator","header",fragment="<stddef.h>") { +namespace swig { + struct stop_iteration { + }; + + struct SwigPyIterator { + private: + SwigPtr_PyObject _seq; + + protected: + SwigPyIterator(PyObject *seq) : _seq(seq) + { + } + + public: + virtual ~SwigPyIterator() {} + + // Access iterator method, required by Python + virtual PyObject *value() const = 0; + + // Forward iterator method, required by Python + virtual SwigPyIterator *incr(size_t n = 1) = 0; + + // Backward iterator method, very common in C++, but not required in Python + virtual SwigPyIterator *decr(size_t /*n*/ = 1) + { + throw stop_iteration(); + } + + // Random access iterator methods, but not required in Python + virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const + { + throw std::invalid_argument("operation not supported"); + } + + virtual bool equal (const SwigPyIterator &/*x*/) const + { + throw std::invalid_argument("operation not supported"); + } + + // C++ common/needed methods + virtual SwigPyIterator *copy() const = 0; + + PyObject *next() + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads + PyObject *obj = value(); + incr(); + SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads + return obj; + } + + /* Make an alias for Python 3.x */ + PyObject *__next__() + { + return next(); + } + + PyObject *previous() + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads + decr(); + PyObject *obj = value(); + SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads + return obj; + } + + SwigPyIterator *advance(ptrdiff_t n) + { + return (n > 0) ? incr(n) : decr(-n); + } + + bool operator == (const SwigPyIterator& x) const + { + return equal(x); + } + + bool operator != (const SwigPyIterator& x) const + { + return ! operator==(x); + } + + SwigPyIterator& operator += (ptrdiff_t n) + { + return *advance(n); + } + + SwigPyIterator& operator -= (ptrdiff_t n) + { + return *advance(-n); + } + + SwigPyIterator* operator + (ptrdiff_t n) const + { + return copy()->advance(n); + } + + SwigPyIterator* operator - (ptrdiff_t n) const + { + return copy()->advance(-n); + } + + ptrdiff_t operator - (const SwigPyIterator& x) const + { + return x.distance(*this); + } + + static swig_type_info* descriptor() { + static int init = 0; + static swig_type_info* desc = 0; + if (!init) { + desc = SWIG_TypeQuery("swig::SwigPyIterator *"); + init = 1; + } + return desc; + } + }; + +%#if defined(SWIGPYTHON_BUILTIN) + inline PyObject* make_output_iterator_builtin (PyObject *pyself) + { + Py_INCREF(pyself); + return pyself; + } +%#endif +} +} + +%fragment("SwigPyIterator_T","header",fragment="<stddef.h>",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") { +namespace swig { + template<typename OutIterator> + class SwigPyIterator_T : public SwigPyIterator + { + public: + typedef OutIterator out_iterator; + typedef typename std::iterator_traits<out_iterator>::value_type value_type; + typedef SwigPyIterator_T<out_iterator> self_type; + + SwigPyIterator_T(out_iterator curr, PyObject *seq) + : SwigPyIterator(seq), current(curr) + { + } + + const out_iterator& get_current() const + { + return current; + } + + + bool equal (const SwigPyIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return (current == iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + ptrdiff_t distance(const SwigPyIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return std::distance(current, iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + protected: + out_iterator current; + }; + + template <class ValueType> + struct from_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v); + } + }; + + template<typename OutIterator, + typename ValueType = typename std::iterator_traits<OutIterator>::value_type, + typename FromOper = from_oper<ValueType> > + class SwigPyIteratorOpen_T : public SwigPyIterator_T<OutIterator> + { + public: + FromOper from; + typedef OutIterator out_iterator; + typedef ValueType value_type; + typedef SwigPyIterator_T<out_iterator> base; + typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type; + + SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq) + : SwigPyIterator_T<OutIterator>(curr, seq) + { + } + + PyObject *value() const { + return from(static_cast<const value_type&>(*(base::current))); + } + + SwigPyIterator *copy() const + { + return new self_type(*this); + } + + SwigPyIterator *incr(size_t n = 1) + { + while (n--) { + ++base::current; + } + return this; + } + + SwigPyIterator *decr(size_t n = 1) + { + while (n--) { + --base::current; + } + return this; + } + }; + + template<typename OutIterator, + typename ValueType = typename std::iterator_traits<OutIterator>::value_type, + typename FromOper = from_oper<ValueType> > + class SwigPyIteratorClosed_T : public SwigPyIterator_T<OutIterator> + { + public: + FromOper from; + typedef OutIterator out_iterator; + typedef ValueType value_type; + typedef SwigPyIterator_T<out_iterator> base; + typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type; + + SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) + : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last) + { + } + + PyObject *value() const { + if (base::current == end) { + throw stop_iteration(); + } else { + return from(static_cast<const value_type&>(*(base::current))); + } + } + + SwigPyIterator *copy() const + { + return new self_type(*this); + } + + SwigPyIterator *incr(size_t n = 1) + { + while (n--) { + if (base::current == end) { + throw stop_iteration(); + } else { + ++base::current; + } + } + return this; + } + + SwigPyIterator *decr(size_t n = 1) + { + while (n--) { + if (base::current == begin) { + throw stop_iteration(); + } else { + --base::current; + } + } + return this; + } + + private: + out_iterator begin; + out_iterator end; + }; + + template<typename OutIter> + inline SwigPyIterator* + make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) + { + return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq); + } + + template<typename OutIter> + inline SwigPyIterator* + make_output_iterator(const OutIter& current, PyObject *seq = 0) + { + return new SwigPyIteratorOpen_T<OutIter>(current, seq); + } + +} +} + + +%fragment("SwigPyIterator"); +namespace swig +{ + /* + Throw a StopIteration exception + */ + %ignore stop_iteration; + struct stop_iteration {}; + + %typemap(throws) stop_iteration { + (void)$1; + SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void()); + SWIG_fail; + } + + /* + Mark methods that return new objects + */ + %newobject SwigPyIterator::copy; + %newobject SwigPyIterator::operator + (ptrdiff_t n) const; + %newobject SwigPyIterator::operator - (ptrdiff_t n) const; + + %nodirector SwigPyIterator; + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:tp_iter") SwigPyIterator "&swig::make_output_iterator_builtin"; + %feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__; +#else + %extend SwigPyIterator { + %pythoncode {def __iter__(self): return self} + } +#endif + + %catches(swig::stop_iteration) SwigPyIterator::value() const; + %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1); + %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1); + %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const; + %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const; + %catches(swig::stop_iteration) SwigPyIterator::__next__(); + %catches(swig::stop_iteration) SwigPyIterator::next(); + %catches(swig::stop_iteration) SwigPyIterator::previous(); + %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n); + %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n); + %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n); + %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const; + %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const; + + struct SwigPyIterator + { + protected: + SwigPyIterator(PyObject *seq); + + public: + virtual ~SwigPyIterator(); + + // Access iterator method, required by Python + virtual PyObject *value() const = 0; + + // Forward iterator method, required by Python + virtual SwigPyIterator *incr(size_t n = 1) = 0; + + // Backward iterator method, very common in C++, but not required in Python + virtual SwigPyIterator *decr(size_t n = 1); + + // Random access iterator methods, but not required in Python + virtual ptrdiff_t distance(const SwigPyIterator &x) const; + + virtual bool equal (const SwigPyIterator &x) const; + + // C++ common/needed methods + virtual SwigPyIterator *copy() const = 0; + + PyObject *next(); + PyObject *__next__(); + PyObject *previous(); + SwigPyIterator *advance(ptrdiff_t n); + + bool operator == (const SwigPyIterator& x) const; + bool operator != (const SwigPyIterator& x) const; + SwigPyIterator& operator += (ptrdiff_t n); + SwigPyIterator& operator -= (ptrdiff_t n); + SwigPyIterator* operator + (ptrdiff_t n) const; + SwigPyIterator* operator - (ptrdiff_t n) const; + ptrdiff_t operator - (const SwigPyIterator& x) const; + }; +} + diff --git a/share/swig/2.0.11/python/pymacros.swg b/share/swig/2.0.11/python/pymacros.swg new file mode 100644 index 0000000..ab7bace --- /dev/null +++ b/share/swig/2.0.11/python/pymacros.swg @@ -0,0 +1,4 @@ +%include <typemaps/swigmacros.swg> + + + diff --git a/share/swig/2.0.11/python/pyname_compat.i b/share/swig/2.0.11/python/pyname_compat.i new file mode 100644 index 0000000..96af343 --- /dev/null +++ b/share/swig/2.0.11/python/pyname_compat.i @@ -0,0 +1,86 @@ +/* +* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, +* since they are inappropriate and discouraged in Python documentation +* (from http://www.python.org/doc/2.5.2/api/includes.html): +* +* "All user visible names defined by Python.h (except those defined by the included +* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with +* "_Py" are for internal use by the Python implementation and should not be used +* by extension writers. Structure member names do not have a reserved prefix. +* +* Important: user code should never define names that begin with "Py" or "_Py". +* This confuses the reader, and jeopardizes the portability of the user code to +* future Python versions, which may define additional names beginning with one +* of these prefixes." +* +* This file defined macros to provide backward compatibility for these deprecated +* symbols. In the case you have these symbols in your interface file, you can simply +* include this file at beginning of it. +* +* However, this file may be removed in future release of SWIG, so using this file to +* keep these inappropriate names in your SWIG interface file is also not recommended. +* Instead, we provide a simple tool for converting your interface files to +* the new naming convention. You can get the tool from the SWIG distribution: +* Tools/pyname_patch.py +*/ + +%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {} +%fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {} +%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} +%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {} +%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {} +%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} + +%inline %{ +#define PyMapIterator_T SwigPyMapIterator_T +#define PyMapKeyIterator_T SwigPyMapKeyIterator_T +#define PyMapValueIterator_T SwigPyMapValueITerator_T +#define PyObject_ptr SwigPtr_PyObject +#define PyObject_var SwigVar_PyObject +#define PyOper SwigPyOper +#define PySeq SwigPySeq +#define PySequence_ArrowProxy SwigPySequence_ArrowProxy +#define PySequence_Cont SwigPySequence_Cont +#define PySequence_InputIterator SwigPySequence_InputIterator +#define PySequence_Ref SwigPySequence_Ref +#define PySwigClientData SwigPyClientData +#define PySwigClientData_Del SwigPyClientData_Del +#define PySwigClientData_New SwigPyClientData_New +#define PySwigIterator SwigPyIterator +#define PySwigIteratorClosed_T SwigPyIteratorClosed_T +#define PySwigIteratorOpen_T SwigPyIteratorOpen_T +#define PySwigIterator_T SwigPyIterator_T +#define PySwigObject SwigPyObject +#define PySwigObject_Check SwigPyObject_Check +#define PySwigObject_GetDesc SwigPyObject_GetDesc +#define PySwigObject_New SwigPyObject_New +#define PySwigObject_acquire SwigPyObject_acquire +#define PySwigObject_append SwigPyObject_append +#define PySwigObject_as_number SwigPyObject_as_number +#define PySwigObject_compare SwigPyObject_compare +#define PySwigObject_dealloc SwigPyObject_dealloc +#define PySwigObject_disown SwigPyObject_disown +#define PySwigObject_format SwigPyObject_format +#define PySwigObject_getattr SwigPyObject_getattr +#define PySwigObject_hex SwigPyObject_hex +#define PySwigObject_long SwigPyObject_long +#define PySwigObject_next SwigPyObject_next +#define PySwigObject_oct SwigPyObject_oct +#define PySwigObject_own SwigPyObject_own +#define PySwigObject_repr SwigPyObject_repr +#define PySwigObject_richcompare SwigPyObject_richcompare +#define PySwigObject_type SwigPyObject_type +#define PySwigPacked SwigPyPacked +#define PySwigPacked_Check SwigPyPacked_Check +#define PySwigPacked_New SwigPyPacked_New +#define PySwigPacked_UnpackData SwigPyPacked_UnpackData +#define PySwigPacked_compare SwigPyPacked_compare +#define PySwigPacked_dealloc SwigPyPacked_dealloc +#define PySwigPacked_print SwigPyPacked_print +#define PySwigPacked_repr SwigPyPacked_repr +#define PySwigPacked_str SwigPyPacked_str +#define PySwigPacked_type SwigPyPacked_type +#define pyseq swigpyseq +#define pyswigobject_type swigpyobject_type +#define pyswigpacked_type swigpypacked_type +%} diff --git a/share/swig/2.0.11/python/pyopers.swg b/share/swig/2.0.11/python/pyopers.swg new file mode 100644 index 0000000..ecbe783 --- /dev/null +++ b/share/swig/2.0.11/python/pyopers.swg @@ -0,0 +1,235 @@ +/* ------------------------------------------------------------ + * 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: + + %{ + + static long myHashFunc (PyObject *pyobj) { + MyClass *cobj; + // Convert pyobj to cobj + return (cobj->field1 * (cobj->field2 << 7)); + } + + %} + + %feature("python:tp_hash") MyClass "myHashFunc"; + + 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: + + class MyClass { + public: + long myHashFunc () const; + ... + }; + + %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc; + + 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 %feature("python:slot") like this: + + class MyClass { + public: + bool lessThan (const MyClass& x) const; + ... + }; + + %feature("python:slot", "Py_LT") MyClass::lessThan; + + ... 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 comparsion 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(__div__, *::operator/, binaryfunc, nb_div); +%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); + +%feature("python:slot", "nb_truediv", functype="binaryfunc") *::operator/; + +/* 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); +#else +%feature("shadow") *::operator bool %{ +def __nonzero__(self): + return $action(self) +__bool__ = __nonzero__ +%}; +%rename(__nonzero__) *::operator bool; +#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 'self' pointer, and assigning + it to the returning object: + + %feature("del") *::Operator; + %feature("new") *::Operator; + + This makes the most common case safe, ie: + + A& A::operator+=(int i) { ...; return *this; } + ^^^^ ^^^^^^ + + will work fine, even when the resulting python object shares the + 'this' pointer with the input one. The input object is usually + deleted after the operation, including the shared 'this' pointer, + producing 'strange' seg faults, as reported by Lucriz + (lucriz@sitilandia.it). + + If you have an interface that already takes care of that, ie, you + already are using inplace operators and you are not getting + seg. faults, with the new scheme you could end with 'free' elements + that never get deleted (maybe, not sure, it depends). But if that is + the case, you could recover the old behaviour using + + %feature("del","") A::operator+=; + %feature("new","") A::operator+=; + + which recovers the old behaviour for the class 'A', or if you are + 100% sure your entire system works fine in the old way, use: + + %feature("del","") *::operator+=; + %feature("new","") *::operator+=; + +*/ + +#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(__idiv__ , *::operator /=, binaryfunc, nb_inplace_divide); +%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); + + +/* Finally, in python we need to mark the binary operations to fail as + 'maybecall' methods */ + +#define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __ + +%pybinopermaybecall(add); +%pybinopermaybecall(pos); +%pybinopermaybecall(pos); +%pybinopermaybecall(sub); +%pybinopermaybecall(neg); +%pybinopermaybecall(neg); +%pybinopermaybecall(mul); +%pybinopermaybecall(div); +%pybinopermaybecall(mod); +%pybinopermaybecall(lshift); +%pybinopermaybecall(rshift); +%pybinopermaybecall(and); +%pybinopermaybecall(or); +%pybinopermaybecall(xor); +%pybinopermaybecall(lt); +%pybinopermaybecall(le); +%pybinopermaybecall(gt); +%pybinopermaybecall(ge); +%pybinopermaybecall(eq); +%pybinopermaybecall(ne); + +#endif + + + diff --git a/share/swig/2.0.11/python/pyprimtypes.swg b/share/swig/2.0.11/python/pyprimtypes.swg new file mode 100644 index 0000000..66ff104 --- /dev/null +++ b/share/swig/2.0.11/python/pyprimtypes.swg @@ -0,0 +1,327 @@ +/* ------------------------------------------------------------ + * Primitive Types + * ------------------------------------------------------------ */ + +/* boolean */ + +%fragment(SWIG_From_frag(bool),"header") { +SWIGINTERNINLINE PyObject* + SWIG_From_dec(bool)(bool value) +{ + return PyBool_FromLong(value ? 1 : 0); +} +} + +%fragment(SWIG_AsVal_frag(bool),"header", + fragment=SWIG_AsVal_frag(long)) { +SWIGINTERN int +SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) +{ + int r = PyObject_IsTrue(obj); + if (r == -1) + return SWIG_ERROR; + if (val) *val = r ? true : false; + return SWIG_OK; +} +} + +/* 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), PyLong_FromLong) +} + +%fragment(SWIG_AsVal_frag(long),"header", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(long)(PyObject *obj, long* val) +{ + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +%#endif + return SWIG_TypeError; +} +} + +/* unsigned long */ + +%fragment(SWIG_From_frag(unsigned long),"header", + fragment=SWIG_From_frag(long)) { +SWIGINTERNINLINE PyObject* +SWIG_From_dec(unsigned long)(unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyLong_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(); +%#if PY_VERSION_HEX >= 0x03000000 + { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (v < 0) { + return SWIG_OverflowError; + } + } else { + PyErr_Clear(); + } + } +%#endif + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +%#endif + return SWIG_TypeError; +} +} + +/* long long */ + +%fragment(SWIG_From_frag(long long),"header", + fragment=SWIG_From_frag(long), + fragment="<limits.h>") { +SWIGINTERNINLINE PyObject* +SWIG_From_dec(long long)(long long value) +{ + return ((value < LONG_MIN) || (value > LONG_MAX)) ? + PyLong_FromLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); +} +} + +%fragment(SWIG_AsVal_frag(long long),"header", + fragment=SWIG_AsVal_frag(long), + fragment="SWIG_CanCastAsInteger", + fragment="<limits.h>") { +SWIGINTERN int +SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + long long v = PyLong_AsLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } else { + long v; + res = SWIG_AsVal(long)(obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + res = SWIG_AsVal(double)(obj,&d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +%#endif + return res; +} +} + +/* unsigned long long */ + +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment=SWIG_From_frag(long long), + fragment="<limits.h>") { +SWIGINTERNINLINE PyObject* +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); +} +} + +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment=SWIG_AsVal_frag(unsigned long), + fragment="SWIG_CanCastAsInteger", + fragment="<limits.h>") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } else { + unsigned long v; + res = SWIG_AsVal(unsigned long)(obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal(double)(obj,&d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +%#endif + return res; +} +} + +/* double */ + +%fragment(SWIG_From_frag(double),"header") { + %define_as(SWIG_From_dec(double), PyFloat_FromDouble) +} + +%fragment(SWIG_AsVal_frag(double),"header") { +SWIGINTERN int +SWIG_AsVal_dec(double)(PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +%#endif + return res; +} +} + + + diff --git a/share/swig/2.0.11/python/pyrun.swg b/share/swig/2.0.11/python/pyrun.swg new file mode 100644 index 0000000..b077fad --- /dev/null +++ b/share/swig/2.0.11/python/pyrun.swg @@ -0,0 +1,1774 @@ +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#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) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN int +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + register int 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 { + register Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + register int i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#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 + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +#ifdef METH_NOARGS +SwigPyObject_repr(SwigPyObject *v) +#else +SwigPyObject_repr(SwigPyObject *v, PyObject *args) +#endif +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); + if (v->next) { +# ifdef METH_NOARGS + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# else + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); +# endif +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +SWIGRUNTIME int +SwigPyObject_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); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!SwigPyObject_Check(next)) { + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +SwigPyObject_next(PyObject* v) +#else +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_disown(PyObject *v) +#else +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_acquire(PyObject *v) +#else +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#elif (PY_VERSION_HEX < 0x02050000) + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#else + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v); + } else { + SwigPyObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } +#endif + } + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +SwigPyObject_getattr(SwigPyObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +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 >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 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 */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpyobject_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; +#endif + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME int +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* 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 = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + (printfunc)SwigPyPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpypacked_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; +#endif + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return SWIG_Python_str_FromChar("this"); +} + +static PyObject *swig_this = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (swig_this == NULL) + swig_this = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + 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) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#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 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 (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 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; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } +#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; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst = 0; + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(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; + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + 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 + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else +# ifdef SWIGPY_USE_CAPSULE + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); +# else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); +# endif + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +#ifdef SWIGPY_USE_CAPSULE +SWIG_Python_DestroyModule(PyObject *obj) +#else +SWIG_Python_DestroyModule(void *vptr) +#endif +{ +#ifdef SWIGPY_USE_CAPSULE + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); +#else + swig_module_info *swig_module = (swig_module_info *) vptr; +#endif + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + swig_this = 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((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif +#ifdef SWIGPY_USE_CAPSULE + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#else + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#endif +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { +#ifdef SWIGPY_USE_CAPSULE + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); +#else + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); +#endif + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { +#ifdef SWIGPY_USE_CAPSULE + obj = PyCapsule_New((void*) descriptor, NULL, NULL); +#else + obj = PyCObject_FromVoidPtr(descriptor, NULL); +#endif + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + } else { + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef 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); + } + 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/share/swig/2.0.11/python/pyruntime.swg b/share/swig/2.0.11/python/pyruntime.swg new file mode 100644 index 0000000..fad97be --- /dev/null +++ b/share/swig/2.0.11/python/pyruntime.swg @@ -0,0 +1,22 @@ +%insert(runtime) %{ +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include <Python.h> +# define _DEBUG +#else +# include <Python.h> +#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/share/swig/2.0.11/python/pystdcommon.swg b/share/swig/2.0.11/python/pystdcommon.swg new file mode 100644 index 0000000..2f223a8 --- /dev/null +++ b/share/swig/2.0.11/python/pystdcommon.swg @@ -0,0 +1,259 @@ +%fragment("StdTraits","header",fragment="StdTraitsCommon") +{ +namespace swig { + /* + Traits that provides the from method + */ + template <class Type> struct traits_from_ptr { + static PyObject *from(Type *val, int owner = 0) { + return SWIG_InternalNewPointerObj(val, type_info<Type>(), owner); + } + }; + + template <class Type> struct traits_from { + static PyObject *from(const Type& val) { + return traits_from_ptr<Type>::from(new Type(val), 1); + } + }; + + template <class Type> struct traits_from<Type *> { + static PyObject *from(Type* val) { + return traits_from_ptr<Type>::from(val, 0); + } + }; + + template <class Type> struct traits_from<const Type *> { + static PyObject *from(const Type* val) { + return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0); + } + }; + + + template <class Type> + inline PyObject *from(const Type& val) { + return traits_from<Type>::from(val); + } + + template <class Type> + inline PyObject *from_ptr(Type* val, int owner) { + return traits_from_ptr<Type>::from(val, owner); + } + + /* + Traits that provides the asval/as/check method + */ + template <class Type> + struct traits_asptr { + static int asptr(PyObject *obj, Type **val) { + Type *p; + int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0); + if (SWIG_IsOK(res)) { + if (val) *val = p; + } + return res; + } + }; + + template <class Type> + inline int asptr(PyObject *obj, Type **vptr) { + return traits_asptr<Type>::asptr(obj, vptr); + } + + template <class Type> + struct traits_asval { + static int asval(PyObject *obj, Type *val) { + if (val) { + Type *p = 0; + int res = traits_asptr<Type>::asptr(obj, &p); + if (!SWIG_IsOK(res)) return res; + if (p) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + *(const_cast<noconst_type*>(val)) = *p; + if (SWIG_IsNewObj(res)){ + %delete(p); + res = SWIG_DelNewMask(res); + } + return res; + } else { + return SWIG_ERROR; + } + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> struct traits_asval<Type*> { + static int asval(PyObject *obj, Type **val) { + if (val) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + noconst_type *p = 0; + int res = traits_asptr<noconst_type>::asptr(obj, &p); + if (SWIG_IsOK(res)) { + *(const_cast<noconst_type**>(val)) = p; + } + return res; + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> + inline int asval(PyObject *obj, Type *val) { + return traits_asval<Type>::asval(obj, val); + } + + template <class Type> + struct traits_as<Type, value_category> { + static Type as(PyObject *obj, bool throw_error) { + Type v; + int res = asval(obj, &v); + if (!obj || !SWIG_IsOK(res)) { + if (!PyErr_Occurred()) { + ::%type_error(swig::type_name<Type>()); + } + if (throw_error) throw std::invalid_argument("bad type"); + } + return v; + } + }; + + template <class Type> + struct traits_as<Type, pointer_category> { + static Type as(PyObject *obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res) && v) { + if (SWIG_IsNewObj(res)) { + Type r(*v); + %delete(v); + return r; + } else { + return *v; + } + } else { + // Uninitialized return value, no Type() constructor required. + static Type *v_def = (Type*) malloc(sizeof(Type)); + if (!PyErr_Occurred()) { + %type_error(swig::type_name<Type>()); + } + if (throw_error) throw std::invalid_argument("bad type"); + memset(v_def,0,sizeof(Type)); + return *v_def; + } + } + }; + + template <class Type> + struct traits_as<Type*, pointer_category> { + static Type* as(PyObject *obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res)) { + return v; + } else { + if (!PyErr_Occurred()) { + %type_error(swig::type_name<Type>()); + } + if (throw_error) throw std::invalid_argument("bad type"); + return 0; + } + } + }; + + template <class Type> + inline Type as(PyObject *obj, bool te = false) { + return traits_as<Type, typename traits<Type>::category>::as(obj, te); + } + + template <class Type> + struct traits_check<Type, value_category> { + static bool check(PyObject *obj) { + int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + struct traits_check<Type, pointer_category> { + static bool check(PyObject *obj) { + int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + inline bool check(PyObject *obj) { + return traits_check<Type, typename traits<Type>::category>::check(obj); + } +} +} + +// +// Backward compatibility +// + +#ifdef SWIG_PYTHON_BACKWARD_COMP +%{ +#include <string> + +PyObject* SwigInt_FromBool(bool b) { + return PyInt_FromLong(b ? 1L : 0L); +} +double SwigNumber_Check(PyObject* o) { + return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o); +} +double SwigNumber_AsDouble(PyObject* o) { + return PyFloat_Check(o) ? PyFloat_AsDouble(o) + : (PyInt_Check(o) ? double(PyInt_AsLong(o)) + : double(PyLong_AsLong(o))); +} +PyObject* SwigString_FromString(const std::string& s) { + return PyString_FromStringAndSize(s.data(),s.size()); +} +std::string SwigString_AsString(PyObject* o) { + return std::string(PyString_AsString(o)); +} +%} + +#endif + + +%define %specialize_std_container(Type,Check,As,From) +%{ +namespace swig { + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(PyObject *obj, value_type *val) { + if (Check(obj)) { + if (val) *val = As(obj); + return SWIG_OK; + } + return SWIG_ERROR; + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static PyObject *from(const value_type& val) { + return From(val); + } + }; + + template <> + struct traits_check<Type, value_category> { + static int check(PyObject *obj) { + int res = Check(obj); + return obj && res ? res : 0; + } + }; +} +%} +%enddef + + +#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) diff --git a/share/swig/2.0.11/python/pystrings.swg b/share/swig/2.0.11/python/pystrings.swg new file mode 100644 index 0000000..f6a4eba --- /dev/null +++ b/share/swig/2.0.11/python/pystrings.swg @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------ + * utility methods for char strings + * ------------------------------------------------------------ */ +%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +%#if PY_VERSION_HEX>=0x03000000 + if (PyUnicode_Check(obj)) +%#else + if (PyString_Check(obj)) +%#endif + { + char *cstr; Py_ssize_t len; +%#if PY_VERSION_HEX>=0x03000000 + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + PyBytes_AsStringAndSize(obj, &cstr, &len); + if(alloc) *alloc = SWIG_NEWOBJ; +%#else + PyString_AsStringAndSize(obj, &cstr, &len); +%#endif + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +%#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +%#else + if (*alloc == SWIG_NEWOBJ) +%#endif + { + *cptr = %new_copy_array(cstr, len + 1, char); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { + %#if PY_VERSION_HEX>=0x03000000 + assert(0); /* Should never reach here in Python 3 */ + %#endif + *cptr = SWIG_Python_str_AsChar(obj); + } + } + if (psize) *psize = len + 1; +%#if PY_VERSION_HEX>=0x03000000 + Py_XDECREF(obj); +%#endif + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +%#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int)); +%#else + return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); +%#endif + } + } else { + return SWIG_Py_Void(); + } +} +} + + diff --git a/share/swig/2.0.11/python/python.swg b/share/swig/2.0.11/python/python.swg new file mode 100644 index 0000000..769d9e1 --- /dev/null +++ b/share/swig/2.0.11/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/share/swig/2.0.11/python/pythonkw.swg b/share/swig/2.0.11/python/pythonkw.swg new file mode 100644 index 0000000..8ad0ef1 --- /dev/null +++ b/share/swig/2.0.11/python/pythonkw.swg @@ -0,0 +1,136 @@ +/* + Warnings for Python keywords, built-in names and bad names. +*/ + +#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x` +#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") `x` + + +/* + Warnings for Python keywords + http://www.fnorb.org/docs/1.2/Fnorb-Guide/node62.html +*/ + +PYTHONKW(and); +PYTHONKW(assert); +PYTHONKW(break); +PYTHONKW(class); +PYTHONKW(continue); +PYTHONKW(def); +PYTHONKW(del); +PYTHONKW(elif); +PYTHONKW(else); +PYTHONKW(except); +PYTHONKW(exec); +PYTHONKW(finally); +PYTHONKW(for); +PYTHONKW(from); +PYTHONKW(global); +PYTHONKW(if); +PYTHONKW(import); +PYTHONKW(in); +PYTHONKW(is); +PYTHONKW(lambda); +PYTHONKW(not); +PYTHONKW(or); +PYTHONKW(pass); +PYTHONKW(print); +PYTHONKW(raise); +PYTHONKW(return); +PYTHONKW(try); +PYTHONKW(while); +PYTHONKW(yield); + +/* + built-in functions + http://www.zvon.org/other/python/doc21/lib/built-in-funcs.html + */ + +PYTHONBN(abs); +PYTHONBN(apply); +PYTHONBN(bool); +PYTHONBN(buffer); +PYTHONBN(callable); +PYTHONBN(chr); +PYTHONBN(classmethod); +PYTHONBN(cmp); +PYTHONBN(coerce); +PYTHONBN(compile); +PYTHONBN(complex); +PYTHONBN(delattr); +PYTHONBN(dict); +PYTHONBN(dir); +PYTHONBN(divmod); +PYTHONBN(enumerate); +PYTHONBN(eval); +PYTHONBN(execfile); +PYTHONBN(file); +PYTHONBN(filter); +PYTHONBN(float); +PYTHONBN(frozenset); +PYTHONBN(getattr); +PYTHONBN(globals); +PYTHONBN(hasattr); +PYTHONBN(hash); +PYTHONBN(hex); +PYTHONBN(id); +PYTHONBN(input); +PYTHONBN(int); +PYTHONBN(intern); +PYTHONBN(isinstance); +PYTHONBN(issubclass); +PYTHONBN(iter); +PYTHONBN(len); +PYTHONBN(list); +PYTHONBN(locals); +PYTHONBN(long); +PYTHONBN(map); +PYTHONBN(max); +PYTHONBN(min); +PYTHONBN(object); +PYTHONBN(oct); +PYTHONBN(open); +PYTHONBN(ord); +PYTHONBN(pow); +PYTHONBN(property); +PYTHONBN(range); +PYTHONBN(raw_input); +PYTHONBN(reduce); +PYTHONBN(reload); +PYTHONBN(repr); +PYTHONBN(reversed); +PYTHONBN(round); +PYTHONBN(set); +PYTHONBN(setattr); +PYTHONBN(slice); +PYTHONBN(sorted); +PYTHONBN(staticmethod); +PYTHONBN(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 +*/ +PYTHONBN(self); + +#undef PYTHONBN +#undef PYTHONKW diff --git a/share/swig/2.0.11/python/pythreads.swg b/share/swig/2.0.11/python/pythreads.swg new file mode 100644 index 0000000..a7552f1 --- /dev/null +++ b/share/swig/2.0.11/python/pythreads.swg @@ -0,0 +1,66 @@ +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif diff --git a/share/swig/2.0.11/python/pytuplehlp.swg b/share/swig/2.0.11/python/pytuplehlp.swg new file mode 100644 index 0000000..32e1580 --- /dev/null +++ b/share/swig/2.0.11/python/pytuplehlp.swg @@ -0,0 +1,8 @@ +/* + Helper function to return output types, now we need to use a list + instead of a tuple since all the other types + (std::pair,std::vector,std::list,etc) return tuples. +*/ + +#warning "Deprecated file: Don't use t_output_helper anymore," +#warning "use SWIG_Python_AppendOutput or %append_output instead." diff --git a/share/swig/2.0.11/python/pytypemaps.swg b/share/swig/2.0.11/python/pytypemaps.swg new file mode 100644 index 0000000..c64b47b --- /dev/null +++ b/share/swig/2.0.11/python/pytypemaps.swg @@ -0,0 +1,101 @@ +/* ------------------------------------------------------------ + * Typemap specializations for Python + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Fragment section + * ------------------------------------------------------------ */ +/* bool is dangerous in Python, change precedence */ +#undef SWIG_TYPECHECK_BOOL +%define SWIG_TYPECHECK_BOOL 10000 %enddef + +/* Include fundamental fragemt definitions */ +%include <typemaps/fragments.swg> + +/* Look for user fragments file. */ +%include <pyfragments.swg> + +/* Python fragments for fundamental types */ +%include <pyprimtypes.swg> + +/* Python fragments for char* strings */ +%include <pystrings.swg> + +/* Backward compatibility output helper */ +%fragment("t_output_helper","header") %{ +#define t_output_helper SWIG_Python_AppendOutput +%} + + +/* ------------------------------------------------------------ + * Unified typemap section + * ------------------------------------------------------------ */ + +/* directors are supported in Python */ +#ifndef SWIG_DIRECTOR_TYPEMAPS +#define SWIG_DIRECTOR_TYPEMAPS +#endif + + +/* Python types */ +#define SWIG_Object PyObject * +#define VOID_Object SWIG_Py_Void() + +/* Python allows implicit conversion */ +#define %implicitconv_flag $implicitconv + + +/* Overload of the output/constant/exception/dirout handling */ + +/* append output */ +#define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj) + +/* set constant */ +#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, (char*)"$symname", 0, 0, (void *)($value), &$descriptor } + +%typemap(constcode) SWIGTYPE ((*)(ANY)) ""; + + +/* Smart Pointers */ +%typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { + $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); +} + +%typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { + if ($result) { + PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); + if (robj && !PyErr_Occurred()) { + SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), + (PyObject *) SWIG_Python_GetSwigThis(robj)); + Py_DECREF(robj); + } + } +} + diff --git a/share/swig/2.0.11/python/pyuserdir.swg b/share/swig/2.0.11/python/pyuserdir.swg new file mode 100644 index 0000000..d3c3eb1 --- /dev/null +++ b/share/swig/2.0.11/python/pyuserdir.swg @@ -0,0 +1,246 @@ +/* ------------------------------------------------------------------------- + * 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 + +and works for modern (-modern) and plain python. We do not use __slots__, +so, it works with old python versions. + +*/ + +#define %pythonnondynamic %feature("python:nondynamic", "1") +#define %nopythonnondynamic %feature("python:nondynamic", "0") +#define %clearpythonnondynamic %feature("python:nondynamic", "") +#define %pythondynamic %nopythonnondynamic + + +/* ------------------------------------------------------------------------- */ +/* + +Use %pythonmaybecall to flag a method like __add__ or __radd__. These +don't produce an error when called, they just return NotImplemented. + +These methods "may be called" if needed. + +*/ + +#define %pythonmaybecall %feature("python:maybecall", "1") +#define %nopythonmaybecall %feature("python:maybecall", "0") +#define %clearpythonmaybecall %feature("python:maybecall", "") + +/* ------------------------------------------------------------------------- */ +/* + The %pythoncallback feature produce a more natural callback wrapper + than the %callback mechanism, ie, it uses the original name for + the callback and callable objects. + + Just use it as + + %pythoncallback(1) foo; + int foo(int a); + + %pythoncallback(1) A::foo; + struct A { + static int foo(int a); + }; + + int bar(int, int (*pf)(int)); + + then, you can use it as: + + a = foo(1) + b = bar(2, foo) + + c = A.foo(3) + d = bar(4, A.foo) + + + If you use it with a member method + %pythoncallback(1) A::foom; + struct A { + int foom(int a); + }; + + then you can use it as + + r = a.foom(3) # eval the method + mptr = A.foom_cb_ptr # returns the callback pointer + + where the '_cb_ptr' suffix is added for the callback pointer. + +*/ + +#define %pythoncallback %feature("python:callback") +#define %nopythoncallback %feature("python:callback","0") +#define %clearpythoncallback %feature("python:callback","") + +/* ------------------------------------------------------------------------- */ +/* + Support for the old %callback directive name +*/ +#ifdef %callback +#undef %callback +#endif + +#ifdef %nocallback +#undef %nocallback +#endif + +#ifdef %clearcallback +#undef %clearcallback +#endif + +#define %callback(x) %feature("python:callback",`x`) +#define %nocallback %nopythoncallback +#define %clearcallback %clearpythoncallback + +/* ------------------------------------------------------------------------- */ +/* + Thread support - Advance control + +*/ + +#define %nothread %feature("nothread") +#define %thread %feature("nothread","0") +#define %clearnothread %feature("nothread","") + +#define %nothreadblock %feature("nothreadblock") +#define %threadblock %feature("nothreadblock","0") +#define %clearnothreadblock %feature("nothreadblock","") + +#define %nothreadallow %feature("nothreadallow") +#define %threadallow %feature("nothreadallow","0") +#define %clearnothreadallow %feature("nothreadallow","") + + +/* ------------------------------------------------------------------------- */ +/* + Implicit Conversion using the C++ constructor mechanism +*/ + +#define %implicitconv %feature("implicitconv") +#define %noimplicitconv %feature("implicitconv", "0") +#define %clearimplicitconv %feature("implicitconv", "") + + +/* ------------------------------------------------------------------------- */ +/* + Enable keywords paramaters +*/ + +#define %kwargs %feature("kwargs") +#define %nokwargs %feature("kwargs", "0") +#define %clearkwargs %feature("kwargs", "") + +/* ------------------------------------------------------------------------- */ +/* + Add python code to the proxy/shadow code + + %pythonprepend - Add code before the C++ function is called + %pythonappend - Add code after the C++ function is called +*/ + +#define %pythonprepend %feature("pythonprepend") +#define %clearpythonprepend %feature("pythonprepend","") + +#define %pythonappend %feature("pythonappend") +#define %clearpythonappend %feature("pythonappend","") + + + +/* ------------------------------------------------------------------------- */ +/* + %extend_smart_pointer extend the smart pointer support. + + For example, if you have a smart pointer as: + + template <class Type> class RCPtr { + public: + ... + RCPtr(Type *p); + Type * operator->() const; + ... + }; + + you use the %extend_smart_pointer directive as: + + %extend_smart_pointer(RCPtr<A>); + %template(RCPtr_A) RCPtr<A>; + + then, if you have something like: + + RCPtr<A> make_ptr(); + int foo(A *); + + you can do the following: + + a = make_ptr(); + b = foo(a); + + ie, swig will accept a RCPtr<A> object where a 'A *' is + expected. + + Also, when using vectors + + %extend_smart_pointer(RCPtr<A>); + %template(RCPtr_A) RCPtr<A>; + %template(vector_A) std::vector<RCPtr<A> >; + + you can type + + a = A(); + v = vector_A(2) + v[0] = a + + ie, an 'A *' object is accepted, via implicit conversion, + where a RCPtr<A> object is expected. Additionally + + x = v[0] + + returns (and sets 'x' as) a copy of v[0], making reference + counting possible and consistent. +*/ + +%define %extend_smart_pointer(Type...) +%implicitconv Type; +%apply const SWIGTYPE& SMARTPOINTER { const Type& }; +%apply SWIGTYPE SMARTPOINTER { Type }; +%enddef diff --git a/share/swig/2.0.11/python/pywstrings.swg b/share/swig/2.0.11/python/pywstrings.swg new file mode 100644 index 0000000..864376b --- /dev/null +++ b/share/swig/2.0.11/python/pywstrings.swg @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------ + * utility methods for wchar_t strings + * ------------------------------------------------------------ */ + +%{ +#if PY_VERSION_HEX >= 0x03020000 +# define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) +#else +# define SWIGPY_UNICODE_ARG(obj) ((PyUnicodeObject*) (obj)) +#endif +%} + +%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { +SWIGINTERN int +SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) +{ + PyObject *tmp = 0; + int isunicode = PyUnicode_Check(obj); +%#if PY_VERSION_HEX < 0x03000000 + if (!isunicode && PyString_Check(obj)) { + obj = tmp = PyUnicode_FromObject(obj); + isunicode = 1; + } +%#endif + if (isunicode) { + Py_ssize_t len = PyUnicode_GetSize(obj); + if (cptr) { + *cptr = %new_array(len + 1, wchar_t); + PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len); + (*cptr)[len] = 0; + } + if (psize) *psize = (size_t) len + 1; + if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; + Py_XDECREF(tmp); + return SWIG_OK; + } else { + swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); + if (pwchar_descriptor) { + void * vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (wchar_t *)vptr; + if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { +SWIGINTERNINLINE PyObject * +SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); + return pwchar_descriptor ? + SWIG_InternalNewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void(); + } else { + return PyUnicode_FromWideChar(carray, %numeric_cast(size,int)); + } + } else { + return SWIG_Py_Void(); + } +} +} + + diff --git a/share/swig/2.0.11/python/std_alloc.i b/share/swig/2.0.11/python/std_alloc.i new file mode 100644 index 0000000..35dc051 --- /dev/null +++ b/share/swig/2.0.11/python/std_alloc.i @@ -0,0 +1 @@ +%include <std/std_alloc.i> diff --git a/share/swig/2.0.11/python/std_basic_string.i b/share/swig/2.0.11/python/std_basic_string.i new file mode 100644 index 0000000..7d3366d --- /dev/null +++ b/share/swig/2.0.11/python/std_basic_string.i @@ -0,0 +1,103 @@ +#if !defined(SWIG_STD_STRING) +#define SWIG_STD_BASIC_STRING + +%include <pycontainer.swg> + +#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) + + +%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header", + fragment="SWIG_AsCharPtrAndSize") { +SWIGINTERN int +SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val) +{ + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string<char> *"); + std::string *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + char* buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::string(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError,"a string is expected"); + SWIG_PYTHON_THREAD_END_BLOCK; + } + return 0; + } +} +} + +%fragment(SWIG_From_frag(std::basic_string<char>),"header", + fragment="SWIG_FromCharPtrAndSize") { +SWIGINTERNINLINE PyObject* + SWIG_From(std::basic_string<char>)(const std::string& s) + { + return SWIG_FromCharPtrAndSize(s.data(), s.size()); + } +} + +%include <std/std_basic_string.i> +%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>); + +#endif + + +#if !defined(SWIG_STD_WSTRING) + +%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header", + fragment="SWIG_AsWCharPtrAndSize") { +SWIGINTERN int + SWIG_AsPtr(std::basic_string<wchar_t>)(PyObject* obj, std::wstring **val) + { + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string<wchar_t> *"); + std::wstring *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::wstring(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError,"a wstring is expected"); + SWIG_PYTHON_THREAD_END_BLOCK; + } + return 0; + } + } +} + +%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header", + fragment="SWIG_FromWCharPtrAndSize") { +SWIGINTERNINLINE PyObject* + SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s) + { + return SWIG_FromWCharPtrAndSize(s.data(), s.size()); + } +} + +%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>); + +#endif diff --git a/share/swig/2.0.11/python/std_carray.i b/share/swig/2.0.11/python/std_carray.i new file mode 100644 index 0000000..680d671 --- /dev/null +++ b/share/swig/2.0.11/python/std_carray.i @@ -0,0 +1,54 @@ +%include <pycontainer.swg> + + +%fragment("StdCarrayTraits","header",fragment="StdSequenceTraits") +{ +namespace swig { + template <class T, size_t S> + struct traits_asptr<std::carray<T, S> > { + static int asptr(PyObject *obj, std::carray<T, S> **array) { + return traits_asptr_stdseq<std::carray<T, S> >::asptr(obj, array); + } + }; +} +} + +%warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[]; + +%extend std::carray { + %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", + fragment="SwigPyIterator_T", + fragment=SWIG_Traits_frag(_Type), + fragment="StdCarrayTraits") { + namespace swig { + template <> struct traits<std::carray<_Type, _Size > > { + typedef pointer_category category; + static const char* type_name() { + return "std::carray<" #_Type "," #_Size " >"; + } + }; + } + } + + %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr, + SWIG_Traits_frag(std::carray<_Type, _Size >), + std::carray<_Type, _Size >); + + %typemap(out,noblock=1) iterator, const_iterator { + $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + } + + inline size_t __len__() const { return self->size(); } + + inline const _Type& __getitem__(size_t i) const { return (*self)[i]; } + + inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } + + + swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { + return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } +} + +%include <std/std_carray.swg> diff --git a/share/swig/2.0.11/python/std_char_traits.i b/share/swig/2.0.11/python/std_char_traits.i new file mode 100644 index 0000000..bf4e6c4 --- /dev/null +++ b/share/swig/2.0.11/python/std_char_traits.i @@ -0,0 +1 @@ +%include <std/std_char_traits.i> diff --git a/share/swig/2.0.11/python/std_common.i b/share/swig/2.0.11/python/std_common.i new file mode 100644 index 0000000..401bbde --- /dev/null +++ b/share/swig/2.0.11/python/std_common.i @@ -0,0 +1,74 @@ +%include <std/std_except.i> +%include <pystdcommon.swg> + + +/* + Generate the traits for a 'primitive' type, such as 'double', + for which the SWIG_AsVal and SWIG_From methods are already defined. +*/ + +%define %traits_ptypen(Type...) + %fragment(SWIG_Traits_frag(Type),"header", + fragment=SWIG_AsVal_frag(Type), + fragment=SWIG_From_frag(Type), + fragment="StdTraits") { +namespace swig { + template <> struct traits<Type > { + typedef value_category category; + static const char* type_name() { return #Type; } + }; + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(PyObject *obj, value_type *val) { + return SWIG_AsVal(Type)(obj, val); + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static PyObject *from(const value_type& val) { + return SWIG_From(Type)(val); + } + }; +} +} +%enddef + +/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums + is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit + instantiations required using %template). The STL containers define the 'front' method and the typemap + below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the + standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from + required in the generated code for enums. */ + +%define %traits_enum(Type...) + %fragment("SWIG_Traits_enum_"{Type},"header", + fragment=SWIG_AsVal_frag(int), + fragment=SWIG_From_frag(int), + fragment="StdTraits") { +namespace swig { + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(PyObject *obj, value_type *val) { + return SWIG_AsVal(int)(obj, (int *)val); + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static PyObject *from(const value_type& val) { + return SWIG_From(int)((int)val); + } + }; +} +} +%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} +%enddef + + +%include <std/std_common.i> + +// +// Generates the traits for all the known primitive +// C++ types (int, double, ...) +// +%apply_cpptypes(%traits_ptypen); + diff --git a/share/swig/2.0.11/python/std_complex.i b/share/swig/2.0.11/python/std_complex.i new file mode 100644 index 0000000..4e8fed3 --- /dev/null +++ b/share/swig/2.0.11/python/std_complex.i @@ -0,0 +1,22 @@ +/* + * STD C++ complex typemaps + */ + +%include <pycomplex.swg> + +%{ +#include <complex> +%} + +/* defining the complex as/from converters */ + +%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag) +%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag) + +/* defining the typemaps */ + +%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>); +%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>); + + + diff --git a/share/swig/2.0.11/python/std_container.i b/share/swig/2.0.11/python/std_container.i new file mode 100644 index 0000000..d24c157 --- /dev/null +++ b/share/swig/2.0.11/python/std_container.i @@ -0,0 +1,2 @@ +%include <pycontainer.swg> +%include <std/std_container.i> diff --git a/share/swig/2.0.11/python/std_deque.i b/share/swig/2.0.11/python/std_deque.i new file mode 100644 index 0000000..b193756 --- /dev/null +++ b/share/swig/2.0.11/python/std_deque.i @@ -0,0 +1,27 @@ +/* + Deques +*/ + +%fragment("StdDequeTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::deque<T> > { + static int asptr(PyObject *obj, std::deque<T> **vec) { + return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::deque<T> > { + static PyObject *from(const std::deque<T> & vec) { + return traits_from_stdseq<std::deque<T> >::from(vec); + } + }; + } +%} + +#define %swig_deque_methods(Type...) %swig_sequence_methods(Type) +#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_deque.i> diff --git a/share/swig/2.0.11/python/std_except.i b/share/swig/2.0.11/python/std_except.i new file mode 100644 index 0000000..af98428 --- /dev/null +++ b/share/swig/2.0.11/python/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/share/swig/2.0.11/python/std_ios.i b/share/swig/2.0.11/python/std_ios.i new file mode 100644 index 0000000..aa6f099 --- /dev/null +++ b/share/swig/2.0.11/python/std_ios.i @@ -0,0 +1,3 @@ +%rename(ios_base_in) std::ios_base::in; + +%include <std/std_ios.i> diff --git a/share/swig/2.0.11/python/std_iostream.i b/share/swig/2.0.11/python/std_iostream.i new file mode 100644 index 0000000..43d6b0c --- /dev/null +++ b/share/swig/2.0.11/python/std_iostream.i @@ -0,0 +1,8 @@ +namespace std +{ +%callback(1) endl; +%callback(1) ends; +%callback(1) flush; +} + +%include <std/std_iostream.i> diff --git a/share/swig/2.0.11/python/std_list.i b/share/swig/2.0.11/python/std_list.i new file mode 100644 index 0000000..baf66d9 --- /dev/null +++ b/share/swig/2.0.11/python/std_list.i @@ -0,0 +1,28 @@ +/* + Lists +*/ + +%fragment("StdListTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T > + struct traits_asptr<std::list<T> > { + static int asptr(PyObject *obj, std::list<T> **lis) { + return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis); + } + }; + + template <class T> + struct traits_from<std::list<T> > { + static PyObject *from(const std::list<T> & vec) { + return traits_from_stdseq<std::list<T> >::from(vec); + } + }; + } +%} + +#define %swig_list_methods(Type...) %swig_sequence_methods(Type) +#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_list.i> + diff --git a/share/swig/2.0.11/python/std_map.i b/share/swig/2.0.11/python/std_map.i new file mode 100644 index 0000000..66ed68d --- /dev/null +++ b/share/swig/2.0.11/python/std_map.i @@ -0,0 +1,309 @@ +/* + Maps +*/ + +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template <class ValueType> + struct from_key_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.first); + } + }; + + template <class ValueType> + struct from_value_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.second); + } + }; + + template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type> + struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> + { + SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq) + { + } + }; + + + template<class OutIterator, + class FromOper = from_key_oper<typename OutIterator::value_type> > + struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper> + { + SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq) + { + } + }; + + template<typename OutIter> + inline SwigPyIterator* + make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq); + } + + template<class OutIterator, + class FromOper = from_value_oper<typename OutIterator::value_type> > + struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper> + { + SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq) + { + } + }; + + + template<typename OutIter> + inline SwigPyIterator* + make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq); + } + } +} + +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") +{ + namespace swig { + template <class SwigPySeq, class K, class T, class Compare, class Alloc > + inline void + assign(const SwigPySeq& swigpyseq, std::map<K,T,Compare,Alloc > *map) { + typedef typename std::map<K,T,Compare,Alloc >::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template <class K, class T, class Compare, class Alloc> + struct traits_asptr<std::map<K,T,Compare,Alloc > > { + typedef std::map<K,T,Compare,Alloc > map_type; + static int asptr(PyObject *obj, map_type **val) { + int res = SWIG_ERROR; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (PyDict_Check(obj)) { + SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); +%#if PY_VERSION_HEX >= 0x03000000 + /* In Python 3.x the ".items()" method returns a dict_items object */ + items = PySequence_Fast(items, ".items() didn't return a sequence!"); +%#endif + res = traits_asptr_stdseq<map_type, std::pair<K, T> >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + SWIG_PYTHON_THREAD_END_BLOCK; + return res; + } + }; + + template <class K, class T, class Compare, class Alloc > + struct traits_from<std::map<K,T,Compare,Alloc > > { + typedef std::map<K,T,Compare,Alloc > map_type; + typedef typename map_type::const_iterator const_iterator; + typedef typename map_type::size_type size_type; + + static PyObject *asdict(const map_type& map) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + size_type size = map.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + SWIG_PYTHON_THREAD_END_BLOCK; + return obj; + } + + static PyObject *from(const map_type& map) { + swig_type_info *desc = swig::type_info<map_type>(); + if (desc && desc->clientdata) { + return SWIG_InternalNewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + return asdict(map); + } + } + }; + } +} + +%define %swig_map_common(Map...) + %swig_sequence_iterator(Map); + %swig_container_methods(Map) + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_length", functype="lenfunc") __len__; + %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; + %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; + + %extend { + %newobject iterkeys(PyObject **PYTHON_SELF); + swig::SwigPyIterator* iterkeys(PyObject **PYTHON_SELF) { + return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %newobject itervalues(PyObject **PYTHON_SELF); + swig::SwigPyIterator* itervalues(PyObject **PYTHON_SELF) { + return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %newobject iteritems(PyObject **PYTHON_SELF); + swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) { + return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + } + +#else + %extend { + %pythoncode {def __iter__(self): return self.key_iterator()} + %pythoncode {def iterkeys(self): return self.key_iterator()} + %pythoncode {def itervalues(self): return self.value_iterator()} + %pythoncode {def iteritems(self): return self.iterator()} + } +#endif + + %extend { + mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) { + Map::const_iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + + void __delitem__(const key_type& key) throw (std::out_of_range) { + Map::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + + bool has_key(const key_type& key) const { + Map::const_iterator i = self->find(key); + return i != self->end(); + } + + PyObject* keys() { + Map::size_type size = self->size(); + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (pysize < 0) { + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject* keyList = PyList_New(pysize); + Map::const_iterator i = self->begin(); + for (int j = 0; j < pysize; ++i, ++j) { + PyList_SET_ITEM(keyList, j, swig::from(i->first)); + } + SWIG_PYTHON_THREAD_END_BLOCK; + return keyList; + } + + PyObject* values() { + Map::size_type size = self->size(); + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (pysize < 0) { + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject* valList = PyList_New(pysize); + Map::const_iterator i = self->begin(); + for (int j = 0; j < pysize; ++i, ++j) { + PyList_SET_ITEM(valList, j, swig::from(i->second)); + } + SWIG_PYTHON_THREAD_END_BLOCK; + return valList; + } + + PyObject* items() { + Map::size_type size = self->size(); + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (pysize < 0) { + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject* itemList = PyList_New(pysize); + Map::const_iterator i = self->begin(); + for (int j = 0; j < pysize; ++i, ++j) { + PyList_SET_ITEM(itemList, j, swig::from(*i)); + } + SWIG_PYTHON_THREAD_END_BLOCK; + return itemList; + } + + // Python 2.2 methods + bool __contains__(const key_type& key) { + return self->find(key) != self->end(); + } + + %newobject key_iterator(PyObject **PYTHON_SELF); + swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { + return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %newobject value_iterator(PyObject **PYTHON_SELF); + swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { + return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + } + +%enddef + +%define %swig_map_methods(Map...) + %swig_map_common(Map) + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; +#endif + + %extend { + // This will be called through the mp_ass_subscript slot to delete an entry. + void __setitem__(const key_type& key) { + self->erase(key); + } + + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + (*self)[key] = x; + } + + PyObject* asdict() { + return swig::traits_from< Map >::asdict(*self); + } + } + + +%enddef + + +%include <std/std_map.i> diff --git a/share/swig/2.0.11/python/std_multimap.i b/share/swig/2.0.11/python/std_multimap.i new file mode 100644 index 0000000..c81e2ac --- /dev/null +++ b/share/swig/2.0.11/python/std_multimap.i @@ -0,0 +1,79 @@ +/* + Multimaps +*/ +%include <std_map.i> + +%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") +{ + namespace swig { + template <class SwigPySeq, class K, class T > + inline void + assign(const SwigPySeq& swigpyseq, std::multimap<K,T > *multimap) { + typedef typename std::multimap<K,T>::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { + multimap->insert(value_type(it->first, it->second)); + } + } + + template <class K, class T> + struct traits_asptr<std::multimap<K,T> > { + typedef std::multimap<K,T> multimap_type; + static int asptr(PyObject *obj, std::multimap<K,T> **val) { + int res = SWIG_ERROR; + if (PyDict_Check(obj)) { + SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); + return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val); + } else { + multimap_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template <class K, class T > + struct traits_from<std::multimap<K,T> > { + typedef std::multimap<K,T> multimap_type; + typedef typename multimap_type::const_iterator const_iterator; + typedef typename multimap_type::size_type size_type; + + static PyObject *from(const multimap_type& multimap) { + swig_type_info *desc = swig::type_info<multimap_type>(); + if (desc && desc->clientdata) { + return SWIG_InternalNewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); + } else { + size_type size = multimap.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "multimap size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + return obj; + } + } + }; + } +} + +%define %swig_multimap_methods(Type...) + %swig_map_common(Type); + %extend { + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + self->insert(Type::value_type(key,x)); + } + } +%enddef + +%include <std/std_multimap.i> + diff --git a/share/swig/2.0.11/python/std_multiset.i b/share/swig/2.0.11/python/std_multiset.i new file mode 100644 index 0000000..ac43033 --- /dev/null +++ b/share/swig/2.0.11/python/std_multiset.i @@ -0,0 +1,41 @@ +/* + Multisets +*/ + +%include <std_set.i> + +%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class SwigPySeq, class T> + inline void + assign(const SwigPySeq& swigpyseq, std::multiset<T>* seq) { + // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented + typedef typename SwigPySeq::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } + } + + template <class T> + struct traits_asptr<std::multiset<T> > { + static int asptr(PyObject *obj, std::multiset<T> **m) { + return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, m); + } + }; + + template <class T> + struct traits_from<std::multiset<T> > { + static PyObject *from(const std::multiset<T>& vec) { + return traits_from_stdseq<std::multiset<T> >::from(vec); + } + }; + } +%} + +#define %swig_multiset_methods(Set...) %swig_set_methods(Set) + + + +%include <std/std_multiset.i> diff --git a/share/swig/2.0.11/python/std_pair.i b/share/swig/2.0.11/python/std_pair.i new file mode 100644 index 0000000..7829695 --- /dev/null +++ b/share/swig/2.0.11/python/std_pair.i @@ -0,0 +1,196 @@ +/* + Pairs +*/ +%include <pystdcommon.swg> + +//#define SWIG_STD_PAIR_ASVAL + +%fragment("StdPairTraits","header",fragment="StdTraits") { + namespace swig { +#ifdef SWIG_STD_PAIR_ASVAL + template <class T, class U > + struct traits_asval<std::pair<T,U> > { + typedef std::pair<T,U> value_type; + + static int get_pair(PyObject* first, PyObject* second, + std::pair<T,U> *val) + { + if (val) { + T *pfirst = &(val->first); + int res1 = swig::asval((PyObject*)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = &(val->second); + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } else { + T *pfirst = 0; + int res1 = swig::asval((PyObject*)first, 0); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = 0; + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } + } + + static int asval(PyObject *obj, std::pair<T,U> *val) { + int res = SWIG_ERROR; + if (PyTuple_Check(obj)) { + if (PyTuple_GET_SIZE(obj) == 2) { + res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); + } + } else if (PySequence_Check(obj)) { + if (PySequence_Size(obj) == 2) { + swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); + swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); + res = get_pair(first, second, val); + } + } else { + value_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0); + if (SWIG_IsOK(res) && val) *val = *p; + } + return res; + } + }; + +#else + template <class T, class U > + struct traits_asptr<std::pair<T,U> > { + typedef std::pair<T,U> value_type; + + static int get_pair(PyObject* first, PyObject* second, + std::pair<T,U> **val) + { + if (val) { + value_type *vp = %new_instance(std::pair<T,U>); + T *pfirst = &(vp->first); + int res1 = swig::asval((PyObject*)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = &(vp->second); + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + *val = vp; + return SWIG_AddNewMask(res1 > res2 ? res1 : res2); + } else { + T *pfirst = 0; + int res1 = swig::asval((PyObject*)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = 0; + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } + } + + static int asptr(PyObject *obj, std::pair<T,U> **val) { + int res = SWIG_ERROR; + if (PyTuple_Check(obj)) { + if (PyTuple_GET_SIZE(obj) == 2) { + res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); + } + } else if (PySequence_Check(obj)) { + if (PySequence_Size(obj) == 2) { + swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); + swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); + res = get_pair(first, second, val); + } + } else { + value_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + +#endif + template <class T, class U > + struct traits_from<std::pair<T,U> > { + static PyObject *from(const std::pair<T,U>& val) { + PyObject* obj = PyTuple_New(2); + PyTuple_SetItem(obj,0,swig::from(val.first)); + PyTuple_SetItem(obj,1,swig::from(val.second)); + return obj; + } + }; + } + +#if defined(SWIGPYTHON_BUILTIN) +SWIGINTERN Py_ssize_t +SwigPython_std_pair_len (PyObject *a) +{ + return 2; +} + +SWIGINTERN PyObject* +SwigPython_std_pair_repr (PyObject *o) +{ + PyObject *tuple = PyTuple_New(2); + assert(tuple); + PyTuple_SET_ITEM(tuple, 0, PyObject_GetAttrString(o, (char*) "first")); + PyTuple_SET_ITEM(tuple, 1, PyObject_GetAttrString(o, (char*) "second")); + PyObject *result = PyObject_Repr(tuple); + Py_DECREF(tuple); + return result; +} + +SWIGINTERN PyObject* +SwigPython_std_pair_getitem (PyObject *a, Py_ssize_t b) +{ + PyObject *result = PyObject_GetAttrString(a, b % 2 ? (char*) "second" : (char*) "first"); + return result; +} + +SWIGINTERN int +SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c) +{ + int result = PyObject_SetAttrString(a, b % 2 ? (char*) "second" : (char*) "first", c); + return result; +} +#endif + +} + +%feature("python:sq_length") std::pair "SwigPython_std_pair_len"; +%feature("python:sq_length") std::pair<T*,U> "SwigPython_std_pair_len"; +%feature("python:sq_length") std::pair<T,U*> "SwigPython_std_pair_len"; +%feature("python:sq_length") std::pair<T*,U*> "SwigPython_std_pair_len"; + +%feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; +%feature("python:tp_repr") std::pair<T*,U> "SwigPython_std_pair_repr"; +%feature("python:tp_repr") std::pair<T,U*> "SwigPython_std_pair_repr"; +%feature("python:tp_repr") std::pair<T*,U*> "SwigPython_std_pair_repr"; + +%feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; +%feature("python:sq_item") std::pair<T*,U> "SwigPython_std_pair_getitem"; +%feature("python:sq_item") std::pair<T,U*> "SwigPython_std_pair_getitem"; +%feature("python:sq_item") std::pair<T*,U*> "SwigPython_std_pair_getitem"; + +%feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; +%feature("python:sq_ass_item") std::pair<T*,U> "SwigPython_std_pair_setitem"; +%feature("python:sq_ass_item") std::pair<T,U*> "SwigPython_std_pair_setitem"; +%feature("python:sq_ass_item") std::pair<T*,U*> "SwigPython_std_pair_setitem"; + +%define %swig_pair_methods(pair...) +#if !defined(SWIGPYTHON_BUILTIN) +%extend { +%pythoncode {def __len__(self): return 2 +def __repr__(self): return str((self.first, self.second)) +def __getitem__(self, index): + if not (index % 2): + return self.first + else: + return self.second +def __setitem__(self, index, val): + if not (index % 2): + self.first = val + else: + self.second = val} +} +#endif +%enddef + +%include <std/std_pair.i> + diff --git a/share/swig/2.0.11/python/std_set.i b/share/swig/2.0.11/python/std_set.i new file mode 100644 index 0000000..53f97e4 --- /dev/null +++ b/share/swig/2.0.11/python/std_set.i @@ -0,0 +1,63 @@ +/* + Sets +*/ + +%fragment("StdSetTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class SwigPySeq, class T> + inline void + assign(const SwigPySeq& swigpyseq, std::set<T>* seq) { + // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented + typedef typename SwigPySeq::value_type value_type; + typename SwigPySeq::const_iterator it = swigpyseq.begin(); + for (;it != swigpyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } + } + + template <class T> + struct traits_asptr<std::set<T> > { + static int asptr(PyObject *obj, std::set<T> **s) { + return traits_asptr_stdseq<std::set<T> >::asptr(obj, s); + } + }; + + template <class T> + struct traits_from<std::set<T> > { + static PyObject *from(const std::set<T>& vec) { + return traits_from_stdseq<std::set<T> >::from(vec); + } + }; + } +%} + +%define %swig_set_methods(set...) + %swig_sequence_iterator(set); + %swig_container_methods(set); + + %extend { + void append(value_type x) { + self->insert(x); + } + + bool __contains__(value_type x) { + return self->find(x) != self->end(); + } + + value_type __getitem__(difference_type i) const throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void add(value_type x) { + self->insert(x); + } + + void discard(value_type x) { + self->erase(x); + } + + }; +%enddef + +%include <std/std_set.i> diff --git a/share/swig/2.0.11/python/std_shared_ptr.i b/share/swig/2.0.11/python/std_shared_ptr.i new file mode 100644 index 0000000..df87367 --- /dev/null +++ b/share/swig/2.0.11/python/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include <boost_shared_ptr.i> diff --git a/share/swig/2.0.11/python/std_sstream.i b/share/swig/2.0.11/python/std_sstream.i new file mode 100644 index 0000000..6647df8 --- /dev/null +++ b/share/swig/2.0.11/python/std_sstream.i @@ -0,0 +1 @@ +%include <std/std_sstream.i> diff --git a/share/swig/2.0.11/python/std_streambuf.i b/share/swig/2.0.11/python/std_streambuf.i new file mode 100644 index 0000000..44b9bb4 --- /dev/null +++ b/share/swig/2.0.11/python/std_streambuf.i @@ -0,0 +1 @@ +%include <std/std_streambuf.i> diff --git a/share/swig/2.0.11/python/std_string.i b/share/swig/2.0.11/python/std_string.i new file mode 100644 index 0000000..dc1378a --- /dev/null +++ b/share/swig/2.0.11/python/std_string.i @@ -0,0 +1 @@ +%include <typemaps/std_string.swg> diff --git a/share/swig/2.0.11/python/std_vector.i b/share/swig/2.0.11/python/std_vector.i new file mode 100644 index 0000000..3f04a30 --- /dev/null +++ b/share/swig/2.0.11/python/std_vector.i @@ -0,0 +1,27 @@ +/* + Vectors +*/ + +%fragment("StdVectorTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::vector<T> > { + static int asptr(PyObject *obj, std::vector<T> **vec) { + return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::vector<T> > { + static PyObject *from(const std::vector<T>& vec) { + return traits_from_stdseq<std::vector<T> >::from(vec); + } + }; + } +%} + +#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) +#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_vector.i> diff --git a/share/swig/2.0.11/python/std_vectora.i b/share/swig/2.0.11/python/std_vectora.i new file mode 100644 index 0000000..3f084bd --- /dev/null +++ b/share/swig/2.0.11/python/std_vectora.i @@ -0,0 +1,31 @@ +/* + Vectors + allocators +*/ + +%fragment("StdVectorATraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T, class A> + struct traits_asptr<std::vector<T,A> > { + typedef std::vector<T,A> vector_type; + typedef T value_type; + static int asptr(PyObject *obj, vector_type **vec) { + return traits_asptr_stdseq<vector_type>::asptr(obj, vec); + } + }; + + template <class T, class A> + struct traits_from<std::vector<T,A> > { + typedef std::vector<T,A> vector_type; + static PyObject *from(const vector_type& vec) { + return traits_from_stdseq<vector_type>::from(vec); + } + }; + } +%} + + +#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) +#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_vectora.i> diff --git a/share/swig/2.0.11/python/std_wios.i b/share/swig/2.0.11/python/std_wios.i new file mode 100644 index 0000000..930a57d --- /dev/null +++ b/share/swig/2.0.11/python/std_wios.i @@ -0,0 +1 @@ +%include <std/std_wios.i> diff --git a/share/swig/2.0.11/python/std_wiostream.i b/share/swig/2.0.11/python/std_wiostream.i new file mode 100644 index 0000000..d3a5ee7 --- /dev/null +++ b/share/swig/2.0.11/python/std_wiostream.i @@ -0,0 +1,10 @@ +namespace std +{ +%callback(1) wendl; +%callback(1) wends; +%callback(1) wflush; +} + +%include <std_basic_string.i> +%include <std_wstring.i> +%include <std/std_wiostream.i> diff --git a/share/swig/2.0.11/python/std_wsstream.i b/share/swig/2.0.11/python/std_wsstream.i new file mode 100644 index 0000000..8843f56 --- /dev/null +++ b/share/swig/2.0.11/python/std_wsstream.i @@ -0,0 +1 @@ +%include <std/std_wsstream.i> diff --git a/share/swig/2.0.11/python/std_wstreambuf.i b/share/swig/2.0.11/python/std_wstreambuf.i new file mode 100644 index 0000000..c0f0920 --- /dev/null +++ b/share/swig/2.0.11/python/std_wstreambuf.i @@ -0,0 +1 @@ +%include <std/std_wstreambuf.i> diff --git a/share/swig/2.0.11/python/std_wstring.i b/share/swig/2.0.11/python/std_wstring.i new file mode 100644 index 0000000..ef86281 --- /dev/null +++ b/share/swig/2.0.11/python/std_wstring.i @@ -0,0 +1,3 @@ +%include <pywstrings.swg> +%include <typemaps/std_wstring.swg> + diff --git a/share/swig/2.0.11/python/stl.i b/share/swig/2.0.11/python/stl.i new file mode 100644 index 0000000..a3566db --- /dev/null +++ b/share/swig/2.0.11/python/stl.i @@ -0,0 +1,7 @@ +/* initial STL definition. extended as needed in each language */ +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/share/swig/2.0.11/python/typemaps.i b/share/swig/2.0.11/python/typemaps.i new file mode 100644 index 0000000..5d438ec --- /dev/null +++ b/share/swig/2.0.11/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).K: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Python output of the function would be a tuple containing both +output values. + +*/ + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Python tuple. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + void neg(double *INOUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value (since +this makes no sense in Python). Rather, the modified input value shows +up as the return value of the function. Thus, to apply this function +to a Python variable you might do this : + + x = neg(x) + +Note : previous versions of SWIG used the symbol 'BOTH' to mark +input/output arguments. This is still supported, but will be slowly +phased out in future releases. + +*/ + +%include <typemaps/typemaps.swg> diff --git a/share/swig/2.0.11/python/wchar.i b/share/swig/2.0.11/python/wchar.i new file mode 100644 index 0000000..308139a --- /dev/null +++ b/share/swig/2.0.11/python/wchar.i @@ -0,0 +1,21 @@ +#ifdef __cplusplus + +%{ +#include <cwchar> +%} + +#else + +%{ +#include <wchar.h> +%} + +#endif + +%types(wchar_t *); +%include <pywstrings.swg> + +/* + Enable swig wchar support. +*/ +#define SWIG_WCHAR |