Proxy class types will be COMPLETELY INDEPENDENT: shadowing and such is handled by SWIG since Fortran sucks balls
Write C wrapper functions only for base class methods (i.e. don't duplicate wrapper code between base and derived)
Add implementation (private) functions that implement casts between the C++ class pointers
Proxy code will use pointer casting functions
Add user-accessible free functions to cast between Fortran proxy classes
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
Example:
In the above, C wrapper code will be generated for all the methods in
A
, plus thebar(double)
andbaz
methods in B. Becausebar
in B shadows the base class method, it will not have the overloads for the base classbar
methods.Fortran proxy code: