PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/minherit2.i

#
Swig | 117 lines | 98 code | 19 blank | 0 comment | 0 complexity | 88eb1cd3a564c3d1f17a9ecb165418ef MD5 | raw file
  1%module minherit2
  2
  3// A multiple inheritance example, mainly for Java, C# and D.
  4// The example shows how it is possible to turn C++ abstract base classes into
  5// Java/C#/D interfaces.
  6// In the future, all this trouble might be more automated.
  7
  8%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
  9	    SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
 10	    SWIGWARN_D_MULTIPLE_INHERITANCE,
 11	    SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
 12	    SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe;
 13
 14
 15#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
 16
 17#if defined(SWIGCSHARP)
 18#define javaclassmodifiers   csclassmodifiers
 19#define javabody             csbody
 20#define javafinalize         csfinalize
 21#define javadestruct         csdestruct
 22#define javaout              csout
 23#define javainterfaces       csinterfaces
 24#define javabase             csbase
 25#endif
 26
 27#if defined(SWIGD)
 28#define javaclassmodifiers   dclassmodifiers
 29#define javabody             dbody
 30#define javafinalize         ddestructor
 31#define javadestruct         ddispose
 32#define javaout              dout
 33#define javainterfaces       dinterfaces
 34#define javabase             dbase
 35
 36%typemap(dimports) RemoteMpe %{
 37$importtype(IRemoteSyncIO)
 38$importtype(IRemoteAsyncIO)
 39%}
 40#endif
 41
 42// Modify multiple inherited base classes into inheriting interfaces
 43%typemap(javainterfaces) RemoteMpe "IRemoteSyncIO, IRemoteAsyncIO";
 44%typemap(javabase, replace="1") RemoteMpe "";
 45
 46// Turn the proxy class into an interface
 47%typemap(javaclassmodifiers) IRemoteSyncIO "public interface";
 48%typemap(javaclassmodifiers) IRemoteAsyncIO "public interface";
 49%typemap(javabody) IRemoteSyncIO "";
 50%typemap(javabody) IRemoteAsyncIO "";
 51%typemap(javafinalize) IRemoteSyncIO "";
 52%typemap(javafinalize) IRemoteAsyncIO "";
 53%typemap(javadestruct) IRemoteSyncIO "";
 54%typemap(javadestruct) IRemoteAsyncIO "";
 55
 56// Turn the methods into abstract methods
 57%typemap(javaout) void IRemoteSyncIO::syncmethod ";"
 58%typemap(javaout) void IRemoteAsyncIO::asyncmethod ";"
 59#if defined(SWIGJAVA)
 60%javamethodmodifiers IRemoteSyncIO::syncmethod "abstract public";
 61%javamethodmodifiers IRemoteAsyncIO::asyncmethod "abstract public";
 62// Features are inherited by derived classes, so override this
 63%javamethodmodifiers RemoteMpe::syncmethod "public"
 64%javamethodmodifiers RemoteMpe::asyncmethod "public"
 65#elif defined(SWIGCSHARP)
 66%csmethodmodifiers IRemoteSyncIO::syncmethod "";
 67%csmethodmodifiers IRemoteAsyncIO::asyncmethod "";
 68// Features are inherited by derived classes, so override this
 69%csmethodmodifiers RemoteMpe::syncmethod "public"
 70%csmethodmodifiers RemoteMpe::asyncmethod "public"
 71#elif defined(SWIGD)
 72%dmethodmodifiers IRemoteSyncIO::syncmethod "";
 73%dmethodmodifiers IRemoteAsyncIO::asyncmethod "";
 74// Features are inherited by derived classes, so override this
 75%dmethodmodifiers RemoteMpe::syncmethod "public"
 76%dmethodmodifiers RemoteMpe::asyncmethod "public"
 77#endif
 78
 79#endif
 80
 81
 82%inline %{
 83class IRemoteSyncIO
 84{
 85public:
 86  virtual ~IRemoteSyncIO () {}
 87  virtual void syncmethod() = 0;
 88protected:
 89  IRemoteSyncIO () {}
 90  
 91private:
 92  IRemoteSyncIO (const IRemoteSyncIO&);
 93  IRemoteSyncIO& operator= (const IRemoteSyncIO&);
 94};
 95
 96class IRemoteAsyncIO
 97{
 98public:
 99  virtual ~IRemoteAsyncIO () {}
100  virtual void asyncmethod() = 0;
101protected:
102  IRemoteAsyncIO () {}
103  
104private:
105  IRemoteAsyncIO (const IRemoteAsyncIO&);
106  IRemoteAsyncIO& operator= (const IRemoteAsyncIO&);
107};
108
109class RemoteMpe : public IRemoteSyncIO, public IRemoteAsyncIO
110{
111public:
112  virtual void syncmethod() {}
113  virtual void asyncmethod() {}
114};
115
116%}
117