How to wrap a container of custom type?

Asked by yesint

I'm trying to wrap the container

std::vector<Eigen::Vector3f>

Currently I have the following custom converters:

class Vector3fParam(Parameter):
    DIRECTIONS = [Parameter.DIRECTION_IN, Parameter.DIRECTION_OUT]
    CTYPES = ['Eigen::Vector3f&']
   def convert_python_to_c(self, wrapper):
      ...

class Vector3fReturn(ReturnValue):
    CTYPES = ['Eigen::Vector3f']
    def convert_c_to_python(self, wrapper):
       ...

This is enough to wrap my methods, which take Vector3f or return it, but obviously it's not enough for container since I'm getting an error when executing
mod.add_container('std::vector<Eigen::Vector3f>', 'Eigen::Vector3f', 'vector') :

Traceback (most recent call last):
  File "./generate.py", line 358, in <module>
    mod.generate(FileCodeSink(open('bindings.cpp','w')))
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/module.py", line 928, in generate
    self.do_generate(sink_manager, module_file_base_name)
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/module.py", line 777, in do_generate
    container.generate(sink, self)
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/container.py", line 372, in generate
    self._generate_container_constructor(code_sink)
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/container.py", line 513, in _generate_container_constructor
    item_python_to_c_converter = self.module.get_root().generate_python_to_c_type_converter(self.value_type, code_sink)
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/module.py", line 956, in generate_python_to_c_type_converter
    converter_function_name = self.get_python_to_c_type_converter_function_name(value_type)
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/module.py", line 937, in get_python_to_c_type_converter_function_name
    mangled_ctype = utils.mangle_name(ctype)
  File "/usr/local/lib/python2.7/dist-packages/pybindgen/utils.py", line 146, in mangle_name
    s = name.replace('<', '__lt__').replace('>', '__gt__').replace(',', '_')
AttributeError: 'CType' object has no attribute 'replace'

Could you please tell me which converters I need to add in order to wrap the container? Is there anything special except the converter, which I have to do?

Thank you in advance!

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
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
yesint (yesint4) said :
#2

Bump

Revision history for this message
Gustavo Carneiro (gjc) said :
#3

This looks to be a bug in pybindgen. I pushed a possible bug fix to trunk.

Can you help with this problem?

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

To post a message you must log in.