Merge branch 'gsoc2009-matevz' into master - C++11 support

* gsoc2009-matevz:
  Minor cleanup prior to merging to master
  Add gsoc2009-matevz for Travis testing
  C++11 testing moved to a configure option
  Rename all C++0x to C++11 and cpp0x to cpp11
  Grab .travis.yml file from master to turn on Travis testing
  Suppress leaking memory warnings in rvalue reference tests
  Add support for extern "C++" - no warning should be issued as was previously occurring
  Add support for extern "C" thread_local
  Fixes detecting if a variable is extern when using 'extern thread_local'
  Add support for thread_local when specified with other legitimate storage class specifiers - extern and static
  Remove test tokens
  User defined literals: fix for %rename and update docs
  Add ability to suppress variadic template first argumnet warning
  Add template aliasing and type aliasing into symbol table and enable explicit warning suppression for these. They still need to be added into the parse tree and dealt with.
  Add lambda functions to the symbol tables and add ability to suppress lambda warnings.
  Rework std::initializer_list handling to warn about usage in any method, not just constructors. A typemap is used to issue the warning and can be overridden with user defined behaviour.
  Initialization list doc updates and new tests. Fix functions with default arguments that are initializer lists
  Better clarification about polymorphic wrappers for function objects - std::function
  Remove generated output that should not be checked in2
  Fix shift/shift and shift/reduce errors around variadic templates since merge
  Variadic templates doc update
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Add rvalue reference typemaps
  Use CXXFLAGS for c++ code for Go examples
  Add missing static member to testcase
  More rvalue reference typemaps
  Fix generated code for rvalue references by converting functions returning an rvalue reference into something that can be taken the address of - via a const ref cast. Now the rvalue_reference tests compile under g++-4.7 (C# only atm)
  Remove recently added %expect in parser in case of backward compatibility problems
  Cosmetic changes to previous (unicode literals) commit
  Fixes to previous (unicode literals) commit
  Unicode literals
  Add check-cpp11 target for testing c++11 only tests
  Improve detection of C++11 compiler and set appropriate flags to use C++11/C++0x features
  Modify autoconf macro to be more flexible about how it is used - sets CXX11FLAGS, HAVE_CXX11_COMPILER and option to not error out
  Autoconf archive macro to detect c++11 - as downloaded from archive
  Update variadic templates
  result_of not working
  Add lambda tests to test-suite - gcc-4.7 supports these
  One more lambda test using constexpr
  More lambda support - for optional lambda declarators
  Add in support for initialising auto variables from lambda expressions
  Lambda expressions: parse exception specification in lambda functions. Fix lambda testcase for gcc-4.7.
  Delegating constructors and inheriting constructors clarification and split of tests
  gcc-4.7 now supports alias templates
  Update on C++11 user-defined literal status
  Fix unrestricted unions testcase and add runtime example
  Minor doc tweaks for unrestricted unions
  Some updates to c++11 warning messages and update docs on alias templates
  Provide unique c++11 warnings which were previously hijacking another warning
  Tidy up test and docs on template double brackets
  Better clarify C++11 smart pointer support
  Update c++0x tests run by default for g++-4.6
  Improve nullptr constant wrapping
  Add scoped enums into correct correct scope in type system. Note that cpp0x_strongly_typed_enumerations.i still shows further language symbol table problems which need fixing.
  Using C++11 enum classes with just a forward reference.
  Add support for c++11 strongly typed enums inheriting from non standard primitive types
  Fix parsing of forward declaration of C++0x enums
  html fixes
  sort out c++0x lambda tests and reorder cpp0x tests
  Improved C++0x rvalue reference implementation differentiating lvalue and rvalue references. The previous implementation treated rvalue references as lvalue references which leads to a number of different wrapping issues.
  simple formatting changes
  Warning suppression for explicit template instantiations
  Raw string literal changes in paper N3077 changes delimiters to use round brackets instead of square brackets
  add in more raw string literals for gcc-4.5
  typo fix
  minor warning message changes
  Add new GPL license headers to all source files in this branch
  merge revisions 11872:11876 from trunk to gsoc2009-matevz branch - license changes
  Grammar and formatting improvements
  Added developer documentation for C++0x.
  Fixed testcase warnings.
  Documented C++0x testcases.
  Updated C++0x User's manual.
  Removed decr-- Hash tables feature. Added some comments.
  Added draft user documentation for the C++0x.
  Added warning for initializer_list introduced in C++0x. Added testcase cpp0x_initializer_list.
  Fixed cpp0x_result_of testcase. Added testcase cpp0x_sizeof_object.
  Added testcase for default/delete arguments introduced in C++0x.
  Added cpp0x_result_of testcase.
  Added syntax support for template aliasing and new 'using' syntax for typedefs introduced in C++0x. Added testcase cpp0x_template_typedefs.
  Added testcase cpp0x_constructors for delegating constructors and constructor inheritance.
  Added initial support for C++0x decltype(). Added testcase cpp0x_decltype.
  Added support for user-defined string literals. Added testcase cpp0x_userdefined_literals.i
  Fixed compilation error.
  Added syntax for lambda expressions and closures introduced in C++0x. Added testcase cpp0x_lambda_functions.i.
  Fixed variadic template argument warning.
  Enabled support for variadic %template directive.
  Enabled alternate function syntax and added runtime testcases. Added support for null pointer constant introduced in C++0x.
  Fixed S/R and R/R conflicts. Fixed testcase for rvalue reference.
  Added variadic '...' syntax for inheritance introduced in C++0x. Added sizeof... syntax introduced in C++0x.
  Added initial support for variadic templates.
  Added partial support for unordered_ STL types.
  Added support for C++0x rvalue and move semantics. Added testcase.
  Added initial support for parsing C++0x strongly typed enumerations.
  Fixed bug in cpp0x testcase.
  Added testcase for cpp0x unrestricted unions.
  Disabled alternate function syntax testcase.
  Added testcase for function objects.
  Added initial support for hash tables unordered_ types.
  Added C++0x test case for the hash_tables.
  Added support for C++0x alternate function syntax. Added testcase.
  Added support for cpp0x uniform initialization. Added testcases.
  Fixed cpp0x_raw_string_literals.i test case.
  Added testcase for shared_ptr, unique_ptr and weak_ptr.
  Added keyword 'thread_local' to Swig. Added testcase.
  Added test case.
  Added C++0x support for 'extern' explicit template instantiation without the translation unit. Added test cases.
  Added support for C++0x static_assert().
  Added support for custom string delimiters.
  Added support for unicode strings and fixed support for wstrings. Added test case cpp0x_raw_string_literals.i.
  Added test case for explicit conversion operators. Some cosmetic fixes.
  Added constexpr keywords and CONSTEXPR terminal to Swig parser. Added cpp0x_constexpr.i testcase. Fixed compilation bug of cpp0x_template_double_brackets.i testcase. Removed obsolete cpp0x_template_double_brackets_broken.
  Introduced new CXXFLAGS symbol for the compilation of test suite. Added -std=c++0x to g++ compiler to enable compilation of the new C++0x tests.
  Renamed template_double_brackets -> cpp0x_template_double_brackets. Added CPP0X_TEST_CASES and CPP0X_TEST_BROKEN in common.mk.
  Added support for template double brackets for C++0x. Added test cases.
This commit is contained in:
William S Fulton 2013-10-11 21:52:05 +01:00
commit b17456e617
118 changed files with 6056 additions and 390 deletions

View file

@ -24,7 +24,8 @@
TARGET =
CC = @CC@
CXX = @CXX@
CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@
CFLAGS = @PLATCFLAGS@
CXXFLAGS = @BOOST_CPPFLAGS@ @PLATCXXFLAGS@
prefix = @prefix@
exec_prefix= @exec_prefix@
SRCS =
@ -138,7 +139,7 @@ tclsh: $(SRCS)
tclsh_cpp: $(SRCS)
$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
# -----------------------------------------------------------
@ -156,8 +157,8 @@ tcl: $(SRCS)
tcl_cpp: $(SRCS)
$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
$(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
$(TCLCXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
# -----------------------------------------------------------------
# Run Tcl example
@ -217,8 +218,8 @@ perl5: $(SRCS)
perl5_cpp: $(SRCS)
$(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a module from existing XS C source code. (ie. from xsubpp).
@ -237,7 +238,7 @@ perl5_static: $(SRCS)
perl5_static_cpp: $(SRCS)
$(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
$(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
# -----------------------------------------------------------------
# Running a Perl5 example
@ -309,8 +310,8 @@ python: $(SRCS)
python_cpp: $(SRCS)
$(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
# -----------------------------------------------------------------
# Build statically linked Python interpreter
@ -330,7 +331,7 @@ python_static: $(SRCS)
python_static_cpp: $(SRCS)
$(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
# -----------------------------------------------------------------
@ -393,7 +394,7 @@ OCTAVE_SCRIPT = $(RUNME).m
octave: $(SRCS)
$(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CXX) -g -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CSRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
@ -403,8 +404,8 @@ octave: $(SRCS)
octave_cpp: $(SRCS)
$(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
$(CXX) -g -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CXXSHARED) -g $(CXXFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
# -----------------------------------------------------------------
# Running an Octave example
@ -454,8 +455,8 @@ guile: $(SRCS)
guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS)
$(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
guile_externalhdr:
$(SWIG) -guile -external-runtime $(TARGET)
@ -466,7 +467,7 @@ guile_externalhdr:
guile_augmented:
$(SWIG) -guile $(SWIGOPT) $(INTERFACE)
$(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET)
$(CC) $(CXXFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET)
# -----------------------------------------------------------------
# Build statically linked Guile interpreter
@ -480,7 +481,7 @@ guile_static: $(SRCS)
guile_static_cpp: $(SRCS)
$(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
-DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
$(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile
@ -491,7 +492,7 @@ guile_simple: $(SRCS)
guile_simple_cpp: $(SRCS)
$(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile
# -----------------------------------------------------------------
@ -554,8 +555,8 @@ java: $(SRCS)
java_cpp: $(SRCS)
$(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
$(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
$(JAVACXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
# ----------------------------------------------------------------
# Compile java files
@ -706,7 +707,7 @@ mzscheme: $(SRCS)
mzscheme_cpp: $(SRCS)
$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
$(CXXSHARED) $(CXXFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
# -----------------------------------------------------------------
# Run mzscheme example
@ -771,7 +772,7 @@ ocaml_dynamic: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(CXXSHARED) $(CXXFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS)
$(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
$(INTERFACE:%.i=%_dynamic.ml)
@ -842,7 +843,7 @@ ocaml_dynamic_cpp: $(SRCS)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(CXXSHARED) $(CXXFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
$(CPP_DLLIBS) $(LIBS)
$(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
@ -912,8 +913,8 @@ ruby: $(SRCS)
ruby_cpp: $(SRCS)
$(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO)
# -----------------------------------------------------------------
# Build statically linked Ruby interpreter
@ -929,7 +930,7 @@ ruby_static: $(SRCS)
ruby_cpp_static: $(SRCS)
$(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(CXX) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
# -----------------------------------------------------------------
@ -979,8 +980,8 @@ php: $(SRCS)
php_cpp: $(SRCS)
$(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
# -----------------------------------------------------------------
# Running a PHP example
@ -1033,8 +1034,8 @@ pike: $(SRCS)
pike_cpp: $(SRCS)
$(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
# Build statically linked Pike interpreter
@ -1050,7 +1051,7 @@ pike_static: $(SRCS)
pike_cpp_static: $(SRCS)
$(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(CXX) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
# -----------------------------------------------------------------
@ -1121,9 +1122,9 @@ chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-dynamic -feature chicken-compile-shared \
-output-file $(CHICKEN_COMPILED_SCHEME)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
$(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CHICKEN_COMPILED_SCHEME)
$(CXXSHARED) $(CFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
$(CXXSHARED) $(CXXFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
$(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
@ -1149,7 +1150,7 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
-output-file $(CHICKEN_COMPILED_SCHEME)
$(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
-output-file $(CHICKEN_MAIN:.scm=_chicken.c)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
$(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) \
$(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
$(CXX) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
@ -1221,8 +1222,8 @@ csharp: $(SRCS)
csharp_cpp: $(SRCS)
$(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
# ----------------------------------------------------------------
# Compile CSharp files
@ -1288,8 +1289,8 @@ lua: $(SRCS)
lua_cpp: $(SRCS)
$(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
# -----------------------------------------------------------------
# Build statically linked Lua interpreter
@ -1302,7 +1303,7 @@ lua_static: $(SRCS)
lua_static_cpp: $(SRCS)
$(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \
$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \
$(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET)
# -----------------------------------------------------------------
@ -1345,8 +1346,8 @@ allegrocl: $(SRCS)
allegrocl_cpp: $(SRCS)
$(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
# Run ALLEGRO CL example
@ -1421,8 +1422,8 @@ cffi: $(SRCS)
cffi_cpp: $(SRCS)
$(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
# Run CFFI example
@ -1461,8 +1462,8 @@ uffi: $(SRCS)
uffi_cpp: $(SRCS)
$(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
# $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
# $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
# Run UFFI example
@ -1519,7 +1520,7 @@ endif
r_cpp: $(CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
ifneq ($(CXXSRCS),)
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
$(CXX) -g -c $(CXXFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
endif
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
@ -1594,8 +1595,8 @@ go: $(SRCS)
go_cpp: $(SRCS)
$(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
$(CXX) -g -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
if ! $(GOGCC) ; then \
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \
@ -1666,8 +1667,8 @@ d: $(SRCS)
d_cpp: $(SRCS)
$(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
# ----------------------------------------------------------------
# Compile D files

View file

@ -86,14 +86,14 @@ CPP_TEST_BROKEN += \
li_boost_shared_ptr_template \
overload_complicated \
template_default_pointer \
template_expr
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 \
@ -478,6 +478,42 @@ CPP_TEST_CASES += \
wallkw \
wrapmacro
# C++11 test cases.
CPP11_TEST_CASES = \
cpp11_alternate_function_syntax \
cpp11_constexpr \
cpp11_decltype \
cpp11_default_delete \
cpp11_delegating_constructors \
cpp11_explicit_conversion_operators \
cpp11_function_objects \
cpp11_initializer_list \
cpp11_initializer_list_extend \
cpp11_lambda_functions \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \
cpp11_rvalue_reference \
cpp11_rvalue_reference2 \
cpp11_rvalue_reference3 \
cpp11_sizeof_object \
cpp11_static_assert \
cpp11_strongly_typed_enumerations \
cpp11_template_double_brackets \
cpp11_template_explicit \
cpp11_template_typedefs \
cpp11_uniform_initialization \
cpp11_unrestricted_unions \
cpp11_userdefined_literals \
cpp11_variadic_templates
# cpp11_inheriting_constructors \ # not supported by gcc-4.7
# cpp11_hash_tables \ # not fully implemented yet
# cpp11_result_of \ # SWIG does not support
# cpp11_thread_local \ # needs gcc-4.8
# Broken C++11 test cases.
CPP11_TEST_BROKEN =
#
# Put all the heavy STD/STL cases here, where they can be skipped if needed
#
@ -507,6 +543,9 @@ 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 += \
@ -590,10 +629,12 @@ ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \
#######################################################################
# 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)
check-cpp11: $(CPP11_TEST_CASES:=.cpptest)
# 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

View 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;
}
%}

View file

@ -0,0 +1,12 @@
/* This interface tests whether SWIG supports the new "constexpr" keyword
introduced by C++11.
*/
%module cpp11_constexpr
%inline %{
class TestClass {
public:
constexpr int func() { return 10; }
};
%}

View 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;
}
};
%}

View file

@ -0,0 +1,24 @@
/* This testcase checks whether SWIG correctly parses the default and delete
keywords which keep or remove default C++ object construction functions. */
%module cpp11_default_delete
%{
#include <stdlib.h>
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 f(int i);
void f(double i) = delete; /* Don't cast double to int. Compiler returns an error */
};
struct A2 {
void f(int i);
template<class T> void f(T) = delete; /* Only accept int */
};
%}

View 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; }
};
%}

View file

@ -0,0 +1,28 @@
/* This interface checks whether SWIG correctly compiles the new
explicit conversion operators feature introduced in C++11.
*/
%module cpp11_explicit_conversion_operators
%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;
};
%}

View 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;
}
%}

View 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;
};
%}

View file

@ -0,0 +1,18 @@
/* This test checks whether SWIG correctly parses the new constructor
inheritance.
*/
%module cpp11_inheriting_constructors
%inline %{
class BaseClass {
private:
int _val;
public:
BaseClass(int iValue) { _val = iValue; }
};
class DerivedClass: public BaseClass {
public:
using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
};
%}

View 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() {}
};
%}

View 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&) {}
};
%}

View 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; })());
%}

View 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) {}
};
%}

View 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";
%}

View file

@ -0,0 +1,20 @@
/* 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>
#include <iostream>
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);
}
%}
%template(test_result) test_result_impl<double(*)(double), double>;
%constant double (*SQUARE)(double) = square;

View 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;
};
%}

View 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>;

View 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) {}
};
%}

View 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);
%}

View 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");
};
%}

View 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;
};
*/
%}

View file

@ -0,0 +1,39 @@
/* 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; }
};
template<class T>
class ABC2 {
public:
int a;
template<typename U>
U operator>>(ABC &);
template<typename U>
U operator<<(ABC &);
};
%}

View file

@ -0,0 +1,24 @@
/* 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 %{
#include <vector>
class A {
public:
int member;
int memberFunction() { return 100; }
};
template class std::vector<A>;
extern template class std::vector<A>;
template class std::vector<A*>;
extern template class std::vector<A*>;
%}

View file

@ -0,0 +1,23 @@
/* This testcase checks whether SWIG correctly parses alias templates. */
%module cpp11_template_typedefs
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
%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
%}

View 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;
%}

View 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} };
%}

View 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;
%}

View 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;
%}

View 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>;

View file

@ -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'){}
};
%}

