Merge branch 'master' into gsoc2017-php7-classes-via-c-api
This commit is contained in:
commit
f72d9c1f21
103 changed files with 2332 additions and 853 deletions
|
|
@ -30,5 +30,5 @@ f.enum_test(example.Foo.LUDICROUS);
|
|||
// enum value BLUE of enum color is accessed as property of cconst
|
||||
console.log("example.BLUE= " + example.BLUE);
|
||||
|
||||
// enum value LUDICROUS of enum Foo::speed is accessed as as property of cconst
|
||||
// enum value LUDICROUS of enum Foo::speed is accessed as property of cconst
|
||||
console.log("example.speed.LUDICROUS= " + example.Foo.LUDICROUS);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO");
|
|||
|
||||
# Create an instance of our employee extension class, CEO. The calls to
|
||||
# getName() and getPosition() are standard, the call to getTitle() uses
|
||||
# the director wrappers to call CEO.getPosition. e = CEO("Alice")
|
||||
# the director wrappers to call CEO.getPosition.
|
||||
|
||||
e = CEO("Alice");
|
||||
printf("%s is a %s\n",e.getName(),e.getPosition());
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class CEO(example.Manager):
|
|||
|
||||
# Create an instance of our employee extension class, CEO. The calls to
|
||||
# getName() and getPosition() are standard, the call to getTitle() uses
|
||||
# the director wrappers to call CEO.getPosition. e = CEO("Alice")
|
||||
# the director wrappers to call CEO.getPosition.
|
||||
|
||||
e = CEO("Alice")
|
||||
print e.getName(), "is a", e.getPosition()
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
import robin
|
||||
|
||||
assert(robin.run() == "AWAY!")
|
||||
if not(robin.run() == "AWAY!"):
|
||||
raise RuntimeError("test failed")
|
||||
|
|
|
|||
|
|
@ -4,4 +4,5 @@ sys.path.insert(0, 'path1')
|
|||
|
||||
from brave import robin
|
||||
|
||||
assert(robin.run() == "AWAY!")
|
||||
if not(robin.run() == "AWAY!"):
|
||||
raise RuntimeError("test failed")
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ sys.path.insert(0, 'path3')
|
|||
|
||||
from brave import robin
|
||||
|
||||
assert(robin.run() == "AWAY!")
|
||||
if not(robin.run() == "AWAY!"):
|
||||
raise RuntimeError("test failed")
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ sys.path.insert(0, 'path3')
|
|||
|
||||
from brave import robin
|
||||
|
||||
assert(robin.run() == "AWAY!")
|
||||
if not(robin.run() == "AWAY!"):
|
||||
raise RuntimeError("test failed")
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ import pkg1.foo
|
|||
|
||||
print " Finished importing pkg1.foo"
|
||||
|
||||
assert(pkg1.foo.count() == 3)
|
||||
if not(pkg1.foo.count() == 3):
|
||||
raise RuntimeError("test failed")
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ import pkg1.foo
|
|||
|
||||
print " Finished importing pkg1.foo"
|
||||
|
||||
assert(pkg1.foo.count() == 3)
|
||||
if not(pkg1.foo.count() == 3):
|
||||
raise RuntimeError("test failed")
|
||||
|
|
|
|||
|
|
@ -47,6 +47,6 @@ testdir/README file.
|
|||
Further Documentation
|
||||
---------------------
|
||||
|
||||
There is documentation about the test-suite and how to use use it in
|
||||
There is documentation about the test-suite and how to use it in
|
||||
the SWIG documentation - Doc/Manual/Extending.html#Extending_test_suite.
|
||||
|
||||
|
|
|
|||
160
Examples/test-suite/class_scope_namespace.i
Normal file
160
Examples/test-suite/class_scope_namespace.i
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
// Test a mix of forward class declarations, class definitions, using declarations and using directives.
|
||||
|
||||
%module class_scope_namespace
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) H::HH;
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Space8::I::II;
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
namespace Space1 {
|
||||
namespace SubSpace1 {
|
||||
struct A {
|
||||
void aa(Space1::SubSpace1::A, SubSpace1::A, A) {}
|
||||
};
|
||||
void aaa(Space1::SubSpace1::A, SubSpace1::A, A) {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Space2 {
|
||||
struct B;
|
||||
}
|
||||
using Space2::B;
|
||||
#ifdef __clang__
|
||||
namespace Space2 {
|
||||
struct B {
|
||||
void bb(Space2::B, B) {}
|
||||
};
|
||||
}
|
||||
#else
|
||||
struct B {
|
||||
void bb(Space2::B, B) {}
|
||||
};
|
||||
#endif
|
||||
void bbb(Space2::B, B) {}
|
||||
|
||||
namespace Space3 {
|
||||
namespace SubSpace3 {
|
||||
struct C;
|
||||
struct D;
|
||||
}
|
||||
}
|
||||
struct C;
|
||||
struct D;
|
||||
namespace Space3 {
|
||||
struct C;
|
||||
struct SubSpace3::C {
|
||||
void cc(Space3::SubSpace3::C, SubSpace3::C) {}
|
||||
};
|
||||
using SubSpace3::D;
|
||||
struct SubSpace3::D {
|
||||
void dd(Space3::SubSpace3::D, SubSpace3::D, D) {}
|
||||
};
|
||||
void ccc(Space3::SubSpace3::C, SubSpace3::C) {}
|
||||
void ddd(Space3::SubSpace3::D, SubSpace3::D, D) {}
|
||||
}
|
||||
|
||||
namespace Space4 {
|
||||
namespace SubSpace4 {
|
||||
struct E;
|
||||
}
|
||||
}
|
||||
using namespace Space4;
|
||||
using SubSpace4::E;
|
||||
// Was added to incorrect namespace in swig-3.0.12
|
||||
struct SubSpace4::E {
|
||||
void ee(Space4::SubSpace4::E, SubSpace4::E, E) {}
|
||||
};
|
||||
void eee(Space4::SubSpace4::E, SubSpace4::E, E) {}
|
||||
|
||||
namespace Space5 {
|
||||
namespace SubSpace5 {
|
||||
namespace SubSubSpace5 {
|
||||
struct F;
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Space5 {
|
||||
using namespace SubSpace5;
|
||||
using SubSubSpace5::F;
|
||||
// Was added to incorrect namespace in swig-3.0.12
|
||||
struct SubSubSpace5::F {
|
||||
void ff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
|
||||
};
|
||||
void fff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
|
||||
}
|
||||
|
||||
namespace Space6 {
|
||||
struct G;
|
||||
namespace SubSpace6 {
|
||||
struct G;
|
||||
}
|
||||
}
|
||||
namespace Space6 {
|
||||
struct SubSpace6::G {
|
||||
void gg(Space6::SubSpace6::G, SubSpace6::G) {}
|
||||
};
|
||||
void ggg(Space6::SubSpace6::G, SubSpace6::G) {}
|
||||
}
|
||||
|
||||
struct HH;
|
||||
struct H {
|
||||
struct HH {
|
||||
void hh(H::HH) {}
|
||||
};
|
||||
};
|
||||
void hhh(H::HH) {}
|
||||
|
||||
namespace Space8 {
|
||||
struct II;
|
||||
struct I {
|
||||
struct II {
|
||||
void ii(Space8::I::II, I::II) {}
|
||||
};
|
||||
};
|
||||
void iii(Space8::I::II, I::II) {}
|
||||
}
|
||||
|
||||
struct J;
|
||||
namespace Space9 {
|
||||
namespace SubSpace9 {
|
||||
struct J {
|
||||
void jj(Space9::SubSpace9::J, SubSpace9::J, J) {}
|
||||
};
|
||||
void jjj(Space9::SubSpace9::J, SubSpace9::J, J) {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Space10 {
|
||||
struct K;
|
||||
}
|
||||
namespace Space10 {
|
||||
namespace SubSpace10 {
|
||||
struct K {
|
||||
void kk(Space10::SubSpace10::K, SubSpace10::K, K) {}
|
||||
};
|
||||
void kkk(Space10::SubSpace10::K, SubSpace10::K, K) {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace OtherSpace {
|
||||
struct L;
|
||||
struct M;
|
||||
}
|
||||
using OtherSpace::L;
|
||||
namespace Space11 {
|
||||
using OtherSpace::M;
|
||||
namespace SubSpace11 {
|
||||
struct L {
|
||||
void ll(Space11::SubSpace11::L, SubSpace11::L, L) {}
|
||||
};
|
||||
void lll(Space11::SubSpace11::L, SubSpace11::L, L) {}
|
||||
struct M {
|
||||
void mm(Space11::SubSpace11::M, SubSpace11::M, M) {}
|
||||
};
|
||||
void mmm(Space11::SubSpace11::M, SubSpace11::M, M) {}
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
|
@ -136,6 +136,7 @@ CPP_TEST_CASES += \
|
|||
char_binary \
|
||||
char_strings \
|
||||
chartest \
|
||||
class_scope_namespace \
|
||||
class_forward \
|
||||
class_ignore \
|
||||
class_scope_weird \
|
||||
|
|
@ -291,6 +292,7 @@ CPP_TEST_CASES += \
|
|||
multiple_inheritance_shared_ptr \
|
||||
name_cxx \
|
||||
name_warnings \
|
||||
namespace_chase \
|
||||
namespace_class \
|
||||
namespace_enum \
|
||||
namespace_extend \
|
||||
|
|
@ -418,6 +420,7 @@ CPP_TEST_CASES += \
|
|||
template_default_inherit \
|
||||
template_default_qualify \
|
||||
template_default_vw \
|
||||
template_empty_inherit \
|
||||
template_enum \
|
||||
template_enum_ns_inherit \
|
||||
template_enum_typedef \
|
||||
|
|
@ -434,6 +437,7 @@ CPP_TEST_CASES += \
|
|||
template_methods \
|
||||
template_namespace_forward_declaration \
|
||||
template_using_directive_and_declaration_forward \
|
||||
template_using_directive_typedef \
|
||||
template_nested \
|
||||
template_nested_typemaps \
|
||||
template_ns \
|
||||
|
|
@ -444,6 +448,7 @@ CPP_TEST_CASES += \
|
|||
template_ns_enum2 \
|
||||
template_ns_inherit \
|
||||
template_ns_scope \
|
||||
template_parameters_global_scope \
|
||||
template_partial_arg \
|
||||
template_partial_specialization \
|
||||
template_partial_specialization_typedef \
|
||||
|
|
|
|||
|
|
@ -1,12 +1,32 @@
|
|||
/* This test case checks whether SWIG correctly parses and ignores the
|
||||
keywords "static_assert()" inside the class or struct.
|
||||
/* This test case checks whether SWIG correctly parses and ignores
|
||||
"static_assert()" in various places.
|
||||
*/
|
||||
%module cpp11_static_assert
|
||||
|
||||
%inline %{
|
||||
static_assert(sizeof(int) >= 2, "What? int size is invalid!");
|
||||
|
||||
namespace dummy {
|
||||
// C++17 allows the message to be omitted, so check that works too.
|
||||
// But only show the C++17 version to SWIG, as the compiler may
|
||||
// lack C++17 support.
|
||||
#ifdef SWIG
|
||||
static_assert(sizeof(int) >= sizeof(short));
|
||||
#else
|
||||
static_assert(sizeof(int) >= sizeof(short), "blah");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct Check1 {
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
Check1() {
|
||||
#ifdef SWIG
|
||||
static_assert(true);
|
||||
#else
|
||||
static_assert(true, "true");
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class li_std_map_runme {
|
|||
|
||||
public static void Main()
|
||||
{
|
||||
// Set up an int int map
|
||||
// Set up an string to int map
|
||||
StringIntMap simap = new StringIntMap();
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Swig {
|
|||
size_t ExceptionMethod()
|
||||
{
|
||||
// Check positioning of director code in wrapper file
|
||||
// Below is what we really want to test, but director exceptions vary too much across across all languages
|
||||
// Below is what we really want to test, but director exceptions vary too much across all languages
|
||||
// throw Swig::DirectorException("DirectorException was not in scope!!");
|
||||
// Instead check definition of Director class as that is defined in the same place as DirectorException (director.swg)
|
||||
size_t size = sizeof(Swig::Director);
|
||||
|
|
|
|||
26
Examples/test-suite/errors/cpp_class_definition.i
Normal file
26
Examples/test-suite/errors/cpp_class_definition.i
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
%module xxx
|
||||
|
||||
// This should error but doesn't
|
||||
#if 0
|
||||
namespace OtherSpace {
|
||||
struct L;
|
||||
}
|
||||
namespace Space11 {
|
||||
namespace SubSpace11 {
|
||||
using OtherSpace::L;
|
||||
struct L {
|
||||
void ll();
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Space1 {
|
||||
struct A;
|
||||
}
|
||||
namespace Space2 {
|
||||
struct Space1::A {
|
||||
void x();
|
||||
};
|
||||
}
|
||||
|
||||
1
Examples/test-suite/errors/cpp_class_definition.stderr
Normal file
1
Examples/test-suite/errors/cpp_class_definition.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_class_definition.i:22: Error: 'Space1::A' resolves to 'Space1::A' and was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
|
||||
9
Examples/test-suite/errors/cpp_invalid_template.i
Normal file
9
Examples/test-suite/errors/cpp_invalid_template.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%module cpp_invalid_scope
|
||||
|
||||
%template(abc) SSS::AAA<int>;
|
||||
|
||||
namespace UUU {
|
||||
struct JJJ;
|
||||
}
|
||||
|
||||
%template(xxx) UUU::JJJ<int>;
|
||||
3
Examples/test-suite/errors/cpp_invalid_template.stderr
Normal file
3
Examples/test-suite/errors/cpp_invalid_template.stderr
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
cpp_invalid_template.i:3: Error: Undefined scope 'SSS'
|
||||
cpp_invalid_template.i:3: Error: Template 'SSS::AAA' undefined.
|
||||
cpp_invalid_template.i:9: Error: 'JJJ' is not defined as a template. (classforward)
|
||||
40
Examples/test-suite/errors/cpp_namespace_template_bad.i
Normal file
40
Examples/test-suite/errors/cpp_namespace_template_bad.i
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
%module namespace_template
|
||||
|
||||
namespace test {
|
||||
template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
|
||||
template<typename T> class vector {
|
||||
public:
|
||||
vector() { }
|
||||
~vector() { }
|
||||
};
|
||||
}
|
||||
|
||||
namespace test2 {
|
||||
using namespace test;
|
||||
%template(maxshort) max<short>;
|
||||
%template(vectorshort) vector<short>;
|
||||
}
|
||||
|
||||
namespace test3 {
|
||||
using test::max;
|
||||
using test::vector;
|
||||
%template(maxlong) max<long>;
|
||||
%template(vectorlong) vector<long>;
|
||||
}
|
||||
|
||||
namespace test4 {
|
||||
using namespace test;
|
||||
typedef int Integer;
|
||||
}
|
||||
|
||||
namespace test4 {
|
||||
%template(maxInteger) max<Integer>;
|
||||
%template(vectorInteger) vector<Integer>;
|
||||
}
|
||||
|
||||
using namespace test;
|
||||
namespace test5 {
|
||||
%template(maxdouble) max<double>;
|
||||
%template(vectordouble) vector<double>;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
cpp_namespace_template_bad.i:14: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:15: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:21: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:22: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:31: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:32: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:37: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
|
||||
cpp_namespace_template_bad.i:37: Error: Template 'max' undefined.
|
||||
cpp_namespace_template_bad.i:38: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
cpp_nested_template.i:9: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'A' instead of within scope ''.
|
||||
cpp_nested_template.i:9: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
|
||||
cpp_nested_template.i:18: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'B' instead of within scope ''.
|
||||
cpp_nested_template.i:18: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
|
||||
|
|
|
|||
57
Examples/test-suite/errors/cpp_template_scope.i
Normal file
57
Examples/test-suite/errors/cpp_template_scope.i
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
%module xxx
|
||||
|
||||
namespace std {
|
||||
template<typename T> class vector {};
|
||||
}
|
||||
|
||||
struct S1 {};
|
||||
struct S2 {};
|
||||
struct S3 {};
|
||||
struct S4 {};
|
||||
struct S5 {};
|
||||
struct S6 {};
|
||||
struct S7 {};
|
||||
|
||||
// valid
|
||||
namespace std {
|
||||
%template(vi1) vector<S1>;
|
||||
template class vector<S1>;
|
||||
}
|
||||
|
||||
// valid
|
||||
using namespace std;
|
||||
%template(vi2) vector<S2>;
|
||||
template class vector<S2>;
|
||||
|
||||
// valid
|
||||
using std::vector;
|
||||
%template(vi3) vector<S3>;
|
||||
template class vector<S3>;
|
||||
|
||||
// ill-formed
|
||||
namespace unrelated {
|
||||
using std::vector;
|
||||
%template(vi4) vector<S4>;
|
||||
template class vector<S4>;
|
||||
}
|
||||
|
||||
// ill-formed
|
||||
namespace unrelated {
|
||||
using namespace std;
|
||||
%template(vi5) vector<S5>;
|
||||
template class vector<S5>;
|
||||
}
|
||||
|
||||
// ill-formed
|
||||
namespace unrelated {
|
||||
namespace std {
|
||||
%template(vi6) vector<S6>;
|
||||
template class vector<S6>;
|
||||
}
|
||||
}
|
||||
|
||||
// ill-formed
|
||||
namespace unrelated {
|
||||
%template(vi7) std::vector<S7>;
|
||||
template class std::vector<S7>;
|
||||
}
|
||||
11
Examples/test-suite/errors/cpp_template_scope.stderr
Normal file
11
Examples/test-suite/errors/cpp_template_scope.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
cpp_template_scope.i:18: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_scope.i:24: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_scope.i:29: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
|
||||
cpp_template_scope.i:35: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_scope.i:41: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
|
||||
cpp_template_scope.i:42: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_scope.i:48: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated::std' instead of within scope 'std'.
|
||||
cpp_template_scope.i:49: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_scope.i:55: Error: 'std::vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
|
||||
cpp_template_scope.i:56: Warning 320: Explicit template instantiation ignored.
|
||||
59
Examples/test-suite/java/class_scope_namespace_runme.java
Normal file
59
Examples/test-suite/java/class_scope_namespace_runme.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
import class_scope_namespace.*;
|
||||
|
||||
public class class_scope_namespace_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("class_scope_namespace");
|
||||
} 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[])
|
||||
{
|
||||
A a = new A();
|
||||
B b = new B();
|
||||
C c = new C();
|
||||
D d = new D();
|
||||
E e = new E();
|
||||
F f = new F();
|
||||
G g = new G();
|
||||
H.HH h = new H.HH();
|
||||
I.II i = new I.II();
|
||||
J j = new J();
|
||||
K k = new K();
|
||||
L l = new L();
|
||||
M m = new M();
|
||||
|
||||
a.aa(a, a, a);
|
||||
b.bb(b, b);
|
||||
c.cc(c, c);
|
||||
d.dd(d, d, d);
|
||||
e.ee(e, e, e);
|
||||
f.ff(f, f, f, f);
|
||||
g.gg(g, g);
|
||||
h.hh(h);
|
||||
i.ii(i, i);
|
||||
j.jj(j, j, j);
|
||||
k.kk(k, k, k);
|
||||
l.ll(l, l, l);
|
||||
m.mm(m, m, m);
|
||||
|
||||
class_scope_namespace.aaa(a, a, a);
|
||||
class_scope_namespace.bbb(b, b);
|
||||
class_scope_namespace.ccc(c, c);
|
||||
class_scope_namespace.ddd(d, d, d);
|
||||
class_scope_namespace.eee(e, e, e);
|
||||
class_scope_namespace.fff(f, f, f, f);
|
||||
class_scope_namespace.ggg(g, g);
|
||||
class_scope_namespace.hhh(h);
|
||||
class_scope_namespace.iii(i, i);
|
||||
class_scope_namespace.jjj(j, j, j);
|
||||
class_scope_namespace.kkk(k, k, k);
|
||||
class_scope_namespace.lll(l, l, l);
|
||||
class_scope_namespace.mmm(m, m, m);
|
||||
}
|
||||
}
|
||||
19
Examples/test-suite/java/cpp11_template_typedefs_runme.java
Normal file
19
Examples/test-suite/java/cpp11_template_typedefs_runme.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import cpp11_template_typedefs.*;
|
||||
|
||||
public class cpp11_template_typedefs_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_template_typedefs");
|
||||
} 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[]) {
|
||||
int alloc1 = cpp11_template_typedefs.get_bucket_allocator1();
|
||||
int alloc2 = cpp11_template_typedefs.get_bucket_allocator2();
|
||||
}
|
||||
}
|
||||
|
||||
26
Examples/test-suite/java/namespace_chase_runme.java
Normal file
26
Examples/test-suite/java/namespace_chase_runme.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
import namespace_chase.*;
|
||||
|
||||
public class namespace_chase_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("namespace_chase");
|
||||
} 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[])
|
||||
{
|
||||
Struct1A s1a = new Struct1A();
|
||||
Struct1B s1b = new Struct1B();
|
||||
Struct1C s1c = new Struct1C();
|
||||
|
||||
namespace_chase.sss3a(s1a, s1b, s1c);
|
||||
namespace_chase.sss3b(s1a, s1b, s1c);
|
||||
// needs fixing
|
||||
// namespace_chase.sss3c(s1a, s1b, s1c);
|
||||
}
|
||||
}
|
||||
32
Examples/test-suite/java/namespace_template_runme.java
Normal file
32
Examples/test-suite/java/namespace_template_runme.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
import namespace_template.*;
|
||||
|
||||
public class namespace_template_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("namespace_template");
|
||||
} 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[]) {
|
||||
vectorchar vc = new vectorchar();
|
||||
vectorshort vs = new vectorshort();
|
||||
vectorint vi = new vectorint();
|
||||
vectorlong vl = new vectorlong();
|
||||
|
||||
vc.blah((char)10);
|
||||
vs.blah((short)10);
|
||||
vi.blah(10);
|
||||
vl.blah(10);
|
||||
|
||||
vc.vectoruse(vc, vc);
|
||||
vs.vectoruse(vs, vs);
|
||||
vi.vectoruse(vi, vi);
|
||||
vl.vectoruse(vl, vl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
import template_parameters_global_scope.*;
|
||||
|
||||
public class template_parameters_global_scope_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_parameters_global_scope");
|
||||
} 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[]) {
|
||||
|
||||
int alloc = 0;
|
||||
|
||||
// Check 1
|
||||
alloc = template_parameters_global_scope.Bucket1();
|
||||
alloc = template_parameters_global_scope.Bucket2();
|
||||
alloc = template_parameters_global_scope.Bucket3();
|
||||
alloc = template_parameters_global_scope.Bucket4();
|
||||
alloc = template_parameters_global_scope.Bucket5();
|
||||
alloc = template_parameters_global_scope.Bucket6();
|
||||
|
||||
// Check 2
|
||||
alloc = template_parameters_global_scope.Spade1();
|
||||
alloc = template_parameters_global_scope.Spade2();
|
||||
alloc = template_parameters_global_scope.Spade3();
|
||||
alloc = template_parameters_global_scope.Spade4();
|
||||
alloc = template_parameters_global_scope.Spade5();
|
||||
alloc = template_parameters_global_scope.Spade6();
|
||||
|
||||
// Check 3
|
||||
alloc = template_parameters_global_scope.Ball1();
|
||||
alloc = template_parameters_global_scope.Ball2();
|
||||
alloc = template_parameters_global_scope.Ball3();
|
||||
alloc = template_parameters_global_scope.Ball4();
|
||||
alloc = template_parameters_global_scope.Ball5();
|
||||
alloc = template_parameters_global_scope.Ball6();
|
||||
|
||||
// Check 4
|
||||
alloc = template_parameters_global_scope.Bat1();
|
||||
alloc = template_parameters_global_scope.Bat2();
|
||||
alloc = template_parameters_global_scope.Bat3();
|
||||
alloc = template_parameters_global_scope.Bat4();
|
||||
alloc = template_parameters_global_scope.Bat5();
|
||||
alloc = template_parameters_global_scope.Bat6();
|
||||
|
||||
// Check 5
|
||||
alloc = template_parameters_global_scope.Chair1();
|
||||
alloc = template_parameters_global_scope.Chair2();
|
||||
alloc = template_parameters_global_scope.Chair3();
|
||||
alloc = template_parameters_global_scope.Chair4();
|
||||
alloc = template_parameters_global_scope.Chair5();
|
||||
alloc = template_parameters_global_scope.Chair6();
|
||||
|
||||
// Check 6
|
||||
alloc = template_parameters_global_scope.Table1();
|
||||
alloc = template_parameters_global_scope.Table2();
|
||||
alloc = template_parameters_global_scope.Table3();
|
||||
alloc = template_parameters_global_scope.Table4();
|
||||
alloc = template_parameters_global_scope.Table5();
|
||||
alloc = template_parameters_global_scope.Table6();
|
||||
|
||||
/*
|
||||
alloc = template_parameters_global_scope.rejig1();
|
||||
alloc = template_parameters_global_scope.rejig2();
|
||||
alloc = template_parameters_global_scope.rejig3();
|
||||
alloc = template_parameters_global_scope.rejig4();
|
||||
alloc = template_parameters_global_scope.rejig5();
|
||||
alloc = template_parameters_global_scope.rejig6();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
@ -19,32 +19,32 @@ public class template_using_directive_and_declaration_forward_runme {
|
|||
template_using_directive_and_declaration_forward.useit1b(new Thing1Int());
|
||||
template_using_directive_and_declaration_forward.useit1c(new Thing1Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit2(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2a(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2b(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2c(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2d(new Thing2Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit3(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3a(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3b(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3c(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3d(new Thing3Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit4(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4a(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4b(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4c(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4d(new Thing4Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit5(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5a(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5b(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5c(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5d(new Thing5Int());
|
||||
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit7(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7a(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7b(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7c(new Thing7Int());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
import template_using_directive_typedef.*;
|
||||
|
||||
public class template_using_directive_typedef_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_using_directive_typedef");
|
||||
} 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[]) {
|
||||
Vector_Obj vo = new Vector_Obj();
|
||||
|
||||
Holder h = new Holder();
|
||||
h.holder_use1(vo, vo, vo);
|
||||
h.holder_use2(vo, vo, vo);
|
||||
h.holder_use3(vo, vo, vo);
|
||||
|
||||
template_using_directive_typedef.tns_holder_use(vo, vo);
|
||||
template_using_directive_typedef.tns_use(vo, vo, vo);
|
||||
template_using_directive_typedef.global_holder_use(vo);
|
||||
template_using_directive_typedef.global_use(vo, vo, vo);
|
||||
template_using_directive_typedef.ns1_holder_use(vo);
|
||||
template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo);
|
||||
}
|
||||
}
|
||||
|
||||
36
Examples/test-suite/namespace_chase.i
Normal file
36
Examples/test-suite/namespace_chase.i
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
%module namespace_chase
|
||||
|
||||
%inline %{
|
||||
namespace Space1A {
|
||||
struct Struct1A {};
|
||||
namespace Space1B {
|
||||
struct Struct1B {};
|
||||
namespace Space1C {
|
||||
struct Struct1C {};
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Space2A {
|
||||
using namespace Space1A;
|
||||
namespace Space2B {
|
||||
using namespace Space1B;
|
||||
namespace Space2C {
|
||||
using namespace Space1C;
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Space3 {
|
||||
using namespace Space2A;
|
||||
void sss3a(Space1A::Struct1A, Space1A::Space1B::Struct1B, Space1A::Space1B::Space1C::Struct1C) {}
|
||||
void sss3b(Struct1A, Space1B::Struct1B, Space1B::Space1C::Struct1C) {}
|
||||
// To fix: the last two parameters below fail and result in SWIGTYPE_ types instead of proxy classes
|
||||
void sss3c(Space2A::Struct1A, Space2A::Space1B::Struct1B, Space2A::Space1B::Space1C::Struct1C) {}
|
||||
}
|
||||
namespace Space4 {
|
||||
using namespace Space2A;
|
||||
using namespace Space2A::Space2B;
|
||||
using namespace Space2A::Space2B::Space2C;
|
||||
void sss4a(Struct1A, Struct1B, Space2C::Struct1C) {}
|
||||
void sss4b(Struct1A, Struct1B, Struct1C) {}
|
||||
}
|
||||
%}
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
%module namespace_template
|
||||
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test2::vector<short>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test3::vector<long>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<test4::Integer>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<int>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<short>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<long>; /* Ruby, wrong class name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<test::Char>; /* Ruby, wrong class name */
|
||||
|
||||
%{
|
||||
#ifdef max
|
||||
|
|
@ -23,20 +23,9 @@ namespace test {
|
|||
char * blah(T x) {
|
||||
return (char *) "vector::blah";
|
||||
}
|
||||
void vectoruse(vector<T> a, test::vector<T> b) {}
|
||||
};
|
||||
}
|
||||
|
||||
namespace test2 {
|
||||
using namespace test;
|
||||
}
|
||||
|
||||
namespace test3 {
|
||||
using test::max;
|
||||
using test::vector;
|
||||
}
|
||||
|
||||
using namespace test2;
|
||||
namespace T4 = test;
|
||||
%}
|
||||
|
||||
namespace test {
|
||||
|
|
@ -48,6 +37,7 @@ namespace test {
|
|||
char * blah(T x) {
|
||||
return (char *) "vector::blah";
|
||||
}
|
||||
void vectoruse(vector<T> a, test::vector<T> b) {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -55,30 +45,26 @@ using namespace test;
|
|||
%template(maxint) max<int>;
|
||||
%template(vectorint) vector<int>;
|
||||
|
||||
namespace test2 {
|
||||
using namespace test;
|
||||
namespace test {
|
||||
%template(maxshort) max<short>;
|
||||
%template(vectorshort) vector<short>;
|
||||
}
|
||||
|
||||
namespace test3 {
|
||||
using test::max;
|
||||
using test::vector;
|
||||
namespace test {
|
||||
%template(maxlong) max<long>;
|
||||
%template(vectorlong) vector<long>;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace test4 {
|
||||
using namespace test;
|
||||
typedef int Integer;
|
||||
namespace test {
|
||||
typedef char Char;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
namespace test4 {
|
||||
%template(maxInteger) max<Integer>;
|
||||
%template(vectorInteger) vector<Integer>;
|
||||
namespace test {
|
||||
%template(maxchar) max<Char>;
|
||||
%template(vectorchar) vector<Char>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Test::More Support
|
|||
==
|
||||
|
||||
Test::More is a standard perl test harness tool.
|
||||
Support was added for for using Test::More in 1.3.28.
|
||||
Support was added for using Test::More in 1.3.28.
|
||||
If adding a new test to this suite, please use Test::More.
|
||||
|
||||
There are a few legacy test cases which do not use Test::More and these ought to be converted:
|
||||
|
|
|
|||
|
|
@ -9,4 +9,3 @@ check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==v
|
|||
check::done();
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -372,8 +372,9 @@ int methodX(int x) { return x+100; }
|
|||
|
||||
// Comma in macro - Github issue #974
|
||||
%inline %{
|
||||
#define __attribute__(x)
|
||||
#define TCX_PACKED(d) d __attribute__ ((__packed__))
|
||||
#define swig__attribute__(x)
|
||||
#define TCX_PACKED(d) d swig__attribute__ ((__packed__))
|
||||
|
||||
|
||||
TCX_PACKED (typedef struct tcxMessageTestImpl
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
import template_using_directive_typedef
|
||||
|
||||
vo = template_using_directive_typedef.Vector_Obj();
|
||||
|
||||
h = template_using_directive_typedef.Holder();
|
||||
h.holder_use1(vo, vo, vo);
|
||||
h.holder_use2(vo, vo, vo);
|
||||
h.holder_use3(vo, vo, vo);
|
||||
|
||||
template_using_directive_typedef.tns_holder_use(vo, vo);
|
||||
template_using_directive_typedef.tns_use(vo, vo, vo);
|
||||
template_using_directive_typedef.global_holder_use(vo);
|
||||
template_using_directive_typedef.global_use(vo, vo, vo);
|
||||
template_using_directive_typedef.ns1_holder_use(vo);
|
||||
template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo);
|
||||
32
Examples/test-suite/python/typemap_template_typedef_runme.py
Normal file
32
Examples/test-suite/python/typemap_template_typedef_runme.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from typemap_template_typedef import *
|
||||
|
||||
def check(got, expected):
|
||||
if got != expected:
|
||||
raise RuntimeError("got: " + str(got) + " expected: " + str(expected))
|
||||
|
||||
x = XXXInt()
|
||||
|
||||
check(x.aa1(0), 0)
|
||||
check(x.aa2(0), 55)
|
||||
check(x.aa3(0), 0)
|
||||
check(aa1(0), 0)
|
||||
check(aa2(0), 0)
|
||||
|
||||
check(x.bb1(0), 0)
|
||||
check(x.bb2(0), 66)
|
||||
check(x.bb3(0), 0)
|
||||
check(bb1(0), 0)
|
||||
check(bb2(0), 0)
|
||||
|
||||
check(x.cc1(0), 0)
|
||||
check(x.cc2(0), 77)
|
||||
check(x.cc3(0), 77)
|
||||
check(cc1(0), 0)
|
||||
check(cc2(0), 0)
|
||||
|
||||
check(x.dd1(0), 0)
|
||||
check(x.dd2(0), 88)
|
||||
check(x.dd3(0), 0)
|
||||
check(dd1(0), 0)
|
||||
check(dd2(0), 0)
|
||||
|
||||
|
|
@ -49,11 +49,6 @@ namespace one
|
|||
};
|
||||
}
|
||||
|
||||
%define PTR_DEF(o)
|
||||
typedef one::Ptr<o> o ## _ptr;
|
||||
%template(o ## _ptr) one::Ptr<o>;
|
||||
%enddef
|
||||
|
||||
namespace one
|
||||
{
|
||||
class Obj1
|
||||
|
|
@ -63,7 +58,8 @@ namespace one
|
|||
void donothing() {}
|
||||
};
|
||||
|
||||
PTR_DEF(Obj1)
|
||||
typedef one::Ptr<Obj1> Obj1_ptr;
|
||||
%template(Obj1_ptr) one::Ptr<Obj1>;
|
||||
}
|
||||
|
||||
namespace two
|
||||
|
|
@ -75,6 +71,9 @@ namespace two
|
|||
void donothing() {}
|
||||
};
|
||||
|
||||
PTR_DEF(Obj2)
|
||||
typedef one::Ptr<Obj2> Obj2_ptr;
|
||||
}
|
||||
|
||||
using two::Obj2;
|
||||
%template(Obj2_ptr) one::Ptr<Obj2>;
|
||||
|
||||
|
|
|
|||
33
Examples/test-suite/template_empty_inherit.i
Normal file
33
Examples/test-suite/template_empty_inherit.i
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
%module template_empty_inherit
|
||||
|
||||
%rename(FunctorOperator) operator();
|
||||
|
||||
%inline %{
|
||||
template<class Arg, typename Result> struct Functor {
|
||||
virtual Result operator()(Arg x) const = 0;
|
||||
};
|
||||
%}
|
||||
|
||||
// Bug fix - %ignore was resulting in this warning:
|
||||
// Warning 401: Base class 'Functor< int,int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
|
||||
%ignore Functor<int, int>;
|
||||
%template() Functor<int, int>;
|
||||
|
||||
%inline %{
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
struct SquareFunctor : Functor<int, int> {
|
||||
int operator()(int v) const { return v*v; }
|
||||
};
|
||||
%}
|
||||
|
||||
%include <std_vector.i>
|
||||
%template(VectorInt) std::vector<int>;
|
||||
|
||||
%inline %{
|
||||
std::vector<int> squares(const std::vector<int>& vi) {
|
||||
std::vector<int> result;
|
||||
std::transform(vi.begin(), vi.end(), std::back_inserter(result), SquareFunctor());
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
|
@ -1,25 +1,30 @@
|
|||
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE
|
||||
|
||||
%module template_nested_typemaps
|
||||
|
||||
// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_NAMED_NESTED_CLASS
|
||||
|
||||
template <typename T> struct Typemap {
|
||||
%typemap(in) T {
|
||||
$1 = -99;
|
||||
}
|
||||
};
|
||||
template <> struct Typemap<short> { // Note explicit specialization
|
||||
%typemap(in) short {
|
||||
$1 = -77;
|
||||
}
|
||||
};
|
||||
// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
|
||||
// Only for languages that support nested classes
|
||||
|
||||
%inline %{
|
||||
int globalInt1(int s) { return s; }
|
||||
short globalShort1(short s) { return s; }
|
||||
|
||||
template <typename T> struct Breeze {
|
||||
template <typename TMT> struct Typemap {
|
||||
#ifdef SWIG
|
||||
%typemap(in) TMT {
|
||||
$1 = -99;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
template <typename TMT> struct TypemapShort {
|
||||
#ifdef SWIG
|
||||
%typemap(in) short {
|
||||
$1 = -77;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
int methodInt1(int s) { return s; }
|
||||
#if defined(SWIG)
|
||||
%template() Typemap<int>;
|
||||
|
|
@ -29,7 +34,7 @@ template <typename T> struct Breeze {
|
|||
|
||||
short methodShort1(short s) { return s; }
|
||||
#if defined(SWIG)
|
||||
%template(TypemapShort) Typemap<short>; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE
|
||||
%template() TypemapShort<short>;
|
||||
#endif
|
||||
short methodShort2(short s) { return s; } // should pick up the typemap within Typemap<short>
|
||||
};
|
||||
|
|
|
|||
133
Examples/test-suite/template_parameters_global_scope.i
Normal file
133
Examples/test-suite/template_parameters_global_scope.i
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
%module template_parameters_global_scope
|
||||
|
||||
%inline %{
|
||||
namespace Alloc {
|
||||
template<typename T> struct Rebind {
|
||||
typedef int Integer;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct Bucket_ {};
|
||||
typedef Bucket_ TDBucket;
|
||||
typedef ::Bucket_ TDGlobalBucket;
|
||||
%}
|
||||
|
||||
// Check 1: %template no unary scope operator
|
||||
%template(RebindBucket) Alloc::Rebind< Bucket_ >;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rebind< Bucket_ >::Integer Bucket1() { return 1; }
|
||||
Alloc::Rebind< ::Bucket_ >::Integer Bucket2() { return 2; }
|
||||
Alloc::Rebind< TDBucket >::Integer Bucket3() { return 3; }
|
||||
Alloc::Rebind< ::TDBucket >::Integer Bucket4() { return 4; }
|
||||
Alloc::Rebind< TDGlobalBucket >::Integer Bucket5() { return 5; }
|
||||
Alloc::Rebind< ::TDGlobalBucket >::Integer Bucket6() { return 6; }
|
||||
%}
|
||||
|
||||
// Check 2: %template with unary scope operator
|
||||
%inline %{
|
||||
struct Spade {};
|
||||
typedef Spade TDSpade;
|
||||
typedef ::Spade TDGlobalSpade;
|
||||
%}
|
||||
%template(RebindSpade) Alloc::Rebind< ::Spade >;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rebind< Spade >::Integer Spade1() { return 1; }
|
||||
Alloc::Rebind< ::Spade >::Integer Spade2() { return 2; }
|
||||
Alloc::Rebind< TDSpade >::Integer Spade3() { return 3; }
|
||||
Alloc::Rebind< ::TDSpade >::Integer Spade4() { return 4; }
|
||||
Alloc::Rebind< TDGlobalSpade >::Integer Spade5() { return 5; }
|
||||
Alloc::Rebind< ::TDGlobalSpade >::Integer Spade6() { return 6; }
|
||||
%}
|
||||
|
||||
// Check 3: %template typedef no unary scope operator
|
||||
%inline %{
|
||||
struct Ball {};
|
||||
typedef Ball TDBall;
|
||||
typedef ::Ball TDGlobalBall;
|
||||
%}
|
||||
%template(RebindBall) Alloc::Rebind< TDBall >;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rebind< Ball >::Integer Ball1() { return 1; }
|
||||
Alloc::Rebind< ::Ball >::Integer Ball2() { return 2; }
|
||||
Alloc::Rebind< TDBall >::Integer Ball3() { return 3; }
|
||||
Alloc::Rebind< ::TDBall >::Integer Ball4() { return 4; }
|
||||
Alloc::Rebind< TDGlobalBall >::Integer Ball5() { return 5; }
|
||||
Alloc::Rebind< ::TDGlobalBall >::Integer Ball6() { return 6; }
|
||||
%}
|
||||
|
||||
// Check 4: %template typedef with unary scope operator
|
||||
%inline %{
|
||||
struct Bat {};
|
||||
typedef Bat TDBat;
|
||||
typedef ::Bat TDGlobalBat;
|
||||
%}
|
||||
%template(RebindBat) Alloc::Rebind< ::TDBat >;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rebind< Bat >::Integer Bat1() { return 1; }
|
||||
Alloc::Rebind< ::Bat >::Integer Bat2() { return 2; }
|
||||
Alloc::Rebind< TDBat >::Integer Bat3() { return 3; }
|
||||
Alloc::Rebind< ::TDBat >::Integer Bat4() { return 4; }
|
||||
Alloc::Rebind< TDGlobalBat >::Integer Bat5() { return 5; }
|
||||
Alloc::Rebind< ::TDGlobalBat >::Integer Bat6() { return 6; }
|
||||
%}
|
||||
|
||||
// Check 5: %template double typedef no unary scope operator
|
||||
%inline %{
|
||||
struct Chair {};
|
||||
typedef Chair TDChair;
|
||||
typedef ::Chair TDGlobalChair;
|
||||
%}
|
||||
%template(RebindChair) Alloc::Rebind< TDGlobalChair >;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rebind< Chair >::Integer Chair1() { return 1; }
|
||||
Alloc::Rebind< ::Chair >::Integer Chair2() { return 2; }
|
||||
Alloc::Rebind< TDChair >::Integer Chair3() { return 3; }
|
||||
Alloc::Rebind< ::TDChair >::Integer Chair4() { return 4; }
|
||||
Alloc::Rebind< TDGlobalChair >::Integer Chair5() { return 5; }
|
||||
Alloc::Rebind< ::TDGlobalChair >::Integer Chair6() { return 6; }
|
||||
%}
|
||||
|
||||
// Check 6: %template double typedef with unary scope operator
|
||||
%inline %{
|
||||
struct Table {};
|
||||
typedef Table TDTable;
|
||||
typedef ::Table TDGlobalTable;
|
||||
%}
|
||||
%template(RebindTable) Alloc::Rebind< ::TDGlobalTable >;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rebind< Table >::Integer Table1() { return 1; }
|
||||
Alloc::Rebind< ::Table >::Integer Table2() { return 2; }
|
||||
Alloc::Rebind< TDTable >::Integer Table3() { return 3; }
|
||||
Alloc::Rebind< ::TDTable >::Integer Table4() { return 4; }
|
||||
Alloc::Rebind< TDGlobalTable >::Integer Table5() { return 5; }
|
||||
Alloc::Rebind< ::TDGlobalTable >::Integer Table6() { return 6; }
|
||||
%}
|
||||
|
||||
#if 0
|
||||
%inline %{
|
||||
namespace Alloc {
|
||||
template<typename T=::Spade/*, typename T2=TDSpade, typename T3=::TDSpade, typename T4=TDGlobalSpade, typename T5=::TDGlobalSpade*/> struct Rejig {
|
||||
typedef int Integer;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%template(RejigSpade) Alloc::Rejig<::Spade>;
|
||||
|
||||
%inline %{
|
||||
Alloc::Rejig<>::Integer rejig1() { return 1; }
|
||||
Alloc::Rejig< ::Spade >::Integer rejig2() { return 2; }
|
||||
Alloc::Rejig< ::TDSpade >::Integer rejig3() { return 3; }
|
||||
Alloc::Rejig< ::TDSpade >::Integer rejig4() { return 4; }
|
||||
Alloc::Rejig< TDGlobalSpade >::Integer rejig5() { return 5; }
|
||||
Alloc::Rejig< ::TDGlobalSpade >::Integer rejig6() { return 6; }
|
||||
%}
|
||||
#endif
|
||||
|
|
@ -32,7 +32,7 @@ namespace One {
|
|||
%template(H) One::OneParm<int **>;
|
||||
|
||||
// %template scope explicit specializations
|
||||
namespace ONE {
|
||||
namespace One {
|
||||
%template(I) One::OneParm<float>;
|
||||
%template(J) ::One::OneParm<float *>;
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ namespace One {
|
|||
}
|
||||
|
||||
// %template scope partial specializations
|
||||
namespace ONE {
|
||||
namespace One {
|
||||
%template(BB) One::OneParm<bool *>;
|
||||
%template(BBB) ::One::OneParm<char *>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace One {
|
|||
%template(H) One::OneParm<TypeDef::IntPtrPtr>;
|
||||
|
||||
// %template scope explicit specializations
|
||||
namespace ONE {
|
||||
namespace One {
|
||||
%template(I) One::OneParm<TypeDef::Float>;
|
||||
%template(J) ::One::OneParm<TypeDef::FloatPtr>;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ namespace One {
|
|||
}
|
||||
|
||||
// %template scope partial specializations
|
||||
namespace ONE {
|
||||
namespace One {
|
||||
%template(BB) One::OneParm<TypeDef::BoolPtr>;
|
||||
%template(BBB) ::One::OneParm<TypeDef::CharPtr>;
|
||||
}
|
||||
|
|
|
|||
44
Examples/test-suite/template_using_directive_typedef.i
Normal file
44
Examples/test-suite/template_using_directive_typedef.i
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
%module template_using_directive_typedef
|
||||
|
||||
%inline %{
|
||||
namespace space {
|
||||
template<typename T> class Vector {};
|
||||
class VectorClass {};
|
||||
}
|
||||
struct Obj {};
|
||||
%}
|
||||
|
||||
%template(Vector_Obj) space::Vector<Obj>;
|
||||
|
||||
%inline %{
|
||||
namespace tns {
|
||||
using space::Vector; // template using directives were not being added into the typedef table
|
||||
using space::VectorClass;
|
||||
typedef Vector<Obj> NSVec;
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace tns {
|
||||
struct Holder {
|
||||
// using Vec = Vector<Obj>;
|
||||
typedef Vector<Obj> Vec;
|
||||
typedef VectorClass VecClass;
|
||||
Vec items;
|
||||
void holder_use1(space::Vector<Obj>, tns::NSVec, tns::Vector<Obj>) {}
|
||||
void holder_use2(space::Vector<Obj>, NSVec, Vector<Obj>) {}
|
||||
void holder_use3(tns::Holder::Vec, Holder::Vec, Vec) {}
|
||||
};
|
||||
void tns_holder_use(tns::Holder::Vec, Holder::Vec) {}
|
||||
void tns_use(space::Vector<Obj>, NSVec, tns::NSVec) {}
|
||||
}
|
||||
void global_holder_use(tns::Holder::Vec) {}
|
||||
void global_use(space::Vector<Obj>, tns::NSVec, tns::Vector<Obj>) {}
|
||||
namespace ns1 {
|
||||
void ns1_holder_use(tns::Holder::Vec) {}
|
||||
}
|
||||
namespace ns2 {
|
||||
using namespace tns;
|
||||
void ns2_holder_use(tns::Holder::Vec, Holder::Vec, NSVec, Vector<Obj>) {}
|
||||
}
|
||||
%}
|
||||
66
Examples/test-suite/typemap_template_typedef.i
Normal file
66
Examples/test-suite/typemap_template_typedef.i
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
%module typemap_template_typedef
|
||||
//%module("templatereduce") typemap_template_typedef
|
||||
|
||||
%typemap(in) int TMAP55 %{ $1 = 55; /* int TMAP55 typemap */ %}
|
||||
%typemap(in) int TMAP66 %{ $1 = 66; /* int TMAP66 typemap */ %}
|
||||
%typemap(in) int TMAP77 %{ $1 = 77; /* int TMAP77 typemap */ %}
|
||||
%typemap(in) int TMAP88 %{ $1 = 88; /* int TMAP88 typemap */ %}
|
||||
|
||||
%apply int TMAP77 { XXX<int>::Long cc }
|
||||
|
||||
%inline %{
|
||||
typedef int Integer;
|
||||
|
||||
template<typename T> struct XXX {
|
||||
#ifdef SWIG
|
||||
// In swig-3.0.12 'Long aa' was actually stored as 'long aa' in typemap table instead of 'XXX<int>::Long aa'
|
||||
%apply int TMAP55 { Long aa }
|
||||
%apply int TMAP66 { XXX<int>::Long bb }
|
||||
%apply int TMAP88 { XXX<Integer>::Long dd }
|
||||
#endif
|
||||
typedef long Long;
|
||||
long aa1(long aa) { return aa; }
|
||||
long aa2(Long aa) { return aa; }
|
||||
long bb1(long bb) { return bb; }
|
||||
long bb2(Long bb) { return bb; }
|
||||
long cc1(long cc) { return cc; }
|
||||
long cc2(Long cc) { return cc; }
|
||||
long dd1(long dd) { return dd; }
|
||||
long dd2(Long dd) { return dd; }
|
||||
#ifdef SWIG
|
||||
%clear Long aa;
|
||||
%clear XXX<int>::Long bb;
|
||||
%clear XXX<Integer>::Long dd;
|
||||
#endif
|
||||
long aa3(Long aa) { return aa; }
|
||||
long bb3(Long bb) { return bb; }
|
||||
long cc3(Long cc) { return cc; }
|
||||
long dd3(Long dd) { return dd; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(XXXInt) XXX<Integer>;
|
||||
|
||||
%clear XXX<int>::Long cc;
|
||||
|
||||
%inline %{
|
||||
long aa1(XXX<int>::Long aa) { return aa; }
|
||||
long aa2(long aa) { return aa; }
|
||||
long bb1(XXX<int>::Long bb) { return bb; }
|
||||
long bb2(long bb) { return bb; }
|
||||
long cc1(XXX<int>::Long cc) { return cc; }
|
||||
long cc2(long cc) { return cc; }
|
||||
long dd1(XXX<Integer>::Long dd) { return dd; }
|
||||
long dd2(long dd) { return dd; }
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef Integer INTEGER;
|
||||
template<typename T1, typename T2 = INTEGER> struct YYY {
|
||||
void meff(T1 t1, T2 t2) {}
|
||||
};
|
||||
%}
|
||||
%template(YYYIntInt) YYY<INTEGER>;
|
||||
%inline %{
|
||||
void whyohwhy(YYY<INTEGER> yy) {}
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue