Incorrect generation of Python code for a C++ method with >1 PyObject* argument
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Hello, people
We were developing a new feature in our company that required us to bind a VTK actor developed in C++ to our Python code. One of the methods in our VTK actor is similar to one below:
void SetSomething(
PyObject *a1,
PyObject *a2,
PyObject *a3,
PyObject *a4
);
However the generated Python binding code ended up incorrect. The generated code for function in question looked like this:
static PyObject *
PyvtkMyActor_SetSomething(PyObject *self, PyObject *args)
{
vtkPythonArgs ap(self, args, "SetSomething");
vtkObjectBase *vp = ap.GetSelfPointer(self, args);
vtkMyActor *op = static_cast<vtkMyActor *>(vp);
PyObject *temp0 = NULL;
PyObject *result = NULL;
if (op && ap.CheckArgCount(4) &&
ap.GetPythonObject(temp0) &&
ap.GetPythonObject(temp1) &&
ap.GetPythonObject(temp2) &&
ap.GetPythonObject(temp3))
{
if (ap.IsBound())
{
op->SetSomething(temp0, temp1, temp2, temp3);
}
else
{
op->vtkMyActor::SetSomething(temp0, temp1, temp2, temp3);
}
if (!ap.ErrorOccurred())
{
result = ap.BuildNone();
}
}
return result;
}
Notice the missing declaration of variables temp1, temp2 and temp3, which correspond to 2nd through 4th arguments. Curiously the rest of method counts and notices the number of arguments correctly.
We looked around VTK source code and the problem seems to be the break statement in line 92 of vtkWrapPython_DeclareVariables method of vtkWrapPythonMethod.c file. It looks like it should be a continue, as it should not prevent further arguments from being declared just because a PyObject argument was found.
If you need further information to reproduce, let me know.