diff --git a/SWIG/Examples/test-suite/common.mk b/SWIG/Examples/test-suite/common.mk index 7c7495191..2e5a969a1 100644 --- a/SWIG/Examples/test-suite/common.mk +++ b/SWIG/Examples/test-suite/common.mk @@ -109,6 +109,7 @@ CPP_TEST_CASES += \ destructor_reprotected \ director_abstract \ director_basic \ + director_constructor \ director_detect \ director_default \ director_enum \ diff --git a/SWIG/Examples/test-suite/director_constructor.i b/SWIG/Examples/test-suite/director_constructor.i new file mode 100644 index 000000000..b3505f9f5 --- /dev/null +++ b/SWIG/Examples/test-suite/director_constructor.i @@ -0,0 +1,37 @@ +%module(directors="1") director_constructor + +%feature("director") Foo; + +%inline %{ +class Foo +{ +public: + int a; + + Foo(int i) + { + a=i; + } + + virtual ~Foo() { } + + int do_test() { + return test(); + } + + virtual int getit() + { + return a; + } + + virtual void doubleit() + { + a = a * 2; + } + + virtual int test() = 0; +}; +%} + + + diff --git a/SWIG/Examples/test-suite/ruby/director_constructor_runme.rb b/SWIG/Examples/test-suite/ruby/director_constructor_runme.rb new file mode 100644 index 000000000..3100cf9b9 --- /dev/null +++ b/SWIG/Examples/test-suite/ruby/director_constructor_runme.rb @@ -0,0 +1,26 @@ +require 'director_constructor' + +include Director_constructor + +class Test < Foo + def initialize(i) + super(i) + end + + def doubleit() + self.a = (self.a * 2) + end + + def test + 3 + end +end + +a = Test.new(5) #dies here + +raise RuntimeError if a.getit != 5 +raise RuntimeError if a.do_test != 3 + +a.doubleit +raise RuntimeError if a.getit != 10 +