Merge branch 'master' into doxygen

The way Python docstrings are indented has changed on master, so use the
standard inspect module in Python autodoc unit test to ignore the differences
in their indentation level between -builtin and non-builtin cases to make the
test still pass with the branch version, which avoids the use of different
(but almost identical) values in the test itself.
This commit is contained in:
Vadim Zeitlin 2016-12-05 02:14:51 +01:00
commit e668c47b70
1094 changed files with 39390 additions and 11483 deletions

View file

@ -15,7 +15,6 @@ complex.i C99 or C++ complex type
cstring.i Various forms of C character string handling
cwstring.i Various forms of C wchar_t string handling
embed.i embedding the Python interpreter in something else
embed15.i embedding the Python interpreter in something else
file.i FILE C type
implicit.i Allow the use of implicit C++ constructors
wchar.i wchar_t C type

View file

@ -51,7 +51,7 @@
%variable_fail(res, "$type", "$name");
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
%variable_nullref("$type", "$name");
} 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 > *);
@ -137,7 +137,9 @@
%variable_fail(res, "$type", "$name");
}
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
if (!argp) {
%variable_nullref("$type", "$name");
}
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 > *);

View file

@ -1,211 +1,29 @@
#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; \
Py_XDECREF(sobj->dict); \
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 Py_hash_t
SwigPyObject_hash(PyObject *obj) {
SwigPyObject *sobj = (SwigPyObject *)obj;
void *ptr = sobj->ptr;
return (Py_hash_t)ptr;
}
SWIGINTERN Py_hash_t
SWIG_PyNumber_AsPyHash(PyObject *obj) {
Py_hash_t result = -1;
#if PY_VERSION_HEX < 0x03020000
if (PyLong_Check(obj))
result = PyLong_AsLong(obj);
#else
if (PyNumber_Check(obj))
result = PyNumber_AsSsize_t(obj, NULL);
#endif
else
PyErr_Format(PyExc_TypeError, "Wrong type for hash function");
return result;
}
SWIGINTERN int
SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) {
PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name);
@ -213,11 +31,10 @@ SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *
}
SWIGINTERN void
SwigPyBuiltin_BadDealloc(PyObject *pyobj) {
SwigPyObject *sobj;
sobj = (SwigPyObject *)pyobj;
SwigPyBuiltin_BadDealloc(PyObject *obj) {
SwigPyObject *sobj = (SwigPyObject *)obj;
if (sobj->own) {
PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name);
PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name);
}
}
@ -347,9 +164,13 @@ SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
}
SWIGINTERN int
SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) {
SwigPyObjectType_setattro(PyObject *typeobject, PyObject *name, PyObject *value) {
PyObject *attribute;
PyTypeObject *type;
descrsetfunc local_set;
assert(PyType_Check(typeobject));
type = (PyTypeObject *)typeobject;
attribute = _PyType_Lookup(type, name);
if (attribute != NULL) {
/* Implement descriptor functionality, if any */
@ -378,16 +199,15 @@ SwigPyStaticVar_Type(void) {
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,
0, /* ob_size */
#endif
"swig_static_var_getset_descriptor",
sizeof(PyGetSetDescrObject),
0,
"swig_static_var_getset_descriptor", /* tp_name */
sizeof(PyGetSetDescrObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
@ -433,10 +253,19 @@ SwigPyStaticVar_Type(void) {
0, /* tp_del */
#endif
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version */
0, /* tp_version_tag */
#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#ifdef COUNT_ALLOCS
0,0,0,0 /* tp_alloc -> tp_next */
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
#endif
0 /* tp_next */
#endif
};
staticvar_type = tmp;
@ -451,6 +280,95 @@ SwigPyStaticVar_Type(void) {
return &staticvar_type;
}
SWIGINTERN PyTypeObject*
SwigPyObjectType(void) {
static char swigpyobjecttype_doc[] = "Metaclass for SWIG wrapped types";
static PyTypeObject swigpyobjecttype_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#else
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
#endif
"SwigPyObjectType", /* tp_name */
PyType_Type.tp_basicsize, /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
SwigPyObjectType_setattro, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */
swigpyobjecttype_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
#if PY_VERSION_HEX >= 0x02030000
0, /* tp_del */
#endif
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
#endif
0 /* tp_next */
#endif
};
swigpyobjecttype_type = tmp;
type_init = 1;
swigpyobjecttype_type.tp_base = &PyType_Type;
#if PY_VERSION_HEX < 0x02020000
swigpyobjecttype_type.ob_type = &PyType_Type;
#else
if (PyType_Ready(&swigpyobjecttype_type) < 0)
return NULL;
#endif
}
return &swigpyobjecttype_type;
}
SWIGINTERN PyGetSetDescrObject *
SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
@ -509,6 +427,295 @@ SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype)
#endif
}
/* Start of callback function macros for use in PyTypeObject */
typedef PyObject *(*SwigPyWrapperFunction)(PyObject *, PyObject *);
#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_unaryfunc_closure(PyObject *a) { \
return SwigPyBuiltin_unaryfunc_closure(wrapper, a); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_unaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \
SWIGINTERN void \
wrapper##_destructor_closure(PyObject *a) { \
SwigPyBuiltin_destructor_closure(wrapper, #wrapper, a); \
}
SWIGINTERN void
SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrappername, PyObject *a) {
SwigPyObject *sobj;
sobj = (SwigPyObject *)a;
Py_XDECREF(sobj->dict);
if (sobj->own) {
PyObject *o;
PyObject *val = 0, *type = 0, *tb = 0;
PyErr_Fetch(&val, &type, &tb);
o = wrapper(a, NULL);
if (!o) {
PyObject *deallocname = PyString_FromString(wrappername);
PyErr_WriteUnraisable(deallocname);
Py_DECREF(deallocname);
}
PyErr_Restore(val, type, tb);
Py_XDECREF(o);
}
if (PyType_IS_GC(a->ob_type)) {
PyObject_GC_Del(a);
} else {
PyObject_Del(a);
}
}
#define SWIGPY_INQUIRY_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_inquiry_closure(PyObject *a) { \
return SwigPyBuiltin_inquiry_closure(wrapper, a); \
}
SWIGINTERN int
SwigPyBuiltin_inquiry_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
PyObject *pyresult;
int result;
pyresult = wrapper(a, NULL);
result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0;
Py_XDECREF(pyresult);
return result;
}
#define SWIGPY_GETITERFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_getiterfunc_closure(PyObject *a) { \
return SwigPyBuiltin_getiterfunc_closure(wrapper, a); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_getiterfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_binaryfunc_closure(PyObject *a, PyObject *b) { \
return SwigPyBuiltin_binaryfunc_closure(wrapper, a, b); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) {
PyObject *tuple, *result;
tuple = PyTuple_New(1);
assert(tuple);
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##_ternaryfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \
return SwigPyBuiltin_ternaryfunc_closure(wrapper, a, b, c); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
PyObject *tuple, *result;
tuple = PyTuple_New(2);
assert(tuple);
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##_ternarycallfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \
return SwigPyBuiltin_ternarycallfunc_closure(wrapper, a, b, c); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ternarycallfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
(void) c;
return wrapper(a, b);
}
#define SWIGPY_LENFUNC_CLOSURE(wrapper) \
SWIGINTERN Py_ssize_t \
wrapper##_lenfunc_closure(PyObject *a) { \
return SwigPyBuiltin_lenfunc_closure(wrapper, a); \
}
SWIGINTERN Py_ssize_t
SwigPyBuiltin_lenfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
PyObject *resultobj;
Py_ssize_t result;
resultobj = wrapper(a, NULL);
result = PyNumber_AsSsize_t(resultobj, NULL);
Py_DECREF(resultobj);
return result;
}
#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ssizessizeargfunc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \
return SwigPyBuiltin_ssizessizeargfunc_closure(wrapper, a, b, c); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ssizessizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c) {
PyObject *tuple, *result;
tuple = PyTuple_New(2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));
result = wrapper(a, tuple);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_ssizessizeobjargproc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \
return SwigPyBuiltin_ssizessizeobjargproc_closure(wrapper, a, b, c, d); \
}
SWIGINTERN int
SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) {
PyObject *tuple, *resultobj;
int result;
tuple = PyTuple_New(d ? 3 : 2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));
if (d) {
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##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \
return SwigPyBuiltin_funpack_ssizeargfunc_closure(wrapper, a, b); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_funpack_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) {
PyObject *tuple, *result;
tuple = PyTuple_New(1);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
result = wrapper(a, tuple);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \
return SwigPyBuiltin_ssizeargfunc_closure(wrapper, a, b); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) {
PyObject *arg, *result;
arg = _PyLong_FromSsize_t(b);
result = wrapper(a, arg);
Py_DECREF(arg);
return result;
}
#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_ssizeobjargproc_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \
return SwigPyBuiltin_ssizeobjargproc_closure(wrapper, a, b, c); \
}
SWIGINTERN int
SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, PyObject *c) {
PyObject *tuple, *resultobj;
int result;
tuple = PyTuple_New(2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
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##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \
return SwigPyBuiltin_objobjargproc_closure(wrapper, a, b, c); \
}
SWIGINTERN int
SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
PyObject *tuple, *resultobj;
int result;
tuple = PyTuple_New(c ? 2 : 1);
assert(tuple);
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##_reprfunc_closure(PyObject *a) { \
return SwigPyBuiltin_reprfunc_closure(wrapper, a); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_reprfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \
SWIGINTERN Py_hash_t \
wrapper##_hashfunc_closure(PyObject *a) { \
return SwigPyBuiltin_hashfunc_closure(wrapper, a); \
}
SWIGINTERN Py_hash_t
SwigPyBuiltin_hashfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
PyObject *pyresult;
Py_hash_t result;
pyresult = wrapper(a, NULL);
if (!pyresult)
return -1;
result = SWIG_PyNumber_AsPyHash(pyresult);
Py_DECREF(pyresult);
return result;
}
#define SWIGPY_ITERNEXTFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_iternextfunc_closure(PyObject *a) { \
return SwigPyBuiltin_iternextfunc_closure(wrapper, a);\
}
SWIGINTERN PyObject *
SwigPyBuiltin_iternextfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
/* End of callback function macros for use in PyTypeObject */
#ifdef __cplusplus
}
#endif

