Coding style fixes for Python builtin changes added on the szager-builtin branch

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12515 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-03-03 19:34:18 +00:00
commit 908c37cef8
7 changed files with 425 additions and 506 deletions

View file

@ -1,15 +1,13 @@
#define PYSWIG_UNARYFUNC_CLOSURE(wrapper) \ #define PYSWIG_UNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \
return wrapper(a, NULL); \ return wrapper(a, NULL); \
} }
#define PYSWIG_DESTRUCTOR_CLOSURE(wrapper) \ #define PYSWIG_DESTRUCTOR_CLOSURE(wrapper) \
SWIGINTERN void \ SWIGINTERN void \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \ SwigPyObject *sobj = (SwigPyObject *)a; \
SwigPyObject *sobj = (SwigPyObject*) a; \
if (sobj->own) { \ if (sobj->own) { \
PyObject *o = wrapper(a, NULL); \ PyObject *o = wrapper(a, NULL); \
Py_XDECREF(o); \ Py_XDECREF(o); \
@ -18,8 +16,7 @@ wrapper##_closure (PyObject *a) \
#define PYSWIG_INQUIRY_CLOSURE(wrapper) \ #define PYSWIG_INQUIRY_CLOSURE(wrapper) \
SWIGINTERN int \ SWIGINTERN int \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \
PyObject *pyresult = wrapper(a, NULL); \ PyObject *pyresult = wrapper(a, NULL); \
int result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \ int result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \
Py_XDECREF(pyresult); \ Py_XDECREF(pyresult); \
@ -27,9 +24,8 @@ wrapper##_closure (PyObject *a) \
} }
#define PYSWIG_BINARYFUNC_CLOSURE(wrapper) \ #define PYSWIG_BINARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a, PyObject *b) \ wrapper##_closure(PyObject *a, PyObject *b) { \
{ \
PyObject *tuple = PyTuple_New(1); \ PyObject *tuple = PyTuple_New(1); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, b); \ PyTuple_SET_ITEM(tuple, 0, b); \
@ -40,9 +36,8 @@ wrapper##_closure (PyObject *a, PyObject *b) \
} }
#define PYSWIG_TERNARYFUNC_CLOSURE(wrapper) \ #define PYSWIG_TERNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a, PyObject *b, PyObject *c) \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \
{ \
PyObject *tuple = PyTuple_New(2); \ PyObject *tuple = PyTuple_New(2); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, b); \ PyTuple_SET_ITEM(tuple, 0, b); \
@ -56,8 +51,7 @@ wrapper##_closure (PyObject *a, PyObject *b, PyObject *c) \
#define PYSWIG_LENFUNC_CLOSURE(wrapper) \ #define PYSWIG_LENFUNC_CLOSURE(wrapper) \
SWIGINTERN Py_ssize_t \ SWIGINTERN Py_ssize_t \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \
PyObject *resultobj = wrapper(a, NULL); \ PyObject *resultobj = wrapper(a, NULL); \
Py_ssize_t result = PyNumber_AsSsize_t(resultobj, NULL); \ Py_ssize_t result = PyNumber_AsSsize_t(resultobj, NULL); \
Py_DECREF(resultobj); \ Py_DECREF(resultobj); \
@ -65,9 +59,8 @@ wrapper##_closure (PyObject *a) \
} }
#define PYSWIG_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ #define PYSWIG_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a, Py_ssize_t b, Py_ssize_t c) \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \
{ \
PyObject *tuple = PyTuple_New(2); \ PyObject *tuple = PyTuple_New(2); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
@ -79,8 +72,7 @@ wrapper##_closure (PyObject *a, Py_ssize_t b, Py_ssize_t c) \
#define PYSWIG_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ #define PYSWIG_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \ SWIGINTERN int \
wrapper##_closure (PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) \ wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \
{ \
PyObject *tuple = PyTuple_New(d ? 3 : 2); \ PyObject *tuple = PyTuple_New(d ? 3 : 2); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
@ -97,9 +89,8 @@ wrapper##_closure (PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) \
} }
#define PYSWIG_SSIZEARGFUNC_CLOSURE(wrapper) \ #define PYSWIG_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a, Py_ssize_t b) \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \
{ \
PyObject *tuple = PyTuple_New(1); \ PyObject *tuple = PyTuple_New(1); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
@ -109,9 +100,8 @@ wrapper##_closure (PyObject *a, Py_ssize_t b) \
} }
#define PYSWIG_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ #define PYSWIG_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a, Py_ssize_t b) \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \
{ \
PyObject *arg = _PyLong_FromSsize_t(b); \ PyObject *arg = _PyLong_FromSsize_t(b); \
PyObject *result = wrapper(a, arg); \ PyObject *result = wrapper(a, arg); \
Py_DECREF(arg); \ Py_DECREF(arg); \
@ -120,8 +110,7 @@ wrapper##_closure (PyObject *a, Py_ssize_t b) \
#define PYSWIG_SSIZEOBJARGPROC_CLOSURE(wrapper) \ #define PYSWIG_SSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \ SWIGINTERN int \
wrapper##_closure (PyObject *a, Py_ssize_t b, PyObject *c) \ wrapper##_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \
{ \
PyObject *tuple = PyTuple_New(2); \ PyObject *tuple = PyTuple_New(2); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \ PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
@ -136,8 +125,7 @@ wrapper##_closure (PyObject *a, Py_ssize_t b, PyObject *c) \
#define PYSWIG_OBJOBJARGPROC_CLOSURE(wrapper) \ #define PYSWIG_OBJOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \ SWIGINTERN int \
wrapper##_closure (PyObject *a, PyObject *b, PyObject *c) \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \
{ \
PyObject *tuple = PyTuple_New(c ? 2 : 1); \ PyObject *tuple = PyTuple_New(c ? 2 : 1); \
assert(tuple); \ assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, b); \ PyTuple_SET_ITEM(tuple, 0, b); \
@ -154,16 +142,14 @@ wrapper##_closure (PyObject *a, PyObject *b, PyObject *c) \
} }
#define PYSWIG_REPRFUNC_CLOSURE(wrapper) \ #define PYSWIG_REPRFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \
return wrapper(a, NULL); \ return wrapper(a, NULL); \
} }
#define PYSWIG_HASHFUNC_CLOSURE(wrapper) \ #define PYSWIG_HASHFUNC_CLOSURE(wrapper) \
SWIGINTERN long \ SWIGINTERN long \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \
PyObject *pyresult = wrapper(a, NULL); \ PyObject *pyresult = wrapper(a, NULL); \
if (!pyresult || !PyLong_Check(pyresult)) \ if (!pyresult || !PyLong_Check(pyresult)) \
return -1; \ return -1; \
@ -173,9 +159,8 @@ wrapper##_closure (PyObject *a) \
} }
#define PYSWIG_ITERNEXT_CLOSURE(wrapper) \ #define PYSWIG_ITERNEXT_CLOSURE(wrapper) \
SWIGINTERN PyObject* \ SWIGINTERN PyObject * \
wrapper##_closure (PyObject *a) \ wrapper##_closure(PyObject *a) { \
{ \
PyObject *result = wrapper(a, NULL); \ PyObject *result = wrapper(a, NULL); \
if (result && result == Py_None) { \ if (result && result == Py_None) { \
Py_DECREF(result); \ Py_DECREF(result); \
@ -184,19 +169,17 @@ wrapper##_closure (PyObject *a) \
return result; \ return result; \
} }
SWIGINTERN int py_builtin_bad_init (PyObject *self, PyObject *args, PyObject *kwds) SWIGINTERN 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); PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name);
return -1; return -1;
} }
SWIGINTERN void py_builtin_bad_dealloc (PyObject *pyobj) SWIGINTERN void
{ py_builtin_bad_dealloc(PyObject *pyobj) {
SwigPyObject *sobj = (SwigPyObject*) pyobj; SwigPyObject *sobj = (SwigPyObject *)pyobj;
if (sobj->own) { if (sobj->own) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name);
"Swig detected a memory leak in type '%.300s': no callable destructor found.",
pyobj->ob_type->tp_name);
} }
} }
@ -205,12 +188,11 @@ typedef struct {
PyCFunction set; PyCFunction set;
} SwigPyGetSet; } SwigPyGetSet;
SWIGINTERN PyObject* SWIGINTERN PyObject *
pyswig_getter_closure (PyObject *obj, void *closure) pyswig_getter_closure(PyObject *obj, void *closure) {
{
if (!closure) if (!closure)
return SWIG_Py_Void(); return SWIG_Py_Void();
SwigPyGetSet *getset = (SwigPyGetSet*) closure; SwigPyGetSet *getset = (SwigPyGetSet *)closure;
if (!getset->get) if (!getset->get)
return SWIG_Py_Void(); return SWIG_Py_Void();
PyObject *tuple = PyTuple_New(0); PyObject *tuple = PyTuple_New(0);
@ -220,12 +202,11 @@ pyswig_getter_closure (PyObject *obj, void *closure)
return result; return result;
} }
SWIGINTERN PyObject* SWIGINTERN PyObject *
pyswig_funpack_getter_closure (PyObject *obj, void *closure) pyswig_funpack_getter_closure(PyObject *obj, void *closure) {
{
if (!closure) if (!closure)
return SWIG_Py_Void(); return SWIG_Py_Void();
SwigPyGetSet *getset = (SwigPyGetSet*) closure; SwigPyGetSet *getset = (SwigPyGetSet *)closure;
if (!getset->get) if (!getset->get)
return SWIG_Py_Void(); return SWIG_Py_Void();
PyObject *result = (*getset->get)(obj, NULL); PyObject *result = (*getset->get)(obj, NULL);
@ -233,13 +214,12 @@ pyswig_funpack_getter_closure (PyObject *obj, void *closure)
} }
SWIGINTERN int SWIGINTERN int
pyswig_setter_closure (PyObject *obj, PyObject *val, void *closure) pyswig_setter_closure(PyObject *obj, PyObject *val, void *closure) {
{
if (!closure) { if (!closure) {
PyErr_Format(PyExc_TypeError, "Missing getset closure"); PyErr_Format(PyExc_TypeError, "Missing getset closure");
return -1; return -1;
} }
SwigPyGetSet *getset = (SwigPyGetSet*) closure; 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); PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
return -1; return -1;
@ -255,13 +235,12 @@ pyswig_setter_closure (PyObject *obj, PyObject *val, void *closure)
} }
SWIGINTERN int SWIGINTERN int
pyswig_funpack_setter_closure (PyObject *obj, PyObject *val, void *closure) pyswig_funpack_setter_closure(PyObject *obj, PyObject *val, void *closure) {
{
if (!closure) { if (!closure) {
PyErr_Format(PyExc_TypeError, "Missing getset closure"); PyErr_Format(PyExc_TypeError, "Missing getset closure");
return -1; return -1;
} }
SwigPyGetSet *getset = (SwigPyGetSet*) closure; 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); PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
return -1; return -1;
@ -271,12 +250,11 @@ pyswig_funpack_setter_closure (PyObject *obj, PyObject *val, void *closure)
return result ? 0 : -1; return result ? 0 : -1;
} }
SWIGINTERN PyObject* SWIGINTERN PyObject *
pyswig_static_getter_closure (PyObject *obj, void *closure) pyswig_static_getter_closure(PyObject *obj, void *closure) {
{
if (!closure) if (!closure)
return SWIG_Py_Void(); return SWIG_Py_Void();
SwigPyGetSet *getset = (SwigPyGetSet*) closure; SwigPyGetSet *getset = (SwigPyGetSet *)closure;
if (!getset->get) if (!getset->get)
return SWIG_Py_Void(); return SWIG_Py_Void();
PyObject *tuple = PyTuple_New(0); PyObject *tuple = PyTuple_New(0);
@ -287,13 +265,12 @@ pyswig_static_getter_closure (PyObject *obj, void *closure)
} }
SWIGINTERN int SWIGINTERN int
pyswig_static_setter_closure (PyObject *obj, PyObject *val, void *closure) pyswig_static_setter_closure(PyObject *obj, PyObject *val, void *closure) {
{
if (!closure) { if (!closure) {
PyErr_Format(PyExc_TypeError, "Missing getset closure"); PyErr_Format(PyExc_TypeError, "Missing getset closure");
return -1; return -1;
} }
SwigPyGetSet *getset = (SwigPyGetSet*) closure; SwigPyGetSet *getset = (SwigPyGetSet *)closure;
if (!getset->set) { if (!getset->set) {
PyErr_Format(PyExc_TypeError, "Illegal static variable assignment."); PyErr_Format(PyExc_TypeError, "Illegal static variable assignment.");
return -1; return -1;
@ -309,8 +286,7 @@ pyswig_static_setter_closure (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);
@ -318,61 +294,43 @@ SwigPyStaticVar_dealloc(PyDescrObject *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 return PyUnicode_FromFormat("<class attribute '%U' of type '%s'>", descr->d_name, descr->d_type->tp_name);
("<class attribute '%U' of type '%s'>",
descr->d_name, descr->d_type->tp_name);
#else #else
return PyString_FromFormat return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(descr->d_name), descr->d_type->tp_name);
("<class attribute '%s' of type '%s'>",
PyString_AsString(descr->d_name), descr->d_type->tp_name);
#endif #endif
} }
SWIGINTERN int SWIGINTERN int
SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) {
{
PyDescrObject *descr = (PyDescrObject *)self; PyDescrObject *descr = (PyDescrObject *)self;
Py_VISIT(descr->d_type); Py_VISIT(descr->d_type);
return 0; return 0;
} }
SWIGINTERN PyObject * SWIGINTERN PyObject *
SwigPyStaticVar_get (PyGetSetDescrObject *descr, PyObject *obj, PyObject *type) SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type) {
{
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, PyErr_Format(PyExc_AttributeError, "attribute '%.300U' of '%.100s' objects is not readable", descr->d_name, descr->d_type->tp_name);
"attribute '%.300U' of '%.100s' objects is not readable",
descr->d_name, descr->d_type->tp_name);
#else #else
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
"attribute '%.300s' of '%.100s' objects is not readable",
PyString_AsString(descr->d_name), descr->d_type->tp_name);
#endif #endif
return NULL; return NULL;
} }
SWIGINTERN int SWIGINTERN int
SwigPyStaticVar_set (PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) {
{
int res; int res;
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, PyErr_Format(PyExc_AttributeError, "attribute '%.300U' of '%.100s' objects is not writable", descr->d_name, descr->d_type->tp_name);
"attribute '%.300U' of '%.100s' objects is not writable",
descr->d_name,
descr->d_type->tp_name);
#else #else
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
"attribute '%.300s' of '%.100s' objects is not writable",
PyString_AsString(descr->d_name),
descr->d_type->tp_name);
#endif #endif
return -1; return -1;
} }
@ -420,42 +378,32 @@ SWIGINTERN PyTypeObject SwigPyStaticVar_Type = {
}; };
SWIGINTERN int SWIGINTERN int
SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) {
{
PyObject *attribute = _PyType_Lookup(type, name); PyObject *attribute = _PyType_Lookup(type, name);
if (attribute != NULL) { if (attribute != NULL) {
/* Implement descriptor functionality, if any */ /* Implement descriptor functionality, if any */
descrsetfunc local_set = attribute->ob_type->tp_descr_set; descrsetfunc local_set = attribute->ob_type->tp_descr_set;
if (local_set != NULL) if (local_set != NULL)
return local_set(attribute, (PyObject*) type, value); return local_set(attribute, (PyObject *)type, value);
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400U'", type->tp_name, name);
"cannot modify read-only attribute '%.50s.%.400U'",
type->tp_name, name);
#else #else
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name));
"cannot modify read-only attribute '%.50s.%.400s'",
type->tp_name, PyString_AS_STRING(name));
#endif #endif
} else { } else {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400U'", type->tp_name, name);
"type '%.50s' has no attribute '%.400U'",
type->tp_name, name);
#else #else
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name));
"type '%.50s' has no attribute '%.400s'",
type->tp_name, PyString_AS_STRING(name));
#endif #endif
} }
return -1; return -1;
} }
SWIGINTERN PyGetSetDescrObject* SWIGINTERN PyGetSetDescrObject *
SwigPyStaticVar_new_getset (PyTypeObject *type, PyGetSetDef *getset) SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
{ PyGetSetDescrObject *descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&SwigPyStaticVar_Type, 0);
PyGetSetDescrObject *descr = (PyGetSetDescrObject*) PyType_GenericAlloc(&SwigPyStaticVar_Type, 0);
assert(descr); assert(descr);
Py_XINCREF(type); Py_XINCREF(type);
descr->d_type = type; descr->d_type = type;
@ -473,25 +421,23 @@ SwigPyStaticVar_new_getset (PyTypeObject *type, PyGetSetDef *getset)
#include <vector> #include <vector>
SWIGINTERN void SWIGINTERN void
pyswig_builtin_init_bases (PyTypeObject *type, std::vector<PyTypeObject*>& bases) pyswig_builtin_init_bases(PyTypeObject *type, std::vector<PyTypeObject *> &bases) {
{
if (!bases.size()) if (!bases.size())
bases.push_back(SwigPyObject_type()); bases.push_back(SwigPyObject_type());
type->tp_base = bases[0]; type->tp_base = bases[0];
Py_INCREF((PyObject*) bases[0]); Py_INCREF((PyObject *)bases[0]);
PyObject *tuple = PyTuple_New(bases.size()); PyObject *tuple = PyTuple_New(bases.size());
int i; int i;
for (i = 0; i < bases.size(); ++i) { for (i = 0; i < bases.size(); ++i) {
PyTuple_SET_ITEM(tuple, i, (PyObject*) bases[i]); PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]);
Py_INCREF((PyObject*) bases[i]); Py_INCREF((PyObject *)bases[i]);
} }
type->tp_bases = tuple; type->tp_bases = tuple;
} }
SWIGINTERN PyObject* SWIGINTERN PyObject *
pyswig_this_closure (PyObject *self, void *closure) pyswig_this_closure(PyObject *self, void *closure) {
{ PyObject *result = (PyObject *)SWIG_Python_GetSwigThis(self);
PyObject *result = (PyObject*) SWIG_Python_GetSwigThis(self);
Py_XINCREF(result); Py_XINCREF(result);
return result; return result;
} }

