swig-fortran / swig

This fork of SWIG creates Fortran wrapper code from C++ headers.
http://www.swig.org
Other
42 stars 11 forks source link

Rewrite inheritance #54

Closed sethrj closed 6 years ago

sethrj commented 6 years ago

Example:

class A {
  public:
    virtual ~A();
    virtual void foo() = 0;
    void bar();
    void bar(int a);
};

class B : public A {
  public:
    B();
    void foo();
    void bar(double c);
    void baz();
};

In the above, C wrapper code will be generated for all the methods in A, plus the bar(double) and baz methods in B. Because bar in B shadows the base class method, it will not have the overloads for the base class bar methods.

Fortran proxy code:

function derived_to_base(derived) &
    result(base)
    use, intrinsic :: ISO_C_BINDING
    type(A) :: base
    class(B) :: derived
    type(C_PTR) :: fresult 
    type(C_PTR) :: farg1 

    farg1 = derived%swigptr
    fresult = swigc_derived_to_base(farg1)
    base%swigptr = fresult
end function
sethrj commented 6 years ago

Per my email discussions with @wsfulton we'll keep the current inheritance but warn/rename cases that don't work.