From: sehmann <se...@gm...> - 2013-04-19 20:28:25
|
Below I have included some code for reference. With SWIG 2.0.9 Issue 1) performance concern about having an additional function layer here + doing tuple manipulation Issue 2) the second PyTuple_GetSlice has a +1 for the last argument -- seems wrong Issue 3) $input is not mapped to the "varargs" variable, it is mapped to "self" Can someone concur with me so I can confidently file a bug against SWIG for these? This is the typemap and the static method I am wrapping: %typemap(in) (...) (ArgList al) { for (int j = 0; j < PyTuple_Size($input); ++j) { // TODO what if this fails to convert? boost::shared_ptr<Arg> a; if (ConvertPythonObjToValue(PyTuple_GetItem($input, j), a)) { al.push_back(a); } } $1 = &al; } class ConfigReader { public: static void writeYaml(...); }; This is the generated code: SWIGINTERN PyObject *_wrap_ConfigReader_writeYaml__varargs__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) { PyObject *resultobj = 0; void *arg1 = 0 ; ArgList al1 ; if(!PyArg_UnpackTuple(args,(char *)"ConfigReader_writeYaml",0,1)) SWIG_fail; { for (int j = 0; j < PyTuple_Size(self); ++j) { // TODO what if this fails to convert? boost::shared_ptr<Arg> a; if (ConvertPythonObjToValue(PyTuple_GetItem(self, j), a)) { al1.push_back(a); } } arg1 = &al1; } { try { ConfigReader::writeYaml(arg1); } catch( std::runtime_error& e ) { PyErr_SetString(PyExc_RuntimeError, e.what()); return NULL; } } resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_ConfigReader_writeYaml(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj; PyObject *varargs; PyObject *newargs; newargs = PyTuple_GetSlice(args,0,0); varargs = PyTuple_GetSlice(args,0,PyTuple_Size(args)+1); resultobj = _wrap_ConfigReader_writeYaml__varargs__(NULL,newargs,varargs); Py_XDECREF(newargs); Py_XDECREF(varargs); return resultobj; } -- View this message in context: http://swig.10945.n7.nabble.com/python-varargs-using-typemap-not-working-well-a-few-issues-tp13209.html Sent from the swig-user mailing list archive at Nabble.com. |