View file

@ -461,12 +461,13 @@ namespace Swig {
} }
template <typename _Tp> template <typename _Tp>
static PyObject* pyobj_disown (PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args)) static PyObject* pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args))
{ {
SwigPyObject *sobj = (SwigPyObject *) pyobj; SwigPyObject *sobj = (SwigPyObject *)pyobj;
sobj->own = 0; sobj->own = 0;
Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<_Tp*>(sobj->ptr)); Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<_Tp *>(sobj->ptr));
if (d) d->swig_disown(); if (d)
d->swig_disown();
return PyWeakref_NewProxy(pyobj, NULL); return PyWeakref_NewProxy(pyobj, NULL);
} }

View file

@ -352,7 +352,7 @@ SWIG_init(void) {
// metatype is used to implement static member variables. // metatype is used to implement static member variables.
PyObject *metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); PyObject *metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
assert(metatype_args); assert(metatype_args);
PyTypeObject *metatype = (PyTypeObject*) PyType_Type.tp_call((PyObject*) &PyType_Type, metatype_args, NULL); PyTypeObject *metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL);
assert(metatype); assert(metatype);
Py_DECREF(metatype_args); Py_DECREF(metatype_args);
metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;
@ -386,7 +386,7 @@ SWIG_init(void) {
// All objects have a 'this' attribute // All objects have a 'this' attribute
static PyGetSetDef this_getset_def = { static PyGetSetDef this_getset_def = {
const_cast<char*>("this"), pyswig_this_closure, NULL, NULL, NULL const_cast<char *>("this"), pyswig_this_closure, NULL, NULL, NULL
}; };
PyObject *this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); PyObject *this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);

