Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12905 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
dd3db36b1a
321 changed files with 12114 additions and 8559 deletions
|
|
@ -1,9 +1,9 @@
|
|||
%module(docstring="hello") python_autodoc
|
||||
%module(docstring="hello") autodoc
|
||||
|
||||
%feature("autodoc");
|
||||
|
||||
// especial typemap and its docs
|
||||
%typemap(in) (int c, int d) "$1 =0; $2 = 0;";
|
||||
// special typemap and its docs
|
||||
%typemap(in) (int c, int d) "$1 = 0; $2 = 0;";
|
||||
%typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
|
||||
|
||||
// testing for different documentation levels
|
||||
|
|
@ -12,7 +12,22 @@
|
|||
%feature("autodoc","2") A::func2; // extended
|
||||
%feature("autodoc","3") A::func3; // extended + types
|
||||
|
||||
%feature("autodoc","just a string") A::func; // names
|
||||
%feature("autodoc","0") A::func0default; // names
|
||||
%feature("autodoc","1") A::func1default; // names + types
|
||||
%feature("autodoc","2") A::func2default; // extended
|
||||
%feature("autodoc","3") A::func3default; // extended + types
|
||||
|
||||
%feature("autodoc","0") A::func0static; // names
|
||||
%feature("autodoc","1") A::func1static; // names + types
|
||||
%feature("autodoc","2") A::func2static; // extended
|
||||
%feature("autodoc","3") A::func3static; // extended + types
|
||||
|
||||
%feature("autodoc","0") A::variable_a; // names
|
||||
%feature("autodoc","1") A::variable_b; // names + types
|
||||
%feature("autodoc","2") A::variable_c; // extended
|
||||
%feature("autodoc","3") A::variable_d; // extended + types
|
||||
|
||||
%feature("autodoc","just a string") A::funk; // names
|
||||
|
||||
%inline {
|
||||
|
||||
|
|
@ -20,36 +35,29 @@
|
|||
hi, hello
|
||||
};
|
||||
|
||||
struct A
|
||||
{
|
||||
A(int a, short b, Hola h)
|
||||
{
|
||||
}
|
||||
struct A {
|
||||
A(int a, short b, Hola h) {}
|
||||
int funk(int a) { return a; }
|
||||
|
||||
int func(int a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
int func0(short, int c, int d) { return c; }
|
||||
int func1(short, int c, int d) { return c; }
|
||||
int func2(short, int c, int d) { return c; }
|
||||
int func3(short, int c, int d) { return c; }
|
||||
|
||||
int func0(int c, int d)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
int func1(int c, int d)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
int func0default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
int func1default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
int func2default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
int func3default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
|
||||
int func2(A* c, double d = 2)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
static int func0static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
static int func1static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
static int func2static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
static int func3static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
|
||||
int func3(A* c, double d = 2)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
int variable_a;
|
||||
int variable_b;
|
||||
int variable_c;
|
||||
int variable_d;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -62,34 +70,66 @@
|
|||
%typemap(doc) int a "a: special comment for parameter a";
|
||||
%typemap(doc) int b "b: another special comment for parameter b";
|
||||
|
||||
%callback(1) func_cb;
|
||||
%feature("autodoc","0") C::C(int a, int b, Hola h); // names
|
||||
%feature("autodoc","1") D::D(int a, int b, Hola h); // names + types
|
||||
%feature("autodoc","2") E::E(int a, int b, Hola h); // extended
|
||||
%feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types
|
||||
|
||||
%inline {
|
||||
|
||||
struct B
|
||||
{
|
||||
B(int a, int b, Hola h)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int func(int c, int d)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
struct B {
|
||||
B(int a, int b, Hola h) {}
|
||||
int funk(int c, int d) { return c; }
|
||||
};
|
||||
|
||||
int func(int c, int d) {
|
||||
return c;
|
||||
}
|
||||
struct C {
|
||||
C(int a, int b, Hola h) {}
|
||||
};
|
||||
struct D {
|
||||
D(int a, int b, Hola h) {}
|
||||
};
|
||||
struct E {
|
||||
E(int a, int b, Hola h) {}
|
||||
};
|
||||
struct F {
|
||||
F(int a, int b, Hola h) {}
|
||||
};
|
||||
|
||||
int funcio(int *INOUT) {
|
||||
int funk(A *e, short, int c, int d) { return c; }
|
||||
int funkdefaults(A *e, short, int c, int d, double f = 2) { return c; }
|
||||
}
|
||||
|
||||
%include <typemaps.i>
|
||||
%inline %{
|
||||
int func_input(int *INPUT) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int func_cb(int c, int d) {
|
||||
return c;
|
||||
int func_output(int *OUTPUT) {
|
||||
*OUTPUT = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int func_inout(int *INOUT) {
|
||||
*INOUT += 1;
|
||||
return 1;
|
||||
}
|
||||
%}
|
||||
|
||||
%callback("%(uppercase)s_CALLBACK") func_cb;
|
||||
|
||||
%inline {
|
||||
int func_cb(int c, int d) { return c; }
|
||||
}
|
||||
|
||||
// Bug 3310528
|
||||
%feature("autodoc","1") banana; // names + types
|
||||
%inline %{
|
||||
typedef struct tagS {
|
||||
int a;
|
||||
char b;
|
||||
} S;
|
||||
|
||||
typedef int Integer;
|
||||
|
||||
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
||||
%}
|
||||
|
||||
|
|
|
|||
10
Examples/test-suite/class_forward.i
Normal file
10
Examples/test-suite/class_forward.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module class_forward
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
class B;
|
||||
};
|
||||
class C : public A {
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -124,7 +124,9 @@ CPP_TEST_CASES += \
|
|||
catches \
|
||||
cast_operator \
|
||||
casts \
|
||||
char_binary \
|
||||
char_strings \
|
||||
class_forward \
|
||||
class_ignore \
|
||||
class_scope_weird \
|
||||
compactdefaultargs \
|
||||
|
|
@ -158,6 +160,7 @@ CPP_TEST_CASES += \
|
|||
director_abstract \
|
||||
director_alternating \
|
||||
director_basic \
|
||||
director_binary_string \
|
||||
director_classes \
|
||||
director_classic \
|
||||
director_constructor \
|
||||
|
|
@ -171,6 +174,7 @@ CPP_TEST_CASES += \
|
|||
director_ignore \
|
||||
director_keywords \
|
||||
director_namespace_clash \
|
||||
director_nspace \
|
||||
director_nested \
|
||||
director_overload \
|
||||
director_primitives \
|
||||
|
|
@ -194,10 +198,12 @@ CPP_TEST_CASES += \
|
|||
evil_diamond_prop \
|
||||
exception_order \
|
||||
extend \
|
||||
extend_constructor_destructor \
|
||||
extend_default \
|
||||
extend_placement \
|
||||
extend_template \
|
||||
extend_template_ns \
|
||||
extend_typedef_class \
|
||||
extern_c \
|
||||
extern_namespace \
|
||||
extern_throws \
|
||||
|
|
@ -227,6 +233,7 @@ CPP_TEST_CASES += \
|
|||
li_attribute \
|
||||
li_boost_shared_ptr \
|
||||
li_boost_shared_ptr_bits \
|
||||
li_boost_shared_ptr_template \
|
||||
li_carrays \
|
||||
li_cdata \
|
||||
li_cpointer \
|
||||
|
|
@ -283,6 +290,7 @@ CPP_TEST_CASES += \
|
|||
protected_rename \
|
||||
pure_virtual \
|
||||
redefined \
|
||||
redefined_not \
|
||||
refcount \
|
||||
reference_global_vars \
|
||||
register_par \
|
||||
|
|
@ -341,6 +349,7 @@ CPP_TEST_CASES += \
|
|||
template_default2 \
|
||||
template_default_arg \
|
||||
template_default_class_parms \
|
||||
template_default_class_parms_typedef \
|
||||
template_default_inherit \
|
||||
template_default_qualify \
|
||||
template_default_vw \
|
||||
|
|
@ -382,15 +391,20 @@ CPP_TEST_CASES += \
|
|||
template_tbase_template \
|
||||
template_template_parameters \
|
||||
template_typedef \
|
||||
template_typedef_class_template \
|
||||
template_typedef_cplx \
|
||||
template_typedef_cplx2 \
|
||||
template_typedef_cplx3 \
|
||||
template_typedef_cplx4 \
|
||||
template_typedef_cplx5 \
|
||||
template_typedef_funcptr \
|
||||
template_typedef_inherit \
|
||||
template_typedef_ns \
|
||||
template_typedef_ptr \
|
||||
template_typedef_rec \
|
||||
template_typemaps \
|
||||
template_typemaps_typedef \
|
||||
template_typemaps_typedef2 \
|
||||
template_using \
|
||||
template_virtual \
|
||||
template_whitespace \
|
||||
|
|
@ -409,6 +423,7 @@ CPP_TEST_CASES += \
|
|||
typemap_arrays \
|
||||
typemap_delete \
|
||||
typemap_global_scope \
|
||||
typemap_manyargs \
|
||||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
typemap_numinputs \
|
||||
|
|
@ -450,6 +465,7 @@ CPP_STD_TEST_CASES += \
|
|||
director_string \
|
||||
ignore_template_constructor \
|
||||
li_std_combinations \
|
||||
li_std_containers_int \
|
||||
li_std_deque \
|
||||
li_std_except \
|
||||
li_std_map \
|
||||
|
|
|
|||
|
|
@ -26,9 +26,13 @@ public:
|
|||
|
||||
// Test that the correct types are used for typedef struct declarations
|
||||
typedef struct {
|
||||
int something;
|
||||
void m() {}
|
||||
} UnnamedStruct;
|
||||
|
||||
typedef struct NamedStruct {
|
||||
int something;
|
||||
void m() {}
|
||||
} TypedefNamedStruct;
|
||||
|
||||
typedef TypedefNamedStruct DoubleTypedef;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ CPP_TEST_CASES = \
|
|||
enum_thorough_simple \
|
||||
enum_thorough_typesafe \
|
||||
exception_partial_info \
|
||||
intermediary_classname
|
||||
intermediary_classname \
|
||||
li_boost_intrusive_ptr
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
32
Examples/test-suite/csharp/director_nspace_runme.cs
Normal file
32
Examples/test-suite/csharp/director_nspace_runme.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
using System;
|
||||
using director_nspaceNamespace;
|
||||
|
||||
public class bools_runme {
|
||||
|
||||
public static void Main() {
|
||||
}
|
||||
}
|
||||
|
||||
class director_nspace_MyBarFoo : director_nspaceNamespace.Bar.Foo {
|
||||
|
||||
public override String ping() {
|
||||
return "director_nspace_MyBarFoo.ping();";
|
||||
}
|
||||
|
||||
public override String pong() {
|
||||
return "director_nspace_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
public override String fooBar(director_nspaceNamespace.Bar.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
public override director_nspaceNamespace.Bar.Foo makeFoo() {
|
||||
return new director_nspaceNamespace.Bar.Foo();
|
||||
}
|
||||
|
||||
public override director_nspaceNamespace.Bar.FooBar makeFooBar() {
|
||||
return new director_nspaceNamespace.Bar.FooBar();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,6 @@ endif
|
|||
TESTSUFFIX = _runme$(VERSIONSUFFIX).d
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
d_exception_name \
|
||||
d_nativepointers \
|
||||
exception_partial_info
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ module allprotected_runme;
|
|||
|
||||
import allprotected.Klass;
|
||||
import allprotected.ProtectedBase;
|
||||
import std.conv : text;
|
||||
import std.exception : enforce;
|
||||
|
||||
void main() {
|
||||
auto mpb = new MyProtectedBase("MyProtectedBase");
|
||||
|
|
@ -16,50 +18,46 @@ public:
|
|||
|
||||
void accessProtected() {
|
||||
string s = virtualMethod();
|
||||
if (s != "ProtectedBase")
|
||||
throw new Exception("Failed");
|
||||
enforce(s == "ProtectedBase", "Failed, got '" ~ s ~ "'");
|
||||
|
||||
Klass k = instanceMethod(new Klass("xyz"));
|
||||
if (k.getName() != "xyz")
|
||||
throw new Exception("Failed");
|
||||
Klass k;
|
||||
void expect(string name) {
|
||||
auto kName = k.getName();
|
||||
enforce(kName == name, "Failed, expected '" ~ name ~ "' instead of '" ~
|
||||
kName ~ "'.");
|
||||
}
|
||||
|
||||
k = instanceMethod(new Klass("xyz"));
|
||||
expect("xyz");
|
||||
|
||||
k = instanceOverloaded(new Klass("xyz"));
|
||||
if (k.getName() != "xyz")
|
||||
throw new Exception("Failed");
|
||||
expect("xyz");
|
||||
|
||||
k = instanceOverloaded(new Klass("xyz"), "abc");
|
||||
if (k.getName() != "abc")
|
||||
throw new Exception("Failed");
|
||||
expect("abc");
|
||||
|
||||
k = staticMethod(new Klass("abc"));
|
||||
if (k.getName() != "abc")
|
||||
throw new Exception("Failed");
|
||||
expect("abc");
|
||||
|
||||
k = staticOverloaded(new Klass("xyz"));
|
||||
if (k.getName() != "xyz")
|
||||
throw new Exception("Failed");
|
||||
expect("xyz");
|
||||
|
||||
k = staticOverloaded(new Klass("xyz"), "abc");
|
||||
if (k.getName() != "abc")
|
||||
throw new Exception("Failed");
|
||||
expect("abc");
|
||||
|
||||
instanceMemberVariable = 30;
|
||||
int i = instanceMemberVariable;
|
||||
if (i != 30)
|
||||
throw new Exception("Failed");
|
||||
enforce(i == 30, text("Failed, expected ", 30, "instead of ", i));
|
||||
|
||||
staticMemberVariable = 40;
|
||||
i = staticMemberVariable;
|
||||
if (i != 40)
|
||||
throw new Exception("Failed");
|
||||
enforce(i == 40, text("Failed, expected ", 40, "instead of ", i));
|
||||
|
||||
i = staticConstMemberVariable;
|
||||
if (i != 20)
|
||||
throw new Exception("Failed");
|
||||
enforce(i == 20, text("Failed, expected ", 20, "instead of ", i));
|
||||
|
||||
anEnum = ProtectedBase.AnEnum.EnumVal1;
|
||||
ProtectedBase.AnEnum ae = anEnum;
|
||||
if (ae != ProtectedBase.AnEnum.EnumVal1)
|
||||
throw new Exception("Failed");
|
||||
enforce(ae == ProtectedBase.AnEnum.EnumVal1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
|
|||
import d_nativepointers.SWIGTYPE_p_p_SomeClass;
|
||||
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
|
||||
|
||||
extern(C) alias void function(int**, char***) GType;
|
||||
|
||||
void main() {
|
||||
check!(a, int*);
|
||||
check!(b, float**);
|
||||
|
|
@ -13,7 +15,7 @@ void main() {
|
|||
check!(d, SomeClass);
|
||||
check!(e, SWIGTYPE_p_p_SomeClass);
|
||||
check!(f, SWIGTYPE_p_OpaqueClass);
|
||||
check!(g, void function(int**, char***));
|
||||
check!(g, GType);
|
||||
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
|
|||
import d_nativepointers.SWIGTYPE_p_p_SomeClass;
|
||||
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
|
||||
|
||||
extern(C) alias void function(int**, char***) GType;
|
||||
|
||||
void main() {
|
||||
check!(a, int*);
|
||||
check!(b, float**);
|
||||
|
|
@ -13,7 +15,7 @@ void main() {
|
|||
check!(d, SomeClass);
|
||||
check!(e, SWIGTYPE_p_p_SomeClass);
|
||||
check!(f, SWIGTYPE_p_OpaqueClass);
|
||||
check!(g, void function(int**, char***));
|
||||
check!(g, GType);
|
||||
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ public:
|
|||
int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
|
||||
int OverloadedMethod(int n, int xoffset) { return 0; }
|
||||
int OverloadedMethod(int n) { return 0; }
|
||||
alias super.OverloadedMethod OverloadedMethod;
|
||||
|
||||
protected:
|
||||
int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
|
||||
int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
|
||||
int OverloadedProtectedMethod(int n) { return 0; }
|
||||
|
|
@ -31,7 +33,9 @@ public:
|
|||
int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
|
||||
int OverloadedMethod(int n, int xoffset) { return 0; }
|
||||
int OverloadedMethod(int n) { return 0; }
|
||||
alias super.OverloadedMethod OverloadedMethod;
|
||||
|
||||
protected:
|
||||
int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
|
||||
int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
|
||||
int OverloadedProtectedMethod(int n) { return 0; }
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ private void verifyCount(int expected, Klass k) {
|
|||
// We deliberately call the use_count(Klass) overload also for objects which
|
||||
// are instances of a subclass of Klass (due to static dispatch); things still
|
||||
// have to work.
|
||||
int got = use_count(k);
|
||||
auto got = use_count(k);
|
||||
if (expected != got)
|
||||
throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ void main() {
|
|||
// Basic functionality tests.
|
||||
{
|
||||
auto vector = new IntVector();
|
||||
for (size_t i = 0; i < SIZE; ++i) {
|
||||
foreach (int i; 0 .. SIZE) {
|
||||
vector ~= i * 10;
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ void main() {
|
|||
// To array conversion tests.
|
||||
{
|
||||
auto dVector = new DoubleVector();
|
||||
for (size_t i = 0; i < SIZE; ++i) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
dVector ~= i * 10.1f;
|
||||
}
|
||||
|
||||
|
|
@ -67,13 +67,13 @@ void main() {
|
|||
|
||||
|
||||
auto sVector = new StructVector();
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
sVector ~= new Struct(i / 10.0);
|
||||
}
|
||||
|
||||
Struct[] sArray = array(sVector[]);
|
||||
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
// Make sure that a shallow copy has been made.
|
||||
void* aPtr = Struct.swigGetCPtr(sArray[i]);
|
||||
void* vPtr = Struct.swigGetCPtr(sVector[i]);
|
||||
|
|
@ -84,7 +84,7 @@ void main() {
|
|||
// remove() tests.
|
||||
{
|
||||
auto iVector = new IntVector();
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
foreach (int i; 0 .. SIZE) {
|
||||
iVector ~= i;
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ void main() {
|
|||
// Test the methods being wrapped.
|
||||
{
|
||||
auto iv = new IntVector();
|
||||
for (int i=0; i<4; i++) {
|
||||
foreach (int i; 0 .. 4) {
|
||||
iv ~= i;
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ void main() {
|
|||
RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f]));
|
||||
|
||||
auto dv = new DoubleVector();
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
dv ~= i / 2.0;
|
||||
}
|
||||
halve_in_place(dv);
|
||||
|
|
@ -147,13 +147,13 @@ void main() {
|
|||
// Test vectors of pointers.
|
||||
{
|
||||
auto vector = new StructPtrVector();
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
vector ~= new Struct(i / 10.0);
|
||||
}
|
||||
|
||||
Struct[] array = array(vector[]);
|
||||
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
// Make sure that a shallow copy has been made.
|
||||
void* aPtr = Struct.swigGetCPtr(array[i]);
|
||||
void* vPtr = Struct.swigGetCPtr(vector[i]);
|
||||
|
|
@ -164,13 +164,13 @@ void main() {
|
|||
// Test vectors of const pointers.
|
||||
{
|
||||
auto vector = new StructConstPtrVector();
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
vector ~= new Struct(i / 10.0);
|
||||
}
|
||||
|
||||
Struct[] array = array(vector[]);
|
||||
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
foreach (i; 0 .. SIZE) {
|
||||
// Make sure that a shallow copy has been made.
|
||||
void* aPtr = Struct.swigGetCPtr(array[i]);
|
||||
void* vPtr = Struct.swigGetCPtr(vector[i]);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_c_runme;
|
||||
|
||||
import tango.stdc.config;
|
||||
import preproc_constants_c.preproc_constants_c;
|
||||
|
||||
// Same as preproc_constants.i testcase, but bool types are int instead.
|
||||
|
|
@ -10,10 +11,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -38,8 +39,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_c_runme;
|
||||
|
||||
import core.stdc.config;
|
||||
import preproc_constants_c.preproc_constants_c;
|
||||
|
||||
// Same as preproc_constants.i testcase, but bool types are int instead.
|
||||
|
|
@ -10,10 +11,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -38,8 +39,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_runme;
|
||||
|
||||
import tango.stdc.config;
|
||||
import preproc_constants.preproc_constants;
|
||||
|
||||
void main() {
|
||||
|
|
@ -9,10 +10,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -37,8 +38,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module preproc_constants_runme;
|
||||
|
||||
import core.stdc.config;
|
||||
import preproc_constants.preproc_constants;
|
||||
|
||||
void main() {
|
||||
|
|
@ -9,10 +10,10 @@ void main() {
|
|||
static assert(is(uint == typeof(CONST_UINT2())));
|
||||
static assert(is(uint == typeof(CONST_UINT3())));
|
||||
static assert(is(uint == typeof(CONST_UINT4())));
|
||||
static assert(is(int == typeof(CONST_LONG1())));
|
||||
static assert(is(int == typeof(CONST_LONG2())));
|
||||
static assert(is(int == typeof(CONST_LONG3())));
|
||||
static assert(is(int == typeof(CONST_LONG4())));
|
||||
static assert(is(c_long == typeof(CONST_LONG1())));
|
||||
static assert(is(c_long == typeof(CONST_LONG2())));
|
||||
static assert(is(c_long == typeof(CONST_LONG3())));
|
||||
static assert(is(c_long == typeof(CONST_LONG4())));
|
||||
static assert(is(long == typeof(CONST_LLONG1())));
|
||||
static assert(is(long == typeof(CONST_LLONG2())));
|
||||
static assert(is(long == typeof(CONST_LLONG3())));
|
||||
|
|
@ -37,8 +38,8 @@ void main() {
|
|||
// static assert(is(int == typeof(INT_AND_CHAR())));
|
||||
static assert(is(int == typeof(INT_AND_INT())));
|
||||
static assert(is(uint == typeof(INT_AND_UINT())));
|
||||
static assert(is(int == typeof(INT_AND_LONG())));
|
||||
static assert(is(uint == typeof(INT_AND_ULONG())));
|
||||
static assert(is(c_long == typeof(INT_AND_LONG())));
|
||||
static assert(is(c_ulong == typeof(INT_AND_ULONG())));
|
||||
static assert(is(long == typeof(INT_AND_LLONG())));
|
||||
static assert(is(ulong == typeof(INT_AND_ULLONG())));
|
||||
static assert(is(int == typeof(BOOL_AND_BOOL())));
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
// Tests if exception handling still works in the presence of a wrapped C++
|
||||
// class called »Exception«, which could shadow the built-in Exception class.
|
||||
%module d_exception_name
|
||||
|
||||
%inline %{
|
||||
class Exception {
|
||||
Exception(int i) {}
|
||||
};
|
||||
|
||||
class Foo {
|
||||
~Foo() {}
|
||||
public:
|
||||
void bar(Exception *e) {}
|
||||
};
|
||||
%}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
virtual std::string ping() { return "Foo::ping()"; }
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
|
||||
static Foo* get_self(Foo *self) {return self;}
|
||||
static Foo* get_self(Foo *slf) {return slf;}
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
|
||||
static Foo* get_self(Foo *self);
|
||||
static Foo* get_self(Foo *slf);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
50
Examples/test-suite/director_binary_string.i
Normal file
50
Examples/test-suite/director_binary_string.i
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
%module(directors="1") director_binary_string;
|
||||
|
||||
%feature("director") Callback;
|
||||
|
||||
%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) };
|
||||
%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) };
|
||||
|
||||
%inline %{
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BUFFER_SIZE_AA 8
|
||||
#define BUFFER_SIZE_BB 5
|
||||
|
||||
class Callback {
|
||||
public:
|
||||
virtual ~Callback() {}
|
||||
virtual void run(char* dataBufferAA, int sizeAA, char* dataBufferBB, int sizeBB) {
|
||||
memset(dataBufferAA, -1, sizeAA);
|
||||
memset(dataBufferBB, -1, sizeBB);
|
||||
}
|
||||
};
|
||||
|
||||
class Caller {
|
||||
private:
|
||||
Callback *_callback;
|
||||
public:
|
||||
Caller(): _callback(0) {}
|
||||
~Caller() { delCallback(); }
|
||||
void delCallback() { delete _callback; _callback = 0; }
|
||||
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
|
||||
int call() {
|
||||
if (_callback) {
|
||||
char* aa = (char*)malloc(BUFFER_SIZE_AA);
|
||||
memset(aa, 9, BUFFER_SIZE_AA);
|
||||
char* bb = (char*)malloc(BUFFER_SIZE_BB);
|
||||
memset(bb, 13, BUFFER_SIZE_BB);
|
||||
int sum = 0;
|
||||
_callback->run(aa, BUFFER_SIZE_AA, bb, BUFFER_SIZE_BB);
|
||||
for (int i = 0; i < BUFFER_SIZE_AA; i++)
|
||||
sum += aa[i];
|
||||
for (int i = 0; i < BUFFER_SIZE_BB; i++)
|
||||
sum += bb[i];
|
||||
free(aa);
|
||||
free(bb);
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
68
Examples/test-suite/director_nspace.i
Normal file
68
Examples/test-suite/director_nspace.i
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
%module(directors="1") director_nspace
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar() {}
|
||||
FooBar(const FooBar&) {}
|
||||
virtual ~FooBar() {}
|
||||
|
||||
std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
|
||||
};
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "Bar::Foo::ping()"; }
|
||||
virtual std::string pong() { return "Bar::Foo::pong();" + ping(); }
|
||||
virtual std::string fooBar(FooBar* fb) { return fb->FooBarDo(); }
|
||||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
static Foo* get_self(Foo *self) {return self;}
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%nspace Bar::Foo;
|
||||
%nspace Bar::FooBar;
|
||||
|
||||
%feature("director") Bar::Foo;
|
||||
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar();
|
||||
FooBar(const FooBar&);
|
||||
virtual ~FooBar();
|
||||
|
||||
std::string FooBarDo();
|
||||
|
||||
};
|
||||
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
virtual std::string fooBar(FooBar* fb);
|
||||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self);
|
||||
};
|
||||
}
|
||||
104
Examples/test-suite/errors/cpp_extend_destructors.i
Normal file
104
Examples/test-suite/errors/cpp_extend_destructors.i
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
%module xxx
|
||||
|
||||
/////////////////////////////
|
||||
%extend AStruct {
|
||||
~AStruct() {}
|
||||
}
|
||||
struct AStruct {
|
||||
~AStruct() {}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
struct BStruct {
|
||||
~BStruct() {}
|
||||
~BStruct() {}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
struct CStruct {
|
||||
};
|
||||
|
||||
%extend CStruct {
|
||||
~NOT_CStruct() {
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend DStruct {
|
||||
~NOT_DStruct() {
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
struct DStruct {
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
struct EStruct {
|
||||
~EStruct() {}
|
||||
};
|
||||
|
||||
%extend EStruct {
|
||||
~NOT_EStruct() {
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend FStruct {
|
||||
~NOT_FStruct() {
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
struct FStruct {
|
||||
~FStruct() {}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
struct GStruct {
|
||||
};
|
||||
|
||||
%extend GStruct {
|
||||
~GStruct() {}
|
||||
~NOT_GStruct() {
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend HStruct {
|
||||
~HStruct() {}
|
||||
~NOT_HStruct() {
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
struct HStruct {
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
struct IStruct {
|
||||
~IStruct() {}
|
||||
~NOT_IStruct() {}
|
||||
};
|
||||
|
||||
struct JStruct {
|
||||
~JStruct() {}
|
||||
~NOT_JStruct() {}
|
||||
~JStruct() {}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
struct KStruct {
|
||||
~NOT_KStruct() {}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
template<typename T>
|
||||
struct LStruct {
|
||||
~LStruct() {}
|
||||
~NOT_LStruct() {}
|
||||
~LStruct() {}
|
||||
};
|
||||
%template(LStructInt) LStruct<int>;
|
||||
%template(LStructShort) LStruct<short>;
|
||||
|
||||
12
Examples/test-suite/errors/cpp_no_return_type.i
Normal file
12
Examples/test-suite/errors/cpp_no_return_type.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%module xxx
|
||||
|
||||
struct R {};
|
||||
|
||||
struct S {
|
||||
R() {}
|
||||
};
|
||||
|
||||
typedef struct U {
|
||||
UU() {}
|
||||
} UU;
|
||||
|
||||
|
|
@ -205,10 +205,40 @@ $source by $input and $target by $1. For typemaps related to return values (ou
|
|||
argout,ret,except), replace $source by $1 and $target by $result. See the file
|
||||
Doc/Manual/Typemaps.html for complete details.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_typemap_warn.i :::::::::::::::::::::::::::::::::::
|
||||
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||
swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double
|
||||
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
|
||||
cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_extend_destructors.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_extend_destructors.i:8: Warning 302: Identifier '~AStruct' redefined by %extend (ignored),
|
||||
cpp_extend_destructors.i:5: Warning 302: %extend definition of '~AStruct'.
|
||||
cpp_extend_destructors.i:14: Warning 302: Identifier '~BStruct' redefined (ignored),
|
||||
cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct'.
|
||||
cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignored),
|
||||
cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct'.
|
||||
cpp_extend_destructors.i:100: Warning 302: Identifier '~LStruct' redefined (ignored),
|
||||
cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct'.
|
||||
cpp_extend_destructors.i:24: Warning 521: Illegal destructor name ~NOT_CStruct. Ignored.
|
||||
cpp_extend_destructors.i:30: Warning 521: Illegal destructor name ~NOT_DStruct. Ignored.
|
||||
cpp_extend_destructors.i:44: Warning 521: Illegal destructor name ~NOT_EStruct. Ignored.
|
||||
cpp_extend_destructors.i:50: Warning 521: Illegal destructor name ~NOT_FStruct. Ignored.
|
||||
cpp_extend_destructors.i:65: Warning 521: Illegal destructor name ~NOT_GStruct. Ignored.
|
||||
cpp_extend_destructors.i:72: Warning 521: Illegal destructor name ~NOT_HStruct. Ignored.
|
||||
cpp_extend_destructors.i:81: Warning 521: Illegal destructor name ~NOT_IStruct. Ignored.
|
||||
cpp_extend_destructors.i:86: Warning 521: Illegal destructor name ~NOT_JStruct. Ignored.
|
||||
cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored.
|
||||
cpp_extend_destructors.i:99: Warning 521: Illegal destructor name ~NOT_LStruct< int >. Ignored.
|
||||
cpp_extend_destructors.i:99: Warning 521: Illegal destructor name ~NOT_LStruct< short >. Ignored.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_extend_redefine.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
|
||||
cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
|
||||
|
|
@ -281,6 +311,10 @@ cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored
|
|||
:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_no_return_type.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_no_return_type.i:6: Warning 504: Function R must have a return type. Ignored.
|
||||
cpp_no_return_type.i:10: Warning 504: Function UU must have a return type. Ignored.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
|
||||
cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored.
|
||||
|
|
|
|||
|
|
@ -58,11 +58,13 @@ swig_identifier
|
|||
swig_insert_bad
|
||||
swig_typemap_copy
|
||||
swig_typemap_old
|
||||
swig_typemap_warn
|
||||
'
|
||||
|
||||
# Files run in C++ mode
|
||||
CPPFILES='
|
||||
cpp_bad_extern
|
||||
cpp_extend_destructors
|
||||
cpp_extend_redefine
|
||||
cpp_extend_undefined
|
||||
cpp_inline_namespace
|
||||
|
|
@ -74,6 +76,7 @@ cpp_namespace_aliasnot
|
|||
cpp_namespace_aliasundef
|
||||
cpp_nested
|
||||
cpp_no_access
|
||||
cpp_no_return_type
|
||||
cpp_nobase
|
||||
cpp_overload
|
||||
cpp_overload_const
|
||||
|
|
|
|||
7
Examples/test-suite/errors/swig_typemap_warn.i
Normal file
7
Examples/test-suite/errors/swig_typemap_warn.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module xxx
|
||||
|
||||
%typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name ($1) - argnum: $argnum &1_ltype: $&1_ltype descriptor: $1_descriptor") int ""
|
||||
|
||||
%typemap(out, warning="1001:Test warning for 'out' typemap for $1_type $1_name ($1) - name: $name symname: $symname &1_ltype: $&1_ltype descriptor: $1_descriptor") double ""
|
||||
|
||||
double mmm(int abc, short def, int);
|
||||
125
Examples/test-suite/extend_constructor_destructor.i
Normal file
125
Examples/test-suite/extend_constructor_destructor.i
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
%module extend_constructor_destructor
|
||||
|
||||
%inline %{
|
||||
int globalVar = 0;
|
||||
|
||||
namespace Space {
|
||||
typedef struct tagAStruct {
|
||||
int ivar;
|
||||
} AStruct;
|
||||
|
||||
struct BStruct {
|
||||
int ivar;
|
||||
};
|
||||
|
||||
typedef struct tagCStruct {
|
||||
int ivar;
|
||||
} CStruct;
|
||||
|
||||
// Unnamed struct
|
||||
typedef struct {
|
||||
int ivar;
|
||||
} DStruct;
|
||||
|
||||
}
|
||||
|
||||
typedef struct tagEStruct {
|
||||
int ivar;
|
||||
} EStruct;
|
||||
|
||||
namespace Space {
|
||||
template<typename T>
|
||||
struct FFStruct {
|
||||
int ivar;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
namespace Space {
|
||||
|
||||
%extend tagAStruct {
|
||||
tagAStruct(int ivar0) {
|
||||
Space::AStruct *s = new Space::AStruct();
|
||||
s->ivar = ivar0;
|
||||
globalVar = ivar0;
|
||||
return s;
|
||||
}
|
||||
~tagAStruct() {
|
||||
globalVar = -$self->ivar;
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend BStruct {
|
||||
BStruct(int ivar0) {
|
||||
Space::BStruct *s = new Space::BStruct();
|
||||
s->ivar = ivar0;
|
||||
globalVar = ivar0;
|
||||
return s;
|
||||
}
|
||||
~BStruct() {
|
||||
globalVar = -$self->ivar;
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend CStruct {
|
||||
CStruct(int ivar0) {
|
||||
Space::CStruct *s = new Space::CStruct();
|
||||
s->ivar = ivar0;
|
||||
globalVar = ivar0;
|
||||
return s;
|
||||
}
|
||||
~CStruct() {
|
||||
globalVar = -$self->ivar;
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend DStruct {
|
||||
DStruct(int ivar0) {
|
||||
Space::DStruct *s = new Space::DStruct();
|
||||
s->ivar = ivar0;
|
||||
globalVar = ivar0;
|
||||
return s;
|
||||
}
|
||||
~DStruct() {
|
||||
globalVar = -$self->ivar;
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%extend EStruct {
|
||||
EStruct(int ivar0) {
|
||||
EStruct *s = new EStruct();
|
||||
s->ivar = ivar0;
|
||||
globalVar = ivar0;
|
||||
return s;
|
||||
}
|
||||
~EStruct() {
|
||||
globalVar = -$self->ivar;
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Space {
|
||||
%extend FFStruct {
|
||||
FFStruct(int ivar0) {
|
||||
Space::FFStruct<T> *s = new Space::FFStruct<T>();
|
||||
s->ivar = ivar0;
|
||||
globalVar = ivar0;
|
||||
return s;
|
||||
}
|
||||
~FFStruct() {
|
||||
globalVar = -$self->ivar;
|
||||
delete $self;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%template(FStruct) Space::FFStruct<long>;
|
||||
%template(GStruct) Space::FFStruct<char>;
|
||||
|
||||
81
Examples/test-suite/extend_typedef_class.i
Normal file
81
Examples/test-suite/extend_typedef_class.i
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
%module extend_typedef_class
|
||||
|
||||
// classes in global namespace
|
||||
%inline %{
|
||||
typedef struct tagAClass {
|
||||
int membervar;
|
||||
} AClass;
|
||||
|
||||
struct BClass {
|
||||
int membervar;
|
||||
};
|
||||
|
||||
typedef struct tagCClass {
|
||||
int membervar;
|
||||
} CClass;
|
||||
|
||||
// Unnamed struct
|
||||
typedef struct {
|
||||
int membervar;
|
||||
} DClass;
|
||||
%}
|
||||
|
||||
%extend tagAClass {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
%extend BClass {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
%extend CClass {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
%extend DClass {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
|
||||
// classes in a namespace
|
||||
%inline %{
|
||||
namespace Space {
|
||||
typedef struct tagAStruct {
|
||||
int membervar;
|
||||
} AStruct;
|
||||
|
||||
struct BStruct {
|
||||
int membervar;
|
||||
};
|
||||
|
||||
typedef struct tagCStruct {
|
||||
int membervar;
|
||||
} CStruct;
|
||||
|
||||
// Unnamed struct
|
||||
typedef struct {
|
||||
int membervar;
|
||||
} DStruct;
|
||||
}
|
||||
%}
|
||||
|
||||
namespace Space {
|
||||
|
||||
%extend tagAStruct {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
%extend BStruct {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
%extend CStruct {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
%extend DStruct {
|
||||
int getvar() { return $self->membervar; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -20,3 +20,14 @@ int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
|
|||
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
|
||||
%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
|
||||
%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
|
||||
|
||||
|
||||
%inline %{
|
||||
typedef int AddByValueTypedef(const int &a, int b);
|
||||
typedef int * AddByPointerTypedef(const int &a, int b);
|
||||
typedef int & AddByReferenceTypedef(const int &a, int b);
|
||||
void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; }
|
||||
void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; }
|
||||
void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; }
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ func f3() {
|
|||
p2.Vmethod(bc)
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ func main() {
|
|||
panic("overload(const char *)")
|
||||
}
|
||||
|
||||
|
||||
// everything put in a namespace
|
||||
if Nsoverload("hi") != 1000 {
|
||||
panic("nsoverload()")
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ func main() {
|
|||
panic("specialization(const char *, const char *)")
|
||||
}
|
||||
|
||||
|
||||
// simple specialization
|
||||
Xyz()
|
||||
Xyz_int()
|
||||
|
|
@ -144,7 +143,6 @@ func main() {
|
|||
panic("overload(const char *)")
|
||||
}
|
||||
|
||||
|
||||
// everything put in a namespace
|
||||
if Nsoverload("hi") != 1000 {
|
||||
panic("nsoverload()")
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ func main() {
|
|||
xz := template_default_arg.NewX_Foo_Z_8()
|
||||
_ = xz.Meth(fz)
|
||||
|
||||
|
||||
// Templated functions
|
||||
|
||||
// plain function: int ott(Foo<int>)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ func main() {
|
|||
panic(0)
|
||||
}
|
||||
|
||||
|
||||
// 'narrowing' also works
|
||||
ddc := virtual_poly.NDoubleNarrow(d.Nnumber())
|
||||
if d.Get() != ddc.Get() {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ SWIGOPT += -package $(JAVA_PACKAGE)
|
|||
# Custom tests - tests with additional commandline options
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace.%: JAVA_PACKAGE = $*Package
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
|
|
|||
42
Examples/test-suite/java/director_binary_string_runme.java
Normal file
42
Examples/test-suite/java/director_binary_string_runme.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
import director_binary_string.*;
|
||||
|
||||
public class director_binary_string_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_binary_string");
|
||||
} 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[]) {
|
||||
Caller caller = new Caller();
|
||||
Callback callback = new DirectorBinaryStringCallback();
|
||||
caller.setCallback(callback);
|
||||
int sum = caller.call();
|
||||
caller.delCallback();
|
||||
|
||||
if (sum != 9*2*8 + 13*3*5)
|
||||
throw new RuntimeException("Unexpected sum: " + sum);
|
||||
}
|
||||
}
|
||||
|
||||
class DirectorBinaryStringCallback extends Callback {
|
||||
public DirectorBinaryStringCallback() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(byte[] dataBufferAA, byte[] dataBufferBB)
|
||||
{
|
||||
for (int i = 0; i < dataBufferAA.length; i++)
|
||||
dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
|
||||
|
||||
for (int i = 0; i < dataBufferBB.length; i++)
|
||||
dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
|
||||
}
|
||||
}
|
||||
|
||||
48
Examples/test-suite/java/director_nspace_runme.java
Normal file
48
Examples/test-suite/java/director_nspace_runme.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Make sure that directors are connected and disconnected when used inconjunction with
|
||||
// the %nspace feature
|
||||
|
||||
public class director_nspace_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_nspace");
|
||||
} 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[]) {
|
||||
director_nspace_MyBarFoo myBarFoo =
|
||||
new director_nspace_MyBarFoo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
return "director_nspace_MyBarFoo.ping();";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pong() {
|
||||
return "director_nspace_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(director_nspacePackage.Bar.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_nspacePackage.Bar.Foo makeFoo() {
|
||||
return new director_nspacePackage.Bar.Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_nspacePackage.Bar.FooBar makeFooBar() {
|
||||
return new director_nspacePackage.Bar.FooBar();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import extend_constructor_destructor.*;
|
||||
|
||||
public class extend_constructor_destructor_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("extend_constructor_destructor");
|
||||
} 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[]) {
|
||||
AStruct a = new AStruct(10);
|
||||
checkGlobal(10);
|
||||
BStruct b = new BStruct(20);
|
||||
checkGlobal(20);
|
||||
CStruct c = new CStruct(30);
|
||||
checkGlobal(30);
|
||||
DStruct d = new DStruct(40);
|
||||
checkGlobal(40);
|
||||
EStruct e = new EStruct(50);
|
||||
checkGlobal(50);
|
||||
FStruct f = new FStruct(60);
|
||||
checkGlobal(60);
|
||||
GStruct g = new GStruct(70);
|
||||
checkGlobal(70);
|
||||
|
||||
a.delete();
|
||||
checkGlobal(-10);
|
||||
b.delete();
|
||||
checkGlobal(-20);
|
||||
c.delete();
|
||||
checkGlobal(-30);
|
||||
d.delete();
|
||||
checkGlobal(-40);
|
||||
e.delete();
|
||||
checkGlobal(-50);
|
||||
f.delete();
|
||||
checkGlobal(-60);
|
||||
g.delete();
|
||||
checkGlobal(-70);
|
||||
}
|
||||
|
||||
public static void checkGlobal(int val) {
|
||||
int global = extend_constructor_destructor.getGlobalVar();
|
||||
if (global != val)
|
||||
throw new RuntimeException("global value incorrect. Expected: " + val + " got: " + global);
|
||||
}
|
||||
}
|
||||
|
||||
65
Examples/test-suite/java/extend_typedef_class_runme.java
Normal file
65
Examples/test-suite/java/extend_typedef_class_runme.java
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import extend_typedef_class.*;
|
||||
|
||||
public class extend_typedef_class_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("extend_typedef_class");
|
||||
} 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[]) {
|
||||
// No namespace
|
||||
{
|
||||
AClass s = new AClass();
|
||||
s.setMembervar(10);
|
||||
checkMatch(s.getvar(), 10);
|
||||
}
|
||||
{
|
||||
BClass s = new BClass();
|
||||
s.setMembervar(20);
|
||||
checkMatch(s.getvar(), 20);
|
||||
}
|
||||
{
|
||||
CClass s = new CClass();
|
||||
s.setMembervar(30);
|
||||
checkMatch(s.getvar(), 30);
|
||||
}
|
||||
{
|
||||
DClass s = new DClass();
|
||||
s.setMembervar(40);
|
||||
checkMatch(s.getvar(), 40);
|
||||
}
|
||||
|
||||
// In namespace
|
||||
{
|
||||
AStruct s = new AStruct();
|
||||
s.setMembervar(10);
|
||||
checkMatch(s.getvar(), 10);
|
||||
}
|
||||
{
|
||||
BStruct s = new BStruct();
|
||||
s.setMembervar(20);
|
||||
checkMatch(s.getvar(), 20);
|
||||
}
|
||||
{
|
||||
CStruct s = new CStruct();
|
||||
s.setMembervar(30);
|
||||
checkMatch(s.getvar(), 30);
|
||||
}
|
||||
{
|
||||
DStruct s = new DStruct();
|
||||
s.setMembervar(40);
|
||||
checkMatch(s.getvar(), 40);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkMatch(int expected, int got) {
|
||||
if (expected != got)
|
||||
throw new RuntimeException("Value incorrect. Expected: " + expected + " got: " + got);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -23,6 +23,7 @@ public class java_lib_arrays_runme {
|
|||
|
||||
// Create arrays for all the array types that ArrayStruct can handle
|
||||
String array_c = "X";
|
||||
byte[] array_c_extra = {11, 22};
|
||||
byte[] array_sc = {10, 20};
|
||||
short[] array_uc = {101, 201};
|
||||
short[] array_s = {1002, 2002};
|
||||
|
|
@ -105,6 +106,12 @@ public class java_lib_arrays_runme {
|
|||
|
||||
as.setArray_struct(array_struct);
|
||||
check_struct_array(array_struct, as.getArray_struct());
|
||||
|
||||
// Extended element (for char[])
|
||||
ArrayStructExtra ase = new ArrayStructExtra();
|
||||
ase.setArray_c2(array_c_extra);
|
||||
check_byte_array(array_c_extra, ase.getArray_c2());
|
||||
|
||||
}
|
||||
|
||||
// Functions to check that the array values were set correctly
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
|
||||
import li_boost_shared_ptr_template.*;
|
||||
|
||||
public class li_boost_shared_ptr_template_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_boost_shared_ptr_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[]) {
|
||||
{
|
||||
BaseINTEGER b = new BaseINTEGER();
|
||||
DerivedINTEGER d = new DerivedINTEGER();
|
||||
if (b.bar() != 1)
|
||||
throw new RuntimeException("test 1");
|
||||
if (d.bar() != 2)
|
||||
throw new RuntimeException("test 2");
|
||||
if (li_boost_shared_ptr_template.bar_getter(b) != 1)
|
||||
throw new RuntimeException("test 3");
|
||||
if (li_boost_shared_ptr_template.bar_getter(d) != 2)
|
||||
throw new RuntimeException("test 4");
|
||||
}
|
||||
|
||||
{
|
||||
BaseDefaultInt b = new BaseDefaultInt();
|
||||
DerivedDefaultInt d = new DerivedDefaultInt();
|
||||
DerivedDefaultInt2 d2 = new DerivedDefaultInt2();
|
||||
if (b.bar2() != 3)
|
||||
throw new RuntimeException("test 5");
|
||||
if (d.bar2() != 4)
|
||||
throw new RuntimeException("test 6");
|
||||
if (d2.bar2() != 4)
|
||||
throw new RuntimeException("test 6");
|
||||
if (li_boost_shared_ptr_template.bar2_getter(b) != 3)
|
||||
throw new RuntimeException("test 7");
|
||||
if (li_boost_shared_ptr_template.bar2_getter(d) != 4)
|
||||
throw new RuntimeException("test 8");
|
||||
if (li_boost_shared_ptr_template.bar2_getter(d2) != 4)
|
||||
throw new RuntimeException("test 8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -17,8 +17,11 @@ public class template_default_class_parms_runme {
|
|||
{
|
||||
DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
|
||||
double d = bar.getCType();
|
||||
bar.setCType(d);
|
||||
SomeType s = bar.getDType();
|
||||
bar.setDType(s);
|
||||
int i = bar.getEType();
|
||||
bar.setEType(i);
|
||||
d = bar.method(d, s, i);
|
||||
}
|
||||
{
|
||||
|
|
@ -29,13 +32,17 @@ public class template_default_class_parms_runme {
|
|||
{
|
||||
BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
|
||||
AnotherType a = bar.getCType();
|
||||
bar.setCType(a);
|
||||
boolean b = bar.getDType();
|
||||
bar.setDType(b);
|
||||
int i = bar.getEType();
|
||||
bar.setEType(i);
|
||||
a = bar.method(a, b, i);
|
||||
}
|
||||
{
|
||||
FooAnotherType foo = new FooAnotherType(new AnotherType());
|
||||
AnotherType a = foo.getTType();
|
||||
foo.setTType(a);
|
||||
a = foo.method(a);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
|
||||
import template_default_class_parms_typedef.*;
|
||||
|
||||
public class template_default_class_parms_typedef_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_default_class_parms_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[]) {
|
||||
{
|
||||
DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
|
||||
double d = bar.getCType();
|
||||
bar.setCType(d);
|
||||
SomeType s = bar.getDType();
|
||||
bar.setDType(s);
|
||||
int i = bar.getEType();
|
||||
bar.setEType(i);
|
||||
d = bar.method(d, s, i);
|
||||
d = bar.method_1(d, s, i);
|
||||
d = bar.method_2(d, s, i);
|
||||
d = bar.method_3(d, s, i);
|
||||
|
||||
bar = new DefaultBar(true, 20.0, new SomeType(), 10);
|
||||
bar = new DefaultBar(true, true, 20.0, new SomeType(), 10);
|
||||
bar = new DefaultBar(true, true, true, 20.0, new SomeType(), 10);
|
||||
}
|
||||
{
|
||||
DefaultFoo foo = new DefaultFoo(new SomeType());
|
||||
SomeType s = foo.getTType();
|
||||
s = foo.method(s);
|
||||
s = foo.method_A(s);
|
||||
s = foo.method_B(s);
|
||||
s = foo.method_C(s);
|
||||
|
||||
foo = new DefaultFoo(new SomeType(), new SomeType());
|
||||
foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType());
|
||||
foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType(), new SomeType());
|
||||
}
|
||||
{
|
||||
BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
|
||||
AnotherType a = bar.getCType();
|
||||
bar.setCType(a);
|
||||
boolean b = bar.getDType();
|
||||
bar.setDType(b);
|
||||
int i = bar.getEType();
|
||||
bar.setEType(i);
|
||||
|
||||
a = bar.method(a, b, i);
|
||||
a = bar.method_1(a, b, i);
|
||||
a = bar.method_2(a, b, i);
|
||||
a = bar.method_3(a, b, i);
|
||||
|
||||
bar = new BarAnotherTypeBool(true, new AnotherType(), true, 10);
|
||||
bar = new BarAnotherTypeBool(true, true, new AnotherType(), true, 10);
|
||||
bar = new BarAnotherTypeBool(true, true, true, new AnotherType(), true, 10);
|
||||
}
|
||||
{
|
||||
FooAnotherType foo = new FooAnotherType(new AnotherType());
|
||||
AnotherType a = foo.getTType();
|
||||
foo.setTType(a);
|
||||
a = foo.method(a);
|
||||
a = foo.method_A(a);
|
||||
a = foo.method_B(a);
|
||||
a = foo.method_C(a);
|
||||
|
||||
foo = new FooAnotherType(new AnotherType(), new AnotherType());
|
||||
foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType());
|
||||
foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType(), new AnotherType());
|
||||
}
|
||||
{
|
||||
UsesBarDouble u = new UsesBarDouble();
|
||||
u.use_A(10.1, new SomeType(), 10);
|
||||
u.use_B(10.1, new SomeType(), 10);
|
||||
u.use_C(10.1, new SomeType(), 10);
|
||||
u.use_D(10.1, new SomeType(), 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
Examples/test-suite/java/template_typedef_inherit_runme.java
Normal file
24
Examples/test-suite/java/template_typedef_inherit_runme.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
|
||||
import template_typedef_inherit.*;
|
||||
|
||||
public class template_typedef_inherit_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_typedef_inherit");
|
||||
} 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[]) {
|
||||
DescriptionImplementationTypedCollectionInterfaceObject d = new DescriptionImplementationTypedCollectionInterfaceObject();
|
||||
d.add("a string");
|
||||
|
||||
StringPersistentCollection s = new StringPersistentCollection();
|
||||
s.add("a string");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
JAVA_ARRAYSOFCLASSES(SimpleStruct)
|
||||
%apply ARRAYSOFENUMS[ANY] { finger[ANY] }
|
||||
//%apply signed char[ANY] { char array_c2[ANY] }
|
||||
|
||||
%include "arrays.i"
|
||||
|
||||
|
|
@ -54,3 +55,15 @@ typedef enum { Big, Little } toe;
|
|||
void toestest(toe *t, toe tt[], toe ttt[2]) {}
|
||||
%}
|
||||
|
||||
|
||||
JAVA_ARRAYS_IMPL(char, jbyte, Byte, Char)
|
||||
JAVA_ARRAYS_TYPEMAPS(char, byte, jbyte, Char, "[B")
|
||||
%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */
|
||||
signed char[ANY], signed char[]
|
||||
""
|
||||
|
||||
%inline %{
|
||||
struct ArrayStructExtra {
|
||||
char array_c2[ARRAY_LEN];
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%module python_kwargs
|
||||
%module kwargs_feature
|
||||
|
||||
%nocopyctor;
|
||||
%kwargs;
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
%module li_boost_intrusive_ptr
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
|
||||
%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived;
|
||||
%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived;
|
||||
|
||||
%inline %{
|
||||
#include "boost/shared_ptr.hpp"
|
||||
|
|
@ -37,7 +39,7 @@
|
|||
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
|
||||
#endif
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
|
|
@ -50,6 +52,7 @@
|
|||
%intrusive_ptr(Space::KlassDerivedDerived)
|
||||
|
||||
//For the use_count shared_ptr functions
|
||||
#if defined(SWIGJAVA)
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
|
||||
$1 = $input ? *($&1_ltype)&$input : &tempnull;
|
||||
%}
|
||||
|
|
@ -74,6 +77,10 @@
|
|||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
|
||||
|
||||
#elif defined(SWIGCSHARP)
|
||||
// TODO!
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
|
|
|
|||
99
Examples/test-suite/li_boost_shared_ptr_template.i
Normal file
99
Examples/test-suite/li_boost_shared_ptr_template.i
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
%module li_boost_shared_ptr_template
|
||||
|
||||
// First test- Bug 3333549 - using INTEGER typedef in %shared_ptr before typedef defined
|
||||
%{
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
typedef int INTEGER;
|
||||
|
||||
template <class T>
|
||||
class Base {
|
||||
public:
|
||||
virtual T bar() {return 1;}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Derived : public Base<T> {
|
||||
public:
|
||||
virtual T bar() {return 2;}
|
||||
};
|
||||
|
||||
INTEGER bar_getter(Base<INTEGER>& foo) {
|
||||
return foo.bar();
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
|
||||
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%include <boost_shared_ptr.i>
|
||||
%shared_ptr(Base<INTEGER>)
|
||||
%shared_ptr(Derived<INTEGER>)
|
||||
|
||||
#endif
|
||||
|
||||
typedef int INTEGER;
|
||||
|
||||
template <class T>
|
||||
class Base {
|
||||
public:
|
||||
virtual T bar() {return 1;}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Derived : public Base<T> {
|
||||
public:
|
||||
virtual T bar() {return 2;}
|
||||
};
|
||||
|
||||
INTEGER bar_getter(Base<INTEGER>& foo) {
|
||||
return foo.bar();
|
||||
}
|
||||
|
||||
%template(BaseINTEGER) Base<INTEGER>;
|
||||
%template(DerivedINTEGER) Derived<INTEGER>;
|
||||
|
||||
|
||||
// 2nd test - templates with default template parameters
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%shared_ptr(Space::BaseDefault<short>)
|
||||
%shared_ptr(Space::DerivedDefault<short>)
|
||||
%shared_ptr(Space::DerivedDefault2<short>)
|
||||
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
typedef int INT_TYPEDEF;
|
||||
template <class X, class T = int>
|
||||
class BaseDefault {
|
||||
public:
|
||||
virtual T bar2() {return 3;}
|
||||
};
|
||||
|
||||
template <class X, class T = int>
|
||||
class DerivedDefault : public BaseDefault<X, T> {
|
||||
public:
|
||||
virtual T bar2() {return 4;}
|
||||
};
|
||||
template <class X>
|
||||
class DerivedDefault2 : public BaseDefault<X> {
|
||||
public:
|
||||
virtual int bar2() {return 4;}
|
||||
};
|
||||
|
||||
int bar2_getter(BaseDefault<short>& foo) {
|
||||
return foo.bar2();
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%template(BaseDefaultInt) Space::BaseDefault<short>;
|
||||
%template(DerivedDefaultInt) Space::DerivedDefault<short>;
|
||||
%template(DerivedDefaultInt2) Space::DerivedDefault2<short>;
|
||||
|
||||
12
Examples/test-suite/li_std_containers_int.i
Normal file
12
Examples/test-suite/li_std_containers_int.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%module li_std_containers_int
|
||||
|
||||
//
|
||||
// Test containers of type int
|
||||
//
|
||||
|
||||
%include std_vector.i
|
||||
%include std_list.i
|
||||
|
||||
%template(vector_int) std::vector<int>;
|
||||
%template(list_int) std::list<int>;
|
||||
|
||||
|
|
@ -27,6 +27,7 @@ namespace std {
|
|||
|
||||
%inline %{
|
||||
typedef float Real;
|
||||
size_t typedef_test(std::vector<int>::size_type s) { return s; }
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ top_builddir = @top_builddir@
|
|||
|
||||
# sorry, currently very few test cases work/have been written
|
||||
|
||||
#CPP_TEST_CASES += \
|
||||
# cnum
|
||||
CPP_TEST_CASES += \
|
||||
lua_no_module_global \
|
||||
|
||||
#C_TEST_CASES += \
|
||||
# file_test \
|
||||
# nondynamic
|
||||
|
||||
C_TEST_CASES += \
|
||||
lua_no_module_global \
|
||||
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
|
@ -25,7 +25,7 @@ include $(srcdir)/../common.mk
|
|||
LIBS = -L.
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
lua_no_module_global.%: SWIGOPT += -nomoduleglobal
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
|
|
|||
24
Examples/test-suite/lua/lua_no_module_global_runme.lua
Normal file
24
Examples/test-suite/lua/lua_no_module_global_runme.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
-- require is only available in Lua 5.1
|
||||
|
||||
if string.sub(_VERSION,1,7)=='Lua 5.1' then
|
||||
|
||||
-- Initially the package should not be loaded
|
||||
assert(package.loaded["lua_no_module_global"] == nil)
|
||||
|
||||
-- Load the module
|
||||
the_module = require "lua_no_module_global"
|
||||
|
||||
-- require should return the module table
|
||||
assert(the_module.hi_mom ~= nil)
|
||||
assert(the_module.hi_mom() == "hi mom!")
|
||||
|
||||
-- But it should not end up in the global table _G, subject to
|
||||
-- the -nomoduleglobal swig option.
|
||||
assert(_G["lua_no_module_global"] == nil)
|
||||
|
||||
-- According to the Lua 5.1 reference manual, require should also
|
||||
-- store the module table into package.loaded["name"]
|
||||
assert(package.loaded["lua_no_module_global"] == the_module)
|
||||
assert(package.loaded["lua_no_module_global"].hi_mom() == "hi mom!")
|
||||
|
||||
end
|
||||
5
Examples/test-suite/lua_no_module_global.i
Normal file
5
Examples/test-suite/lua_no_module_global.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%module lua_no_module_global
|
||||
%{
|
||||
const char *hi_mom() { return "hi mom!"; }
|
||||
%}
|
||||
const char *hi_mom();
|
||||
|
|
@ -4,6 +4,10 @@
|
|||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
#endif
|
||||
|
||||
%nspace;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
#endif
|
||||
%nspace;
|
||||
|
||||
%extend Outer::Inner1::Color {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,74 +1,99 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 415;
|
||||
use Test::More tests => 631;
|
||||
BEGIN { use_ok('li_typemaps') }
|
||||
require_ok('li_typemaps');
|
||||
|
||||
sub batch { my($type, @values) = @_;
|
||||
# this is a little ugly because I'm trying to be clever and save my
|
||||
# wrists from hammering out all these tests.
|
||||
for my $val (@values) {
|
||||
for my $tst (qw(
|
||||
in inr
|
||||
out outr
|
||||
inout inoutr
|
||||
)) {
|
||||
my $func = $tst . '_' . $type;
|
||||
is(eval { li_typemaps->can($func)->($val) }, $val, "$func $val");
|
||||
if($@) {
|
||||
my $err = $@;
|
||||
$err =~ s/^/#\$\@# /mg;
|
||||
print $err;
|
||||
}
|
||||
my @tests = qw(
|
||||
in inr
|
||||
out outr
|
||||
inout inoutr
|
||||
);
|
||||
|
||||
sub should_pass { my($type, @values) = @_;
|
||||
# verify that each value passes cleanly
|
||||
for my $test (@tests) {
|
||||
my $name = "${test}_${type}";
|
||||
my $func = li_typemaps->can($name);
|
||||
for my $val (@values) {
|
||||
my $rv = eval { $func->($val) };
|
||||
is($rv, $val, "$name $val");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
batch('bool', '', 1);
|
||||
# let's assume we're at least on a 32 bit machine
|
||||
batch('int', -0x80000000, -1, 0, 1, 12, 0x7fffffff);
|
||||
# long could be bigger, but it's at least this big
|
||||
batch('long', -0x80000000, -1, 0, 1, 12, 0x7fffffff);
|
||||
batch('short', -0x8000, -1, 0, 1, 12, 0x7fff);
|
||||
batch('uint', 0, 1, 12, 0xffffffff);
|
||||
batch('ushort', 0, 1, 12, 0xffff);
|
||||
batch('ulong', 0, 1, 12, 0xffffffff);
|
||||
batch('uchar', 0, 1, 12, 0xff);
|
||||
batch('schar', -0x80, 0, 1, 12, 0x7f);
|
||||
|
||||
{
|
||||
use Math::BigInt qw();
|
||||
# the pack dance is to get plain old NVs out of the
|
||||
# Math::BigInt objects.
|
||||
my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
|
||||
my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
|
||||
batch('float',
|
||||
-(2 - 2 ** -23) * 2 ** 127,
|
||||
-1, -2 ** -149, 0, 2 ** -149, 1,
|
||||
(2 - 2 ** -23) * 2 ** 127,
|
||||
$nan);
|
||||
{ local $TODO = "float typemaps don't pass infinity";
|
||||
# it seems as though SWIG is unwilling to pass infinity around
|
||||
# because that value always fails bounds checking. I think that
|
||||
# is a bug.
|
||||
batch('float', $inf);
|
||||
}
|
||||
batch('double',
|
||||
-(2 - 2 ** -53) ** 1023,
|
||||
-1, -2 ** -1074, 0, 2 ** 1074,
|
||||
(2 - 2 ** -53) ** 1023,
|
||||
$nan, $inf);
|
||||
sub should_fail { my($type, @values) = @_;
|
||||
# verify that all values trigger runtime errors
|
||||
for my $test (@tests) {
|
||||
my $name = "${test}_${type}";
|
||||
my $func = li_typemaps->can($name);
|
||||
for my $val (@values) {
|
||||
my $rv = eval { $func->($val) };
|
||||
like($@, qr/\b(?:Overflow|Type)Error\b/, "overflow $name $val");
|
||||
}
|
||||
}
|
||||
}
|
||||
batch('longlong', -1, 0, 1, 12);
|
||||
batch('ulonglong', 0, 1, 12);
|
||||
|
||||
sub pad { my($t, $s, $f) = @_;
|
||||
my $nbytes = length pack $t, 0;
|
||||
return unpack $t, $s . ($f x ($nbytes - 1));
|
||||
}
|
||||
|
||||
# some edge case values:
|
||||
my $nan = unpack 'f>', "\x7f\xc0\x00\x00";
|
||||
my $inf = unpack 'f>', "\x7f\x80\x00\x00";
|
||||
my $char_min = pad 'c', "\x80";
|
||||
my $char_max = pad 'c', "\x7f";
|
||||
my $char_umax = pad 'C', "\xff";
|
||||
my $short_min = pad 's!>', "\x80", "\x00";
|
||||
my $short_max = pad 's!>', "\x7f", "\xff";
|
||||
my $short_umax = pad 'S!>', "\xff", "\xff";
|
||||
my $int_min = pad 'i!>', "\x80", "\x00";
|
||||
my $int_max = pad 'i!>', "\x7f", "\xff";
|
||||
my $int_umax = pad 'I!>', "\xff", "\xff";
|
||||
my $long_min = pad 'l!>', "\x80", "\x00";
|
||||
my $long_max = pad 'l!>', "\x7f", "\xff";
|
||||
my $long_umax = pad 'L!>', "\xff", "\xff";
|
||||
|
||||
should_pass('bool', '', 1);
|
||||
should_pass('int', $int_min, -1, 0, 1, 12, $int_max);
|
||||
should_fail('int', $int_min - 1000, $int_max + 1000, $inf, $nan);
|
||||
should_pass('long', $long_min, -1, 0, 1, 12, $long_max);
|
||||
should_fail('long', $long_min - 8000, $long_max + 8000, $inf, $nan);
|
||||
should_pass('short', $short_min, -1, 0, 1, 12, $short_max);
|
||||
should_fail('short', $short_min - 1, $short_max + 1, $inf, $nan);
|
||||
should_pass('uint', 0, 1, 12, $int_umax);
|
||||
should_fail('uint', -1, $int_umax + 1000, $inf, $nan);
|
||||
should_pass('ushort', 0, 1, 12, $short_umax);
|
||||
should_fail('ushort', -1, $short_umax + 1, $inf, $nan);
|
||||
should_pass('ulong', 0, 1, 12, $long_umax);
|
||||
should_fail('ulong', -1, $long_umax + 8000, $inf, $nan);
|
||||
should_pass('uchar', 0, 1, 12, $char_umax);
|
||||
should_fail('uchar', -1, $char_umax + 1, $inf, $nan);
|
||||
should_pass('schar', $char_min, -1, 0, 1, 12, $char_max);
|
||||
should_fail('schar', $char_min - 1, $char_max + 1, $inf, $nan);
|
||||
should_pass('float', -1, 0, 1, $nan);
|
||||
TODO: {
|
||||
local $TODO = "typemaps don't allow float infinity";
|
||||
should_pass('float', -$inf, $inf);
|
||||
}
|
||||
should_pass('double', -$inf, -1, 0, 1, $inf, $nan);
|
||||
should_pass('longlong', -1, 0, 1, 12);
|
||||
should_fail('longlong', $inf, $nan);
|
||||
should_pass('ulonglong', 0, 1, 12);
|
||||
should_fail('ulonglong', -1, $inf, $nan);
|
||||
SKIP: {
|
||||
my $a = "8000000000000000";
|
||||
my $b = "7fffffffffffffff";
|
||||
my $c = "ffffffffffffffff";
|
||||
skip "not a 64bit Perl", 18 unless eval { pack 'q', 1 };
|
||||
batch('longlong', -hex($a), hex($b));
|
||||
batch('ulonglong', hex($c));
|
||||
my $llong_min = eval { pad 'q>', "\x80", "\x00" };
|
||||
my $llong_max = eval { pad 'q>', "\x7f", "\xff" };
|
||||
my $llong_umax = eval { pad 'Q>', "\xff", "\xff" };
|
||||
|
||||
skip 'not a 64 bit perl', 6 * 6 unless defined $llong_min;
|
||||
|
||||
should_pass('longlong', $llong_min, $llong_max);
|
||||
should_fail('longlong', $llong_min - 8000, $llong_max + 8000);
|
||||
should_pass('ulonglong', $llong_umax);
|
||||
should_fail('ulonglong', $llong_umax + 8000);
|
||||
}
|
||||
|
||||
my($foo, $int) = li_typemaps::out_foo(10);
|
||||
|
|
@ -79,4 +104,3 @@ is($int, 20);
|
|||
my($a, $b) = li_typemaps::inoutr_int2(13, 31);
|
||||
is($a, 13);
|
||||
is($b, 31);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ CPP_TEST_CASES += \
|
|||
inout \
|
||||
inplaceadd \
|
||||
input \
|
||||
kwargs_feature \
|
||||
li_cstring \
|
||||
li_cwstring \
|
||||
li_factory \
|
||||
|
|
@ -58,7 +59,7 @@ CPP_TEST_CASES += \
|
|||
primitive_types \
|
||||
python_abstractbase \
|
||||
python_append \
|
||||
python_kwargs \
|
||||
python_director \
|
||||
python_nondynamic \
|
||||
python_overload_simple_cast \
|
||||
python_richcompare \
|
||||
|
|
|
|||
176
Examples/test-suite/python/autodoc_runme.py
Normal file
176
Examples/test-suite/python/autodoc_runme.py
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
from autodoc import *
|
||||
|
||||
def check(got, expected):
|
||||
if expected != got:
|
||||
raise RuntimeError("\n" + "Expected: [" + expected + "]\n" + "Got : [" + got + "]")
|
||||
|
||||
check(A.__doc__, "Proxy of C++ A class")
|
||||
check(A.funk.__doc__, "just a string")
|
||||
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
|
||||
check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
|
||||
check(A.func2.__doc__, "\n"
|
||||
" func2(self, arg2, hello) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" arg2: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
check(A.func3.__doc__, "\n"
|
||||
" func3(A self, short arg2, Tuple hello) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" arg2: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
|
||||
check(A.func0default.__doc__, "\n"
|
||||
" func0default(self, e, arg3, hello, f=2) -> int\n"
|
||||
" func0default(self, e, arg3, hello) -> int\n"
|
||||
" "
|
||||
)
|
||||
check(A.func1default.__doc__, "\n"
|
||||
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
|
||||
" "
|
||||
)
|
||||
check(A.func2default.__doc__, "\n"
|
||||
" func2default(self, e, arg3, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg3: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
" f: double\n"
|
||||
"\n"
|
||||
" func2default(self, e, arg3, hello) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg3: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
check(A.func3default.__doc__, "\n"
|
||||
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg3: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
" f: double\n"
|
||||
"\n"
|
||||
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg3: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
|
||||
check(A.func0static.__doc__, "\n"
|
||||
" func0static(e, arg2, hello, f=2) -> int\n"
|
||||
" func0static(e, arg2, hello) -> int\n"
|
||||
" "
|
||||
)
|
||||
check(A.func1static.__doc__, "\n"
|
||||
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||
" func1static(A e, short arg2, Tuple hello) -> int\n"
|
||||
" "
|
||||
)
|
||||
check(A.func2static.__doc__, "\n"
|
||||
" func2static(e, arg2, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg2: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
" f: double\n"
|
||||
"\n"
|
||||
" func2static(e, arg2, hello) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg2: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
check(A.func3static.__doc__, "\n"
|
||||
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg2: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
" f: double\n"
|
||||
"\n"
|
||||
" func3static(A e, short arg2, Tuple hello) -> int\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" e: A *\n"
|
||||
" arg2: short\n"
|
||||
" hello: int tuple[2]\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
|
||||
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
|
||||
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
|
||||
check(A.variable_c.__doc__, "\n"
|
||||
"A_variable_c_get(self) -> int\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
" self: A *\n"
|
||||
"\n"
|
||||
)
|
||||
check(A.variable_d.__doc__, "\n"
|
||||
"A_variable_d_get(A self) -> int\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
" self: A *\n"
|
||||
"\n"
|
||||
)
|
||||
|
||||
check(B.__doc__, "Proxy of C++ B class")
|
||||
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
|
||||
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
|
||||
check(E.__init__.__doc__, "\n"
|
||||
" __init__(self, a, b, h) -> E\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" a: special comment for parameter a\n"
|
||||
" b: another special comment for parameter b\n"
|
||||
" h: enum Hola\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
check(F.__init__.__doc__, "\n"
|
||||
" __init__(F self, int a, int b, Hola h) -> F\n"
|
||||
"\n"
|
||||
" Parameters:\n"
|
||||
" a: special comment for parameter a\n"
|
||||
" b: another special comment for parameter b\n"
|
||||
" h: enum Hola\n"
|
||||
"\n"
|
||||
" "
|
||||
)
|
||||
|
||||
check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
|
||||
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
|
||||
check(funkdefaults.__doc__, "\n"
|
||||
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
||||
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
||||
" "
|
||||
)
|
||||
|
||||
check(func_input.__doc__, "func_input(int * INPUT) -> int")
|
||||
check(func_output.__doc__, "func_output() -> int")
|
||||
check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
|
||||
check(banana.__doc__, "banana(S a, S b, int c, Integer d)")
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from python_kwargs import *
|
||||
from kwargs_feature import *
|
||||
|
||||
class MyFoo(Foo):
|
||||
def __init__(self, a , b = 0):
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
from li_boost_shared_ptr_template import *
|
||||
|
||||
b = BaseINTEGER()
|
||||
d = DerivedINTEGER()
|
||||
if b.bar() != 1:
|
||||
raise RuntimeError
|
||||
if d.bar() != 2:
|
||||
raise RuntimeError
|
||||
if bar_getter(b) != 1:
|
||||
raise RuntimeError
|
||||
if bar_getter(d) != 2:
|
||||
raise RuntimeError
|
||||
|
||||
b = BaseDefaultInt()
|
||||
d = DerivedDefaultInt()
|
||||
d2 = DerivedDefaultInt2()
|
||||
if b.bar2() != 3:
|
||||
raise RuntimeError
|
||||
if d.bar2() != 4:
|
||||
raise RuntimeError
|
||||
if d2.bar2() != 4:
|
||||
raise RuntimeError
|
||||
if bar2_getter(b) != 3:
|
||||
raise RuntimeError
|
||||
if bar2_getter(d) != 4:
|
||||
raise RuntimeError
|
||||
if bar2_getter(d2) != 4:
|
||||
raise RuntimeError
|
||||
265
Examples/test-suite/python/li_std_containers_int_runme.py
Normal file
265
Examples/test-suite/python/li_std_containers_int_runme.py
Normal file
|
|
@ -0,0 +1,265 @@
|
|||
# Check std::vector and std::list behaves the same as Python iterable types (list)
|
||||
|
||||
from li_std_containers_int import *
|
||||
|
||||
def failed(a, b, msg):
|
||||
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
|
||||
|
||||
def compare_sequences(a, b):
|
||||
if len(a) != len(b):
|
||||
failed(a, b, "different sizes")
|
||||
for i in range(len(a)):
|
||||
if a[i] != b[i]:
|
||||
failed(a, b, "elements are different")
|
||||
|
||||
def compare_containers(pythonlist, swigvector, swiglist):
|
||||
compare_sequences(pythonlist, swigvector)
|
||||
compare_sequences(pythonlist, swiglist)
|
||||
|
||||
# Check std::vector and std::list assignment behaves same as Python list assignment including exceptions
|
||||
def container_insert_step(i, j, step, newval):
|
||||
ps = range(6)
|
||||
iv = vector_int(ps)
|
||||
il = list_int(ps)
|
||||
|
||||
# Python slice
|
||||
try:
|
||||
if step == None:
|
||||
if j == None:
|
||||
ps[i] = newval
|
||||
else:
|
||||
ps[i:j] = newval
|
||||
else:
|
||||
if j == None:
|
||||
ps[i::step] = newval
|
||||
else:
|
||||
ps[i:j:step] = newval
|
||||
ps_error = None
|
||||
except ValueError, e:
|
||||
ps_error = e
|
||||
except IndexError, e:
|
||||
ps_error = e
|
||||
|
||||
# std::vector<int>
|
||||
try:
|
||||
if step == None:
|
||||
if j == None:
|
||||
iv[i] = newval
|
||||
else:
|
||||
iv[i:j] = newval
|
||||
else:
|
||||
if j == None:
|
||||
iv[i::step] = newval
|
||||
else:
|
||||
iv[i:j:step] = newval
|
||||
iv_error = None
|
||||
except ValueError, e:
|
||||
iv_error = e
|
||||
except IndexError, e:
|
||||
iv_error = e
|
||||
|
||||
# std::list<int>
|
||||
try:
|
||||
if step == None:
|
||||
if j == None:
|
||||
il[i] = newval
|
||||
else:
|
||||
il[i:j] = newval
|
||||
else:
|
||||
if j == None:
|
||||
il[i::step] = newval
|
||||
else:
|
||||
il[i:j:step] = newval
|
||||
il_error = None
|
||||
except ValueError, e:
|
||||
il_error = e
|
||||
except IndexError, e:
|
||||
il_error = e
|
||||
|
||||
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
||||
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
||||
|
||||
compare_containers(ps, iv, il)
|
||||
|
||||
|
||||
# Check std::vector and std::list delete behaves same as Python list delete including exceptions
|
||||
def container_delete_step(i, j, step):
|
||||
ps = range(6)
|
||||
iv = vector_int(ps)
|
||||
il = list_int(ps)
|
||||
|
||||
# Python slice
|
||||
try:
|
||||
if step == None:
|
||||
if j == None:
|
||||
del ps[i]
|
||||
else:
|
||||
del ps[i:j]
|
||||
else:
|
||||
if j == None:
|
||||
del ps[i::step]
|
||||
else:
|
||||
del ps[i:j:step]
|
||||
ps_error = None
|
||||
except ValueError, e:
|
||||
ps_error = e
|
||||
except IndexError, e:
|
||||
ps_error = e
|
||||
|
||||
# std::vector<int>
|
||||
try:
|
||||
if step == None:
|
||||
if j == None:
|
||||
del iv[i]
|
||||
else:
|
||||
del iv[i:j]
|
||||
else:
|
||||
if j == None:
|
||||
del iv[i::step]
|
||||
else:
|
||||
del iv[i:j:step]
|
||||
iv_error = None
|
||||
except ValueError, e:
|
||||
iv_error = e
|
||||
except IndexError, e:
|
||||
iv_error = e
|
||||
|
||||
# std::list<int>
|
||||
try:
|
||||
if step == None:
|
||||
if j == None:
|
||||
del il[i]
|
||||
else:
|
||||
del il[i:j]
|
||||
else:
|
||||
if j == None:
|
||||
del il[i::step]
|
||||
else:
|
||||
del il[i:j:step]
|
||||
il_error = None
|
||||
except ValueError, e:
|
||||
il_error = e
|
||||
except IndexError, e:
|
||||
il_error = e
|
||||
|
||||
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
||||
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
||||
|
||||
compare_containers(ps, iv, il)
|
||||
|
||||
|
||||
ps = [0,1,2,3,4,5]
|
||||
|
||||
iv = vector_int(ps)
|
||||
il = list_int(ps)
|
||||
|
||||
# slices
|
||||
compare_containers(ps[0:0], iv[0:0], il[0:0])
|
||||
compare_containers(ps[1:1], iv[1:1], il[1:1])
|
||||
compare_containers(ps[1:3], iv[1:3], il[1:3])
|
||||
compare_containers(ps[2:4], iv[2:4], il[2:4])
|
||||
compare_containers(ps[0:3], iv[0:3], il[0:3])
|
||||
compare_containers(ps[3:6], iv[3:6], il[3:6])
|
||||
compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range
|
||||
|
||||
# before beginning of range (negative indexing)
|
||||
compare_containers(ps[-1:7], iv[-1:7], il[-1:7])
|
||||
compare_containers(ps[-2:7], iv[-2:7], il[-2:7])
|
||||
compare_containers(ps[-5:7], iv[-5:7], il[-5:7])
|
||||
compare_containers(ps[-6:7], iv[-6:7], il[-6:7])
|
||||
|
||||
# before beginning of range (negative indexing, negative index is > container size)
|
||||
compare_containers(ps[-7:7], iv[-7:7], il[-7:7])
|
||||
compare_containers(ps[-100:7], iv[-100:7], il[-100:7])
|
||||
|
||||
compare_containers(ps[3:], iv[3:], il[3:])
|
||||
compare_containers(ps[:3], iv[:3], il[:3])
|
||||
compare_containers(ps[:], iv[:], il[:])
|
||||
compare_containers(ps[-3:], iv[-3:], il[-3:])
|
||||
compare_containers(ps[-7:], iv[-7:], il[-7:])
|
||||
compare_containers(ps[:-1], iv[:-1], il[:-1])
|
||||
compare_containers(ps[:-7], iv[:-7], il[:-7])
|
||||
|
||||
# step slicing
|
||||
compare_containers(ps[1:5:1], iv[1:5:1], il[1:5:1])
|
||||
compare_containers(ps[1:5:2], iv[1:5:2], il[1:5:2])
|
||||
compare_containers(ps[1:5:3], iv[1:5:3], il[1:5:3])
|
||||
compare_containers(ps[1:5:4], iv[1:5:4], il[1:5:4])
|
||||
compare_containers(ps[1:6:5], iv[1:6:5], il[1:6:5])
|
||||
compare_containers(ps[1:7:5], iv[1:7:5], il[1:7:5])
|
||||
compare_containers(ps[-1:7:1], iv[-1:7:1], il[-1:7:1])
|
||||
compare_containers(ps[-1:7:2], iv[-1:7:2], il[-1:7:2])
|
||||
compare_containers(ps[-6:7:2], iv[-6:7:2], il[-6:7:2])
|
||||
compare_containers(ps[-100:7:2], iv[-100:7:2], il[-100:7:2])
|
||||
compare_containers(ps[::1], iv[::1], il[::1])
|
||||
compare_containers(ps[::2], iv[::2], il[::2])
|
||||
|
||||
compare_containers(ps[::-1], iv[::-1], il[::-1])
|
||||
compare_containers(ps[6::-1], iv[6::-1], il[6::-1])
|
||||
compare_containers(ps[:-3:-1], iv[:-3:-1], il[:-3:-1])
|
||||
compare_containers(ps[:-6:-1], iv[:-6:-1], il[:-6:-1])
|
||||
compare_containers(ps[:-7:-1], iv[:-7:-1], il[:-7:-1])
|
||||
compare_containers(ps[:-8:-1], iv[:-8:-1], il[:-8:-1])
|
||||
compare_containers(ps[:-100:-1], iv[:-100:-1], il[:-100:-1])
|
||||
compare_containers(ps[4:6:-1], iv[4:6:-1], il[4:6:-1])
|
||||
compare_containers(ps[4:5:-1], iv[4:5:-1], il[4:5:-1])
|
||||
compare_containers(ps[4:4:-1], iv[4:4:-1], il[4:4:-1])
|
||||
compare_containers(ps[4:3:-1], iv[4:3:-1], il[4:3:-1])
|
||||
compare_containers(ps[4:2:-1], iv[4:2:-1], il[4:2:-1])
|
||||
compare_containers(ps[100:104:-1], iv[100:104:-1], il[100:104:-1])
|
||||
compare_containers(ps[104:100:-1], iv[104:100:-1], il[104:100:-1])
|
||||
compare_containers(ps[-100:-104:-1], iv[-100:-104:-1], il[-100:-104:-1])
|
||||
compare_containers(ps[-104:-100:-1], iv[-104:-100:-1], il[-104:-100:-1])
|
||||
compare_containers(ps[::-2], iv[::-2], il[::-2])
|
||||
compare_containers(ps[::-3], iv[::-3], il[::-3])
|
||||
compare_containers(ps[::-4], iv[::-4], il[::-4])
|
||||
compare_containers(ps[::-5], iv[::-5], il[::-5])
|
||||
|
||||
|
||||
# insert sequences (growing, shrinking and staying same size)
|
||||
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||
# single element set/replace
|
||||
container_insert_step(start, None, None, 111)
|
||||
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666, 777])
|
||||
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666])
|
||||
container_insert_step(start, end, None, [111, 222, 333, 444, 555])
|
||||
container_insert_step(start, end, None, [111, 222, 333, 444])
|
||||
container_insert_step(start, end, None, [111, 222, 333])
|
||||
container_insert_step(start, end, None, [111, 222])
|
||||
container_insert_step(start, end, None, [111])
|
||||
container_insert_step(start, end, None, [])
|
||||
|
||||
# delete sequences (growing, shrinking and staying same size)
|
||||
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||
# single element delete
|
||||
container_delete_step(start, None, None)
|
||||
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||
container_delete_step(start, end, None)
|
||||
for step in range(-7,7):
|
||||
container_delete_step(start, end, step)
|
||||
|
||||
ps = range(6)
|
||||
iv = vector_int(ps)
|
||||
il = list_int(ps)
|
||||
del ps[:]; del iv[:]; del il[:]
|
||||
compare_containers(ps, iv, il)
|
||||
|
||||
for end in range(7):
|
||||
for step in range(-7,7):
|
||||
for start in range(7):
|
||||
container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777])
|
||||
container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666])
|
||||
container_insert_step(start, end, step, [111, 222, 333, 444, 555])
|
||||
container_insert_step(start, end, step, [111, 222, 333, 444])
|
||||
container_insert_step(start, end, step, [111, 222, 333])
|
||||
container_insert_step(start, end, step, [111, 222])
|
||||
container_insert_step(start, end, step, [111])
|
||||
container_insert_step(start, end, step, [])
|
||||
|
||||
try:
|
||||
x = iv[::0]
|
||||
raise RuntimeError("Zero step not caught")
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
4
Examples/test-suite/python/li_std_vector_runme.py
Normal file
4
Examples/test-suite/python/li_std_vector_runme.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from li_std_vector import *
|
||||
|
||||
if typedef_test(101) != 101:
|
||||
raise RuntimeError
|
||||
|
|
@ -10,14 +10,14 @@ b2 = B.create(a)
|
|||
|
||||
|
||||
if a.ref_count() != 3:
|
||||
print "This program will crash... now"
|
||||
raise RuntimeError("Count = %d" % a.ref_count())
|
||||
|
||||
|
||||
rca = b2.get_rca()
|
||||
b3 = B.create(rca)
|
||||
|
||||
if a.ref_count() != 5:
|
||||
print "This program will crash... now"
|
||||
raise RuntimeError("Count = %d" % a.ref_count())
|
||||
|
||||
|
||||
v = vector_A(2)
|
||||
|
|
@ -27,6 +27,35 @@ v[1] = a
|
|||
x = v[0]
|
||||
del v
|
||||
|
||||
if a.ref_count() != 6:
|
||||
raise RuntimeError("Count = %d" % a.ref_count())
|
||||
|
||||
# Check %newobject
|
||||
b4 = b2.cloner()
|
||||
if b4.ref_count() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
b5 = global_create(a)
|
||||
if b5.ref_count() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
b6 = Factory.create(a)
|
||||
if b6.ref_count() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
b7 = Factory().create2(a)
|
||||
if b7.ref_count() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
if a.ref_count() != 10:
|
||||
raise RuntimeError("Count = %d" % a.ref_count())
|
||||
|
||||
del b4
|
||||
del b5
|
||||
del b6
|
||||
del b7
|
||||
|
||||
if a.ref_count() != 6:
|
||||
raise RuntimeError("Count = %d" % a.ref_count())
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
from template_typemaps_typedef2 import *
|
||||
|
||||
m1 = MultimapIntA()
|
||||
|
||||
dummy_pair = m1.make_dummy_pair()
|
||||
val = m1.typemap_test(dummy_pair).val
|
||||
if val != 1234:
|
||||
raise RuntimeError, "typemaps not working"
|
||||
|
||||
m2 = MultimapAInt()
|
||||
|
||||
# TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up.
|
||||
#dummy_pair = m2.make_dummy_pair()
|
||||
#val = m2.typemap_test(dummy_pair)
|
||||
|
||||
#print val
|
||||
#if val != 4321:
|
||||
# raise RuntimeError, "typemaps not working"
|
||||
|
||||
if typedef_test1(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test1 not working"
|
||||
|
||||
if typedef_test2(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test2 not working"
|
||||
|
||||
if typedef_test3(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test3 not working"
|
||||
|
||||
if typedef_test4(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test4 not working"
|
||||
|
||||
if typedef_test5(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test5 not working"
|
||||
|
||||
if typedef_test6(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test6 not working"
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
from template_typemaps_typedef import *
|
||||
|
||||
m1 = MultimapIntA()
|
||||
|
||||
dummy_pair = m1.make_dummy_pair()
|
||||
val = m1.typemap_test(dummy_pair).val
|
||||
if val != 1234:
|
||||
raise RuntimeError, "typemaps not working"
|
||||
|
||||
m2 = MultimapAInt()
|
||||
|
||||
# TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up.
|
||||
#dummy_pair = m2.make_dummy_pair()
|
||||
#val = m2.typemap_test(dummy_pair)
|
||||
|
||||
#print val
|
||||
#if val != 4321:
|
||||
# raise RuntimeError, "typemaps not working"
|
||||
|
||||
if typedef_test1(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test1 not working"
|
||||
|
||||
if typedef_test2(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test2 not working"
|
||||
|
||||
if typedef_test3(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test3 not working"
|
||||
|
||||
if typedef_test4(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test4 not working"
|
||||
|
||||
if typedef_test5(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test5 not working"
|
||||
|
||||
if typedef_test6(dummy_pair).val != 1234:
|
||||
raise RuntimeError, "typedef_test6 not working"
|
||||
|
||||
|
|
@ -5,8 +5,8 @@ b = typename.Bar()
|
|||
|
||||
x = typename.twoFoo(f)
|
||||
if not isinstance(x,types.FloatType):
|
||||
print "Wrong return type!"
|
||||
raise RuntimeError,"Wrong return type (FloatType) !"
|
||||
y = typename.twoBar(b)
|
||||
if not isinstance(y,types.IntType):
|
||||
print "Wrong return type!"
|
||||
raise RuntimeError,"Wrong return type (IntType)!"
|
||||
|
||||
|
|
|
|||
18
Examples/test-suite/python_director.i
Normal file
18
Examples/test-suite/python_director.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
%module(directors="1") python_director
|
||||
|
||||
%feature("director");
|
||||
%inline %{
|
||||
class IFactoryFuncs {
|
||||
public:
|
||||
IFactoryFuncs() {}
|
||||
virtual ~IFactoryFuncs() {}
|
||||
|
||||
virtual PyObject * process(PyObject *pyobj) {
|
||||
return pyobj;
|
||||
}
|
||||
|
||||
void process_again(const PyObject *& pyobj) {
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
13
Examples/test-suite/redefined_not.i
Normal file
13
Examples/test-suite/redefined_not.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module redefined_not
|
||||
|
||||
// These should not emit an Identifer redefined warning
|
||||
%inline %{
|
||||
typedef unsigned int my_size_t;
|
||||
namespace Std {
|
||||
using ::my_size_t;
|
||||
}
|
||||
using Std::my_size_t;
|
||||
typedef unsigned int my_size_t;
|
||||
using Std::my_size_t;
|
||||
%}
|
||||
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
%}
|
||||
|
||||
//
|
||||
// using the %refobject/%unrefobject directives you can active the
|
||||
// ref. counting for RCObj and all its descendents at once
|
||||
// using the %refobject/%unrefobject directives you can activate the
|
||||
// reference counting for RCObj and all its descendents at once
|
||||
//
|
||||
|
||||
%refobject RCObj "$this->addref();"
|
||||
|
|
@ -18,7 +18,10 @@
|
|||
%include "refcount.h"
|
||||
|
||||
%newobject B::create(A* a);
|
||||
%newobject global_create(A* a);
|
||||
%newobject B::cloner();
|
||||
%newobject Factory::create(A* a);
|
||||
%newobject Factory::create2(A* a);
|
||||
|
||||
|
||||
|
||||
|
|
@ -94,6 +97,22 @@
|
|||
RCPtr<A> _a;
|
||||
};
|
||||
|
||||
class B* global_create(A* a)
|
||||
{
|
||||
return new B(a);
|
||||
}
|
||||
|
||||
struct Factory {
|
||||
static B* create(A* a)
|
||||
{
|
||||
return new B(a);
|
||||
}
|
||||
B* create2(A* a)
|
||||
{
|
||||
return new B(a);
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
#if defined(SWIGPYTHON) || defined(SWIGOCTAVE)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ top_srcdir = @top_srcdir@
|
|||
top_builddir = @top_builddir@
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
kwargs_feature \
|
||||
li_cdata \
|
||||
li_cstring \
|
||||
li_factory \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%module special_variables
|
||||
%module(directors="1") special_variables
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
|
|
@ -88,3 +88,19 @@ namespace SpaceNamespace {
|
|||
|
||||
%template(TemplateABC) SpaceNamespace::Template<SpaceNamespace::ABC>;
|
||||
|
||||
/////////////////////////////////// directors /////////////////////////////////
|
||||
%{
|
||||
void DirectorTest_director_testmethod(int i) {}
|
||||
void DirectorTest_director_testmethodSwigExplicitDirectorTest(int i) {}
|
||||
%}
|
||||
%typemap(directorargout) int i {
|
||||
$symname(99);
|
||||
}
|
||||
%feature("director") DirectorTest;
|
||||
%inline %{
|
||||
void director_testmethod(int i) {}
|
||||
struct DirectorTest {
|
||||
virtual void director_testmethod(int i) {}
|
||||
virtual ~DirectorTest() {}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
77
Examples/test-suite/template_default_class_parms_typedef.i
Normal file
77
Examples/test-suite/template_default_class_parms_typedef.i
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
%module template_default_class_parms_typedef
|
||||
|
||||
// Based on template_default_class_parms testcase but using typedefs in template
|
||||
|
||||
%feature("python:nondynamic");
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct SomeType {};
|
||||
struct AnotherType {};
|
||||
template<typename CC, typename DD = SomeType, typename EE = int> class Bar {
|
||||
public:
|
||||
typedef CC C;
|
||||
typedef DD D;
|
||||
typedef EE E;
|
||||
C CType;
|
||||
D DType;
|
||||
E EType;
|
||||
// Use typedef with no qualifiers
|
||||
Bar(C c, D d, E e) {}
|
||||
C method(C c, D d, E e) { return c; }
|
||||
|
||||
// Use typedef with classname qualifiers
|
||||
Bar(bool, Bar::C c, Bar::D d, Bar::E e) {}
|
||||
Bar::C method_1(Bar::C c, Bar::D d, Bar::E e) { return c; }
|
||||
|
||||
// Use typedef with classname and full template parameter qualifiers
|
||||
Bar(bool, bool, Bar<CC, DD, EE>::C c, Bar<CC, DD, EE>::D d, Bar<CC, DD, EE>::E e) {}
|
||||
Bar<CC, DD, EE>::C method_2(Bar<CC, DD, EE>::C c, Bar<CC, DD, EE>::D d, Bar<CC, DD, EE>::E e) { return c; }
|
||||
|
||||
// Use typedef with namespace and classname and full template parameter qualifiers
|
||||
Bar(bool, bool, bool, Space::Bar<CC, DD, EE>::C c, Space::Bar<CC, DD, EE>::D d, Space::Bar<CC, DD, EE>::E e) {}
|
||||
Space::Bar<CC, DD, EE>::C method_3(Space::Bar<CC, DD, EE>::C c, Space::Bar<CC, DD, EE>::D d, Space::Bar<CC, DD, EE>::E e) { return c; }
|
||||
};
|
||||
template<typename TT = SomeType> class Foo {
|
||||
public:
|
||||
typedef TT T;
|
||||
T TType;
|
||||
|
||||
// Use typedef with no qualifiers
|
||||
Foo(T t) {}
|
||||
T method(T t) { return t; }
|
||||
|
||||
// Use typedef with classname qualifiers
|
||||
Foo(const T &, T t) {}
|
||||
Foo::T method_A(Foo::T t) { return t; }
|
||||
|
||||
// Use typedef with classname and full template parameter qualifiers
|
||||
Foo(const Foo<TT>::T &, const Foo<TT>::T &, Foo<TT>::T t) {}
|
||||
Foo<TT>::T method_B(Foo<TT>::T t) { return t; }
|
||||
|
||||
// Use typedef with namespace and classname and full template parameter qualifiers
|
||||
Foo(const Foo<TT>::T &, const Foo<TT>::T &, const Foo<TT>::T &, Foo<TT>::T t) {}
|
||||
Foo<TT>::T method_C(Foo<TT>::T t) { return t; }
|
||||
};
|
||||
template<typename T = int> class ATemplate {};
|
||||
|
||||
template<typename T> struct UsesBar {
|
||||
void use_A(typename Bar<T>::C, typename Bar<T>::D, typename Bar<T>::E) {}
|
||||
void use_B(const typename Bar<T>::C &, const typename Bar<T>::D &, const typename Bar<T>::E &) {}
|
||||
void use_C(typename Space::Bar<T>::C, typename Space::Bar<T>::D, typename Space::Bar<T>::E) {}
|
||||
void use_D(const typename Space::Bar<T>::C &, const typename Space::Bar<T>::D &, const typename Space::Bar<T>::E &) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
// Use defaults
|
||||
%template(DefaultBar) Space::Bar<double>;
|
||||
%template(DefaultFoo) Space::Foo<>;
|
||||
|
||||
// Don't use all defaults
|
||||
%template(BarAnotherTypeBool) Space::Bar<Space::AnotherType, bool>;
|
||||
%template(FooAnotherType) Space::Foo<Space::AnotherType>;
|
||||
|
||||
%template() Space::ATemplate<>;
|
||||
|
||||
%template(UsesBarDouble) Space::UsesBar<double>;
|
||||
57
Examples/test-suite/template_typedef_class_template.i
Normal file
57
Examples/test-suite/template_typedef_class_template.i
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
%module template_typedef_class_template
|
||||
|
||||
%inline %{
|
||||
namespace Standard {
|
||||
template <class T, class U > struct Pair {
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
// previously these typemaps were erroneously being used as iterator was not correctly scoped in Multimap
|
||||
%typemap(out) Standard::Pair<Standard::iterator, Standard::iterator> "_this_will_not_compile_iterator_"
|
||||
%typemap(out) Standard::Pair<Standard::const_iterator, Standard::const_iterator> "_this_will_not_compile_const_iterator_"
|
||||
|
||||
%{
|
||||
namespace Standard {
|
||||
template<class Key, class T> class Multimap {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator {};
|
||||
class const_iterator {};
|
||||
|
||||
// test usage of a typedef of a nested class in a template
|
||||
Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
|
||||
Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
namespace Standard {
|
||||
template<class Key, class T> class Multimap {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator;
|
||||
class const_iterator;
|
||||
|
||||
// test usage of a typedef of a nested class in a template
|
||||
Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
|
||||
Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
|
||||
};
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
int val;
|
||||
A(int v = 0): val(v) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(PairA) Standard::Pair<int, A*>;
|
||||
%template(MultimapA) Standard::Multimap<int, A*>;
|
||||
|
||||
50
Examples/test-suite/template_typedef_inherit.i
Normal file
50
Examples/test-suite/template_typedef_inherit.i
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
%module template_typedef_virtual
|
||||
|
||||
// Bug 3378145
|
||||
|
||||
%include std_string.i
|
||||
|
||||
%inline %{
|
||||
#include <string> // for std::string
|
||||
|
||||
typedef std::string String;
|
||||
|
||||
namespace Type {
|
||||
template <class T> class TypedInterfaceObject {};
|
||||
|
||||
template <class T> class TypedCollectionInterfaceObject : public TypedInterfaceObject<T> {
|
||||
public:
|
||||
typedef T ImplementationType;
|
||||
typedef typename ImplementationType::ElementType ImplementationElementType;
|
||||
|
||||
/** Method add() appends an element to the collection */
|
||||
void add(const ImplementationElementType & elt) {}
|
||||
};
|
||||
|
||||
template <class T> class PersistentCollection {
|
||||
public:
|
||||
typedef T ElementType;
|
||||
|
||||
/** Method add() appends an element to the collection */
|
||||
inline virtual void add(const T & elt) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%template(StringPersistentCollection) Type::PersistentCollection<String>;
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace Type {
|
||||
class DescriptionImplementation : public PersistentCollection<String> {
|
||||
public:
|
||||
typedef PersistentCollection<String>::ElementType ElementType;
|
||||
DescriptionImplementation() {}
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(DescriptionImplementationTypedInterfaceObject) Type::TypedInterfaceObject<Type::DescriptionImplementation>;
|
||||
%template(DescriptionImplementationTypedCollectionInterfaceObject) Type::TypedCollectionInterfaceObject<Type::DescriptionImplementation>;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
%module template_typemap
|
||||
%module template_typemaps
|
||||
|
||||
|
||||
%typemap(in) Integer1
|
||||
|
|
@ -34,12 +34,12 @@
|
|||
{
|
||||
T val;
|
||||
|
||||
T get_val() const
|
||||
T get_value() const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
void set_val(T v)
|
||||
void set_value(T v)
|
||||
{
|
||||
val = v;
|
||||
}
|
||||
|
|
|
|||
109
Examples/test-suite/template_typemaps_typedef.i
Normal file
109
Examples/test-suite/template_typemaps_typedef.i
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
%module template_typemaps_typedef
|
||||
// Similar to template_typedef_class_template
|
||||
// Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters
|
||||
|
||||
%inline %{
|
||||
namespace Standard {
|
||||
template <class T, class U > struct Pair {
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%{
|
||||
namespace Standard {
|
||||
template<class Key, class T, class J = int> class Multimap {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
mapped_type mm;
|
||||
iterator(mapped_type m = mapped_type()) : mm(m) {}
|
||||
};
|
||||
|
||||
mapped_type typemap_test(Standard::Pair<iterator,iterator> pp) { return pp.second.mm; }
|
||||
Standard::Pair<iterator,iterator>* make_dummy_pair() { return new Standard::Pair<iterator, iterator>(); }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
namespace Standard {
|
||||
template<class Key, class T, class J = int> class Multimap {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
%typemap(in) Standard::Pair<iterator,iterator> "$1 = default_general< Key, T >();"
|
||||
mapped_type typemap_test(Standard::Pair<iterator,iterator> pii1);
|
||||
Standard::Pair<iterator,iterator>* make_dummy_pair();
|
||||
};
|
||||
}
|
||||
|
||||
// specialization
|
||||
namespace Standard {
|
||||
template<> class Multimap<A, int> {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
// Note uses a different function to the non-specialized version
|
||||
%typemap(in) Standard::Pair<iterator,iterator> "$1 = default_A_int< A, int >();"
|
||||
mapped_type typemap_test(Standard::Pair<iterator,iterator> pii2);
|
||||
Standard::Pair<iterator,iterator>* make_dummy_pair();
|
||||
};
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
int val;
|
||||
A(int v = 0): val(v) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
// For < int, A >
|
||||
template<typename Key, typename T> Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_general() {
|
||||
Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value;
|
||||
default_value.second.mm = A(1234);
|
||||
return default_value;
|
||||
}
|
||||
// For < A, int >
|
||||
template<typename Key, typename T> Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_A_int() {
|
||||
Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value;
|
||||
default_value.second.mm = 4321;
|
||||
return default_value;
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef A AA;
|
||||
namespace Space {
|
||||
typedef AA AB;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(PairIntA) Standard::Pair<int, A>;
|
||||
%template(MultimapIntA) Standard::Multimap<int, A>;
|
||||
|
||||
%template(PairAInt) Standard::Pair<A, int>;
|
||||
%template(MultimapAInt) Standard::Multimap<A, int>;
|
||||
|
||||
%inline %{
|
||||
|
||||
// Extend the test with some typedefs in the template parameters
|
||||
Standard::Multimap< int, AA >::mapped_type typedef_test1(Standard::Pair< Standard::Multimap< int, AA >::iterator, Standard::Multimap< int, AA >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, A >::mapped_type typedef_test2(Standard::Pair< Standard::Multimap< int, A >::iterator, Standard::Multimap< int, A >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, AA, int >::mapped_type typedef_test3(Standard::Pair< Standard::Multimap< int, AA, int >::iterator, Standard::Multimap< int, AA, int >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, A , int >::mapped_type typedef_test4(Standard::Pair< Standard::Multimap< int, A , int >::iterator, Standard::Multimap< int, A , int >::iterator > pp) { return pp.second.mm; }
|
||||
using namespace Space;
|
||||
Standard::Multimap< int, AB >::mapped_type typedef_test5(Standard::Pair< Standard::Multimap< int, AB >::iterator, Standard::Multimap< int, AB >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, AB, int >::mapped_type typedef_test6(Standard::Pair< Standard::Multimap< int, AB, int >::iterator, Standard::Multimap< int, AB, int >::iterator > pp) { return pp.second.mm; }
|
||||
%}
|
||||
|
||||
111
Examples/test-suite/template_typemaps_typedef2.i
Normal file
111
Examples/test-suite/template_typemaps_typedef2.i
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
%module template_typemaps_typedef2
|
||||
// Identical to template_typemaps_typedef, except for %template
|
||||
|
||||
// Similar to template_typedef_class_template
|
||||
// Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters
|
||||
|
||||
%inline %{
|
||||
namespace Standard {
|
||||
template <class T, class U > struct Pair {
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%{
|
||||
namespace Standard {
|
||||
template<class Key, class T, class J = int> class Multimap {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
mapped_type mm;
|
||||
iterator(mapped_type m = mapped_type()) : mm(m) {}
|
||||
};
|
||||
|
||||
mapped_type typemap_test(Standard::Pair<iterator,iterator> pp) { return pp.second.mm; }
|
||||
Standard::Pair<iterator,iterator>* make_dummy_pair() { return new Standard::Pair<iterator, iterator>(); }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
namespace Standard {
|
||||
template<class Key, class T, class J = int> class Multimap {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
%typemap(in) Standard::Pair<iterator,iterator> "$1 = default_general< Key, T >();"
|
||||
mapped_type typemap_test(Standard::Pair<iterator,iterator> pii1);
|
||||
Standard::Pair<iterator,iterator>* make_dummy_pair();
|
||||
};
|
||||
}
|
||||
|
||||
// specialization
|
||||
namespace Standard {
|
||||
template<> class Multimap<A, int> {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
// Note uses a different function to the non-specialized version
|
||||
%typemap(in) Standard::Pair<iterator,iterator> "$1 = default_A_int< A, int >();"
|
||||
mapped_type typemap_test(Standard::Pair<iterator,iterator> pii2);
|
||||
Standard::Pair<iterator,iterator>* make_dummy_pair();
|
||||
};
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
int val;
|
||||
A(int v = 0): val(v) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
// For < int, A >
|
||||
template<typename Key, typename T> Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_general() {
|
||||
Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value;
|
||||
default_value.second.mm = A(1234);
|
||||
return default_value;
|
||||
}
|
||||
// For < A, int >
|
||||
template<typename Key, typename T> Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_A_int() {
|
||||
Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value;
|
||||
default_value.second.mm = 4321;
|
||||
return default_value;
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef A AA;
|
||||
namespace Space {
|
||||
typedef AA AB;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(PairIntA) Standard::Pair<int, Space::AB>;
|
||||
%template(MultimapIntA) Standard::Multimap<int, Space::AB>;
|
||||
|
||||
%template(PairAInt) Standard::Pair<Space::AB, int>;
|
||||
%template(MultimapAInt) Standard::Multimap<Space::AB, int>;
|
||||
|
||||
%inline %{
|
||||
|
||||
// Extend the test with some typedefs in the template parameters
|
||||
Standard::Multimap< int, AA >::mapped_type typedef_test1(Standard::Pair< Standard::Multimap< int, AA >::iterator, Standard::Multimap< int, AA >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, A >::mapped_type typedef_test2(Standard::Pair< Standard::Multimap< int, A >::iterator, Standard::Multimap< int, A >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, AA, int >::mapped_type typedef_test3(Standard::Pair< Standard::Multimap< int, AA, int >::iterator, Standard::Multimap< int, AA, int >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, A , int >::mapped_type typedef_test4(Standard::Pair< Standard::Multimap< int, A , int >::iterator, Standard::Multimap< int, A , int >::iterator > pp) { return pp.second.mm; }
|
||||
using namespace Space;
|
||||
Standard::Multimap< int, AB >::mapped_type typedef_test5(Standard::Pair< Standard::Multimap< int, AB >::iterator, Standard::Multimap< int, AB >::iterator > pp) { return pp.second.mm; }
|
||||
Standard::Multimap< int, AB, int >::mapped_type typedef_test6(Standard::Pair< Standard::Multimap< int, AB, int >::iterator, Standard::Multimap< int, AB, int >::iterator > pp) { return pp.second.mm; }
|
||||
%}
|
||||
|
||||
|
|
@ -13,4 +13,20 @@ class B
|
|||
typedef RealA A2;
|
||||
int testA (const A2& a) {return a.a;}
|
||||
};
|
||||
|
||||
namespace Space {
|
||||
typedef class AAA {
|
||||
public:
|
||||
AAA() {}
|
||||
} BBB;
|
||||
}
|
||||
|
||||
typedef class AA {
|
||||
public:
|
||||
AA() {}
|
||||
AA(int x) {}
|
||||
int aa_var;
|
||||
int *aa_method(double d) { return 0; }
|
||||
static int *aa_static_method(bool b) { return 0; }
|
||||
} BB;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -41,3 +41,14 @@ B_t make_b() {
|
|||
return make_a();
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
typedef struct _Foo {
|
||||
enum { NONAME1, NONAME2 } enumvar;
|
||||
int foovar;
|
||||
void (*fptr)(int);
|
||||
} Foo;
|
||||
|
||||
%}
|
||||
|
|
|
|||
20
Examples/test-suite/typemap_manyargs.i
Normal file
20
Examples/test-suite/typemap_manyargs.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module typemap_manyargs
|
||||
|
||||
%typemap(in,numinputs=0) (int* a1, int* a2, int* a3, int* a4, int* a5, int* a6, int *a7, int *a8, int *a9, int *a10) (int temp1,int temp2,int temp3,int temp4,int temp5,int temp6,int temp7,int temp8, int temp9, int temp10)
|
||||
{
|
||||
$1 = &temp1; // the code generate for this is arg2 = &temp1;
|
||||
$2 = &temp2; // the code generate for this is arg3 = &temp2;
|
||||
$3 = &temp3; // and so on...
|
||||
$4 = &temp4;
|
||||
$5 = &temp5;
|
||||
$6 = &temp6;
|
||||
$7 = &temp7;
|
||||
$8 = &temp8;
|
||||
$9 = &temp9;
|
||||
$10 = &temp10; // the code generated for this was arg20 = &temp10; and arg20 does not exist.
|
||||
int $10_ptr = 0; // Was arg20_ptr
|
||||
}
|
||||
|
||||
%inline %{
|
||||
void my_c_function(char * filename,int* a1, int* a2, int* a3, int* a4, int* a5, int* a6, int *a7, int *a8, int *a9, int *a10) {}
|
||||
%}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
/* Test bug in 1.3.40 where the presence of a generic/unspecialized typemap caused the incorrect specialized typemap to be used */
|
||||
|
||||
%typemap(in) SWIGTYPE "/*_this_will_not_compile_SWIGTYPE_ \"$type\" */ "
|
||||
%typemap(in) const SWIGTYPE & "/*_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" */ "
|
||||
%typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_ \"$type\" "
|
||||
%typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" "
|
||||
|
||||
%typemap(in) const TemplateTest1 & {$1 = (TemplateTest1<YY> *)0; /* in typemap generic for $type */}
|
||||
%typemap(in) const TemplateTest1< ZZ > & {$1 = (TemplateTest1<ZZ> *)0; /* in typemap ZZ for $type */}
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
%inline %{
|
||||
template<typename T> struct TemplateTest1 {
|
||||
void setT(const TemplateTest1& t) {}
|
||||
typedef double Double;
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -32,3 +33,8 @@ template<typename T> struct TemplateTest1 {
|
|||
{}
|
||||
%}
|
||||
|
||||
%typemap(in) TemplateTest1 "_this_will_not_compile_TemplateTest_ \"$type\" "
|
||||
|
||||
%inline %{
|
||||
void wasbug(TemplateTest1< int >::Double wbug) {}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -55,3 +55,20 @@ void foo2(Foo<short> f, const Foo<short>& ff) {}
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
// Test obscure bug where named typemaps where not being applied when symbol name contained a number
|
||||
%typemap(out) double "_typemap_for_double_no_compile_"
|
||||
%typemap(out) double ABC::meth "$1 = 0.0;"
|
||||
%typemap(out) double ABC::m1 "$1 = 0.0;"
|
||||
%typemap(out) double ABC::_x2 "$1 = 0.0;"
|
||||
%typemap(out) double ABC::y_ "$1 = 0.0;"
|
||||
%typemap(out) double ABC::_3 "$1 = 0.0;"
|
||||
%inline %{
|
||||
struct ABC {
|
||||
double meth() {}
|
||||
double m1() {}
|
||||
double _x2() {}
|
||||
double y_() {}
|
||||
double _3() {}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue