wxWidgets/wxPython/wxSWIG/swig_lib/python/defarg.swg
Robin Dunn c90f71dd8c Since I have made several changes to SWIG over the years to accomodate
special cases and other things in wxPython, and since I plan on making
several more, I've decided to put the SWIG sources in wxPython's CVS
instead of relying on maintaining patches.  This effectivly becomes a
fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
doesn't have some things I rely on in 1.1, not to mention that my
custom patches would all have to be redone, I felt that this is the
easier road to take.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-04-29 19:56:57 +00:00

37 lines
1.1 KiB
Plaintext

/* This file defines an internal function for processing default arguments
with shadow classes.
There seems to be no straightforward way to write a shadow functions
involving default arguments. For example :
def foo(arg1,arg2,*args):
shadowc.foo(arg1,arg2,args)
This fails because args is now a tuple and SWIG doesn't know what to
do with it.
This file allows a different approach :
def foo(arg1,arg2,*args):
shadowc.__call_defarg(shadowc.foo,(arg1,arg2,)+args)
Basically, we form a new tuple from the object, call this special
__call_defarg method and it passes control to the real wrapper function.
An ugly hack, but it works.
*/
static PyObject *swig_call_defargs(PyObject *self, PyObject *args) {
PyObject *func;
PyObject *parms;
if (!PyArg_ParseTuple(args,"OO",&func,&parms))
return NULL;
if (!PyCallable_Check(func)) {
PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!");
return NULL;
}
return PyEval_CallObject(func,parms);
}