Revert rev 11187 "Merged with recent changes from trunk."

This reverts commit c595e4d90ebfd63eb55430c735bb121cf690bd59.

Conflicts:

	Source/Modules/c.cxx

From: William S Fulton <wsf@fultondesigns.co.uk>

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@13033 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-05-06 01:13:16 +00:00
commit d6b81eb831
703 changed files with 9266 additions and 21128 deletions

View file

@ -2,10 +2,10 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) D; /* C#, Java, Php4 multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */
%inline %{
#if defined(_MSC_VER)

View file

@ -9,75 +9,116 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
# these cpp tests generate warnings/errors when compiling
# the wrapper .cxx file.
CPP_TEST_BROKEN_CXX =
# the error is wrap:action code generated by swig. \
# error: can't convert [std::string] 'b' to 'bool' \
# might just need a bool overload op for std::string. \
global_vars \
# same as w/ global_vars but with more errors in cxx file \
naturalvar \
# these cpp tests aren't working. Fix 'em
# need to further separate these into tests requiring
# std libraries, or the $ldestructor problem.
CPP_TEST_BROKEN_ACL = \
array_member \
char_strings \
class_ignore \
constant_pointers \
contract \
allprotected \
# 'throws' typemap entries. \
cplusplus_throw \
# 'throws' typemap entries. \
cpp_basic \
cpp_enum \
cpp_typedef \
default_constructor \
default_args \
# missing typemaps. suspect module support needed \
dynamic_cast \
enum_thorough \
extend_variable \
# cdata.i support needed \
global_vars \
import_nomodule \
kind \
li_carrays \
li_cdata \
# warning generated. otherwise all good. \
li_windows \
namespace_class \
namespace_spaces \
naturalvar \
operator_overload \
# std_common.i support \
overload_simple \
register_par \
sizet \
# std_vector.i support. \
smart_pointer_extend \
smart_pointer_namespace \
template \
template_classes \
template_default \
# *** line 31. can't copy typemap?? \
template_default_inherit \
template_enum \
template_explicit \
template_extend_overload \
template_ns \
template_ns4 \
template_ns_enum \
template_rename \
template_retvalue \
template_static \
template_tbase_template \
template_typedef \
template_typedef_cplx \
template_typedef_cplx2 \
template_typedef_cplx3 \
template_typedef_cplx4 \
template_typedef_cplx5 \
template_typedef_ns \
template_typedef_rec \
threads \
typedef_array_member \
typedef_sizet \
typemap_namespace \
union_scope \
using_pointers \
valuewrapper_opaque \
varargs \
virtual_poly \
voidtest \
wrapmacro
# these aren't working due to longlong support. (low hanging fruit)
CPP_TEST_BROKEN_LONGLONG = \
arrays_dimensionless \
arrays_global \
arrays_global_twodim \
li_stdint \
li_typemaps \
li_windows \
long_long_apply \
mixed_types \
primitive_ref \
reference_global_vars \
template_default_arg
# These are currently unsupported.
CPP_TEST_CASES_ACL_UNSUPPORTED = \
# contract support \
aggregate \
# directors support \
apply_signed_char \
# contract support \
contract \
director_abstract \
director_basic \
director_constructor \
director_detect \
director_default \
director_enum \
director_exception \
director_frob \
director_finalizer \
director_nested \
director_protected \
director_redefined \
director_unroll \
director_using \
director_wombat \
exception_order \
# 'throws' typemap support \
extern_throws \
throw_exception \
using_pointers \
throw_exception
C_TEST_CASES_ACL_BROKEN = \
# 'cdate.i' module support \
arrays \
enums \
extern_declaration \
immutable \
integers \
li_cdata \
# adding an existing type defnition... \
typedef_struct \
# swigrun.swg support. \
typemap_subst
C_TEST_BROKEN_LONGLONG = \
@ -87,9 +128,11 @@ C_TEST_BROKEN_LONGLONG = \
# std lib support hasn't been done yet.
SKIP_CPP_STD_CASES = Yes
include $(srcdir)/../common.mk
C_TEST_CASES =
# SWIGOPT += -debug-module 4
CPP_TEST_CASES =
include $(srcdir)/../common.mk
# Rules for the different types of tests
%.cpptest:
@ -114,8 +157,9 @@ run_testcase = \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
# Clean: (does nothing, we dont generate extra allegrocl code)
%.clean:
@rm -f $*.cl
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean

View file

@ -26,26 +26,14 @@ UVW Bar::static_member_variable;
struct XYZ {
};
// The operator& trick doesn't work for SWIG/PHP because the generated code
// takes the address of the variable in the code in the "vinit" section.
#ifdef SWIGPHP
%{
struct XYZ {
void foo() {}
private:
XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
XYZ* operator&(); // prevent dereferencing used in normally generated get method
};
%}
#else
%{
struct XYZ {
void foo() {}
private:
XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
XYZ* operator&(); // prevent dereferencing used in normally generated get method
};
%}
#endif
#if defined(SWIGUTL)
%exception {
/*

View file

@ -34,8 +34,6 @@ C_CPP_TEST_BROKEN = \
li_windows \
long_long_apply
INTERFACEDIR = ../../
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -9,12 +9,6 @@ below.
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
#ifdef SWIG_ALLEGRO_CL
%{
#include <stdio.h>
%}
#endif
%{
#define OTHERLAND_MSG "Little message from the safe world."
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."

View file

@ -19,7 +19,7 @@ SKIP_CPP_STD_CASES = Yes
CPP_TEST_CASES += li_std_string
EXTRA_TEST_CASES += chicken_ext_test.externaltest
EXTRA_TEST_CASES += ext_test.externaltest
include $(srcdir)/../common.mk

View file

@ -1,4 +1,4 @@
%module chicken_ext_test
%module ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{

View file

@ -1,4 +1,4 @@
(load "chicken_ext_test.so")
(load "ext_test.so")
(define a (test-create))

View file

@ -59,12 +59,11 @@ CXXSRCS =
CSRCS =
TARGETPREFIX =
TARGETSUFFIX =
SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
SWIGOPT = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -DSWIG_NOEXTRA_QUALIFICATION
INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
LIBS = -L.
LIBPREFIX = lib
ACTION = check
INTERFACEDIR = ../
#
# Please keep test cases in alphabetical order.
@ -78,9 +77,8 @@ CPP_TEST_BROKEN += \
cpp_broken \
exception_partial_info \
extend_variable \
li_std_vector_ptr \
namespace_union \
nested_struct \
nested_comment \
overload_complicated \
template_default_pointer \
template_expr
@ -167,7 +165,6 @@ CPP_TEST_CASES += \
director_overload \
director_primitives \
director_protected \
director_protected_overloaded \
director_redefined \
director_thread \
director_unroll \
@ -195,7 +192,6 @@ CPP_TEST_CASES += \
fragments \
friends \
fvirtual \
global_namespace \
global_ns_arg \
global_vars \
grouping \
@ -207,7 +203,6 @@ CPP_TEST_CASES += \
inherit_target_language \
inherit_void_arg \
inline_initializer \
insert_directive \
keyword_rename \
kind \
langobj \
@ -239,12 +234,10 @@ CPP_TEST_CASES += \
namespace_typemap \
namespace_virtual_method \
naturalvar \
nested_comment \
newobject1 \
null_pointer \
operator_overload \
operator_overload_break \
operbool \
ordering \
overload_copy \
overload_extend \
@ -267,7 +260,6 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
rename_strip_encoder \
restrict_cplusplus \
return_const_value \
return_value_scope \
@ -412,7 +404,6 @@ CPP_STD_TEST_CASES += \
template_typedef_fnc \
template_type_namespace \
template_opaque
# li_std_list
ifndef SKIP_CPP_STD_CASES
@ -449,13 +440,11 @@ C_TEST_CASES += \
overload_extendc \
preproc \
ret_by_value \
simple_array \
sizeof_pointer \
sneaky1 \
struct_rename \
typedef_struct \
typemap_subst \
union_parameter \
unions
@ -501,14 +490,14 @@ swig_and_compile_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_c = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)
swig_and_compile_multi_cpp = \
@ -516,7 +505,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
@ -528,7 +517,7 @@ swig_and_compile_external = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_runtime = \

View file

@ -3,7 +3,7 @@
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, Php4 multiple inheritance */
#ifdef SWIGCSHARP
%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
@ -201,33 +201,3 @@ struct E {
};
%}
// Namespace
%{
namespace myNames {
class myClass
{
public:
myClass(int i) {}
};
}
%}
namespace myNames {
%contract myClass::myClass( int i ) {
require:
i > 0;
}
class myClass
{
public:
myClass(int i) {}
};
}

View file

@ -21,17 +21,12 @@ CPP_TEST_CASES = \
enum_thorough_typesafe \
exception_partial_info
CUSTOM_TEST_CASES = \
csharp_lib_arrays \
intermediary_classname
CUSTOM_TEST_CASES = intermediary_classname
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL)
INTERFACEDIR = ../../
CSHARPFLAGSSPECIAL =
# Rules for the different types of tests
%.cpptest:
@ -52,8 +47,6 @@ CSHARPFLAGSSPECIAL =
# Rules for custom tests
intermediary_classname.customtest:
$(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname"
csharp_lib_arrays.customtest:
$(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe"
# Makes a directory for the testcase if it does not exist
setup = \
@ -72,14 +65,14 @@ setup = \
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPFLAGS='-nologo -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \
$*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \
else ( \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPFLAGS='-nologo -t:module -out:$*.netmodule' \
CSHARPSRCS='*.cs' csharp_compile; ); \
fi;

View file

@ -1,70 +0,0 @@
using System;
using csharp_lib_arraysNamespace;
public class runme
{
static void Main()
{
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[ source.Length ];
csharp_lib_arrays.myArrayCopy( source, target, target.Length );
CompareArrays(source, target);
}
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[ source.Length ];
csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length );
CompareArrays(source, target);
}
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[] { 6, 7, 8, 9, 10 };
csharp_lib_arrays.myArraySwap( source, target, target.Length );
for (int i=0; i<target.Length; ++i)
target[i] += 5;
CompareArrays(source, target);
}
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[] { 6, 7, 8, 9, 10 };
csharp_lib_arrays.myArraySwapUsingFixedArrays( source, target, target.Length );
for (int i=0; i<target.Length; ++i)
target[i] += 5;
CompareArrays(source, target);
}
}
static void CompareArrays( int[] a, int[] b )
{
if (a.Length != b.Length)
throw new Exception("size mismatch");
for(int i=0; i<a.Length; ++i) {
if (a[i] != b[i]) {
Console.Error.WriteLine("a:");
PrintArray(a);
Console.Error.WriteLine("b:");
PrintArray(b);
throw new Exception("element mismatch");
}
}
}
static void PrintArray( int[] a )
{
foreach ( int i in a )
Console.Error.Write( "{0} ", i );
Console.Error.WriteLine();
}
}

