Chaste / cppwg

An automatic Python wrapper generator for C++ code.
BSD 3-Clause "New" or "Revised" License
45 stars 8 forks source link

Bug: Instantiation of a single template type breaks writing of wrapped code #2

Closed josephsnyder closed 6 months ago

josephsnyder commented 4 years ago

Hello! The following is a set of steps to reproduce the error of a bug in the writing of the wrapped code that can be reproduced in the "shapes" directory within the repository. The "wrapper_header_collection" template instantiations are not created when the total number of template replacements per substitution is 1.

Steps to reproduce: rm -rf shapes/src/primatives Alter shapes/wrapper/package_info.yaml to match the following diff:

diff --git a/shapes/wrapper/package_info.yaml b/shapes/wrapper/package_info.yaml index f1cace8..d66268d 100644 --- a/shapes/wrapper/package_info.yaml +++ b/shapes/wrapper/package_info.yaml @@ -2,7 +2,7 @@ name: pyshapes # Unique name prepended to all modules smart_ptr_type: std::shared_ptr template_substitutions:

  • signature:

    • replacement: [[2], [3]]
    • replacement: [[2]]

    modules:

    • name: math_funcs # Name of the module @@ -13,9 +13,3 @@ modules: source_locations: classes:
  • name: Point -- name: primitives
    • source_locations:
    • classes:
      • name: Shape
      • name: Cuboid
      • name: Rectangle

The run of cppwg

python3 wrapper/generate.py --source_root ~/Work/TRI/cppwg/shapes --wrapper_root ~/Work/TRI/cppwg/shapes/wrapper/ --castxml_binary ~/Work/TRI/CastXML/build/bin/castxml --package_info ~/Work/TRI/cppwg/shapes/wrapper/package_info.yaml --includes ~/Work/TRI/cppwg/shapes/src/

reports the following error:

> INFO: Cleaning Decls > INFO: Optimizing Decls > Generating Wrapper Code for: math_funcs Module. > Generating Wrapper Code for: geometry Module. > Generating Wrapper Code for: Point Class. > Traceback (most recent call last): > File "wrapper/generate.py", line 45, in > args.package_info, all_includes) > File "wrapper/generate.py", line 21, in generate_wrapper_code > generator.generate_wrapper() > File "/home/softhat/Work/TRI/cppwg/cppwg/generators.py", line 200, in generate_wrapper > module_writer.write() > File "/home/softhat/Work/TRI/cppwg/cppwg/writers/module_writer.py", line 112, in write > class_decl = self.source_ns.class_(fullName.replace(" ","")) > File "/home/softhat/.local/lib/python3.6/site-packages/pygccxml/declarations/scopedef.py", line 574, in class_ > recursive=recursive) > File "/home/softhat/.local/lib/python3.6/site-packages/pygccxml/declarations/scopedef.py", line 484, in _find_single > found = matcher.get_single(decl_matcher, decls, False) > File "/home/softhat/.local/lib/python3.6/site-packages/pygccxml/declarations/scopedef.py", line 87, in get_single > raise runtime_errors.declaration_not_found_t(decl_matcher) > pygccxml.declarations.runtime_errors.declaration_not_found_t: Unable to find declaration. Matcher: [(decl type==class_t) and (name==Point< 2 >)] Thank you for making this code available!