summaryrefslogtreecommitdiff
path: root/Examples/test-suite/inherit_target_language.i
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2007-10-19 21:48:05 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2007-10-19 21:48:05 +0000
commita43e50ac07a33dc271808d9e9007ada1d9470c76 (patch)
treed1e8205ca33c0016ca39c956d1359d17cf3ded6f /Examples/test-suite/inherit_target_language.i
parenta1052bab4ff427409a246f6f865da38ff25258ae (diff)
downloadswig-a43e50ac07a33dc271808d9e9007ada1d9470c76.tar.gz
fix generated code for derived classes when csbase or javabase typemaps are used with the replace=1 attribute.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10016 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Examples/test-suite/inherit_target_language.i')
-rw-r--r--Examples/test-suite/inherit_target_language.i63
1 files changed, 63 insertions, 0 deletions
diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i
new file mode 100644
index 000000000..770e11d36
--- /dev/null
+++ b/Examples/test-suite/inherit_target_language.i
@@ -0,0 +1,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 {};
+%}
+