View file

@ -1,74 +0,0 @@
using System;
namespace director_basicNamespace {
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
director_basic_MyFoo a = new director_basic_MyFoo();
if (a.ping() != "director_basic_MyFoo::ping()") {
throw new Exception ( "a.ping()" );
}
if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") {
throw new Exception ( "a.pong()" );
}
Foo b = new Foo();
if (b.ping() != "Foo::ping()") {
throw new Exception ( "b.ping()" );
}
if (b.pong() != "Foo::pong();Foo::ping()") {
throw new Exception ( "b.pong()" );
}
A1 a1 = new A1(1, false);
a1.Dispose();
{
MyOverriddenClass my = new MyOverriddenClass();
my.expectNull = true;
if (MyClass.call_pmethod(my, null) != null)
throw new Exception("null pointer marshalling problem");
Bar myBar = new Bar();
my.expectNull = false;
Bar myNewBar = MyClass.call_pmethod(my, myBar);
if (myNewBar == null)
throw new Exception("non-null pointer marshalling problem");
myNewBar.x = 10;
}
}
}
class director_basic_MyFoo : Foo {
public director_basic_MyFoo() : base() {
}
public override string ping() {
return "director_basic_MyFoo::ping()";
}
}
class MyOverriddenClass : MyClass {
public bool expectNull = false;
public bool nonNullReceived = false;
public override Bar pmethod(Bar b) {
if ( expectNull && (b != null) )
throw new Exception("null not received as expected");
return b;
}
}
}

View file

@ -1,78 +0,0 @@
// Ported from Python li_attribute_runme.py
using System;
using li_attributeNamespace;
public class li_attribute_runme {
public static void Main() {
A aa = new A(1,2,3);
if (aa.a != 1)
throw new ApplicationException("error");
aa.a = 3;
if (aa.a != 3)
throw new ApplicationException("error");
if (aa.b != 2)
throw new ApplicationException("error");
aa.b = 5;
if (aa.b != 5)
throw new ApplicationException("error");
if (aa.d != aa.b)
throw new ApplicationException("error");
if (aa.c != 3)
throw new ApplicationException("error");
//aa.c = 5;
//if (aa.c != 3)
// throw new ApplicationException("error");
Param_i pi = new Param_i(7);
if (pi.value != 7)
throw new ApplicationException("error");
pi.value=3;
if (pi.value != 3)
throw new ApplicationException("error");
B b = new B(aa);
if (b.a.c != 3)
throw new ApplicationException("error");
// class/struct attribute with get/set methods using return/pass by reference
MyFoo myFoo = new MyFoo();
myFoo.x = 8;
MyClass myClass = new MyClass();
myClass.Foo = myFoo;
if (myClass.Foo.x != 8)
throw new ApplicationException("error");
// class/struct attribute with get/set methods using return/pass by value
MyClassVal myClassVal = new MyClassVal();
if (myClassVal.ReadWriteFoo.x != -1)
throw new ApplicationException("error");
if (myClassVal.ReadOnlyFoo.x != -1)
throw new ApplicationException("error");
myClassVal.ReadWriteFoo = myFoo;
if (myClassVal.ReadWriteFoo.x != 8)
throw new ApplicationException("error");
if (myClassVal.ReadOnlyFoo.x != 8)
throw new ApplicationException("error");
// string attribute with get/set methods using return/pass by value
MyStringyClass myStringClass = new MyStringyClass("initial string");
if (myStringClass.ReadWriteString != "initial string")
throw new ApplicationException("error");
if (myStringClass.ReadOnlyString != "initial string")
throw new ApplicationException("error");
myStringClass.ReadWriteString = "changed string";
if (myStringClass.ReadWriteString != "changed string")
throw new ApplicationException("error");
if (myStringClass.ReadOnlyString != "changed string")
throw new ApplicationException("error");
}
}

View file

@ -345,16 +345,6 @@ public class runme
verifyCount(1, kret);
}
// 3rd derived class
{
Klass k = new Klass3rdDerived("me oh my");
String val = k.getValue();
verifyValue("me oh my-3rdDerived", val);
verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
val = li_boost_shared_ptr.test3rdupcast(k);
verifyValue("me oh my-3rdDerived", val);
verifyCount(3, k);
}
////////////////////////////////// Member variables ////////////////////////////////////////
// smart pointer by value

View file

@ -82,17 +82,14 @@ public class li_std_vector_runme {
} catch (ArgumentException) {
}
}
#if SWIG_DOTNET_1
{
// runtime check that 2D arrays fail
double[,] outputarray = new double[collectionSize,collectionSize];
try {
vect.CopyTo(outputarray);
throw new Exception("CopyTo (5a) test failed");
throw new Exception("CopyTo (5) test failed");
} catch (ArgumentException) {
}
}
#endif
{
StructVector inputvector = new StructVector();
int arrayLen = 10;
@ -157,9 +154,6 @@ public class li_std_vector_runme {
throw new Exception("ICollection constructor null test failed");
} catch (ArgumentNullException) {
}
{
myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
}
// IndexOf() test
for (int i=0; i<collectionSize; i++) {
@ -193,22 +187,11 @@ public class li_std_vector_runme {
throw new Exception("Repeat count test failed");
// Also tests enumerator
{
System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
if ((double)myEnumerator.Current != 77.7)
throw new Exception("Repeat (1) test failed");
}
System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
if ((double)myEnumerator.Current != 77.7)
throw new Exception("Repeat test failed");
}
#if !SWIG_DOTNET_1
{
System.Collections.Generic.IEnumerator<double> myEnumerator = dv.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
if (myEnumerator.Current != 77.7)
throw new Exception("Repeat (2) test failed");
}
}
#endif
}
{
@ -533,13 +516,6 @@ public class li_std_vector_runme {
li_std_vector.halve_in_place(dvec);
}
// Dispose()
{
using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } )
using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) {
}
}
// More wrapped methods
{
RealVector v0 = li_std_vector.vecreal(new RealVector());

View file

@ -1,61 +0,0 @@
%module csharp_lib_arrays
%include "arrays_csharp.i"
%apply int INPUT[] { int* sourceArray }
%apply int OUTPUT[] { int* targetArray }
%apply int INOUT[] { int* array1 }
%apply int INOUT[] { int* array2 }
%inline %{
/* copy the contents of the first array to the second */
void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
int i;
for ( i = 0; i < nitems; i++ ) {
targetArray[ i ] = sourceArray[ i ];
}
}
/* swap the contents of the two arrays */
void myArraySwap( int* array1, int* array2, int nitems ) {
int i, temp;
for ( i = 0; i < nitems; i++ ) {
temp = array1[ i ];
array1[ i ] = array2[ i ];
array2[ i ] = temp;
}
}
%}
%clear int* sourceArray;
%clear int* targetArray;
%clear int* array1;
%clear int* array2;
// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
%csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe";
%csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe";
%apply int FIXED[] { int* sourceArray }
%apply int FIXED[] { int* targetArray }
%inline %{
void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
myArrayCopy(sourceArray, targetArray, nitems);
}
%}
%apply int FIXED[] { int* array1 }
%apply int FIXED[] { int* array2 }
%inline %{
void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
myArraySwap(array1, array2, nitems);
}
%}

View file

