Hi!

I have a C++ class hierarchy which uses multiple inheritance. (at maximum there's one not-abstract class inherited from)
Now i want to use this structure on the C# side somehow. I know there is no real implementation for mapping abstract C++ classes to C# interfaces yet, so I'm looking for the easiest way to get around this.


What i found out so far:

1. Creating interfaces by hand:
http://old.nabble.com/Generating-C--Interfaces-for-Proxy-Classes-td26473557.html
As far as i understood, this workaround would require me to declare every c++ class i want to use as C# interface in the .i file. Further i'd have to overwrite the C# inheritance using %typemap(csinterfaces) and %typemap(csbase) so the interfaces will be used. all the proxy forwarding calls would be implemented when a concrete class implements the method.

I tried that and ran into several problems:
  - If I %include the interfaces c++ header, the abstract methods get declared as "public virtual" in C# and are implemented. Of course this is not valid C# code.
  - If I don't %include it, I get no C# interface at all (thought for a moment the "%typemap(cscode)"-code would create it)
  - Using "%typemap(cbase, replace="1")" leads to C# code that doesn't initialize the base class properly in the classes constructors
  - Will SWIG even recognize the types correctly if i have such an interface somewhere as parameter?


2. Patch implementing %feature("interface"):
http://thread.gmane.org/gmane.comp.programming.swig.devel/18403
I really have no idea where to start here. Where do i get the patch from? How can i use it? Does it work?


3. Workaround idea:
What if i ignore all abstract c++ classes within the .i file and declare all pure virtual methods again in the implementing classes, so i get a class fully qualified with all methods. 
Further i could overload all methods which expect a pointer to an interface with a version accepting an implementing class by using %extend within the .i file.
Simple example of what i think of:

class MyInterface {
public: 
  virtual ~MyInterface() {};
  virtual void myMethod() = 0;
};
class Base { 
};
class NotImplementing : public Base, public MyInterface1 {
public: 
  virtual void myMethod() = 0; // redeclaration, so SWIG calls it in wrapper
  void someOtherStuff() { ... }
};
class Implementation1 : public NotImplementing {
  void myMethod() { ... }
};
class Implementation2 : public NotImplementing {
  void myMethod() { ... }
};

class Foo {
public:
  void acceptMyInterface(MyInterface *obj) { obj->myMethod(); }
};
//----------------------
// within the .i file (excerpt)
//%include "MyInterface.h"  // IGNORED
%include "Base.h"
%include "NotImplementing.h"
%include "Implementation1.h"
%include "Implementation2.h"
%include "Foo.h"

%extend Foo {
  void acceptMyInterface(Implementation1 *obj) { obj->myMethod(); }
  void acceptMyInterface(Implementation2 *obj) { obj->myMethod(); }
};

This way I would ban all interfaces from the C# side, using only implementing classes. I'd have to write quite verbose C++ code redeclaring many methods, but I'd accept that. Also I'd gather highly interdependent code by adding methods accepting implemented versions of interfaces, but that would just happen within the .i file, so I'd be fine with that, too.
Would that be possible?


Thanks, 
Matthias