merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11360 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2009-07-04 06:48:39 +00:00
commit 84aecae48a
44 changed files with 366 additions and 188 deletions

View file

@ -335,12 +335,13 @@ OCTAVE_SO = @OCTAVE_SO@
# ----------------------------------------------------------------
# Build a C dynamically loadable module
# Note: Octave requires C++ compiler when compiling C wrappers
# ----------------------------------------------------------------
octave: $(SRCS)
$(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
$(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(OCTAVE_INCLUDE)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
$(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
# -----------------------------------------------------------------

View file

@ -89,8 +89,12 @@ SKIP_CPP_STD_CASES = Yes
include $(srcdir)/../common.mk
# Overridden variables here
# SWIGOPT += -debug-module 4
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -11,10 +11,14 @@ top_builddir = @top_builddir@
include $(srcdir)/../common.mk
# Overridden variables here
# no C++ tests for now
CPP_TEST_CASES =
#C_TEST_CASES +=
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -23,10 +23,21 @@ EXTRA_TEST_CASES += chicken_ext_test.externaltest
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -nounit
# Custom tests - tests with additional commandline options
# If there exists a PROXYSUFFIX runme file, we also generate the wrapper
# with the -proxy argument
%.cppproxy: SWIGOPT += -proxy
%.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
%.cproxy: SWIGOPT += -proxy
%.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
%.multiproxy: SWIGOPT += -proxy -noclosuses
%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
# Rules for the different types of tests
%.cpptest:
$(setup)
@ -57,6 +68,21 @@ SWIGOPT += -nounit
+$(swig_and_compile_external)
$(run_testcase)
%.cppproxy:
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+$(swig_and_compile_cpp)
$(run_testcase)
%.cproxy:
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+$(swig_and_compile_c)
$(run_testcase)
%.multiproxy:
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+$(swig_and_compile_multi_cpp)
$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
run_testcase = \
@ -64,29 +90,6 @@ run_testcase = \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
# If there exists a PROXYSUFFIX runme file, we also generate the wrapper
# with the -proxy argument
%.cppproxy: SWIGOPT += -proxy
%.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
%.cppproxy:
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+$(swig_and_compile_cpp)
$(run_testcase)
%.cproxy: SWIGOPT += -proxy
%.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
%.cproxy:
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+$(swig_and_compile_c)
$(run_testcase)
%.multiproxy: SWIGOPT += -proxy -noclosuses
%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
%.multiproxy:
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
+$(swig_and_compile_multi_cpp)
$(run_testcase)
# Clean
%.clean:

View file

@ -11,10 +11,14 @@ top_builddir = @top_builddir@
include $(srcdir)/../common.mk
# Overridden variables here
# no C++ tests for now
CPP_TEST_CASES =
#C_TEST_CASES +=
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -16,8 +16,8 @@
# b) Define rules for %.ctest, %.cpptest, %.multicpptest and %.clean.
# c) Define srcdir, top_srcdir and top_builddir (these are the
# equivalent to configure's variables of the same name).
# 3) One off special commandline options can be achieved by adding a
# test case to CUSTOM_TEST_CASES and defining rules to run and test.
# 3) One off special commandline options for a testcase can be added.
# See custom tests below.
#
# The 'check' target runs the testcases including SWIG invocation,
# C/C++ compilation, target language compilation (if any) and runtime
@ -64,14 +64,14 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
LIBS = -L.
LIBPREFIX = lib
ACTION = check
INTERFACEDIR = $(if $(wildcard $*.i), ./, ../)
INTERFACEDIR = ../
#
# Please keep test cases in alphabetical order.
# Note that any whitespace after the last entry in each list will break make
#
# Broken C++ test cases. (Can be run individually using make testcase.cpptest.)
# Broken C++ test cases. (Can be run individually using: make testcase.cpptest)
CPP_TEST_BROKEN += \
constants \
cpp_broken \
@ -85,12 +85,12 @@ CPP_TEST_BROKEN += \
template_expr
# Broken C test cases. (Can be run individually using make testcase.ctest.)
# Broken C test cases. (Can be run individually using: make testcase.ctest)
C_TEST_BROKEN += \
tag_no_clash_with_variable
# C++ test cases. (Can be run individually using make testcase.cpptest.)
# C++ test cases. (Can be run individually using: make testcase.cpptest)
CPP_TEST_CASES += \
abstract_access \
abstract_inherit \
@ -394,6 +394,7 @@ CPP_TEST_CASES += \
virtual_destructor \
virtual_poly \
voidtest \
wallkw \
wrapmacro
#
@ -420,7 +421,7 @@ CPP_TEST_CASES += ${CPP_STD_TEST_CASES}
endif
# C test cases. (Can be run individually using make testcase.ctest.)
# C test cases. (Can be run individually using: make testcase.ctest)
C_TEST_CASES += \
arrays \
char_constant \
@ -459,7 +460,7 @@ C_TEST_CASES += \
unions
# Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest.)
# Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest)
MULTI_CPP_TEST_CASES += \
clientdata_prop \
imports \
@ -468,10 +469,13 @@ MULTI_CPP_TEST_CASES += \
template_typedef_import \
multi_import
# Custom tests - tests with additional commandline options
wallkw.cpptest: SWIGOPT += -Wallkw
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
$(C_TEST_CASES:=.ctest) \
$(MULTI_CPP_TEST_CASES:=.multicpptest) \
$(CUSTOM_TEST_CASES:=.customtest) \
$(EXTRA_TEST_CASES)
BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \
@ -480,7 +484,6 @@ BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \
ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \
$(C_TEST_CASES:=.clean) \
$(MULTI_CPP_TEST_CASES:=.clean) \
$(CUSTOM_TEST_CASES:=.clean) \
$(CPP_TEST_BROKEN:=.clean) \
$(C_TEST_BROKEN:=.clean)

View file

@ -15,24 +15,26 @@ CPP_TEST_CASES = \
csharp_attributes \
csharp_exceptions \
csharp_features \
csharp_lib_arrays \
csharp_prepost \
csharp_typemaps \
enum_thorough_simple \
enum_thorough_typesafe \
exception_partial_info
CUSTOM_TEST_CASES = \
csharp_lib_arrays \
exception_partial_info \
intermediary_classname
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL)
SWIGOPT += -namespace $*Namespace
INTERFACEDIR = ../../
CSHARPFLAGSSPECIAL =
# Custom tests - tests with additional commandline options
intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
# Rules for the different types of tests
%.cpptest:
$(setup)
@ -49,12 +51,6 @@ CSHARPFLAGSSPECIAL =
+(cd $* && $(swig_and_compile_multi_cpp))
+$(run_testcase)
# 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 = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \

View file

@ -119,6 +119,7 @@
// tests valuewrapper
%feature("compactdefaultargs") MyClass2::set;
%inline %{
enum MyType { Val1, Val2 };
@ -134,6 +135,7 @@
void set(MyClass1 cl1 = Val1) {}
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
// But it works in C++ since there is a "conversion" constructor in MyClass1.
void set2(MyClass1 cl1 = Val1) {}
};
%}

View file

@ -9,14 +9,22 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
GUILE = @GUILE@
GUILE_RUNTIME=-runtime
C_TEST_CASES = long_long \
list_vector \
multivalue \
pointer_in_out
C_TEST_CASES = long_long list_vector pointer_in_out multivalue
include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
%.multicpptest: SWIGOPT += $(GUILE_RUNTIME)
# Rules for the different types of tests
%.cpptest:
$(setup)
@ -28,19 +36,6 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
# override the default in common.mk by adding SWIGOPT +=
swig_and_compile_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
SWIGOPT=" -runtime "; \
export SWIGOPT; \
$(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" \
$(LANGUAGE)$(VARIANT)_cpp; \
SWIGOPT=" -noruntime "; \
done
%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)

View file

@ -6,11 +6,15 @@ EXTRA_TEST_CASES += guilescm_ext_test.externaltest
include ../guile/Makefile
# Overridden variables here
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm
VARIANT =
# Refer to the guile directory for the run scripts
SCRIPTPREFIX = ../guile/
GUILE_RUNTIME=
# Custom tests - tests with additional commandline options
# none!
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
@ -26,15 +30,6 @@ setup = \
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
fi;
swig_and_compile_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(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" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
%.externaltest:
$(local_setup)
+$(swig_and_compile_external)

View file

@ -40,6 +40,9 @@ include $(srcdir)/../common.mk
SWIGOPT += -package $*
INTERFACEDIR = ../../
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -0,0 +1,25 @@
import wallkw.*;
public class wallkw_runme {
static {
try {
System.loadLibrary("wallkw");
} 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[]) {
if (!wallkw.c_clone().equals("clone"))
throw new RuntimeException("clone_c keyword fail");
if (!wallkw._delegate().equals("delegate"))
throw new RuntimeException("delegate keyword fail");
if (!wallkw._pass().equals("pass"))
throw new RuntimeException("pass keyword fail");
if (!wallkw.C_alias().equals("alias"))
throw new RuntimeException("alias keyword fail");
}
}

View file

@ -1,4 +1,4 @@
%module byreference
%module li_reference
%include "reference.i"

View file

@ -24,6 +24,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
LIBS = -L.
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -14,6 +14,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -27,7 +27,7 @@ struct a
struct {
/*struct*/
struct {
int b;
int b; /**< v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */
} c;
} d;
};

View file

@ -44,6 +44,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
echo $@ >> testing

View file

@ -34,6 +34,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
LIBS = -L.
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -15,7 +15,7 @@ CPP_TEST_CASES += \
li_cdata \
li_cstring \
li_cdata_carrays \
byreference \
li_reference \
C_TEST_CASES += \
li_cdata \
@ -27,6 +27,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -1,36 +0,0 @@
use strict;
use warnings;
use Test::More tests => 68;
BEGIN { use_ok('byreference') }
require_ok('byreference');
sub chk { my($type, $call, $v1, $v2) = @_;
$byreference::FrVal = $v1;
my $v = $v2;
eval { $call->(\$v) };
is($@, '', "$type check");
is($byreference::ToVal, $v2, "$type out");
is($v, $v1, "$type in");
}
chk("double*", \&byreference::PDouble, 12.2, 18.6);
chk("double&", \&byreference::RDouble, 32.5, 64.8);
chk("float*", \&byreference::PFloat, 64.5, 96.0);
chk("float&", \&byreference::RFloat, 98.5, 6.25);
chk("int*", \&byreference::PInt, 1887, 3356);
chk("int&", \&byreference::RInt, 2622, 9867);
chk("short*", \&byreference::PShort, 4752, 3254);
chk("short&", \&byreference::RShort, 1898, 5757);
chk("long*", \&byreference::PLong, 6687, 7132);
chk("long&", \&byreference::RLong, 8346, 4398);
chk("uint*", \&byreference::PUInt, 6853, 5529);
chk("uint&", \&byreference::RUInt, 5483, 7135);
chk("ushort*", \&byreference::PUShort, 9960, 9930);
chk("ushort&", \&byreference::RUShort, 1193, 4178);
chk("ulong*", \&byreference::PULong, 7960, 4788);
chk("ulong&", \&byreference::RULong, 8829, 1603);
chk("uchar*", \&byreference::PUChar, 110, 239);
chk("uchar&", \&byreference::RUChar, 15, 97);
chk("char*", \&byreference::PChar, -7, 118);
chk("char&", \&byreference::RChar, -3, -107);
chk("bool*", \&byreference::PBool, 0, 1);
chk("bool&", \&byreference::RBool, 1, 0);

View file

@ -0,0 +1,36 @@
use strict;
use warnings;
use Test::More tests => 68;
BEGIN { use_ok('li_reference') }
require_ok('li_reference');
sub chk { my($type, $call, $v1, $v2) = @_;
$li_reference::FrVal = $v1;
my $v = $v2;
eval { $call->(\$v) };
is($@, '', "$type check");
is($li_reference::ToVal, $v2, "$type out");
is($v, $v1, "$type in");
}
chk("double*", \&li_reference::PDouble, 12.2, 18.6);
chk("double&", \&li_reference::RDouble, 32.5, 64.8);
chk("float*", \&li_reference::PFloat, 64.5, 96.0);
chk("float&", \&li_reference::RFloat, 98.5, 6.25);
chk("int*", \&li_reference::PInt, 1887, 3356);
chk("int&", \&li_reference::RInt, 2622, 9867);
chk("short*", \&li_reference::PShort, 4752, 3254);
chk("short&", \&li_reference::RShort, 1898, 5757);
chk("long*", \&li_reference::PLong, 6687, 7132);
chk("long&", \&li_reference::RLong, 8346, 4398);
chk("uint*", \&li_reference::PUInt, 6853, 5529);
chk("uint&", \&li_reference::RUInt, 5483, 7135);
chk("ushort*", \&li_reference::PUShort, 9960, 9930);
chk("ushort&", \&li_reference::RUShort, 1193, 4178);
chk("ulong*", \&li_reference::PULong, 7960, 4788);
chk("ulong&", \&li_reference::RULong, 8829, 1603);
chk("uchar*", \&li_reference::PUChar, 110, 239);
chk("uchar&", \&li_reference::RUChar, 15, 97);
chk("char*", \&li_reference::PChar, -7, 118);
chk("char&", \&li_reference::RChar, -3, -107);
chk("bool*", \&li_reference::PBool, 0, 1);
chk("bool&", \&li_reference::RBool, 1, 0);

View file

@ -16,6 +16,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
TARGETPREFIX =# Should be php_ for Windows, empty otherwise
# Custom tests - tests with additional commandline options
# none!
# write out tests without a _runme.php
missingcpptests:
for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done

View file

@ -14,6 +14,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -89,6 +89,9 @@ include $(srcdir)/../common.mk
LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -16,6 +16,10 @@ CPP_TEST_CASES = r_double_delete
include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:

View file

@ -38,12 +38,10 @@ include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -w801 -noautorename -features autodoc=4
# Rules for the different types of tests
# make sure -autorename is true for the naming test
# Custom tests - tests with additional commandline options
ruby_naming.cpptest: SWIGOPT += -autorename
# Rules for the different types of tests
%.cpptest:
$(setup)
+$(swig_and_compile_cpp)

View file

@ -50,6 +50,9 @@ end
raise RuntimeError if fail != 1
# Test a number which won't fit in a 32 bit integer and is represented
# as a FIXNUM by Ruby.
raise RuntimeError if val_double(51767811298) != 51767811298
raise RuntimeError if val_double_2(1.0) != 4.0
raise RuntimeError if val_double_2(1) != 4

View file

@ -23,6 +23,9 @@ include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -11,10 +11,14 @@ top_builddir = @top_builddir@
include $(srcdir)/../common.mk
# Overridden variables here
# no C++ tests for now
CPP_TEST_CASES =
#C_TEST_CASES +=
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)

View file

@ -0,0 +1,16 @@
%module wallkw
// test the -Wallkw option
%warnfilter(SWIGWARN_PARSE_KEYWORD) clone; // 'clone' is a php keyword, renamed as 'c_clone'
%warnfilter(SWIGWARN_PARSE_KEYWORD) delegate; // 'delegate' is a C# keyword, renaming to '_delegate'
%warnfilter(SWIGWARN_PARSE_KEYWORD) pass; // 'pass' is a python keyword, renaming to '_pass'
%warnfilter(SWIGWARN_PARSE_KEYWORD) alias; // 'alias' is a ruby keyword, renaming to 'C_alias'
%inline %{
const char * clone() { return "clone"; }
const char * delegate() { return "delegate"; }
const char * pass() { return "pass"; }
const char * alias() { return "alias"; }
%}