@ -1,6 +1,6 @@
%module csharp_prepost
// Test the pre, post, terminate and cshin attributes for csin typemaps
// Test the pre, post and cshin attributes for csin typemaps
%include "std_vector.i"
@ -88,102 +88,3 @@ public:
};
%}
// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html)
%typemap(cstype) const CDate& "System.DateTime"
%typemap(csin,
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
) const CDate &
"$csclassname.getCPtr(temp$csinput)"
%typemap(cstype) CDate& "out System.DateTime"
%typemap(csin,
pre=" CDate temp$csinput = new CDate();",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
cshin="out $csinput"
) CDate &
"$csclassname.getCPtr(temp$csinput)"
%inline %{
class CDate {
public:
CDate();
CDate(int year, int month, int day);
int getYear();
int getMonth();
int getDay();
private:
int m_year;
int m_month;
int m_day;
};
struct Action {
int doSomething(const CDate &dateIn, CDate &dateOut);
Action(const CDate &dateIn, CDate& dateOut);
};
%}
%{
Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;}
int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; }
CDate::CDate() : m_year(0), m_month(0), m_day(0) {}
CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {}
int CDate::getYear() { return m_year; }
int CDate::getMonth() { return m_month; }
int CDate::getDay() { return m_day; }
%}
%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"
%typemap(csin,
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
cshin="ref $csinput"
) CDate *
"$csclassname.getCPtr(temp$csinput)"
%inline %{
void addYears(CDate *pDate, int years) {
*pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay());
}
%}
%typemap(csin,
pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
terminator=" } // terminate temp$csinput using block",
cshin="ref $csinput"
) CDate *
"$csclassname.getCPtr(temp$csinput)"
%inline %{
void subtractYears(CDate *pDate, int years) {
*pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
}
%}
%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
/* csvarin typemap code */
set {
CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);
$imcall;$excode
} %}
%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
/* csvarout typemap code */
get {
IntPtr cPtr = $imcall;
CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
0, 0, 0);
} %}
%inline %{
CDate ImportantDate = CDate(1999, 12, 31);
%}

View file

@ -5,11 +5,11 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) EB; /* C#, Java, Php4 multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) AD; /* C#, Java, Php4 multiple inheritance */
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */

View file

@ -112,14 +112,12 @@ public:
return vmethod(b);
}
static MyClass *get_self(MyClass *c)
{
return c;
}
static Bar * call_pmethod(MyClass *myclass, Bar *b) {
return myclass->pmethod(b);
}
};
template<class T>

0
Examples/test-suite/director_classic.i Normal file → Executable file
View file

0
Examples/test-suite/director_ignore.i Normal file → Executable file
View file

View file

@ -1,21 +0,0 @@
%module(directors="1",dirprot="1") director_protected_overloaded
%director IDataObserver;
%director DerivedDataObserver;
// protected overloaded methods
%inline %{
class IDataObserver
{
public:
virtual ~IDataObserver(){}
protected:
virtual void notoverloaded() = 0;
virtual void isoverloaded() = 0;
virtual void isoverloaded(int i) = 0;
virtual void isoverloaded(int i, double d) = 0;
};
class DerivedDataObserver : public IDataObserver {
};
%}

View file

@ -13,7 +13,6 @@
#include <process.h>
#else
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#endif
@ -28,8 +27,6 @@ extern "C" {
void* working(void* t);
pthread_t thread;
#endif
static int thread_terminate = 0;
}
%}
@ -54,15 +51,6 @@ extern "C" {
virtual ~Foo() {
}
void stop() {
thread_terminate = 1;
%#ifdef _WIN32
/*TODO(bhy) what to do for win32? */
%#else
pthread_join(thread, NULL);
%#endif
}
void run() {
%#ifdef _WIN32
_beginthreadex(NULL,0,working,this,0,&thread_id);
@ -87,15 +75,10 @@ extern "C" {
#endif
{
Foo* f = static_cast<Foo*>(t);
while ( ! thread_terminate ) {
while (1) {
MilliSecondSleep(50);
f->do_foo();
}
#ifdef _WIN32
/* TODO(bhy) what's the corresponding of pthread_exit in win32? */
#else
pthread_exit(0);
#endif
return 0;
}
}

View file

@ -6,7 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance
%inline %{

View file

@ -6,7 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance
%inline %{
namespace Blah {

View file

@ -6,7 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance
%inline %{

View file

@ -162,20 +162,3 @@ namespace Space {
}
%}
// Test 8 conversion operators
%rename(opbool) operator bool;
%rename(opuint) operator unsigned int;
%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */";
%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */";
%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */";
%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/";
%inline %{
class ConversionOperators {
public:
operator bool() { return false; }
operator unsigned int() { return 0; }
};
%}

View file

@ -1,60 +0,0 @@
%module global_namespace
// classes
%inline %{
class Klass1 {};
class Klass2 {};
class Klass3 {};
class Klass4 {};
class Klass5 {};
class Klass6 {};
class Klass7 {};
struct KlassMethods {
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {}
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {}
};
%}
%inline %{
namespace Space {
class XYZ1 {};
class XYZ2 {};
class XYZ3 {};
class XYZ4 {};
class XYZ5 {};
class XYZ6 {};
class XYZ7 {};
}
struct XYZMethods {
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {}
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {}
};
%}
//enums
%inline %{
enum AnEnum1 { anenum1 };
enum AnEnum2 { anenum2 };
enum AnEnum3 { anenum3 };
struct AnEnumMethods {
static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {}
static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {}
};
%}
%inline %{
namespace Space {
enum TheEnum1 { theenum1 };
enum TheEnum2 { theenum2 };
enum TheEnum3 { theenum3 };
struct TheEnumMethods {
static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {}
static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {}
};
}
%}

View file

@ -36,7 +36,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
SWIGOPT=" -noruntime "; \
done

View file

@ -2,7 +2,7 @@
# Makefile for guile test-suite (with SCM API)
#######################################################################
EXTRA_TEST_CASES += guilescm_ext_test.externaltest
EXTRA_TEST_CASES += ext_test.externaltest
include ../guile/Makefile
@ -31,7 +31,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done

View file

@ -1,4 +1,4 @@
%module guilescm_ext_test
%module ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{

View file

@ -1,4 +1,4 @@
(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so"))
(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so"))
; This is a test for SF Bug 1573892
; If IsPointer is called before TypeQuery, the test-is-pointer will fail

View file

@ -37,9 +37,3 @@ public:
#endif
%template(VectFlow) std::vector<Flow>;
%inline %{
std::vector<Flow> inandout(std::vector<Flow> v) {
return v;
}
%}

View file

@ -3,9 +3,6 @@
#include "import_nomodule.h"
%}
// For Python
%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive.
%import "import_nomodule.h"
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP)

View file

@ -34,14 +34,9 @@
*/
#if 0
%import "imports_a.i"
%import "imports_a.i"
#else
# if 0
// Test Warning 401 (Python only)
%import "imports_a.h"
# else
%import(module="imports_a") "imports_a.h"
# endif
%import(module="imports_a") "imports_a.h"
#endif
%include "imports_b.h"

View file

@ -1,38 +0,0 @@
%module insert_directive
// check %insert and the order of each insert section is correct
%begin %{
// %inserted code %begin
int inserted_begin(int i) { return i; }
%}
%runtime %{
// %inserted code %runtime
int inserted_runtime(int i) { return inserted_begin(i); }
%}
%{
// %inserted code %header
int inserted_header1(int i) { return inserted_runtime(i); }
%}
%header %{
// %inserted code %header
int inserted_header2(int i) { return inserted_header1(i); }
%}
%{
// %inserted code %header
int inserted_header3(int i) { return inserted_header2(i); }
%}
%wrapper %{
// %inserted code %wrapper
int inserted_wrapper(int i) { return inserted_header3(i); }
%}
%init %{
// %inserted code %init
int inserted_init_value = inserted_wrapper(0);
%}

View file

@ -18,7 +18,6 @@
"new $javaclassname($jniinput, false)/*javadirectorin*/"
%typemap(out, throws="IllegalAccessException/*out Base&*/") Base& {
// XYZ& typemap out
$result = 0; // remove unused variable warning
}
%inline %{

View file

@ -32,13 +32,11 @@ CPP_TEST_CASES = \
java_throws \
java_typemaps_proxy \
java_typemaps_typewrapper
# li_boost_intrusive_ptr
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -package $*
INTERFACEDIR = ../../
# Rules for the different types of tests
%.cpptest:
@ -74,7 +72,7 @@ run_testcase = \
(cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*\_runme;) \
fi;
# Clean: remove testcase directories

0
Examples/test-suite/java/allprotected_runme.java Normal file → Executable file
View file

View file

@ -14,43 +14,28 @@ public class director_basic_runme {
public static void main(String argv[]) {
director_basic_MyFoo a = new director_basic_MyFoo();
director_basic_MyFoo a = new director_basic_MyFoo();
if (!a.ping().equals("director_basic_MyFoo::ping()")) {
throw new RuntimeException ( "a.ping()" );
}
if (!a.ping().equals("director_basic_MyFoo::ping()")) {
throw new RuntimeException ( "a.ping()" );
}
if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) {
throw new RuntimeException ( "a.pong()" );
}
if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) {
throw new RuntimeException ( "a.pong()" );
}
Foo b = new Foo();
Foo b = new Foo();
if (!b.ping().equals("Foo::ping()")) {
throw new RuntimeException ( "b.ping()" );
}
if (!b.ping().equals("Foo::ping()")) {
throw new RuntimeException ( "b.ping()" );
}
if (!b.pong().equals("Foo::pong();Foo::ping()")) {
throw new RuntimeException ( "b.pong()" );
}
if (!b.pong().equals("Foo::pong();Foo::ping()")) {
throw new RuntimeException ( "b.pong()" );
}
A1 a1 = new A1(1, false);
a1.delete();
{
MyOverriddenClass my = new MyOverriddenClass();
my.expectNull = true;
if (MyClass.call_pmethod(my, null) != null)
throw new RuntimeException("null pointer marshalling problem");
Bar myBar = new Bar();
my.expectNull = false;
Bar myNewBar = MyClass.call_pmethod(my, myBar);
if (myNewBar == null)
throw new RuntimeException("non-null pointer marshalling problem");
myNewBar.setX(10);
}
A1 a1 = new A1(1, false);
a1.delete();
}
}
@ -60,13 +45,3 @@ class director_basic_MyFoo extends Foo {
}
}
class MyOverriddenClass extends MyClass {
public boolean expectNull = false;
public boolean nonNullReceived = false;
public Bar pmethod(Bar b) {
if ( expectNull && (b != null) )
throw new RuntimeException("null not received as expected");
return b;
}
}

0
Examples/test-suite/java/director_classic_runme.java Normal file → Executable file
View file

0
Examples/test-suite/java/director_ignore_runme.java Normal file → Executable file
View file

View file

@ -1,25 +0,0 @@
import global_namespace.*;
public class global_namespace_runme {
static {
try {
System.loadLibrary("global_namespace");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
}
}

View file

@ -94,20 +94,5 @@ public class java_throws_runme {
if (!pass)
throw new RuntimeException("Test 7 failed");
// Test %nojavaexception
NoExceptTest net = new NoExceptTest();
pass = false;
try {
net.exceptionPlease();
pass = true;
}
catch (MyException e) {}
if (!pass)
throw new RuntimeException("Test 8 failed");
net.noExceptionPlease();
}
}

View file

@ -1,701 +0,0 @@
import li_boost_intrusive_ptr.*;
public class li_boost_intrusive_ptr_runme {
static {
try {
System.loadLibrary("li_boost_intrusive_ptr");
} 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);
}
}
// Debugging flag
public final static boolean debug = false;
public static void main(String argv[])
{
if (debug)
System.out.println("Started");
li_boost_intrusive_ptr.setDebug_shared(debug);
// Change loop count to run for a long time to monitor memory
final int loopCount = 5000; //5000;
for (int i=0; i<loopCount; i++) {
new li_boost_intrusive_ptr_runme().runtest();
System.gc();
System.runFinalization();
try {
if (i%100 == 0) {
java.lang.Thread.sleep(1); // give some time to the lower priority finalizer thread
}
} catch (java.lang.InterruptedException e) {
}
}
if (debug)
System.out.println("Nearly finished");
int countdown = 50;
while (true) {
System.gc();
System.runFinalization();
try {
java.lang.Thread.sleep(100);
} catch (java.lang.InterruptedException e) {
}
if (--countdown == 0)
break;
if (Klass.getTotal_count() == 1 && KlassWithoutRefCount.getTotal_count() == 0 &&
li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() == 0 &&
KlassDerived.getTotal_count() == 0 && KlassDerivedDerived.getTotal_count() == 1)
// Expect 1 Klass instance - the one global variable (GlobalValue)
break;
};
if (Klass.getTotal_count() != 1)
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
if (KlassWithoutRefCount.getTotal_count() != 0)
throw new RuntimeException("KlassWithoutRefCount.total_count=" + KlassWithoutRefCount.getTotal_count());
if (li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() != 0)
throw new RuntimeException("IgnoredRefCountingBase.total_count=" + li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count());
if (KlassDerived.getTotal_count() != 0)
throw new RuntimeException("KlassDerived.total_count=" + KlassDerived.getTotal_count());
if (KlassDerivedDerived.getTotal_count() != 0)
throw new RuntimeException("KlassDerivedDerived.total_count=" + KlassDerivedDerived.getTotal_count());
int wrapper_count = li_boost_intrusive_ptr.intrusive_ptr_wrapper_count();
if (wrapper_count != li_boost_intrusive_ptr.getNOT_COUNTING())
if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
throw new RuntimeException("shared_ptr wrapper count=" + wrapper_count);
if (debug)
System.out.println("Finished");
}
private void runtest() {
// simple shared_ptr usage - created in C++
{
Klass k = new Klass("me oh my");
String val = k.getValue();
verifyValue("me oh my", val);
verifyCount(1, k);
}
// simple shared_ptr usage - not created in C++
{
Klass k = li_boost_intrusive_ptr.factorycreate();
String val = k.getValue();
verifyValue("factorycreate", val);
verifyCount(1, k);
}
// pass by shared_ptr
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.smartpointertest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointertest", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// pass by shared_ptr pointer
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.smartpointerpointertest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerpointertest", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// pass by shared_ptr reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.smartpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerreftest", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// pass by shared_ptr pointer reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.smartpointerpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// const pass by shared_ptr
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.constsmartpointertest(k);
String val = kret.getValue();
verifyValue("me oh my", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// const pass by shared_ptr pointer
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.constsmartpointerpointertest(k);
String val = kret.getValue();
verifyValue("me oh my", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// const pass by shared_ptr reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.constsmartpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
verifyCount(1, kret);
verifyIntrusiveCount(2, kret);
}
// pass by value
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.valuetest(k);
String val = kret.getValue();
verifyValue("me oh my valuetest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// pass by pointer
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.pointertest(k);
String val = kret.getValue();
verifyValue("me oh my pointertest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// pass by reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.reftest(k);
String val = kret.getValue();
verifyValue("me oh my reftest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// pass by pointer reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_intrusive_ptr.pointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my pointerreftest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// null tests
{
Klass k = null;
if (li_boost_intrusive_ptr.smartpointertest(k) != null)
throw new RuntimeException("return was not null");
if (li_boost_intrusive_ptr.smartpointerpointertest(k) != null)
throw new RuntimeException("return was not null");
if (li_boost_intrusive_ptr.smartpointerreftest(k) != null)
throw new RuntimeException("return was not null");
if (li_boost_intrusive_ptr.smartpointerpointerreftest(k) != null)
throw new RuntimeException("return was not null");
if (!li_boost_intrusive_ptr.nullsmartpointerpointertest(null).equals("null pointer"))
throw new RuntimeException("not null smartpointer pointer");
try { li_boost_intrusive_ptr.valuetest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
if (li_boost_intrusive_ptr.pointertest(k) != null)
throw new RuntimeException("return was not null");
try { li_boost_intrusive_ptr.reftest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
}
// $owner
{
Klass k = li_boost_intrusive_ptr.pointerownertest();
String val = k.getValue();
verifyValue("pointerownertest", val);
verifyCount(1, k);
}
{
Klass k = li_boost_intrusive_ptr.smartpointerpointerownertest();
String val = k.getValue();
verifyValue("smartpointerpointerownertest", val);
verifyCount(1, k);
}
////////////////////////////////// Derived classes ////////////////////////////////////////
// derived access to base class which cannot be wrapped in an intrusive_ptr
{
KlassWithoutRefCount k = new KlassDerived("me oh my");
verifyValue("this class cannot be wrapped by intrusive_ptrs but we can still use it", k.getSpecialValueFromUnwrappableClass());
}
// derived pass by shared_ptr
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrtest-Derived", val);
verifyIntrusiveCount(2, k);
verifyCount(2, k); // includes extra reference for upcast
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// derived pass by shared_ptr pointer
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
verifyIntrusiveCount(2, k);
verifyCount(2, k); // includes extra reference for upcast
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// derived pass by shared_ptr ref
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrreftest-Derived", val);
verifyIntrusiveCount(2, k);
verifyCount(2, k); // includes extra reference for upcast
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// derived pass by shared_ptr pointer ref
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
verifyIntrusiveCount(2, k);
verifyCount(2, k); // includes extra reference for upcast
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// derived pass by pointer
{
KlassDerived k = new KlassDerived("me oh my");
verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
verifyCount(2, kret);
String val = kret.getValue();
verifyValue("me oh my derivedpointertest-Derived", val);
verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
verifyCount(2, k); // includes extra reference for upcast
verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
verifyCount(2, kret);
}
// derived pass by ref
{
KlassDerived k = new KlassDerived("me oh my");
verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
verifyCount(2, kret);
String val = kret.getValue();
verifyValue("me oh my derivedreftest-Derived", val);
verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
verifyCount(2, k); // includes extra reference for upcast
verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
verifyCount(2, kret);
}
////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
// pass by shared_ptr (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrtest-DerivedDerived", val);
verifyIntrusiveCount(2, k);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// pass by shared_ptr pointer (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointertest-DerivedDerived", val);
verifyIntrusiveCount(2, k);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// pass by shared_ptr reference (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrreftest-DerivedDerived", val);
verifyIntrusiveCount(2, k);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// pass by shared_ptr pointer reference (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointerreftest-DerivedDerived", val);
verifyIntrusiveCount(2, k);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(2, kret);
verifyCount(2, kret);
}
// pass by value (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedvaluetest(k);
String val = kret.getValue();
verifyValue("me oh my derivedvaluetest-Derived", val); // note slicing
verifyIntrusiveCount(1, k);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(1, kret);
verifyCount(2, kret);
}
// pass by pointer (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
String val = kret.getValue();
verifyValue("me oh my derivedpointertest-DerivedDerived", val);
verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
verifyCount(2, kret);
}
// pass by ref (mixed)
{
KlassDerived k = new KlassDerivedDerived("me oh my");
KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedreftest-DerivedDerived", val);
verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
verifyCount(2, kret);
}
////////////////////////////////// Member variables ////////////////////////////////////////
// smart pointer by value
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("smart member value");
m.setSmartMemberValue(k);
String val = k.getValue();
verifyValue("smart member value", val);
verifyIntrusiveCount(2, k);
verifyCount(1, k);
Klass kmember = m.getSmartMemberValue();
val = kmember.getValue();
verifyValue("smart member value", val);
verifyIntrusiveCount(3, kmember);
verifyIntrusiveCount(3, k);
verifyCount(1, k);
verifyCount(1, kmember);
m.delete();
verifyIntrusiveCount(2, kmember);
verifyIntrusiveCount(2, k);
}
// smart pointer by pointer
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("smart member pointer");
m.setSmartMemberPointer(k);
String val = k.getValue();
verifyValue("smart member pointer", val);
verifyCount(1, k);
verifyIntrusiveCount(2, k);
Klass kmember = m.getSmartMemberPointer();
val = kmember.getValue();
verifyValue("smart member pointer", val);
verifyIntrusiveCount(3, kmember);
verifyCount(1, kmember);
verifyIntrusiveCount(3, k);
verifyCount(1, k);
m.delete();
verifyIntrusiveCount(2, kmember);
verifyCount(1, kmember);
verifyIntrusiveCount(2, k);
verifyCount(1, k);
}
// smart pointer by reference
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("smart member reference");
m.setSmartMemberReference(k);
String val = k.getValue();
verifyValue("smart member reference", val);
verifyIntrusiveCount(2, k);
verifyCount(1, k);
Klass kmember = m.getSmartMemberReference();
val = kmember.getValue();
verifyValue("smart member reference", val);
verifyIntrusiveCount(3, kmember);
verifyCount(1, kmember);
verifyIntrusiveCount(3, k);
verifyCount(1, k);
// The C++ reference refers to SmartMemberValue...
m.setSmartMemberValue(k);
Klass kmemberVal = m.getSmartMemberValue();
val = kmember.getValue();
verifyValue("smart member reference", val);
verifyIntrusiveCount(5, kmemberVal);
verifyCount(1, kmemberVal);
verifyIntrusiveCount(5, kmember);
verifyCount(1, kmember);
verifyIntrusiveCount(5, k);
verifyCount(1, k);
m.delete();
verifyIntrusiveCount(3, kmemberVal);
verifyCount(1, kmemberVal);
verifyIntrusiveCount(3, kmember);
verifyCount(1, kmember);
verifyIntrusiveCount(3, k);
verifyCount(1, k);
}
//plain by value
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("plain member value");
m.setMemberValue(k);
String val = k.getValue();
verifyValue("plain member value", val);
verifyCount(1, k);
Klass kmember = m.getMemberValue();
val = kmember.getValue();
verifyValue("plain member value", val);
verifyCount(1, kmember);
verifyCount(1, k);
m.delete();
verifyCount(1, kmember);
verifyCount(1, k);
}
//plain by pointer
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("plain member pointer");
m.setMemberPointer(k);
String val = k.getValue();
verifyValue("plain member pointer", val);
verifyCount(1, k);
Klass kmember = m.getMemberPointer();
val = kmember.getValue();
verifyValue("plain member pointer", val);
verifyCount(1, kmember);
verifyCount(1, k);
m.delete();
verifyCount(1, kmember);
verifyCount(1, k);
}
//plain by reference
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("plain member reference");
m.setMemberReference(k);
String val = k.getValue();
verifyValue("plain member reference", val);
verifyCount(1, k);
Klass kmember = m.getMemberReference();
val = kmember.getValue();
verifyValue("plain member reference", val);
verifyCount(1, kmember);
verifyCount(1, k);
m.delete();
verifyCount(1, kmember);
verifyCount(1, k);
}
//null member variables
{
MemberVariables m = new MemberVariables();
// shared_ptr by value
Klass k = m.getSmartMemberValue();
if (k != null)
throw new RuntimeException("expected null");
m.setSmartMemberValue(null);
k = m.getSmartMemberValue();
if (k != null)
throw new RuntimeException("expected null");
verifyCount(0, k);
// plain by value
try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
}
}
private void toIgnore() {
////////////////////////////////// Global variables ////////////////////////////////////////
// smart pointer
{
Klass kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
if (kglobal != null)
throw new RuntimeException("expected null");
Klass k = new Klass("smart global value");
li_boost_intrusive_ptr.setGlobalSmartValue(k);
verifyIntrusiveCount(2, k);
verifyCount(1, k);
kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
String val = kglobal.getValue();
verifyValue("smart global value", val);
verifyIntrusiveCount(3, kglobal);
verifyCount(1, kglobal);
verifyIntrusiveCount(3, k);
verifyCount(1, k);
verifyValue("smart global value", li_boost_intrusive_ptr.getGlobalSmartValue().getValue());
li_boost_intrusive_ptr.setGlobalSmartValue(null);
}
// plain value
{
Klass kglobal;
Klass k = new Klass("global value");
li_boost_intrusive_ptr.setGlobalValue(k);
verifyCount(1, k);
kglobal = li_boost_intrusive_ptr.getGlobalValue();
String val = kglobal.getValue();
verifyValue("global value", val);
verifyCount(1, kglobal);
verifyCount(1, k);
verifyValue("global value", li_boost_intrusive_ptr.getGlobalValue().getValue());
try { li_boost_intrusive_ptr.setGlobalValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
}
//plain pointer
{
Klass kglobal = li_boost_intrusive_ptr.getGlobalPointer();
if (kglobal != null)
throw new RuntimeException("expected null");
Klass k = new Klass("global pointer");
li_boost_intrusive_ptr.setGlobalPointer(k);
verifyCount(1, k);
kglobal = li_boost_intrusive_ptr.getGlobalPointer();
String val = kglobal.getValue();
verifyValue("global pointer", val);
verifyCount(1, kglobal);
verifyCount(1, k);
li_boost_intrusive_ptr.setGlobalPointer(null);
}
// plain reference
{
Klass kglobal;
Klass k = new Klass("global reference");
li_boost_intrusive_ptr.setGlobalReference(k);
verifyCount(1, k);
kglobal = li_boost_intrusive_ptr.getGlobalReference();
String val = kglobal.getValue();
verifyValue("global reference", val);
verifyCount(1, kglobal);
verifyCount(1, k);
try { li_boost_intrusive_ptr.setGlobalReference(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
}
////////////////////////////////// Templates ////////////////////////////////////////
{
PairIntDouble pid = new PairIntDouble(10, 20.2);
if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
throw new RuntimeException("Base values wrong");
if (pid.getVal1() != 10 || pid.getVal2() != 20.2)
throw new RuntimeException("Derived Values wrong");
}
}
private void verifyValue(String expected, String got) {
if (!expected.equals(got))
throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
}
private void verifyCount(int expected, Klass k) {
int got = li_boost_intrusive_ptr.use_count(k);
if (expected != got)
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
}
private void verifyCount(int expected, KlassDerived kd) {
int got = li_boost_intrusive_ptr.use_count(kd);
if (expected != got)
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
}
private void verifyCount(int expected, KlassDerivedDerived kdd) {
int got = li_boost_intrusive_ptr.use_count(kdd);
if (expected != got)
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
}
private void verifyIntrusiveCount(int expected, Klass k) {
int got = k.use_count();
if (expected != got)
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
}
private void verifyIntrusiveCount(int expected, KlassDerived kd) {
int got = kd.use_count();
if (expected != got)
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
}
private void verifyIntrusiveCount(int expected, KlassDerivedDerived kdd) {
int got = kdd.use_count();
if (expected != got)
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
}
}

View file

@ -357,16 +357,6 @@ public class li_boost_shared_ptr_runme {
verifyCount(1, kret);
}
// 3rd derived class
{
Klass k = new Klass3rdDerived("me oh my");
String val = k.getValue();
verifyValue("me oh my-3rdDerived", val);
verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
val = li_boost_shared_ptr.test3rdupcast(k);
verifyValue("me oh my-3rdDerived", val);
verifyCount(3, k);
}
////////////////////////////////// Member variables ////////////////////////////////////////
// smart pointer by value

View file

View file

@ -143,41 +143,3 @@ try {
}
%}
// Test %nojavaexception
%javaexception("MyException") %{
/* global exception handler */
try {
$action
} catch (MyException) {
jclass excep = jenv->FindClass("java_throws/MyException");
if (excep)
jenv->ThrowNew(excep, "exception message");
return $null;
}
%}
%nojavaexception *::noExceptionPlease();
%nojavaexception NoExceptTest::NoExceptTest();
// Need to handle the checked exception in NoExceptTest.delete()
%typemap(javafinalize) SWIGTYPE %{
protected void finalize() {
try {
delete();
} catch (MyException e) {
throw new RuntimeException(e);
}
}
%}
%inline %{
struct NoExceptTest {
unsigned int noExceptionPlease() { return 123; }
unsigned int exceptionPlease() { return 456; }
~NoExceptTest() {}
};
%}
// Turn global exceptions off (for the implicit destructors/constructors)
%nojavaexception;

View file

@ -93,11 +93,9 @@ struct MyFoo; // %attribute2 does not work with templates
%template(Param_i) Param<int>;
// class/struct attribute with get/set methods using return/pass by reference
%attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo);
%inline %{
struct MyFoo {
MyFoo() : x(-1) {}
int x;
};
class MyClass {
@ -108,32 +106,3 @@ struct MyFoo; // %attribute2 does not work with templates
};
%}
// class/struct attribute with get/set methods using return/pass by value
%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo);
%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo);
%inline %{
class MyClassVal {
MyFoo foo;
public:
MyFoo GetFoo() { return foo; }
void SetFoo(MyFoo other) { foo = other; }
};
%}
// string attribute with get/set methods using return/pass by value
%include <std_string.i>
%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString);
%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString);
%inline %{
class MyStringyClass {
std::string str;
public:
MyStringyClass(const std::string &val) : str(val) {}
std::string GetString() { return str; }
void SetString(std::string other) { str = other; }
};
%}

