CastXML / pygccxml

pygccxml is a specialized XML reader that reads the output from CastXML or GCCXML. It provides a simple framework to navigate C++ declarations, using Python classes.
Boost Software License 1.0
129 stars 44 forks source link

Exception: Demangled name is not available with CastXML. #93

Closed dodgyville closed 5 years ago

dodgyville commented 6 years ago

Hi, great project!

On ubuntu 16.10 and python3 using castxml (gccxml no longer compiles) I can't generate bindings from a header file due to this error:


INFO Parsing source file "my-module.h" ... 
Traceback (most recent call last):
  File "generate.py", line 25, in <module>
    my_module_gen()
  File "generate.py", line 18, in my_module_gen
    module = module_parser.parse([f])

  File "/usr/local/lib/python3.5/dist-packages/pybindgen/gccxmlparser.py", line 602, in parse
    self.scan_functions()

  File "/usr/local/lib/python3.5/dist-packages/pybindgen/gccxmlparser.py", line 2077, in scan_functions
    self._scan_namespace_functions(self.module, self.module_namespace)

  File "/usr/local/lib/python3.5/dist-packages/pybindgen/gccxmlparser.py", line 2216, in _scan_namespace_functions
    if templates.is_instantiation(fun.demangled_name):

  File "/usr/lib/python3/dist-packages/pygccxml/declarations/calldef.py", line 396, in demangled_name
    raise Exception("Demangled name is not available with CastXML.")
Exception: Demangled name is not available with CastXML.

my-module.h contains the following line from the tutorial:

void MyModuleDoAction (void);

and my call to the parser is:

   f = "my-module.h"

    module_parser = ModuleParser('a1', '::')

    module = module_parser.parse([f])

    module.add_include('"%s"'%f)

I also had to manually force self.gccxml_config.xml_generator_path = "/usr/bin/castxml"

As it looks like find_xml_generator is not called anywhere in pygccxml.

BenNewton commented 5 years ago

Did you ever figure this out?

iMichka commented 5 years ago

Hi. Sorry I did not answer before. The bug is not in pygccxml, but in pybindgen. They maybe fixed it since then?

You can not access fun.demangled_name, this is not available anymore with the newer version of pygccxml and castxml. You could try using fun.name instead in pybindgen.