Fixed PyGetSetDescr for python3.2.
Fixed memory management in special_variable_macros test. Don't define asdict() for multimap. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12659 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cba65bd524
commit
a52612f845
7 changed files with 53 additions and 19 deletions
|
|
@ -4,6 +4,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
Version 2.0.4 (in progress)
|
Version 2.0.4 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
2011-05-07: szager
|
||||||
|
[python] Fixed PyGetSetDescr for python3.2.
|
||||||
|
|
||||||
2011-05-05: wsfulton
|
2011-05-05: wsfulton
|
||||||
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
|
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
|
||||||
method with incorrect arguments improved to show always show fully qualified name
|
method with incorrect arguments improved to show always show fully qualified name
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ BUILTIN_BROKEN = \
|
||||||
default_constructor.cpptest \
|
default_constructor.cpptest \
|
||||||
director_exception.cpptest \
|
director_exception.cpptest \
|
||||||
exception_order.cpptest \
|
exception_order.cpptest \
|
||||||
threads_exception.cpptest
|
threads_exception.cpptest \
|
||||||
|
python_abstractbase.cpptest
|
||||||
|
|
||||||
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
|
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,25 @@
|
||||||
|
|
||||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */
|
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */
|
||||||
|
|
||||||
|
%ignore Name::operator=;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
struct Name {
|
struct Name {
|
||||||
Name(const char *n="none") : name(n) {}
|
Name(const char *n="none") : name(strdup(n ? n : "")) {}
|
||||||
|
Name(const Name& x) : name(strdup(x.name)) {}
|
||||||
|
Name& operator= (const Name& x)
|
||||||
|
{
|
||||||
|
if (this != &x) {
|
||||||
|
free(this->name);
|
||||||
|
this->name = strdup(x.name);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~Name () { free(this->name); }
|
||||||
const char *getName() const { return name; };
|
const char *getName() const { return name; };
|
||||||
Name *getNamePtr() { return this; };
|
Name *getNamePtr() { return this; };
|
||||||
private:
|
private:
|
||||||
const char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
struct NameWrap {
|
struct NameWrap {
|
||||||
NameWrap(const char *n="casternone") : name(n) {}
|
NameWrap(const char *n="casternone") : name(n) {}
|
||||||
|
|
|
||||||
|
|
@ -285,17 +285,22 @@ SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure)
|
||||||
SWIGINTERN void
|
SWIGINTERN void
|
||||||
SwigPyStaticVar_dealloc(PyDescrObject *descr) {
|
SwigPyStaticVar_dealloc(PyDescrObject *descr) {
|
||||||
_PyObject_GC_UNTRACK(descr);
|
_PyObject_GC_UNTRACK(descr);
|
||||||
|
/*
|
||||||
Py_XDECREF(descr->d_type);
|
Py_XDECREF(descr->d_type);
|
||||||
Py_XDECREF(descr->d_name);
|
Py_XDECREF(descr->d_name);
|
||||||
|
*/
|
||||||
|
Py_XDECREF(PyDescr_TYPE(descr));
|
||||||
|
Py_XDECREF(PyDescr_NAME(descr));
|
||||||
PyObject_GC_Del(descr);
|
PyObject_GC_Del(descr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGINTERN PyObject *
|
SWIGINTERN PyObject *
|
||||||
SwigPyStaticVar_repr(PyGetSetDescrObject *descr) {
|
SwigPyStaticVar_repr(PyGetSetDescrObject *descr) {
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
return PyUnicode_FromFormat("<class attribute '%S' of type '%s'>", descr->d_name, descr->d_type->tp_name);
|
|
||||||
|
return PyUnicode_FromFormat("<class attribute '%S' of type '%s'>", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
|
||||||
#else
|
#else
|
||||||
return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(descr->d_name), descr->d_type->tp_name);
|
return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -303,7 +308,7 @@ SWIGINTERN int
|
||||||
SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) {
|
SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) {
|
||||||
PyDescrObject *descr;
|
PyDescrObject *descr;
|
||||||
descr = (PyDescrObject *)self;
|
descr = (PyDescrObject *)self;
|
||||||
Py_VISIT((PyObject*) descr->d_type);
|
Py_VISIT((PyObject*) PyDescr_TYPE(descr));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,9 +317,9 @@ SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNU
|
||||||
if (descr->d_getset->get != NULL)
|
if (descr->d_getset->get != NULL)
|
||||||
return descr->d_getset->get(obj, descr->d_getset->closure);
|
return descr->d_getset->get(obj, descr->d_getset->closure);
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", descr->d_name, descr->d_type->tp_name);
|
PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
|
||||||
#else
|
#else
|
||||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
|
PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -324,9 +329,9 @@ SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
|
||||||
if (descr->d_getset->set != NULL)
|
if (descr->d_getset->set != NULL)
|
||||||
return descr->d_getset->set(obj, value, descr->d_getset->closure);
|
return descr->d_getset->set(obj, value, descr->d_getset->closure);
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", descr->d_name, descr->d_type->tp_name);
|
PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
|
||||||
#else
|
#else
|
||||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
|
PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -425,10 +430,10 @@ SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
|
||||||
descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&SwigPyStaticVar_Type, 0);
|
descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&SwigPyStaticVar_Type, 0);
|
||||||
assert(descr);
|
assert(descr);
|
||||||
Py_XINCREF(type);
|
Py_XINCREF(type);
|
||||||
descr->d_type = type;
|
PyDescr_TYPE(descr) = type;
|
||||||
descr->d_name = PyString_InternFromString(getset->name);
|
PyDescr_NAME(descr) = PyString_InternFromString(getset->name);
|
||||||
descr->d_getset = getset;
|
descr->d_getset = getset;
|
||||||
if (descr->d_name == NULL) {
|
if (PyDescr_NAME(descr) == NULL) {
|
||||||
Py_DECREF(descr);
|
Py_DECREF(descr);
|
||||||
descr = NULL;
|
descr = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,3 +206,8 @@ typedef destructor freefunc;
|
||||||
# define SWIGPY_USE_CAPSULE
|
# define SWIGPY_USE_CAPSULE
|
||||||
# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
|
# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX < 0x03020000
|
||||||
|
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
|
||||||
|
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,16 @@ SWIG_init(void) {
|
||||||
PyObject *m, *d, *md;
|
PyObject *m, *d, *md;
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
static struct PyModuleDef SWIG_module = {
|
static struct PyModuleDef SWIG_module = {
|
||||||
|
# if PY_VERSION_HEX >= 0x03020000
|
||||||
PyModuleDef_HEAD_INIT,
|
PyModuleDef_HEAD_INIT,
|
||||||
|
# else
|
||||||
|
{
|
||||||
|
PyObject_HEAD_INIT(NULL)
|
||||||
|
NULL, /* m_init */
|
||||||
|
0, /* m_index */
|
||||||
|
NULL, /* m_copy */
|
||||||
|
},
|
||||||
|
# endif
|
||||||
(char *) SWIG_name,
|
(char *) SWIG_name,
|
||||||
NULL,
|
NULL,
|
||||||
-1,
|
-1,
|
||||||
|
|
|
||||||
|
|
@ -168,10 +168,6 @@
|
||||||
swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) {
|
swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) {
|
||||||
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
|
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* asdict() {
|
|
||||||
return swig::traits_from< Map >::asdict(*self);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
@ -292,14 +288,17 @@
|
||||||
void __setitem__(const key_type& key) {
|
void __setitem__(const key_type& key) {
|
||||||
self->erase(key);
|
self->erase(key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
%extend {
|
|
||||||
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
||||||
(*self)[key] = x;
|
(*self)[key] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject* asdict() {
|
||||||
|
return swig::traits_from< Map >::asdict(*self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue