File: inherit_target_language.i

package info (click to toggle)
swig1.3 1.3.36-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 27,060 kB
  • ctags: 13,774
  • sloc: cpp: 40,816; ansic: 27,565; python: 9,069; java: 6,432; makefile: 5,065; yacc: 4,916; cs: 4,551; sh: 4,071; ruby: 3,760; perl: 3,562; lisp: 1,993; tcl: 1,266; php: 1,026; ml: 708
file content (63 lines) | stat: -rw-r--r-- 1,970 bytes parent folder | download
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
// Test using a target language specified base class, primarily for Java/C# and possibly other single inheritance languages

// Note the multiple inheritance warnings don't appear because of the two techniques used in here: typemaps and %ignore

%module inherit_target_language

#if defined(SWIGJAVA)
# define csbase javabase
#endif

%pragma(csharp) moduleimports=%{
using System;
using System.Runtime.InteropServices;
public class TargetLanguageBase { public virtual void targetLanguageBaseMethod() {} };
%}

%pragma(java) moduleimports=%{
class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
%}


%typemap(csbase) SWIGTYPE "TargetLanguageBase"

// Two ways to replace a C++ base with a completely different target language base
%ignore Base1; // another way to use the target language base
%typemap(csbase, replace="1") Derived2 "TargetLanguageBase"

%inline %{
struct Base1 { virtual ~Base1() {} };
struct Base2 { virtual ~Base2() {} };
struct Derived1 : Base1 {};
struct Derived2 : Base2 {};
%}

// Multiple inheritance
%ignore MBase1a;
%ignore MBase1b;
%typemap(csbase, replace="1") MultipleDerived2 "TargetLanguageBase"

%inline %{
struct MBase1a { virtual ~MBase1a() {} virtual void a() {} };
struct MBase1b { virtual ~MBase1b() {} virtual void b() {} };
struct MBase2a { virtual ~MBase2a() {} virtual void c() {} };
struct MBase2b { virtual ~MBase2b() {} virtual void d() {} };
struct MultipleDerived1 : MBase1a, MBase1b {};
struct MultipleDerived2 : MBase1a, MBase2b {};
%}


%ignore MBase3a;
%ignore MBase4b;
%typemap(csbase) MultipleDerived3 ""
%typemap(csbase) MultipleDerived4 ""

%inline %{
struct MBase3a { virtual ~MBase3a() {} virtual void e() {} };
struct MBase3b { virtual ~MBase3b() {} virtual void f() {} };
struct MBase4a { virtual ~MBase4a() {} virtual void g() {} };
struct MBase4b { virtual ~MBase4b() {} virtual void h() {} };
struct MultipleDerived3 : MBase3a, MBase3b {};
struct MultipleDerived4 : MBase4a, MBase4b {};
%}