View file

@ -1,8 +1,8 @@
//
// 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 is deprecated and no longer actively maintained, but it still
// seems to work with Python 2.7. Status with Python 3 is unknown.
//
// This file makes it possible to extend Python and all of its
// built-in functions without having to hack its setup script.
@ -24,13 +24,8 @@ 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.
As far as I know, this module is C++ safe.
%}
#else
%echo "embed.i : Using Python 1.5"
#endif
%wrapper %{
@ -51,12 +46,12 @@ extern "C" {
#endif
#include <config.c>
#undef _PyImport_Inittab
#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];
struct _inittab SWIG_Import_Inittab[1000];
static int swig_num_modules = 0;
@ -68,18 +63,18 @@ static void swig_add_module(char *name, void (*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 */
/* Function to add all of Python's built-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++;
}
i++;
}
#ifdef SWIGMODINIT
SWIGMODINIT
SWIGMODINIT
#endif
/* Add SWIG builtin function */
swig_add_module(SWIG_name, SWIG_init);
@ -109,7 +104,3 @@ main(int argc, char **argv) {
}
%}

View file

@ -1,115 +0,0 @@
/* -----------------------------------------------------------------------------
* 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);
}
%}

View file

@ -4,7 +4,7 @@
the complex Constructor method, and the Real and Imag complex
accessor methods.
See the std_complex.i and ccomplex.i for concret examples.
See the std_complex.i and ccomplex.i for concrete examples.
*/
/* the common from converter */

View file

@ -206,7 +206,7 @@ namespace swig {
if (step == 0) {
throw std::invalid_argument("slice step cannot be zero");
} else if (step > 0) {
// Required range: 0 <= i < size, 0 <= j < size
// Required range: 0 <= i < size, 0 <= j < size, i <= j
if (i < 0) {
ii = 0;
} else if (i < (Difference)size) {
@ -214,13 +214,15 @@ namespace swig {
} else if (insert && (i >= (Difference)size)) {
ii = (Difference)size;
}
if ( j < 0 ) {
if (j < 0) {
jj = 0;
} else {
jj = (j < (Difference)size) ? j : (Difference)size;
}
if (jj < ii)
jj = ii;
} else {
// Required range: -1 <= i < size-1, -1 <= j < size-1
// Required range: -1 <= i < size-1, -1 <= j < size-1, i >= j
if (i < -1) {
ii = -1;
} else if (i < (Difference) size) {
@ -233,6 +235,8 @@ namespace swig {
} else {
jj = (j < (Difference)size ) ? j : (Difference)(size-1);
}
if (ii < jj)
ii = jj;
}
}
@ -252,6 +256,19 @@ namespace swig {
return pos;
}
template <class Sequence>
inline void
erase(Sequence* seq, const typename Sequence::iterator& position) {
seq->erase(position);
}
template <class Sequence>
struct traits_reserve {
static void reserve(Sequence & /*seq*/, typename Sequence::size_type /*n*/) {
// This should be specialized for types that support reserve
}
};
template <class Sequence, class Difference>
inline Sequence*
getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
@ -269,6 +286,7 @@ namespace swig {
return new Sequence(sb, se);
} else {
Sequence *sequence = new Sequence();
swig::traits_reserve<Sequence>::reserve(*sequence, (jj - ii + step - 1) / step);
typename Sequence::const_iterator it = sb;
while (it!=se) {
sequence->push_back(*it);
@ -279,17 +297,16 @@ namespace swig {
}
} 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++;
}
swig::traits_reserve<Sequence>::reserve(*sequence, (ii - jj - step - 1) / -step);
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;
}
@ -303,12 +320,11 @@ namespace swig {
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
swig::traits_reserve<Sequence>::reserve(*self, self->size() - ssize + is.size());
typename Sequence::iterator sb = self->begin();
typename InputSeq::const_iterator isit = is.begin();
std::advance(sb,ii);
@ -342,8 +358,6 @@ namespace swig {
}
}
} else {
if (jj > ii)
jj = ii;
size_t replacecount = (ii - jj - step - 1) / -step;
if (is.size() != replacecount) {
char msg[1024];
@ -369,37 +383,33 @@ namespace swig {
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;
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 = typename Sequence::reverse_iterator(self->erase((++it).base()));
for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
it = self->erase(it);
for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
delcount--;
}
}
} else {
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--;
}
}
}
}
@ -415,7 +425,7 @@ namespace swig
template <class T>
struct SwigPySequence_Ref
{
SwigPySequence_Ref(PyObject* seq, int index)
SwigPySequence_Ref(PyObject* seq, Py_ssize_t index)
: _seq(seq), _index(index)
{
}
@ -427,7 +437,7 @@ namespace swig
return swig::as<T>(item, true);
} catch (std::exception& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", _index);
sprintf(msg, "in sequence element %d ", (int)_index);
if (!PyErr_Occurred()) {
::%type_error(swig::type_name<T>());
}
@ -445,7 +455,7 @@ namespace swig
private:
PyObject* _seq;
int _index;
Py_ssize_t _index;
};
template <class T>
@ -466,13 +476,13 @@ namespace swig
typedef Reference reference;
typedef T value_type;
typedef T* pointer;
typedef int difference_type;
typedef Py_ssize_t difference_type;
SwigPySequence_InputIterator()
{
}
SwigPySequence_InputIterator(PyObject* seq, int index)
SwigPySequence_InputIterator(PyObject* seq, Py_ssize_t index)
: _seq(seq), _index(index)
{
}
@ -552,6 +562,7 @@ namespace swig
difference_type _index;
};
// STL container wrapper around a Python sequence
template <class T>
struct SwigPySequence_Cont
{
@ -559,8 +570,8 @@ namespace swig
typedef const SwigPySequence_Ref<T> const_reference;
typedef T value_type;
typedef T* pointer;
typedef int difference_type;
typedef int size_type;
typedef Py_ssize_t difference_type;
typedef size_t size_type;
typedef const pointer const_pointer;
typedef SwigPySequence_InputIterator<T, reference> iterator;
typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
@ -621,13 +632,13 @@ namespace swig
bool check(bool set_err = true) const
{
int s = size();
for (int i = 0; i < s; ++i) {
Py_ssize_t s = size();
for (Py_ssize_t 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);
sprintf(msg, "in sequence element %d", (int)i);
SWIG_Error(SWIG_RuntimeError, msg);
}
return false;
@ -748,7 +759,6 @@ namespace swig
return self->size();
}
}
%enddef
@ -756,7 +766,7 @@ namespace swig
%define %swig_sequence_methods_common(Sequence...)
%swig_sequence_iterator(%arg(Sequence))
%swig_container_methods(%arg(Sequence))
%fragment("SwigPySequence_Base");
#if defined(SWIGPYTHON_BUILTIN)
@ -769,14 +779,6 @@ namespace swig
#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)) {
@ -794,7 +796,11 @@ namespace swig
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) {
void __setslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) {
swig::setslice(self, i, j, 1, Sequence());
}
void __setslice__(difference_type i, difference_type j, const Sequence& v) throw (std::out_of_range, std::invalid_argument) {
swig::setslice(self, i, j, 1, v);
}
@ -803,11 +809,10 @@ namespace swig
}
#endif
void __delitem__(difference_type i) throw (std::out_of_range) {
self->erase(swig::getpos(self,i));
void __delitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) {
swig::erase(self, swig::getpos(self, i));
}
/* Overloaded methods for Python 3 compatibility
* (Also useful in Python 2.x)
*/
@ -858,12 +863,11 @@ namespace swig
Sequence::difference_type jd = j;
swig::delslice(self, id, jd, step);
}
}
}
%enddef
%define %swig_sequence_methods(Sequence...)
%define %swig_sequence_methods_non_resizable(Sequence...)
%swig_sequence_methods_common(%arg(Sequence))
%extend {
const value_type& __getitem__(difference_type i) const throw (std::out_of_range) {
@ -876,19 +880,32 @@ namespace swig
#if defined(SWIGPYTHON_BUILTIN)
// This will be called through the mp_ass_subscript slot to delete an entry.
void __setitem__(difference_type i) throw (std::out_of_range) {
self->erase(swig::getpos(self,i));
void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) {
swig::erase(self, swig::getpos(self, i));
}
#endif
}
%enddef
%define %swig_sequence_methods(Sequence...)
%swig_sequence_methods_non_resizable(%arg(Sequence))
%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;
}
void append(const value_type& x) {
self->push_back(x);
}
}
}
%enddef
%define %swig_sequence_methods_val(Sequence...)
%define %swig_sequence_methods_non_resizable_val(Sequence...)
%swig_sequence_methods_common(%arg(Sequence))
%extend {
value_type __getitem__(difference_type i) throw (std::out_of_range) {
@ -901,16 +918,28 @@ namespace swig
#if defined(SWIGPYTHON_BUILTIN)
// This will be called through the mp_ass_subscript slot to delete an entry.
void __setitem__(difference_type i) throw (std::out_of_range) {
self->erase(swig::getpos(self,i));
void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) {
swig::erase(self, swig::getpos(self, i));
}
#endif
}
%enddef
%define %swig_sequence_methods_val(Sequence...)
%swig_sequence_methods_non_resizable_val(%arg(Sequence))
%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;
}
void append(value_type x) {
self->push_back(x);
}
}
}
%enddef
@ -943,8 +972,8 @@ namespace swig {
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) {
swig_type_info *descriptor = swig::type_info<sequence>();
if (descriptor && SWIG_IsOK(::SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
if (seq) *seq = p;
return SWIG_OLDOBJ;
}
@ -983,15 +1012,14 @@ namespace swig {
%#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);
return SWIG_InternalNewPointerObj(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) {
PyObject *obj = PyTuple_New((Py_ssize_t)size);
Py_ssize_t i = 0;
for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) {
PyTuple_SetItem(obj,i,swig::from<value_type>(*it));
}
return obj;

View file

@ -97,10 +97,6 @@ PyString_FromFormat(const char *fmt, ...) {
}
#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
@ -215,4 +211,5 @@ typedef destructor freefunc;
#if PY_VERSION_HEX < 0x03020000
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
#define Py_hash_t long
#endif

View file

@ -145,7 +145,6 @@ swig_varlink_type(void) {
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
@ -183,10 +182,19 @@ swig_varlink_type(void) {
0, /* tp_del */
#endif
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version */
0, /* tp_version_tag */
#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#ifdef COUNT_ALLOCS
0,0,0,0 /* tp_alloc -> tp_next */
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
#endif
0 /* tp_next */
#endif
};
varlink_type = tmp;
@ -366,13 +374,13 @@ SWIG_init(void) {
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;
PyTypeObject *swigpyobject;
SwigPyClientData *cd;
PyObject *public_interface, *public_symbol;
PyObject *this_descr;
@ -387,14 +395,9 @@ SWIG_init(void) {
(void)static_getset;
(void)self;
/* 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);
/* Metaclass is used to implement static member variables */
metatype = SwigPyObjectType();
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 */
@ -412,13 +415,15 @@ SWIG_init(void) {
SWIG_InitializeModule(0);
#ifdef SWIGPYTHON_BUILTIN
swigpyobject = SwigPyObject_TypeOnce();
SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
assert(SwigPyObject_stype);
cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
if (!cd) {
SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce();
} else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) {
SwigPyObject_clientdata.pytype = swigpyobject;
} else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) {
PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
# if PY_VERSION_HEX >= 0x03000000
return NULL;

View file

@ -18,31 +18,35 @@
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";
class MyClass {
public:
...
};
%{
// Note: Py_hash_t was introduced in Python 3.2
static Py_hash_t myHashFunc(PyObject *pyobj) {
MyClass *cobj;
// Convert pyobj to cobj
return (cobj->field1 * (cobj->field2 << 7));
}
%}
NOTE: It is the responsibility of the programmer (that's you) to ensure
that a statically defined slot function has the correct signature.
If, instead, you want to dispatch to an instance method, you can
use %feature("python:slot"). For example:
%feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
class MyClass {
public:
long myHashFunc () const;
Py_hash_t 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,
@ -58,20 +62,21 @@
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:
operation, you may use a different feature, %feature("python:compare")
like this:
%feature("python:compare", "Py_LT") MyClass::lessThan;
class MyClass {
public:
bool lessThan (const MyClass& x) const;
bool lessThan(const MyClass& other) 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,
If there's no method defined to handle a particular comparison operation,
the default behavior is to compare pointer values of the wrapped
C++ objects.
@ -103,7 +108,6 @@
%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);
@ -117,8 +121,6 @@
%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~;
@ -127,6 +129,7 @@
#if defined(SWIGPYTHON_BUILTIN)
%pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero);
%pybinoperator(__truediv__, *::operator/ , binaryfunc, nb_divide);
#else
%feature("shadow") *::operator bool %{
def __nonzero__(self):
@ -134,6 +137,13 @@ def __nonzero__(self):
__bool__ = __nonzero__
%};
%rename(__nonzero__) *::operator bool;
%feature("shadow") *::operator/ %{
def __truediv__(self, *args):
return $action(self, *args)
__div__ = __truediv__
%};
%rename(__truediv__) *::operator/;
%pythonmaybecall *::operator/;
#endif
/* Ignored operators */
@ -151,11 +161,11 @@ __bool__ = __nonzero__
They translate the inplace C++ operators (+=, -=, ...) into the
corresponding python equivalents(__iadd__,__isub__), etc,
disabling the ownership of the input 'self' pointer, and assigning
disabling the ownership of the input 'this' pointer, and assigning
it to the returning object:
%feature("del") *::Operator;
%feature("new") *::Operator;
%feature("del") *::Operator; // disables ownership by generating SWIG_POINTER_DISOWN
%feature("new") *::Operator; // claims ownership by generating SWIG_POINTER_OWN
This makes the most common case safe, ie:
@ -174,8 +184,8 @@ __bool__ = __nonzero__
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+=;
%feature("del","0") A::operator+=;
%feature("new","0") A::operator+=;
which recovers the old behaviour for the class 'A', or if you are
100% sure your entire system works fine in the old way, use:
@ -183,6 +193,12 @@ __bool__ = __nonzero__
%feature("del","") *::operator+=;
%feature("new","") *::operator+=;
The default behaviour assumes that the 'this' pointer's memory is
already owned by the SWIG object; it relinquishes ownership then
takes it back. This may not be the case though as the SWIG object
might be owned by memory managed elsewhere, eg after calling a
function that returns a C++ reference. In such case you will need
to use the features above to recover the old behaviour too.
*/
#if defined(SWIGPYTHON_BUILTIN)
@ -194,7 +210,6 @@ __bool__ = __nonzero__
%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);
@ -202,6 +217,19 @@ __bool__ = __nonzero__
%pyinplaceoper(__ilshift__, *::operator <<=, binaryfunc, nb_inplace_lshift);
%pyinplaceoper(__irshift__, *::operator >>=, binaryfunc, nb_inplace_rshift);
/* Special cases */
#if defined(SWIGPYTHON_BUILTIN)
%pyinplaceoper(__itruediv__ , *::operator /=, binaryfunc, nb_inplace_divide);
#else
%delobject *::operator /=;
%newobject *::operator /=;
%feature("shadow") *::operator /= %{
def __itruediv__(self, *args):
return $action(self, *args)
__idiv__ = __itruediv__
%};
%rename(__itruediv__) *::operator /=;
#endif
/* Finally, in python we need to mark the binary operations to fail as
'maybecall' methods */
@ -216,6 +244,7 @@ __bool__ = __nonzero__
%pybinopermaybecall(neg);
%pybinopermaybecall(mul);
%pybinopermaybecall(div);
%pybinopermaybecall(truediv);
%pybinopermaybecall(mod);
%pybinopermaybecall(lshift);
%pybinopermaybecall(rshift);

View file

@ -67,7 +67,7 @@ SWIGINTERNINLINE PyObject*
/* long */
%fragment(SWIG_From_frag(long),"header") {
%define_as(SWIG_From_dec(long), PyLong_FromLong)
%define_as(SWIG_From_dec(long), PyInt_FromLong)
}
%fragment(SWIG_AsVal_frag(long),"header",
@ -75,16 +75,20 @@ SWIGINTERNINLINE PyObject*
SWIGINTERN int
SWIG_AsVal_dec(long)(PyObject *obj, long* val)
{
%#if PY_VERSION_HEX < 0x03000000
if (PyInt_Check(obj)) {
if (val) *val = PyInt_AsLong(obj);
return SWIG_OK;
} else if (PyLong_Check(obj)) {
} else
%#endif
if (PyLong_Check(obj)) {
long v = PyLong_AsLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_OK;
} else {
PyErr_Clear();
return SWIG_OverflowError;
}
}
%#ifdef SWIG_PYTHON_CAST_MODE
@ -119,7 +123,7 @@ SWIGINTERNINLINE PyObject*
SWIG_From_dec(unsigned long)(unsigned long value)
{
return (value > LONG_MAX) ?
PyLong_FromUnsignedLong(value) : PyLong_FromLong(%numeric_cast(value,long));
PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long));
}
}
@ -146,18 +150,7 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
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
return SWIG_OverflowError;
}
}
%#ifdef SWIG_PYTHON_CAST_MODE
@ -187,20 +180,22 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
/* long long */
%fragment(SWIG_From_frag(long long),"header",
fragment=SWIG_From_frag(long),
fragment="<limits.h>") {
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERNINLINE PyObject*
SWIG_From_dec(long long)(long long value)
{
return ((value < LONG_MIN) || (value > LONG_MAX)) ?
PyLong_FromLongLong(value) : PyLong_FromLong(%numeric_cast(value,long));
PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
}
%#endif
}
%fragment(SWIG_AsVal_frag(long long),"header",
fragment=SWIG_AsVal_frag(long),
fragment="SWIG_CanCastAsInteger",
fragment="<limits.h>") {
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERN int
SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
{
@ -212,6 +207,7 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
return SWIG_OK;
} else {
PyErr_Clear();
res = SWIG_OverflowError;
}
} else {
long v;
@ -227,6 +223,8 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
const double mant_min = -mant_max;
double d;
res = SWIG_AsVal(double)(obj,&d);
if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max))
return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
if (val) *val = (long long)(d);
return SWIG_AddCast(res);
@ -236,25 +234,28 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
%#endif
return res;
}
%#endif
}
/* unsigned long long */
%fragment(SWIG_From_frag(unsigned long long),"header",
fragment=SWIG_From_frag(long long),
fragment="<limits.h>") {
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERNINLINE PyObject*
SWIG_From_dec(unsigned long long)(unsigned long long value)
{
return (value > LONG_MAX) ?
PyLong_FromUnsignedLongLong(value) : PyLong_FromLong(%numeric_cast(value,long));
PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
}
%#endif
}
%fragment(SWIG_AsVal_frag(unsigned long long),"header",
fragment=SWIG_AsVal_frag(unsigned long),
fragment="SWIG_CanCastAsInteger",
fragment="<limits.h>") {
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERN int
SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
{
@ -266,6 +267,7 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
return SWIG_OK;
} else {
PyErr_Clear();
res = SWIG_OverflowError;
}
} else {
unsigned long v;
@ -280,6 +282,8 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
const double mant_max = 1LL << DBL_MANT_DIG;
double d;
res = SWIG_AsVal(double)(obj,&d);
if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
if (val) *val = (unsigned long long)(d);
return SWIG_AddCast(res);
@ -289,6 +293,7 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
%#endif
return res;
}
%#endif
}
/* double */
@ -305,9 +310,11 @@ SWIG_AsVal_dec(double)(PyObject *obj, double *val)
if (PyFloat_Check(obj)) {
if (val) *val = PyFloat_AsDouble(obj);
return SWIG_OK;
%#if PY_VERSION_HEX < 0x03000000
} else if (PyInt_Check(obj)) {
if (val) *val = PyInt_AsLong(obj);
if (val) *val = (double) PyInt_AsLong(obj);
return SWIG_OK;
%#endif
} else if (PyLong_Check(obj)) {
double v = PyLong_AsDouble(obj);
if (!PyErr_Occurred()) {

View file

@ -161,7 +161,7 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
/* Unpack the argument tuple */
SWIGINTERN int
SWIGINTERN Py_ssize_t
SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
{
if (!args) {
@ -175,7 +175,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
}
if (!PyTuple_Check(args)) {
if (min <= 1 && max >= 1) {
int i;
Py_ssize_t i;
objs[0] = args;
for (i = 1; i < max; ++i) {
objs[i] = 0;
@ -195,7 +195,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
name, (min == max ? "" : "at most "), (int)max, (int)l);
return 0;
} else {
int i;
Py_ssize_t i;
for (i = 0; i < l; ++i) {
objs[i] = PyTuple_GET_ITEM(args, i);
}
@ -536,16 +536,32 @@ SwigPyObject_dealloc(PyObject *v)
if (destroy) {
/* destroy is always a VARARGS method */
PyObject *res;
/* PyObject_CallFunction() has the potential to silently drop
the active active exception. In cases of unnamed temporary
variable or where we just finished iterating over a generator
StopIteration will be active right now, and this needs to
remain true upon return from SwigPyObject_dealloc. So save
and restore. */
PyObject *val = NULL, *type = NULL, *tb = NULL;
PyErr_Fetch(&val, &type, &tb);
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);
/* 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));
PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
PyObject *mself = PyCFunction_GET_SELF(destroy);
res = ((*meth)(mself, v));
}
if (!res)
PyErr_WriteUnraisable(destroy);
PyErr_Restore(val, type, tb);
Py_XDECREF(res);
}
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
@ -569,6 +585,7 @@ SwigPyObject_append(PyObject* v, PyObject* next)
next = tmp;
#endif
if (!SwigPyObject_Check(next)) {
PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
return NULL;
}
sobj->next = next;
@ -724,7 +741,9 @@ SwigPyObject_TypeOnce(void) {
(unaryfunc)SwigPyObject_oct, /*nb_oct*/
(unaryfunc)SwigPyObject_hex, /*nb_hex*/
#endif
#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */
#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
#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 */
@ -739,7 +758,6 @@ SwigPyObject_TypeOnce(void) {
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
@ -750,7 +768,7 @@ SwigPyObject_TypeOnce(void) {
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
@ -758,7 +776,7 @@ SwigPyObject_TypeOnce(void) {
#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 */
0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
#else
(cmpfunc)SwigPyObject_compare, /* tp_compare */
#endif
@ -768,7 +786,7 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
0, /* tp_str */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@ -804,10 +822,19 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_del */
#endif
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version */
0, /* tp_version_tag */
#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#ifdef COUNT_ALLOCS
0,0,0,0 /* tp_alloc -> tp_next */
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
#endif
0 /* tp_next */
#endif
};
swigpyobject_type = tmp;
@ -922,7 +949,6 @@ SwigPyPacked_TypeOnce(void) {
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
@ -983,10 +1009,19 @@ SwigPyPacked_TypeOnce(void) {
0, /* tp_del */
#endif
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version */
0, /* tp_version_tag */
#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#ifdef COUNT_ALLOCS
0,0,0,0 /* tp_alloc -> tp_next */
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
#if PY_VERSION_HEX >= 0x02050000
0, /* tp_prev */
#endif
0 /* tp_next */
#endif
};
swigpypacked_type = tmp;
@ -1514,13 +1549,11 @@ 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");
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");
PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value");
return SWIG_ERROR;
}

View file

@ -46,7 +46,8 @@ namespace swig {
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p;
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) *val = p;
}

View file

@ -6,13 +6,18 @@ SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
{
%#if PY_VERSION_HEX>=0x03000000
%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
if (PyBytes_Check(obj))
%#else
if (PyUnicode_Check(obj))
%#endif
%#else
if (PyString_Check(obj))
%#endif
{
char *cstr; Py_ssize_t len;
%#if PY_VERSION_HEX>=0x03000000
%#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
if (!alloc && cptr) {
/* We can't allow converting without allocation, since the internal
representation of string in Python 3 is UCS-2/UCS-4 but we require
@ -21,8 +26,9 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
return SWIG_RuntimeError;
}
obj = PyUnicode_AsUTF8String(obj);
PyBytes_AsStringAndSize(obj, &cstr, &len);
if(alloc) *alloc = SWIG_NEWOBJ;
%#endif
PyBytes_AsStringAndSize(obj, &cstr, &len);
%#else
PyString_AsStringAndSize(obj, &cstr, &len);
%#endif
@ -42,27 +48,58 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
%#else
if (*alloc == SWIG_NEWOBJ)
%#endif
{
*cptr = %new_copy_array(cstr, len + 1, char);
*alloc = SWIG_NEWOBJ;
}
else {
{
*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
%#if PY_VERSION_HEX>=0x03000000
%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
*cptr = PyBytes_AsString(obj);
%#else
assert(0); /* Should never reach here with Unicode strings in Python 3 */
%#endif
%#else
*cptr = SWIG_Python_str_AsChar(obj);
%#endif
}
}
if (psize) *psize = len + 1;
%#if PY_VERSION_HEX>=0x03000000
%#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
Py_XDECREF(obj);
%#endif
return SWIG_OK;
} else {
%#if defined(SWIG_PYTHON_2_UNICODE)
%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
%#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once"
%#endif
%#if PY_VERSION_HEX<0x03000000
if (PyUnicode_Check(obj)) {
char *cstr; Py_ssize_t len;
if (!alloc && cptr) {
return SWIG_RuntimeError;
}
obj = PyUnicode_AsUTF8String(obj);
if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) {
if (cptr) {
if (alloc) *alloc = SWIG_NEWOBJ;
*cptr = %new_copy_array(cstr, len + 1, char);
}
if (psize) *psize = len + 1;
Py_XDECREF(obj);
return SWIG_OK;
} else {
Py_XDECREF(obj);
}
}
%#endif
%#endif
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
if (pchar_descriptor) {
void* vptr = 0;
@ -89,13 +126,17 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
%#if PY_VERSION_HEX >= 0x03000000
%#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, %numeric_cast(size,int), "surrogateescape");
%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
return PyBytes_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
%#else
return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
%#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape");
%#else
return PyUnicode_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
%#endif
%#endif
%#else
return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));
%#endif
}
} else {
@ -104,4 +145,3 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
}
}

View file

@ -8,10 +8,11 @@
/*
Warnings for Python keywords
http://www.fnorb.org/docs/1.2/Fnorb-Guide/node62.html
https://docs.python.org/2/reference/lexical_analysis.html#keywords
*/
PYTHONKW(and);
PYTHONKW(as);
PYTHONKW(assert);
PYTHONKW(break);
PYTHONKW(class);
@ -39,11 +40,12 @@ PYTHONKW(raise);
PYTHONKW(return);
PYTHONKW(try);
PYTHONKW(while);
PYTHONKW(with);
PYTHONKW(yield);
/*
built-in functions
http://www.zvon.org/other/python/doc21/lib/built-in-funcs.html
https://docs.python.org/2/library/functions.html
*/
PYTHONBN(abs);

View file

@ -79,10 +79,12 @@
/* Consttab, needed for callbacks, it should be removed later */
%typemap(consttab) SWIGTYPE ((*)(ANY))
%typemap(consttab) SWIGTYPE ((*)(ANY))
{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
%typemap(consttab) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
%typemap(constcode) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
/* Smart Pointers */

View file

@ -16,7 +16,7 @@ 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 PY_VERSION_HEX < 0x03000000 && !defined(SWIG_PYTHON_STRICT_UNICODE_WCHAR)
if (!isunicode && PyString_Check(obj)) {
obj = tmp = PyUnicode_FromObject(obj);
isunicode = 1;
@ -58,7 +58,7 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
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));
return PyUnicode_FromWideChar(carray, %numeric_cast(size, Py_ssize_t));
}
} else {
return SWIG_Py_Void();

91
Lib/python/std_array.i Normal file
View file

@ -0,0 +1,91 @@
/*
std::array
*/
%fragment("StdArrayTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
template <class T, size_t N>
struct traits_asptr<std::array<T, N> > {
static int asptr(PyObject *obj, std::array<T, N> **vec) {
return traits_asptr_stdseq<std::array<T, N> >::asptr(obj, vec);
}
};
template <class T, size_t N>
struct traits_from<std::array<T, N> > {
static PyObject *from(const std::array<T, N>& vec) {
return traits_from_stdseq<std::array<T, N> >::from(vec);
}
};
template <class SwigPySeq, class T, size_t N>
inline void
assign(const SwigPySeq& swigpyseq, std::array<T, N>* seq) {
if (swigpyseq.size() < seq->size())
throw std::invalid_argument("std::array cannot be expanded in size");
else if (swigpyseq.size() > seq->size())
throw std::invalid_argument("std::array cannot be reduced in size");
std::copy(swigpyseq.begin(), swigpyseq.end(), seq->begin());
}
template <class T, size_t N>
inline void
erase(std::array<T, N>* SWIGUNUSEDPARM(seq), const typename std::array<T, N>::iterator& SWIGUNUSEDPARM(position)) {
throw std::invalid_argument("std::array object does not support item deletion");
}
// Only limited slicing is supported as std::array is fixed in size
template <class T, size_t N, class Difference>
inline std::array<T, N>*
getslice(const std::array<T, N>* self, Difference i, Difference j, Py_ssize_t step) {
typedef std::array<T, N> Sequence;
typename Sequence::size_type size = self->size();
Difference ii = 0;
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj);
if (step == 1 && ii == 0 && static_cast<typename Sequence::size_type>(jj) == size) {
Sequence *sequence = new Sequence();
std::copy(self->begin(), self->end(), sequence->begin());
return sequence;
} else if (step == -1 && static_cast<typename Sequence::size_type>(ii) == (size - 1) && jj == -1) {
Sequence *sequence = new Sequence();
std::copy(self->rbegin(), self->rend(), sequence->begin());
return sequence;
} else {
throw std::invalid_argument("std::array object only supports getting a slice that is the size of the array");
}
}
template <class T, size_t N, class Difference, class InputSeq>
inline void
setslice(std::array<T, N>* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) {
typedef std::array<T, N> Sequence;
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 == 1 && ii == 0 && static_cast<typename Sequence::size_type>(jj) == size) {
std::copy(is.begin(), is.end(), self->begin());
} else if (step == -1 && static_cast<typename Sequence::size_type>(ii) == (size - 1) && jj == -1) {
std::copy(is.rbegin(), is.rend(), self->begin());
} else {
throw std::invalid_argument("std::array object only supports setting a slice that is the size of the array");
}
}
template <class T, size_t N, class Difference>
inline void
delslice(std::array<T, N>* SWIGUNUSEDPARM(self), Difference SWIGUNUSEDPARM(i), Difference SWIGUNUSEDPARM(j), Py_ssize_t SWIGUNUSEDPARM(step)) {
throw std::invalid_argument("std::array object does not support item deletion");
}
}
%}
#define %swig_array_methods(Type...) %swig_sequence_methods_non_resizable(Type)
#define %swig_array_methods_val(Type...) %swig_sequence_methods_non_resizable_val(Type);
%include <std/std_array.i>

