Merge branch 'master' into gsoc2012-scilab
Conflicts: .gitignore .travis.yml COPYRIGHT Examples/Makefile.in Examples/test-suite/constructor_copy.i Makefile.in configure.ac
This commit is contained in:
commit
07b06a4089
1502 changed files with 46955 additions and 11374 deletions
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = allegrocl
|
||||
ALLEGROCL = @ALLEGROCLBIN@
|
||||
SCRIPTSUFFIX = _runme.lisp
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
|
@ -12,7 +13,7 @@ top_builddir = @top_builddir@
|
|||
|
||||
# these cpp tests generate warnings/errors when compiling
|
||||
# the wrapper .cxx file.
|
||||
CPP_TEST_BROKEN_CXX =
|
||||
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. \
|
||||
|
|
@ -71,7 +72,7 @@ CPP_TEST_CASES_ACL_UNSUPPORTED = \
|
|||
extern_throws \
|
||||
throw_exception \
|
||||
using_pointers \
|
||||
|
||||
|
||||
C_TEST_CASES_ACL_BROKEN = \
|
||||
# 'cdate.i' module support \
|
||||
li_cdata \
|
||||
|
|
@ -96,7 +97,7 @@ include $(srcdir)/../common.mk
|
|||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -106,7 +107,7 @@ include $(srcdir)/../common.mk
|
|||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -114,13 +115,12 @@ include $(srcdir)/../common.mk
|
|||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
%.clean:
|
||||
@rm -f $*.cl
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
|
||||
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" allegrocl_clean
|
||||
|
|
|
|||
20
Examples/test-suite/c_delete.i
Normal file
20
Examples/test-suite/c_delete.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module c_delete
|
||||
|
||||
/* check C++ delete keyword is okay in C wrappers */
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) delete;
|
||||
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */
|
||||
|
||||
%inline %{
|
||||
struct delete {
|
||||
int delete;
|
||||
};
|
||||
%}
|
||||
|
||||
%rename(DeleteGlobalVariable) delete;
|
||||
%inline %{
|
||||
int delete = 0;
|
||||
%}
|
||||
|
||||
#endif
|
||||
13
Examples/test-suite/c_delete_function.i
Normal file
13
Examples/test-suite/c_delete_function.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module c_delete_function
|
||||
|
||||
/* check C++ delete keyword is okay in C wrappers */
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) delete;
|
||||
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */
|
||||
|
||||
%inline %{
|
||||
double delete(double d) { return d; }
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = cffi
|
||||
CFFI = @CFFIBIN@
|
||||
SCRIPTSUFFIX = _runme.lisp
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
|
@ -14,13 +15,13 @@ include $(srcdir)/../common.mk
|
|||
# Overridden variables here
|
||||
# no C++ tests for now
|
||||
CPP_TEST_CASES =
|
||||
#C_TEST_CASES +=
|
||||
#C_TEST_CASES +=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -30,7 +31,7 @@ CPP_TEST_CASES =
|
|||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -38,14 +39,13 @@ CPP_TEST_CASES =
|
|||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra cffi code)
|
||||
%.clean:
|
||||
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile cffi_clean
|
||||
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" cffi_clean
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
#######################################################################
|
||||
|
||||
LANGUAGE = chicken
|
||||
VARIANT =
|
||||
VARIANT =
|
||||
SCRIPTSUFFIX = _runme.ss
|
||||
PROXYSUFFIX = _runme_proxy.ss
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
CHICKEN_CSI = @CHICKEN_CSI@ -quiet -batch -no-init
|
||||
SO = @SO@
|
||||
|
||||
|
|
@ -17,7 +19,7 @@ SO = @SO@
|
|||
# Skip the STD cases for now, except for li_std_string.i
|
||||
SKIP_CPP_STD_CASES = Yes
|
||||
|
||||
CPP_TEST_CASES += li_std_string
|
||||
CPP_TEST_CASES += li_std_string
|
||||
|
||||
EXTRA_TEST_CASES += chicken_ext_test.externaltest
|
||||
|
||||
|
|
@ -39,11 +41,11 @@ SWIGOPT += -nounit
|
|||
%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
$(MAKE) $*.cppproxy; \
|
||||
fi
|
||||
|
||||
|
|
@ -51,15 +53,15 @@ SWIGOPT += -nounit
|
|||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
$(MAKE) $*.cproxy; \
|
||||
fi
|
||||
|
||||
%.multicpptest:
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
$(MAKE) $*.multiproxy; \
|
||||
fi
|
||||
|
||||
|
|
@ -69,31 +71,31 @@ SWIGOPT += -nounit
|
|||
$(run_testcase)
|
||||
|
||||
%.cppproxy:
|
||||
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy"
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.cproxy:
|
||||
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy"
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multiproxy:
|
||||
echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy"
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) 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 = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean
|
||||
%.clean:
|
||||
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile chicken_clean
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" chicken_clean
|
||||
rm -f *.scm
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = clisp
|
||||
CLISP = @CLISPBIN@
|
||||
SCRIPTSUFFIX = _runme.lisp
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
|
@ -14,13 +15,13 @@ include $(srcdir)/../common.mk
|
|||
# Overridden variables here
|
||||
# no C++ tests for now
|
||||
CPP_TEST_CASES =
|
||||
#C_TEST_CASES +=
|
||||
#C_TEST_CASES +=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -30,7 +31,7 @@ CPP_TEST_CASES =
|
|||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -38,14 +39,13 @@ CPP_TEST_CASES =
|
|||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra clisp code)
|
||||
%.clean:
|
||||
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile clisp_clean
|
||||
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" clisp_clean
|
||||
|
|
|
|||
|
|
@ -69,7 +69,13 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
|
|||
LIBS = -L.
|
||||
LIBPREFIX = lib
|
||||
ACTION = check
|
||||
INTERFACEDIR = $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/
|
||||
INTERFACEDIR = ../
|
||||
SRCDIR = $(srcdir)/
|
||||
SCRIPTDIR = $(srcdir)
|
||||
|
||||
# Regenerate Makefile if Makefile.in or config.status have changed.
|
||||
Makefile: $(srcdir)/Makefile.in ../../../config.status
|
||||
cd ../../../ && $(SHELL) ./config.status $(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE)/Makefile
|
||||
|
||||
#
|
||||
# Please keep test cases in alphabetical order.
|
||||
|
|
@ -84,16 +90,19 @@ CPP_TEST_BROKEN += \
|
|||
extend_variable \
|
||||
li_std_vector_ptr \
|
||||
li_boost_shared_ptr_template \
|
||||
nested_private \
|
||||
overload_complicated \
|
||||
rename_camel \
|
||||
template_default_pointer \
|
||||
template_expr
|
||||
template_private_assignment \
|
||||
template_expr \
|
||||
$(CPP11_TEST_BROKEN)
|
||||
|
||||
|
||||
# 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)
|
||||
CPP_TEST_CASES += \
|
||||
abstract_access \
|
||||
|
|
@ -194,11 +203,14 @@ CPP_TEST_CASES += \
|
|||
disown \
|
||||
dynamic_cast \
|
||||
empty \
|
||||
enum_ignore \
|
||||
enum_plus \
|
||||
enum_rename \
|
||||
enum_scope_template \
|
||||
enum_template \
|
||||
enum_thorough \
|
||||
enum_var \
|
||||
equality \
|
||||
evil_diamond \
|
||||
evil_diamond_ns \
|
||||
evil_diamond_prop \
|
||||
|
|
@ -242,10 +254,13 @@ CPP_TEST_CASES += \
|
|||
li_boost_shared_ptr \
|
||||
li_boost_shared_ptr_bits \
|
||||
li_boost_shared_ptr_template \
|
||||
li_boost_shared_ptr_attribute \
|
||||
li_carrays \
|
||||
li_cdata \
|
||||
li_cpointer \
|
||||
li_std_auto_ptr \
|
||||
li_stdint \
|
||||
li_swigtype_inout \
|
||||
li_typemaps \
|
||||
li_typemaps_apply \
|
||||
li_windows \
|
||||
|
|
@ -275,8 +290,11 @@ CPP_TEST_CASES += \
|
|||
nspace_extend \
|
||||
naturalvar \
|
||||
naturalvar_more \
|
||||
naturalvar_onoff \
|
||||
nested_class \
|
||||
nested_directors \
|
||||
nested_comment \
|
||||
nested_scope \
|
||||
nested_workaround \
|
||||
newobject1 \
|
||||
null_pointer \
|
||||
|
|
@ -285,6 +303,7 @@ CPP_TEST_CASES += \
|
|||
operator_pointer_ref \
|
||||
operbool \
|
||||
ordering \
|
||||
overload_bool \
|
||||
overload_copy \
|
||||
overload_extend \
|
||||
overload_method \
|
||||
|
|
@ -315,6 +334,7 @@ CPP_TEST_CASES += \
|
|||
rename_strip_encoder \
|
||||
rename_pcre_encoder \
|
||||
rename_pcre_enum \
|
||||
rename_predicates \
|
||||
restrict_cplusplus \
|
||||
return_const_value \
|
||||
return_value_scope \
|
||||
|
|
@ -337,6 +357,7 @@ CPP_TEST_CASES += \
|
|||
smart_pointer_simple \
|
||||
smart_pointer_static \
|
||||
smart_pointer_template_const_overload \
|
||||
smart_pointer_template_defaults_overload \
|
||||
smart_pointer_templatemethods \
|
||||
smart_pointer_templatevariables \
|
||||
smart_pointer_typedef \
|
||||
|
|
@ -395,7 +416,6 @@ CPP_TEST_CASES += \
|
|||
template_partial_specialization \
|
||||
template_partial_specialization_typedef \
|
||||
template_qualifier \
|
||||
template_qualifier \
|
||||
template_ref_type \
|
||||
template_rename \
|
||||
template_retvalue \
|
||||
|
|
@ -417,6 +437,7 @@ CPP_TEST_CASES += \
|
|||
template_typedef_ns \
|
||||
template_typedef_ptr \
|
||||
template_typedef_rec \
|
||||
template_typedef_typedef \
|
||||
template_typemaps \
|
||||
template_typemaps_typedef \
|
||||
template_typemaps_typedef2 \
|
||||
|
|
@ -435,6 +456,7 @@ CPP_TEST_CASES += \
|
|||
typedef_scope \
|
||||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typedef_typedef \
|
||||
typemap_arrays \
|
||||
typemap_array_qualifiers \
|
||||
typemap_delete \
|
||||
|
|
@ -452,6 +474,7 @@ CPP_TEST_CASES += \
|
|||
typemap_various \
|
||||
typename \
|
||||
types_directive \
|
||||
unicode_strings \
|
||||
union_scope \
|
||||
using1 \
|
||||
using2 \
|
||||
|
|
@ -478,6 +501,47 @@ CPP_TEST_CASES += \
|
|||
wallkw \
|
||||
wrapmacro
|
||||
|
||||
# C++11 test cases.
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_alignment \
|
||||
cpp11_alternate_function_syntax \
|
||||
cpp11_constexpr \
|
||||
cpp11_decltype \
|
||||
cpp11_default_delete \
|
||||
cpp11_delegating_constructors \
|
||||
cpp11_explicit_conversion_operators \
|
||||
cpp11_final_override \
|
||||
cpp11_function_objects \
|
||||
cpp11_inheriting_constructors \
|
||||
cpp11_initializer_list \
|
||||
cpp11_initializer_list_extend \
|
||||
cpp11_lambda_functions \
|
||||
cpp11_noexcept \
|
||||
cpp11_null_pointer_constant \
|
||||
cpp11_raw_string_literals \
|
||||
cpp11_result_of \
|
||||
cpp11_rvalue_reference \
|
||||
cpp11_rvalue_reference2 \
|
||||
cpp11_rvalue_reference3 \
|
||||
cpp11_sizeof_object \
|
||||
cpp11_static_assert \
|
||||
cpp11_thread_local \
|
||||
cpp11_template_double_brackets \
|
||||
cpp11_template_explicit \
|
||||
cpp11_template_typedefs \
|
||||
cpp11_type_traits \
|
||||
cpp11_uniform_initialization \
|
||||
cpp11_unrestricted_unions \
|
||||
cpp11_userdefined_literals \
|
||||
|
||||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN = \
|
||||
# cpp11_hash_tables \ # not fully implemented yet
|
||||
# cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs
|
||||
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
|
||||
# cpp11_reference_wrapper \ # No typemaps
|
||||
|
||||
|
||||
#
|
||||
# Put all the heavy STD/STL cases here, where they can be skipped if needed
|
||||
#
|
||||
|
|
@ -507,11 +571,16 @@ ifndef SKIP_CPP_STD_CASES
|
|||
CPP_TEST_CASES += ${CPP_STD_TEST_CASES}
|
||||
endif
|
||||
|
||||
ifneq (,$(HAVE_CXX11_COMPILER))
|
||||
CPP_TEST_CASES += $(CPP11_TEST_CASES)
|
||||
endif
|
||||
|
||||
# C test cases. (Can be run individually using: make testcase.ctest)
|
||||
C_TEST_CASES += \
|
||||
arrays \
|
||||
bom_utf8 \
|
||||
c_delete \
|
||||
c_delete_function \
|
||||
char_constant \
|
||||
const_const \
|
||||
constant_expr \
|
||||
|
|
@ -519,11 +588,14 @@ C_TEST_CASES += \
|
|||
enums \
|
||||
enum_forward \
|
||||
enum_macro \
|
||||
enum_missing \
|
||||
extern_declaration \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
global_functions \
|
||||
immutable_values \
|
||||
inctest \
|
||||
infinity \
|
||||
integers \
|
||||
keyword_rename \
|
||||
lextype \
|
||||
|
|
@ -537,6 +609,7 @@ C_TEST_CASES += \
|
|||
memberin_extend_c \
|
||||
name \
|
||||
nested \
|
||||
nested_extend_c \
|
||||
nested_structs \
|
||||
newobject2 \
|
||||
overload_extend \
|
||||
|
|
@ -550,6 +623,7 @@ C_TEST_CASES += \
|
|||
simple_array \
|
||||
sizeof_pointer \
|
||||
sneaky1 \
|
||||
string_simple \
|
||||
struct_rename \
|
||||
struct_initialization \
|
||||
typedef_struct \
|
||||
|
|
@ -587,28 +661,43 @@ ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \
|
|||
$(CPP_TEST_BROKEN:=.clean) \
|
||||
$(C_TEST_BROKEN:=.clean)
|
||||
|
||||
#######################################################################
|
||||
# Error test suite has its own set of test cases
|
||||
#######################################################################
|
||||
ifneq (,$(ERROR_TEST_CASES))
|
||||
check: $(ERROR_TEST_CASES)
|
||||
else
|
||||
|
||||
#######################################################################
|
||||
# The following applies for all module languages
|
||||
#######################################################################
|
||||
all: $(BROKEN_TEST_CASES) $(NOT_BROKEN_TEST_CASES)
|
||||
all: $(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES)
|
||||
|
||||
check: $(NOT_BROKEN_TEST_CASES)
|
||||
broken: $(BROKEN_TEST_CASES)
|
||||
|
||||
check: $(NOT_BROKEN_TEST_CASES)
|
||||
|
||||
check-c: $(C_TEST_CASES:=.ctest)
|
||||
|
||||
check-cpp: $(CPP_TEST_CASES:=.cpptest)
|
||||
|
||||
check-cpp11: $(CPP11_TEST_CASES:=.cpptest)
|
||||
|
||||
endif
|
||||
|
||||
# partialcheck target runs SWIG only, ie no compilation or running of tests (for a subset of languages)
|
||||
partialcheck:
|
||||
$(MAKE) check CC=true CXX=true LDSHARED=true CXXSHARED=true RUNTOOL=true COMPILETOOL=true
|
||||
|
||||
broken: $(BROKEN_TEST_CASES)
|
||||
|
||||
swig_and_compile_cpp = \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
|
||||
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||
$(LANGUAGE)$(VARIANT)_cpp
|
||||
|
||||
swig_and_compile_c = \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
|
||||
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||
|
|
@ -616,7 +705,7 @@ swig_and_compile_c = \
|
|||
|
||||
swig_and_compile_multi_cpp = \
|
||||
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" 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" \
|
||||
|
|
@ -624,11 +713,11 @@ swig_and_compile_multi_cpp = \
|
|||
done
|
||||
|
||||
swig_and_compile_external = \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
TARGET="$*_wrap_hdr.h" \
|
||||
$(LANGUAGE)$(VARIANT)_externalhdr; \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS) $*_external.cxx" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
|
||||
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||
|
|
@ -637,10 +726,10 @@ swig_and_compile_external = \
|
|||
swig_and_compile_runtime = \
|
||||
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
|
||||
fi;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
%include "std_vector.i"
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGSCILAB) || defined(SWIGRUBY)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB)
|
||||
#define SWIG_GOOD_VECTOR
|
||||
%ignore std::vector<Space::Flow>::vector(size_type);
|
||||
%ignore std::vector<Space::Flow>::resize(size_type);
|
||||
|
|
@ -94,14 +94,16 @@ public:
|
|||
|
||||
namespace Space {
|
||||
class Flow {
|
||||
int x;
|
||||
public:
|
||||
Flow(int i) {}
|
||||
Flow(int i) : x(i) {}
|
||||
};
|
||||
|
||||
|
||||
class FlowFlow {
|
||||
int x;
|
||||
public:
|
||||
FlowFlow(int i) {}
|
||||
FlowFlow(int i) : x(i) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
16
Examples/test-suite/cpp11_alignment.i
Normal file
16
Examples/test-suite/cpp11_alignment.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module cpp11_alignment
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
int member;
|
||||
};
|
||||
const int align1 = alignof(A::member);
|
||||
%}
|
||||
|
||||
%{
|
||||
// alignas - not yet working
|
||||
struct alignas(16) S {
|
||||
int num;
|
||||
};
|
||||
alignas(double) unsigned char c[sizeof(double)];
|
||||
%}
|
||||
18
Examples/test-suite/cpp11_alternate_function_syntax.i
Normal file
18
Examples/test-suite/cpp11_alternate_function_syntax.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* This testcase checks whether SWIG correctly uses the new alternate functions
|
||||
declarations and definitions introduced in C++11. */
|
||||
%module cpp11_alternate_function_syntax
|
||||
|
||||
%inline %{
|
||||
struct SomeStruct {
|
||||
int addNormal(int x, int y);
|
||||
auto addAlternate(int x, int y) -> int;
|
||||
};
|
||||
|
||||
auto SomeStruct::addAlternate(int x, int y) -> int {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
int SomeStruct::addNormal(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
%}
|
||||
34
Examples/test-suite/cpp11_constexpr.i
Normal file
34
Examples/test-suite/cpp11_constexpr.i
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* This interface tests whether SWIG supports the new "constexpr" keyword
|
||||
introduced by C++11.
|
||||
*/
|
||||
%module cpp11_constexpr
|
||||
|
||||
%inline %{
|
||||
constexpr int AAA = 10;
|
||||
constexpr const int BBB = 20;
|
||||
constexpr int CCC() { return 30; }
|
||||
constexpr const int DDD() { return 40; }
|
||||
|
||||
constexpr int XXX() { return 10; }
|
||||
constexpr int YYY = XXX() + 100;
|
||||
|
||||
struct ConstExpressions {
|
||||
static constexpr const int JJJ = 100;
|
||||
static constexpr int KKK = 200;
|
||||
static const int LLL = 300;
|
||||
constexpr int MMM() { return 400; }
|
||||
constexpr const int NNN() { return 500; }
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
int Array10[AAA];
|
||||
int Array20[BBB];
|
||||
int Array30[CCC()];
|
||||
int Array40[DDD()];
|
||||
int Array100[ConstExpressions::JJJ];
|
||||
int Array200[ConstExpressions::KKK];
|
||||
int Array300[ConstExpressions::LLL];
|
||||
//int Array400[ConstExpressions::MMM()];
|
||||
//int Array500[ConstExpressions::NNN()];
|
||||
%}
|
||||
19
Examples/test-suite/cpp11_decltype.i
Normal file
19
Examples/test-suite/cpp11_decltype.i
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This testcase checks whether SWIG correctly uses the new 'decltype()'
|
||||
introduced in C++11.
|
||||
*/
|
||||
%module cpp11_decltype
|
||||
|
||||
%inline %{
|
||||
class A {
|
||||
public:
|
||||
int i;
|
||||
decltype(i) j;
|
||||
|
||||
auto foo( decltype(i) a ) -> decltype(i) {
|
||||
if (a==5)
|
||||
return 10;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
%}
|
||||
81
Examples/test-suite/cpp11_default_delete.i
Normal file
81
Examples/test-suite/cpp11_default_delete.i
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* This testcase checks whether SWIG correctly parses C++11 explicitly defaulted functions and deleted functions */
|
||||
%module cpp11_default_delete
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&);
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&);
|
||||
|
||||
%rename(Assignment) *::operator=;
|
||||
|
||||
%inline %{
|
||||
|
||||
class NonCopyable {
|
||||
public:
|
||||
NonCopyable& operator=(const NonCopyable&) = delete; /* Removes operator= */
|
||||
NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */
|
||||
NonCopyable() = default; /* Explicitly allows the empty constructor */
|
||||
void *operator new(size_t) = delete; /* Removes new NonCopyable */
|
||||
};
|
||||
|
||||
struct A1 {
|
||||
void func(int i) {}
|
||||
A1() = default;
|
||||
~A1() = default;
|
||||
void func(double i) = delete; /* Don't cast double to int. Compiler returns an error */
|
||||
private:
|
||||
A1(const A1&);
|
||||
};
|
||||
A1::A1(const A1&) = default;
|
||||
|
||||
struct A2 {
|
||||
void func(int i) {}
|
||||
virtual void fff(int) = delete;
|
||||
virtual ~A2() = default;
|
||||
template<class T> void func(T) = delete;
|
||||
};
|
||||
|
||||
struct trivial {
|
||||
trivial() = default;
|
||||
trivial(const trivial&) = default;
|
||||
trivial(trivial&&) = default;
|
||||
trivial& operator=(const trivial&) = default;
|
||||
trivial& operator=(trivial&&) = default;
|
||||
~trivial() = default;
|
||||
};
|
||||
|
||||
struct nontrivial1 {
|
||||
nontrivial1();
|
||||
};
|
||||
nontrivial1::nontrivial1() = default;
|
||||
|
||||
struct sometype {
|
||||
sometype() = delete;
|
||||
sometype(int) = delete;
|
||||
sometype(double);
|
||||
};
|
||||
sometype::sometype(double) {}
|
||||
|
||||
/* Not working with prerelease of gcc-4.8
|
||||
struct nonew {
|
||||
void *operator new(std::size_t) = delete;
|
||||
void *operator new[](std::size_t) = delete;
|
||||
};
|
||||
*/
|
||||
|
||||
struct moveonly {
|
||||
moveonly() = default;
|
||||
moveonly(const moveonly&) = delete;
|
||||
moveonly(moveonly&&) = default;
|
||||
moveonly& operator=(const moveonly&) = delete;
|
||||
moveonly& operator=(moveonly&&) = default;
|
||||
~moveonly() = default;
|
||||
};
|
||||
|
||||
struct ConstructorThrow {
|
||||
ConstructorThrow() throw() = default;
|
||||
ConstructorThrow(const ConstructorThrow&) throw() = delete;
|
||||
ConstructorThrow(ConstructorThrow&&) throw() = delete;
|
||||
ConstructorThrow& operator=(const ConstructorThrow&) throw() = delete;
|
||||
~ConstructorThrow() throw() = default;
|
||||
};
|
||||
|
||||
%}
|
||||
18
Examples/test-suite/cpp11_delegating_constructors.i
Normal file
18
Examples/test-suite/cpp11_delegating_constructors.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* This test checks whether SWIG correctly parses the new delegating
|
||||
constructors.
|
||||
*/
|
||||
%module cpp11_delegating_constructors
|
||||
|
||||
%inline %{
|
||||
class A {
|
||||
public:
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
|
||||
A() : A( 10 ) {}
|
||||
A(int aa) : A(aa, 20) {}
|
||||
A(int aa, int bb) : A(aa, bb, 30) {}
|
||||
A(int aa, int bb, int cc) { a=aa; b=bb; c=cc; }
|
||||
};
|
||||
%}
|
||||
41
Examples/test-suite/cpp11_explicit_conversion_operators.i
Normal file
41
Examples/test-suite/cpp11_explicit_conversion_operators.i
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* This interface checks whether SWIG correctly compiles the new
|
||||
explicit conversion operators feature introduced in C++11.
|
||||
*/
|
||||
%module cpp11_explicit_conversion_operators
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_IDENTIFIER) Testable::operator bool;
|
||||
%rename(AsInteger) Testable::operator int;
|
||||
|
||||
%inline %{
|
||||
|
||||
class U {
|
||||
public:
|
||||
int u;
|
||||
};
|
||||
|
||||
class V {
|
||||
public:
|
||||
int v;
|
||||
};
|
||||
|
||||
class TestClass {
|
||||
public:
|
||||
//implicit converting constructor
|
||||
TestClass( U const &val ) { t=val.u; }
|
||||
// explicit constructor
|
||||
explicit TestClass( V const &val ) { t=val.v; }
|
||||
|
||||
int t;
|
||||
};
|
||||
|
||||
struct Testable {
|
||||
// explicit conversion operator
|
||||
explicit operator bool() const {
|
||||
return false;
|
||||
}
|
||||
explicit operator int() {
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
128
Examples/test-suite/cpp11_final_override.i
Normal file
128
Examples/test-suite/cpp11_final_override.i
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
// Test C++11 virtual specifier sequences (final and/or override on methods)
|
||||
// Also check final/override - the two 'identifiers with special meaning' work as normal identifiers
|
||||
|
||||
%module cpp11_final_override
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) final; // 'final' is a java keyword, renaming to '_final'
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) override; // 'override' is a C# keyword, renaming to '_override'
|
||||
|
||||
%inline %{
|
||||
|
||||
struct Base {
|
||||
virtual void stuff() const {}
|
||||
virtual void override1() const {}
|
||||
virtual void override2() const {}
|
||||
virtual void finaloverride1() {}
|
||||
virtual void finaloverride2() {}
|
||||
virtual void finaloverride3() {}
|
||||
virtual void finaloverride4() const {}
|
||||
virtual ~Base() {}
|
||||
};
|
||||
|
||||
struct Derived /*final*/ : Base {
|
||||
virtual void stuff() const noexcept override final {}
|
||||
virtual void override1() const noexcept override;
|
||||
virtual void override2() const noexcept override;
|
||||
virtual void final1() final {}
|
||||
virtual void final2() noexcept final {}
|
||||
virtual void final4() const final {}
|
||||
virtual void final5() const noexcept final {}
|
||||
virtual void finaloverride1() final override {}
|
||||
virtual void finaloverride2() override final {}
|
||||
virtual void finaloverride3() noexcept override final {}
|
||||
virtual void finaloverride4() const noexcept override final {}
|
||||
virtual ~Derived() override final {}
|
||||
};
|
||||
void Derived::override2() const noexcept {}
|
||||
|
||||
// Pure virtual methods
|
||||
struct PureBase {
|
||||
virtual void pure1(int) const = 0;
|
||||
virtual void pure2(int) const = 0;
|
||||
virtual void pure3(int) const = 0;
|
||||
virtual void pure4(int) const = 0;
|
||||
virtual void pure5(int) const = 0;
|
||||
virtual ~PureBase() {}
|
||||
};
|
||||
|
||||
struct PureDerived : PureBase {
|
||||
virtual void pure1(int) const override = 0;
|
||||
virtual void pure2(int) const final = 0;
|
||||
virtual void pure3(int) const override final = 0;
|
||||
virtual void pure4(int) const final override = 0;
|
||||
virtual void pure5(int) const noexcept final override = 0;
|
||||
virtual ~PureDerived() override final;
|
||||
};
|
||||
void PureDerived::pure1(int) const {}
|
||||
void PureDerived::pure2(int) const {}
|
||||
void PureDerived::pure3(int) const {}
|
||||
void PureDerived::pure4(int) const {}
|
||||
void PureDerived::pure5(int) const noexcept {}
|
||||
PureDerived::~PureDerived() {}
|
||||
|
||||
// Destructors and virtual specifier sequences (final/override)
|
||||
struct Destructors1 : Base {
|
||||
virtual ~Destructors1() override {}
|
||||
};
|
||||
struct Destructors2 : Base {
|
||||
virtual ~Destructors2() final {}
|
||||
};
|
||||
struct Destructors3 : Base {
|
||||
virtual ~Destructors3() noexcept final override {}
|
||||
};
|
||||
struct Destructors4 : Base {
|
||||
virtual ~Destructors4() noexcept override final {}
|
||||
};
|
||||
|
||||
// Check the two 'identifiers with special meaning' work as normal identifiers
|
||||
struct FinalOverrideMethods {
|
||||
virtual void final() {}
|
||||
virtual void override(int) {}
|
||||
};
|
||||
struct FinalOverrideVariables {
|
||||
int final;
|
||||
double override;
|
||||
};
|
||||
void final(int) {}
|
||||
void override() {}
|
||||
%}
|
||||
|
||||
%{
|
||||
void Derived::override1() const noexcept {}
|
||||
%}
|
||||
|
||||
// Example in documentation ... declarations only
|
||||
%inline %{
|
||||
struct BaseStruct {
|
||||
virtual void ab() const = 0;
|
||||
virtual void cd();
|
||||
virtual void ef();
|
||||
virtual ~BaseStruct();
|
||||
};
|
||||
struct DerivedStruct : BaseStruct {
|
||||
virtual void ab() const override;
|
||||
virtual void cd() final;
|
||||
virtual void ef() final override;
|
||||
virtual ~DerivedStruct() override;
|
||||
};
|
||||
struct DerivedNoVirtualStruct : BaseStruct {
|
||||
void ab() const override;
|
||||
void cd() final;
|
||||
void ef() final override;
|
||||
~DerivedNoVirtualStruct() override;
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
void BaseStruct::cd() {}
|
||||
void BaseStruct::ef() {}
|
||||
BaseStruct::~BaseStruct() {}
|
||||
void DerivedStruct::ab() const {}
|
||||
void DerivedStruct::cd() {}
|
||||
void DerivedStruct::ef() {}
|
||||
DerivedStruct::~DerivedStruct() {}
|
||||
void DerivedNoVirtualStruct::ab() const {}
|
||||
void DerivedNoVirtualStruct::cd() {}
|
||||
void DerivedNoVirtualStruct::ef() {}
|
||||
DerivedNoVirtualStruct::~DerivedNoVirtualStruct() {}
|
||||
%}
|
||||
35
Examples/test-suite/cpp11_function_objects.i
Normal file
35
Examples/test-suite/cpp11_function_objects.i
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* This testcase checks whether SWIG correctly parses function objects
|
||||
and the templates for the functions (signature).
|
||||
Function objects are objects which overload the operator() function.
|
||||
The std::function does not provide any seamless support in the target languages yet.
|
||||
*/
|
||||
%module cpp11_function_objects
|
||||
|
||||
%rename(__call__) Test::operator();
|
||||
|
||||
%inline %{
|
||||
struct Test {
|
||||
int value;
|
||||
|
||||
void operator()(int x, int y) {
|
||||
value=x+y;
|
||||
}
|
||||
Test() : value(0) {}
|
||||
} test;
|
||||
|
||||
#include <functional>
|
||||
std::function<void ( int, int )> pF = test;
|
||||
|
||||
int testit1(Test new_test, int a, int b) {
|
||||
pF = new_test;
|
||||
pF(a, b);
|
||||
return new_test.value;
|
||||
}
|
||||
|
||||
int testit2(int a, int b) {
|
||||
test(a, b);
|
||||
return test.value;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
43
Examples/test-suite/cpp11_hash_tables.i
Normal file
43
Examples/test-suite/cpp11_hash_tables.i
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* This testcase checks the new wrappers for the new unordered_ STL types
|
||||
introduced in C++11. */
|
||||
%module cpp11_hash_tables
|
||||
|
||||
%inline %{
|
||||
#include <set>
|
||||
//#include <map>
|
||||
#include <unordered_set>
|
||||
//#include <unordered_map>
|
||||
%}
|
||||
|
||||
%include "std_set.i"
|
||||
//%include "std_map.i"
|
||||
%include "std_unordered_set.i"
|
||||
//%include "std_unordered_map.i"
|
||||
%template (SetInt) std::set<int>;
|
||||
//%template (MapIntInt) std::map<int, int>;
|
||||
%template (UnorderedSetInt) std::unordered_set<int>;
|
||||
//%template (UnorderedMapIntInt) std::unordered_map<int, int>;
|
||||
|
||||
%inline %{
|
||||
using namespace std;
|
||||
|
||||
class MyClass {
|
||||
public:
|
||||
set<int> getSet() { return _set; }
|
||||
void addSet(int elt) { _set.insert(_set.begin(), elt); }
|
||||
// map<int, int> getMap() { return _map; }
|
||||
// void addMap(int elt1, int elt2) { _map.insert(make_pair(elt1, elt2)); }
|
||||
|
||||
unordered_set<int> getUnorderedSet() { return _unordered_set; }
|
||||
void addUnorderedSet(int elt) { _unordered_set.insert(_unordered_set.begin(), elt); }
|
||||
// unordered_map<int, int> getUnorderedMap() { return _unordered_map; }
|
||||
// void addUnorderedMap(int elt1, int elt2) { _unordered_map.insert(make_pair(elt1, elt2)); }
|
||||
private:
|
||||
set<int> _set;
|
||||
// map<int, int> _map;
|
||||
|
||||
unordered_set<int> _unordered_set;
|
||||
// unordered_map<int, int> _unordered_map;
|
||||
};
|
||||
%}
|
||||
|
||||
29
Examples/test-suite/cpp11_inheriting_constructors.i
Normal file
29
Examples/test-suite/cpp11_inheriting_constructors.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* This test checks whether SWIG correctly parses the new constructor
|
||||
inheritance.
|
||||
*/
|
||||
%module cpp11_inheriting_constructors
|
||||
|
||||
%inline %{
|
||||
// Delegating constructors
|
||||
class BaseClass {
|
||||
private:
|
||||
int _val;
|
||||
public:
|
||||
BaseClass(int iValue) { _val = iValue; }
|
||||
};
|
||||
|
||||
// Constructor inheritance via using declaration
|
||||
class DerivedClass: public BaseClass {
|
||||
public:
|
||||
using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
|
||||
};
|
||||
|
||||
// Member initialization at the site of the declaration
|
||||
class SomeClass {
|
||||
public:
|
||||
SomeClass() {}
|
||||
explicit SomeClass(int new_value) : value(new_value) {}
|
||||
|
||||
int value = 5;
|
||||
};
|
||||
%}
|
||||
34
Examples/test-suite/cpp11_initializer_list.i
Normal file
34
Examples/test-suite/cpp11_initializer_list.i
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* This testcase shows a few simple ways to deal with the new initializer_list
|
||||
introduced in C++11. */
|
||||
%module cpp11_initializer_list
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_INITIALIZER_LIST) B::B;
|
||||
%ignore A::A(std::initializer_list<int>);
|
||||
%ignore B::method;
|
||||
|
||||
%typemap(in) std::initializer_list<const char *> {
|
||||
$1 = {"Ab", "Fab"};
|
||||
}
|
||||
|
||||
%inline %{
|
||||
#include <initializer_list>
|
||||
|
||||
class A {
|
||||
public:
|
||||
A(std::initializer_list<int>) {}
|
||||
A() {}
|
||||
A(double d) {}
|
||||
};
|
||||
class B {
|
||||
public:
|
||||
B(std::initializer_list<int>, std::initializer_list<double>) {}
|
||||
B() {}
|
||||
void method(std::initializer_list<int> init) {}
|
||||
};
|
||||
class C {
|
||||
public:
|
||||
C(std::initializer_list<const char *>) {}
|
||||
C() {}
|
||||
};
|
||||
%}
|
||||
|
||||
29
Examples/test-suite/cpp11_initializer_list_extend.i
Normal file
29
Examples/test-suite/cpp11_initializer_list_extend.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* This testcase shows how to replace std_initializer_list with std_vector. */
|
||||
|
||||
%module cpp11_initializer_list_extend
|
||||
|
||||
%ignore Container::Container(std::initializer_list<int>);
|
||||
%include <std_vector.i>
|
||||
%template(VectorInt) std::vector<int>;
|
||||
|
||||
%extend Container {
|
||||
Container(const std::vector<int> &elements) {
|
||||
Container *c = new Container();
|
||||
for (int element : elements)
|
||||
c->push_back(element);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%inline %{
|
||||
#include <initializer_list>
|
||||
|
||||
class Container {
|
||||
public:
|
||||
Container(std::initializer_list<int>) {}
|
||||
Container() {}
|
||||
void push_back(const int&) {}
|
||||
};
|
||||
%}
|
||||
|
||||
110
Examples/test-suite/cpp11_lambda_functions.i
Normal file
110
Examples/test-suite/cpp11_lambda_functions.i
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/* This testcase checks whether SWIG correctly parses the lambda expressions
|
||||
and closure syntax introduced in C++11.
|
||||
SWIG supports only lambda syntax and doesn't produce any wrapper code for
|
||||
this.
|
||||
*/
|
||||
%module cpp11_lambda_functions
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda1;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda2;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda3;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda4;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda5;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda6;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda7;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda8;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda9;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda10;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda11;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda12;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda13;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda14;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda15;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda16;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda17;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda18;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::lambda19;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::Space2::lambda20;
|
||||
|
||||
%inline %{
|
||||
/* Defined lambda function with return value. */
|
||||
auto lambda1 = [](int x, int y) -> int { return x+y; };
|
||||
|
||||
/* Defined lambda function without return value.
|
||||
Return value is calculated by compiler, if the function contains a
|
||||
single statement "return expr;". */
|
||||
auto lambda2 = [](int x, int y) { return x+y; };
|
||||
|
||||
auto lambda3 = [&](int x, int y) { return x+y; };
|
||||
auto lambda4 = [=](int x, int y) { return x+y; };
|
||||
int thing = 0;
|
||||
#ifdef SWIG
|
||||
// Not strictly correct as captured variables should have non-automatic storage duration, ie shouldn't capture globals. gcc-4.7 warns about this, but we check that SWIG can parse this anyway.
|
||||
auto lambda5 = [=,&thing]() { return thing; };
|
||||
#else
|
||||
auto lambda5 = [=]() { return thing; };
|
||||
#endif
|
||||
|
||||
void fn() {
|
||||
int stuff = 0;
|
||||
auto lambdaxxxx = [=,&stuff]() { return thing; };
|
||||
}
|
||||
auto lambda6 = [] (int a, int b) mutable { return a + b; };
|
||||
auto lambda7 = [] (int x, int y) -> int { return x+y; };
|
||||
auto lambda8 = [] (int x, int y) throw() -> int { return x+y; };
|
||||
auto lambda9 = [] (int x, int y) mutable throw() -> int { return x+y; };
|
||||
auto lambda10 = [] (int x, int y) throw(int) { return x+y; };
|
||||
auto lambda11 = [] (int x, int y) mutable throw(int) { return x+y; };
|
||||
auto lambda12 = [] (int a, int b) { return a + b; }(1, 2);
|
||||
auto lambda13 = [] (int a, int b) mutable { return a + b; }(1, 2);
|
||||
auto lambda14 = [] () throw () {};
|
||||
auto lambda15 = [] () mutable throw () {};
|
||||
auto lambda16 = [] { return thing; };
|
||||
auto lambda17 = [] { return thing; }();
|
||||
constexpr auto lambda18 = [] (int x, int y) mutable throw(int) { return x+y; };
|
||||
|
||||
namespace Space1 {
|
||||
constexpr auto lambda19 = [] (int x, int y) mutable throw(int) { return x+y; };
|
||||
namespace Space2 {
|
||||
constexpr auto lambda20 = [] (int x, int y) mutable throw(int) { return x+y; };
|
||||
}
|
||||
}
|
||||
|
||||
int runLambda1() {
|
||||
return lambda1(5,6);
|
||||
}
|
||||
|
||||
int runLambda2() {
|
||||
return lambda2(5,6);
|
||||
}
|
||||
|
||||
int runLambda3() {
|
||||
return lambda3(5,6);
|
||||
}
|
||||
|
||||
int runLambda4() {
|
||||
return lambda4(5,6);
|
||||
}
|
||||
|
||||
int runLambda5() {
|
||||
thing++;
|
||||
return lambda5();
|
||||
}
|
||||
|
||||
/* Inline defined lambda function. */
|
||||
int runLambdaInline() {
|
||||
auto myLambda = [](int x, int y) { return x+y; };
|
||||
return myLambda(5,6);
|
||||
}
|
||||
%}
|
||||
|
||||
%{
|
||||
// TODO
|
||||
struct LambdaStruct {
|
||||
static constexpr auto lambda_struct1 = [=]() { return thing; };
|
||||
};
|
||||
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
|
||||
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
|
||||
void lambda_init(int = ([=]{ return 0; })());
|
||||
%}
|
||||
|
||||
49
Examples/test-suite/cpp11_noexcept.i
Normal file
49
Examples/test-suite/cpp11_noexcept.i
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
%module cpp11_noexcept
|
||||
|
||||
%ignore NoExceptClass(NoExceptClass&&);
|
||||
%rename(Assignment) NoExceptClass::operator=;
|
||||
|
||||
%inline %{
|
||||
|
||||
extern "C" void global_noexcept(int, bool) noexcept;
|
||||
|
||||
struct NoExceptClass {
|
||||
static const bool VeryTrue = true;
|
||||
|
||||
NoExceptClass() noexcept {}
|
||||
NoExceptClass(const NoExceptClass&) noexcept {}
|
||||
NoExceptClass(NoExceptClass&&) noexcept {}
|
||||
NoExceptClass& operator=(const NoExceptClass&) noexcept {}
|
||||
~NoExceptClass() noexcept {}
|
||||
|
||||
void noex0() noexcept {}
|
||||
void noex1() noexcept(sizeof(int) == 4) {}
|
||||
void noex2() noexcept(true) {}
|
||||
void noex3() noexcept(false) {}
|
||||
void noex4() noexcept(VeryTrue) {}
|
||||
|
||||
template<typename T> void template_noexcept(T) noexcept {}
|
||||
|
||||
void noo1() const noexcept {}
|
||||
static void noo2() noexcept {}
|
||||
virtual void noo3() const noexcept {}
|
||||
virtual void noo4() const noexcept = delete;
|
||||
virtual void noo5() const throw() = delete;
|
||||
};
|
||||
|
||||
struct NoExceptAbstract {
|
||||
virtual void noo4() const noexcept = 0;
|
||||
virtual ~NoExceptAbstract() noexcept = 0;
|
||||
};
|
||||
|
||||
struct NoExceptDefaultDelete {
|
||||
template<typename T> NoExceptDefaultDelete(T) noexcept = delete;
|
||||
NoExceptDefaultDelete() noexcept = default;
|
||||
NoExceptDefaultDelete(const NoExceptDefaultDelete&) noexcept = delete;
|
||||
NoExceptDefaultDelete(NoExceptDefaultDelete&&) = delete;
|
||||
NoExceptDefaultDelete& operator=(const NoExceptDefaultDelete&) = delete;
|
||||
~NoExceptDefaultDelete() noexcept = default;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
22
Examples/test-suite/cpp11_null_pointer_constant.i
Normal file
22
Examples/test-suite/cpp11_null_pointer_constant.i
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* This testcase checks whether SWIG correctly treats the new nullptr_t
|
||||
constant introduced in C++11.
|
||||
*/
|
||||
|
||||
%module cpp11_null_pointer_constant
|
||||
|
||||
%feature("autodoc") A::NullPtrMethod; // Triggers conversion of nullptr to None, nil etc in target language
|
||||
%feature("compactdefaultargs") A::NullPtrMethod;
|
||||
|
||||
%inline %{
|
||||
|
||||
const int *const MyIntegerPtr = nullptr;
|
||||
|
||||
class A {
|
||||
public:
|
||||
A() : _myA(nullptr) { }
|
||||
|
||||
A *_myA;
|
||||
|
||||
void NullPtrMethod(double *ptr = nullptr) {}
|
||||
};
|
||||
%}
|
||||
59
Examples/test-suite/cpp11_raw_string_literals.i
Normal file
59
Examples/test-suite/cpp11_raw_string_literals.i
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* This module tests whether SWIG correctly parses:
|
||||
- ordinary strings (char_t)
|
||||
- L wide strings (wchar_t)
|
||||
- u8 unicode8 strings (char_t)
|
||||
- u unicode16 strings (char16_t)
|
||||
- U unicode32 strings (char32_t)
|
||||
|
||||
This module also tests whether SWIG correctly parses custom string delimiters.
|
||||
*/
|
||||
%module cpp11_raw_string_literals
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) bb;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) ee;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) gg;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) xx;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) dd;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) hh;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ii;
|
||||
|
||||
%include <std_wstring.i>
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int L = 100;
|
||||
int u8 = 100;
|
||||
int u = 100;
|
||||
struct UStruct {
|
||||
static const int U = 100;
|
||||
};
|
||||
|
||||
int R = 100;
|
||||
int LR = 100;
|
||||
int u8R = 100;
|
||||
int uR = 100;
|
||||
struct URStruct {
|
||||
static const int UR = 100;
|
||||
};
|
||||
|
||||
// New string literals
|
||||
wstring aa = L"Wide string";
|
||||
const char *bb = u8"UTF-8 string";
|
||||
const char16_t *cc = u"UTF-16 string";
|
||||
const char32_t *dd = U"UTF-32 string";
|
||||
%}
|
||||
|
||||
/* Raw string literals */
|
||||
%inline %{
|
||||
const char *xx = ")I'm an \"ascii\" \\ string.";
|
||||
const char *ee = R"XXX()I'm an "ascii" \ string.)XXX";
|
||||
wstring ff = LR"XXX(I'm a "raw wide" \ string.)XXX";
|
||||
const char *gg = u8R"XXX(I'm a "raw UTF-8" \ string.)XXX";
|
||||
const char16_t *hh = uR"XXX(I'm a "raw UTF-16" \ string.)XXX";
|
||||
const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";
|
||||
%}
|
||||
|
||||
36
Examples/test-suite/cpp11_reference_wrapper.i
Normal file
36
Examples/test-suite/cpp11_reference_wrapper.i
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
%module cpp11_reference_wrapper
|
||||
|
||||
// SWIG could provide some sort of typemaps for reference_wrapper which is acts like a C++ reference,
|
||||
// but is copy-constructible and copy-assignable
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
using namespace std;
|
||||
|
||||
struct B {
|
||||
B(int &val) : val(val) {}
|
||||
std::reference_wrapper<int> val;
|
||||
// int &val;
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void go() {
|
||||
int val(999);
|
||||
B b1(val);
|
||||
int const& aa1 = b1.val;
|
||||
cout << aa1 << endl;
|
||||
|
||||
// copy constructible
|
||||
B b2(b1);
|
||||
int const& aa2 = b2.val;
|
||||
cout << aa2 << endl;
|
||||
|
||||
// copy assignable
|
||||
B b3(val);
|
||||
b3 = b1;
|
||||
int const& aa3 = b3.val;
|
||||
cout << aa3 << endl;
|
||||
}
|
||||
%}
|
||||
57
Examples/test-suite/cpp11_result_of.i
Normal file
57
Examples/test-suite/cpp11_result_of.i
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/* This testcase checks whether SWIG correctly uses the new result_of class
|
||||
and its templating capabilities introduced in C++11. */
|
||||
%module cpp11_result_of
|
||||
|
||||
%inline %{
|
||||
#include <functional>
|
||||
typedef double(*fn_ptr)(double);
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
// Forward declaration of result_of
|
||||
template<typename Func> struct result_of;
|
||||
// Add in the required partial specialization of result_of
|
||||
template<> struct result_of< fn_ptr(double) > {
|
||||
typedef double type;
|
||||
};
|
||||
}
|
||||
|
||||
%template() std::result_of< fn_ptr(double) >;
|
||||
|
||||
%inline %{
|
||||
|
||||
double square(double x) {
|
||||
return (x * x);
|
||||
}
|
||||
|
||||
template<class Fun, class Arg>
|
||||
typename std::result_of<Fun(Arg)>::type test_result_impl(Fun fun, Arg arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
|
||||
std::result_of< fn_ptr(double) >::type test_result_alternative1(double(*fun)(double), double arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
%}
|
||||
|
||||
%{
|
||||
// Another alternative approach using decltype (not very SWIG friendly)
|
||||
std::result_of< decltype(square)&(double) >::type test_result_alternative2(double(*fun)(double), double arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
|
||||
void cpp_testing() {
|
||||
std::cout << "result: " << test_result_impl(square, 3) << std::endl;
|
||||
std::cout << "result: " << test_result_impl<double(*)(double), double>(square, 4) << std::endl;
|
||||
std::cout << "result: " << test_result_impl< fn_ptr, double >(square, 5) << std::endl;
|
||||
std::cout << "result: " << test_result_alternative1(square, 6) << std::endl;
|
||||
std::cout << "result: " << test_result_alternative2(square, 7) << std::endl;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(test_result) test_result_impl< fn_ptr, double>;
|
||||
%constant double (*SQUARE)(double) = square;
|
||||
22
Examples/test-suite/cpp11_rvalue_reference.i
Normal file
22
Examples/test-suite/cpp11_rvalue_reference.i
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* This testcase checks whether SWIG correctly parses the double ampersand &&
|
||||
move operator which is currently mapped to the reference & operator. */
|
||||
%module cpp11_rvalue_reference
|
||||
|
||||
%inline %{
|
||||
#include <utility>
|
||||
class A {
|
||||
public:
|
||||
int getAcopy() { return _a; }
|
||||
int *getAptr() { return &_a; }
|
||||
int &getAref() { return _a; }
|
||||
int &&getAmove() { return std::move(_a); }
|
||||
|
||||
void setAcopy(int a) { _a = a; }
|
||||
void setAptr(int *a) { _a = *a; }
|
||||
void setAref(int &a) { _a = a; }
|
||||
void setAmove(int &&a) { _a = a; }
|
||||
|
||||
private:
|
||||
int _a;
|
||||
};
|
||||
%}
|
||||
86
Examples/test-suite/cpp11_rvalue_reference2.i
Normal file
86
Examples/test-suite/cpp11_rvalue_reference2.i
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
%module cpp11_rvalue_reference2
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) globalrrval;
|
||||
|
||||
// This testcase tests lots of different places that rvalue reference syntax can be used
|
||||
|
||||
%typemap(in) Something && "/*in Something && typemap*/"
|
||||
%rename(OperatorRValue) Thingy::operator int&&;
|
||||
%rename(memberFnRenamed) memberFn(short &&i);
|
||||
%feature("compactdefaultargs") Thingy::compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef);
|
||||
%feature("exception") Thingy::privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue);
|
||||
%ignore Thingy::operator=;
|
||||
|
||||
%inline %{
|
||||
#include <utility>
|
||||
struct UserDef {
|
||||
int a;
|
||||
};
|
||||
static const bool PublicGlobalTrue = true;
|
||||
static const UserDef PublicUserDef = UserDef();
|
||||
struct Thingy {
|
||||
typedef int Integer;
|
||||
int val;
|
||||
int &lvalref;
|
||||
int &&rvalref;
|
||||
Thingy(int v) : val(v), lvalref(val), rvalref(22) {}
|
||||
void refIn(long &i) {}
|
||||
void rvalueIn(long &&i) {}
|
||||
short && rvalueInOut(short &&i) { return std::move(i); }
|
||||
static short && staticRvalueInOut(short &&i) { return std::move(i); }
|
||||
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
|
||||
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
|
||||
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
|
||||
operator int &&() {}
|
||||
Thingy& operator=(const Thingy& rhs) {
|
||||
val = rhs.val;
|
||||
lvalref = rhs.lvalref;
|
||||
rvalref = rhs.rvalref;
|
||||
}
|
||||
private:
|
||||
static const bool PrivateTrue;
|
||||
Thingy();
|
||||
};
|
||||
const bool Thingy::PrivateTrue = true;
|
||||
|
||||
short && globalRvalueInOut(short &&i) { return std::move(i); }
|
||||
|
||||
Thingy &&globalrrval = Thingy(55);
|
||||
|
||||
short && func(short &&i) { return std::move(i); }
|
||||
Thingy getit() { return Thingy(22); }
|
||||
|
||||
void rvalrefFunction1(int &&v = (int &&)5) {}
|
||||
void rvalrefFunctionBYVAL(short (Thingy::*memFunc)(short)) {}
|
||||
void rvalrefFunctionLVALUE(short &(Thingy::*memFunc)(short &)) {}
|
||||
void rvalrefFunction2(short && (Thingy::*memFunc)(short &&)) {}
|
||||
void rvalrefFunction3(short && (*memFunc)(short &&)) {}
|
||||
|
||||
template <typename T> struct RemoveReference {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T> struct RemoveReference<T&> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T> struct RemoveReference<T&&> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <> struct RemoveReference<short &&> {
|
||||
typedef short type;
|
||||
};
|
||||
|
||||
// like std::move
|
||||
template <typename T> typename RemoveReference<T>::type&& Move(T&& t) {
|
||||
return static_cast<typename RemoveReference<T>::type&&>(t);
|
||||
}
|
||||
%}
|
||||
|
||||
%template(RemoveReferenceDouble) RemoveReference<double &&>;
|
||||
%template(RemoveReferenceFloat) RemoveReference<float &&>;
|
||||
%template(RemoveReferenceShort) RemoveReference<short &&>;
|
||||
%template(MoveFloat) Move<float>;
|
||||
|
||||
|
||||
67
Examples/test-suite/cpp11_rvalue_reference3.i
Normal file
67
Examples/test-suite/cpp11_rvalue_reference3.i
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
%module cpp11_rvalue_reference3
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
|
||||
|
||||
%inline %{
|
||||
#include <utility>
|
||||
struct Thing {};
|
||||
|
||||
Thing && global_rvalue_ref = Thing();
|
||||
Thing *&& global_rvalue_ref_ptr1 = 0;
|
||||
Thing const*&& global_rvalue_ref_ptr2 = 0;
|
||||
Thing *const&& global_rvalue_ref_ptr3 = 0;
|
||||
Thing const*const &&global_rvalue_ref_ptr4 = 0;
|
||||
|
||||
Thing && returnit1() { return std::move(global_rvalue_ref); }
|
||||
Thing *&& returnit2() { return std::move(global_rvalue_ref_ptr1); }
|
||||
Thing const*&& returnit3() { return std::move(global_rvalue_ref_ptr2); }
|
||||
Thing *const&& returnit4() { return std::move(global_rvalue_ref_ptr3); }
|
||||
Thing const*const&& returnit5() { return std::move(global_rvalue_ref_ptr4); }
|
||||
|
||||
void takeit1(Thing && t) {}
|
||||
void takeit2(Thing *&& t) {}
|
||||
void takeit3(Thing const*&& t) {}
|
||||
void takeit4(Thing *const&& t) {}
|
||||
void takeit5(Thing const*const&& t) {}
|
||||
|
||||
struct Containing {
|
||||
Thing && member_rvalue_ref;
|
||||
Thing *&& member_rvalue_ref_ptr1 = 0;
|
||||
Thing const*&& member_rvalue_ref_ptr2 = 0;
|
||||
Thing *const&& member_rvalue_ref_ptr3 = 0;
|
||||
Thing const*const &&member_rvalue_ref_ptr4 = 0;
|
||||
|
||||
Containing() : member_rvalue_ref(Thing()) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
int && int_global_rvalue_ref = 5;
|
||||
int *&& int_global_rvalue_ref_ptr1 = 0;
|
||||
int const*&& int_global_rvalue_ref_ptr2 = 0;
|
||||
int *const&& int_global_rvalue_ref_ptr3 = 0;
|
||||
int const*const &&int_global_rvalue_ref_ptr4 = 0;
|
||||
|
||||
int && int_returnit1() { return std::move(int_global_rvalue_ref); }
|
||||
int *&& int_returnit2() { return std::move(int_global_rvalue_ref_ptr1); }
|
||||
int const*&& int_returnit3() { return std::move(int_global_rvalue_ref_ptr2); }
|
||||
int *const&& int_returnit4() { return std::move(int_global_rvalue_ref_ptr3); }
|
||||
int const*const&& int_returnit5() { return std::move(int_global_rvalue_ref_ptr4); }
|
||||
|
||||
void int_takeit1(int && t) {}
|
||||
void int_takeit2(int *&& t) {}
|
||||
void int_takeit3(int const*&& t) {}
|
||||
void int_takeit4(int *const&& t) {}
|
||||
void int_takeit5(int const*const&& t) {}
|
||||
|
||||
struct IntContaining {
|
||||
int && member_rvalue_ref;
|
||||
int *&& member_rvalue_ref_ptr1 = 0;
|
||||
int const*&& member_rvalue_ref_ptr2 = 0;
|
||||
int *const&& member_rvalue_ref_ptr3 = 0;
|
||||
int const*const &&member_rvalue_ref_ptr4 = 0;
|
||||
|
||||
IntContaining() : member_rvalue_ref(55) {}
|
||||
};
|
||||
%}
|
||||
17
Examples/test-suite/cpp11_sizeof_object.i
Normal file
17
Examples/test-suite/cpp11_sizeof_object.i
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* This testcase checks whether SWIG correctly uses the sizeof() on the
|
||||
concrete objects and not only types introduced in C++11. */
|
||||
%module cpp11_sizeof_object
|
||||
|
||||
%inline %{
|
||||
struct B {
|
||||
unsigned long member1;
|
||||
long long member2;
|
||||
char member3;
|
||||
};
|
||||
|
||||
struct A {
|
||||
B member;
|
||||
};
|
||||
|
||||
const int a = sizeof(A::member);
|
||||
%}
|
||||
17
Examples/test-suite/cpp11_static_assert.i
Normal file
17
Examples/test-suite/cpp11_static_assert.i
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* This test case checks whether SWIG correctly parses and ignores the
|
||||
keywords "static_assert()" inside the class or struct.
|
||||
*/
|
||||
%module cpp11_static_assert
|
||||
|
||||
%inline %{
|
||||
template <typename T>
|
||||
struct Check1 {
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class Check2 {
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
%}
|
||||
|
||||
87
Examples/test-suite/cpp11_strongly_typed_enumerations.i
Normal file
87
Examples/test-suite/cpp11_strongly_typed_enumerations.i
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/* This testcase checks whether SWIG produces the correct wrapper for the
|
||||
strongly typed enums. Enums with the same type are comparable. Enum classes
|
||||
require support for nested classes. */
|
||||
%module cpp11_strongly_typed_enumerations
|
||||
%warnfilter(302) Val1;
|
||||
%warnfilter(302) Val2;
|
||||
%warnfilter(302) Val3;
|
||||
%warnfilter(302) Val4;
|
||||
|
||||
/* Forward declarations (illegally accepted by SWIG - oh well!) */
|
||||
enum Enum1 : short;
|
||||
enum Enum3;
|
||||
enum ;
|
||||
enum : unsigned short;
|
||||
|
||||
%inline %{
|
||||
enum class Enum1 {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3 = 100,
|
||||
Val4 /* = 101 */
|
||||
};
|
||||
|
||||
enum class Enum2 : short {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3 = 100,
|
||||
Val4
|
||||
};
|
||||
%}
|
||||
|
||||
// SWIG should fail this one
|
||||
enum Enum2 : unsigned short; // Illegal in C++11, because Enum2 was previously declared with a different type.
|
||||
|
||||
%inline %{
|
||||
/* Forward declarations. */
|
||||
enum Enum4 : unsigned int; // Legal in C++11.
|
||||
enum class Enum5; // Legal in C++11, because enum class declarations have a default type of "int".
|
||||
enum class Enum6 : unsigned int; // Legal C++11.
|
||||
|
||||
enum Enum4 : unsigned int {
|
||||
Val1, Val2, Val3 = 100, Val4
|
||||
};
|
||||
|
||||
enum class Enum5 {
|
||||
Val1, Val2, Val3 = 100, Val4
|
||||
};
|
||||
|
||||
enum class Enum6 : unsigned int {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
};
|
||||
|
||||
typedef enum class Enum7 : unsigned int {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
} Enum7td;
|
||||
|
||||
// enum inherits from non-primitive type
|
||||
enum class Enum8 : size_t {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
};
|
||||
|
||||
template <typename T> struct TType {
|
||||
typedef T type_name;
|
||||
};
|
||||
|
||||
enum class Enum10 : TType<int>::type_name {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
};
|
||||
|
||||
// forward declaration, no definition of enum
|
||||
enum class Enum11 : int;
|
||||
struct UseEnum11 {
|
||||
Enum11 myenum11;
|
||||
};
|
||||
|
||||
/*
|
||||
TODO
|
||||
enum class MyClass {AAA, BBB, CCC};
|
||||
namespace Space {
|
||||
enum MyEnum {XXX, YYY, ZZZ};
|
||||
}
|
||||
struct SSS {
|
||||
MyClass m;
|
||||
};
|
||||
*/
|
||||
%}
|
||||
|
||||
53
Examples/test-suite/cpp11_template_double_brackets.i
Normal file
53
Examples/test-suite/cpp11_template_double_brackets.i
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* This interface checks whether SWIG supports the new double angled brackets
|
||||
in the template syntax without having a space inbetween. This feature was
|
||||
introduced in new C++11 standard.
|
||||
*/
|
||||
%module cpp11_template_double_brackets
|
||||
%inline %{
|
||||
#include <map>
|
||||
std::map<int,std::map<int, double>> map1;
|
||||
std::map< int,std::map<int, double> > map2;
|
||||
|
||||
std::map<int,std::map<int, std::map<int, double>>> map3;
|
||||
std::map<int,std::map<int, std::map<int, std::map<int, double>>>> map4;
|
||||
%}
|
||||
|
||||
// Check streaming operators are still okay
|
||||
%rename(ExtractionOperator) operator>>;
|
||||
%rename(InsertionOperator) operator<<;
|
||||
|
||||
%inline %{
|
||||
class ABC {
|
||||
public:
|
||||
int a;
|
||||
int operator>>(ABC &) { return 0; }
|
||||
int operator<<(ABC &) { return 0; }
|
||||
};
|
||||
|
||||
class DEF {
|
||||
public:
|
||||
int a;
|
||||
int operator<<(DEF &) { return 0; }
|
||||
int operator>>(DEF &) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class ABC2 {
|
||||
public:
|
||||
int a;
|
||||
|
||||
template<typename U>
|
||||
U operator>>(ABC &);
|
||||
|
||||
template<typename U>
|
||||
U operator<<(ABC &);
|
||||
};
|
||||
%}
|
||||
|
||||
// Test shifts are still working
|
||||
%inline %{
|
||||
int shift_init1 = 4 << 2 >> 1;
|
||||
int shift_init2 = 4 >> 2 << 1 << 1 >> 2;
|
||||
%}
|
||||
|
||||
31
Examples/test-suite/cpp11_template_explicit.i
Normal file
31
Examples/test-suite/cpp11_template_explicit.i
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* This unit tests whether SWIG correctly parses the code and makes wrappers
|
||||
for the new C++11 extern templates (explicit template instantiation without
|
||||
using the translation unit).
|
||||
*/
|
||||
%module cpp11_template_explicit
|
||||
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_EXPLICIT_TEMPLATE
|
||||
|
||||
%inline %{
|
||||
|
||||
template<typename T> struct Temper {
|
||||
T val;
|
||||
};
|
||||
|
||||
class A {
|
||||
public:
|
||||
int member;
|
||||
int memberFunction() { return 100; }
|
||||
};
|
||||
|
||||
template class Temper<A>;
|
||||
extern template class Temper<A>;
|
||||
|
||||
template class Temper<A*>;
|
||||
extern template class Temper<A*>;
|
||||
|
||||
template class Temper<int>;
|
||||
extern template class Temper<int>;
|
||||
%}
|
||||
|
||||
%template(TemperInt) Temper<int>;
|
||||
32
Examples/test-suite/cpp11_template_typedefs.i
Normal file
32
Examples/test-suite/cpp11_template_typedefs.i
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* This testcase checks whether SWIG correctly parses alias templates. */
|
||||
%module cpp11_template_typedefs
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
|
||||
|
||||
%inline %{
|
||||
template< typename T1, typename T2, int >
|
||||
class SomeType {
|
||||
T1 a;
|
||||
T2 b;
|
||||
int c;
|
||||
};
|
||||
|
||||
// template aliasing
|
||||
template< typename T2 >
|
||||
using TypedefName = SomeType<char*, T2, 5>;
|
||||
|
||||
// type aliasing
|
||||
typedef void (*PFD)(double); // Old style
|
||||
using PF = void (*)(double); // New introduced syntax
|
||||
|
||||
|
||||
// use of template aliasing
|
||||
template<typename Key,typename Val>
|
||||
class MyCPP11Class {
|
||||
};
|
||||
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
|
||||
MyIntKeyClass<char> intchar;
|
||||
%}
|
||||
|
||||
33
Examples/test-suite/cpp11_thread_local.i
Normal file
33
Examples/test-suite/cpp11_thread_local.i
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* This testcase checks whether SWIG correctly parses the 'thread_local' storage specifier */
|
||||
|
||||
%module cpp11_thread_local
|
||||
|
||||
%inline %{
|
||||
struct ThreadLocals {
|
||||
// thread_local int tval; // members must also be declared static
|
||||
static thread_local int stval;
|
||||
thread_local static int tsval;
|
||||
static thread_local const int stcval88 = 88;
|
||||
thread_local static const int tscval99 = 99;
|
||||
};
|
||||
thread_local int tval;
|
||||
static thread_local int stval;
|
||||
thread_local static int tsval;
|
||||
extern thread_local int etval;
|
||||
thread_local extern int teval;
|
||||
extern "C" thread_local int ectval;
|
||||
extern "C++" thread_local int ecpptval;
|
||||
|
||||
thread_local int ThreadLocals::stval = 11;
|
||||
thread_local int ThreadLocals::tsval = 22;
|
||||
thread_local const int ThreadLocals::stcval88;
|
||||
thread_local const int ThreadLocals::tscval99;
|
||||
%}
|
||||
|
||||
%{
|
||||
// externs
|
||||
thread_local int etval = 33;
|
||||
thread_local int teval = 44;
|
||||
thread_local int ectval = 55;
|
||||
thread_local int ecpptval = 66;
|
||||
%}
|
||||
29
Examples/test-suite/cpp11_type_traits.i
Normal file
29
Examples/test-suite/cpp11_type_traits.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
%module cpp11_type_traits
|
||||
|
||||
// The example in the CPlusPlus11.html documentation.
|
||||
// This doesn't really directly test functionality in type_traits as it doesn't provide
|
||||
// much for use by target languages, rather it tests usage of it.
|
||||
|
||||
%inline %{
|
||||
#include <type_traits>
|
||||
|
||||
// First way of operating.
|
||||
template< bool B > struct algorithm {
|
||||
template< class T1, class T2 > static int do_it(T1 &, T2 &) { /*...*/ return 1; }
|
||||
};
|
||||
|
||||
// Second way of operating.
|
||||
template<> struct algorithm<true> {
|
||||
template< class T1, class T2 > static int do_it(T1, T2) { /*...*/ return 2; }
|
||||
};
|
||||
|
||||
// Instantiating 'elaborate' will automatically instantiate the correct way to operate, depending on the types used.
|
||||
template< class T1, class T2 > int elaborate(T1 A, T2 B) {
|
||||
// Use the second way only if 'T1' is an integer and if 'T2' is
|
||||
// a floating point, otherwise use the first way.
|
||||
return algorithm< std::is_integral<T1>::value && std::is_floating_point<T2>::value >::do_it(A, B);
|
||||
}
|
||||
%}
|
||||
|
||||
%template(Elaborate) elaborate<int, int>;
|
||||
%template(Elaborate) elaborate<int, double>;
|
||||
49
Examples/test-suite/cpp11_uniform_initialization.i
Normal file
49
Examples/test-suite/cpp11_uniform_initialization.i
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* This testcase checks whether SWIG syntactically correctly parses the initialization syntax using
|
||||
{} braces for uniform member initialization. */
|
||||
%module cpp11_uniform_initialization
|
||||
|
||||
%include <std_vector.i>
|
||||
|
||||
%template(VectorInt) std::vector<int>;
|
||||
|
||||
%inline %{
|
||||
struct BasicStruct {
|
||||
int x;
|
||||
double y;
|
||||
};
|
||||
|
||||
struct AltStruct {
|
||||
AltStruct(int x, double y) : x_{x}, y_{y} {}
|
||||
int getX() { return x_; }
|
||||
double getY() { return y_; }
|
||||
|
||||
private:
|
||||
int x_;
|
||||
double y_;
|
||||
};
|
||||
|
||||
BasicStruct var1{5, 3.2}; // only fills the struct components
|
||||
AltStruct var2{2, 4.3}; // calls the constructor
|
||||
|
||||
class MoreInit
|
||||
{
|
||||
public:
|
||||
int yarray[5] {1,2,3,4,5};
|
||||
char *charptr {nullptr};
|
||||
std::vector<int> vi {1,2,3,4,5};
|
||||
|
||||
MoreInit() {}
|
||||
|
||||
int more1(std::vector<int> vv = {1,2,3,4}) {
|
||||
int sum = 0;
|
||||
for (int i : vv)
|
||||
sum += i;
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
const int arr1[] = {1,2,3};
|
||||
const int arr2[]{1,2,3};
|
||||
const int arr3[][3]{ {1,2,3}, {4,5,6} };
|
||||
const int arr4[][3] = { {1,2,3}, {4,5,6} };
|
||||
%}
|
||||
|
||||
23
Examples/test-suite/cpp11_unrestricted_unions.i
Normal file
23
Examples/test-suite/cpp11_unrestricted_unions.i
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* This testcase checks whether SWIG correctly parses the support for types
|
||||
without the defined trivial constructor in the unions. */
|
||||
%module cpp11_unrestricted_unions
|
||||
|
||||
%inline %{
|
||||
struct point {
|
||||
point() {}
|
||||
point(int x, int y) : x_(x), y_(y) {}
|
||||
int x_, y_;
|
||||
};
|
||||
|
||||
#include <new> // For placement 'new' in the constructor below
|
||||
union P {
|
||||
int z;
|
||||
double w;
|
||||
point p; // Illegal in C++03; legal in C++11.
|
||||
// Due to the point member, a constructor definition is required.
|
||||
P() {
|
||||
new(&p) point();
|
||||
}
|
||||
} p1;
|
||||
%}
|
||||
|
||||
53
Examples/test-suite/cpp11_userdefined_literals.i
Normal file
53
Examples/test-suite/cpp11_userdefined_literals.i
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* This testcase checks whether SWIG correctly parses the user-defined literals
|
||||
introduced in C++11. */
|
||||
%module cpp11_userdefined_literals
|
||||
|
||||
// Unfortunately full declaration is needed for %rename atm, the parameter list cannot be omitted.
|
||||
%rename(MyRawLiteral) operator"" _myRawLiteral(const char * value);
|
||||
%rename(MySuffixIntegral) operator "" _mySuffixIntegral(unsigned long long);
|
||||
%rename(MySuffixFloat) operator "" _mySuffixFloat(long double);
|
||||
%rename(MySuffix1) operator "" _mySuffix1(const char * string_values, size_t num_chars);
|
||||
%rename(MySuffix2) operator "" _mySuffix2(const wchar_t * string_values, size_t num_chars);
|
||||
%rename(MySuffix3) operator "" _mySuffix3(const char16_t * string_values, size_t num_chars);
|
||||
%rename(MySuffix4) operator "" _mySuffix4(const char32_t * string_values, size_t num_chars);
|
||||
|
||||
%ignore operator "" _myRawLiteralIgnored(const char * value);
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
|
||||
struct OutputType {
|
||||
int val;
|
||||
OutputType(int v) : val(v) {}
|
||||
};
|
||||
|
||||
// Raw literal
|
||||
OutputType operator "" _myRawLiteral(const char * value) { return OutputType(10); }
|
||||
|
||||
// Cooked numeric literals
|
||||
OutputType operator "" _mySuffixIntegral(unsigned long long) { return OutputType(20); }
|
||||
OutputType operator "" _mySuffixFloat(long double) { return OutputType(30); }
|
||||
|
||||
// Cooked string literals
|
||||
OutputType operator "" _mySuffix1(const char * string_values, size_t num_chars) { return OutputType(100); }
|
||||
OutputType operator "" _mySuffix2(const wchar_t * string_values, size_t num_chars) { return OutputType(200); }
|
||||
OutputType operator "" _mySuffix3(const char16_t * string_values, size_t num_chars) { return OutputType(300); }
|
||||
OutputType operator "" _mySuffix4(const char32_t * string_values, size_t num_chars) { return OutputType(400); }
|
||||
|
||||
OutputType operator"" _myRawLiteralIgnored(const char * value) { return OutputType(15); }
|
||||
%}
|
||||
|
||||
%{
|
||||
// TODO: SWIG cannot parse these
|
||||
OutputType some_variable_a = 1234_myRawLiteral;
|
||||
|
||||
OutputType some_variable_b = 1234_mySuffixIntegral;
|
||||
OutputType some_variable_c = 3.1416_mySuffixFloat;
|
||||
|
||||
OutputType some_variable_d = "1234"_mySuffix1;
|
||||
OutputType some_variable_e = u8"1234"_mySuffix1;
|
||||
OutputType some_variable_f = L"1234"_mySuffix2;
|
||||
OutputType some_variable_g = u"1234"_mySuffix3;
|
||||
OutputType some_variable_h = U"1234"_mySuffix4;
|
||||
%}
|
||||
|
||||
77
Examples/test-suite/cpp11_variadic_templates.i
Normal file
77
Examples/test-suite/cpp11_variadic_templates.i
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* This testcase checks whether SWIG correctly parses and generates the code
|
||||
for variadic templates. This covers the variadic number of arguments inside
|
||||
the template brackets, new functions sizeof... and multiple inheritance
|
||||
using variadic number of classes.
|
||||
*/
|
||||
%module cpp11_variadic_templates
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiArgs;
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) SizeOf;
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiInherit;
|
||||
|
||||
////////////////////////
|
||||
// Variadic templates //
|
||||
////////////////////////
|
||||
%inline %{
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
template<typename... Values>
|
||||
class MultiArgs {
|
||||
};
|
||||
|
||||
class MultiArgs<int, std::vector<int>, std::map<std::string, std::vector<int>>> multiArgs;
|
||||
|
||||
%}
|
||||
|
||||
// TODO
|
||||
%template (MultiArgs1) MultiArgs<int, std::vector<int>, std::map<std::string, std::vector<int>>>;
|
||||
|
||||
////////////////////////
|
||||
// Variadic sizeof... //
|
||||
////////////////////////
|
||||
%inline %{
|
||||
template<typename... Args> struct SizeOf {
|
||||
static const int size = sizeof...(Args);
|
||||
};
|
||||
%}
|
||||
|
||||
%template (SizeOf1) SizeOf<int, int>;
|
||||
|
||||
//////////////////////////
|
||||
// Variadic inheritance //
|
||||
//////////////////////////
|
||||
%inline %{
|
||||
class A {
|
||||
public:
|
||||
A() {
|
||||
a = 100;
|
||||
}
|
||||
virtual ~A() {}
|
||||
int a;
|
||||
};
|
||||
|
||||
class B {
|
||||
public:
|
||||
B() {
|
||||
b = 200;
|
||||
}
|
||||
virtual ~B() {}
|
||||
int b;
|
||||
};
|
||||
|
||||
template <typename... BaseClasses> class MultiInherit : public BaseClasses... {
|
||||
public:
|
||||
MultiInherit(BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {}
|
||||
int InstanceMethod() { return 123; }
|
||||
static int StaticMethod() { return 456; }
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
// TODO
|
||||
//%template (MultiInherit0) MultiInherit<>;
|
||||
%template (MultiInherit1) MultiInherit<A>;
|
||||
// TODO
|
||||
%template (MultiInherit2) MultiInherit<A,B>;
|
||||
|
||||
|
|
@ -30,6 +30,19 @@ class Foo {
|
|||
}
|
||||
|
||||
int (Foo::*func_ptr)(int);
|
||||
|
||||
const char* __str__() const { return "Foo"; }
|
||||
};
|
||||
|
||||
class FooSub : public Foo {
|
||||
public:
|
||||
FooSub() :Foo(42) {}
|
||||
};
|
||||
|
||||
class FooSubSub : public FooSub {
|
||||
public:
|
||||
FooSubSub() : FooSub() {}
|
||||
const char* __str__() const { return "FooSubSub"; }
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -4,19 +4,22 @@
|
|||
|
||||
LANGUAGE = csharp
|
||||
SCRIPTSUFFIX = _runme.cs
|
||||
INTERPRETER = @CSHARPCILINTERPRETER@
|
||||
INTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
||||
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
|
||||
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
csharp_attributes \
|
||||
csharp_swig2_compatibility \
|
||||
csharp_exceptions \
|
||||
csharp_features \
|
||||
csharp_lib_arrays \
|
||||
csharp_namespace_system_collision \
|
||||
csharp_prepost \
|
||||
csharp_typemaps \
|
||||
enum_thorough_simple \
|
||||
|
|
@ -28,6 +31,7 @@ CPP_TEST_CASES = \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SRCDIR = ../$(srcdir)/
|
||||
SWIGOPT += -namespace $*Namespace
|
||||
|
||||
CSHARPFLAGSSPECIAL =
|
||||
|
|
@ -35,9 +39,10 @@ CSHARPFLAGSSPECIAL =
|
|||
# Custom tests - tests with additional commandline options
|
||||
intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
|
||||
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
|
||||
csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+(cd $* && $(swig_and_compile_cpp))
|
||||
+$(run_testcase)
|
||||
|
|
@ -47,17 +52,17 @@ csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
|
|||
+(cd $* && $(swig_and_compile_c))
|
||||
+$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+(cd $* && $(swig_and_compile_multi_cpp))
|
||||
+$(run_testcase)
|
||||
|
||||
# Makes a directory for the testcase if it does not exist
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
|
||||
fi; \
|
||||
if [ ! -d $* ]; then \
|
||||
mkdir $*; \
|
||||
|
|
@ -68,11 +73,11 @@ setup = \
|
|||
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
|
||||
# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) ./$*_runme.exe; \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
|
|
|
|||
|
|
@ -323,7 +323,9 @@ public class TestThread {
|
|||
} catch (ArgumentOutOfRangeException e) {
|
||||
String expectedMessage = "caught:" + i + "\n" + "Parameter name: input";
|
||||
if (e.Message.Replace(runme.CRLF,"\n") != expectedMessage)
|
||||
throw new Exception("Exception message incorrect. Expected:\n[" + expectedMessage + "]\n" + "Received:\n[" + e.Message + "]");
|
||||
throw new Exception("Exception message incorrect. Expected:\n[" +
|
||||
expectedMessage + "]\n" + "Received:\n[" +
|
||||
e.Message + "]");
|
||||
if (e.ParamName != "input")
|
||||
throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]");
|
||||
if (e.InnerException != null)
|
||||
|
|
@ -333,7 +335,7 @@ public class TestThread {
|
|||
throw new Exception("throwsException.dub = " + throwsClass.dub + " expected: 1234.5678");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
|
||||
Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message + "\n TestThread Inner stack trace: " + e.StackTrace);
|
||||
Failed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,13 @@ public class runme
|
|||
// Debugging flag
|
||||
public static bool debug = false;
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.GC.Collect();
|
||||
System.GC.WaitForPendingFinalizers();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
if (debug)
|
||||
|
|
@ -27,22 +34,24 @@ public class runme
|
|||
if (debug)
|
||||
Console.WriteLine("Nearly finished");
|
||||
|
||||
int countdown = 100;
|
||||
while (true) {
|
||||
System.GC.Collect();
|
||||
System.GC.WaitForPendingFinalizers();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
|
||||
break;
|
||||
};
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new ApplicationException("Klass.total_count=" + Klass.getTotal_count());
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount) // Expect the one global variable (GlobalValue)
|
||||
break;
|
||||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||
if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING)
|
||||
if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
|
||||
if (wrapper_count != 1) // Expect the one global variable (GlobalSmartValue)
|
||||
throw new ApplicationException("shared_ptr wrapper count=" + wrapper_count);
|
||||
|
||||
if (debug)
|
||||
|
|
|
|||
57
Examples/test-suite/csharp/li_std_auto_ptr_runme.cs
Normal file
57
Examples/test-suite/csharp/li_std_auto_ptr_runme.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using li_std_auto_ptrNamespace;
|
||||
|
||||
public class li_std_auto_ptr_runme {
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.GC.Collect();
|
||||
System.GC.WaitForPendingFinalizers();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
Klass k1 = li_std_auto_ptr.makeKlassAutoPtr("first");
|
||||
if (k1.getLabel() != "first")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
Klass k2 = li_std_auto_ptr.makeKlassAutoPtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
|
||||
k1 = null;
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
};
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2 = null;
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 0;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -82,17 +82,6 @@ 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");
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
StructVector inputvector = new StructVector();
|
||||
int arrayLen = 10;
|
||||
|
|
@ -208,7 +197,6 @@ public class li_std_vector_runme {
|
|||
throw new Exception("Repeat (1) test failed");
|
||||
}
|
||||
}
|
||||
#if !SWIG_DOTNET_1
|
||||
{
|
||||
System.Collections.Generic.IEnumerator<double> myEnumerator = dv.GetEnumerator();
|
||||
while ( myEnumerator.MoveNext() ) {
|
||||
|
|
@ -216,7 +204,6 @@ public class li_std_vector_runme {
|
|||
throw new Exception("Repeat (2) test failed");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
56
Examples/test-suite/csharp/li_swigtype_inout_runme.cs
Normal file
56
Examples/test-suite/csharp/li_swigtype_inout_runme.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
using System;
|
||||
using li_swigtype_inoutNamespace;
|
||||
|
||||
public class li_swigtype_inout_runme {
|
||||
|
||||
public static void Main() {
|
||||
XXX xxx = new XXX(999);
|
||||
check_count(1);
|
||||
XXX x1 = null;
|
||||
XXX x2 = null;
|
||||
XXX x3 = null;
|
||||
XXX x4 = null;
|
||||
li_swigtype_inout.ptr_ref_out(out x1, out x2, out x3, out x4);
|
||||
check_value(111, x1.value);
|
||||
check_value(222, x2.value);
|
||||
check_value(333, x3.value);
|
||||
check_value(444, x4.value);
|
||||
check_count(5);
|
||||
x1.Dispose();
|
||||
x2.Dispose();
|
||||
x3.Dispose();
|
||||
x4.Dispose();
|
||||
xxx.Dispose();
|
||||
check_count(0);
|
||||
|
||||
x1 = null;
|
||||
x2 = null;
|
||||
x3 = null;
|
||||
x4 = null;
|
||||
new ConstructorTest(out x1, out x2, out x3, out x4);
|
||||
check_count(4);
|
||||
check_value(111, x1.value);
|
||||
check_value(222, x2.value);
|
||||
check_value(333, x3.value);
|
||||
check_value(444, x4.value);
|
||||
x1.Dispose();
|
||||
x2.Dispose();
|
||||
x3.Dispose();
|
||||
x4.Dispose();
|
||||
check_count(0);
|
||||
}
|
||||
|
||||
public static void check_count(int count) {
|
||||
int actual = XXX.count;
|
||||
if( count != actual ) {
|
||||
throw new Exception(String.Format("Count wrong. Expected: {0} Got: {1}", count, actual));
|
||||
}
|
||||
}
|
||||
|
||||
public static void check_value(int expected, int actual) {
|
||||
if( expected != actual ) {
|
||||
throw new Exception(String.Format("Wrong value. Expected: {0} Got: {1}", expected, actual));
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Examples/test-suite/csharp/nested_class_runme.cs
Normal file
66
Examples/test-suite/csharp/nested_class_runme.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using nested_classNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
|
||||
Outer outer = new Outer();
|
||||
outer.a = 1;
|
||||
outer.b = 2;
|
||||
Outer.InnerStruct1 is1 = outer.makeInnerStruct1();
|
||||
Outer.InnerClass1 ic1 = outer.makeInnerClass1();
|
||||
Outer.InnerUnion1 iu1 = outer.makeInnerUnion1();
|
||||
|
||||
Outer.InnerStruct2 is2 = outer.makeInnerStruct2();
|
||||
Outer.InnerClass2 ic2 = outer.makeInnerClass2();
|
||||
Outer.InnerUnion2 iu2 = outer.makeInnerUnion2();
|
||||
|
||||
Outer.InnerClass4Typedef ic4 = outer.makeInnerClass4Typedef();
|
||||
Outer.InnerStruct4Typedef is4 = outer.makeInnerStruct4Typedef();
|
||||
Outer.InnerUnion4Typedef iu4 = outer.makeInnerUnion4Typedef();
|
||||
|
||||
Outer.InnerClass5Typedef ic5 = outer.makeInnerClass5();
|
||||
Outer.InnerStruct5Typedef is5 = outer.makeInnerStruct5();
|
||||
Outer.InnerUnion5Typedef iu5 = outer.makeInnerUnion5();
|
||||
|
||||
ic5 = outer.makeInnerClass5Typedef();
|
||||
is5 = outer.makeInnerStruct5Typedef();
|
||||
iu5 = outer.makeInnerUnion5Typedef();
|
||||
|
||||
{
|
||||
Outer.InnerMultiple im1 = outer.MultipleInstance1;
|
||||
Outer.InnerMultiple im2 = outer.MultipleInstance2;
|
||||
Outer.InnerMultiple im3 = outer.MultipleInstance3;
|
||||
Outer.InnerMultiple im4 = outer.MultipleInstance4;
|
||||
}
|
||||
|
||||
{
|
||||
Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1;
|
||||
Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2;
|
||||
Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3;
|
||||
Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4;
|
||||
}
|
||||
|
||||
{
|
||||
Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1;
|
||||
Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2;
|
||||
Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3;
|
||||
Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4;
|
||||
}
|
||||
|
||||
{
|
||||
Outer.InnerMultipleAnonTypedef1 mat1 = outer.makeInnerMultipleAnonTypedef1();
|
||||
Outer.InnerMultipleAnonTypedef1 mat2 = outer.makeInnerMultipleAnonTypedef2();
|
||||
SWIGTYPE_p_p_Outer__InnerMultipleAnonTypedef1 mat3 = outer.makeInnerMultipleAnonTypedef3();
|
||||
|
||||
Outer.InnerMultipleNamedTypedef1 mnt = outer.makeInnerMultipleNamedTypedef();
|
||||
Outer.InnerMultipleNamedTypedef1 mnt1 = outer.makeInnerMultipleNamedTypedef1();
|
||||
Outer.InnerMultipleNamedTypedef1 mnt2 = outer.makeInnerMultipleNamedTypedef2();
|
||||
SWIGTYPE_p_p_Outer__InnerMultipleNamedTypedef mnt3 = outer.makeInnerMultipleNamedTypedef3();
|
||||
}
|
||||
{
|
||||
Outer.InnerSameName isn = outer.makeInnerSameName();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Examples/test-suite/csharp/nested_directors_runme.cs
Normal file
20
Examples/test-suite/csharp/nested_directors_runme.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using nested_directorsNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class CNested : Base.Nest {
|
||||
public override bool GetValue() {return true;}
|
||||
}
|
||||
public class CSub : Sub {
|
||||
protected override bool GetValue() { return base.GetValue(); }
|
||||
public bool Test(){ return GetValue(); }
|
||||
}
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
CNested n = new CNested();
|
||||
CSub s = new CSub();
|
||||
if (!s.Test())
|
||||
throw new Exception("Sub.GetValue");
|
||||
}
|
||||
}
|
||||
28
Examples/test-suite/csharp/nested_structs_runme.cs
Normal file
28
Examples/test-suite/csharp/nested_structs_runme.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using nested_structsNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
Outer outer = new Outer();
|
||||
nested_structs.setValues(outer, 10);
|
||||
|
||||
Outer_inner1 inner1 = outer.inner1;
|
||||
Outer_inner1 inner2 = outer.inner2;
|
||||
Outer_inner1 inner3 = outer.inner3;
|
||||
Outer_inner1 inner4 = outer.inner4;
|
||||
if (inner1.val != 10) throw new Exception("failed inner1");
|
||||
if (inner2.val != 20) throw new Exception("failed inner2");
|
||||
if (inner3.val != 20) throw new Exception("failed inner3");
|
||||
if (inner4.val != 40) throw new Exception("failed inner4");
|
||||
|
||||
Named inside1 = outer.inside1;
|
||||
Named inside2 = outer.inside2;
|
||||
Named inside3 = outer.inside3;
|
||||
Named inside4 = outer.inside4;
|
||||
if (inside1.val != 100) throw new Exception("failed inside1");
|
||||
if (inside2.val != 200) throw new Exception("failed inside2");
|
||||
if (inside3.val != 200) throw new Exception("failed inside3");
|
||||
if (inside4.val != 400) throw new Exception("failed inside4");
|
||||
}
|
||||
}
|
||||
23
Examples/test-suite/csharp/nested_workaround_runme.cs
Normal file
23
Examples/test-suite/csharp/nested_workaround_runme.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using nested_workaroundNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
{
|
||||
Inner inner = new Inner(5);
|
||||
Outer outer = new Outer();
|
||||
Inner newInner = outer.doubleInnerValue(inner);
|
||||
if (newInner.getValue() != 10)
|
||||
throw new Exception("inner failed");
|
||||
}
|
||||
|
||||
{
|
||||
Outer outer = new Outer();
|
||||
Inner inner = outer.createInner(3);
|
||||
Inner newInner = outer.doubleInnerValue(inner);
|
||||
if (outer.getInnerValue(newInner) != 6)
|
||||
throw new Exception("inner failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,12 @@ using rename_pcre_encoderNamespace;
|
|||
public class runme {
|
||||
static void Main() {
|
||||
SomeWidget w = new SomeWidget();
|
||||
w.putBorderWidth(17);
|
||||
if ( w.getBorderWidth() != 17 )
|
||||
w.put_borderWidth(17);
|
||||
if ( w.get_borderWidth() != 17 )
|
||||
throw new Exception(String.Format("Border with should be 17, not {0}",
|
||||
w.getBorderWidth()));
|
||||
w.get_borderWidth()));
|
||||
|
||||
if ( rename_pcre_encoder.StartINSAneAndUNSAvoryTraNSAtlanticRaNSAck() != 42 )
|
||||
throw new Exception("Unexpected result of renamed function call");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
25
Examples/test-suite/csharp/template_nested_runme.cs
Normal file
25
Examples/test-suite/csharp/template_nested_runme.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using template_nestedNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
new T_NormalTemplateNormalClass().tmethod(new NormalClass());
|
||||
new OuterClass().T_OuterTMethodNormalClass(new NormalClass());
|
||||
|
||||
TemplateFuncs tf = new TemplateFuncs();
|
||||
if (tf.T_TemplateFuncs1Int(-10) != -10)
|
||||
throw new Exception("it failed");
|
||||
if (tf.T_TemplateFuncs2Double(-12.3) != -12.3)
|
||||
throw new Exception("it failed");
|
||||
|
||||
T_NestedOuterTemplateDouble tn = new T_NestedOuterTemplateDouble();
|
||||
if (tn.hohum(-12.3) != -12.3)
|
||||
throw new Exception("it failed");
|
||||
OuterClass.T_OuterClassInner1Int inner1 = new OuterClass().useInner1(new OuterClass.T_OuterClassInner1Int());
|
||||
OuterClass.T_OuterClassInner2NormalClass inner2 = new OuterClass.T_OuterClassInner2NormalClass();
|
||||
inner2.embeddedVar = 2;
|
||||
OuterClass.T_OuterClassInner2NormalClass inner22 = new OuterClass().useInner2Again(inner2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
%module csharp_features
|
||||
%include "wchar.i"
|
||||
|
||||
// SWIG gets the method modifiers wrong occasionally, like with private inheritance, %csmethodmodifiers can fix this
|
||||
%csmethodmodifiers Derived::VirtualMethod() "public virtual"
|
||||
|
|
@ -19,6 +20,9 @@ public:
|
|||
class MoreDerived : public Derived {
|
||||
public:
|
||||
int variable;
|
||||
// test wide char literals support for C# module
|
||||
void methodWithDefault1(const wchar_t* s = L"literal with escapes \x1234"){}
|
||||
void methodWithDefault2(wchar_t c = L'\x1234'){}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
39
Examples/test-suite/csharp_namespace_system_collision.i
Normal file
39
Examples/test-suite/csharp_namespace_system_collision.i
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
%module namespace_system_collision
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
namespace TopLevel
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "TopLevel::System::Foo::ping()"; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
%nspace;
|
||||
#else
|
||||
//#warning nspace feature not yet supported in this target language
|
||||
#endif
|
||||
|
||||
namespace TopLevel
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ struct PrePost3 {
|
|||
// Check attributes in the typemaps
|
||||
%typemap(cstype, inattributes="[CustomInt]") int val "int"
|
||||
%typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int val "tmp_$csinput"
|
||||
%typemap(imtype, out="IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "HandleRef/*overridden*/"
|
||||
%typemap(imtype, out="global::System.IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "global::System.Runtime.InteropServices.HandleRef/*overridden*/"
|
||||
|
||||
%inline %{
|
||||
class CsinAttributes {
|
||||
|
|
@ -216,8 +216,8 @@ void subtractYears(CDate *pDate, int years) {
|
|||
%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
|
||||
/* csvarout typemap code */
|
||||
get {
|
||||
IntPtr cPtr = $imcall;
|
||||
CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
CDate tempDate = (cPtr == global::System.IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
|
||||
return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
|
||||
0, 0, 0);
|
||||
} %}
|
||||
|
|
|
|||
48
Examples/test-suite/csharp_swig2_compatibility.i
Normal file
48
Examples/test-suite/csharp_swig2_compatibility.i
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
%module csharp_swig2_compatibility
|
||||
|
||||
%typemap(cscode) Foo %{
|
||||
|
||||
// Without the using directives generated by the
|
||||
// SWIG 2 compatibility mode, this code would fail
|
||||
// to build.
|
||||
public void FooBar(string input)
|
||||
{
|
||||
Console.WriteLine(input);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%pragma(csharp) imclasscode=%{
|
||||
|
||||
// Without the using directives generated by the
|
||||
// SWIG 2 compatibility mode, this code would fail
|
||||
// to build.
|
||||
public void IntermediateClassMethod(string input)
|
||||
{
|
||||
Console.WriteLine(input);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%pragma(csharp) modulecode=%{
|
||||
|
||||
// Without the using directives generated by the
|
||||
// SWIG 2 compatibility mode, this code would fail
|
||||
// to build.
|
||||
public void ModuleClassMethod(string input)
|
||||
{
|
||||
Console.WriteLine(input);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
Foo() {}
|
||||
|
||||
void Bar() {}
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ Number times12(const Number* num) {
|
|||
%typemap(csvarin, excode=SWIGEXCODE2) int %{
|
||||
set {
|
||||
if ($csinput < 0)
|
||||
throw new ApplicationException("number too small!");
|
||||
throw new global::System.ApplicationException("number too small!");
|
||||
$imcall;$excode
|
||||
} %}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
#######################################################################
|
||||
|
||||
LANGUAGE = d
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
ifeq (2,$(D_VERSION))
|
||||
VERSIONSUFFIX = .2
|
||||
|
|
@ -13,7 +14,7 @@ else
|
|||
VERSIONSUFFIX = .1
|
||||
endif
|
||||
|
||||
TESTSUFFIX = _runme$(VERSIONSUFFIX).d
|
||||
SCRIPTSUFFIX = _runme$(VERSIONSUFFIX).d
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
d_nativepointers \
|
||||
|
|
@ -45,10 +46,10 @@ SWIGOPT+=-splitproxy -package $*
|
|||
|
||||
# Makes a directory for the testcase if it does not exist
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
|
||||
fi; \
|
||||
if [ ! -d $*$(VERSIONSUFFIX) ]; then \
|
||||
mkdir $*$(VERSIONSUFFIX); \
|
||||
|
|
@ -60,11 +61,11 @@ setup = \
|
|||
# Compiles D files then runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.d appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
cd $*$(VERSIONSUFFIX) && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
DFLAGS='-of$*_runme' \
|
||||
DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) `find $* -name *.d`' d_compile && \
|
||||
DSRCS='../$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) `find $* -name *.d`' d_compile && \
|
||||
env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \
|
||||
else \
|
||||
cd $*$(VERSIONSUFFIX) && \
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void main() {
|
|||
assert(-a == a);
|
||||
assert(-b == new Op(-5));
|
||||
|
||||
// Unfortunaly, there is no way to override conversion to boolean for
|
||||
// Unfortunately, there is no way to override conversion to boolean for
|
||||
// classes in D, opCast!("bool") is only used for structs.
|
||||
|
||||
// test []
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ This was reported in bug #909389 */
|
|||
|
||||
%inline %{
|
||||
|
||||
class A { int x; };
|
||||
class A {
|
||||
public:
|
||||
int x;
|
||||
};
|
||||
class B {
|
||||
class C { int y; }; //generates a warning
|
||||
class D : public A { int z; }; //ok
|
||||
|
|
|
|||
|
|
@ -41,6 +41,29 @@ class DirectorMethodException: public Swig::DirectorException {};
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
|
||||
// Default for director exception warns about unmapped exceptions now in java
|
||||
// Suppress warnings for this older test
|
||||
// %warnfilter(476) Bar;
|
||||
|
||||
// Default for java is to throw Swig::DirectorException if no
|
||||
// direct:except feature. Since methods below have exception specification
|
||||
// cannot throw director exception.
|
||||
|
||||
// Change back to old 2.0 default behavior
|
||||
|
||||
%feature("director:except") {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
// Dont clear exception, still be active when return to java execution
|
||||
// Essentially ignore exception occurred -- old behavior.
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGRUBY
|
||||
|
||||
%feature("director:except") {
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ namespace TopLevel
|
|||
%include <std_string.i>
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
|
||||
%nspace TopLevel::Bar::Foo;
|
||||
%nspace TopLevel::Bar::FooBar;
|
||||
#else
|
||||
#warning nspace feature not yet supported in this target language
|
||||
//#warning nspace feature not yet supported in this target language
|
||||
#endif
|
||||
|
||||
%feature("director") TopLevel::Bar::Foo;
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ namespace TopLevel
|
|||
%include <std_string.i>
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
|
||||
%nspace TopLevel::A::Foo;
|
||||
%nspace TopLevel::B::Foo;
|
||||
#else
|
||||
#warning nspace feature not yet supported in this target language
|
||||
//#warning nspace feature not yet supported in this target language
|
||||
%ignore TopLevel::B::Foo;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%module enum_forward
|
||||
|
||||
/* This contains C code that is not valid C++03 and Octave wrappers are always compiled as C++ */
|
||||
#if !defined(SWIGOCTAVE)
|
||||
/* This contains C code that is not valid C++03 and Octave, and Javascript(v8) wrappers are always compiled as C++ */
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
|
||||
%{
|
||||
enum ForwardEnum1 { AAA, BBB };
|
||||
enum ForwardEnum2 { CCC, DDD };
|
||||
|
|
|
|||
20
Examples/test-suite/enum_ignore.i
Normal file
20
Examples/test-suite/enum_ignore.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module enum_ignore
|
||||
|
||||
// Similar to enum_missing C test, but with namespaces and using %ignore
|
||||
|
||||
%ignore N::C;
|
||||
|
||||
%inline %{
|
||||
namespace N {
|
||||
enum C { Red, Green, Blue };
|
||||
|
||||
struct Draw {
|
||||
void DrawBW() {}
|
||||
void DrawC(C c) {}
|
||||
void DrawC_Ptr(C* c) {}
|
||||
void DrawC_ConstRef(C const& c) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
39
Examples/test-suite/enum_missing.i
Normal file
39
Examples/test-suite/enum_missing.i
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
%module enum_missing
|
||||
|
||||
// Test when SWIG does not parse the enum definition
|
||||
%{
|
||||
enum AVPixelFormat {
|
||||
AV_PIX_FMT_NONE = -1,
|
||||
AV_PIX_FMT_YUV420P
|
||||
};
|
||||
enum AVPixelFormat2 {
|
||||
AV_PIX_FMT_NONE2 = -1,
|
||||
AV_PIX_FMT_YUV420P2
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef struct AVCodecContext {
|
||||
enum AVPixelFormat pix_fmt;
|
||||
enum AVPixelFormat2 pix_fmt2;
|
||||
} AVCodecContext;
|
||||
|
||||
enum AVPixelFormat global_fmt;
|
||||
enum AVPixelFormat2 global_fmt2;
|
||||
|
||||
enum AVPixelFormat use_pixel_format(enum AVPixelFormat px) {
|
||||
return px;
|
||||
}
|
||||
enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) {
|
||||
return px;
|
||||
}
|
||||
|
||||
const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
|
||||
return px;
|
||||
}
|
||||
const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) {
|
||||
return px;
|
||||
}
|
||||
%}
|
||||
|
||||
69
Examples/test-suite/equality.i
Normal file
69
Examples/test-suite/equality.i
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/* File : equality.i */
|
||||
/*
|
||||
Specific test for operator== overload. Partially overlaps with
|
||||
operator_overload.i
|
||||
*/
|
||||
|
||||
%module equality
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_IDENTIFIER) operator==;
|
||||
|
||||
%inline %{
|
||||
|
||||
/* Point has no equality operator */
|
||||
typedef struct Point
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
} Point;
|
||||
|
||||
static const Point s_zeroPoint = { 0.0, 0.0 };
|
||||
/* stack version */
|
||||
Point MakePoint(double x, double y)
|
||||
{ Point new_point = {x, y}; return new_point; }
|
||||
|
||||
const Point* GetZeroPointPtr() { return &s_zeroPoint; }
|
||||
Point GetZeroPointCopy() { return s_zeroPoint; }
|
||||
|
||||
/* EqualOpDefined has correct equality operator */
|
||||
class EqualOpDefined {
|
||||
public:
|
||||
EqualOpDefined():
|
||||
x(5) {}
|
||||
EqualOpDefined(int val):
|
||||
x(val) {}
|
||||
|
||||
int x;
|
||||
};
|
||||
|
||||
/* EqualOpWrong has logically incorrect equality operator */
|
||||
class EqualOpWrong {
|
||||
public:
|
||||
inline static const EqualOpWrong* GetStaticObject();
|
||||
};
|
||||
|
||||
static EqualOpWrong s_wrongEqOp;
|
||||
|
||||
const EqualOpWrong* EqualOpWrong::GetStaticObject()
|
||||
{ return &s_wrongEqOp; }
|
||||
|
||||
|
||||
inline bool operator==( const EqualOpDefined& first, const EqualOpDefined& second )
|
||||
{ return first.x == second.x; }
|
||||
|
||||
inline bool operator==( const EqualOpWrong& first, const EqualOpWrong& second )
|
||||
{ return false; }
|
||||
|
||||
%}
|
||||
|
||||
/*
|
||||
in order to wrapper this correctly
|
||||
we need to extend the class
|
||||
to make the friends & non members part of the class
|
||||
*/
|
||||
%extend EqualOpDefined {
|
||||
bool operator==(const EqualOpDefined& b){return (*$self) == b;}
|
||||
}
|
||||
%extend EqualOpWrong {
|
||||
bool operator==(const EqualOpWrong& b){return (*$self) == b;}
|
||||
}
|
||||
56
Examples/test-suite/errors/Makefile.in
Normal file
56
Examples/test-suite/errors/Makefile.in
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#######################################################################
|
||||
# Makefile for errors test-suite
|
||||
#
|
||||
# This test-suite is for checking SWIG errors and warnings and uses
|
||||
# Python as the target language.
|
||||
#
|
||||
# It compares the stderr output from SWIG to the contents of the .stderr
|
||||
# file for each test case. The test cases are different to those used by
|
||||
# the language module test-suites. The .i files in this directory are
|
||||
# used instead of those in the parent directory.
|
||||
#
|
||||
# When adding a new test case, be sure to commit the expected output
|
||||
# file (.stderr) in addition to the test case itself.
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = errors
|
||||
ERROR_EXT = newerr
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
# All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input
|
||||
ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i)))
|
||||
CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES))
|
||||
C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES))
|
||||
|
||||
ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \
|
||||
$(C_ERROR_TEST_CASES:=.ctest)
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Portable dos2unix / todos for stripping CR
|
||||
TODOS = tr -d '\r'
|
||||
#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
|
||||
|
||||
# strip source directory from output, so that diffs compare
|
||||
STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
echo "$(ACTION)ing errors testcase $*"
|
||||
-$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
|
||||
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
|
||||
|
||||
%.ctest:
|
||||
echo "$(ACTION)ing errors testcase $*"
|
||||
-$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
|
||||
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
|
||||
|
||||
%.clean:
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean
|
||||
@rm -f *.$(ERROR_EXT) *.py
|
||||
2
Examples/test-suite/errors/c_bad_name.stderr
Normal file
2
Examples/test-suite/errors/c_bad_name.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead.
|
||||
c_bad_name.i:3: Error: Missing argument to %name directive.
|
||||
1
Examples/test-suite/errors/c_bad_native.stderr
Normal file
1
Examples/test-suite/errors/c_bad_native.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_bad_native.i:3: Error: %native declaration 'foo' is not a function.
|
||||
2
Examples/test-suite/errors/c_class.stderr
Normal file
2
Examples/test-suite/errors/c_class.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c_class.i:3: Warning 301: class keyword used, but not in C++ mode.
|
||||
c_class.i:3: Warning 314: 'class' is a python keyword, renaming to '_class'
|
||||
0
Examples/test-suite/errors/c_default_error.stderr
Normal file
0
Examples/test-suite/errors/c_default_error.stderr
Normal file
2
Examples/test-suite/errors/c_deprecated.stderr
Normal file
2
Examples/test-suite/errors/c_deprecated.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c_deprecated.i:3: Warning 102: %val directive deprecated (ignored).
|
||||
c_deprecated.i:3: Warning 103: %out directive deprecated (ignored).
|
||||
1
Examples/test-suite/errors/c_empty_char.stderr
Normal file
1
Examples/test-suite/errors/c_empty_char.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_empty_char.i:3: Error: Empty character constant
|
||||
1
Examples/test-suite/errors/c_enum_badvalue.stderr
Normal file
1
Examples/test-suite/errors/c_enum_badvalue.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_enum_badvalue.i:6: Error: Type error. Expecting an integral type
|
||||
1
Examples/test-suite/errors/c_extra_rblock.stderr
Normal file
1
Examples/test-suite/errors/c_extra_rblock.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_extra_rblock.i:5: Error: Syntax error in input(1).
|
||||
1
Examples/test-suite/errors/c_extra_rbrace.stderr
Normal file
1
Examples/test-suite/errors/c_extra_rbrace.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}'
|
||||
3
Examples/test-suite/errors/c_extra_unsigned.stderr
Normal file
3
Examples/test-suite/errors/c_extra_unsigned.stderr
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
c_extra_unsigned.i:3: Error: Extra unsigned specifier.
|
||||
c_extra_unsigned.i:4: Error: Extra signed specifier.
|
||||
c_extra_unsigned.i:5: Error: Extra signed specifier.
|
||||
1
Examples/test-suite/errors/c_insert_missing.stderr
Normal file
1
Examples/test-suite/errors/c_insert_missing.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_insert_missing.i:3: Error: Couldn't find 'missing_file.i'.
|
||||
4
Examples/test-suite/errors/c_long_short.stderr
Normal file
4
Examples/test-suite/errors/c_long_short.stderr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
c_long_short.i:3: Error: Extra long specifier.
|
||||
c_long_short.i:4: Error: Extra short specifier.
|
||||
c_long_short.i:5: Error: Extra long specifier.
|
||||
c_long_short.i:6: Error: Extra short specifier.
|
||||
2
Examples/test-suite/errors/c_missing_rbrace.stderr
Normal file
2
Examples/test-suite/errors/c_missing_rbrace.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c_missing_rbrace.i:3: Error: Missing '}'. Reached end of input.
|
||||
c_missing_rbrace.i:3: Error: Syntax error in input(1).
|
||||
1
Examples/test-suite/errors/c_missing_semi.stderr
Normal file
1
Examples/test-suite/errors/c_missing_semi.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_missing_semi.i:3: Error: Syntax error in input(1).
|
||||
6
Examples/test-suite/errors/c_redefine.stderr
Normal file
6
Examples/test-suite/errors/c_redefine.stderr
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
c_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored),
|
||||
c_redefine.i:3: Warning 302: previous definition of 'foo'.
|
||||
c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored),
|
||||
c_redefine.i:6: Warning 302: previous definition of 'bar'.
|
||||
c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'),
|
||||
c_redefine.i:6: Warning 322: previous declaration of 'bar'.
|
||||
0
Examples/test-suite/errors/c_varargs.stderr
Normal file
0
Examples/test-suite/errors/c_varargs.stderr
Normal file
1
Examples/test-suite/errors/c_varargs_neg.stderr
Normal file
1
Examples/test-suite/errors/c_varargs_neg.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
|
||||
2
Examples/test-suite/errors/cpp_bad_extern.stderr
Normal file
2
Examples/test-suite/errors/cpp_bad_extern.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
|
||||
cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
|
||||
19
Examples/test-suite/errors/cpp_extend_destructors.stderr
Normal file
19
Examples/test-suite/errors/cpp_extend_destructors.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
cpp_extend_destructors.i:8: Warning 302: Identifier '~AStruct' redefined by %extend (ignored),
|
||||
cpp_extend_destructors.i:5: Warning 302: %extend definition of '~AStruct'.
|
||||
cpp_extend_destructors.i:14: Warning 302: Identifier '~BStruct' redefined (ignored),
|
||||
cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct'.
|
||||
cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignored),
|
||||
cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct'.
|
||||
cpp_extend_destructors.i:100: Warning 302: Identifier '~LStruct' redefined (ignored),
|
||||
cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct'.
|
||||
cpp_extend_destructors.i:24: Warning 521: Illegal destructor name CStruct::~NOT_CStruct(). Ignored.
|
||||
cpp_extend_destructors.i:30: Warning 521: Illegal destructor name DStruct::~NOT_DStruct(). Ignored.
|
||||
cpp_extend_destructors.i:44: Warning 521: Illegal destructor name EStruct::~NOT_EStruct(). Ignored.
|
||||
cpp_extend_destructors.i:50: Warning 521: Illegal destructor name FStruct::~NOT_FStruct(). Ignored.
|
||||
cpp_extend_destructors.i:65: Warning 521: Illegal destructor name GStruct::~NOT_GStruct(). Ignored.
|
||||
cpp_extend_destructors.i:72: Warning 521: Illegal destructor name HStruct::~NOT_HStruct(). Ignored.
|
||||
cpp_extend_destructors.i:81: Warning 521: Illegal destructor name IStruct::~NOT_IStruct(). Ignored.
|
||||
cpp_extend_destructors.i:86: Warning 521: Illegal destructor name JStruct::~NOT_JStruct(). Ignored.
|
||||
cpp_extend_destructors.i:92: Warning 521: Illegal destructor name KStruct::~NOT_KStruct(). Ignored.
|
||||
cpp_extend_destructors.i:99: Warning 521: Illegal destructor name LStruct< int >::~NOT_LStruct(). Ignored.
|
||||
cpp_extend_destructors.i:99: Warning 521: Illegal destructor name LStruct< short >::~NOT_LStruct(). Ignored.
|
||||
4
Examples/test-suite/errors/cpp_extend_redefine.stderr
Normal file
4
Examples/test-suite/errors/cpp_extend_redefine.stderr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
|
||||
cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
|
||||
cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam',
|
||||
cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'.
|
||||
1
Examples/test-suite/errors/cpp_extend_undefined.stderr
Normal file
1
Examples/test-suite/errors/cpp_extend_undefined.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo.
|
||||
6
Examples/test-suite/errors/cpp_extra_brackets.i
Normal file
6
Examples/test-suite/errors/cpp_extra_brackets.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%module cpp_extra_brackets
|
||||
|
||||
// Extra brackets was segfaulting in SWIG-3.0.0
|
||||
struct ABC {
|
||||
int operator<<(ABC &))) { return 0; }
|
||||
};
|
||||
1
Examples/test-suite/errors/cpp_extra_brackets.stderr
Normal file
1
Examples/test-suite/errors/cpp_extra_brackets.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_extra_brackets.i:5: Error: Syntax error in input(3).
|
||||
9
Examples/test-suite/errors/cpp_extra_brackets2.i
Normal file
9
Examples/test-suite/errors/cpp_extra_brackets2.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%module cpp_extra_brackets
|
||||
|
||||
// Extra brackets was segfaulting in SWIG-3.0.0
|
||||
struct ABC {
|
||||
;
|
||||
)))
|
||||
int operator<<(ABC &) { return 0; }
|
||||
int operator>>(ABC &) { return 0; }
|
||||
};
|
||||
1
Examples/test-suite/errors/cpp_extra_brackets2.stderr
Normal file
1
Examples/test-suite/errors/cpp_extra_brackets2.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_extra_brackets2.i:6: Error: Syntax error in input(3).
|
||||
20
Examples/test-suite/errors/cpp_inherit.stderr
Normal file
20
Examples/test-suite/errors/cpp_inherit.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
cpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored).
|
||||
cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored).
|
||||
cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored).
|
||||
cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored).
|
||||
cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored).
|
||||
cpp_inherit.i:15: Warning 401: Base class 'A1' undefined.
|
||||
cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class.
|
||||
cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored.
|
||||
cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete.
|
||||
cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found.
|
||||
cpp_inherit.i:24: Error: 'A6' is not a valid base class.
|
||||
cpp_inherit.i:5: Error: See definition of 'A6'.
|
||||
cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
|
||||
cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
|
||||
cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
|
||||
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
|
||||
cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
|
||||
cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name.
|
||||
cpp_inherit.i:53: Warning 401: Base class 'Base< double >' undefined.
|
||||
cpp_inherit.i:54: Warning 401: 'Base< double >' must be defined before it is used as a base class.
|
||||
1
Examples/test-suite/errors/cpp_inline_namespace.stderr
Normal file
1
Examples/test-suite/errors/cpp_inline_namespace.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed.
|
||||
21
Examples/test-suite/errors/cpp_macro_locator.stderr
Normal file
21
Examples/test-suite/errors/cpp_macro_locator.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
|
||||
cpp_macro_locator.i:96: Warning 204: CPP #warning, "an inline warning message 2".
|
||||
cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
|
||||
cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).
|
||||
cpp_macro_locator.i:61: Warning 509: Overloaded method overload2(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:60: Warning 509: as it is shadowed by overload2(int *).
|
||||
cpp_macro_locator.i:64: Warning 509: Overloaded method Klass1::methodX(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:64: Warning 509: as it is shadowed by Klass1::methodX(int *).
|
||||
cpp_macro_locator.i:68: Warning 509: Overloaded method overload3(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:67: Warning 509: as it is shadowed by overload3(int *).
|
||||
cpp_macro_locator.i:90: Warning 509: Overloaded method overload4(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:89: Warning 509: as it is shadowed by overload4(int *).
|
||||
cpp_macro_locator.i:94: Warning 509: Overloaded method overloadinline1(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:93: Warning 509: as it is shadowed by overloadinline1(int *).
|
||||
cpp_macro_locator.i:95: Warning 509: Overloaded method Klass2::methodX(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:95: Warning 509: as it is shadowed by Klass2::methodX(int *).
|
||||
cpp_macro_locator.i:98: Warning 509: Overloaded method overloadinline2(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *).
|
||||
cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *).
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
cpp_missing_rparenthesis.i:5: Error: Missing ')'. Reached end of input.
|
||||
cpp_missing_rparenthesis.i:5: Error: Syntax error in input(3).
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue