diff --git a/SWIG/Examples/test-suite/common.mk b/SWIG/Examples/test-suite/common.mk index eebb6528e..a9960c3d1 100644 --- a/SWIG/Examples/test-suite/common.mk +++ b/SWIG/Examples/test-suite/common.mk @@ -46,13 +46,10 @@ LIBPREFIX = lib # Broken C++ test cases. (Can be run individually using make testcase.cpptest.) CPP_TEST_BROKEN += \ derived_nested \ - derived_byvalue \ multiple_inheritance \ namespace_union \ overload_complicated \ smart_pointer_namespace2 \ - template_specialization_defarg \ - template_typedef_ptr \ using_namespace # Broken C test cases. (Can be run individually using make testcase.ctest.) @@ -114,6 +111,7 @@ CPP_TEST_CASES += \ default_args \ default_ref \ defvalue_constructor \ + derived_byvalue \ destructor_reprotected \ director_abstract \ director_basic \ @@ -165,6 +163,7 @@ CPP_TEST_CASES += \ long_long_apply \ member_template \ minherit \ + mixed_types \ name_cxx \ name_inherit \ name_warnings \ @@ -253,6 +252,7 @@ CPP_TEST_CASES += \ template_rename \ template_retvalue \ template_specialization \ + template_specialization_defarg \ template_specialization_enum \ template_static \ template_tbase_template \ @@ -263,6 +263,7 @@ CPP_TEST_CASES += \ template_typedef_cplx3 \ template_typedef_cplx4 \ template_typedef_cplx5 \ + template_typedef_ptr \ template_virtual \ template_whitespace \ throw_exception \ diff --git a/SWIG/Examples/test-suite/director_basic.i b/SWIG/Examples/test-suite/director_basic.i index 5393dd7d2..6d435e0c6 100644 --- a/SWIG/Examples/test-suite/director_basic.i +++ b/SWIG/Examples/test-suite/director_basic.i @@ -15,6 +15,7 @@ public: %feature("director") Foo; + class Foo { public: virtual ~Foo() {} @@ -25,7 +26,12 @@ public: %{ #include %} -%feature("director") A; +%feature("director"); + +// basic renaming +%rename(rg) A::gg; +%feature("nodirector") hi::A1::gg; + %inline %{ struct A{ @@ -34,11 +40,18 @@ struct A{ virtual ~A() {} virtual int f(int i=0) {return i;} + virtual int gg(int i=0) {return i;} }; -struct A1 : public A{ +namespace hi { + + struct A1 : public A{ A1(std::complex i, double d=0.0) : A(i, d) {} A1(int i, bool j=false) : A(i, j) {} -}; + + virtual int ff(int i = 0) {return i;} + }; +} + %} diff --git a/SWIG/Examples/test-suite/director_frob.i b/SWIG/Examples/test-suite/director_frob.i index d9dee606b..df90b74b6 100644 --- a/SWIG/Examples/test-suite/director_frob.i +++ b/SWIG/Examples/test-suite/director_frob.i @@ -5,9 +5,9 @@ %} %feature("director"); -%feature("nodirector") Bravo::abs_method(); // ok -%feature("director") Charlie::abs_method(); // ok -%feature("nodirector") Delta::abs_method(); // doesn't work +%feature("nodirector") Bravo::abs_method(); // ok +%feature("director") Charlie::abs_method(); // ok +%feature("nodirector") Delta::abs_method(); // ok %inline %{ diff --git a/SWIG/Examples/test-suite/extend_default.i b/SWIG/Examples/test-suite/extend_default.i index 0d5eef76f..6750101ff 100644 --- a/SWIG/Examples/test-suite/extend_default.i +++ b/SWIG/Examples/test-suite/extend_default.i @@ -2,6 +2,10 @@ %module extend_default +%warnfilter(302) Override::over; +%warnfilter(302) Override::overload; +%warnfilter(302) Override::ride; + // %extend before the class definition %extend Before { Before(int i = -1, double d = -1.0) { @@ -86,9 +90,6 @@ struct OverAfter { %} -#pragma SWIG nowarn=-302 -//%warnfilter(302) over; // why doesn't this work? - // %extend overrides the class definition %extend Override { int over(int a) { return a*a; } // SWIG should give a warning then choose this one over the real one diff --git a/SWIG/Examples/test-suite/namespace_nested.i b/SWIG/Examples/test-suite/namespace_nested.i index 6b2a06ccb..440c873ba 100644 --- a/SWIG/Examples/test-suite/namespace_nested.i +++ b/SWIG/Examples/test-suite/namespace_nested.i @@ -21,12 +21,13 @@ %} -namespace hello +namespace hello { %template(Hi_hi0) Hi; } + %inline %{ namespace hello @@ -48,7 +49,9 @@ namespace hello template struct hi1 : T1 { - }; + }; + + typedef hello::Hi h0; } %} diff --git a/SWIG/Examples/test-suite/overload_extend.i b/SWIG/Examples/test-suite/overload_extend.i index 65206c359..f024a5c06 100644 --- a/SWIG/Examples/test-suite/overload_extend.i +++ b/SWIG/Examples/test-suite/overload_extend.i @@ -4,7 +4,10 @@ %typemap(default) double y "$1=1000;"; #endif -#pragma SWIG nowarn=-302 +%warnfilter(302) Foo::test; + + + %extend Foo { int test() { return 0; } int test(int x) { x = 0; return 1; } diff --git a/SWIG/Examples/test-suite/primitive_types.i b/SWIG/Examples/test-suite/primitive_types.i index 662fd01e5..ec04a284c 100644 --- a/SWIG/Examples/test-suite/primitive_types.i +++ b/SWIG/Examples/test-suite/primitive_types.i @@ -146,7 +146,7 @@ // // These applies shouldn't be needed ....!! // -%apply const int& { const Hello& }; +//%apply const int& { const Hello& }; %apply void* { pint }; %apply const void*& { const pint& }; @@ -154,6 +154,10 @@ // // Some simple types +%apply char FIXSIZE[ANY] {char fixsize[8]}; + + + %inline %{ enum Hello { Hi, Hola @@ -170,7 +174,8 @@ const namet def_namet = {'h','o',0, 'l','a'}; extern namet gbl_namet; - + + char fixsize[8] = {'h','o',0, 'l','a', 0, 0, 0}; %} @@ -383,6 +388,16 @@ macro(size_t, pfx, sizet) }; + typedef Foo* foo_ptr; + + foo_ptr fptr_val(foo_ptr a) { + return a; + } + + const foo_ptr& fptr_ref(const foo_ptr& a) { + return a; + } + struct Test { diff --git a/SWIG/Examples/test-suite/python/lib_std_except.i b/SWIG/Examples/test-suite/python/lib_std_except.i index 5bc54a916..098315d77 100644 --- a/SWIG/Examples/test-suite/python/lib_std_except.i +++ b/SWIG/Examples/test-suite/python/lib_std_except.i @@ -1,6 +1,6 @@ %module lib_std_except -%include "std_except.i" +%include %inline %{ diff --git a/SWIG/Examples/test-suite/python/lib_std_string.i b/SWIG/Examples/test-suite/python/lib_std_string.i index b2cc353fc..b48324976 100644 --- a/SWIG/Examples/test-suite/python/lib_std_string.i +++ b/SWIG/Examples/test-suite/python/lib_std_string.i @@ -1,5 +1,6 @@ %module lib_std_string -%include "std_string.i" +%include +%include %template(string) std::basic_string; %inline %{ diff --git a/SWIG/Examples/test-suite/python/lib_std_wstring.i b/SWIG/Examples/test-suite/python/lib_std_wstring.i index 3d511eb6c..1e096eb8f 100644 --- a/SWIG/Examples/test-suite/python/lib_std_wstring.i +++ b/SWIG/Examples/test-suite/python/lib_std_wstring.i @@ -1,6 +1,6 @@ %module lib_std_wstring - -%include "std_wstring.i" +%include +%include %template(wstring) std::basic_string; diff --git a/SWIG/Examples/test-suite/python/primitive_types_runme.py b/SWIG/Examples/test-suite/python/primitive_types_runme.py index 04c5233d5..f31c2f15f 100644 --- a/SWIG/Examples/test-suite/python/primitive_types_runme.py +++ b/SWIG/Examples/test-suite/python/primitive_types_runme.py @@ -329,3 +329,18 @@ t2 = p.vtest(t) if t.var_namet != t2.var_namet: raise RuntimeError, "bad SWIGTYPE* typemap" + +if cvar.fixsize != 'ho\0la\0\0\0': + raise RuntimeError, "bad FIXSIZE typemap" + +cvar.fixsize = 'ho' +if cvar.fixsize != 'ho\0\0\0\0\0\0': + raise RuntimeError, "bad FIXSIZE typemap" + + +f = Foo(3) +f1 = fptr_val(f) +f2 = fptr_ref(f) +if f1._a != f2._a: + raise RuntimeError, "bad const ptr& typemap" + diff --git a/SWIG/Examples/test-suite/python/template_default_arg_runme.py b/SWIG/Examples/test-suite/python/template_default_arg_runme.py index 3f5d0aa91..235a2313a 100644 --- a/SWIG/Examples/test-suite/python/template_default_arg_runme.py +++ b/SWIG/Examples/test-suite/python/template_default_arg_runme.py @@ -2,7 +2,7 @@ import template_default_arg helloInt = template_default_arg.Hello_int() -helloInt.foo(Hello_int.Hi.hi) +helloInt.foo(template_default_arg.Hello_int.hi) x = template_default_arg.X_int() diff --git a/SWIG/Examples/test-suite/python/template_typedef_runme.py b/SWIG/Examples/test-suite/python/template_typedef_runme.py index 1de6bb807..e2efb7246 100644 --- a/SWIG/Examples/test-suite/python/template_typedef_runme.py +++ b/SWIG/Examples/test-suite/python/template_typedef_runme.py @@ -33,7 +33,7 @@ except: # the old large format -if not SWIG_TypeQuery("vfncs::ArithUnaryFunction::argument_type,vfncs::arith_traits::result_type > *"): +if not SWIG_TypeQuery("vfncs::ArithUnaryFunction::argument_type,vfncs::arith_traits::result_type > *"): raise RuntimeError diff --git a/SWIG/Examples/test-suite/template_explicit.i b/SWIG/Examples/test-suite/template_explicit.i index 848f0fcbb..7e39b22c2 100644 --- a/SWIG/Examples/test-suite/template_explicit.i +++ b/SWIG/Examples/test-suite/template_explicit.i @@ -5,11 +5,11 @@ %warnfilter(801) vector; /* Ruby, wrong class name */ %warnfilter(801) vector; /* Ruby, wrong class name */ -// This warnfilter doesn't work -// %warnfilter(320); -// back to pragma +// #pragma is used for warnings that are not associated to +// specific nodes. #pragma SWIG nowarn=-320 + /* Let's just grab the original header file here */ %inline %{ diff --git a/SWIG/Examples/test-suite/template_opaque.i b/SWIG/Examples/test-suite/template_opaque.i index dee5d40ed..b5406d530 100644 --- a/SWIG/Examples/test-suite/template_opaque.i +++ b/SWIG/Examples/test-suite/template_opaque.i @@ -14,7 +14,7 @@ %inline { namespace A { struct OpaqueStruct; - typedef struct OpaqueStruct OpaqueType; + typedef OpaqueStruct OpaqueType; typedef std::vector OpaqueVectorType; void FillVector(OpaqueVectorType& v) diff --git a/SWIG/Examples/test-suite/template_specialization_defarg.i b/SWIG/Examples/test-suite/template_specialization_defarg.i index efa2c5aa8..2f664c6f2 100644 --- a/SWIG/Examples/test-suite/template_specialization_defarg.i +++ b/SWIG/Examples/test-suite/template_specialization_defarg.i @@ -36,6 +36,42 @@ } }; + + template + struct Alloc + { + }; + + + template + struct D + { + D(int){} + }; + + + template <> + struct D + { + D(){} + int foo() { return 0; } + }; + + + + template > + struct Vector + { + Vector(int){} + }; + + + template <> + struct Vector + { + Vector(){} + int foo() { return 0; } + }; %} @@ -49,4 +85,11 @@ // // This one fails // +%template(C_dd) C; %template(C_d) C; + +%template(D_i) D; +%template(D_d) D; + +%template(Vector_i) Vector; +%template(Vector_d) Vector >; diff --git a/SWIG/Examples/test-suite/template_typedef_ptr.i b/SWIG/Examples/test-suite/template_typedef_ptr.i index 2bb441481..23de9c9c1 100644 --- a/SWIG/Examples/test-suite/template_typedef_ptr.i +++ b/SWIG/Examples/test-suite/template_typedef_ptr.i @@ -17,7 +17,7 @@ template struct Test { - Test (A a, B* b) + Test (B* a) { }