LLNL / shroud

Shroud: generate Fortran and Python wrappers for C and C++ libraries
BSD 3-Clause "New" or "Revised" License
90 stars 7 forks source link

Add support for type templates with multiple arguments #357

Closed ltaylor16 closed 4 months ago

ltaylor16 commented 4 months ago

Fixed lots of places that assumed one template argument that were used by std::vector. Remove explicit checks for type vector.

Use a modified abstract declarator in the statements names. This uses a shorter name which maps more directly to the C++ declaration. Eliminate explicit use of scalar.

- f_function_vector_scalar_cdesc_allocatable_targ_native_scalar
+ f_function_vector<native>_cdesc_allocatable

Otherwise, multiple template arguments would become unwieldy:

usertype<int,int>

would become:

- f_function_shadow_scalar_cdesc_allocatable_targ_native_scalar_targ_native_scalar
+ f_function_shadow<native,native>_cdesc_allocatable

Add option.typemap_sgroup to set the Typemap.sgroup field for a class/struct which allows control of which statements are used to create the wrapper. This allows a user to create custom wrappers similar to the way std::vector is wrapped. See example in sgroup.yaml.

Add format field targs to allow access to template arguments typemaps. ex {targs[0].cxx_type}. Before the first template argument replaced the arguments typemap. This worked for std::vector.