Regressions pass! With a few tweaks for unsupported features, primarily:

- Throwing wrapped types as exceptions is unsupported.
- Reverse comparison operators (e.g., __radd__) aren't supported.

Rationalized destructors.

Finished std::map implementation.  Required fixes to typecheck for
SWIGTYPE* const&.

Need a little special handling of the swig_type_info for SwigPyObject
when multiple modules are loaded.

Fall back to SwigPyObject_richcompare if there's no operator overload.

"memberget" and "memberset" attrs are applied strangely; work around
them.

Added 'this' attribute.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12415 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-01-30 03:17:28 +00:00
commit 288c37f5bf
9 changed files with 352 additions and 574 deletions

View file

@ -5,6 +5,17 @@ wrapper##_closure (PyObject *a) \
return wrapper(a, NULL); \
}
#define PYSWIG_DESTRUCTOR_CLOSURE(wrapper) \
SWIGINTERN void \
wrapper##_closure (PyObject *a) \
{ \
SwigPyObject *sobj = (SwigPyObject*) a; \
if (sobj->own) { \
PyObject *o = wrapper(a, NULL); \
Py_XDECREF(o); \
} \
}
#define PYSWIG_INQUIRY_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_closure (PyObject *a) \
@ -132,22 +143,6 @@ wrapper##_closure (PyObject *a, PyObject *b, PyObject *c) \
return result; \
}
#ifdef __cplusplus
namespace {
template <typename _Tp> void py_builtin_dealloc (PyObject *pyobj)
{
SwigPyObject *obj = (SwigPyObject*) pyobj;
if (obj->own)
delete reinterpret_cast<_Tp*>(obj->ptr);
(*pyobj->ob_type->tp_free)(pyobj);
}
} // namespace {
#endif
SWIGRUNTIME int py_builtin_bad_init (PyObject *self, PyObject *args, PyObject *kwds)
{
PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name);
@ -187,11 +182,15 @@ pyswig_getter_closure (PyObject *obj, void *closure)
SWIGRUNTIME int
pyswig_setter_closure (PyObject *obj, PyObject *val, void *closure)
{
if (!closure)
if (!closure) {
PyErr_Format(PyExc_TypeError, "Missing getset closure");
return -1;
}
SwigPyGetSet *getset = (SwigPyGetSet*) closure;
if (!getset->set)
if (!getset->set) {
PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
return -1;
}
PyObject *tuple = PyTuple_New(1);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, val);
@ -220,11 +219,15 @@ pyswig_static_getter_closure (PyObject *obj, void *closure)
SWIGRUNTIME int
pyswig_static_setter_closure (PyObject *obj, PyObject *val, void *closure)
{
if (!closure)
if (!closure) {
PyErr_Format(PyExc_TypeError, "Missing getset closure");
return -1;
}
SwigPyGetSet *getset = (SwigPyGetSet*) closure;
if (!getset->set)
if (!getset->set) {
PyErr_Format(PyExc_TypeError, "Illegal static variable assignment.");
return -1;
}
PyObject *tuple = PyTuple_New(1);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, val);
@ -381,4 +384,12 @@ pyswig_builtin_init_bases (PyTypeObject *type, std::vector<PyTypeObject*>& bases
type->tp_bases = tuple;
}
SWIGINTERN PyObject*
pyswig_this_closure (PyObject *self, void *closure)
{
PyObject *result = (PyObject*) SWIG_Python_GetSwigThis(self);
Py_XINCREF(result);
return result;
}
#endif