mapping c++ abstract class to c# Interface

View: New views
3 Messages — Rating Filter:   Alert me  

mapping c++ abstract class to c# Interface

by stefano ruberto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there...

The problem "... Multiple inheritance is not supported in C#."


In order to translate multiple inheritance into c#  I think would be
usefull to use the c# interface.

SWIG only take the first base class in my c++ code but anyway insert the
inherited method from all
the base class in the cs proxy class...

So I tought to add a c# interface for each abstract  c++ base class.

//c++ side
class abstarctCppBase1{ void mth1Base1()=0 ;  void mth2Base1(){}  ... }

class abstarctCppBase2{  void mth1Base2()=0 ; void mth2Base1() {}...}

class CppInherited : abstarctCppBase1 , abstarctCppBase2
{ }

//c# side


interface Ibase2 {  mth1Base2();  mth2Base1(); }

class csBase1{  ... }

class csInherited : csBase1, Ibase2 { void mth1Base1(){}   void
mth2Base1(){} void mth1Base2(){} void mth2Base1() {} }

Is this the correct way ... ??
I'm so new to swig so that any help will be appreciated!

Thank you for your help
By
Rubio





-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Parent Message unknown Re: mapping c++ abstract class to c# Interface

by zhiyang jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Message: 4
Date: Thu, 8 May 2008 16:33:04 +0200
From: "stefano ruberto" <stefano.ruberto@...>
Subject: [Swig-user] mapping c++ abstract class to c# Interface
To: swig-user@...
Message-ID:
       <beddcd8a0805080733r237ac60cjd02f2d3b39a96737@...>
Content-Type: text/plain; charset="iso-8859-1"

Hi there...

The problem "... Multiple inheritance is not supported in C#."


In order to translate multiple inheritance into c#  I think would be
usefull to use the c# interface.

SWIG only take the first base class in my c++ code but anyway insert the
inherited method from all
the base class in the cs proxy class...

So I tought to add a c# interface for each abstract  c++ base class.

//c++ side
class abstarctCppBase1{ void mth1Base1()=0 ;  void mth2Base1(){}  ... }

class abstarctCppBase2{  void mth1Base2()=0 ; void mth2Base1() {}...}

class CppInherited : abstarctCppBase1 , abstarctCppBase2
{ }

//c# side


interface Ibase2 {  mth1Base2();  mth2Base1(); }

class csBase1{  ... }

class csInherited : csBase1, Ibase2 { void mth1Base1(){}   void
mth2Base1(){} void mth1Base2(){} void mth2Base1() {} }

Is this the correct way ... ??
I'm so new to swig so that any help will be appreciated!

Thank you for your help
By
Rubio
it is good way  to transform the abstract classes into interfaces in c#,but the swig does not know which should be transformed, if you define the interfaces manually ,  there may be some map problems between the proxy classes and wrapper classes.
The multiple inheritance  will be completely supported in future ,as you said ,the abstract classs will be interfaces in c# or java, and a new directives like %feature(interface) will be added into swig for showing what are interfaces.
Hope it is useful to you!
 
Jiang

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: mapping c++ abstract class to c# Interface

by stefano ruberto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

zhiyang jiang ha scritto:

>
>
>     Message: 4
>     Date: Thu, 8 May 2008 16:33:04 +0200
>     From: "stefano ruberto" <stefano.ruberto@...
>     <mailto:stefano.ruberto@...>>
>     Subject: [Swig-user] mapping c++ abstract class to c# Interface
>     To: swig-user@...
>     <mailto:swig-user@...>
>     Message-ID:
>          
>      <beddcd8a0805080733r237ac60cjd02f2d3b39a96737@...
>     <mailto:beddcd8a0805080733r237ac60cjd02f2d3b39a96737@...>>
>     Content-Type: text/plain; charset="iso-8859-1"
>
>     Hi there...
>
>     The problem "... Multiple inheritance is not supported in C#."
>
>
>     In order to translate multiple inheritance into c#  I think would be
>     usefull to use the c# interface.
>
>     SWIG only take the first base class in my c++ code but anyway
>     insert the
>     inherited method from all
>     the base class in the cs proxy class...
>
>     So I tought to add a c# interface for each abstract  c++ base class.
>
>     //c++ side
>     class abstarctCppBase1{ void mth1Base1()=0 ;  void mth2Base1(){}
>      ... }
>
>     class abstarctCppBase2{  void mth1Base2()=0 ; void mth2Base1() {}...}
>
>     class CppInherited : abstarctCppBase1 , abstarctCppBase2
>     { }
>
>     //c# side
>
>
>     interface Ibase2 {  mth1Base2();  mth2Base1(); }
>
>     class csBase1{  ... }
>
>     class csInherited : csBase1, Ibase2 { void mth1Base1(){}   void
>     mth2Base1(){} void mth1Base2(){} void mth2Base1() {} }
>
>     Is this the correct way ... ??
>     I'm so new to swig so that any help will be appreciated!
>
>     Thank you for your help
>     By
>     Rubio
>
> it is good way  to transform the abstract classes into interfaces in
> c#,but the swig does not know which should be transformed, if you
> define the interfaces manually ,  there may be some map problems
> between the proxy classes and wrapper classes.
> The multiple inheritance  will be completely supported in future ,as
> you said ,the abstract classs will be interfaces in c# or java, and a
> new directives like %feature(interface) will be added into swig for
> showing what are interfaces.
> Hope it is useful to you!
>  
> Jiang
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> ------------------------------------------------------------------------
>
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user
>  
Thank you for your replay ...  before doing some more experimet.. I
would like to know how far is this (beautiful  :-) ) future ...
can you give some good news?

Rubio


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user