add_function_as_method error: list index out of range

Asked by Chadrik

i'm wrapping someone else's API and unfortunately, instead of a normal class constructor, they provide a function for creating a new class instance. it looks something like this:

    class VoxelFlowBase {
       ...
    };

    VoxelFlowBase* CreateVoxelFlow();

i'm trying to use 'add_function_as_method', to make 'CreateVoxelFlow' into the __init__ method of VoxelFlowBase:

    VoxelFlowBase.add_function_as_method('CreateVoxelFlow',
          retval('VoxelFlowBase *', caller_owns_return=True),
          [],
          custom_name='__init__')

i get this error:

Traceback (most recent call last):
  File "./voxelflowgen.py", line 32, in <module>
    custom_name='__init__')
  File "/usr/local/python-2.5.1/lib/python2.5/site-packages/pybindgen/cppclass.py", line 1401, in add_function_as_method
    self._add_method_obj(meth)
  File "/usr/local/python-2.5.1/lib/python2.5/site-packages/pybindgen/cppclass.py", line 1253, in _add_method_obj
    assert isinstance(method.parameters[0], CppClassParameterBase)
IndexError: list index out of range

i think that pybindgen assumes that the function should take a pointer or reference to the class as its first argument. what is the best way to add this function as a constructor/__init__ method?

-chad

Question information

Language:
English Edit question
Status:
Answered
For:
PyBindGen Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Gustavo Carneiro (gjc) said :
#1

Can you help with this problem?

Provide an answer of your own, or ask Chadrik for more information if necessary.

To post a message you must log in.