Skip to content

Pure functions #317

@CarvFS

Description

@CarvFS

Hello :)

I am trying to implement a class member function whith the +pure input on shroud, i.e.:

library: Tutorial
format:
  F_filename_suffix: F90
cxx_header: tutorial.hpp

declarations:
- decl: namespace tutorial
  declarations:
  - decl: class Class1
    declarations:
    - decl: Class1() +name(new)
    - decl: ~Class1() +name(delete)
    - decl: int get_intvalue() +pure

By doing this I have the Fortran wrapper containing the prefixe pure for the function in the C interface:

   interface

        [...other functions implemented...]

        pure function c_class1_get_intvalue(self) result(SHT_rv)  bind(C, name="TUT_tutorial_Class1_get_intvalue")
            use iso_c_binding, only : C_INT
            import :: SHROUD_class1_capsule
            implicit none
            type(SHROUD_class1_capsule), intent(IN) :: self
            integer(C_INT) :: SHT_rv
        end function c_class1_get_intvalue

    end interface

But not for the function in the contains block:

    function class1_get_intvalue(obj) &
            result(SHT_rv)
        use iso_c_binding, only : C_INT
        class(class1) :: obj
        integer(C_INT) :: SHT_rv
        ! splicer begin namespace.tutorial.class.Class1.method.get_intvalue
        SHT_rv = c_class1_get_intvalue(obj%cxxmem)
        ! splicer end namespace.tutorial.class.Class1.method.get_intvalue
    end function class1_get_intvalue

I could solve this by changing from this to:

    pure function class1_get_intvalue(obj) &
            result(SHT_rv)
        use iso_c_binding, only : C_INT
        class(class1), intent(in) :: obj
        integer(C_INT) :: SHT_rv
        ! splicer begin namespace.tutorial.class.Class1.method.get_intvalue
        SHT_rv = c_class1_get_intvalue(obj%cxxmem)
        ! splicer end namespace.tutorial.class.Class1.method.get_intvalue
    end function class1_get_intvalue

Is this not supported yet or am I missing something?

Thank you very much!
Felipe Silva Carvalho

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions