summaryrefslogtreecommitdiff
path: root/Examples/test-suite/minherit2.i
blob: 1bca4fc48d1ec3fc8492021b0777ff66ddc745ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
%module minherit2

// A multiple inheritance example, mainly for Java and C#.
// The example shows how it is possible to turn C++ abstract base classes into Java/C# interface.
// In the future, all this trouble might be more automated.

%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
	    SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
	    SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
	    SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe;


#if defined(SWIGJAVA) || defined(SWIGCSHARP)

#if defined(SWIGCSHARP)
#define javaclassmodifiers   csclassmodifiers
#define javabody             csbody
#define javafinalize         csfinalize
#define javadestruct         csdestruct
#define javaout              csout
#define javainterfaces       csinterfaces
#define javabase             csbase
#endif

// Modify multiple inherited base classes into inheriting interfaces
%typemap(javainterfaces) RemoteMpe "IRemoteSyncIO, IRemoteAsyncIO";
%typemap(javabase, replace="1") RemoteMpe "";

// Turn the proxy class into an interface
%typemap(javaclassmodifiers) IRemoteSyncIO "public interface";
%typemap(javaclassmodifiers) IRemoteAsyncIO "public interface";
%typemap(javabody) IRemoteSyncIO "";
%typemap(javabody) IRemoteAsyncIO "";
%typemap(javafinalize) IRemoteSyncIO "";
%typemap(javafinalize) IRemoteAsyncIO "";
%typemap(javadestruct) IRemoteSyncIO "";
%typemap(javadestruct) IRemoteAsyncIO "";

// Turn the methods into abstract methods
%typemap(javaout) void IRemoteSyncIO::syncmethod ";"
%typemap(javaout) void IRemoteAsyncIO::asyncmethod ";"
#if defined(SWIGJAVA)
%javamethodmodifiers IRemoteSyncIO::syncmethod "abstract public";
%javamethodmodifiers IRemoteAsyncIO::asyncmethod "abstract public";
// Features are inherited by derived classes, so override this
%javamethodmodifiers RemoteMpe::syncmethod "public"
%javamethodmodifiers RemoteMpe::asyncmethod "public"
#elif defined(SWIGCSHARP)
%csmethodmodifiers IRemoteSyncIO::syncmethod "";
%csmethodmodifiers IRemoteAsyncIO::asyncmethod "";
// Features are inherited by derived classes, so override this
%csmethodmodifiers RemoteMpe::syncmethod "public"
%csmethodmodifiers RemoteMpe::asyncmethod "public"
#endif

#endif


%inline %{
class IRemoteSyncIO
{
public:
  virtual ~IRemoteSyncIO () {}
  virtual void syncmethod() = 0;
protected:
  IRemoteSyncIO () {}
  
private:
  IRemoteSyncIO (const IRemoteSyncIO&);
  IRemoteSyncIO& operator= (const IRemoteSyncIO&);
};

class IRemoteAsyncIO
{
public:
  virtual ~IRemoteAsyncIO () {}
  virtual void asyncmethod() = 0;
protected:
  IRemoteAsyncIO () {}
  
private:
  IRemoteAsyncIO (const IRemoteAsyncIO&);
  IRemoteAsyncIO& operator= (const IRemoteAsyncIO&);
};

class RemoteMpe : public IRemoteSyncIO, public IRemoteAsyncIO
{
public:
  virtual void syncmethod() {}
  virtual void asyncmethod() {}
};

%}