View file

@ -0,0 +1,28 @@
import cpp11_lambda_functions.*;
public class cpp11_lambda_functions_runme {
static {
try {
System.loadLibrary("cpp11_lambda_functions");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
private static void check(int received, int expected) {
if (expected != received)
throw new RuntimeException("check failed, expected: " + expected + " received: " + received);
}
public static void main(String argv[])
{
check(cpp11_lambda_functions.runLambda1(), 11);
check(cpp11_lambda_functions.runLambda2(), 11);
check(cpp11_lambda_functions.runLambda3(), 11);
check(cpp11_lambda_functions.runLambda4(), 11);
check(cpp11_lambda_functions.runLambda5(), 1);
check(cpp11_lambda_functions.runLambda5(), 2);
}
}

View file

@ -0,0 +1,51 @@
import cpp11_thread_local.*;
public class cpp11_thread_local_runme {
static {
try {
System.loadLibrary("cpp11_thread_local");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
if (ThreadLocals.getStval() != 11)
throw new RuntimeException();
if (ThreadLocals.getTsval() != 22)
throw new RuntimeException();
if (ThreadLocals.tscval99 != 99)
throw new RuntimeException();
cpp11_thread_local.setEtval(-11);
if (cpp11_thread_local.getEtval() != -11)
throw new RuntimeException();
cpp11_thread_local.setStval(-22);
if (cpp11_thread_local.getStval() != -22)
throw new RuntimeException();
cpp11_thread_local.setTsval(-33);
if (cpp11_thread_local.getTsval() != -33)
throw new RuntimeException();
cpp11_thread_local.setEtval(-44);
if (cpp11_thread_local.getEtval() != -44)
throw new RuntimeException();
cpp11_thread_local.setTeval(-55);
if (cpp11_thread_local.getTeval() != -55)
throw new RuntimeException();
cpp11_thread_local.setEctval(-55);
if (cpp11_thread_local.getEctval() != -55)
throw new RuntimeException();
cpp11_thread_local.setEcpptval(-66);
if (cpp11_thread_local.getEcpptval() != -66)
throw new RuntimeException();
}
}

View file

@ -0,0 +1,13 @@
import cpp11_alternate_function_syntax
a = cpp11_alternate_function_syntax.SomeStruct()
res = a.addNormal(4,5)
if res != 9:
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
res = a.addAlternate(4,5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")

View file

@ -0,0 +1,19 @@
import cpp11_decltype
a = cpp11_decltype.A()
a.i = 5
if a.i != 5:
raise RuntimeError, "Assignment to a.i failed."
a.j = 10
if a.j != 10:
raise RuntimeError, "Assignment to a.j failed."
b = a.foo(5)
if b != 10:
raise RuntimeError, "foo(5) should return 10."
b = a.foo(6)
if b != 0:
raise RuntimeError, "foo(6) should return 0."

View file

@ -0,0 +1,12 @@
import cpp11_function_objects
import sys
t = cpp11_function_objects.Test()
if t.value != 0:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
t(1,2) # adds numbers and sets value
if t.value != 3:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))

View file

@ -0,0 +1,4 @@
import cpp11_initializer_list_extend
c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] )

