Skip to content

Releases: LLNL/shroud

Cumulative Update

05 Sep 20:37
4388ff1
Compare
Choose a tag to compare

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
    individual decl lines in the YAML file similar to how
    class members are defined. Before the struct was defined
    in a single decl:.

  • 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 * and std::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 with const 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 and USE statements into generated files.
    These are collated with headers and USE 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 is void.

  • 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 of std::string.

  • Create C and Fortran wrappers for typedef statements.
    Before typedef was treated as an alias. typedef int TypeID would
    substitute integer(C_INT) for every use of TypeID 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) for void **.

  • 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 and enum as part of declaration.
    This allows typedef 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 was c_create__cstruct_as_class now c_create_cstruct_as_class
    • Add missing underscore
      AFunction was afunction now a_function.

Mangle some Fortran derived type names with C_prefix

05 Aug 08:14
939ba0a
Compare
Choose a tag to compare

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 be PRIVATE, but
    gfortran does not allow PRIVATE and BIND(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

28 Jun 02:25
c093446
Compare
Choose a tag to compare
  • 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

09 Jan 23:41
503b852
Compare
Choose a tag to compare
  • 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(*), for void * arguments.

  • Parse enum class and enum 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

08 Aug 02:17
Compare
Choose a tag to compare

Fixes a problem detected by XLF.

Wrap additional C++ features

01 Aug 22:03
Compare
Choose a tag to compare
  • 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

05 Apr 04:52
Compare
Choose a tag to compare
  • Create namespace declarations. Allow nesting namespace, class, typedef, and enum.
  • Add cpp_if support to Fortran wrapper.

Improve Python, allocatable support

27 Feb 02:44
b58ac35
Compare
Choose a tag to compare
  • 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

22 Jan 21:07
Compare
Choose a tag to compare
  • 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

11 Jan 01:31
958b157
Compare
Choose a tag to compare

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()