View file

@ -74,7 +74,7 @@ SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
#if defined(SWIGPYTHON_BUILTIN) #if defined(SWIGPYTHON_BUILTIN)
SWIGINTERN void SWIGINTERN void
pyswig_add_public_symbol (PyObject *seq, const char *key) { pyswig_add_public_symbol(PyObject *seq, const char *key) {
PyObject *s = PyString_InternFromString(key); PyObject *s = PyString_InternFromString(key);
PyList_Append(seq, s); PyList_Append(seq, s);
Py_DECREF(s); Py_DECREF(s);
@ -82,7 +82,7 @@ pyswig_add_public_symbol (PyObject *seq, const char *key) {
SWIGINTERN void SWIGINTERN void
SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
PyDict_SetItemString(d, (char*) name, obj); PyDict_SetItemString(d, (char *)name, obj);
Py_DECREF(obj); Py_DECREF(obj);
if (public_interface) if (public_interface)
pyswig_add_public_symbol(public_interface, name); pyswig_add_public_symbol(public_interface, name);
@ -92,7 +92,7 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam
SWIGINTERN void SWIGINTERN void
SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
PyDict_SetItemString(d, (char*) name, obj); PyDict_SetItemString(d, (char *)name, obj);
Py_DECREF(obj); Py_DECREF(obj);
} }
@ -338,8 +338,7 @@ SwigPyClientData_New(PyObject* obj)
} }
SWIGRUNTIME void SWIGRUNTIME void
SwigPyClientData_Del(SwigPyClientData* data) SwigPyClientData_Del(SwigPyClientData *data) {
{
Py_XDECREF(data->newraw); Py_XDECREF(data->newraw);
Py_XDECREF(data->newargs); Py_XDECREF(data->newargs);
Py_XDECREF(data->destroy); Py_XDECREF(data->destroy);
@ -1127,28 +1126,6 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK; return SWIG_OK;
} }
/*
if (ty && ty->clientdata && ((SwigPyClientData*) ty->clientdata)->pytype) {
PyTypeObject *target_tp = ((SwigPyClientData*) ty->clientdata)->pytype;
SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
for (; sobj; sobj = (SwigPyObject*) sobj->next) {
if (!sobj->ty->clientdata)
continue;
PyTypeObject *candidate_tp = ((SwigPyClientData*) sobj->ty->clientdata)->pytype;
if (candidate_tp && PyType_IsSubtype(candidate_tp, target_tp)) {
if (own)
*own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN)
sobj->own = 0;
if (ptr)
*ptr = sobj->ptr;
return SWIG_OK;
}
}
return SWIG_ERROR;
}
*/
int res = SWIG_ERROR; int res = SWIG_ERROR;
SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
@ -1444,12 +1421,12 @@ SWIG_Python_NewBuiltinObj(PyObject *self, void *ptr, swig_type_info *type, int f
assert(clientdata); assert(clientdata);
assert(clientdata->pytype); assert(clientdata->pytype);
int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
SwigPyObject *newobj = (SwigPyObject*) self; SwigPyObject *newobj = (SwigPyObject *)self;
if (newobj->ptr) { if (newobj->ptr) {
PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
while (newobj->next) newobj = (SwigPyObject*) newobj->next; while (newobj->next) newobj = (SwigPyObject *)newobj->next;
newobj->next = next_self; newobj->next = next_self;
newobj = (SwigPyObject*) next_self; newobj = (SwigPyObject *)next_self;
} }
newobj->ptr = ptr; newobj->ptr = ptr;
newobj->own = own; newobj->own = own;
@ -1696,8 +1673,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
// Cribbed from Objects/object.c in the python source code and modified // Cribbed from Objects/object.c in the python source code and modified
SWIGRUNTIME int SWIGRUNTIME int
SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
{
PyTypeObject *tp = obj->ob_type; PyTypeObject *tp = obj->ob_type;
PyObject *descr; PyObject *descr;
descrsetfunc f; descrsetfunc f;
@ -1706,21 +1682,19 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value)
#ifdef Py_USING_UNICODE #ifdef Py_USING_UNICODE
if (PyString_Check(name)) { if (PyString_Check(name)) {
name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
if (name == NULL) if (!name)
return -1; return -1;
} else if (!PyUnicode_Check(name)) { } else if (!PyUnicode_Check(name)) {
#else #else
if (!PyString_Check(name)) { if (!PyString_Check(name)) {
#endif #endif
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
"attribute name must be string, not '%.200s'",
name->ob_type->tp_name);
return -1; return -1;
} else { } else {
Py_INCREF(name); Py_INCREF(name);
} }
if (tp->tp_dict == NULL) { if (!tp->tp_dict) {
if (PyType_Ready(tp) < 0) if (PyType_Ready(tp) < 0)
goto done; goto done;
} }
@ -1729,7 +1703,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value)
f = NULL; f = NULL;
if (descr != NULL) if (descr != NULL)
f = descr->ob_type->tp_descr_set; f = descr->ob_type->tp_descr_set;
if (f == NULL) { if (!f) {
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
#ifdef Py_USING_UNICODE #ifdef Py_USING_UNICODE
"'%.100s' object has no attribute '%.200U'", "'%.100s' object has no attribute '%.200U'",
@ -1741,7 +1715,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value)
res = f(descr, obj, value); res = f(descr, obj, value);
} }
done: done:
Py_DECREF(name); Py_DECREF(name);
return res; return res;
} }