View file

@ -0,0 +1,5 @@
import cpp11_initializer_list
a = cpp11_initializer_list.A()
a = cpp11_initializer_list.A(11.1)

View file

@ -0,0 +1,15 @@
import cpp11_null_pointer_constant
a = cpp11_null_pointer_constant.A()
if a._myA != None:
raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
b = cpp11_null_pointer_constant.A()
if a._myA != b._myA:
raise RuntimeError, ("cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
a._myA = cpp11_null_pointer_constant.A()
if a._myA == None:
raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be object, but is None")

View file

@ -0,0 +1,50 @@
from cpp11_raw_string_literals import *
if cvar.L != 100:
raise RuntimeError
if cvar.u8 != 100:
raise RuntimeError
if cvar.u != 100:
raise RuntimeError
if UStruct.U != 100:
raise RuntimeError
if cvar.R != 100:
raise RuntimeError
if cvar.LR != 100:
raise RuntimeError
if cvar.u8R != 100:
raise RuntimeError
if cvar.uR != 100:
raise RuntimeError
if URStruct.UR != 100:
raise RuntimeError
if cvar.aa != "Wide string":
raise RuntimeError
if cvar.bb != "UTF-8 string":
raise RuntimeError, cvar.wide
if cvar.xx != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.xx
if cvar.ee != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.ee
if cvar.ff != "I'm a \"raw wide\" \\ string.":
raise RuntimeError, cvar.ff
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
raise RuntimeError, cvar.gg

View file

@ -0,0 +1,3 @@
import cpp11_result_of
if cpp11_result_of.test_result(cpp11_result_of.square, 3.0) != 9.0:
raise RuntimeError, "test_result(square, 3.0) is not 9.0."

View file

@ -0,0 +1,24 @@
import cpp11_rvalue_reference
a = cpp11_rvalue_reference.A()
a.setAcopy(5)
if a.getAcopy() != 5:
raise RunTimeError, ("int A::getAcopy() value is ", a.getAcopy(), " should be 5")
ptr = a.getAptr()
a.setAptr(ptr)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
a.setAref(ptr)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
rvalueref = a.getAmove()
a.setAmove(rvalueref)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")

View file

@ -0,0 +1,38 @@
from cpp11_thread_local import *
t = ThreadLocals()
if t.stval != 11:
raise RuntimeError
if t.tsval != 22:
raise RuntimeError
if t.tscval99 != 99:
raise RuntimeError
cvar.etval = -11
if cvar.etval != -11:
raise RuntimeError
cvar.stval = -22
if cvar.stval != -22:
raise RuntimeError
cvar.tsval = -33
if cvar.tsval != -33:
raise RuntimeError
cvar.etval = -44
if cvar.etval != -44:
raise RuntimeError
cvar.teval = -55
if cvar.teval != -55:
raise RuntimeError
cvar.ectval = -66
if cvar.ectval != -66:
raise RuntimeError
cvar.ecpptval = -66
if cvar.ecpptval != -66:
raise RuntimeError

View file

@ -0,0 +1,21 @@
import cpp11_uniform_initialization
var1 = cpp11_uniform_initialization.cvar.var1
if var1.x != 5:
raise RuntimeError
var2 = cpp11_uniform_initialization.cvar.var2
if var2.getX() != 2:
raise RuntimeError
m = cpp11_uniform_initialization.MoreInit()
if m.charptr != None:
raise RuntimeError, m.charptr
m.charptr = "hello sir"
if m.charptr != "hello sir":
raise RuntimeError, m.charptr
if m.more1(m.vi) != 15:
raise RuntimeError, m.vi
if m.more1( [-1,1,2] ) != 2:
raise RuntimeError, m.vi
if m.more1() != 10:
raise RuntimeError