View file

@ -1,494 +0,0 @@
// 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);
%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) || defined(SWIGPYTHON)
#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
#endif
#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
%include <boost_intrusive_ptr.i>
SWIG_INTRUSIVE_PTR(Klass, Space::Klass)
SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount)
SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived)
SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived)
//For the use_count shared_ptr functions
%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)"
#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*& pointerreftest(Klass*& 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 *&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
SWIG_INTRUSIVE_PTR(BaseIntDouble, Base<int, double>)
// Note: cannot use Base<int, double> in the macro below because of the comma in the type,
// so we use a typedef instead. Alternatively use %arg(Base<int, double>). %arg is defined in swigmacros.swg.
SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, 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; }
};
typedef Base<int, double> BaseIntDouble_t;
%}
%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
}
%}

View file

@ -43,14 +43,6 @@
%include <boost_shared_ptr.i>
SWIG_SHARED_PTR(Klass, Space::Klass)
SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived)
SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived)
SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived)
// TEMP for python
%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) {
*newmemory = SWIG_CAST_NEW_MEMORY;
return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from);
}
#endif
@ -109,13 +101,7 @@ private:
};
SwigExamples::CriticalSection Space::Klass::critical_section;
struct IgnoredMultipleInheritBase {
IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
virtual ~IgnoredMultipleInheritBase() {}
double d;
double e;
virtual void AVirtualMethod() {}
};
struct IgnoredMultipleInheritBase { virtual ~IgnoredMultipleInheritBase() {} double d; double e;};
// For most compilers, this use of multiple inheritance results in different derived and base class
// pointer values ... for some more challenging tests :)
@ -156,21 +142,7 @@ SwigBoost::shared_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::s
return kd;
}
// 3 classes in inheritance chain test
struct Klass2ndDerived : Klass {
Klass2ndDerived() : Klass() {}
Klass2ndDerived(const std::string &val) : Klass(val) {}
};
struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived {
Klass3rdDerived() : Klass2ndDerived() {}
Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {}
virtual ~Klass3rdDerived() {}
virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; }
};
std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) {
return k->getValue();
}
@ -245,14 +217,8 @@ SwigBoost::shared_ptr<Klass>* smartpointerpointerownertest() {
return new SwigBoost::shared_ptr<Klass>(new Klass("smartpointerpointerownertest"));
}
// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in
// Provide overloads for Klass and KlassDerived as some language modules, eg Python, create an extra reference in
// the marshalling if an upcast to a base class is required.
long use_count(const SwigBoost::shared_ptr<Klass3rdDerived>& sptr) {
return sptr.use_count();
}
long use_count(const SwigBoost::shared_ptr<Klass2ndDerived>& sptr) {
return sptr.use_count();
}
long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) {
return sptr.use_count();
}