View file

@ -10,5 +10,4 @@
%insert(runtime) "pythreads.swg"; /* Python thread code */ %insert(runtime) "pythreads.swg"; /* Python thread code */
%insert(runtime) "pyapi.swg"; /* Python API */ %insert(runtime) "pyapi.swg"; /* Python API */
%insert(runtime) "pyrun.swg"; /* Python run-time code */ %insert(runtime) "pyrun.swg"; /* Python run-time code */
%insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */ %insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */

View file

@ -240,9 +240,11 @@ public:
} }
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Thread Implementation * Thread Implementation
* ------------------------------------------------------------ */ int threads_enable(Node *n) const { * ------------------------------------------------------------ */
int threads_enable(Node *n) const {
return threads && !GetFlagAttr(n, "feature:nothread"); return threads && !GetFlagAttr(n, "feature:nothread");
} }
int initialize_threads(String *f_init) { int initialize_threads(String *f_init) {
if (!threads) { if (!threads) {
return SWIG_OK; return SWIG_OK;
@ -510,7 +512,7 @@ public:
} }
} }
} /* for */ }
if (py3) { if (py3) {
/* force disable features that not compatible with Python 3.x */ /* force disable features that not compatible with Python 3.x */
@ -882,11 +884,11 @@ public:
* But don't sure wether this would broken old Python? * But don't sure wether this would broken old Python?
*/ */
Printv(f_shadow, Printv(f_shadow,
// "import types\n", // "import types\n",
"try:\n", "try:\n",
// " _object = types.ObjectType\n", // " _object = types.ObjectType\n",
" _object = object\n", " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", " _object = object\n", " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
// "del types\n", // "del types\n",
"\n\n", NIL); "\n\n", NIL);
} }
} }
@ -995,8 +997,6 @@ public:
} }
Dump(f_wrappers, f_begin); Dump(f_wrappers, f_begin);
//if (builtin)
//Dump(f_builtins, f_begin);
Wrapper_pretty_print(f_init, f_begin); Wrapper_pretty_print(f_init, f_begin);
Delete(f_header); Delete(f_header);
@ -3186,7 +3186,7 @@ public:
String *mname = SwigType_manglestr(rname); String *mname = SwigType_manglestr(rname);
Printf(f_init, "\n// type '%s'\n", rname); Printf(f_init, "\n// type '%s'\n", rname);
Printf(f_init, " builtin_pytype = (PyTypeObject*) &SwigPyBuiltin_%s_type;\n", mname); Printf(f_init, " builtin_pytype = (PyTypeObject *)&SwigPyBuiltin_%s_type;\n", mname);
Printf(f_init, " builtin_pytype->tp_dict = d = PyDict_New();\n"); Printf(f_init, " builtin_pytype->tp_dict = d = PyDict_New();\n");
Delete(rname); Delete(rname);
@ -3277,9 +3277,8 @@ public:
// Rich compare function // Rich compare function
Hash *richcompare = Getattr(n, "richcompare"); Hash *richcompare = Getattr(n, "richcompare");
assert(richcompare); assert(richcompare);
Printf(f, "SWIGINTERN PyObject*\n"); Printf(f, "SWIGINTERN PyObject *\n");
Printf(f, "%s_richcompare (PyObject *self, PyObject *other, int op)\n", templ); Printf(f, "%s_richcompare(PyObject *self, PyObject *other, int op) {\n", templ);
Printf(f, "{\n");
Printf(f, " PyObject *result = NULL;\n"); Printf(f, " PyObject *result = NULL;\n");
if (!funpack) { if (!funpack) {
Printf(f, " PyObject *tuple = PyTuple_New(1);\n"); Printf(f, " PyObject *tuple = PyTuple_New(1);\n");
@ -3292,9 +3291,9 @@ public:
Printf(f, " case %s : result = %s(self, %s); break;\n", i.key, i.item, funpack ? "other" : "tuple"); Printf(f, " case %s : result = %s(self, %s); break;\n", i.key, i.item, funpack ? "other" : "tuple");
Printv(f, " default : break;\n", NIL); Printv(f, " default : break;\n", NIL);
Printf(f, " }\n"); Printf(f, " }\n");
Printv(f, " if (result == NULL) {\n", NIL); Printv(f, " if (!result) {\n", NIL);
Printv(f, " if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) {\n", NIL); Printv(f, " if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) {\n", NIL);
Printv(f, " result = SwigPyObject_richcompare((SwigPyObject*) self, (SwigPyObject*) other, op);\n", NIL); Printv(f, " result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op);\n", NIL);
Printv(f, " } else {\n", NIL); Printv(f, " } else {\n", NIL);
Printv(f, " result = Py_NotImplemented;\n", NIL); Printv(f, " result = Py_NotImplemented;\n", NIL);
Printv(f, " Py_INCREF(result);\n", NIL); Printv(f, " Py_INCREF(result);\n", NIL);
@ -3502,7 +3501,7 @@ public:
Printf(clientdata_klass, "(PyObject*) &%s_type", templ); Printf(clientdata_klass, "(PyObject*) &%s_type", templ);
} }
Printf(f, "SWIGINTERN SwigPyClientData %s_clientdata = {%s, 0, 0, 0, 0, 0, (PyTypeObject*) &%s_type};\n\n", templ, clientdata_klass, templ); Printf(f, "SWIGINTERN SwigPyClientData %s_clientdata = {%s, 0, 0, 0, 0, 0, (PyTypeObject *)&%s_type};\n\n", templ, clientdata_klass, templ);
Printv(f_init, " if (PyType_Ready(builtin_pytype) < 0) {\n", NIL); Printv(f_init, " if (PyType_Ready(builtin_pytype) < 0) {\n", NIL);
Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Couldn't create type '%s'\");\n", symname); Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Couldn't create type '%s'\");\n", symname);