Merge remote-tracking branch 'origin/master' into gsoc2012-scilab
Conflicts: Examples/Makefile.in
This commit is contained in:
commit
21e17eaa73
795 changed files with 16905 additions and 11792 deletions
|
|
@ -40,3 +40,13 @@ is an error in which case stderr is suggested.
|
|||
Please set the name of the module to the same name as the testcase,
|
||||
otherwise modules will not be found.
|
||||
|
||||
There is a special directory called testdir for testcases requiring
|
||||
inputs from subdirectories or multiple directories. See the
|
||||
testdir/README file.
|
||||
|
||||
Further Documentation
|
||||
---------------------
|
||||
|
||||
There is documentation about the test-suite and how to use use it in
|
||||
the SWIG documentation - Doc/Manual/Extending.html#Extending_test_suite.
|
||||
|
||||
|
|
|
|||
27
Examples/test-suite/allprotected_not.i
Normal file
27
Examples/test-suite/allprotected_not.i
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Tests directors and allprotected option when the class does not have the "director" feature
|
||||
// Was previously crashing and/or generating uncompilable code.
|
||||
|
||||
%module(directors="1", allprotected="1") allprotected_not
|
||||
|
||||
//%feature("director") AllProtectedNot;
|
||||
%feature("director") AllProtectedNot::ProtectedMethod;
|
||||
%feature("director") AllProtectedNot::StaticNonVirtualProtectedMethod;
|
||||
%feature("director") AllProtectedNot::NonVirtualProtectedMethod;
|
||||
%feature("director") AllProtectedNot::ProtectedVariable;
|
||||
%feature("director") AllProtectedNot::StaticProtectedVariable;
|
||||
%feature("director") AllProtectedNot::PublicMethod;
|
||||
|
||||
%inline %{
|
||||
class AllProtectedNot {
|
||||
public:
|
||||
virtual ~AllProtectedNot() {}
|
||||
virtual void PublicMethod() {}
|
||||
protected:
|
||||
virtual void ProtectedMethod() {}
|
||||
static void StaticNonVirtualProtectedMethod() {}
|
||||
void NonVirtualProtectedMethod() {}
|
||||
int ProtectedVariable;
|
||||
static int StaticProtectedVariable;
|
||||
};
|
||||
int AllProtectedNot::StaticProtectedVariable = 0;
|
||||
%}
|
||||
|
|
@ -61,7 +61,6 @@ char* test_b(name a, const namea b) {
|
|||
return a;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int test_a(int a) {
|
||||
return a;
|
||||
}
|
||||
|
|
@ -70,7 +69,6 @@ int test_b(int a) {
|
|||
return a;
|
||||
}
|
||||
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ CPP_TEST_CASES =
|
|||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra cffi code)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
See ../README for common README file.
|
||||
|
||||
Any testcases which have _runme.ss appended after the testcase name will be detected and run.
|
||||
NOTE: I had to use _runme.ss becuase otherwise it would be hard to implement make clean
|
||||
NOTE: I had to use _runme.ss because otherwise it would be hard to implement make clean
|
||||
Since when SWIG runs it generates an example.scm file for every test, to clean those files
|
||||
I needed to add a rm -f *.scm to make clean. But we don't want the runme scripts to
|
||||
dissappear as well!
|
||||
disappear as well!
|
||||
|
||||
Any testcases which have _runme_proxy.ss appended after the testcase name will be detected
|
||||
and run with the -proxy argument passed to SWIG. SWIG will not be run with the -unhide-primitive
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <ext_test_wrap_hdr.h>
|
||||
#include <chicken/chicken_ext_test_wrap_hdr.h>
|
||||
#include <imports_a.h>
|
||||
|
||||
void test_create(C_word,C_word,C_word) C_noret;
|
||||
|
|
@ -7,16 +7,15 @@ void test_create(C_word argc, C_word closure, C_word continuation) {
|
|||
swig_type_info *type;
|
||||
A *newobj;
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
|
||||
|
||||
C_trace("test-create");
|
||||
if (argc!=2) C_bad_argc(argc,2);
|
||||
|
||||
|
||||
newobj = new A();
|
||||
|
||||
|
||||
type = SWIG_TypeQuery("A *");
|
||||
resultobj = SWIG_NewPointerObj(newobj, type, 1);
|
||||
|
||||
C_kontinue(continuation, resultobj);
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ CPP_TEST_CASES =
|
|||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra clisp code)
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ CPP_TEST_CASES += \
|
|||
aggregate \
|
||||
allowexcept \
|
||||
allprotected \
|
||||
allprotected_not \
|
||||
anonymous_bitfield \
|
||||
apply_signed_char \
|
||||
apply_strings \
|
||||
|
|
@ -151,6 +152,7 @@ CPP_TEST_CASES += \
|
|||
cpp_nodefault \
|
||||
cpp_static \
|
||||
cpp_typedef \
|
||||
curiously_recurring_template_pattern \
|
||||
default_args \
|
||||
default_arg_values \
|
||||
default_constructor \
|
||||
|
|
@ -176,12 +178,15 @@ CPP_TEST_CASES += \
|
|||
director_keywords \
|
||||
director_namespace_clash \
|
||||
director_nspace \
|
||||
director_nspace_director_name_collision \
|
||||
director_nested \
|
||||
director_overload \
|
||||
director_overload2 \
|
||||
director_primitives \
|
||||
director_protected \
|
||||
director_protected_overloaded \
|
||||
director_redefined \
|
||||
director_smartptr \
|
||||
director_thread \
|
||||
director_unroll \
|
||||
director_using \
|
||||
|
|
@ -202,6 +207,7 @@ CPP_TEST_CASES += \
|
|||
extend_constructor_destructor \
|
||||
extend_default \
|
||||
extend_placement \
|
||||
extend_special_variables \
|
||||
extend_template \
|
||||
extend_template_ns \
|
||||
extend_typedef_class \
|
||||
|
|
@ -228,10 +234,11 @@ CPP_TEST_CASES += \
|
|||
inherit_void_arg \
|
||||
inline_initializer \
|
||||
insert_directive \
|
||||
keyword_rename \
|
||||
keyword_rename \
|
||||
kind \
|
||||
langobj \
|
||||
li_attribute \
|
||||
li_attribute_template \
|
||||
li_boost_shared_ptr \
|
||||
li_boost_shared_ptr_bits \
|
||||
li_boost_shared_ptr_template \
|
||||
|
|
@ -256,6 +263,7 @@ CPP_TEST_CASES += \
|
|||
namespace_class \
|
||||
namespace_enum \
|
||||
namespace_extend \
|
||||
namespace_forward_declaration \
|
||||
namespace_nested \
|
||||
namespace_spaces \
|
||||
namespace_template \
|
||||
|
|
@ -274,7 +282,7 @@ CPP_TEST_CASES += \
|
|||
operator_overload \
|
||||
operator_overload_break \
|
||||
operator_pointer_ref \
|
||||
operbool \
|
||||
operbool \
|
||||
ordering \
|
||||
overload_copy \
|
||||
overload_method \
|
||||
|
|
@ -350,6 +358,7 @@ CPP_TEST_CASES += \
|
|||
template_default \
|
||||
template_default2 \
|
||||
template_default_arg \
|
||||
template_default_arg_virtual_destructor \
|
||||
template_default_class_parms \
|
||||
template_default_class_parms_typedef \
|
||||
template_default_inherit \
|
||||
|
|
@ -368,6 +377,8 @@ CPP_TEST_CASES += \
|
|||
template_inherit_abstract \
|
||||
template_int_const \
|
||||
template_methods \
|
||||
template_namespace_forward_declaration \
|
||||
template_using_directive_and_declaration_forward \
|
||||
template_nested \
|
||||
template_nested_typemaps \
|
||||
template_ns \
|
||||
|
|
@ -423,13 +434,16 @@ CPP_TEST_CASES += \
|
|||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_arrays \
|
||||
typemap_array_qualifiers \
|
||||
typemap_delete \
|
||||
typemap_directorout \
|
||||
typemap_global_scope \
|
||||
typemap_manyargs \
|
||||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
typemap_numinputs \
|
||||
typemap_template \
|
||||
typemap_template_parm_typedef \
|
||||
typemap_out_optimal \
|
||||
typemap_qualifier_strip \
|
||||
typemap_variables \
|
||||
|
|
@ -440,6 +454,8 @@ CPP_TEST_CASES += \
|
|||
using1 \
|
||||
using2 \
|
||||
using_composition \
|
||||
using_directive_and_declaration \
|
||||
using_directive_and_declaration_forward \
|
||||
using_extend \
|
||||
using_inherit \
|
||||
using_namespace \
|
||||
|
|
@ -469,11 +485,14 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_combinations \
|
||||
li_std_deque \
|
||||
li_std_except \
|
||||
li_std_except_as_class \
|
||||
li_std_map \
|
||||
li_std_pair \
|
||||
li_std_pair \
|
||||
li_std_pair_using \
|
||||
li_std_string \
|
||||
li_std_vector \
|
||||
li_std_vector_enum \
|
||||
li_std_vector_member_var\
|
||||
naturalvar \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
|
|
@ -495,13 +514,15 @@ C_TEST_CASES += \
|
|||
constant_expr \
|
||||
empty \
|
||||
enums \
|
||||
enum_forward \
|
||||
enum_macro \
|
||||
extern_declaration \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
immutable_values \
|
||||
inctest \
|
||||
integers \
|
||||
keyword_rename \
|
||||
keyword_rename \
|
||||
lextype \
|
||||
li_carrays \
|
||||
li_cdata \
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ run_testcase = \
|
|||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) $*_runme.exe; \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) ./$*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
|
|
|
|||
|
|
@ -5,6 +5,22 @@ using csharp_prepostNamespace;
|
|||
|
||||
public class csharp_prepost_runme {
|
||||
|
||||
class PrePost3_Derived : PrePost3
|
||||
{
|
||||
public PrePost3_Derived(){}
|
||||
public override void method(ref double[] vpre, DoubleVector vpost)
|
||||
{
|
||||
Assert(vpre[0], 1.0);
|
||||
vpre[0] = 2.0;
|
||||
Assert(vpost.Count, 2);
|
||||
vpost.Add(1.0);
|
||||
}
|
||||
public override int methodint(ref double[] vpre, DoubleVector vpost)
|
||||
{
|
||||
method(ref vpre, vpost);
|
||||
return vpost.Count;
|
||||
}
|
||||
}
|
||||
public static void Main() {
|
||||
{
|
||||
double[] v;
|
||||
|
|
@ -37,6 +53,28 @@ public class csharp_prepost_runme {
|
|||
Assert(v[1], 8.8);
|
||||
}
|
||||
|
||||
{
|
||||
PrePost3_Derived p = new PrePost3_Derived();
|
||||
double[] vpre = new double[] { 1.0 };
|
||||
DoubleVector vpost = new DoubleVector();
|
||||
vpost.Add(3.0);
|
||||
vpost.Add(4.0);
|
||||
p.method(ref vpre, vpost);
|
||||
Assert(vpre[0], 2.0);
|
||||
Assert(vpost.Count, 3);
|
||||
}
|
||||
{
|
||||
PrePost3_Derived p = new PrePost3_Derived();
|
||||
double[] vpre = new double[] { 1.0 };
|
||||
DoubleVector vpost = new DoubleVector();
|
||||
vpost.Add(3.0);
|
||||
vpost.Add(4.0);
|
||||
int size = p.methodint(ref vpre, vpost);
|
||||
Assert(vpre[0], 2.0);
|
||||
Assert(vpost.Count, 3);
|
||||
Assert(size, 3);
|
||||
}
|
||||
|
||||
// Check attributes are generated for the constructor helper function
|
||||
{
|
||||
CsinAttributes c = new CsinAttributes(5);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public class bools_runme {
|
|||
}
|
||||
}
|
||||
|
||||
class director_nspace_MyBarFoo : director_nspaceNamespace.Bar.Foo {
|
||||
class director_nspace_MyBarFoo : director_nspaceNamespace.TopLevel.Bar.Foo {
|
||||
|
||||
public override String ping() {
|
||||
return "director_nspace_MyBarFoo.ping();";
|
||||
|
|
@ -18,15 +18,15 @@ class director_nspace_MyBarFoo : director_nspaceNamespace.Bar.Foo {
|
|||
return "director_nspace_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
public override String fooBar(director_nspaceNamespace.Bar.FooBar fooBar) {
|
||||
public override String fooBar(director_nspaceNamespace.TopLevel.Bar.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
public override director_nspaceNamespace.Bar.Foo makeFoo() {
|
||||
return new director_nspaceNamespace.Bar.Foo();
|
||||
public override director_nspaceNamespace.TopLevel.Bar.Foo makeFoo() {
|
||||
return new director_nspaceNamespace.TopLevel.Bar.Foo();
|
||||
}
|
||||
|
||||
public override director_nspaceNamespace.Bar.FooBar makeFooBar() {
|
||||
return new director_nspaceNamespace.Bar.FooBar();
|
||||
public override director_nspaceNamespace.TopLevel.Bar.FooBar makeFooBar() {
|
||||
return new director_nspaceNamespace.TopLevel.Bar.FooBar();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
41
Examples/test-suite/csharp/director_smartptr_runme.cs
Normal file
41
Examples/test-suite/csharp/director_smartptr_runme.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using director_smartptrNamespace;
|
||||
|
||||
public class runme
|
||||
{
|
||||
|
||||
private class director_smartptr_MyBarFoo : Foo
|
||||
{
|
||||
public override string ping()
|
||||
{
|
||||
return "director_smartptr_MyBarFoo.ping();";
|
||||
}
|
||||
|
||||
public override string pong()
|
||||
{
|
||||
return "director_smartptr_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
public override string fooBar(FooBar fooBar)
|
||||
{
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
public override Foo makeFoo()
|
||||
{
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public override FooBar makeFooBar()
|
||||
{
|
||||
return new FooBar();
|
||||
}
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
director_smartptr_MyBarFoo myBarFoo =
|
||||
new director_smartptr_MyBarFoo();
|
||||
|
||||
myBarFoo.ping();
|
||||
}
|
||||
}
|
||||
16
Examples/test-suite/csharp/enum_forward_runme.cs
Normal file
16
Examples/test-suite/csharp/enum_forward_runme.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using enum_forwardNamespace;
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
ForwardEnum1 f1 = enum_forward.get_enum1();
|
||||
f1 = enum_forward.test_function1(f1);
|
||||
|
||||
ForwardEnum2 f2 = enum_forward.get_enum2();
|
||||
f2 = enum_forward.test_function2(f2);
|
||||
|
||||
ForwardEnum3 f3 = enum_forward.get_enum3();
|
||||
f3 = enum_forward.test_function3(f3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,246 +1,246 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* li_std_map_runme.cs
|
||||
*
|
||||
* SWIG C# tester for std_map.i
|
||||
* This class tests all the functionality of the std_map.i wrapper.
|
||||
* Upon successful testing, the main function doesn't print out anything.
|
||||
* If any error is found - it will be printed on the screen.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using li_std_mapNamespace;
|
||||
|
||||
public class li_std_map_runme {
|
||||
|
||||
private static readonly int collectionSize = 20;
|
||||
private static readonly int midCollection = collectionSize / 2;
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
// Set up an int int map
|
||||
StringIntMap simap = new StringIntMap();
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
int val = i * 18;
|
||||
simap.Add(i.ToString(), val);
|
||||
}
|
||||
|
||||
// Count property test
|
||||
if (simap.Count != collectionSize)
|
||||
throw new Exception("Count test failed");
|
||||
|
||||
// IsReadOnly property test
|
||||
if (simap.IsReadOnly)
|
||||
throw new Exception("IsReadOnly test failed");
|
||||
|
||||
// Item indexing test
|
||||
simap["0"] = 200;
|
||||
if (simap["0"] != 200)
|
||||
throw new Exception("Item property test failed");
|
||||
simap["0"] = 0 * 18;
|
||||
|
||||
// ContainsKey() test
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!simap.ContainsKey(i.ToString()))
|
||||
throw new Exception("ContainsKey test " + i + " failed");
|
||||
}
|
||||
|
||||
// ContainsKey() test
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!simap.Contains(new KeyValuePair<string, int>(i.ToString(), i * 18)))
|
||||
throw new Exception("Contains test " + i + " failed");
|
||||
}
|
||||
|
||||
// TryGetValue() test
|
||||
int value;
|
||||
bool rc = simap.TryGetValue("3", out value);
|
||||
if (rc != true || value != (3 * 18))
|
||||
throw new Exception("TryGetValue test 1 failed");
|
||||
|
||||
rc = simap.TryGetValue("-1", out value);
|
||||
if (rc != false)
|
||||
throw new Exception("TryGetValue test 2 failed");
|
||||
|
||||
// Keys and Values test
|
||||
{
|
||||
IList<string> keys = new List<string>(simap.Keys);
|
||||
IList<int> values = new List<int>(simap.Values);
|
||||
Dictionary<string, int> check = new Dictionary<string, int>();
|
||||
if (keys.Count != collectionSize)
|
||||
throw new Exception("Keys count test failed");
|
||||
|
||||
if (values.Count != collectionSize)
|
||||
throw new Exception("Values count test failed");
|
||||
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
if (simap[keys[i]] != values[i])
|
||||
throw new Exception("Keys and values test failed for index " + i);
|
||||
check.Add(keys[i], values[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!check.ContainsKey(i.ToString()))
|
||||
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
|
||||
}
|
||||
}
|
||||
|
||||
// Add and Remove test
|
||||
for (int i = 100; i < 103; i++)
|
||||
{
|
||||
simap.Add(i.ToString(), i * 18);
|
||||
if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
|
||||
throw new Exception("Add test failed for index " + i);
|
||||
|
||||
simap.Remove(i.ToString());
|
||||
if (simap.ContainsKey(i.ToString()))
|
||||
throw new Exception("Remove test failed for index " + i);
|
||||
}
|
||||
|
||||
for (int i = 200; i < 203; i++)
|
||||
{
|
||||
simap.Add(new KeyValuePair<string, int>(i.ToString(), i * 18));
|
||||
if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
|
||||
throw new Exception("Add explicit test failed for index " + i);
|
||||
|
||||
simap.Remove(new KeyValuePair<string, int>(i.ToString(), i * 18));
|
||||
if (simap.ContainsKey(i.ToString()))
|
||||
throw new Exception("Remove explicit test failed for index " + i);
|
||||
}
|
||||
|
||||
// Duplicate key test
|
||||
try
|
||||
{
|
||||
simap.Add("3", 0);
|
||||
throw new Exception("Adding duplicate key test failed");
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
|
||||
// CopyTo() test
|
||||
{
|
||||
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize];
|
||||
simap.CopyTo(outputarray);
|
||||
foreach (KeyValuePair<string, int> val in outputarray)
|
||||
{
|
||||
if (simap[val.Key] != val.Value)
|
||||
throw new Exception("CopyTo (1) test failed, index:" + val.Key);
|
||||
}
|
||||
}
|
||||
{
|
||||
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[midCollection + collectionSize];
|
||||
simap.CopyTo(outputarray, midCollection);
|
||||
for (int i = midCollection; i < midCollection + collectionSize; i++)
|
||||
{
|
||||
KeyValuePair<string, int> val = outputarray[i];
|
||||
if (simap[val.Key] != val.Value)
|
||||
throw new Exception("CopyTo (2) test failed, index:" + val.Key);
|
||||
}
|
||||
}
|
||||
{
|
||||
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize - 1];
|
||||
try
|
||||
{
|
||||
simap.CopyTo(outputarray);
|
||||
throw new Exception("CopyTo (4) test failed");
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Clear test
|
||||
simap.Clear();
|
||||
if (simap.Count != 0)
|
||||
throw new Exception("Clear test failed");
|
||||
|
||||
// Test wrapped methods
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
simap[i.ToString()] = i;
|
||||
}
|
||||
double avg = li_std_map.valueAverage(simap);
|
||||
if (avg != 3.0)
|
||||
throw new Exception("Wrapped method valueAverage test failed. Got " + avg);
|
||||
|
||||
string keyStringified = li_std_map.stringifyKeys(simap);
|
||||
if (keyStringified != " 1 2 3 4 5")
|
||||
throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
|
||||
|
||||
// Test a map with a new complex type (Struct)
|
||||
{
|
||||
IntStructMap ismap = new IntStructMap();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
ismap.Add(i, new Struct(i * 10.1));
|
||||
}
|
||||
|
||||
if (ismap.Count != 10)
|
||||
throw new Exception("Count test on complex type map failed");
|
||||
|
||||
foreach (KeyValuePair<int, Struct> p in ismap)
|
||||
{
|
||||
if ((p.Key * 10.1) != p.Value.num)
|
||||
throw new Exception("Iteration test on complex type map failed for index " + p.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// Test a map of pointers
|
||||
{
|
||||
IntStructPtrMap ispmap = new IntStructPtrMap();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
ispmap.Add(i, new Struct(i * 10.1));
|
||||
}
|
||||
|
||||
if (ispmap.Count != 10)
|
||||
throw new Exception("Count test on complex type pointer map failed");
|
||||
|
||||
foreach (KeyValuePair<int, Struct> p in ispmap)
|
||||
{
|
||||
if ((p.Key * 10.1) != p.Value.num)
|
||||
throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key);
|
||||
}
|
||||
}
|
||||
{
|
||||
IntStructConstPtrMap iscpmap = new IntStructConstPtrMap();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
iscpmap.Add(i, new Struct(i * 10.1));
|
||||
}
|
||||
|
||||
if (iscpmap.Count != 10)
|
||||
throw new Exception("Count test on complex type const pointer map failed");
|
||||
|
||||
foreach (KeyValuePair<int, Struct> p in iscpmap)
|
||||
{
|
||||
if ((p.Key * 10.1) != p.Value.num)
|
||||
throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// Test complex type as key (Struct)
|
||||
{
|
||||
StructIntMap limap = new StructIntMap();
|
||||
Struct s7 = new Struct(7);
|
||||
Struct s8 = new Struct(8);
|
||||
limap[s7] = 8;
|
||||
if (limap[s7] != 8)
|
||||
throw new Exception("Assignment test on complex key map failed");
|
||||
|
||||
if (!limap.ContainsKey(s7))
|
||||
throw new Exception("Key test (1) on complex key map failed");
|
||||
|
||||
if (limap.ContainsKey(s8))
|
||||
throw new Exception("Key test (2) on complex key map failed");
|
||||
}
|
||||
|
||||
// All done
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* li_std_map_runme.cs
|
||||
*
|
||||
* SWIG C# tester for std_map.i
|
||||
* This class tests all the functionality of the std_map.i wrapper.
|
||||
* Upon successful testing, the main function doesn't print out anything.
|
||||
* If any error is found - it will be printed on the screen.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using li_std_mapNamespace;
|
||||
|
||||
public class li_std_map_runme {
|
||||
|
||||
private static readonly int collectionSize = 20;
|
||||
private static readonly int midCollection = collectionSize / 2;
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
// Set up an int int map
|
||||
StringIntMap simap = new StringIntMap();
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
int val = i * 18;
|
||||
simap.Add(i.ToString(), val);
|
||||
}
|
||||
|
||||
// Count property test
|
||||
if (simap.Count != collectionSize)
|
||||
throw new Exception("Count test failed");
|
||||
|
||||
// IsReadOnly property test
|
||||
if (simap.IsReadOnly)
|
||||
throw new Exception("IsReadOnly test failed");
|
||||
|
||||
// Item indexing test
|
||||
simap["0"] = 200;
|
||||
if (simap["0"] != 200)
|
||||
throw new Exception("Item property test failed");
|
||||
simap["0"] = 0 * 18;
|
||||
|
||||
// ContainsKey() test
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!simap.ContainsKey(i.ToString()))
|
||||
throw new Exception("ContainsKey test " + i + " failed");
|
||||
}
|
||||
|
||||
// ContainsKey() test
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!simap.Contains(new KeyValuePair<string, int>(i.ToString(), i * 18)))
|
||||
throw new Exception("Contains test " + i + " failed");
|
||||
}
|
||||
|
||||
// TryGetValue() test
|
||||
int value;
|
||||
bool rc = simap.TryGetValue("3", out value);
|
||||
if (rc != true || value != (3 * 18))
|
||||
throw new Exception("TryGetValue test 1 failed");
|
||||
|
||||
rc = simap.TryGetValue("-1", out value);
|
||||
if (rc != false)
|
||||
throw new Exception("TryGetValue test 2 failed");
|
||||
|
||||
// Keys and Values test
|
||||
{
|
||||
IList<string> keys = new List<string>(simap.Keys);
|
||||
IList<int> values = new List<int>(simap.Values);
|
||||
Dictionary<string, int> check = new Dictionary<string, int>();
|
||||
if (keys.Count != collectionSize)
|
||||
throw new Exception("Keys count test failed");
|
||||
|
||||
if (values.Count != collectionSize)
|
||||
throw new Exception("Values count test failed");
|
||||
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
if (simap[keys[i]] != values[i])
|
||||
throw new Exception("Keys and values test failed for index " + i);
|
||||
check.Add(keys[i], values[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!check.ContainsKey(i.ToString()))
|
||||
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
|
||||
}
|
||||
}
|
||||
|
||||
// Add and Remove test
|
||||
for (int i = 100; i < 103; i++)
|
||||
{
|
||||
simap.Add(i.ToString(), i * 18);
|
||||
if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
|
||||
throw new Exception("Add test failed for index " + i);
|
||||
|
||||
simap.Remove(i.ToString());
|
||||
if (simap.ContainsKey(i.ToString()))
|
||||
throw new Exception("Remove test failed for index " + i);
|
||||
}
|
||||
|
||||
for (int i = 200; i < 203; i++)
|
||||
{
|
||||
simap.Add(new KeyValuePair<string, int>(i.ToString(), i * 18));
|
||||
if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
|
||||
throw new Exception("Add explicit test failed for index " + i);
|
||||
|
||||
simap.Remove(new KeyValuePair<string, int>(i.ToString(), i * 18));
|
||||
if (simap.ContainsKey(i.ToString()))
|
||||
throw new Exception("Remove explicit test failed for index " + i);
|
||||
}
|
||||
|
||||
// Duplicate key test
|
||||
try
|
||||
{
|
||||
simap.Add("3", 0);
|
||||
throw new Exception("Adding duplicate key test failed");
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
|
||||
// CopyTo() test
|
||||
{
|
||||
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize];
|
||||
simap.CopyTo(outputarray);
|
||||
foreach (KeyValuePair<string, int> val in outputarray)
|
||||
{
|
||||
if (simap[val.Key] != val.Value)
|
||||
throw new Exception("CopyTo (1) test failed, index:" + val.Key);
|
||||
}
|
||||
}
|
||||
{
|
||||
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[midCollection + collectionSize];
|
||||
simap.CopyTo(outputarray, midCollection);
|
||||
for (int i = midCollection; i < midCollection + collectionSize; i++)
|
||||
{
|
||||
KeyValuePair<string, int> val = outputarray[i];
|
||||
if (simap[val.Key] != val.Value)
|
||||
throw new Exception("CopyTo (2) test failed, index:" + val.Key);
|
||||
}
|
||||
}
|
||||
{
|
||||
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize - 1];
|
||||
try
|
||||
{
|
||||
simap.CopyTo(outputarray);
|
||||
throw new Exception("CopyTo (4) test failed");
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Clear test
|
||||
simap.Clear();
|
||||
if (simap.Count != 0)
|
||||
throw new Exception("Clear test failed");
|
||||
|
||||
// Test wrapped methods
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
simap[i.ToString()] = i;
|
||||
}
|
||||
double avg = li_std_map.valueAverage(simap);
|
||||
if (avg != 3.0)
|
||||
throw new Exception("Wrapped method valueAverage test failed. Got " + avg);
|
||||
|
||||
string keyStringified = li_std_map.stringifyKeys(simap);
|
||||
if (keyStringified != " 1 2 3 4 5")
|
||||
throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
|
||||
|
||||
// Test a map with a new complex type (Struct)
|
||||
{
|
||||
IntStructMap ismap = new IntStructMap();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
ismap.Add(i, new Struct(i * 10.1));
|
||||
}
|
||||
|
||||
if (ismap.Count != 10)
|
||||
throw new Exception("Count test on complex type map failed");
|
||||
|
||||
foreach (KeyValuePair<int, Struct> p in ismap)
|
||||
{
|
||||
if ((p.Key * 10.1) != p.Value.num)
|
||||
throw new Exception("Iteration test on complex type map failed for index " + p.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// Test a map of pointers
|
||||
{
|
||||
IntStructPtrMap ispmap = new IntStructPtrMap();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
ispmap.Add(i, new Struct(i * 10.1));
|
||||
}
|
||||
|
||||
if (ispmap.Count != 10)
|
||||
throw new Exception("Count test on complex type pointer map failed");
|
||||
|
||||
foreach (KeyValuePair<int, Struct> p in ispmap)
|
||||
{
|
||||
if ((p.Key * 10.1) != p.Value.num)
|
||||
throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key);
|
||||
}
|
||||
}
|
||||
{
|
||||
IntStructConstPtrMap iscpmap = new IntStructConstPtrMap();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
iscpmap.Add(i, new Struct(i * 10.1));
|
||||
}
|
||||
|
||||
if (iscpmap.Count != 10)
|
||||
throw new Exception("Count test on complex type const pointer map failed");
|
||||
|
||||
foreach (KeyValuePair<int, Struct> p in iscpmap)
|
||||
{
|
||||
if ((p.Key * 10.1) != p.Value.num)
|
||||
throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// Test complex type as key (Struct)
|
||||
{
|
||||
StructIntMap limap = new StructIntMap();
|
||||
Struct s7 = new Struct(7);
|
||||
Struct s8 = new Struct(8);
|
||||
limap[s7] = 8;
|
||||
if (limap[s7] != 8)
|
||||
throw new Exception("Assignment test on complex key map failed");
|
||||
|
||||
if (!limap.ContainsKey(s7))
|
||||
throw new Exception("Key test (1) on complex key map failed");
|
||||
|
||||
if (limap.ContainsKey(s8))
|
||||
throw new Exception("Key test (2) on complex key map failed");
|
||||
}
|
||||
|
||||
// All done
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ public class runme {
|
|||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap")
|
||||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJames(name) != "SWIGTYPE_Name")
|
||||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJim(name) != "multiname num")
|
||||
throw new Exception("test failed");
|
||||
NewName newName = NewName.factory("factoryname");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%module csharp_prepost
|
||||
%module (directors="1") csharp_prepost
|
||||
|
||||
// Test the pre, post, terminate and cshin attributes for csin typemaps
|
||||
|
||||
|
|
@ -64,9 +64,11 @@ bool globalfunction2(std::vector<double> & v, std::vector<double> &v2, std::vect
|
|||
struct PrePost2 {
|
||||
PrePost2() {
|
||||
}
|
||||
virtual ~PrePost2() {
|
||||
}
|
||||
PrePost2(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
|
||||
}
|
||||
bool method(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
|
||||
virtual bool method(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
|
||||
return true;
|
||||
}
|
||||
static bool staticmethod(std::vector<double> & v, std::vector<double> &v2, std::vector<double> & vpre, std::vector<double> & vpost) {
|
||||
|
|
@ -75,6 +77,40 @@ struct PrePost2 {
|
|||
};
|
||||
%}
|
||||
|
||||
// Check csdirectorin pre and post attributes
|
||||
// ref param
|
||||
%typemap(csdirectorin,
|
||||
pre=" DoubleVector d$iminput = new DoubleVector($iminput, false);\n"
|
||||
" int count$iminput = d$iminput.Count;\n"
|
||||
" double[] v$iminput = new double[count$iminput];\n"
|
||||
" for (int i=0; i<count$iminput; ++i) {\n"
|
||||
" v$iminput[i] = d$iminput[i];\n"
|
||||
" }\n",
|
||||
post=" foreach (double d in v$iminput) {\n"
|
||||
" d$iminput.Add(d);\n"
|
||||
" }\n"
|
||||
) std::vector<double> &vpre
|
||||
"ref v$iminput"
|
||||
// post only in csdirectorin typemap
|
||||
%typemap(csdirectorin, post=" DoubleVector d$iminput = new DoubleVector($iminput, false);\n"
|
||||
" int size = d$iminput.Count;\n"
|
||||
" for (int i=0; i<size; ++i) {\n"
|
||||
" d$iminput[i] /= 100;\n"
|
||||
" }") std::vector<double> &vpost
|
||||
"new $csclassname($iminput, false)"
|
||||
|
||||
%feature("director") PrePost3;
|
||||
%inline %{
|
||||
struct PrePost3 {
|
||||
PrePost3() {
|
||||
}
|
||||
virtual ~PrePost3(){}
|
||||
virtual void method(std::vector<double> & vpre, std::vector<double> & vpost) {}
|
||||
virtual int methodint(std::vector<double> & vpre, std::vector<double> & vpost) { return 0; }
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%template(DoubleVector) std::vector<double>;
|
||||
|
||||
// Check attributes in the typemaps
|
||||
|
|
|
|||
|
|
@ -117,3 +117,22 @@ void hoop(WasCrashing was) {}
|
|||
enum BigNumbers { big=0x80000000, bigger };
|
||||
%}
|
||||
|
||||
// Member variable qualification
|
||||
%typemap(cstype) bool "badtype1"
|
||||
%typemap(cstype) bool mvar "badtype2"
|
||||
%typemap(cstype) bool svar "badtype4"
|
||||
%typemap(cstype) bool gvar "badtype5"
|
||||
%typemap(cstype) bool MVar::mvar "bool"
|
||||
%typemap(cstype) bool MVar::svar "bool"
|
||||
%typemap(cstype) bool Glob::gvar "bool"
|
||||
%inline %{
|
||||
struct MVar {
|
||||
bool mvar;
|
||||
static bool svar;
|
||||
};
|
||||
namespace Glob {
|
||||
bool gvar;
|
||||
}
|
||||
bool MVar::svar = false;
|
||||
%}
|
||||
|
||||
|
|
|
|||
55
Examples/test-suite/curiously_recurring_template_pattern.i
Normal file
55
Examples/test-suite/curiously_recurring_template_pattern.i
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
%module curiously_recurring_template_pattern
|
||||
|
||||
// Test Curiously Recurring Template Pattern - CRTP
|
||||
|
||||
%inline %{
|
||||
template <typename T> class Base {
|
||||
int base1Param;
|
||||
int base2Param;
|
||||
public:
|
||||
Base() : base1Param(0) {}
|
||||
int getBase1Param() {
|
||||
return base1Param;
|
||||
}
|
||||
T& setBase1Param(int value) {
|
||||
base1Param = value;
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
int getBase2Param() {
|
||||
return base2Param;
|
||||
}
|
||||
T& setBase2Param(int value) {
|
||||
base2Param = value;
|
||||
return *static_cast<T*>(this);
|
||||
}
|
||||
virtual ~Base() {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(basederived) Base<Derived>;
|
||||
|
||||
%inline %{
|
||||
class Derived : public Base<Derived> {
|
||||
int derived1Param;
|
||||
int derived2Param;
|
||||
public:
|
||||
Derived() : derived1Param(0), derived2Param(0) {}
|
||||
int getDerived1Param() {
|
||||
return derived1Param;
|
||||
}
|
||||
Derived& setDerived1Param(int value) {
|
||||
derived1Param = value;
|
||||
return *this;
|
||||
}
|
||||
int getDerived2Param() {
|
||||
return derived2Param;
|
||||
}
|
||||
Derived& setDerived2Param(int value) {
|
||||
derived2Param = value;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
|
@ -24,6 +24,10 @@ void main() {
|
|||
throw new Exception("test failed");
|
||||
}
|
||||
|
||||
if (testJames(name) != "SWIGTYPE_Name") {
|
||||
throw new Exception("test failed");
|
||||
}
|
||||
|
||||
if (testJim(name) != "multiname num") {
|
||||
throw new Exception("test failed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ void main() {
|
|||
enforce(testJack(name) == "$specialname");
|
||||
enforce(testJill(name) == "jilly");
|
||||
enforce(testMary(name) == "SWIGTYPE_p_NameWrap");
|
||||
enforce(testJames(name) == "SWIGTYPE_Name");
|
||||
enforce(testJim(name) == "multiname num");
|
||||
|
||||
enforce(testJohn(new PairIntBool(10, false)) == 123);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
%module(directors="1") director_basic
|
||||
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
|
||||
%module(directors="1") director_basic
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ class Callback {
|
|||
public:
|
||||
virtual ~Callback() {}
|
||||
virtual void run(char* dataBufferAA, int sizeAA, char* dataBufferBB, int sizeBB) {
|
||||
memset(dataBufferAA, -1, sizeAA);
|
||||
memset(dataBufferBB, -1, sizeBB);
|
||||
if (dataBufferAA)
|
||||
memset(dataBufferAA, -1, sizeAA);
|
||||
if (dataBufferBB)
|
||||
memset(dataBufferBB, -1, sizeBB);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -45,6 +47,9 @@ public:
|
|||
}
|
||||
return sum;
|
||||
}
|
||||
void call_null() {
|
||||
_callback->run(NULL, 0, NULL, 0);
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// Tests classes passed by value, pointer and reference
|
||||
// Note: C# module has a large runtime test
|
||||
|
||||
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr;
|
||||
|
||||
%module(directors="1") director_classes
|
||||
|
||||
|
|
@ -108,3 +109,20 @@ public:
|
|||
|
||||
%}
|
||||
|
||||
|
||||
%feature(director) BaseClass;
|
||||
%feature(director) DerivedClass;
|
||||
|
||||
%inline %{
|
||||
class BaseClass
|
||||
{
|
||||
public:
|
||||
virtual ~BaseClass() {};
|
||||
virtual int dofoo(int& one, int& two, int& three) {return 0;}
|
||||
};
|
||||
|
||||
class DerivedClass : public BaseClass
|
||||
{
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@
|
|||
%ignore ProtectedPureVirtualMethod1;
|
||||
%ignore ProtectedPureVirtualMethod2;
|
||||
|
||||
%typemap(imtype,
|
||||
inattributes="[inattributes should not be used]",
|
||||
outattributes="[outattributes should not be used]",
|
||||
directorinattributes="[directorinattributes should not be used]",
|
||||
directoroutattributes="[directoroutattributes should not be used]"
|
||||
) int& "imtype should not be used"
|
||||
|
||||
%inline %{
|
||||
|
||||
#include <string>
|
||||
|
|
@ -61,21 +68,6 @@ class DAbstractIgnores
|
|||
virtual double OverloadedProtectedMethod() = 0;
|
||||
};
|
||||
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreConstructor() {}
|
||||
DIgnoreConstructor(std::string s, int i) {}
|
||||
DIgnoreConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreOnlyConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreOnlyConstructor() {}
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
|
||||
template <typename T> class DTemplateAbstractIgnores
|
||||
{
|
||||
T t;
|
||||
|
|
@ -94,3 +86,37 @@ template <typename T> class DTemplateAbstractIgnores
|
|||
|
||||
%template(DTemplateAbstractIgnoresInt) DTemplateAbstractIgnores<int>;
|
||||
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreConstructor() {}
|
||||
DIgnoreConstructor(std::string s, int i) {}
|
||||
DIgnoreConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreOnlyConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreOnlyConstructor() {}
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
|
||||
%{
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreConstructor() {}
|
||||
DIgnoreConstructor(std::string s, int i) {}
|
||||
private: // Hide constructor
|
||||
DIgnoreConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreOnlyConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreOnlyConstructor() {}
|
||||
private: // Hide constructor
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,28 +8,31 @@ SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
|||
%{
|
||||
#include <string>
|
||||
|
||||
namespace Bar
|
||||
namespace TopLevel
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar() {}
|
||||
FooBar(const FooBar&) {}
|
||||
virtual ~FooBar() {}
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar() {}
|
||||
FooBar(const FooBar&) {}
|
||||
virtual ~FooBar() {}
|
||||
|
||||
std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
|
||||
};
|
||||
|
||||
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(); }
|
||||
|
||||
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_;}
|
||||
};
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -38,36 +41,39 @@ namespace Bar
|
|||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
%nspace Bar::Foo;
|
||||
%nspace Bar::FooBar;
|
||||
%nspace TopLevel::Bar::Foo;
|
||||
%nspace TopLevel::Bar::FooBar;
|
||||
#else
|
||||
#warning nspace feature not yet supported in this target language
|
||||
#endif
|
||||
|
||||
%feature("director") Bar::Foo;
|
||||
%feature("director") TopLevel::Bar::Foo;
|
||||
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar();
|
||||
FooBar(const FooBar&);
|
||||
virtual ~FooBar();
|
||||
namespace TopLevel
|
||||
{
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar();
|
||||
FooBar(const FooBar&);
|
||||
virtual ~FooBar();
|
||||
|
||||
std::string FooBarDo();
|
||||
|
||||
};
|
||||
|
||||
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_);
|
||||
};
|
||||
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_);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
%module(directors="1") director_nspace_director_name_collision
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
namespace TopLevel
|
||||
{
|
||||
namespace A
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "TopLevel::A::Foo::ping()"; }
|
||||
};
|
||||
}
|
||||
|
||||
namespace B
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "TopLevel::B:Foo::ping()"; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
%nspace TopLevel::A::Foo;
|
||||
%nspace TopLevel::B::Foo;
|
||||
#else
|
||||
#warning nspace feature not yet supported in this target language
|
||||
%ignore TopLevel::B::Foo;
|
||||
#endif
|
||||
|
||||
%feature("director") TopLevel::A::Foo;
|
||||
%feature("director") TopLevel::B::Foo;
|
||||
|
||||
namespace TopLevel
|
||||
{
|
||||
namespace A
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
};
|
||||
}
|
||||
|
||||
namespace B
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
};
|
||||
}
|
||||
}
|
||||
22
Examples/test-suite/director_overload2.i
Normal file
22
Examples/test-suite/director_overload2.i
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
%module(directors="1") director_overload2
|
||||
|
||||
%feature("director");
|
||||
|
||||
|
||||
%inline %{
|
||||
struct OverloadBase {
|
||||
virtual ~OverloadBase() {}
|
||||
virtual void mmm() {}
|
||||
virtual void nnn(int vvv) {}
|
||||
virtual void nnn() {}
|
||||
};
|
||||
struct OverloadDerived1 : OverloadBase {
|
||||
virtual void nnn(int vvv) {}
|
||||
// virtual void nnn() {}
|
||||
};
|
||||
struct OverloadDerived2 : OverloadBase {
|
||||
// virtual void nnn(int vvv) {}
|
||||
virtual void nnn() {}
|
||||
};
|
||||
%}
|
||||
|
||||
72
Examples/test-suite/director_smartptr.i
Normal file
72
Examples/test-suite/director_smartptr.i
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
%module(directors="1") director_smartptr
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <string>
|
||||
|
||||
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 "Foo::ping()"; }
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
virtual std::string fooBar(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
|
||||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
|
||||
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%include <std_string.i>
|
||||
%include <boost_shared_ptr.i>
|
||||
|
||||
%shared_ptr(Foo)
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
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* fooBarPtr);
|
||||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
37
Examples/test-suite/enum_forward.i
Normal file
37
Examples/test-suite/enum_forward.i
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
%module enum_forward
|
||||
|
||||
/* This contains C code that is not valid C++03 and Octave wrappers are always compiled as C++ */
|
||||
#if !defined(SWIGOCTAVE)
|
||||
%{
|
||||
enum ForwardEnum1 { AAA, BBB };
|
||||
enum ForwardEnum2 { CCC, DDD };
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
enum ForwardEnum1;
|
||||
enum ForwardEnum1 get_enum1() { return AAA; }
|
||||
enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
|
||||
return e;
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
enum ForwardEnum2;
|
||||
enum ForwardEnum2;
|
||||
enum ForwardEnum2 get_enum2() { return CCC; }
|
||||
enum ForwardEnum2 test_function2(enum ForwardEnum2 e) {
|
||||
return e;
|
||||
}
|
||||
enum ForwardEnum2;
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
enum ForwardEnum3;
|
||||
enum ForwardEnum3 { EEE, FFF };
|
||||
enum ForwardEnum3 get_enum3() { return EEE; }
|
||||
enum ForwardEnum3 test_function3(enum ForwardEnum3 e) {
|
||||
return e;
|
||||
}
|
||||
enum ForwardEnum3;
|
||||
%}
|
||||
#endif
|
||||
92
Examples/test-suite/enum_macro.i
Normal file
92
Examples/test-suite/enum_macro.i
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
%module enum_macro
|
||||
|
||||
%inline %{
|
||||
enum Greeks1
|
||||
{
|
||||
#define GREEK1 -1
|
||||
alpha1=1,
|
||||
beta1,
|
||||
theta1
|
||||
};
|
||||
|
||||
enum Greeks2
|
||||
{
|
||||
alpha2 = 2,
|
||||
#define GREEK2 -2
|
||||
beta2,
|
||||
theta2
|
||||
};
|
||||
|
||||
enum Greeks3
|
||||
{
|
||||
alpha3,
|
||||
beta3,
|
||||
#define GREEK3 -3
|
||||
theta3
|
||||
};
|
||||
|
||||
enum Greeks4
|
||||
{
|
||||
alpha4 = 4,
|
||||
beta4 = 5,
|
||||
theta4 = 6
|
||||
#define GREEK4 -4
|
||||
};
|
||||
|
||||
enum Greeks5
|
||||
{
|
||||
#define GREEK5 -5
|
||||
alpha5,
|
||||
beta5,
|
||||
};
|
||||
|
||||
enum Greeks6
|
||||
{
|
||||
alpha6,
|
||||
#define GREEK6 -6
|
||||
beta6,
|
||||
};
|
||||
|
||||
enum Greeks7
|
||||
{
|
||||
alpha7,
|
||||
beta7,
|
||||
#define GREEK7 -7
|
||||
};
|
||||
|
||||
enum Greeks8
|
||||
{
|
||||
#define GREEK8 -8
|
||||
theta8
|
||||
};
|
||||
|
||||
enum Greeks9
|
||||
{
|
||||
theta9
|
||||
#define GREEK9 -9
|
||||
};
|
||||
|
||||
enum Greeks10
|
||||
{
|
||||
#define GREEK10 -10
|
||||
theta10,
|
||||
};
|
||||
|
||||
enum Greeks11
|
||||
{
|
||||
theta11,
|
||||
#define GREEK11 -11
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
theta12 = 0
|
||||
#define GREEK12 -12
|
||||
} Greeks12;
|
||||
%}
|
||||
|
||||
|
||||
enum Greeks13
|
||||
{
|
||||
#define GREEK13 -13
|
||||
};
|
||||
|
||||
|
|
@ -45,3 +45,11 @@ struct Recursive : Recursive
|
|||
{
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
template <typename T> class Base {};
|
||||
%template() Base<int>;
|
||||
class Derived : public Base<int> {};
|
||||
class Derived2 : public Base<double> {};
|
||||
%template(BaseDouble) Base<double>;
|
||||
|
||||
|
|
|
|||
13
Examples/test-suite/errors/cpp_missing_rparenthesis.i
Normal file
13
Examples/test-suite/errors/cpp_missing_rparenthesis.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module xxx
|
||||
|
||||
%inline %{
|
||||
class Klass {
|
||||
Klass(int i) : m_i(
|
||||
{
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
void something() {
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ c_long_short.i:5: Error: Extra long specifier.
|
|||
c_long_short.i:6: Error: Extra short specifier.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_missing_rbrace.i :::::::::::::::::::::::::::::::::::
|
||||
:168430090: Error: Missing '}'. Reached end of input.
|
||||
c_missing_rbrace.i:3: Error: Missing '}'. Reached end of input.
|
||||
c_missing_rbrace.i:3: Error: Syntax error in input(1).
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_missing_semi.i :::::::::::::::::::::::::::::::::::
|
||||
|
|
@ -188,6 +188,16 @@ pp_variable_args.i:6: Error: Variable length macro argument must be last paramet
|
|||
:::::::::::::::::::::::::::::::: swig_apply_nargs.i :::::::::::::::::::::::::::::::::::
|
||||
swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_extend.i :::::::::::::::::::::::::::::::::::
|
||||
swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'.
|
||||
swig_extend.i:45: Warning 326: Deprecated %extend name used - the struct name 'stru_struct' should be used instead of the typedef name 'stru'.
|
||||
swig_extend.i:56: Warning 326: Deprecated %extend name used - the union name 'uni_union' should be used instead of the typedef name 'uni'.
|
||||
swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName.
|
||||
swig_extend.i:50: Warning 522: Use of an illegal constructor name 'stru' in %extend is deprecated, the constructor name should be 'stru_struct'.
|
||||
swig_extend.i:53: Warning 523: Use of an illegal destructor name 'stru' in %extend is deprecated, the destructor name should be 'stru_struct'.
|
||||
swig_extend.i:57: Warning 522: Use of an illegal constructor name 'uni' in %extend is deprecated, the constructor name should be 'uni_union'.
|
||||
swig_extend.i:58: Warning 523: Use of an illegal destructor name 'uni' in %extend is deprecated, the destructor name should be 'uni_union'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_identifier.i :::::::::::::::::::::::::::::::::::
|
||||
swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier.
|
||||
|
||||
|
|
@ -227,17 +237,17 @@ cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignor
|
|||
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_destructors.i:24: Warning 521: Illegal destructor name CStruct::~NOT_CStruct(). Ignored.
|
||||
cpp_extend_destructors.i:30: Warning 521: Illegal destructor name DStruct::~NOT_DStruct(). Ignored.
|
||||
cpp_extend_destructors.i:44: Warning 521: Illegal destructor name EStruct::~NOT_EStruct(). Ignored.
|
||||
cpp_extend_destructors.i:50: Warning 521: Illegal destructor name FStruct::~NOT_FStruct(). Ignored.
|
||||
cpp_extend_destructors.i:65: Warning 521: Illegal destructor name GStruct::~NOT_GStruct(). Ignored.
|
||||
cpp_extend_destructors.i:72: Warning 521: Illegal destructor name HStruct::~NOT_HStruct(). Ignored.
|
||||
cpp_extend_destructors.i:81: Warning 521: Illegal destructor name IStruct::~NOT_IStruct(). Ignored.
|
||||
cpp_extend_destructors.i:86: Warning 521: Illegal destructor name JStruct::~NOT_JStruct(). Ignored.
|
||||
cpp_extend_destructors.i:92: Warning 521: Illegal destructor name KStruct::~NOT_KStruct(). Ignored.
|
||||
cpp_extend_destructors.i:99: Warning 521: Illegal destructor name LStruct< int >::~NOT_LStruct(). Ignored.
|
||||
cpp_extend_destructors.i:99: Warning 521: Illegal destructor name LStruct< short >::~NOT_LStruct(). Ignored.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_extend_redefine.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
|
||||
|
|
@ -268,6 +278,10 @@ cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
|
|||
cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
|
||||
cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
|
||||
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
|
||||
cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
|
||||
cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name.
|
||||
cpp_inherit.i:53: Warning 401: Base class 'Base< double >' undefined.
|
||||
cpp_inherit.i:54: Warning 401: 'Base< double >' must be defined before it is used as a base class.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
|
||||
|
|
@ -292,6 +306,10 @@ cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *)
|
|||
cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_missing_rparenthesis.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_missing_rparenthesis.i:5: Error: Missing ')'. Reached end of input.
|
||||
cpp_missing_rparenthesis.i:5: Error: Syntax error in input(3).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
|
||||
|
||||
|
|
@ -312,8 +330,8 @@ cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored
|
|||
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_no_return_type.i:6: Warning 504: Function S::R() must have a return type. Ignored.
|
||||
cpp_no_return_type.i:10: Warning 504: Function U::UU() must have a return type. Ignored.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ pp_unterm_comment
|
|||
pp_unterm_string
|
||||
pp_variable_args
|
||||
swig_apply_nargs
|
||||
swig_extend
|
||||
swig_identifier
|
||||
swig_insert_bad
|
||||
swig_typemap_copy
|
||||
|
|
@ -70,6 +71,7 @@ cpp_extend_undefined
|
|||
cpp_inline_namespace
|
||||
cpp_inherit
|
||||
cpp_macro_locator
|
||||
cpp_missing_rparenthesis
|
||||
cpp_missing_rtemplate
|
||||
cpp_namespace_alias
|
||||
cpp_namespace_aliasnot
|
||||
|
|
|
|||
60
Examples/test-suite/errors/swig_extend.i
Normal file
60
Examples/test-suite/errors/swig_extend.i
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
%module xxx
|
||||
|
||||
typedef struct {
|
||||
int myint;
|
||||
} StructA;
|
||||
|
||||
typedef struct StructBName {
|
||||
int myint;
|
||||
} StructB;
|
||||
|
||||
typedef struct StructC {
|
||||
int myint;
|
||||
} StructC;
|
||||
|
||||
%extend StructA {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
%extend StructB {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
%extend StructC {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
struct StructD {
|
||||
int myint;
|
||||
};
|
||||
typedef struct StructD StructDName;
|
||||
|
||||
%extend StructDName {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
|
||||
typedef struct stru_struct {
|
||||
int bar;
|
||||
} stru;
|
||||
typedef union uni_union {
|
||||
int un1;
|
||||
double un2;
|
||||
} uni;
|
||||
|
||||
%extend stru {
|
||||
stru() {
|
||||
stru* s = (stru*)malloc(sizeof(stru));
|
||||
s->bar = 11;
|
||||
return s;
|
||||
}
|
||||
~stru() {
|
||||
free($self);
|
||||
}
|
||||
}
|
||||
|
||||
%extend uni {
|
||||
uni() { return 0; }
|
||||
~uni() { free($self); }
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,12 @@
|
|||
%module extend_constructor_destructor
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) Space::tagCStruct;
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagEStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) Space::tagCStruct::CStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) Space::tagCStruct::~CStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) tagEStruct::EStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) tagEStruct::~EStruct;
|
||||
|
||||
%inline %{
|
||||
int globalVar = 0;
|
||||
|
||||
|
|
|
|||
21
Examples/test-suite/extend_special_variables.i
Normal file
21
Examples/test-suite/extend_special_variables.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%module extend_special_variables
|
||||
|
||||
%rename(ForExtensionNewName) ForExtension;
|
||||
%rename(extended_renamed) ForExtension::extended;
|
||||
|
||||
%extend ForExtension {
|
||||
ForExtension() {
|
||||
return new ForExtension();
|
||||
}
|
||||
const char* extended() {
|
||||
return "name:$name symname:$symname wrapname:$wrapname overname:$overname decl:$decl fulldecl:$fulldecl parentclasssymname:$parentclasssymname parentclassname:$parentclassname";
|
||||
}
|
||||
const char* extended(int) {
|
||||
return "name:$name symname:$symname wrapname:$wrapname overname:$overname decl:$decl fulldecl:$fulldecl parentclasssymname:$parentclasssymname parentclassname:$parentclassname";
|
||||
}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct ForExtension {
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
%module extend_typedef_class
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCClass;
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCStruct;
|
||||
|
||||
// classes in global namespace
|
||||
%inline %{
|
||||
typedef struct tagAClass {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ func main() {
|
|||
if special_variable_macros.TestMary(name) != "SWIGTYPE_p_NameWrap" {
|
||||
panic("test failed")
|
||||
}
|
||||
if special_variable_macros.TestJames(name) != "SWIGTYPE_Name" {
|
||||
panic("test failed")
|
||||
}
|
||||
if special_variable_macros.TestJim(name) != "multiname num" {
|
||||
panic("test failed")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@
|
|||
# Makefile for guile test-suite
|
||||
#######################################################################
|
||||
|
||||
EXTRA_TEST_CASES += guile_ext_test.externaltest
|
||||
|
||||
LANGUAGE = guile
|
||||
VARIANT = _gh
|
||||
VARIANT =
|
||||
SCRIPTSUFFIX = _runme.scm
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
GUILE = @GUILE@
|
||||
GUILE_RUNTIME=-runtime
|
||||
GUILE_RUNTIME=
|
||||
|
||||
C_TEST_CASES = long_long \
|
||||
list_vector \
|
||||
|
|
@ -20,7 +22,7 @@ C_TEST_CASES = long_long \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# none!
|
||||
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
%.multicpptest: SWIGOPT += $(GUILE_RUNTIME)
|
||||
|
|
@ -41,11 +43,16 @@ include $(srcdir)/../common.mk
|
|||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.externaltest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_external)
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.scm appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts.so"))
|
||||
(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts"))
|
||||
(load "../schemerunme/casts.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant.so"))
|
||||
(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant"))
|
||||
(load "../schemerunme/char_constant.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore.so"))
|
||||
(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore"))
|
||||
(load "../schemerunme/class_ignore.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover.so"))
|
||||
(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover"))
|
||||
(load "../schemerunme/constover.scm")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract.so"))
|
||||
(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract"))
|
||||
(load "testsuite.scm")
|
||||
(load "../schemerunme/contract.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum.so"))
|
||||
(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum"))
|
||||
(load "../schemerunme/cpp_enum.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace.so"))
|
||||
(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace"))
|
||||
(load "../schemerunme/cpp_namespace.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast.so"))
|
||||
(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast"))
|
||||
(load "../schemerunme/dynamic_cast.scm")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <ext_test_wrap_hdr.h>
|
||||
#include <guile_ext_test_wrap_hdr.h>
|
||||
#include <imports_a.h>
|
||||
|
||||
SCM test_create()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so"))
|
||||
(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test"))
|
||||
|
||||
; This is a test for SF Bug 1573892
|
||||
; If IsPointer is called before TypeQuery, the test-is-pointer will fail
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule.so"))
|
||||
(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule"))
|
||||
(load "../schemerunme/import_nomodule.scm")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a.so"))
|
||||
(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b.so"))
|
||||
(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a"))
|
||||
(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b"))
|
||||
(load "../schemerunme/imports.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing.so"))
|
||||
(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing"))
|
||||
(load "../schemerunme/inherit_missing.scm")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers.so"))
|
||||
(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers"))
|
||||
|
||||
(define-macro (throws-exception? form)
|
||||
`(catch #t
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so"))
|
||||
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string"))
|
||||
(load "../schemerunme/li_std_string.scm")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so"))
|
||||
(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps"))
|
||||
(load "../schemerunme/li_typemaps.scm")
|
||||
|
||||
(let ((lst (inoutr-int2 3 -2)))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector.so"))
|
||||
(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector"))
|
||||
(load "../schemerunme/list_vector.scm")
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue.so"))
|
||||
(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue"))
|
||||
(load "../schemerunme/multivalue.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_name_module" (dynamic-link "./libname.so"))
|
||||
(dynamic-call "scm_init_name_module" (dynamic-link "./libname"))
|
||||
(load "../schemerunme/name.scm")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated.so"))
|
||||
(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated"))
|
||||
|
||||
(define-macro (check form)
|
||||
`(if (not ,form)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy.so"))
|
||||
(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy"))
|
||||
(load "../schemerunme/overload_copy.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend.so"))
|
||||
(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend"))
|
||||
(load "../schemerunme/overload_extend.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple.so"))
|
||||
(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple"))
|
||||
(load "../schemerunme/overload_simple.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype.so"))
|
||||
(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype"))
|
||||
(load "../schemerunme/overload_subtype.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out.so"))
|
||||
(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out"))
|
||||
(load "../schemerunme/pointer_in_out.scm")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
; copied from python runme_.py
|
||||
(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars.so"))
|
||||
(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars"))
|
||||
(load "../schemerunme/reference_global_vars.scm")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so"))
|
||||
(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception"))
|
||||
|
||||
(define-macro (check-throw form)
|
||||
`(catch 'swig-exception
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit.so"))
|
||||
(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit"))
|
||||
(load "../schemerunme/typedef_inherit.scm")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename.so"))
|
||||
;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes.so"))
|
||||
(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename"))
|
||||
;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes"))
|
||||
(load "../schemerunme/typename.scm")
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions.so"))
|
||||
(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions"))
|
||||
(load "../schemerunme/unions.scm")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%module guilescm_ext_test
|
||||
%module guile_ext_test
|
||||
|
||||
/* just use the imports_a.h header... for this test we only need a class */
|
||||
%{
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#######################################################################
|
||||
# Makefile for guile test-suite (with SCM API)
|
||||
#######################################################################
|
||||
|
||||
EXTRA_TEST_CASES += guilescm_ext_test.externaltest
|
||||
|
||||
include ../guile/Makefile
|
||||
|
||||
# Overridden variables here
|
||||
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm
|
||||
VARIANT =
|
||||
# Refer to the guile directory for the run scripts
|
||||
SCRIPTPREFIX = ../guile/
|
||||
GUILE_RUNTIME=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.scm appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
|
||||
fi
|
||||
|
||||
%.externaltest:
|
||||
$(local_setup)
|
||||
+$(swig_and_compile_external)
|
||||
$(local_run_testcase)
|
||||
|
||||
# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory)
|
||||
local_setup = \
|
||||
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
|
||||
fi
|
||||
|
||||
local_run_testcase = \
|
||||
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
explicit A(char *s) { ii = 4; }
|
||||
|
||||
int get() const { return ii; }
|
||||
|
||||
};
|
||||
|
||||
int get(const A& a) { return a.ii; }
|
||||
|
|
@ -33,7 +32,7 @@
|
|||
explicit A_T(char *s) { ii = 4; }
|
||||
|
||||
int get() const { return ii; }
|
||||
|
||||
static int sget(const A_T& a) { return a.ii; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
// This test fails if swig is not able to include
|
||||
// the following two files:
|
||||
//
|
||||
// 'testdir/subdir1/hello.i'
|
||||
// 'testdir/subdir2/hello.i'
|
||||
// 'testdir/inctest/subdir1/hello.i'
|
||||
// 'testdir/inctest/subdir2/hello.i'
|
||||
//
|
||||
// since they have the same basename 'hello', swig is only
|
||||
// including one. This is not right, it must include both,
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// Also repeats the test for the import directive in subdirectories
|
||||
|
||||
%include "testdir/test.i"
|
||||
%include "testdir/inctest/test.i"
|
||||
|
||||
|
||||
// Bug #1162194
|
||||
|
|
|
|||
|
|
@ -16,5 +16,16 @@
|
|||
unsigned long unsigned_long_identity(unsigned long x) { return x; }
|
||||
signed long long signed_long_long_identity(signed long long x) { return x; }
|
||||
unsigned long long unsigned_long_long_identity(unsigned long long x) { return x; }
|
||||
|
||||
size_t signed_char_size() { return sizeof (signed char); }
|
||||
size_t unsigned_char_size() { return sizeof (unsigned char); }
|
||||
size_t signed_short_size() { return sizeof (signed short); }
|
||||
size_t unsigned_short_size() { return sizeof (unsigned short); }
|
||||
size_t signed_int_size() { return sizeof (signed int); }
|
||||
size_t unsigned_int_size() { return sizeof (unsigned int); }
|
||||
size_t signed_long_size() { return sizeof (signed long); }
|
||||
size_t unsigned_long_size() { return sizeof (unsigned long); }
|
||||
size_t signed_long_long_size() { return sizeof (signed long long); }
|
||||
size_t unsigned_long_long_size() { return sizeof (unsigned long long); }
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
#######################################################################
|
||||
|
||||
LANGUAGE = java
|
||||
JAVA = java
|
||||
JAVAC = javac
|
||||
JAVA = @JAVA@
|
||||
JAVAC = @JAVAC@
|
||||
JAVAFLAGS = -Xcheck:jni
|
||||
SCRIPTSUFFIX = _runme.java
|
||||
srcdir = @srcdir@
|
||||
|
|
@ -23,10 +23,12 @@ CPP_TEST_CASES = \
|
|||
intermediary_classname \
|
||||
java_constants \
|
||||
java_director \
|
||||
java_director_assumeoverride \
|
||||
java_enums \
|
||||
java_jnitypes \
|
||||
java_lib_arrays_dimensionless \
|
||||
java_lib_various \
|
||||
java_jnitypes \
|
||||
java_nspacewithoutpackage \
|
||||
java_pgcpp \
|
||||
java_pragmas \
|
||||
java_prepost \
|
||||
|
|
@ -39,12 +41,15 @@ include $(srcdir)/../common.mk
|
|||
|
||||
# Overridden variables here
|
||||
JAVA_PACKAGE = $*
|
||||
SWIGOPT += -package $(JAVA_PACKAGE)
|
||||
JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
|
||||
SWIGOPT += $(JAVA_PACKAGEOPT)
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
import curiously_recurring_template_pattern.*;
|
||||
|
||||
public class curiously_recurring_template_pattern_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("curiously_recurring_template_pattern");
|
||||
} 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[]) {
|
||||
Derived d = new Derived();
|
||||
d.setBase1Param(1).setDerived1Param(10).setDerived2Param(20).setBase2Param(2);
|
||||
|
||||
if (d.getBase1Param() != 1)
|
||||
throw new RuntimeException("fail");
|
||||
if (d.getDerived1Param() != 10)
|
||||
throw new RuntimeException("fail");
|
||||
if (d.getBase2Param() != 2)
|
||||
throw new RuntimeException("fail");
|
||||
if (d.getDerived2Param() != 20)
|
||||
throw new RuntimeException("fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,6 +21,11 @@ public class director_binary_string_runme {
|
|||
|
||||
if (sum != 9*2*8 + 13*3*5)
|
||||
throw new RuntimeException("Unexpected sum: " + sum);
|
||||
|
||||
new Callback().run(null, null);
|
||||
callback = new DirectorBinaryStringCallback();
|
||||
caller.setCallback(callback);
|
||||
caller.call_null();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,11 +37,13 @@ class DirectorBinaryStringCallback extends Callback {
|
|||
@Override
|
||||
public void run(byte[] dataBufferAA, byte[] dataBufferBB)
|
||||
{
|
||||
for (int i = 0; i < dataBufferAA.length; i++)
|
||||
dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
|
||||
if (dataBufferAA != null)
|
||||
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);
|
||||
if (dataBufferBB != null)
|
||||
for (int i = 0; i < dataBufferBB.length; i++)
|
||||
dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class director_nspace_runme {
|
|||
|
||||
}
|
||||
|
||||
class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
|
||||
class director_nspace_MyBarFoo extends director_nspacePackage.TopLevel.Bar.Foo {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
|
|
@ -32,17 +32,17 @@ class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(director_nspacePackage.Bar.FooBar fooBar) {
|
||||
public String fooBar(director_nspacePackage.TopLevel.Bar.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_nspacePackage.Bar.Foo makeFoo() {
|
||||
return new director_nspacePackage.Bar.Foo();
|
||||
public director_nspacePackage.TopLevel.Bar.Foo makeFoo() {
|
||||
return new director_nspacePackage.TopLevel.Bar.Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_nspacePackage.Bar.FooBar makeFooBar() {
|
||||
return new director_nspacePackage.Bar.FooBar();
|
||||
public director_nspacePackage.TopLevel.Bar.FooBar makeFooBar() {
|
||||
return new director_nspacePackage.TopLevel.Bar.FooBar();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
Examples/test-suite/java/director_smartptr_runme.java
Normal file
48
Examples/test-suite/java/director_smartptr_runme.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Make sure that directors are connected and disconnected when used inconjunction with
|
||||
// being a smart pointer
|
||||
|
||||
public class director_smartptr_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_smartptr");
|
||||
} 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_smartptr_MyBarFoo myBarFoo =
|
||||
new director_smartptr_MyBarFoo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class director_smartptr_MyBarFoo extends director_smartptr.Foo {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
return "director_smartptr_MyBarFoo.ping();";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pong() {
|
||||
return "director_smartptr_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(director_smartptr.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.Foo makeFoo() {
|
||||
return new director_smartptr.Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.FooBar makeFooBar() {
|
||||
return new director_smartptr.FooBar();
|
||||
}
|
||||
}
|
||||
33
Examples/test-suite/java/enum_forward_runme.java
Normal file
33
Examples/test-suite/java/enum_forward_runme.java
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
import enum_forward.*;
|
||||
|
||||
public class enum_forward_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("enum_forward");
|
||||
} 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[])
|
||||
{
|
||||
try {
|
||||
ForwardEnum1 f1 = enum_forward.get_enum1();
|
||||
f1 = enum_forward.test_function1(f1);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
ForwardEnum2 f2 = enum_forward.get_enum2();
|
||||
f2 = enum_forward.test_function2(f2);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
|
||||
ForwardEnum3 f3 = enum_forward.get_enum3();
|
||||
f3 = enum_forward.test_function3(f3);
|
||||
}
|
||||
}
|
||||
|
||||
93
Examples/test-suite/java/enum_macro_runme.java
Normal file
93
Examples/test-suite/java/enum_macro_runme.java
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
import enum_macro.*;
|
||||
|
||||
public class enum_macro_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("enum_macro");
|
||||
} 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[])
|
||||
{
|
||||
{
|
||||
Greeks1 a = Greeks1.alpha1;
|
||||
a = Greeks1.beta1;
|
||||
a = Greeks1.theta1;
|
||||
if (a.swigValue() != 3)
|
||||
throw new RuntimeException("Greeks1");
|
||||
}
|
||||
{
|
||||
Greeks2 a = Greeks2.alpha2;
|
||||
a = Greeks2.beta2;
|
||||
a = Greeks2.theta2;
|
||||
if (a.swigValue() != 4)
|
||||
throw new RuntimeException("Greeks2");
|
||||
}
|
||||
{
|
||||
Greeks3 a = Greeks3.alpha3;
|
||||
a = Greeks3.beta3;
|
||||
a = Greeks3.theta3;
|
||||
if (a.swigValue() != 2)
|
||||
throw new RuntimeException("Greeks3");
|
||||
}
|
||||
{
|
||||
Greeks4 a = Greeks4.alpha4;
|
||||
a = Greeks4.beta4;
|
||||
a = Greeks4.theta4;
|
||||
if (a.swigValue() != 6)
|
||||
throw new RuntimeException("Greeks4");
|
||||
}
|
||||
{
|
||||
Greeks5 a = Greeks5.alpha5;
|
||||
a = Greeks5.beta5;
|
||||
if (a.swigValue() != 1)
|
||||
throw new RuntimeException("Greeks5");
|
||||
}
|
||||
{
|
||||
Greeks6 a = Greeks6.alpha6;
|
||||
a = Greeks6.beta6;
|
||||
if (a.swigValue() != 1)
|
||||
throw new RuntimeException("Greeks6");
|
||||
}
|
||||
{
|
||||
Greeks7 a = Greeks7.alpha7;
|
||||
a = Greeks7.beta7;
|
||||
if (a.swigValue() != 1)
|
||||
throw new RuntimeException("Greeks7");
|
||||
}
|
||||
{
|
||||
Greeks8 a = Greeks8.theta8;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks8");
|
||||
}
|
||||
{
|
||||
Greeks9 a = Greeks9.theta9;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks9");
|
||||
}
|
||||
{
|
||||
Greeks10 a = Greeks10.theta10;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks10");
|
||||
}
|
||||
{
|
||||
Greeks11 a = Greeks11.theta11;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks11");
|
||||
}
|
||||
{
|
||||
Greeks12 a = Greeks12.theta12;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks12");
|
||||
}
|
||||
{
|
||||
Greeks13 a = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
Examples/test-suite/java/extend_special_variables_runme.java
Normal file
25
Examples/test-suite/java/extend_special_variables_runme.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
import extend_special_variables.*;
|
||||
|
||||
public class extend_special_variables_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("extend_special_variables");
|
||||
} 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[])
|
||||
{
|
||||
ForExtensionNewName f = new ForExtensionNewName();
|
||||
verify(f.extended_renamed(), "name:extended symname:extended_renamed wrapname: overname:__SWIG_0 decl:ForExtension::extended() fulldecl:char const * ForExtension::extended() parentclasssymname:ForExtensionNewName parentclassname:ForExtension");
|
||||
verify(f.extended_renamed(10), "name:extended symname:extended_renamed wrapname: overname:__SWIG_1 decl:ForExtension::extended(int) fulldecl:char const * ForExtension::extended(int) parentclasssymname:ForExtensionNewName parentclassname:ForExtension");
|
||||
}
|
||||
static void verify(String received, String expected) {
|
||||
if (!received.equals(expected))
|
||||
throw new RuntimeException("Incorrect, received: " + received);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
import java_director_assumeoverride.*;
|
||||
|
||||
public class java_director_assumeoverride_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("java_director_assumeoverride");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
static class MyOverrideMe extends OverrideMe {
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
OverrideMe overrideMe = new MyOverrideMe();
|
||||
|
||||
// MyOverrideMe doesn't actually override func(), but because assumeoverride
|
||||
// was set to true, the C++ side will believe it was overridden.
|
||||
if (!java_director_assumeoverride.isFuncOverridden(overrideMe)) {
|
||||
throw new RuntimeException ( "isFuncOverridden()" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ public class java_prepost_runme {
|
|||
{
|
||||
// ensure checked exception is generated
|
||||
try {
|
||||
PrePostThrows ppt = new PrePostThrows(null);
|
||||
PrePostThrows ppt = new PrePostThrows(null, true);
|
||||
} catch (InstantiationException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
import namespace_forward_declaration.*;
|
||||
|
||||
public class namespace_forward_declaration_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("namespace_forward_declaration");
|
||||
} 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[]) {
|
||||
XXX xxx = new XXX();
|
||||
namespace_forward_declaration.testXXX1(xxx);
|
||||
namespace_forward_declaration.testXXX2(xxx);
|
||||
namespace_forward_declaration.testXXX3(xxx);
|
||||
YYY yyy = new YYY();
|
||||
namespace_forward_declaration.testYYY1(yyy);
|
||||
namespace_forward_declaration.testYYY2(yyy);
|
||||
namespace_forward_declaration.testYYY3(yyy);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -22,6 +22,8 @@ public class special_variable_macros_runme {
|
|||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testMary(name).equals("SWIGTYPE_p_NameWrap"))
|
||||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testJames(name).equals("SWIGTYPE_Name"))
|
||||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testJim(name).equals("multiname num"))
|
||||
throw new RuntimeException("test failed");
|
||||
NewName newName = NewName.factory("factoryname");
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ public class special_variables_runme {
|
|||
public static void main(String argv[])
|
||||
{
|
||||
verify(special_variables.ExceptionVars(1.0, 2.0),
|
||||
"result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars Java_special_1variables_special_1variablesJNI_ExceptionVars");
|
||||
"result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars Java_special_1variables_special_1variablesJNI_ExceptionVars ");
|
||||
|
||||
verify(special_variables.overloadedmethod(),
|
||||
"result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_11");
|
||||
"result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_11 ");
|
||||
|
||||
verify(special_variables.overloadedmethod(10.0),
|
||||
"result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_10");
|
||||
"result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_10 ");
|
||||
|
||||
ABC a = new ABC(0, 0.0);
|
||||
verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
import template_namespace_forward_declaration.*;
|
||||
|
||||
public class template_namespace_forward_declaration_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_namespace_forward_declaration");
|
||||
} 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[]) {
|
||||
XXXInt xxx = new XXXInt();
|
||||
template_namespace_forward_declaration.testXXX1(xxx);
|
||||
template_namespace_forward_declaration.testXXX2(xxx);
|
||||
template_namespace_forward_declaration.testXXX3(xxx);
|
||||
YYYInt yyy = new YYYInt();
|
||||
template_namespace_forward_declaration.testYYY1(yyy);
|
||||
template_namespace_forward_declaration.testYYY2(yyy);
|
||||
template_namespace_forward_declaration.testYYY3(yyy);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
import template_using_directive_and_declaration_forward.*;
|
||||
|
||||
public class template_using_directive_and_declaration_forward_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_using_directive_and_declaration_forward");
|
||||
} 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[])
|
||||
{
|
||||
template_using_directive_and_declaration_forward.useit1(new Thing1Int());
|
||||
template_using_directive_and_declaration_forward.useit1a(new Thing1Int());
|
||||
template_using_directive_and_declaration_forward.useit1b(new Thing1Int());
|
||||
template_using_directive_and_declaration_forward.useit1c(new Thing1Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit2(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2a(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2b(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2c(new Thing2Int());
|
||||
template_using_directive_and_declaration_forward.useit2d(new Thing2Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit3(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3a(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3b(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3c(new Thing3Int());
|
||||
template_using_directive_and_declaration_forward.useit3d(new Thing3Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit4(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4a(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4b(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4c(new Thing4Int());
|
||||
template_using_directive_and_declaration_forward.useit4d(new Thing4Int());
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit5(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5a(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5b(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5c(new Thing5Int());
|
||||
template_using_directive_and_declaration_forward.useit5d(new Thing5Int());
|
||||
|
||||
|
||||
//BROKEN template_using_directive_and_declaration_forward.useit7(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7a(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7b(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7c(new Thing7Int());
|
||||
template_using_directive_and_declaration_forward.useit7d(new Thing7Int());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
import using_directive_and_declaration_forward.*;
|
||||
|
||||
public class using_directive_and_declaration_forward_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("using_directive_and_declaration_forward");
|
||||
} 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[])
|
||||
{
|
||||
using_directive_and_declaration_forward.useit1(new Thing1());
|
||||
using_directive_and_declaration_forward.useit1a(new Thing1());
|
||||
using_directive_and_declaration_forward.useit1b(new Thing1());
|
||||
using_directive_and_declaration_forward.useit1c(new Thing1());
|
||||
|
||||
using_directive_and_declaration_forward.useit2(new Thing2());
|
||||
using_directive_and_declaration_forward.useit2a(new Thing2());
|
||||
using_directive_and_declaration_forward.useit2b(new Thing2());
|
||||
using_directive_and_declaration_forward.useit2c(new Thing2());
|
||||
using_directive_and_declaration_forward.useit2d(new Thing2());
|
||||
|
||||
using_directive_and_declaration_forward.useit3(new Thing3());
|
||||
using_directive_and_declaration_forward.useit3a(new Thing3());
|
||||
using_directive_and_declaration_forward.useit3b(new Thing3());
|
||||
using_directive_and_declaration_forward.useit3c(new Thing3());
|
||||
using_directive_and_declaration_forward.useit3d(new Thing3());
|
||||
|
||||
using_directive_and_declaration_forward.useit4(new Thing4());
|
||||
using_directive_and_declaration_forward.useit4a(new Thing4());
|
||||
using_directive_and_declaration_forward.useit4b(new Thing4());
|
||||
using_directive_and_declaration_forward.useit4c(new Thing4());
|
||||
using_directive_and_declaration_forward.useit4d(new Thing4());
|
||||
|
||||
using_directive_and_declaration_forward.useit5(new Thing5());
|
||||
using_directive_and_declaration_forward.useit5a(new Thing5());
|
||||
using_directive_and_declaration_forward.useit5b(new Thing5());
|
||||
using_directive_and_declaration_forward.useit5c(new Thing5());
|
||||
using_directive_and_declaration_forward.useit5d(new Thing5());
|
||||
|
||||
|
||||
using_directive_and_declaration_forward.useit7(new Thing7());
|
||||
using_directive_and_declaration_forward.useit7a(new Thing7());
|
||||
using_directive_and_declaration_forward.useit7b(new Thing7());
|
||||
using_directive_and_declaration_forward.useit7c(new Thing7());
|
||||
using_directive_and_declaration_forward.useit7d(new Thing7());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
import using_directive_and_declaration.*;
|
||||
|
||||
public class using_directive_and_declaration_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("using_directive_and_declaration");
|
||||
} 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[])
|
||||
{
|
||||
using_directive_and_declaration.useit1(new Thing1());
|
||||
using_directive_and_declaration.useit2(new Thing2());
|
||||
using_directive_and_declaration.useit3(new Thing3());
|
||||
using_directive_and_declaration.useit4(new Thing4());
|
||||
using_directive_and_declaration.useit5(new Thing5());
|
||||
Thing6a t6a = new Thing6a();
|
||||
t6a.a();
|
||||
Thing6 t6b = new Thing6();
|
||||
t6b.b();
|
||||
using_directive_and_declaration.useit6(t6a, t6b);
|
||||
using_directive_and_declaration.useit7(new Thing7());
|
||||
}
|
||||
}
|
||||
29
Examples/test-suite/java_director_assumeoverride.i
Normal file
29
Examples/test-suite/java_director_assumeoverride.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
%module(directors="1") java_director_assumeoverride
|
||||
|
||||
%{
|
||||
class OverrideMe {
|
||||
public:
|
||||
virtual ~OverrideMe() {}
|
||||
virtual void func() {};
|
||||
};
|
||||
|
||||
#include "java_director_assumeoverride_wrap.h"
|
||||
bool isFuncOverridden(OverrideMe* f) {
|
||||
SwigDirector_OverrideMe* director = dynamic_cast<SwigDirector_OverrideMe*>(f);
|
||||
if (!director) {
|
||||
return false;
|
||||
}
|
||||
return director->swig_overrides(0);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%feature("director", assumeoverride=1) OverrideMe;
|
||||
|
||||
class OverrideMe {
|
||||
public:
|
||||
virtual ~OverrideMe();
|
||||
virtual void func();
|
||||
};
|
||||
|
||||
bool isFuncOverridden(OverrideMe* f);
|
||||
37
Examples/test-suite/java_nspacewithoutpackage.i
Normal file
37
Examples/test-suite/java_nspacewithoutpackage.i
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
%module java_nspacewithoutpackage
|
||||
|
||||
%warnfilter(SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE) TopLevel::Foo;
|
||||
%warnfilter(SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE) TopLevel::Bar;
|
||||
|
||||
%pragma(java) jniclasspackage="PragmaDefinedPackage"
|
||||
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%nspace TopLevel::Foo;
|
||||
%nspace TopLevel::Bar;
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace TopLevel
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "TopLevel::Foo::ping()"; }
|
||||
};
|
||||
|
||||
class Bar {
|
||||
public:
|
||||
virtual ~Bar() {}
|
||||
virtual std::string pong() { return "TopLevel::Bar::pong()"; }
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -83,7 +83,7 @@ struct PrePost2 {
|
|||
|
||||
%inline %{
|
||||
struct PrePostThrows {
|
||||
PrePostThrows(PrePostTest *ppt) {
|
||||
PrePostThrows(PrePostTest *ppt, bool) {
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
110
Examples/test-suite/li_attribute_template.i
Normal file
110
Examples/test-suite/li_attribute_template.i
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
%module li_attribute_template
|
||||
|
||||
%include <exception.i>
|
||||
|
||||
//#define SWIG_ATTRIBUTE_TEMPLATE
|
||||
%include <attribute.i>
|
||||
%include <std_string.i>
|
||||
|
||||
%inline
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
Foo( int _value ) { value = _value; }
|
||||
int value;
|
||||
};
|
||||
|
||||
template< class T1, class T2>
|
||||
struct pair{
|
||||
pair( T1 t1, T2 t2 ):
|
||||
first(t1), second(t2) {;}
|
||||
|
||||
T1 first;
|
||||
T2 second;
|
||||
};
|
||||
|
||||
template< class T1, class T2>
|
||||
struct C
|
||||
{
|
||||
C(int a, int b, int c) :
|
||||
_a(a), _b(b), _c(c), _d(a), _e(b),
|
||||
_f(a,b), _g(b,c)
|
||||
{
|
||||
|
||||
/*
|
||||
_f.first = _a;
|
||||
_f.second = _b;
|
||||
|
||||
_g.first = _b;
|
||||
_g.second = _c;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
int get_value() const
|
||||
{
|
||||
return _a;
|
||||
}
|
||||
|
||||
void set_value(int aa)
|
||||
{
|
||||
_a = aa;
|
||||
}
|
||||
|
||||
/* only one ref method */
|
||||
int& get_ref()
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
Foo get_class_value() const { return _d; }
|
||||
void set_class_value( Foo foo) { _d = foo; }
|
||||
|
||||
const Foo& get_class_ref() const { return _e; }
|
||||
void set_class_ref( const Foo& foo ) { _e = foo; }
|
||||
|
||||
pair<T1,T2> get_template_value() const { return _f; }
|
||||
void set_template_value( const pair<T1,T2> f ) { _f = f; }
|
||||
|
||||
const pair<T1,T2>& get_template_ref() const { return _g; }
|
||||
void set_template_ref( const pair<T1,T2>& g ) { _g = g; }
|
||||
|
||||
std::string get_string() { return str; }
|
||||
void set_string(std::string other) { str = other; }
|
||||
|
||||
private:
|
||||
int _a;
|
||||
int _b;
|
||||
int _c;
|
||||
Foo _d;
|
||||
Foo _e;
|
||||
pair<T1,T2> _f;
|
||||
pair<T1,T2> _g;
|
||||
|
||||
std::string str;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
%define %instantiate_C( T1, T2 )
|
||||
%template (pair_ ## T1 ## T2 ) pair<T1,T2>;
|
||||
// Primitive types
|
||||
%attribute( %arg(C<T1,T2>), int, a, get_value, set_value );
|
||||
%attributeref( %arg(C<T1,T2>), int, b, get_ref );
|
||||
|
||||
// Strings
|
||||
%attributestring(%arg(C<T1,T2>), std::string, str, get_string, set_string);
|
||||
|
||||
// Class types
|
||||
%attributeval( %arg(C<T1,T2>), Foo, d, get_class_value, set_class_value );
|
||||
%attribute2( %arg(C<T1,T2>), Foo, e, get_class_ref, set_class_ref );
|
||||
|
||||
// Moderately templated types
|
||||
%attributeval( %arg(C<T1,T2>), %arg(pair<T1,T2>), f, get_template_value, set_template_value );
|
||||
%attribute2( %arg(C<T1,T2>), %arg(pair<T1,T2>), g, get_template_ref, set_template_ref );
|
||||
|
||||
%template (C ## T1 ## T2) C<T1,T2>;
|
||||
%enddef
|
||||
|
||||
|
||||
%instantiate_C(int,int);
|
||||
|
|
@ -1,498 +1,495 @@
|
|||
// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
|
||||
// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
|
||||
// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
|
||||
// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
|
||||
// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
|
||||
// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
|
||||
//
|
||||
// Also note the debug_shared flag which can be set from the target language.
|
||||
|
||||
%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"
|
||||
#include "boost/intrusive_ptr.hpp"
|
||||
#include <boost/detail/atomic_count.hpp>
|
||||
|
||||
// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
|
||||
//#define INTRUSIVE_PTR_WRAPPER
|
||||
|
||||
#ifdef INTRUSIVE_PTR_WRAPPER
|
||||
# include "intrusive_ptr_wrapper.h"
|
||||
# include "shared_ptr_wrapper.h"
|
||||
#endif
|
||||
%}
|
||||
|
||||
%{
|
||||
#ifndef INTRUSIVE_PTR_WRAPPER
|
||||
# define SwigBoost boost
|
||||
#endif
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
#ifndef INTRUSIVE_PTR_WRAPPER
|
||||
# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
|
||||
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
|
||||
#endif
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%include <boost_intrusive_ptr.i>
|
||||
%intrusive_ptr(Space::Klass)
|
||||
%intrusive_ptr_no_wrap(Space::KlassWithoutRefCount)
|
||||
%intrusive_ptr(Space::KlassDerived)
|
||||
%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;
|
||||
%}
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
|
||||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
|
||||
$1 = $input ? *($&1_ltype)&$input : &tempnull;
|
||||
%}
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
|
||||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
|
||||
$1 = $input ? *($&1_ltype)&$input : &tempnull;
|
||||
%}
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
|
||||
%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:
|
||||
// const intrusive_ptr
|
||||
// std::vector
|
||||
// Add in generic %extend for the Upcast function for derived classes
|
||||
// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
|
||||
|
||||
%exception {
|
||||
if (debug_shared) {
|
||||
cout << "++++++" << endl << flush;
|
||||
cout << "calling $name" << endl << flush;
|
||||
}
|
||||
$action
|
||||
if (debug_shared) {
|
||||
cout << "------" << endl << flush;
|
||||
}
|
||||
}
|
||||
|
||||
%ignore IgnoredRefCountingBase;
|
||||
%ignore *::operator=;
|
||||
%ignore intrusive_ptr_add_ref;
|
||||
%ignore intrusive_ptr_release;
|
||||
%newobject pointerownertest();
|
||||
%newobject smartpointerpointerownertest();
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
static bool debug_shared = false;
|
||||
|
||||
namespace Space {
|
||||
|
||||
struct Klass {
|
||||
Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return value; }
|
||||
void append(const std::string &s) { value += s; }
|
||||
Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
Klass &operator=(const Klass &other) { value = other.value; return *this; }
|
||||
|
||||
void addref(void) const { ++count; }
|
||||
void release(void) const { if (--count == 0) delete this; }
|
||||
int use_count(void) const { return count; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
std::string value;
|
||||
int array[1024];
|
||||
mutable boost::detail::atomic_count count;
|
||||
};
|
||||
|
||||
struct KlassWithoutRefCount {
|
||||
KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return value; }
|
||||
void append(const std::string &s) { value += s; }
|
||||
KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
|
||||
std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
|
||||
KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
std::string value;
|
||||
int array[1024];
|
||||
};
|
||||
|
||||
struct IgnoredRefCountingBase {
|
||||
IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
|
||||
|
||||
IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
|
||||
|
||||
IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
|
||||
|
||||
void addref(void) const { ++count; }
|
||||
void release(void) const { if (--count == 0) delete this; }
|
||||
int use_count(void) const { return count; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
double d;
|
||||
double e;
|
||||
mutable boost::detail::atomic_count count;
|
||||
};
|
||||
|
||||
long getTotal_IgnoredRefCountingBase_count() {
|
||||
return IgnoredRefCountingBase::getTotal_count();
|
||||
}
|
||||
|
||||
// For most compilers, this use of multiple inheritance results in different derived and base class
|
||||
// pointer values ... for some more challenging tests :)
|
||||
struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
|
||||
KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
|
||||
KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
|
||||
KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
|
||||
virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
|
||||
int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
};
|
||||
struct KlassDerivedDerived : KlassDerived {
|
||||
KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
|
||||
KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
|
||||
KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
|
||||
virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
};
|
||||
KlassDerived* derivedpointertest(KlassDerived* kd) {
|
||||
if (kd)
|
||||
kd->append(" derivedpointertest");
|
||||
return kd;
|
||||
}
|
||||
KlassDerived derivedvaluetest(KlassDerived kd) {
|
||||
kd.append(" derivedvaluetest");
|
||||
return kd;
|
||||
}
|
||||
KlassDerived& derivedreftest(KlassDerived& kd) {
|
||||
kd.append(" derivedreftest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::intrusive_ptr<KlassDerived> kd) {
|
||||
if (kd)
|
||||
kd->append(" derivedsmartptrtest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
|
||||
if (kd && *kd)
|
||||
(*kd)->append(" derivedsmartptrpointertest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
|
||||
if (kd && *kd)
|
||||
(*kd)->append(" derivedsmartptrreftest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr<KlassDerived>*& kd) {
|
||||
if (kd && *kd)
|
||||
(*kd)->append(" derivedsmartptrpointerreftest");
|
||||
return kd;
|
||||
}
|
||||
|
||||
SwigBoost::intrusive_ptr<Klass> factorycreate() {
|
||||
return SwigBoost::intrusive_ptr<Klass>(new Klass("factorycreate"));
|
||||
}
|
||||
// smart pointer
|
||||
SwigBoost::intrusive_ptr<Klass> smartpointertest(SwigBoost::intrusive_ptr<Klass> k) {
|
||||
if (k)
|
||||
k->append(" smartpointertest");
|
||||
return SwigBoost::intrusive_ptr<Klass>(k);
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>* smartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
|
||||
if (k && *k)
|
||||
(*k)->append(" smartpointerpointertest");
|
||||
return k;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>& smartpointerreftest(SwigBoost::intrusive_ptr<Klass>& k) {
|
||||
if (k)
|
||||
k->append(" smartpointerreftest");
|
||||
return k;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::intrusive_ptr<Klass>*& k) {
|
||||
if (k && *k)
|
||||
(*k)->append(" smartpointerpointerreftest");
|
||||
return k;
|
||||
}
|
||||
// const
|
||||
SwigBoost::intrusive_ptr<const Klass> constsmartpointertest(SwigBoost::intrusive_ptr<const Klass> k) {
|
||||
return SwigBoost::intrusive_ptr<const Klass>(k);
|
||||
}
|
||||
SwigBoost::intrusive_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::intrusive_ptr<const Klass>* k) {
|
||||
return k;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<const Klass>& constsmartpointerreftest(SwigBoost::intrusive_ptr<const Klass>& k) {
|
||||
return k;
|
||||
}
|
||||
// plain pointer
|
||||
Klass valuetest(Klass k) {
|
||||
k.append(" valuetest");
|
||||
return k;
|
||||
}
|
||||
Klass *pointertest(Klass *k) {
|
||||
if (k)
|
||||
k->append(" pointertest");
|
||||
return k;
|
||||
}
|
||||
Klass& reftest(Klass& k) {
|
||||
k.append(" reftest");
|
||||
return k;
|
||||
}
|
||||
Klass *const& pointerreftest(Klass *const& k) {
|
||||
k->append(" pointerreftest");
|
||||
return k;
|
||||
}
|
||||
// null
|
||||
std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
|
||||
if (k && *k)
|
||||
return "not null";
|
||||
else if (!k)
|
||||
return "null smartpointer pointer";
|
||||
else if (!*k)
|
||||
return "null pointer";
|
||||
else
|
||||
return "also not null";
|
||||
}
|
||||
// $owner
|
||||
Klass *pointerownertest() {
|
||||
return new Klass("pointerownertest");
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>* smartpointerpointerownertest() {
|
||||
return new SwigBoost::intrusive_ptr<Klass>(new Klass("smartpointerpointerownertest"));
|
||||
}
|
||||
|
||||
const SwigBoost::intrusive_ptr<Klass>& ref_1() {
|
||||
static SwigBoost::intrusive_ptr<Klass> sptr;
|
||||
return sptr;
|
||||
}
|
||||
|
||||
// overloading tests
|
||||
std::string overload_rawbyval(int i) { return "int"; }
|
||||
std::string overload_rawbyval(Klass k) { return "rawbyval"; }
|
||||
|
||||
std::string overload_rawbyref(int i) { return "int"; }
|
||||
std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
|
||||
|
||||
std::string overload_rawbyptr(int i) { return "int"; }
|
||||
std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
|
||||
|
||||
std::string overload_rawbyptrref(int i) { return "int"; }
|
||||
std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
|
||||
|
||||
|
||||
|
||||
std::string overload_smartbyval(int i) { return "int"; }
|
||||
std::string overload_smartbyval(SwigBoost::intrusive_ptr<Klass> k) { return "smartbyval"; }
|
||||
|
||||
std::string overload_smartbyref(int i) { return "int"; }
|
||||
std::string overload_smartbyref(SwigBoost::intrusive_ptr<Klass> &k) { return "smartbyref"; }
|
||||
|
||||
std::string overload_smartbyptr(int i) { return "int"; }
|
||||
std::string overload_smartbyptr(SwigBoost::intrusive_ptr<Klass> *k) { return "smartbyptr"; }
|
||||
|
||||
std::string overload_smartbyptrref(int i) { return "int"; }
|
||||
std::string overload_smartbyptrref(SwigBoost::intrusive_ptr<Klass> *&k) { return "smartbyptrref"; }
|
||||
|
||||
} // namespace Space
|
||||
|
||||
%}
|
||||
%{
|
||||
boost::detail::atomic_count Space::Klass::total_count(0);
|
||||
boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
|
||||
boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
|
||||
boost::detail::atomic_count Space::KlassDerived::total_count(0);
|
||||
boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
|
||||
%}
|
||||
|
||||
// Member variables
|
||||
|
||||
%inline %{
|
||||
struct MemberVariables {
|
||||
MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr<Space::Klass>()), SmartMemberReference(*(new SwigBoost::intrusive_ptr<Space::Klass>())), MemberPointer(0), MemberReference(MemberValue) {}
|
||||
virtual ~MemberVariables() {
|
||||
delete SmartMemberPointer;
|
||||
delete &SmartMemberReference;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Space::Klass> SmartMemberValue;
|
||||
SwigBoost::intrusive_ptr<Space::Klass> * SmartMemberPointer;
|
||||
SwigBoost::intrusive_ptr<Space::Klass> & SmartMemberReference;
|
||||
Space::Klass MemberValue;
|
||||
Space::Klass * MemberPointer;
|
||||
Space::Klass & MemberReference;
|
||||
};
|
||||
|
||||
// Global variables
|
||||
SwigBoost::intrusive_ptr<Space::Klass> GlobalSmartValue;
|
||||
Space::Klass GlobalValue;
|
||||
Space::Klass * GlobalPointer = 0;
|
||||
Space::Klass & GlobalReference = GlobalValue;
|
||||
|
||||
%}
|
||||
|
||||
#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
// Note: %template after the intrusive_ptr typemaps
|
||||
%intrusive_ptr(Base<int, double>)
|
||||
%intrusive_ptr(Pair<int, double>)
|
||||
|
||||
#endif
|
||||
|
||||
// Templates
|
||||
%inline %{
|
||||
template <class T1, class T2> struct Base {
|
||||
Space::Klass klassBase;
|
||||
T1 baseVal1;
|
||||
T2 baseVal2;
|
||||
Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
|
||||
virtual std::string getValue() const { return "Base<>"; };
|
||||
mutable int count;
|
||||
void addref(void) const { count++; }
|
||||
void release(void) const { if (--count == 0) delete this; }
|
||||
int use_count(void) const { return count; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(BaseIntDouble) Base<int, double>;
|
||||
|
||||
%inline %{
|
||||
template <class T1, class T2> struct Pair : Base<T1, T2> {
|
||||
Space::Klass klassPair;
|
||||
T1 val1;
|
||||
T2 val2;
|
||||
Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
|
||||
virtual std::string getValue() const { return "Pair<>"; };
|
||||
};
|
||||
|
||||
Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
|
||||
SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
|
||||
|
||||
template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
|
||||
|
||||
template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
|
||||
|
||||
long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
long use_count(const SwigBoost::shared_ptr<Space::KlassDerived>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
long use_count(const SwigBoost::shared_ptr<Space::KlassDerivedDerived>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
%}
|
||||
|
||||
%template(PairIntDouble) Pair<int, double>;
|
||||
|
||||
// For counting the instances of intrusive_ptr (all of which are created on the heap)
|
||||
// intrusive_ptr_wrapper_count() gives overall count
|
||||
%inline %{
|
||||
namespace SwigBoost {
|
||||
const int NOT_COUNTING = -123456;
|
||||
int intrusive_ptr_wrapper_count() {
|
||||
#ifdef INTRUSIVE_PTR_WRAPPER
|
||||
return SwigBoost::IntrusivePtrWrapper::getTotalCount();
|
||||
#else
|
||||
return NOT_COUNTING;
|
||||
#endif
|
||||
}
|
||||
#ifdef INTRUSIVE_PTR_WRAPPER
|
||||
template<> std::string show_message(boost::intrusive_ptr<Space::Klass >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "Klass: " + (*t)->getValue();
|
||||
else
|
||||
return "Klass: NULL";
|
||||
}
|
||||
template<> std::string show_message(boost::intrusive_ptr<const Space::Klass >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "Klass: " + (*t)->getValue();
|
||||
else
|
||||
return "Klass: NULL";
|
||||
}
|
||||
template<> std::string show_message(boost::intrusive_ptr<Space::KlassDerived >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "KlassDerived: " + (*t)->getValue();
|
||||
else
|
||||
return "KlassDerived: NULL";
|
||||
}
|
||||
template<> std::string show_message(boost::intrusive_ptr<const Space::KlassDerived >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "KlassDerived: " + (*t)->getValue();
|
||||
else
|
||||
return "KlassDerived: NULL";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
%}
|
||||
|
||||
// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
|
||||
// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
|
||||
// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
|
||||
// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
|
||||
// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
|
||||
// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
|
||||
//
|
||||
// Also note the debug_shared flag which can be set from the target language.
|
||||
|
||||
%module li_boost_intrusive_ptr
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
|
||||
%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived;
|
||||
%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived;
|
||||
|
||||
%{
|
||||
template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
|
||||
template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/detail/atomic_count.hpp>
|
||||
|
||||
// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
|
||||
//#define INTRUSIVE_PTR_WRAPPER
|
||||
|
||||
#ifdef INTRUSIVE_PTR_WRAPPER
|
||||
# include "intrusive_ptr_wrapper.h"
|
||||
# include "shared_ptr_wrapper.h"
|
||||
#endif
|
||||
%}
|
||||
|
||||
%{
|
||||
#ifndef INTRUSIVE_PTR_WRAPPER
|
||||
# define SwigBoost boost
|
||||
#endif
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
#ifndef INTRUSIVE_PTR_WRAPPER
|
||||
# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
|
||||
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
|
||||
#endif
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%include <boost_intrusive_ptr.i>
|
||||
%intrusive_ptr(Space::Klass)
|
||||
%intrusive_ptr_no_wrap(Space::KlassWithoutRefCount)
|
||||
%intrusive_ptr(Space::KlassDerived)
|
||||
%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;
|
||||
%}
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
|
||||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
|
||||
$1 = $input ? *($&1_ltype)&$input : &tempnull;
|
||||
%}
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
|
||||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
|
||||
$1 = $input ? *($&1_ltype)&$input : &tempnull;
|
||||
%}
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
|
||||
%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:
|
||||
// const intrusive_ptr
|
||||
// std::vector
|
||||
// Add in generic %extend for the Upcast function for derived classes
|
||||
// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
|
||||
|
||||
%exception {
|
||||
if (debug_shared) {
|
||||
cout << "++++++" << endl << flush;
|
||||
cout << "calling $name" << endl << flush;
|
||||
}
|
||||
$action
|
||||
if (debug_shared) {
|
||||
cout << "------" << endl << flush;
|
||||
}
|
||||
}
|
||||
|
||||
%ignore IgnoredRefCountingBase;
|
||||
%ignore *::operator=;
|
||||
%newobject pointerownertest();
|
||||
%newobject smartpointerpointerownertest();
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
static bool debug_shared = false;
|
||||
|
||||
namespace Space {
|
||||
|
||||
struct Klass {
|
||||
Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return value; }
|
||||
void append(const std::string &s) { value += s; }
|
||||
Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
Klass &operator=(const Klass &other) { value = other.value; return *this; }
|
||||
|
||||
void addref(void) const { ++count; }
|
||||
void release(void) const { if (--count == 0) delete this; }
|
||||
int use_count(void) const { return count; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
std::string value;
|
||||
int array[1024];
|
||||
mutable boost::detail::atomic_count count;
|
||||
};
|
||||
|
||||
struct KlassWithoutRefCount {
|
||||
KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
|
||||
|
||||
virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return value; }
|
||||
void append(const std::string &s) { value += s; }
|
||||
KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
|
||||
std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
|
||||
KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
std::string value;
|
||||
int array[1024];
|
||||
};
|
||||
|
||||
struct IgnoredRefCountingBase {
|
||||
IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
|
||||
|
||||
IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
|
||||
|
||||
IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
|
||||
|
||||
void addref(void) const { ++count; }
|
||||
void release(void) const { if (--count == 0) delete this; }
|
||||
int use_count(void) const { return count; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
double d;
|
||||
double e;
|
||||
mutable boost::detail::atomic_count count;
|
||||
};
|
||||
|
||||
long getTotal_IgnoredRefCountingBase_count() {
|
||||
return IgnoredRefCountingBase::getTotal_count();
|
||||
}
|
||||
|
||||
// For most compilers, this use of multiple inheritance results in different derived and base class
|
||||
// pointer values ... for some more challenging tests :)
|
||||
struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
|
||||
KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
|
||||
KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
|
||||
KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
|
||||
virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
|
||||
int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
};
|
||||
struct KlassDerivedDerived : KlassDerived {
|
||||
KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
|
||||
KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
|
||||
KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
|
||||
virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
|
||||
virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
|
||||
static long getTotal_count() { return total_count; }
|
||||
|
||||
private:
|
||||
static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
|
||||
static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
|
||||
static boost::detail::atomic_count total_count;
|
||||
};
|
||||
KlassDerived* derivedpointertest(KlassDerived* kd) {
|
||||
if (kd)
|
||||
kd->append(" derivedpointertest");
|
||||
return kd;
|
||||
}
|
||||
KlassDerived derivedvaluetest(KlassDerived kd) {
|
||||
kd.append(" derivedvaluetest");
|
||||
return kd;
|
||||
}
|
||||
KlassDerived& derivedreftest(KlassDerived& kd) {
|
||||
kd.append(" derivedreftest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::intrusive_ptr<KlassDerived> kd) {
|
||||
if (kd)
|
||||
kd->append(" derivedsmartptrtest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
|
||||
if (kd && *kd)
|
||||
(*kd)->append(" derivedsmartptrpointertest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
|
||||
if (kd && *kd)
|
||||
(*kd)->append(" derivedsmartptrreftest");
|
||||
return kd;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr<KlassDerived>*& kd) {
|
||||
if (kd && *kd)
|
||||
(*kd)->append(" derivedsmartptrpointerreftest");
|
||||
return kd;
|
||||
}
|
||||
|
||||
SwigBoost::intrusive_ptr<Klass> factorycreate() {
|
||||
return SwigBoost::intrusive_ptr<Klass>(new Klass("factorycreate"));
|
||||
}
|
||||
// smart pointer
|
||||
SwigBoost::intrusive_ptr<Klass> smartpointertest(SwigBoost::intrusive_ptr<Klass> k) {
|
||||
if (k)
|
||||
k->append(" smartpointertest");
|
||||
return SwigBoost::intrusive_ptr<Klass>(k);
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>* smartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
|
||||
if (k && *k)
|
||||
(*k)->append(" smartpointerpointertest");
|
||||
return k;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>& smartpointerreftest(SwigBoost::intrusive_ptr<Klass>& k) {
|
||||
if (k)
|
||||
k->append(" smartpointerreftest");
|
||||
return k;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::intrusive_ptr<Klass>*& k) {
|
||||
if (k && *k)
|
||||
(*k)->append(" smartpointerpointerreftest");
|
||||
return k;
|
||||
}
|
||||
// const
|
||||
SwigBoost::intrusive_ptr<const Klass> constsmartpointertest(SwigBoost::intrusive_ptr<const Klass> k) {
|
||||
return SwigBoost::intrusive_ptr<const Klass>(k);
|
||||
}
|
||||
SwigBoost::intrusive_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::intrusive_ptr<const Klass>* k) {
|
||||
return k;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<const Klass>& constsmartpointerreftest(SwigBoost::intrusive_ptr<const Klass>& k) {
|
||||
return k;
|
||||
}
|
||||
// plain pointer
|
||||
Klass valuetest(Klass k) {
|
||||
k.append(" valuetest");
|
||||
return k;
|
||||
}
|
||||
Klass *pointertest(Klass *k) {
|
||||
if (k)
|
||||
k->append(" pointertest");
|
||||
return k;
|
||||
}
|
||||
Klass& reftest(Klass& k) {
|
||||
k.append(" reftest");
|
||||
return k;
|
||||
}
|
||||
Klass *const& pointerreftest(Klass *const& k) {
|
||||
k->append(" pointerreftest");
|
||||
return k;
|
||||
}
|
||||
// null
|
||||
std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
|
||||
if (k && *k)
|
||||
return "not null";
|
||||
else if (!k)
|
||||
return "null smartpointer pointer";
|
||||
else if (!*k)
|
||||
return "null pointer";
|
||||
else
|
||||
return "also not null";
|
||||
}
|
||||
// $owner
|
||||
Klass *pointerownertest() {
|
||||
return new Klass("pointerownertest");
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Klass>* smartpointerpointerownertest() {
|
||||
return new SwigBoost::intrusive_ptr<Klass>(new Klass("smartpointerpointerownertest"));
|
||||
}
|
||||
|
||||
const SwigBoost::intrusive_ptr<Klass>& ref_1() {
|
||||
static SwigBoost::intrusive_ptr<Klass> sptr;
|
||||
return sptr;
|
||||
}
|
||||
|
||||
// overloading tests
|
||||
std::string overload_rawbyval(int i) { return "int"; }
|
||||
std::string overload_rawbyval(Klass k) { return "rawbyval"; }
|
||||
|
||||
std::string overload_rawbyref(int i) { return "int"; }
|
||||
std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
|
||||
|
||||
std::string overload_rawbyptr(int i) { return "int"; }
|
||||
std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
|
||||
|
||||
std::string overload_rawbyptrref(int i) { return "int"; }
|
||||
std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
|
||||
|
||||
|
||||
|
||||
std::string overload_smartbyval(int i) { return "int"; }
|
||||
std::string overload_smartbyval(SwigBoost::intrusive_ptr<Klass> k) { return "smartbyval"; }
|
||||
|
||||
std::string overload_smartbyref(int i) { return "int"; }
|
||||
std::string overload_smartbyref(SwigBoost::intrusive_ptr<Klass> &k) { return "smartbyref"; }
|
||||
|
||||
std::string overload_smartbyptr(int i) { return "int"; }
|
||||
std::string overload_smartbyptr(SwigBoost::intrusive_ptr<Klass> *k) { return "smartbyptr"; }
|
||||
|
||||
std::string overload_smartbyptrref(int i) { return "int"; }
|
||||
std::string overload_smartbyptrref(SwigBoost::intrusive_ptr<Klass> *&k) { return "smartbyptrref"; }
|
||||
|
||||
} // namespace Space
|
||||
|
||||
%}
|
||||
%{
|
||||
boost::detail::atomic_count Space::Klass::total_count(0);
|
||||
boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
|
||||
boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
|
||||
boost::detail::atomic_count Space::KlassDerived::total_count(0);
|
||||
boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
|
||||
%}
|
||||
|
||||
// Member variables
|
||||
|
||||
%inline %{
|
||||
struct MemberVariables {
|
||||
MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr<Space::Klass>()), SmartMemberReference(*(new SwigBoost::intrusive_ptr<Space::Klass>())), MemberPointer(0), MemberReference(MemberValue) {}
|
||||
virtual ~MemberVariables() {
|
||||
delete SmartMemberPointer;
|
||||
delete &SmartMemberReference;
|
||||
}
|
||||
SwigBoost::intrusive_ptr<Space::Klass> SmartMemberValue;
|
||||
SwigBoost::intrusive_ptr<Space::Klass> * SmartMemberPointer;
|
||||
SwigBoost::intrusive_ptr<Space::Klass> & SmartMemberReference;
|
||||
Space::Klass MemberValue;
|
||||
Space::Klass * MemberPointer;
|
||||
Space::Klass & MemberReference;
|
||||
};
|
||||
|
||||
// Global variables
|
||||
SwigBoost::intrusive_ptr<Space::Klass> GlobalSmartValue;
|
||||
Space::Klass GlobalValue;
|
||||
Space::Klass * GlobalPointer = 0;
|
||||
Space::Klass & GlobalReference = GlobalValue;
|
||||
|
||||
%}
|
||||
|
||||
#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
// Note: %template after the intrusive_ptr typemaps
|
||||
%intrusive_ptr(Base<int, double>)
|
||||
%intrusive_ptr(Pair<int, double>)
|
||||
|
||||
#endif
|
||||
|
||||
// Templates
|
||||
%inline %{
|
||||
template <class T1, class T2> struct Base {
|
||||
Space::Klass klassBase;
|
||||
T1 baseVal1;
|
||||
T2 baseVal2;
|
||||
Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
|
||||
virtual std::string getValue() const { return "Base<>"; };
|
||||
mutable int count;
|
||||
void addref(void) const { count++; }
|
||||
void release(void) const { if (--count == 0) delete this; }
|
||||
int use_count(void) const { return count; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(BaseIntDouble) Base<int, double>;
|
||||
|
||||
%inline %{
|
||||
template <class T1, class T2> struct Pair : Base<T1, T2> {
|
||||
Space::Klass klassPair;
|
||||
T1 val1;
|
||||
T2 val2;
|
||||
Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
|
||||
virtual std::string getValue() const { return "Pair<>"; };
|
||||
};
|
||||
|
||||
Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
|
||||
SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
|
||||
|
||||
long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
long use_count(const SwigBoost::shared_ptr<Space::KlassDerived>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
long use_count(const SwigBoost::shared_ptr<Space::KlassDerivedDerived>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
%}
|
||||
|
||||
%template(PairIntDouble) Pair<int, double>;
|
||||
|
||||
// For counting the instances of intrusive_ptr (all of which are created on the heap)
|
||||
// intrusive_ptr_wrapper_count() gives overall count
|
||||
%inline %{
|
||||
namespace SwigBoost {
|
||||
const int NOT_COUNTING = -123456;
|
||||
int intrusive_ptr_wrapper_count() {
|
||||
#ifdef INTRUSIVE_PTR_WRAPPER
|
||||
return SwigBoost::IntrusivePtrWrapper::getTotalCount();
|
||||
#else
|
||||
return NOT_COUNTING;
|
||||
#endif
|
||||
}
|
||||
#ifdef INTRUSIVE_PTR_WRAPPER
|
||||
template<> std::string show_message(boost::intrusive_ptr<Space::Klass >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "Klass: " + (*t)->getValue();
|
||||
else
|
||||
return "Klass: NULL";
|
||||
}
|
||||
template<> std::string show_message(boost::intrusive_ptr<const Space::Klass >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "Klass: " + (*t)->getValue();
|
||||
else
|
||||
return "Klass: NULL";
|
||||
}
|
||||
template<> std::string show_message(boost::intrusive_ptr<Space::KlassDerived >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "KlassDerived: " + (*t)->getValue();
|
||||
else
|
||||
return "KlassDerived: NULL";
|
||||
}
|
||||
template<> std::string show_message(boost::intrusive_ptr<const Space::KlassDerived >*t) {
|
||||
if (!t)
|
||||
return "null intrusive_ptr!!!";
|
||||
if (*t)
|
||||
return "KlassDerived: " + (*t)->getValue();
|
||||
else
|
||||
return "KlassDerived: NULL";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
25
Examples/test-suite/li_std_except_as_class.i
Normal file
25
Examples/test-suite/li_std_except_as_class.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* File : li_std_except_as_class.i */
|
||||
%module li_std_except_as_class
|
||||
|
||||
/* NOTE: SF bug 1295:
|
||||
* if there were also functions throwing 'std::logic_error' and
|
||||
* 'std::exception' then the bug would not be fully replicated */
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
%}
|
||||
|
||||
%{
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
void test_domain_error() throw(std::domain_error)
|
||||
{ throw std::domain_error("std::domain_error"); }
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
#define SWIG_STD_EXCEPTIONS_AS_CLASSES
|
||||
%include <std_except.i>
|
||||
void test_domain_error() throw(std::domain_error)
|
||||
{ throw std::domain_error("std::domain_error"); }
|
||||
21
Examples/test-suite/li_std_pair_using.i
Normal file
21
Examples/test-suite/li_std_pair_using.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%module li_std_pair_using
|
||||
|
||||
%include<stl.i>
|
||||
using std::pair;
|
||||
|
||||
%template(StringStringPair) pair<std::string, std::string>;
|
||||
|
||||
%inline %{
|
||||
typedef int Integer;
|
||||
using std::string;
|
||||
%}
|
||||
|
||||
%template(StringIntPair) pair<string, int>;
|
||||
|
||||
%inline %{
|
||||
typedef std::string String;
|
||||
typedef string Streeng;
|
||||
std::pair<String, Streeng> bounce(std::pair<std::string, string> p) {
|
||||
return p;
|
||||
}
|
||||
%}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue