diff --git a/SWIG/Examples/test-suite/arrays.i b/SWIG/Examples/test-suite/arrays.i index 037f99159..f252d800f 100644 --- a/SWIG/Examples/test-suite/arrays.i +++ b/SWIG/Examples/test-suite/arrays.i @@ -57,3 +57,13 @@ void array_pointer_func(int (*x)[10]) {} %} +%inline %{ +typedef float FLOAT; + +typedef FLOAT cartPosition_t[3]; + +typedef struct { +cartPosition_t p; +} CartPoseData_t; + +%} diff --git a/SWIG/Examples/test-suite/common.mk b/SWIG/Examples/test-suite/common.mk index db061761b..b2b5e6dd6 100644 --- a/SWIG/Examples/test-suite/common.mk +++ b/SWIG/Examples/test-suite/common.mk @@ -45,8 +45,11 @@ LIBPREFIX = lib # Broken C++ test cases. (Can be run individually using make testcase.cpptest.) CPP_TEST_BROKEN += \ + cpp_broken \ namespace_union \ - overload_complicated + nested_comment \ + overload_complicated \ + template_expr \ # Broken C test cases. (Can be run individually using make testcase.ctest.) C_TEST_BROKEN += \ @@ -168,6 +171,7 @@ CPP_TEST_CASES += \ newobject1 \ overload_copy \ overload_extend \ + overload_rename \ overload_simple \ overload_subtype \ overload_template \ @@ -178,10 +182,12 @@ CPP_TEST_CASES += \ pure_virtual \ redefined \ reference_global_vars \ + register_par \ rename_scope \ return_const_value \ return_value_scope \ rname \ + sizet \ smart_pointer_const \ smart_pointer_const2 \ smart_pointer_multi \ diff --git a/SWIG/Examples/test-suite/cpp_broken.i b/SWIG/Examples/test-suite/cpp_broken.i new file mode 100644 index 000000000..a7857c2c0 --- /dev/null +++ b/SWIG/Examples/test-suite/cpp_broken.i @@ -0,0 +1,26 @@ +%module cpp_broken + + +// bug #1060789 +%inline %{ +#define MASK(shift, size) (((1 << (size)) - 1) << (shift)) +#define SOME_MASK_DEF (80*MASK(8, 10)) +%} + +// bug #1060079 +%inline %{ +#define FIELD(name, width) unsigned int name:width +#define SOME_CONST 2 +#define NEXT_CONST (2 * SOME_CONST) + +typedef struct { +FIELD(a, SOME_CONST); +FIELD(b, NEXT_CONST); +} MyStruct_t; +%} + +// bug #994301 +%inline %{ +#define max(a,b) ((a) > (b) ? (a) : (b)) +%} + diff --git a/SWIG/Examples/test-suite/mixed_types.i b/SWIG/Examples/test-suite/mixed_types.i index cf8dd08a2..1cc8656eb 100644 --- a/SWIG/Examples/test-suite/mixed_types.i +++ b/SWIG/Examples/test-suite/mixed_types.i @@ -69,9 +69,14 @@ } - + template struct NameT { + }; + + typedef char name[8]; typedef char namea[]; + + typedef NameT name_t[8]; char* test_a(char hello[8], char hi[], @@ -84,11 +89,26 @@ return 1; } -/* gcc doesn't like this one. Removing until reason resolved. +/* gcc doesn't like this one. Removing until reason resolved.*/ int test_c(const name& n1) { return 1; } -*/ + + int test_d(name* n1) { + return 1; + } + + int test_e(const name_t& n1) { + return 1; + } + + int test_f(name_t n1) { + return 1; + } + + int test_g(name_t* n1) { + return 1; + } struct Foo { diff --git a/SWIG/Examples/test-suite/nested_comment.i b/SWIG/Examples/test-suite/nested_comment.i new file mode 100644 index 000000000..2c0ff4196 --- /dev/null +++ b/SWIG/Examples/test-suite/nested_comment.i @@ -0,0 +1,21 @@ +%module nested_comment + +// this example shows a problem with 'dump_nested' (parser.y). + +%inline %{ +typedef struct s1 { +union { +int fsc; /* genie structure hiding - Conductor +*/ +int fso; /* genie structure hiding - FSOptions +*/ +struct { +double *vals; +int size; +} vector_val; /* matrix values are mainly used +in rlgc models */ +char *name; +} n ; +} s2; + +%} diff --git a/SWIG/Examples/test-suite/overload_rename.i b/SWIG/Examples/test-suite/overload_rename.i new file mode 100644 index 000000000..14ed7ec73 --- /dev/null +++ b/SWIG/Examples/test-suite/overload_rename.i @@ -0,0 +1,28 @@ +%module overload_rename + + +%{ + +class Foo { +public: + Foo(float a, float b=1.0) + { + } + r + Foo(float a, int c, float b=1.0) + { + } + +}; + +%} + +%rename(Foo_int) Foo::Foo(float a, int c, float b=1.0); + +class Foo { +public: + Foo(float a, float b=1.0); + Foo(float a, int c, float b=1.0); +}; + + diff --git a/SWIG/Examples/test-suite/python/Makefile.in b/SWIG/Examples/test-suite/python/Makefile.in index 3064a60e1..885158095 100644 --- a/SWIG/Examples/test-suite/python/Makefile.in +++ b/SWIG/Examples/test-suite/python/Makefile.in @@ -75,3 +75,8 @@ run_testcase = \ clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean +cvsignore: + @echo '*wrap* *.pyc *.so *.dll *.exp *.lib' + @echo Makefile + @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done + @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done diff --git a/SWIG/Examples/test-suite/python/overload_rename_runme.py b/SWIG/Examples/test-suite/python/overload_rename_runme.py new file mode 100644 index 000000000..b192f7d5d --- /dev/null +++ b/SWIG/Examples/test-suite/python/overload_rename_runme.py @@ -0,0 +1,8 @@ +import overload_rename + + +f = overload_rename.Foo(1) +f = overload_rename.Foo(1,1) +f = overload_rename.Foo_int(1,1) +f = overload_rename.Foo_int(1,1,1) + diff --git a/SWIG/Examples/test-suite/register_par.i b/SWIG/Examples/test-suite/register_par.i new file mode 100644 index 000000000..a410c0dfe --- /dev/null +++ b/SWIG/Examples/test-suite/register_par.i @@ -0,0 +1,6 @@ +%module register_par + +// bug # 924413 +%inline { + void clear_tree_flags(register struct tree *tp, register int i); +} diff --git a/SWIG/Examples/test-suite/sizet.i b/SWIG/Examples/test-suite/sizet.i new file mode 100644 index 000000000..1b4d448ee --- /dev/null +++ b/SWIG/Examples/test-suite/sizet.i @@ -0,0 +1,44 @@ +%module sizet +%{ +#include +%} + +%include "std_common.i" +%include "std_vector.i" + +%inline +{ + size_t test1(size_t s) + { + return s; + } + + std::size_t test2(std::size_t s) + { + return s; + } + + const std::size_t& test3(const std::size_t& s) + { + return s; + } + +} + +#ifdef SWIGPYTHON +%template(vectors) std::vector; + +%inline +{ + std::vector testv1(std::vector s) + { + return s; + } + + const std::vector& testv2(const std::vector& s) + { + return s; + } + +} +#endif diff --git a/SWIG/Examples/test-suite/template_expr.i b/SWIG/Examples/test-suite/template_expr.i new file mode 100644 index 000000000..cf642c7cb --- /dev/null +++ b/SWIG/Examples/test-suite/template_expr.i @@ -0,0 +1,25 @@ +%module template_expr + +// bug #925555 +%inline %{ + + template + inline const ThisType & + ConcatenationOf(const vctFixedLengthConstSequenceBase<_size - 1, + __stride, __elementTypeSequence, __dataPtrType> & other, + __elementType last); +%} + +// bug #956282 +%inline %{ + + +template +class X {}; + + +%} + +%template(X_1) X<1>; +%template(X_m1) X<-1>; diff --git a/SWIG/Examples/test-suite/typedef_array_member.i b/SWIG/Examples/test-suite/typedef_array_member.i index 8663fd335..bb66efd77 100644 --- a/SWIG/Examples/test-suite/typedef_array_member.i +++ b/SWIG/Examples/test-suite/typedef_array_member.i @@ -8,3 +8,18 @@ struct Foo { }; %} + + +%ignore jbuf_tag; +%inline %{ + + typedef struct jbuf_tag + { + int mask; + } jbuf[1]; + + struct Ast_channel { + jbuf jmp[32]; + }; + +%}