View file

@ -13,17 +13,17 @@
fragment=SWIG_From_frag(Type),
fragment="StdTraits") {
namespace swig {
template <> struct traits<Type > {
template <> struct traits< Type > {
typedef value_category category;
static const char* type_name() { return #Type; }
};
template <> struct traits_asval<Type > {
};
template <> struct traits_asval< Type > {
typedef Type value_type;
static int asval(PyObject *obj, value_type *val) {
static int asval(PyObject *obj, value_type *val) {
return SWIG_AsVal(Type)(obj, val);
}
};
template <> struct traits_from<Type > {
template <> struct traits_from< Type > {
typedef Type value_type;
static PyObject *from(const value_type& val) {
return SWIG_From(Type)(val);
@ -46,13 +46,13 @@ namespace swig {
fragment=SWIG_From_frag(int),
fragment="StdTraits") {
namespace swig {
template <> struct traits_asval<Type > {
template <> struct traits_asval< Type > {
typedef Type value_type;
static int asval(PyObject *obj, value_type *val) {
static int asval(PyObject *obj, value_type *val) {
return SWIG_AsVal(int)(obj, (int *)val);
}
};
template <> struct traits_from<Type > {
template <> struct traits_from< Type > {
typedef Type value_type;
static PyObject *from(const value_type& val) {
return SWIG_From(int)((int)val);

View file

@ -102,7 +102,8 @@
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);
swig_type_info *descriptor = swig::type_info<map_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
SWIG_PYTHON_THREAD_END_BLOCK;
@ -119,10 +120,9 @@
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;
Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
PyErr_SetString(PyExc_OverflowError, "map size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}
@ -211,17 +211,16 @@
PyObject* keys() {
Map::size_type size = self->size();
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
if (pysize < 0) {
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
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) {
for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
PyList_SET_ITEM(keyList, j, swig::from(i->first));
}
SWIG_PYTHON_THREAD_END_BLOCK;
@ -230,17 +229,16 @@
PyObject* values() {
Map::size_type size = self->size();
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
if (pysize < 0) {
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
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) {
for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
PyList_SET_ITEM(valList, j, swig::from(i->second));
}
SWIG_PYTHON_THREAD_END_BLOCK;
@ -249,17 +247,16 @@
PyObject* items() {
Map::size_type size = self->size();
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
if (pysize < 0) {
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
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) {
for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
PyList_SET_ITEM(itemList, j, swig::from(*i));
}
SWIG_PYTHON_THREAD_END_BLOCK;

View file

@ -26,7 +26,8 @@
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);
swig_type_info *descriptor = swig::type_info<multimap_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
@ -45,11 +46,10 @@
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;
Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"multimap size not valid in python");
PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}

View file

@ -48,7 +48,8 @@
}
} else {
value_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
swig_type_info *descriptor = swig::type_info<value_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = *p;
}
return res;
@ -98,7 +99,8 @@
}
} else {
value_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
swig_type_info *descriptor = swig::type_info<value_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;

View file

@ -15,6 +15,13 @@
}
}
template <class K, class T>
struct traits_reserve<std::unordered_map<K,T> > {
static void reserve(std::unordered_map<K,T> &seq, typename std::unordered_map<K,T>::size_type n) {
seq.reserve(n);
}
};
template <class K, class T>
struct traits_asptr<std::unordered_map<K,T> > {
typedef std::unordered_map<K,T> unordered_map_type;
@ -29,7 +36,8 @@
res = traits_asptr_stdseq<std::unordered_map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
unordered_map_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<unordered_map_type>(),0);
swig_type_info *descriptor = swig::type_info<unordered_map_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
@ -48,11 +56,10 @@
return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN);
} else {
size_type size = unordered_map.size();
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"unordered_map size not valid in python");
PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}
@ -164,17 +171,16 @@
PyObject* keys() {
Map::size_type size = self->size();
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"unordered_map size not valid in python");
PyErr_SetString(PyExc_OverflowError, "unordered_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) {
for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
PyList_SET_ITEM(keyList, j, swig::from(i->first));
}
return keyList;
@ -182,17 +188,16 @@
PyObject* values() {
Map::size_type size = self->size();
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"unordered_map size not valid in python");
PyErr_SetString(PyExc_OverflowError, "unordered_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) {
for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
PyList_SET_ITEM(valList, j, swig::from(i->second));
}
return valList;
@ -200,17 +205,16 @@
PyObject* items() {
Map::size_type size = self->size();
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"unordered_map size not valid in python");
PyErr_SetString(PyExc_OverflowError, "unordered_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) {
for (Py_ssize_t j = 0; j < pysize; ++i, ++j) {
PyList_SET_ITEM(itemList, j, swig::from(*i));
}
return itemList;

View file

@ -16,6 +16,13 @@
}
}
template <class K, class T>
struct traits_reserve<std::unordered_multimap<K,T> > {
static void reserve(std::unordered_multimap<K,T> &seq, typename std::unordered_multimap<K,T>::size_type n) {
seq.reserve(n);
}
};
template <class K, class T>
struct traits_asptr<std::unordered_multimap<K,T> > {
typedef std::unordered_multimap<K,T> unordered_multimap_type;
@ -26,7 +33,8 @@
return traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
unordered_multimap_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<unordered_multimap_type>(),0);
swig_type_info *descriptor = swig::type_info<unordered_multimap_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
@ -45,11 +53,10 @@
return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN);
} else {
size_type size = unordered_multimap.size();
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"unordered_multimap size not valid in python");
PyErr_SetString(PyExc_OverflowError, "unordered_multimap size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}

View file

@ -18,6 +18,13 @@
}
}
template <class T>
struct traits_reserve<std::unordered_multiset<T> > {
static void reserve(std::unordered_multiset<T> &seq, typename std::unordered_multiset<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::unordered_multiset<T> > {
static int asptr(PyObject *obj, std::unordered_multiset<T> **m) {

View file

@ -16,6 +16,13 @@
}
}
template <class T>
struct traits_reserve<std::unordered_set<T> > {
static void reserve(std::unordered_set<T> &seq, typename std::unordered_set<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::unordered_set<T> > {
static int asptr(PyObject *obj, std::unordered_set<T> **s) {

View file

@ -5,6 +5,13 @@
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
template <class T>
struct traits_reserve<std::vector<T> > {
static void reserve(std::vector<T> &seq, typename std::vector<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::vector<T> > {
static int asptr(PyObject *obj, std::vector<T> **vec) {