I have one suggestion about interface support, if you implement this feature: it should be possible to wrap a class with BOTH a normal wrapper AND an interface. That is, don't limit interfaces to abstract base classes--also allow non-abstract base classes. For example, given a class hierarchy like:

struct A { int a; void fa(); }
struct B { int b; void fb(); }
struct C : A, B { int c; void fc(); }

It should be possible to create an interface "IB" in C#:

public interface IB {
  int b { get; set; }
  void fb();
}

But also a concrete class "B" that implements IB:

public class B : IB {
  public B(...) {...}
  public int b { get { ... } set { ... } }
  public void fb() { ... }
  ...
}

And then the wrapper for C would be:

public class C : A, IB {
  public C(...) {...}
  public int b { get { ... } set { ... } }
  public void fb() { ... }
  public int c { get { ... } set { ... } }
  public void fc() { ... }
  ...
}

This way, it is possible to create a standalone B that is not a C. Of course, if B is an abstract base class then an interface alone should suffice, i.e. only an interface IB is needed, not a class B.

It would also be nice if there were some way to request SWIG to create a property that returns a wrapper for B, e.g. in C#, C could have an operator for this:

  // C can convert to B implicitly
  public static implicit operator B(C c) { ??? }

But this feature is optional, since the user could add the necessary code manually, or (I assume) with help from a macro.




From:        Vladimir Kalinin <vkalinin@opendesign.com>
To:        <swig-devel@lists.sourceforge.net>
Date:        03/19/2013 04:55 PM
Subject:        [Swig-devel] Abstract base classes to interfaces conversion




As far as I know, currently there is no easy way to convert C++ abstract base
classes to Java/C# interfaces. (short of redeclaring the classes and
doing some more work)

I found the only reference to the attempt to implement that feature
here:
http://thread.gmane.org/gmane.comp.programming.swig.devel/18403
Is there any information about the status of that work?
(As I understand, the patch posted in that thread is far from
perfection)

Maybe there is some alternative solution being worked at in some SWIG branch?

If no one is planning to implement that feature in near future, I
will do it (in some way at least).
(Because, converting abstract base classes to interfaces is
currently the most time consuming feature in our
project wrappers (after nested classes were implemented)).

I think "feature:interface" syntax proposed by Zhiyang Jiang is ok.

Any suggestions, advices?


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Swig-devel mailing list
Swig-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-devel