diff --git a/CHANGES.current b/CHANGES.current index 503553f33..f7bdb9dae 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-20 szager + [python] Fix closure for tp_call slot. + 2011-07-16: wsfulton [python] Fix director typemap using PyObject *. diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 97150dc5c..d8164777f 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -39,6 +39,8 @@ wrapper##_closure(PyObject *a, PyObject *b) { \ return result; \ } +typedef ternaryfunc ternarycallfunc; + #define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ @@ -54,6 +56,12 @@ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ 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) { \ @@ -498,3 +506,4 @@ SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) #ifdef __cplusplus } #endif + diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index d84d740f4..ecbe7834e 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -123,7 +123,7 @@ %rename(__invert__) *::operator~; %feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~; %rename(__call__) *::operator(); -%feature("python:slot", "tp_call", functype="ternaryfunc") *::operator(); +%feature("python:slot", "tp_call", functype="ternarycallfunc") *::operator(); #if defined(SWIGPYTHON_BUILTIN) %pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3024e299d..43cfcaed9 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -190,6 +190,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) { "getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE", "binaryfunc", "SWIGPY_BINARYFUNC_CLOSURE", "ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE", + "ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE", "lenfunc", "SWIGPY_LENFUNC_CLOSURE", "ssizeargfunc", "SWIGPY_SSIZEARGFUNC_CLOSURE", "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", @@ -208,6 +209,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) { "inquiry", "SWIGPY_INQUIRY_CLOSURE", "getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE", "ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE", + "ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE", "lenfunc", "SWIGPY_LENFUNC_CLOSURE", "ssizeargfunc", "SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE", "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE",