summaryrefslogtreecommitdiff
path: root/Examples/test-suite/minherit.i
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/minherit.i')
-rw-r--r--Examples/test-suite/minherit.i77
1 files changed, 77 insertions, 0 deletions
diff --git a/Examples/test-suite/minherit.i b/Examples/test-suite/minherit.i
new file mode 100644
index 0000000..24092b6
--- /dev/null
+++ b/Examples/test-suite/minherit.i
@@ -0,0 +1,77 @@
+// This module tests multiple inheritance, typedef handling, and some
+// truly horrible parts of the SWIG type system. This is only tested
+// for Python since not all language modules support multiple-inheritance.
+// However, if it works for Python, things should be working for other
+// modules.
+
+%module(ruby_minherit="1") minherit
+
+#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL)
+
+%inline %{
+
+class Foo {
+private:
+ int x;
+public:
+ Foo() { x = 1; }
+ virtual ~Foo() {}
+ virtual int xget() { return x; };
+};
+typedef Foo *FooPtr;
+
+FooPtr toFooPtr(Foo *f) { return f; }
+
+class Bar {
+private:
+ int y;
+public:
+ Bar() { y = 2; }
+ virtual ~Bar() {}
+ virtual int yget() { return y; }
+};
+
+typedef Bar *BarPtr;
+BarPtr toBarPtr(Bar *f) { return f; }
+
+class FooBar : public Foo, public Bar {
+private:
+ int z;
+public:
+ FooBar() { z = 3; }
+ virtual int zget() { return z; }
+};
+
+typedef FooBar *FooBarPtr;
+FooBarPtr toFooBarPtr(FooBar *f) { return f; }
+
+class Spam: public FooBar {
+private:
+ int w;
+public:
+ Spam() { w = 4; }
+ virtual int wget() { return w; }
+};
+
+typedef Spam *SpamPtr;
+SpamPtr toSpamPtr(Spam *f) { return f; }
+
+int xget(FooPtr f) {
+ return f->xget();
+}
+
+int yget(BarPtr f) {
+ return f->yget();
+}
+
+int zget(FooBarPtr f) {
+ return f->zget();
+}
+
+int wget(SpamPtr f) {
+ return f->wget();
+}
+%}
+
+#endif
+