Releases: LLNL/shroud
Cumulative Update
Changes
-
Some generated wrapper names have been changed to be more consistent.
Added format field F_name_api. It is controlled by option
F_API_case which may be set to lower, upper, underscore or
preserve. Uses of format field underscore_name should be
changed to F_name_api. It's often used in name options such as
F_name_impl_template and F_name_generic_template.Likewise, C API names are controlled by option C_name_api. The
default is preserve. The previous behavior can be restored by
setting option C_API_case to underscore.F_API_case defaults to underscore since Fortran is case insensitive.
F_C_case defaults to preserve to make the C API closer to the C++ API. -
Changed the name of C and Python function splicer to use function_name instead
of underscore_name to correspond to C++ library names. -
The C_memory_dtor_function is now written to the utility file,
C_impl_utility. This function contains code to delete memory from
shadow classes. Previously it was written to file C_impl_filename.
In addition, some helper functions are also written into this file.
This may require changes to Makefiles to ensure this file is compiled. -
A single capsule derived type is created in the Fortran wrapper
instead of one per class. This is considered an implementation
detail and a user of the wrapper will not access them directly.
However, it may show up in splicer code. It is used to pass values
from the Fortran wrapper to the C wrapper. The old type names may
of been referenced in explicit splicer code. In that case the name
will need to be changed. The format field
F_capsule_data_type_class is replaced by F_capsule_data_type.
The C wrapper continues to create a capsule struct for each class
as a form of type safety in the C API. -
Class instance arguments which are passed by value will now pass the
shadow type by reference. This allows the addr and idtor fields to be
changed if necessary by the C wrapper. -
Replaced the additional_interfaces splicer with additional_declarations.
This new splicer is outside of an interface block and can be used to add
add a generic interface that could not be added to additional_interfaces.
Existing additional_interfaces splicers can be converted to
additional_declarations by wrapping the splicer with
INTERFACE
/END INTERFACE
.
New Features
-
Added support for C++ class inheritance.
-
Added the ability to treat a struct as a class.
-
Added the ability to declare members of a struct on
individualdecl
lines in the YAML file similar to how
class members are defined. Before the struct was defined
in a singledecl:
. -
Allow structs to be templated.
-
Added the ability to declare variables using the
enum
keyword.
C++ creates a type for each enumeration. -
Generate generic interface which allows a scalar or array to be
passed for an argument. -
Process assumed-rank dimension attribute, dimension(..).
Create a generic interface using scalar and each rank. -
Added some support for Futher Interoperability with C.
Used when option F_CFI is True (C/Fortran Interoperability). -
Support deref(pointer) for
char *
andstd::string
functions.
Requires at least gfortran 6.1.0 -
Added option F_trim_char_in. Controls where
CHARACTER
arguments
are NULL terminated. If True then terminated in Fortran else in C. -
Added attribute +blanknull to convert a blank Fortran string into
a NULL pointer instead of a 1-d buffer with'/0'
.
Used withconst char *
arguments.
This can be defaulted to True with the F_blanknull option. -
Added
file_code
dictionary to input YAML file. It contains
directives to add header file andUSE
statements into generated files.
These are collated with headers andUSE
statements added by typemaps,
statements and helpers to avoid duplication. -
Allow typemaps with base as integer and real to be added to the
input YAML file. This allows kind parameters to be defined via splicers
then used by a typemap. i.e.integer(INDEXTYPE)
-
Added option C_shadow_result. If true, the C wrapper will return a pointer
to the capsule holding the function result. The capsule is also passed
as an argument. If false the function isvoid
. -
The getter for a class member function will return a Fortran pointer if
the dimension attribute is added to the declaration.
Likewise, the setter will expect an array of the same rank as dimension.
Getter and setters will also be generated for struct fields which are pointers
to native types. Option F_struct_getter_setter can be used to control their
creation. -
Added ability to add splicer to
typedef
declarations.
For example, to use the C preprocessor to set the type of the typedef.
See typedefs.yaml for an example. -
Added support for out arguments which return a reference to a
std::vector
or pointer to an array ofstd::string
. -
Create C and Fortran wrappers for typedef statements.
Beforetypedef
was treated as an alias.typedef int TypeID
would
substituteinteger(C_INT)
for every use ofTypeID
in the Fortran wrapper.
Now a parameter is created:integer, parameter :: type_id = C_INT
.
Used as:integer(type_id) :: arg
.
Fixed
-
Order of header files in cxx_header is preserved in the generated code.
-
Create a generic interface even if only one decl is in the fortran_generic list.
-
generic_function now creates a C wrapper for each Fortran wrapper.
This causes each Fortran interface to bind to a different C function which
fixes a compile error with xlf. -
Add generic interfaces for class methods. Generic functions where only being added
to the type-bound procedures.class_generic(obj)
now works instead of only
obj%generic()
. -
Add continuations on Fortran
IMPORT
statements. -
Support an array of pointers -
void **addr+rank(1)
. -
Fix Fortran wrapper for
intent(INOUT)
forvoid **
. -
Promote wrap options (ex wrap_fortran) up to container when True
(library, class, namespace). This allows wrap_fortran to be False at
the global level and set True on a function and get a wrapper.
Before a False at the global level would never attempt to do any
wrapping. -
Better support for
std::vector
with pointer template arguments.
For examples,<const double *>
. -
Parse
class
,struct
andenum
as part of declaration.
This allowstypedef struct tag name
to be parsed properly. -
Create type table earlier in parse. This allows recursive structs such as
struct point { struct point *next; }
to be parsed. -
Fixed issues in converting function names from CamelCase
- Remove redundant underscore
Create_Cstruct_as_class
wasc_create__cstruct_as_class
nowc_create_cstruct_as_class
- Add missing underscore
AFunction
wasafunction
nowa_function
.
- Remove redundant underscore
Mangle some Fortran derived type names with C_prefix
Added
- Added std::string scalar arguments.
Fixed
- Mangle names of Fortran helper functions with C_prefix. This
fixes a conflict when two Shroud generated wrappers are used in the
same subprogram. Ideally these helpers would bePRIVATE
, but
gfortran does not allowPRIVATE
andBIND(C)
together. - Mangle names of Fortran derived types for capsules with C_prefix to avoid
name conflicts. - Correctly count Python arguments when there are default arguments.
Do not include intent(out) arguments.
Improve support for pointers as arrays
- intent(in) pointer arguments should now use attribue rank(1) instead of
dimension(:) to get an assumed-shape argument. Rank can be 1 to 7. - pointer arguments default to intent(inout) instead of intent(in).
- C++ class constructors create a generic interface in Fortran with the same name
as the derived-type name. Before it used the +name attribute in the generic name.
This attribute is still used to create the actual function name. - Expand support for pointers to references (*&)
- Add support for char ** as an array of NULL terminated strings.
- Parse (void) prototypes.
- Add FINAL clause to Fortran memory capsule to release memory at end of scope.
- Added option C_force_wrapper to create a C wrapper.
This can be used when the function is actually a macro or function pointer. - Create a setup.py file for Python Wrapper
- Add support for struct in Python.
- Both using NumPy and treating a struct as a class.
- Parse array syntax for variables and array members ([size]).
- Improve Python3 support in generated wrappers.
Wrap namespace as module
-
Better support for namespaces. Each namespace creates a module
in Fortran and Python -
Process 'void **' argument as 'type(C_PTR)' by reference.
-
Added assumedtype attribute to use Fortran assumed-type declaration,
type(*)
, forvoid *
arguments. -
Parse
enum class
andenum struct
. -
Process arrays in Python as NumPy array or Python list using option
PY_array_arg. -
Process struct in Python as NumPy array or extension type using option
PY_struct_arg. -
Changed how the fortran_generic arguments are specified to allow
multiple arguments and to associate attributes with arguments.
Create a capsule derived type for each class
Fixes a problem detected by XLF.
Wrap additional C++ features
- Add typemaps for unsigned types and size based types (int64_t).
- Support C/C++ structs.
- Wrap class member variables.
- Add support for memory ownership to help reference counting.
- Support multiple template parameters.
- Support class templates.
- Support ALLOCATABLE CHARACTER functions.
Full support for namespaces
- Create
namespace
declarations. Allow nestingnamespace
,class
,typedef
, andenum
. - Add
cpp_if
support to Fortran wrapper.
Improve Python, allocatable support
- Improve Python support, include support for NumPy.
- accept function pointer arguments.
- Add implied and allocatable attributes.
- Improved continuations in generated code
- Write a generic interface for overloaded constructors.
- Move intermediate variables in generated source to aid debugging.
Add C preprocessor conditions to generated code
- Change cpp_ prefixes to cxx_ (used with C++)
- Add cpp_if to set C preprocessor conditional compilation
- Move all format strings into format (many were in options or fields), allow format to be set fromYAML file.
- support std::string * arguments and function result.
Add Python API
Add a Python API to make it easier to create a representation of the library to wrap.
Before input was limited to YAML.
library = LibraryNode('mylibrary')
library.add_function(decl='void func1()')
YAML equivalent
library: mylibrary
functions:
- decl: void func1()