autowrap icon indicating copy to clipboard operation
autowrap copied to clipboard

[autowrap 0.6.1] using "const" keyword gives errors

Open Eliasvan opened this issue 9 years ago • 1 comments

Tested with commit d0e9a5 (Feb 9, 2015). Usage of "const" causes autowrap to raise an exception.

Test code:

cdef extern from "<string>" namespace "std":
    cdef cppclass string:
        string()
        const char* c_str()

Autowrap raises following exception:

Traceback (most recent call last):
File "/usr/bin/autowrap", line 9, in <module>
    load_entry_point('autowrap==0.6.0', 'console_scripts', 'autowrap')()
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 67, in main
    _main(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 121, in _main
    run(pxds, addons, converters, out)
File "/usr/lib/python2.7/site-packages/autowrap/Main.py", line 200, in run
    decls, instance_map = autowrap.parse(pxds, ".")
File "/usr/lib/python2.7/site-packages/autowrap/__init__.py", line 51, in parse
    return DeclResolver.resolve_decls_from_files(files, root)
File "/usr/lib/python2.7/site-packages/autowrap/DeclResolver.py", line 171, in resolve_decls_from_files
    decls.extend(PXDParser.parse_pxd_file(full_path))
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 461, in parse_pxd_file
    result.append(handler(body, lines, path))
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 264, in parseTree
    decl = MethodOrAttributeDecl.parseTree(att, lines, pxd_path)
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 348, in parseTree
    result_type = _extract_type(node.base_type, decl)
File "/usr/lib/python2.7/site-packages/autowrap/PXDParser.py", line 188, in _extract_type
    return CppType(base_type.name, template_parameters, is_ptr, is_ref, is_unsigned, is_long, is_const=is_const)
AttributeError: 'CConstTypeNode' object has no attribute 'name'

Omitting the "const" keyword solves the problem, however, then it doesn't follow the exact C definition.

Eliasvan avatar May 05 '15 14:05 Eliasvan

this is a known issue with autowrap but since there are no "const" objects in Python, leaving out the const keyword does not change much in practice

hroest avatar Jul 11 '16 19:07 hroest