diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2014-12-09 23:31:07 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2014-12-09 23:48:37 +0000 |
commit | ae555c2339aba9d677bc3da813848c93142cb500 (patch) | |
tree | 5e550fee769f6fe721bf16a15b85322be5979659 /Examples | |
parent | 9cbdf69fdc3554a5d3c1bc8c3a0fbe7e3c182254 (diff) | |
download | swig-ae555c2339aba9d677bc3da813848c93142cb500.tar.gz |
Fix templated constructors regression
Templated constructors were incorrectly ignored because SWIG thought they were
methods without a return type.
Regression introduced in swig-3.0.0
Closes #245.
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/test-suite/common.mk | 1 | ||||
-rw-r--r-- | Examples/test-suite/java/template_templated_constructors_runme.java | 26 | ||||
-rw-r--r-- | Examples/test-suite/template_templated_constructors.i | 47 |
3 files changed, 74 insertions, 0 deletions
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c1cef0bcc..d4f34a707 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -382,6 +382,7 @@ CPP_TEST_CASES += \ template_classes \ template_const_ref \ template_construct \ + template_templated_constructors \ template_default \ template_default2 \ template_default_arg \ diff --git a/Examples/test-suite/java/template_templated_constructors_runme.java b/Examples/test-suite/java/template_templated_constructors_runme.java new file mode 100644 index 000000000..cd3f31d21 --- /dev/null +++ b/Examples/test-suite/java/template_templated_constructors_runme.java @@ -0,0 +1,26 @@ + +import template_templated_constructors.*; + +public class template_templated_constructors_runme { + + static { + try { + System.loadLibrary("template_templated_constructors"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) { + TConstructor1 t1 = new TConstructor1(123); + TConstructor2 t2a = new TConstructor2(); + TConstructor2 t2b = new TConstructor2(123); + + TClass1Int tc1 = new TClass1Int(123.4); + TClass2Int tc2a = new TClass2Int(); + TClass2Int tc2b = new TClass2Int(123.4); + + } +} + diff --git a/Examples/test-suite/template_templated_constructors.i b/Examples/test-suite/template_templated_constructors.i new file mode 100644 index 000000000..ee9df94bb --- /dev/null +++ b/Examples/test-suite/template_templated_constructors.i @@ -0,0 +1,47 @@ +%module template_templated_constructors + +%inline %{ +namespace ConstructSpace { + +class TConstructor1 { +public: + template<typename T> TConstructor1(T val) {} + ~TConstructor1() {} +}; + +class TConstructor2 { +public: + TConstructor2() {} + template<typename T> TConstructor2(T val) {} + ~TConstructor2() {} +}; + +template<typename T> class TClass1 { +public: + template<typename Y> TClass1(Y t) {} +}; + +template<typename T> class TClass2 { +public: + TClass2() {} + template<typename Y> TClass2(Y t) {} +}; + +} +%} + +%extend ConstructSpace::TConstructor1 { + %template(TConstructor1) TConstructor1<int>; +} + +%template(TConstructor2) ConstructSpace::TConstructor2::TConstructor2<int>; + +%template(TClass1Int) ConstructSpace::TClass1<int>; +%extend ConstructSpace::TClass1<int> { + %template(TClass1Int) TClass1<double>; +} + +%template(TClass2Int) ConstructSpace::TClass2<int>; +%extend ConstructSpace::TClass2<int> { + %template(TClass2Int) TClass2<double>; +} |