View file

@ -4,7 +4,7 @@
#ifndef SWIG_CSTRING_UNIMPL
%cstring_input_binary(char *str_in, int n);
%cstring_input_binary(char *in, int n);
%cstring_bounded_output(char *out1, 512);
%cstring_chunk_output(char *out2, 64);
%cstring_bounded_mutable(char *out3, 512);
@ -22,13 +22,13 @@
%inline %{
int count(char *str_in, int n, char c) {
int count(char *in, int n, char c) {
int r = 0;
while (n > 0) {
if (*str_in == c) {
if (*in == c) {
r++;
}
str_in++;
in++;
--n;
}
return r;

View file

@ -4,7 +4,7 @@
#ifndef SWIG_CWSTRING_UNIMPL
%cwstring_input_binary(wchar_t *str_in, int n);
%cwstring_input_binary(wchar_t *in, int n);
%cwstring_bounded_output(wchar_t *out1, 512);
%cwstring_chunk_output(wchar_t *out2, 64);
%cwstring_bounded_mutable(wchar_t *out3, 512);
@ -22,13 +22,13 @@
%inline %{
int count(wchar_t *str_in, int n, wchar_t c) {
int count(wchar_t *in, int n, wchar_t c) {
int r = 0;
while (n > 0) {
if (*str_in == c) {
if (*in == c) {
r++;
}
str_in++;
in++;
--n;
}
return r;

View file

@ -10,7 +10,7 @@
*
* For example:
* swig::LANGUAGE_OBJ is GC_VALUE in Ruby
* swig::LANGUAGE_OBJ is SwigPtr_PyObject in python
* swig::LANGUAGE_OBJ is PyObject_ptr in python
*
*
*/
@ -47,15 +47,8 @@ namespace std
%template(pairiiAc) pair<int,const pair<int, A*> >;
#ifdef SWIGRUBY
%template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
%template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
#endif
#ifdef SWIGPYTHON
%template() pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
%template(pymap) map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
#endif
}

View file

@ -10,7 +10,7 @@
*
* For example:
* swig::LANGUAGE_OBJ is GC_VALUE in Ruby
* swig::LANGUAGE_OBJ is SwigPtr_PyObject in python
* swig::LANGUAGE_OBJ is PyObject_ptr in python
*
*
*/
@ -31,10 +31,4 @@
#if defined(SWIGRUBY)
%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
#endif
#if defined(SWIGPYTHON)
%template(pyset) std::set<swig::SwigPtr_PyObject>;
#endif

View file

@ -85,10 +85,8 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
%template(StructureConstPtrVector) std::vector<const Structure *>;
#endif
#if !defined(SWIGR)
%template(IntPtrVector) std::vector<int *>;
%template(IntConstPtrVector) std::vector<const int *>;
#endif
%template(StructVector) std::vector<Struct>;
%template(StructPtrVector) std::vector<Struct *>;
%template(StructConstPtrVector) std::vector<const Struct *>;

View file

@ -1,29 +0,0 @@
%module li_std_vector_ptr
%include "std_vector.i"
%template(IntPtrVector) std::vector<int *>;
%inline %{
#include <iostream>
using namespace std;
int* makeIntPtr(int v) {
return new int(v);
}
double* makeDoublePtr(double v) {
return new double(v);
}
#if 1
int** makeIntPtrPtr(int* v) {
return new int*(v);
}
#endif
void displayVector(std::vector<int *> vpi) {
cout << "displayVector..." << endl;
for (int i=0; i<vpi.size(); ++i)
cout << *vpi[i] << endl;
}
%}

View file

@ -7,7 +7,7 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe;
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) RemoteMpe;
#if defined(SWIGJAVA) || defined(SWIGCSHARP)

View file

@ -5,11 +5,11 @@ It tests basic multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, Php4 multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */
SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, Php4 multiple inheritance */
%inline %{

View file

@ -58,12 +58,13 @@ namespace std
%template(max_i) max<int>;
%inline {
/* silently rename the parameter names in csharp/java */
#ifdef SWIGR
double foo(double inparam, double out) { return 1.0; }
#else
double foo(double abstract, double out) { return 1.0; }
double foo(double in, double out) { return 1.0; }
#endif
double bar(double native, bool boolean) { return 1.0; }
}

View file

@ -75,7 +75,7 @@ namespace test {
class string_class;
#ifdef SWIGPYTHON
%typemap(in) string_class * {
$1 = new string_class(SWIG_Python_str_AsChar($input));
$1 = new string_class(PyString_AsString($input));
}
%typemap(freearg) string_class * {
delete $1;

View file

@ -18,17 +18,24 @@ in rlgc models */
char *name;
} n ;
} s2;
%}
// comment in nested struct
// bug #491476
%inline %{
struct a
{
struct {
/*struct*/
struct {
int b;
} c;
} d;
};
struct {
struct {
int a;
} a, b;
} a;
%}
// bug #909387
%inline %{
struct foo {
struct happy; // no warning
struct sad { int x; }; // warning
happy *good(); // produces good code
sad *bad(); // produces bad code
};

View file

@ -1,22 +0,0 @@
%module nested_structs
// bug #491476
%inline %{
struct {
struct {
int a;
} a, b;
} a;
%}
// bug #909387
%inline %{
struct foo {
struct happy; // no warning
struct sad { int x; }; // warning
happy *good(); // produces good code
sad *bad(); // produces bad code
};
%}

View file

@ -16,7 +16,7 @@ run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
-f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme) ; \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& ./runme) ; \
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \

View file

@ -10,9 +10,7 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
li_std_pair_extra \
li_std_string_extra \
octave_cell_deref
cell_deref
CPP_TEST_BROKEN += \
implicittest \

View file

@ -1,4 +1,4 @@
%module octave_cell_deref
%module cell_deref
%inline {
bool func(const char* s) {

View file

@ -1,4 +1,4 @@
octave_cell_deref;
cell_deref;
assert(func("hello"));
assert(func({"hello"}));

View file

@ -10,6 +10,7 @@ if (aa.a != 3)
error("aa.a = %i",aa.a)
endif
if (aa.b != 2)
error(aa.b)
endif
@ -18,6 +19,8 @@ if (aa.b != 5)
error
endif
if (aa.d != aa.b)
error
endif
@ -36,13 +39,14 @@ if (pi.value != 3)
error
endif
b = li_attribute.B(aa);
if (b.a.c != 3)
error
endif
# class/struct attribute with get/set methods using return/pass by reference
myFoo = li_attribute.MyFoo();
myFoo.x = 8;
myClass = li_attribute.MyClass();
@ -51,35 +55,3 @@ if (myClass.Foo.x != 8)
error
endif
# class/struct attribute with get/set methods using return/pass by value
myClassVal = li_attribute.MyClassVal();
if (myClassVal.ReadWriteFoo.x != -1)
error
endif
if (myClassVal.ReadOnlyFoo.x != -1)
error
endif
myClassVal.ReadWriteFoo = myFoo;
if (myClassVal.ReadWriteFoo.x != 8)
error
endif
if (myClassVal.ReadOnlyFoo.x != 8)
error
endif
# string attribute with get/set methods using return/pass by value
myStringyClass = li_attribute.MyStringyClass("initial string");
if (myStringyClass.ReadWriteString != "initial string")
error
endif
if (myStringyClass.ReadOnlyString != "initial string")
error
endif
myStringyClass.ReadWriteString = "changed string";
if (myStringyClass.ReadWriteString != "changed string")
error
endif
if (myStringyClass.ReadOnlyString != "changed string")
error
endif

View file

@ -1,4 +1,4 @@
%module li_std_pair_extra
%module li_std_pair
//
// activate the automatic comparison methods generation (==,!=,...)

View file

@ -1,69 +0,0 @@
li_std_pair_extra
p = {1,2};
p1 = li_std_pair_extra.p_inout(p);
assert(all(cell2mat(p1)==[2,1]));
p2 = li_std_pair_extra.p_inoutd(p1);
assert(all(cell2mat(p2)==[1,2]));
d1 = li_std_pair_extra.d_inout(2);
assert(d1==4);
[i,d2] = li_std_pair_extra.d_inout2(2);
assert(all([i,d2]==[1,4]));
[i,p] = li_std_pair_extra.p_inout2(p);
assert(i==1&&all([cell2mat(p)]==[2,1]));
[p3,p4] = li_std_pair_extra.p_inout3(p1,p1);
assert(all(cell2mat(p3)==[2,1]));
assert(all(cell2mat(p4)==[2,1]));
psi = li_std_pair_extra.SIPair("hello",1);
assert(psi=={"hello",1});
pci = li_std_pair_extra.CIPair(complex(1,2),1);
assert(pci.first==complex(1,2)&&pci.second==1);
psi = li_std_pair_extra.SIPair("hi",1);
assert(psi.first=="hi"&&psi.second==1);
psii = li_std_pair_extra.SIIPair(psi,1);
assert(psii.first.first=="hi");
assert(psii.first.second==1);
assert(psii.second==1);
a = li_std_pair_extra.A();
b = li_std_pair_extra.B();
pab = li_std_pair_extra.ABPair(a,b);
pab.first = a;
pab.first.val = 2;
assert(pab.first.val == 2);
pci = li_std_pair_extra.CIntPair(1,0);
assert(pci.first==1&&pci.second==0);
a = li_std_pair_extra.A(5);
p1 = li_std_pair_extra.pairP1(1,a);
p2 = li_std_pair_extra.pairP2(a,1);
p3 = li_std_pair_extra.pairP3(a,a);
assert(a.val == li_std_pair_extra.p_identa(p1){2}.val);
p = li_std_pair_extra.IntPair(1,10);
assert(p.first==1&&p.second==10);
p.first = 1;
assert(p.first==1);
p = li_std_pair_extra.paircA1(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
p = li_std_pair_extra.paircA2(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2
pp = li_std_pair_extra.pairiiA(1,{1,A()});

View file

@ -0,0 +1,69 @@
li_std_pair
p = {1,2};
p1 = li_std_pair.p_inout(p);
assert(all(cell2mat(p1)==[2,1]));
p2 = li_std_pair.p_inoutd(p1);
assert(all(cell2mat(p2)==[1,2]));
d1 = li_std_pair.d_inout(2);
assert(d1==4);
[i,d2] = li_std_pair.d_inout2(2);
assert(all([i,d2]==[1,4]));
[i,p] = li_std_pair.p_inout2(p);
assert(i==1&&all([cell2mat(p)]==[2,1]));
[p3,p4] = li_std_pair.p_inout3(p1,p1);
assert(all(cell2mat(p3)==[2,1]));
assert(all(cell2mat(p4)==[2,1]));
psi = li_std_pair.SIPair("hello",1);
assert(psi=={"hello",1});
pci = li_std_pair.CIPair(complex(1,2),1);
assert(pci.first==complex(1,2)&&pci.second==1);
psi = li_std_pair.SIPair("hi",1);
assert(psi.first=="hi"&&psi.second==1);
psii = li_std_pair.SIIPair(psi,1);
assert(psii.first.first=="hi");
assert(psii.first.second==1);
assert(psii.second==1);
a = li_std_pair.A();
b = li_std_pair.B();
pab = li_std_pair.ABPair(a,b);
pab.first = a;
pab.first.val = 2;
assert(pab.first.val == 2);
pci = li_std_pair.CIntPair(1,0);
assert(pci.first==1&&pci.second==0);
a = li_std_pair.A(5);
p1 = li_std_pair.pairP1(1,a);
p2 = li_std_pair.pairP2(a,1);
p3 = li_std_pair.pairP3(a,a);
assert(a.val == li_std_pair.p_identa(p1){2}.val);
p = li_std_pair.IntPair(1,10);
assert(p.first==1&&p.second==10);
p.first = 1;
assert(p.first==1);
p = li_std_pair.paircA1(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
p = li_std_pair.paircA2(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2
pp = li_std_pair.pairiiA(1,{1,A()});

View file

@ -1,4 +1,4 @@
%module li_std_string_extra
%module li_std_string
%naturalvar A;
@ -51,5 +51,5 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_
%}
%include "li_std_string.i"
%include ../li_std_string.i

View file

@ -1,162 +0,0 @@
li_std_string_extra
x="hello";
if (li_std_string_extra.test_ccvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_cvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_value(x) != x)
error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
endif
if (li_std_string_extra.test_const_reference(x) != x)
error("bad string mapping")
endif
s = li_std_string_extra.string("he");
#s += "ll"
#s.append("ll")
s = s + "llo";
if (s != x)
error("bad string mapping: %s, %s", s, x);
endif
#if (s(1:4) != x(1:4))
# error("bad string mapping")
#endif
if (li_std_string_extra.test_value(s) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_const_reference(s) != x)
error("bad string mapping")
endif
a = li_std_string_extra.A(s);
if (li_std_string_extra.test_value(a) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_const_reference(a) != x)
error("bad string mapping")
endif
b = li_std_string_extra.string(" world");
s = a + b;
if (a + b != "hello world")
error("bad string mapping: %s", a + b)
endif
if (a + " world" != "hello world")
error("bad string mapping")
endif
#if ("hello" + b != "hello world")
# error("bad string mapping")
#endif
c = (li_std_string_extra.string("hello") + b);
if (c.find_last_of("l") != 9)
error("bad string mapping")
endif
s = "hello world";
b = li_std_string_extra.B("hi");
b.name = li_std_string_extra.string("hello");
if (b.name != "hello")
error("bad string mapping")
endif
b.a = li_std_string_extra.A("hello");
if (b.a != "hello")
error("bad string mapping")
endif
if (li_std_string_extra.test_value_basic1(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_value_basic2(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_value_basic3(x) != x)
error("bad string mapping")
endif
# Global variables
s = "initial string";
if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
error("GlobalString2 test 1")
endif
li_std_string_extra.cvar.GlobalString2 = s;
if (li_std_string_extra.cvar.GlobalString2 != s)
error("GlobalString2 test 2")
endif
if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
error("ConstGlobalString test")
endif
# Member variables
myStructure = li_std_string_extra.Structure();
if (myStructure.MemberString2 != "member string 2")
error("MemberString2 test 1")
endif
myStructure.MemberString2 = s;
if (myStructure.MemberString2 != s)
error("MemberString2 test 2")
endif
if (myStructure.ConstMemberString != "const member string")
error("ConstMemberString test")
endif
if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
error("StaticMemberString2 test 1")
endif
li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
error("StaticMemberString2 test 2")
endif
if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
error("ConstStaticMemberString test")
endif
if (li_std_string_extra.test_reference_input("hello") != "hello")
error
endif
s = li_std_string_extra.test_reference_inout("hello");
if (s != "hellohello")
error
endif
if (li_std_string_extra.stdstring_empty() != "")
error
endif
if (li_std_string_extra.c_empty() != "")
error
endif
#if (li_std_string_extra.c_null() != None)
# error
#endif

View file

@ -0,0 +1,162 @@
li_std_string
x="hello";
if (li_std_string.test_ccvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_cvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_value(x) != x)
error("bad string mapping: %s, %s", x, li_std_string.test_value(x))
endif
if (li_std_string.test_const_reference(x) != x)
error("bad string mapping")
endif
s = li_std_string.string("he");
#s += "ll"
#s.append('o')
s = s + "llo";
if (s != x)
error("bad string mapping: %s, %s", s, x);
endif
if (s[1:4] != x[1:4])
error("bad string mapping")
endif
if (li_std_string.test_value(s) != x)
error("bad string mapping")
endif
if (li_std_string.test_const_reference(s) != x)
error("bad string mapping")
endif
a = li_std_string.A(s);
if (li_std_string.test_value(a) != x)
error("bad string mapping")
endif
if (li_std_string.test_const_reference(a) != x)
error("bad string mapping")
endif
b = li_std_string.string(" world");
s = a + b;
if (a + b != "hello world")
error("bad string mapping: %s", a + b)
endif
if (a + " world" != "hello world")
error("bad string mapping")
endif
if ("hello" + b != "hello world")
error("bad string mapping")
endif
c = ("hello" + b)
if (c.find_last_of("l") != 9)
error("bad string mapping")
endif
s = "hello world";
b = li_std_string.B("hi");
b.name = li_std_string.string("hello");
if (b.name != "hello")
error("bad string mapping")
endif
b.a = li_std_string.A("hello");
if (b.a != "hello")
error("bad string mapping")
endif
if (li_std_string.test_value_basic1(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_value_basic2(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_value_basic3(x) != x)
error("bad string mapping")
endif
# Global variables
s = "initial string";
if (li_std_string.cvar.GlobalString2 != "global string 2")
error("GlobalString2 test 1")
endif
li_std_string.cvar.GlobalString2 = s;
if (li_std_string.cvar.GlobalString2 != s)
error("GlobalString2 test 2")
endif
if (li_std_string.cvar.ConstGlobalString != "const global string")
error("ConstGlobalString test")
endif
# Member variables
myStructure = li_std_string.Structure();
if (myStructure.MemberString2 != "member string 2")
error("MemberString2 test 1")
endif
myStructure.MemberString2 = s;
if (myStructure.MemberString2 != s)
error("MemberString2 test 2")
endif
if (myStructure.ConstMemberString != "const member string")
error("ConstMemberString test")
endif
if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2")
error("StaticMemberString2 test 1")
endif
li_std_string.cvar.Structure_StaticMemberString2 = s;
if (li_std_string.cvar.Structure_StaticMemberString2 != s)
error("StaticMemberString2 test 2")
endif
if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string")
error("ConstStaticMemberString test")
endif
if (li_std_string.test_reference_input("hello") != "hello")
error
endif
s = li_std_string.test_reference_inout("hello");
if (s != "hellohello")
error
endif
if (li_std_string.stdstring_empty() != "")
error
endif
if (li_std_string.c_empty() != "")
error
endif
if (li_std_string.c_null() != None)
error
endif

View file

@ -76,12 +76,6 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
#ifdef SWIG_ALLEGRO_CL
%{
#include <stdio.h>
%}
#endif
%rename(IntCast) operator int();
%rename(DoubleCast) operator double();

View file

@ -1,12 +0,0 @@
%module operbool
%rename(operbool) operator bool();
%inline %{
class Test {
public:
operator bool() {
return false;
}
};
%}

View file

@ -1,6 +1,5 @@
struct Base {
virtual int vmethod() { return 1; }
int basemethod() { return 1; }
virtual ~Base() {}
class A
{
public:
int testInt() { return 2;}
};

View file

@ -1,3 +1,2 @@
packageoption_a
packageoption_b
packageoption_c

View file

@ -1,4 +1,4 @@
%module(package="CommonPackage") "packageoption_a";
%module(package="C") "packageoption_a";
%inline %{
class A
@ -6,11 +6,5 @@ class A
public:
int testInt() { return 2;}
};
%}
%{
#include "packageoption.h"
%}
%include "packageoption.h"

View file

@ -1,4 +1,4 @@
%module(package="CommonPackage") "packageoption_b";
%module(package="C") "packageoption_b";
%inline %{
class B

View file

@ -1,13 +0,0 @@
%module(package="PackageC") "packageoption_c";
%import "packageoption_a.i"
%inline %{
#include "packageoption.h"
struct Derived : Base {
virtual int vmethod() { return 2; }
virtual ~Derived() {}
};
%}

View file

@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 5;
use Test::More tests => 4;
BEGIN { use_ok('char_strings') }
require_ok('char_strings');
@ -10,6 +10,3 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1');
my $val2 = "greetings";
is(char_strings::CharPingPong($val2), "greetings", 'cstr2');
# SF#2564192
"this is a test" =~ /(\w+)$/;
is(char_strings::CharPingPong($1), "test", "handles Magical");

View file

@ -37,29 +37,24 @@ batch('ulong', 0, 1, 12, 0xffffffff);
batch('uchar', 0, 1, 12, 0xff);
batch('schar', -0x80, 0, 1, 12, 0x7f);
{
use Math::BigInt qw();
# the pack dance is to get plain old NVs out of the
# Math::BigInt objects.
my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
batch('float',
-(2 - 2 ** -23) * 2 ** 127,
-1, -2 ** -149, 0, 2 ** -149, 1,
(2 - 2 ** -23) * 2 ** 127,
$nan);
{ local $TODO = "float typemaps don't pass infinity";
# it seems as though SWIG is unwilling to pass infinity around
# because that value always fails bounds checking. I think that
# is a bug.
batch('float', $inf);
}
batch('double',
-(2 - 2 ** -53) ** 1023,
-1, -2 ** -1074, 0, 2 ** 1074,
(2 - 2 ** -53) ** 1023,
$nan, $inf);
# IEEE 754 machine, please!
batch('float',
-(2 - 2 ** -23) * 2 ** 127,
-1, -2 ** -149, 0, 2 ** -149, 1,
(2 - 2 ** -23) * 2 ** 127,
'nan');
{ local $TODO = "shouldn't some Inf <=> float work?";
# I'm going to guess that it could work reasonably as
# NV Inf => float Inf
# float Inf => NV NaN
# but this needs some thought.
batch('float', 'inf');
}
batch('double',
-(2 - 2 ** -53) ** 1023,
-1, -2 ** -1074, 0, 2 ** 1074,
(2 - 2 ** -53) ** 1023,
'nan', 'inf');
batch('longlong', -1, 0, 1, 12);
batch('ulonglong', 0, 1, 12);
SKIP: {

View file

@ -14,11 +14,11 @@ sub ok_not ($;$) {
ok($test, $name);
}
my $a = CommonPackage::A->new();
my $a = C::A->new();
isa_ok($a, 'CommonPackage::A');
isa_ok($a, 'C::A');
my $b = CommonPackage::B->new();
my $b = C::B->new();
isa_ok($b, 'CommonPackage::B');
isa_ok($b, 'C::B');

View file

@ -1,16 +1,13 @@
#######################################################################
# Makefile for php test-suite
# Makefile for php4 test-suite
#######################################################################
LANGUAGE = php
SCRIPTSUFFIX = _runme.php
LANGUAGE = php4
SCRIPTSUFFIX = _runme.php4
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
#CPP_TEST_CASES += \
# php_namewarn_rename \
include $(srcdir)/../common.mk
# Overridden variables here
@ -25,19 +22,19 @@ makectests:
@bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done'
runcpptests:
@bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done'
@bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done'
runctests:
@bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done'
@bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done'
runtests: runcpptests runctests
# write out tests without a _runme.php
# write out tests without a _runme.php4
missingcpptests:
@bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done'
@bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
missingctests:
@bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done'
@bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
missingtests: missingcpptests missingctests
@ -58,10 +55,10 @@ missingtests: missingcpptests missingctests
+$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.php appended after the testcase name.
# a file is found which has _runme.php4 appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \
fi;
# Clean: remove the generated .php file
@ -69,4 +66,4 @@ run_testcase = \
@rm -f $*.php;
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php4_clean

View file

@ -1,6 +1,6 @@
<?php
require "tests.php";
require "tests.php4";
require "abstract_inherit_ok.php";
check::classes(array(Foo,Spam));

View file

@ -1,6 +1,6 @@
<?php
require "tests.php";
require "tests.php4";
require "abstract_inherit.php";
check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "add_link.php";
// No new functions, except the flat functions

View file

@ -1,6 +1,6 @@
<?php
require "tests.php";
require "tests.php4";
require "argout.php";
check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "arrayptr.php";
// No new functions

View file

@ -1,20 +1,14 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "arrays_global.php";
check::functions(array(test_a,test_b,new_simplestruct,new_material));
check::classes(array(arrays_global,SimpleStruct,Material));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat));
// The size of array_c is 2, but the last byte is \0, so we can only store a
// single byte string in it.
check::set(array_c,"Z");
check::equal("Z",check::get(array_c),"set array_c");
check::set(array_c,"xy");
check::equal("x",check::get(array_c),"set array_c");
check::set(array_c,"h");
check::equal("h",check::get(array_c),"set array_c");
check::set(array_c,"hac");
check::equal("ha",check::get(array_c,"ha"),"set array_c");
check::done();
?>

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "arrays_global_twodim.php";
check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));

View file

@ -1,6 +1,6 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "arrays.php";
check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "arrays_scope.php";
// No new functions

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "casts.php";
// No new functions

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "class_ignore.php";
check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));

View file

@ -1,7 +1,7 @@
<?php
// Sample test file
require "tests.php";
require "tests.php4";
require "conversion_namespace.php";
check::classes(array("Foo","Bar"));

Some files were not shown because too many files have changed in this diff Show more