summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2013-10-11 21:52:05 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-10-11 21:52:05 +0100
commitb17456e617f972a0af39abd0650dd0fe142920ba (patch)
treea8b6b1c8473a6d949295982d7668bd1af4da84e6
parente5f9f9180707c1c30a9bc025ee3d3f171c1b8d6e (diff)
parent7b08378145ad703cb6a8cc128c01975dfdce8af4 (diff)
downloadswig-b17456e617f972a0af39abd0650dd0fe142920ba.tar.gz
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.
-rw-r--r--Doc/Devel/cpp11.html788
-rw-r--r--Doc/Manual/CPlusPlus11.html942
-rw-r--r--Doc/Manual/Warnings.html1
-rw-r--r--Doc/Manual/chapters1
-rw-r--r--Examples/Makefile.in101
-rw-r--r--Examples/test-suite/common.mk47
-rw-r--r--Examples/test-suite/cpp11_alternate_function_syntax.i18
-rw-r--r--Examples/test-suite/cpp11_constexpr.i12
-rw-r--r--Examples/test-suite/cpp11_decltype.i19
-rw-r--r--Examples/test-suite/cpp11_default_delete.i24
-rw-r--r--Examples/test-suite/cpp11_delegating_constructors.i18
-rw-r--r--Examples/test-suite/cpp11_explicit_conversion_operators.i28
-rw-r--r--Examples/test-suite/cpp11_function_objects.i35
-rw-r--r--Examples/test-suite/cpp11_hash_tables.i43
-rw-r--r--Examples/test-suite/cpp11_inheriting_constructors.i18
-rw-r--r--Examples/test-suite/cpp11_initializer_list.i34
-rw-r--r--Examples/test-suite/cpp11_initializer_list_extend.i29
-rw-r--r--Examples/test-suite/cpp11_lambda_functions.i110
-rw-r--r--Examples/test-suite/cpp11_null_pointer_constant.i22
-rw-r--r--Examples/test-suite/cpp11_raw_string_literals.i59
-rw-r--r--Examples/test-suite/cpp11_result_of.i20
-rw-r--r--Examples/test-suite/cpp11_rvalue_reference.i22
-rw-r--r--Examples/test-suite/cpp11_rvalue_reference2.i86
-rw-r--r--Examples/test-suite/cpp11_rvalue_reference3.i67
-rw-r--r--Examples/test-suite/cpp11_sizeof_object.i17
-rw-r--r--Examples/test-suite/cpp11_static_assert.i17
-rw-r--r--Examples/test-suite/cpp11_strongly_typed_enumerations.i87
-rw-r--r--Examples/test-suite/cpp11_template_double_brackets.i39
-rw-r--r--Examples/test-suite/cpp11_template_explicit.i24
-rw-r--r--Examples/test-suite/cpp11_template_typedefs.i23
-rw-r--r--Examples/test-suite/cpp11_thread_local.i33
-rw-r--r--Examples/test-suite/cpp11_uniform_initialization.i49
-rw-r--r--Examples/test-suite/cpp11_unrestricted_unions.i23
-rw-r--r--Examples/test-suite/cpp11_userdefined_literals.i53
-rw-r--r--Examples/test-suite/cpp11_variadic_templates.i77
-rw-r--r--Examples/test-suite/csharp_features.i4
-rw-r--r--Examples/test-suite/java/cpp11_lambda_functions_runme.java28
-rw-r--r--Examples/test-suite/java/cpp11_thread_local_runme.java51
-rw-r--r--Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py13
-rw-r--r--Examples/test-suite/python/cpp11_decltype_runme.py19
-rw-r--r--Examples/test-suite/python/cpp11_function_objects_runme.py12
-rw-r--r--Examples/test-suite/python/cpp11_initializer_list_extend_runme.py4
-rw-r--r--Examples/test-suite/python/cpp11_initializer_list_runme.py5
-rw-r--r--Examples/test-suite/python/cpp11_null_pointer_constant_runme.py15
-rw-r--r--Examples/test-suite/python/cpp11_raw_string_literals_runme.py50
-rw-r--r--Examples/test-suite/python/cpp11_result_of_runme.py3
-rw-r--r--Examples/test-suite/python/cpp11_rvalue_reference_runme.py24
-rw-r--r--Examples/test-suite/python/cpp11_thread_local_runme.py38
-rw-r--r--Examples/test-suite/python/cpp11_uniform_initialization_runme.py21
-rw-r--r--Lib/allegrocl/allegrocl.swg15
-rw-r--r--Lib/cffi/cffi.swg9
-rw-r--r--Lib/chicken/chicken.swg36
-rw-r--r--Lib/csharp/csharp.swg52
-rw-r--r--Lib/csharp/enums.swg4
-rw-r--r--Lib/csharp/enumsimple.swg4
-rw-r--r--Lib/csharp/enumtypesafe.swg4
-rw-r--r--Lib/go/go.swg18
-rw-r--r--Lib/guile/typemaps.i23
-rw-r--r--Lib/java/java.swg43
-rw-r--r--Lib/lua/lua.swg2
-rw-r--r--Lib/lua/luatypemaps.swg25
-rw-r--r--Lib/modula3/modula3.swg51
-rw-r--r--Lib/mzscheme/typemaps.i15
-rw-r--r--Lib/ocaml/typecheck.i2
-rw-r--r--Lib/ocaml/typemaps.i36
-rw-r--r--Lib/perl5/perltypemaps.swg3
-rw-r--r--Lib/php/const.i1
-rw-r--r--Lib/php/globalvar.i6
-rw-r--r--Lib/php/php.swg46
-rw-r--r--Lib/pike/pike.swg14
-rw-r--r--Lib/python/pydocs.swg2
-rw-r--r--Lib/python/pystdcommon.swg2
-rw-r--r--Lib/python/std_unordered_map.i251
-rw-r--r--Lib/python/std_unordered_multimap.i79
-rw-r--r--Lib/python/std_unordered_multiset.i41
-rw-r--r--Lib/python/std_unordered_set.i55
-rw-r--r--Lib/r/rtype.swg15
-rw-r--r--Lib/std/std_multimap.i2
-rw-r--r--Lib/std/std_multiset.i2
-rw-r--r--Lib/std/std_unordered_map.i127
-rw-r--r--Lib/std/std_unordered_multimap.i90
-rw-r--r--Lib/std/std_unordered_multiset.i86
-rw-r--r--Lib/std/std_unordered_set.i119
-rw-r--r--Lib/swig.swg169
-rw-r--r--Lib/swigwarnings.swg1
-rw-r--r--Lib/tcl/tcltypemaps.swg3
-rw-r--r--Lib/typemaps/enumint.swg15
-rw-r--r--Lib/typemaps/swigtype.swg95
-rw-r--r--Makefile.in3
-rw-r--r--Source/CParse/cscanner.c31
-rw-r--r--Source/CParse/parser.y750
-rw-r--r--Source/Include/swigwarn.h6
-rw-r--r--Source/Modules/allocate.cxx2
-rw-r--r--Source/Modules/browser.cxx6
-rw-r--r--Source/Modules/cffi.cxx11
-rw-r--r--Source/Modules/clisp.cxx5
-rw-r--r--Source/Modules/contract.cxx2
-rw-r--r--Source/Modules/directors.cxx4
-rw-r--r--Source/Modules/go.cxx4
-rw-r--r--Source/Modules/lang.cxx22
-rw-r--r--Source/Modules/octave.cxx2
-rw-r--r--Source/Modules/php.cxx2
-rw-r--r--Source/Modules/python.cxx2
-rw-r--r--Source/Modules/ruby.cxx2
-rw-r--r--Source/Modules/swigmod.h1
-rw-r--r--Source/Modules/typepass.cxx17
-rw-r--r--Source/Swig/cwrap.c66
-rw-r--r--Source/Swig/misc.c43
-rw-r--r--Source/Swig/naming.c3
-rw-r--r--Source/Swig/scanner.c338
-rw-r--r--Source/Swig/stype.c51
-rw-r--r--Source/Swig/swig.h12
-rw-r--r--Source/Swig/swigscan.h3
-rw-r--r--Source/Swig/typemap.c6
-rw-r--r--Source/Swig/typeobj.c39
-rw-r--r--Source/Swig/typesys.c13
-rw-r--r--Tools/config/ax_cxx_compile_stdcxx_11.m4121
-rw-r--r--configure.ac39
118 files changed, 6054 insertions, 388 deletions
diff --git a/Doc/Devel/cpp11.html b/Doc/Devel/cpp11.html
new file mode 100644
index 000000000..fc35465ae
--- /dev/null
+++ b/Doc/Devel/cpp11.html
@@ -0,0 +1,788 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
+ <TITLE></TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.0 (Unix)">
+ <META NAME="CREATED" CONTENT="20090712;16061100">
+ <META NAME="CHANGED" CONTENT="20090817;17311900">
+ <META NAME="Podatek 1" CONTENT="">
+ <META NAME="Podatek 2" CONTENT="">
+ <META NAME="Podatek 3" CONTENT="">
+ <META NAME="Podatek 4" CONTENT="">
+ <STYLE TYPE="text/css">
+ <!--
+ @page { margin: 2cm }
+ H1 { margin-bottom: 0.21cm }
+ H1.western { font-family: "Liberation Serif", serif }
+ H1.cjk { font-family: "DejaVu Sans" }
+ H1.ctl { font-family: "DejaVu Sans" }
+ P { margin-bottom: 0.21cm }
+ H2 { margin-bottom: 0.21cm }
+ A:link { so-language: zxx }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-US" DIR="LTR">
+<H1 CLASS="western"><U>C++0x/C++11 support for SWIG</U></H1>
+<H1 CLASS="western">Summary</H1>
+<P>This is a technical overview of the C++0x/C++11 support for the Swig.
+This area of Swig is a work in progress. Initial C++0x/C++11 support for
+Swig was written during the Google Summer of Code 2009 period by
+Matevž Jekovec.</P>
+<H1 CLASS="western">SVN branch</H1>
+<P>branches/gsoc2009-matevz</P>
+<H1 CLASS="western">New C++11 features status</H1>
+<P>Wikipedia article: <A HREF="http://en.wikipedia.org/wiki/C++0x">http://en.wikipedia.org/wiki/C%2B%2B0x</A>
+</P>
+<H2>Rvalue reference and move semantics [done]</H2>
+<P>The Rvalues are used in practice to speed up the move operations
+on different containers.</P>
+<P>In the following example, we want to swap the given elements:</P>
+<PRE>template &lt;class T&gt; swap(T&amp; a, T&amp; b) {
+ T tmp(a); // now we have two copies of a
+ a = b; // now we have two copies of b
+ b = tmp; // now we have two copies of tmp (aka a)
+}</PRE><P>
+This can now be solved using the new function std::move():</P>
+<PRE>template &lt;class T&gt; swap(T&amp; a, T&amp; b) {
+ T tmp(std::move(a));
+ a = std::move(b);
+ b = std::move(tmp);
+}</PRE><P STYLE="margin-bottom: 0cm">
+For the move function to take effect, user needs to reimplement the
+move constructor (taking ClassType&amp;&amp; as an argument) and
+operator=(ClassType&amp;&amp;):</P>
+<PRE>class MyClass {
+ MyClass(MyClass&amp;&amp; p) : ptr(p.ptr) {p.ptr = 0;}
+ MyClass&amp; operator=(MyClass&amp;&amp; p) {
+ std::swap(ptr, p.ptr);
+ return *this;
+ }
+};</PRE><P>
+In practice, the Rvalues are used for temporaries (when passing the
+result of one function as an argument to another).</P>
+<P>Done: Added type&amp;&amp; to Swig parser. Added testcase
+cpp11_rvalue_reference.i. Operator &amp;&amp; is treated the same as
+operator &amp;. R11450</P>
+<P STYLE="margin-bottom: 0cm">Article:
+<A HREF="http://www.artima.com/cppsource/rvalue.html">http://www.artima.com/cppsource/rvalue.html</A></P>
+<H2>Generalized constant expressions [done]</H2>
+<P>In C++11 you can define functions as constant expressions.
+Functions need to return constant value in form &quot;return expr&quot;,
+where expr is a constant expression.
+</P>
+<P>A keyword &quot;constexpr&quot; is introduced for this. eg.:
+constexpr int getNumber() { return 5; } const int MY_CONSTANT =
+getNumber();
+</P>
+<P>Constants are treated as normal variables in interpreted languages
+because they are not compiled into the executable. Java &quot;final&quot;
+constants are defined runtime as well. C++ constants need to be
+declared in the header file and defined in the implementation file,
+so swig doesn't need to know about the constant values when parsing
+the header file.
+</P>
+<P>Done: Added the “constexpr “ keyword to Swig. Added testcase
+cpp11_constexpr. R11322</P>
+<P>Problem: No compilers were known to support constexpr yet, so the
+testcase was temporarily commented out in common.mk.
+</P>
+<H2>Extern template [done]</H2>
+<P>Extern template forces the GCC compiler to not instantiate the
+template in the translation unit at that time. It's a feature
+specifically aimed at compilers to speed up the compilation process.
+</P>
+<P>Done: Added support for 'extern template class
+std::vector&lt;MyClass&gt;;'. Added testcase cpp11_template_explicit.
+R11385 , R11386</P>
+<H2>Initializer lists [done]</H2>
+<P>Initializer list is a new type in standard library:
+std::initializer_list&lt;T&gt;. New symbols {} are introduced for the
+initializer lists.
+</P>
+<P>One can now use:
+</P>
+<PRE> class A {
+ public:
+ A( std::initializer_list&lt;int&gt; );
+ };
+ A a1 = {1,2,3,4};</PRE><P>
+Languages like Java, C# and Python already support direct creation of
+lists natively.</P>
+<P>Problem: initializer_list cannot be treated as an ordinary list.
+The constructor containing initializer_list can only be accessed by
+assigning the value using the {} brackets. I also don't think there
+is a simple way to convert an ordinary list or a vector to the
+initializer_list.</P>
+<P>Done: Ignored the constructor having initializer_list as its
+argument. Show warning to the user. Added testcase
+cpp11_initializer_list. R11450</P>
+<P>Article:
+<A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1919.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1919.pdf</A></P>
+<H2>Uniform initialization [done]</H2>
+<P>The new C++11 standard will allow the following:</P>
+<PRE>struct IdString {
+ std::string name;
+ int identifier;
+};
+
+IdString GetString() {
+ return {&quot;SomeName&quot;, 4}; //Note the lack of explicit type.
+}</PRE><P>
+The feature works exactly as it did now for POD types only (eg. int
+a[] = {1,2,3};). The following declarations are the same in the new
+C++11:</P>
+<PRE>IdString str1 = {„SomeName“, 4};
+IdString str2{„SomeName“, 4};</PRE><P>
+The new way of using uniform initialization allows the following:</P>
+<PRE>struct BasicStruct {
+ int x;
+ double y;
+};
+
+struct AltStruct {
+ AltStruct(int x, double y) : x_{x}, y_{y} {}
+
+private:
+ int x_;
+ double y_;
+};
+
+BasicStruct var1{5, 3.2}; // only fills the struct components
+AltStruct var2{2, 4.3}; // calls the constructor</PRE><P>
+The new syntax is specific to C++. Java, C# and scripting languages
+do not support this behaviour, but always need constructors. They
+support {} brackets for declaration of arrays as C does + they add
+support for creation of arrays on-the-fly (what C++11 introduced with
+this feature and more).</P>
+<P>Done: Added syntax for {} member initialization in class
+constructor. Added testcase cpp11_uniform_initialization. R11413</P>
+<H2>Type inference [partially done]</H2>
+<P>A new keyword 'auto' is introduced in C++11:</P>
+<PRE>auto a1 = 100;
+auto a2 = myFunc();</PRE><P>
+The type of a1 and a2 is automatically determined according to the
+initialization value during the semantic phase of the compiler.</P>
+<P>Another macro 'decltype()' is introduced. The macro takes the
+concrete object as an argument and returns its type. User could use
+this as:</P>
+<PRE>int i = 100;
+decltype(i) j = 200; // decltype(i) = int</PRE><P STYLE="margin-bottom: 0cm">
+Calling operators are allowed as well:</P>
+<PRE STYLE="margin-bottom: 0.5cm">decltype(i+j) k = 300;</PRE><P>
+Done: Added support for decltype() syntax. Test cases for normal
+decltype members and alternate function members work fine. Currently
+only syntax in form decltype(variable name) work. No support for
+custom expresions eg. decltype(i+j) yet. R11525</P>
+<P>TODO: William proposed to support the hidden variables as well
+(ones not parsed by Swig and added to symbol table). This also allows
+Swig to parse custom expressions like decltype(i+j). The idea is to
+introduce a new SwigType for this.</P>
+<H2>Range-based for-loop [ignored]</H2>
+<P>This feature is always present inside the implementation block
+only.
+</P>
+<H2>Lambda functions and expressions [done]</H2>
+<P>C++11 introduces lambda functions defined as:</P>
+<PRE STYLE="margin-bottom: 0.5cm">[](int x, int y) -&gt; int { return x + y; }</PRE><P>
+If the lambda function contains a single return statement only or the
+function doesn't return any type, the return type '-&gt;' can be
+omitted. Lambda functions are function objects.</P>
+<P>The following example prints the number of items stored in a list:</P>
+<PRE>std::vector&lt;int&gt; someList;
+int total = 0;
+std::for_each( someList.begin(), someList.end(), [&amp;total](int x) {total += x} );
+std::cout &lt;&lt; total;</PRE><P>
+Parameters inside the [] are the visible parameters of the lambda
+functions. These can be &amp; (references), = (copies), variable name
+(variable copy), &amp;variable name (variable reference) or this
+(copy of the current object).</P>
+<P>Lambda functions can be stored using:</P>
+<PRE STYLE="margin-bottom: 0.5cm">auto myLambdaFunc = [this]() { this-&gt;SomePrivateMemberFunction() };</PRE><P>
+Proposal: Lambda functions are most commonly used inside the function
+block to quickly define how the sort, find and similar functions
+should work (the other way would be overriding a class – the Java
+style). The latest GCC does not support lambda functions yet so it is
+difficult to test the feature once implemented. I would implement the
+syntax support for this feature, but produce no wrapper code. Lambda
+functions still work inside the function block though.</P>
+<P>Article:
+<A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf</A></P>
+<P>Done: Added syntax support for the lambda functions. Added
+testcase cpp11_lambda_functions.i. R11491, R11492</P>
+<H2>Alternate function syntax [done]</H2>
+<P>The problem with decltype() is that the parameters need to be
+defined before the decltype. The following syntax is not valid,
+because lhs and rhs hasn't been defined at the time of decltype:</P>
+<PRE>template&lt; typename LHS, typename RHS&gt;
+ decltype(lhs+rhs) AddingFunc(const LHS &amp;lhs, const RHS &amp;rhs) {return lhs + rhs;} //Not legal C++11</PRE><P>
+The solution C++11 offers is the combination of the 'auto' keyword
+before and '-&gt; rettype' after the function declaration:</P>
+<PRE>template&lt; typename LHS, typename RHS&gt;
+ auto AddingFunc(const LHS &amp;lhs, const RHS &amp;rhs) -&gt; decltype(lhs+rhs) {return lhs + rhs;}</PRE><P>
+The new syntax only makes the job for the C++ compilers easier when
+parsing such functions. The new syntax can be used for ordinary
+functions as well:</P>
+<PRE>struct SomeStruct {
+ auto FuncName(int x, int y) -&gt; int;
+};
+
+auto SomeStruct::FuncName(int x, int y) -&gt; int {
+ return x + y;
+}</PRE><P>
+Done: Added support for the 'auto' return type. Added support for the
+'-&gt; type' after the funtion declaration. Added testcases
+cpp11_alternate_function_syntax.i and
+cpp11_alternate_function_syntax_runme.py. R11414</P>
+<H2>Concepts, Axioms [ignored]</H2>
+<P>In C++ there is a common problem when you use a template in the
+class which doesn't support all the operations the functions in the
+class actually do on the type. Compiler errors are usually very long
+and unreadable. C++11 adds support for the &quot;concepts&quot;. The
+idea is to define what operations and attributes should the template
+have. In contrast to class inheritance and polimorphism, all lookups
+are done in compile-time.
+</P>
+<P>Basic syntax (note LessThanComparable<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=LessThanComparable">?</A>
+instead of &quot;class&quot; or &quot;typename&quot;):
+</P>
+<PRE> template&lt;LessThanComparable<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=LessThanComparable">?</A> T&gt;
+ const T&amp; min(const T &amp;x, const T &amp;y) {
+ return y &lt; x ? y : x;
+ }</PRE><P>
+Extended syntax (requires conditions are separated with &amp;&amp;,
+|| or !):
+</P>
+<PRE> template&lt; typename T&gt; requires LessThanComparable<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=LessThanComparable">?</A>&lt;T&gt;
+ const T&amp; min(const T &amp;x, const T &amp;y) {
+ return y &lt; x ? y : x;
+ }</PRE><P>
+Definition of the concepts:
+</P>
+<PRE> concept LessThanComparable<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=LessThanComparable">?</A>&lt; typename T &gt; {
+ bool operator&lt;(T,T);
+ requires GreaterThanComparable<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=GreaterThanComparable">?</A>&lt;T&gt;;
+ typename value_type;
+ typename reference;
+ };</PRE><P>
+Concept maps allow usage of a specific type:
+</P>
+<PRE> template&lt; typename T&gt;
+ concept_map InputIterator<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=InputIterator">?</A>&lt;T*&gt; {
+ typedef T value_type ;
+ typedef T&amp; reference ;
+ typedef T* pointer ;
+ typedef std::ptrdiff_t difference_type ;
+ };</PRE><P>
+Concept maps can act as mini-types, with function definitions and
+other constructs commonly associated with classes:
+</P>
+<PRE> concept Stack&lt; typename X&gt; {
+ typename value_type;
+ void push(X&amp;, const value_type&amp;);
+ void pop(X&amp;);
+ value_type top(const X&amp;);
+ bool empty(const X&amp;);
+ };
+ template&lt; typename T&gt;
+ concept_map Stack&lt;std::vector&lt;T&gt; &gt; {
+ typedef T value_type;
+ void push(std::vector&lt;T&gt;&amp; v, const T&amp; x) { v.push_back(x); }
+ void pop(std::vector&lt;T&gt;&amp; v) { v.pop_back(); }
+ T top(const std::vector&lt;T&gt;&amp; v) { return v.back(); }
+ bool empty(const std::vector&lt;T&gt;&amp; v) { return v.empty(); }
+ };</PRE><P>
+Axioms are a facility pertaining to concepts supplied by C++11 to
+express the semantic properties of concepts. For example, the concept
+Semigroup can be defined with an axiom Associativity as:
+</P>
+<PRE> concept Semigroup&lt; typename Op, typename T&gt; : CopyConstructible<A HREF="http://www.dabeaz.com/cgi-bin/wiki.pl?action=change1&amp;id=CopyConstructible">?</A>&lt;T&gt; {
+ T operator()(Op, T, T);
+ axiom Associativity(Op op, T x, T y, T z) {
+ op(x, op(y, z)) == op(op(x, y), z);
+ }
+ };</PRE><P>
+Axioms are more like hints to the compiler to speed-up the process of
+compilation.
+</P>
+<P>Ignored: Concepts and axioms were removed from the C++11 standard.
+</P>
+<H2>Object construction improvement [done]</H2>
+<P>This feature allows classes constructors to call other
+constructors with different arguments (similar to Java and C#
+behaviour).
+</P>
+<P>The syntax is as follows:
+</P>
+<PRE> class SomeType {
+ int number;
+ public:
+ SomeType(int newNumber) : number(newNumber) {}
+ SomeType() : SomeType(42) {}
+ };</PRE><P>
+Also when using the inheritance, the feature introduces inheritance
+of all superclass constructors without being defined separately in
+the inherited class:
+</P>
+<PRE> class BaseClass {
+ public:
+ BaseClass(int iValue);
+ };
+ class DerivedClass: public BaseClass {
+ public:
+ using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
+ };</PRE><P>
+Swig already correctly parses and produces the correct wrapper for
+the “using” keyword.</P>
+<P>Done: Added testcase cpp11_constructors.i which covers both
+constructor delegation and constructor inheritance. R11532</P>
+<P>Problem: Constructor delegation and constructor inheritance is not
+supported by any compiler yet, so it's impossible to try and test
+this feature.</P>
+<H2>Null pointer constant [done]</H2>
+<P>nullptr is part of the standard library.
+</P>
+<P>It's defined as typedef decltype(nullptr) nullptr_t;
+</P>
+<P>nullptr_t is defined in &lt;cstddef&gt;.
+</P>
+<P>As far as the C++ is compatible with 0 as the pointer value, swig
+values will work for the C++. And the other way around, nullptr
+behaves as the ordinary pointer (false, if empty, true, if not
+empty), so it's ok for swig to compare it.</P>
+<P>Done: Written a testcase cpp11_null_pointer_constant.i and
+cpp11_null_pointer_constant_runme.py to prove the nullptr
+functionality. R11484</P>
+<H2>Strongly typed enumerations [partially done]</H2>
+<P>C++11 introduces a new syntax for strongly typed enum declaration:
+</P>
+<PRE> enum class Enumeration {
+ Val1,
+ Val2,
+ Val3 = 100,
+ Val4 /* = 101 */
+ };</PRE><P>
+Typing if (Val4 == 101) will result in compilation error.
+</P>
+<P>The enum itself can now be explicitely of type int, long, unsigned
+int etc.:
+</P>
+<PRE STYLE="margin-bottom: 0.5cm"> enum class Enum2 : unsigned int {Val1, Val2};</PRE><P>
+And it can be forward declared as well:
+</P>
+<PRE> enum Enum1; //Illegal in C++ and C++11; no size is explicitly specified.
+ enum Enum2 : unsigned int; //Legal in C++11.
+ enum class Enum3; //Legal in C++11, because enum class declarations have a default type of &quot;int&quot;.
+ enum class Enum4: unsigned int; //Legal C++11.
+ enum Enum2 : unsigned short; //Illegal in C++11, because Enum2 was previously declared with a different type.</PRE><P>
+Done: Added syntax 'enum class Name' and forward declarators 'enum
+Name : inherited type' or 'enum class Name : inherited type' in
+R11449.</P>
+<P>TODO: Add semantic support for enum elements not clashing with
+enum elements in other enum classes. See cpp11_strongly_typed_enums.i
+warnings.</P>
+<P>Problem: Swig currently doesn't support nested classes. This
+feature should be implemented using a new nested class when using
+“enum class” with a single anonymous “enum {elements}”
+element inside. For example:</P>
+<PRE STYLE="margin-bottom: 0.5cm">class A { enum class EA { a,b,c,d }; };</PRE><P>
+should be mapped to</P>
+<PRE STYLE="margin-bottom: 0.5cm">class A { class EA { enum {a,b,c,d}; }; };</PRE><H2>
+Angle bracket [done]</H2>
+<P>Support for right angled brackets was implemented using the
+following article as a base:
+<A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html</A>
+</P>
+<P>Done: Added support for angle brackets. Used the preferred
+&quot;Approach 1&quot;. Added a testcase named
+cpp11_template_double_brackets. R11245</P>
+<H2>Explicit conversion operators [done]</H2>
+<P>This is used when converting one type to another (eg. if
+(myObject) {}, where myObject is your custom class converted to
+bool).
+</P>
+<P>Requires both operator and function overloading which is not
+supported in any target language (eg. python, php).
+</P>
+<P>Done: Swig already supports the keyword &quot;explicit&quot; for
+function types as well. Added test case
+cpp11_explicit_conversion_operators. R11323</P>
+<H2>Template typedefs [partially done]</H2>
+<P>The new C++11 will allow creation of wrapper around the template.
+For example, if we want to do this:</P>
+<PRE>template&lt; typename first, typename second, int third&gt;
+class SomeType;
+
+template&lt; typename second&gt;
+typedef SomeType&lt;OtherType, second, 5&gt; TypedefName; //Illegal in C++</PRE><P>
+This is still illegal! But we can now use the new syntax for
+achieving the same effect:</P>
+<PRE>template&lt; typename first, typename second, int third&gt;
+class SomeType;
+
+template&lt; typename second&gt;
+using TypedefName = SomeType&lt;OtherType, second, 5&gt;;</PRE><P>
+Here we created a new wrapper TypedefName taking one template
+argument &lt;second&gt; which creates a type SomeType&lt;OtherType,
+second, 5&gt;. OtherType and 5 are predefined here and hidden from
+the user – the user only uses TypedefName type.</P>
+<P>The same goes for the following example:</P>
+<PRE>typedef void (*PFD)(double); // Old style
+using PF = void (*)(double); // New introduced syntax</PRE><P>
+Swig supports parsing typedefs for templates as well for example:</P>
+<PRE STYLE="margin-bottom: 0.5cm">typedef List&lt;int&gt; intList;</PRE><P>
+Done: Expanded support for the new 'using' syntax and template
+aliasing. Added testcase cpp11_template_typedefs. R11533</P>
+<P>TODO: Make Swig aware of the newly defined typedef. The TYPEDEF
+keyword is part of the storage_class rule and type+declarator (see
+c_decl rule) is the right part of the definition – for example void
+(*PFD)(double) cannot be transformed to void *(double) easily. To
+fully support the new 'using' form, we'll probably have to change the
+type, type_right rules and declarator, direct_declarator,
+notso_direct_declarator etc., which is PITA.</P>
+<H2>Unrestricted unions [done]</H2>
+<P>C++ currently offers usage of unions for types with trivial
+constructors only. The new C++11 standard allows usage of types with
+non-trivial constructors as well:</P>
+<PRE> struct point {
+ point() {}
+ point(int x, int y): x_(x), y_(y) {}
+ int x_, y_;
+ };
+ union P {
+ int z;
+ double w;
+ point p; // Illegal in C++; point has a non-trivial constructor. However, this is legal in C++11.
+ } p1;</PRE><P>
+Swig already parses the given syntax.</P>
+<P>Done: Added testcase cpp11_unrestricted_unions. R11435, R11447</P>
+<P>Problem: GCC doesn't support unrestricted unions yet so there is
+no way to actually test, if it works.</P>
+<H2>Variadic templates [partially done]</H2>
+<P>The new C++11 offers the following syntax:</P>
+<PRE STYLE="margin-bottom: 0.5cm">template&lt;typename... Values&gt; class tuple;</PRE><P>
+This can be used for example:</P>
+<PRE STYLE="margin-bottom: 0.5cm">class tuple&lt;int, std::vector&lt;int&gt;, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&gt; someInstanceName;</PRE><P>
+The ... is used in two cases. One is in the template header where it
+marks on the left the keywords 'typename' or 'class' and a type name
+on the right. The second case is usually in the function block to
+decompose typename on the left of the ... . For example:</P>
+<PRE>void printf(const char *s) {
+ while (*s) {
+ if (*s == '%' &amp;&amp; *(++s) != '%')
+ throw std::runtime_error(&quot;invalid format string: missing arguments&quot;);
+ std::cout &lt;&lt; *s++;
+ }
+}
+
+template&lt;typename T, typename... Args&gt;
+void printf(const char* s, T value, Args... args) { // recursive action – split previous args to value + args
+ while (*s) {
+ if (*s == '%' &amp;&amp; *(++s) != '%') {
+ std::cout &lt;&lt; value;
+ printf(*s ? ++s : s, args...); // call even when *s == 0 to detect extra arguments
+ return;
+ }
+ std::cout &lt;&lt; *s++;
+ }
+ throw std::logic_error(&quot;extra arguments provided to printf&quot;);
+}</PRE><P>
+The tricky part is that variadic templates can unpack actually
+anywhere – including the class inheritance :(</P>
+<PRE>template &lt;typename... BaseClasses&gt; class ClassName : public BaseClasses... {
+public:
+
+ ClassName (BaseClasses&amp;&amp;... baseClasses) : BaseClasses(baseClasses)... {}
+}</PRE><P>
+A new extension to sizeof is also introduced with this feature. The
+... after sizeof returns number of arguments:</P>
+<PRE>template&lt;typename ...Args&gt; struct SomeStruct {
+ static const int size = sizeof...(Args);
+}
+// SomeStruct&lt;Type1, Type2&gt;::size is 2 and SomeStruct&lt;&gt;::size is 0</PRE><P>
+Done: Added syntax support for 'typename' or 'class' + ... + id.
+Added testcase cpp11_variadic_templates. R11458</P>
+<P>Done: Added syntax support for BaseClass + ..., type + ... + id in
+parameters and baseclass + ... for intializers after constructor.
+Extended Swig syntax to support sizeof...(Args). R11467</P>
+<P>Done: Fixed %template to support variadic number of templates.</P>
+<P>TODO: Only (if present) first variadically defined argument is
+currently used in %template directive. The next ones are ignored.</P>
+<H2>New string literals [partially done]</H2>
+<P>Beside the implementation, the new C++11 Unicode and custom
+delimeter constants can occur in templates in the header file.
+</P>
+<P>Done: Added symbols 'u', 'u8' and 'U' to mark the beginning of the
+UTF string. Also added test case cpp11_raw_string_literals. R11327</P>
+<P>Done: Added R&quot;DELIMITER[, ]DELIMITER&quot; for a custom
+delimiter for the beginning/end of the string. R11328</P>
+<P>TODO: Fix the Swig's C++ preprocessor bug when parsing an odd
+number of “ inside the string brackets. See
+Source/Preprocessor/cpp.c.</P>
+<H2>User-defined literals [partially done]</H2>
+<P>C++ has different suffix literals. eg. 12.5f marks the number 12.5
+as float.
+</P>
+<P>C++11 allows user to define his own suffix for the strings always
+starting with the underscore (_). eg. int a = &quot;hello&quot;_mySuffix;
+</P>
+<P>The syntax is similar to other operator overloading functions:
+</P>
+<PRE STYLE="margin-bottom: 0.5cm"> OutputType operator &quot;&quot; _mySuffix(const char * string_values);</PRE><P>
+The null terminated const char* is the string between the &quot;&quot;.
+The _mySuffix is the name of the suffix operator. And the OutputType
+is the outputType the operator returns.
+</P>
+<P>Other forms are:
+</P>
+<PRE> OutputType operator &quot;&quot; _mySuffix(const char * string_values, size_t num_chars);
+ OutputType operator &quot;&quot; _mySuffix(const wchar_t * string_values, size_t num_chars);
+ OutputType operator &quot;&quot; _mySuffix(const char16_t * string_values, size_t num_chars);
+ OutputType operator &quot;&quot; _mySuffix(const char32_t * string_values, size_t num_chars);
+ OutputType operator &quot;&quot; _mySuffix(int value); /* cooked version - ie. atoi() of string */</PRE><P>
+Another possibility is to use variadic templates:
+</P>
+<PRE> template&lt;char...&gt; OutputType operator &quot;&quot; _mySuffix();
+ OutputType someVariable = &quot;1234&quot;_mySuffix;</PRE><P>
+This instantiates the literal processing function as
+operator&quot;&quot;_Suffix&lt;'1', '2', '3', '4'&gt;. In this form,
+there is no terminating null character to the string. The main
+purpose to doing this is to use C++11's constexpr keyword and the
+compiler to allow the literal to be transformed entirely at compile
+time, assuming OutputType is a constexpr-constructable and copyable
+type, and the literal processing function is a constexpr function.</P>
+<P>Article:
+<A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf</A></P>
+<P>Done: Added syntax support for userdefined literals. Added
+testcase cpp11_userdefined_literals.i. R11494</P>
+<P>TODO: %rename doesn't parse operator”” yet.</P>
+<H2>Thread-local storage [done]
+</H2>
+<P>New C++11 introduces keyword &quot;thread_local&quot; which marks
+the following variable dynamically located depending on the current
+thread when using the address-of (&amp;) operator.
+</P>
+<P>Syntax:
+</P>
+<PRE> struct A {
+ thread_local int val;
+ };</PRE><P>
+Done: Add &quot;thread_local&quot; keyword to Swig. Added testcase
+cpp11_thread_local. R11393</P>
+<H2>Defaulting/deleting of standard functions on C++ objects [done]</H2>
+<P>C++ automatically creates default constructor with empty
+parameters, copy constructor, operator= and destructor for any class.
+Sometimes user wants to explicitly remove one of them or enable them
+(eg. default constructor with empty parameters doesn't work any more,
+if any other constructor is defined).
+</P>
+<P>Words &quot;default&quot; and &quot;delete&quot; are introduced.
+The syntax is similar to declaration of pure virtual function:
+</P>
+<PRE> struct NonCopyable {
+ NonCopyable &amp; operator=(const NonCopyable&amp;) = delete; /* Removes operator= */
+ NonCopyable(const NonCopyable&amp;) = delete; /* Removed copy constructor */
+ NonCopyable() = default; /* Explicitly allows the empty constructor */
+ void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
+ };</PRE><P>
+User has the ability by using keyword delete to disallow calling of
+the standard functions brought by C++ itself.
+</P>
+<PRE> 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&lt;class T&gt; void f(T) = delete; /* Only accept int */
+ };</PRE><P>
+Ignored: Swig already parses the keywords &quot;= delete&quot; and &quot;=
+default&quot;. These keywords are used for built-in functions (copy
+constructor, operator= etc.), which are ignored by Swig anyway.</P>
+<P>Done: Added testcase cpp11_default_delete. R11535</P>
+<H2>Type long long int [done]</H2>
+<P>Type long long int is an integer type that has at least 64 useful
+bits. C99 added it to its standard, but the C++ didn't adopt it until
+C++11. Most C++ compilers supported it though.
+</P>
+<P>Done: Swig already parses the C code including the long long type.
+</P>
+<H2>Static assertions [done]</H2>
+<P>static_assert() can be used at class scope as well eg.:
+</P>
+<PRE> template &lt;typename T&gt;
+ struct Check {
+ static_assert(sizeof(int) &lt;= sizeof(T), &quot;not big enough&quot;);
+ };</PRE><P>
+Done: Added syntax support for &quot;static_assert()&quot;. Added
+test case cpp11_static_assert. R11369</P>
+<H2>Allow sizeof to work on members of classes without an explicit
+object [done]</H2>
+<P>C++11 allows calls of sizeof to concrete objects as well:
+</P>
+<PRE> struct A { int member; };
+ sizeof(A::member); //Does not work with C++03. Okay with C++11</PRE><P>
+This kind of syntax is already supported by Swig.</P>
+<P>Done: Added testcase cpp11_sizeof_objects. R11538
+</P>
+<H2>Threading facilities [ignored]</H2>
+<P>C++11 will add the following classes to the standard library:
+</P>
+<PRE> * std::thread
+ * std::mutex, std::recursive_mutex
+ * std::condition_variable, std::condition_variable_any
+ * std::lock_guard, std::unique_lock
+ * std::packaged_task</PRE><P>
+Ignored: No changes to the language itself is made.
+</P>
+<H2>Tuple types [TODO]</H2>
+<P>Tuple is array of various types. C++11 introduced this feature
+using variadic templates. Tuple is defined as:</P>
+<PRE STYLE="margin-bottom: 0.5cm">template &lt;class ...Types&gt; class tuple;</PRE><P>
+Constructor is automatically generated filling the tuple elements.
+get&lt;X&gt; function is introduced to get the Xth element in the
+tuple.</P>
+<PRE>typedef tuple&lt; int, double, long &amp;, const char * &gt; test_tuple ;
+long lengthy = 12 ;
+test_tuple proof( 18, 6.5, lengthy, &quot;Ciao!&quot; ) ;
+lengthy = get&lt;0&gt;(proof) ; // Assign to 'lengthy' the value 18.
+get&lt;3&gt;(proof) = &quot; Beautiful!&quot; ; // Modify the tuple’s fourth element.</PRE><P>
+Tuples can be copied to each other, if all the elements are copiable:</P>
+<PRE>typedef tuple&lt; int , double, string &gt; tuple_1 t1 ;
+typedef tuple&lt; char, short , const char * &gt; tuple_2 t2( 'X', 2, &quot;Hola!&quot; ) ;
+t1 = t2 ; // Ok, first two elements can be converted,
+ // the third one can be constructed from a 'const char *'.</PRE><P>
+TODO: Implement wrappers for the tuplet&lt;&gt; class.</P>
+<H2>Hash tables [TODO]</H2>
+<P>C++11 introduces the &quot;unordered&quot; version of existing
+types, which in practice work faster than the linear types:
+</P>
+<PRE> - unordered set
+ - unordered multiset
+ - unordered map
+ - unordered multimap</PRE><P>
+Swig should use the &quot;unordered&quot; types exactly the same as
+the original linear types.</P>
+<P>Problem: Unordered types do not contain exactly same members as
+ordered ones (eg. _Hashtable_iterator does not offer operator--() and
+constructor with compare function which is required). So simply
+aliasing unordered classes to ordered ones doesn't work.</P>
+<P>TODO: Implement wrappers for unordered_ types. Initial work is
+already done in Lib/std/unordered_*.i files.</P>
+<H2>Regular expressions [ignored]</H2>
+<P>Two new classes are introduced in C++11: basic_regex and
+match_results. Both are defined in regex header file.
+</P>
+<P>Ignored: The new feature extends the standardy library only. No
+changes to Swig needed.
+</P>
+<H2>General-purpose smart pointers [done]</H2>
+<P>This feature deprecates auto_ptr and adds shared_ptr, weak_ptr and
+unique_ptr to the standard library.
+</P>
+<P>This feature only adds the smart pointers to the standard library
+and doesn't effect the C++ syntax.</P>
+<P>Done: Added test case which uses all three smart pointers in the
+class. R11394</P>
+<P>Problem: GCC standard library doesn't contain the new smart
+pointers yet.
+</P>
+<H2>Extensible random number facility [ignored]</H2>
+<P>This feature standardize the pseudo random number algorithm
+(currently, the random number generator was dependent on the
+platform/compiler). It adds functions linear_congruential,
+subtract_with_carry and mersenne_twister and symbols
+uniform_int_distribution, bernoulli_distribution,
+geometric_distribution, poisson_distribution, binomial_distribution,
+uniform_real_distribution, exponential_distribution,
+normal_distribution and gamma_distribution to the standard library.
+</P>
+<P>Ignored: The new feature extends the standardy library only. No
+changes to Swig needed.
+</P>
+<H2>Wrapper reference [ignored]</H2>
+<P>This feature adds ref and cref classes to the standard library
+(#include &lt;utility&gt;) usually used in tempalte functions.
+</P>
+<P>Ignored: The new feature extends the standardy library only. No
+changes to Swig needed.
+</P>
+<H2>Polymorphous wrappers for function objects [done]</H2>
+<P>Two features are introduced:
+</P>
+<UL>
+ <LI><P>The function template wrapper:
+ </P>
+</UL>
+<PRE STYLE="margin-bottom: 0.5cm"> function&lt;int ( int, int )&gt; pF;</PRE>
+<UL>
+ <LI><P>and the function object:
+ </P>
+</UL>
+<PRE> struct Test {
+ bool operator()( short x, short y );
+ };</PRE><P>
+Swig already supports the two.</P>
+<P>Done: Added a runtime testcase for function objects
+cpp11_function_objects. R11419.</P>
+<H2>Type traits for metaprogramming [ignored]</H2>
+<P>C++11 adds a new header file &lt;type_traits&gt; which includes
+helper functions to determine the template type while initializing
+the object at compile time.
+</P>
+<P>Swig already supports the following code:
+</P>
+<PRE> template&lt; int B, int N &gt;
+ struct Pow {
+ // recursive call and recombination.
+ enum{ value = B*Pow&lt; B, N-1 &gt;::value };
+ };
+ template&lt; int B &gt; struct Pow&lt; B, 0 &gt; // <EM>N == 0</EM> condition of termination.
+ {
+ enum{ value = 1 };
+ };
+ int quartic_of_three = Pow&lt; 3, 4 &gt;::value ;</PRE><P>
+Functions is_convertible, is_integral, is_integral_const etc. are
+part of the new header:
+</P>
+<PRE>// First way of operating.
+template&lt; bool B &gt; struct algorithm {
+ template&lt; class T1, class T2 &gt; int do_it( T1 &amp;, T2 &amp; ) { /*...*/ }
+};
+// Second way of operating.
+template&lt;&gt; struct algorithm&lt;true&gt; {
+ template&lt; class T1, class T2 &gt; int do_it( T1, T2 ) { /*...*/ }
+};
+// Instantiating 'elaborate' will automatically instantiate the correct way to operate.
+template&lt; class T1, class T2 &gt; int elaborate( T1 A, T2 B ) {
+ // Use the second way only if 'T1' is an integer and if 'T2' is
+ // in floating point, otherwise use the first way.
+ return algorithm&lt; is_integral&lt;T1&gt;::value &amp;&amp; is_floating_point&lt;T2&gt;::value &gt;::do_it( A, B );
+}</PRE><P>
+Swig correctly parses the syntax for template&lt;bool&gt;,
+template&lt;class T&gt; and template&lt;&gt;.
+</P>
+<P>Ignored: Swig requires explicitly defined template class
+(%template directive) to export it to the target language.</P>
+<H2>Uniform method for computing return type of function objects
+[partially done]</H2>
+<P>The template function is introduced: std::result_of() which
+depends on decltype:
+</P>
+<PRE>template&lt; class Obj &gt;
+class calculus_ver2 {
+ public:
+ template&lt; class Arg &gt;
+ typename std::result_of&lt;Obj(Arg)&gt;::type operator()( Arg&amp; a ) const {
+ return member(a);
+ }
+ private:
+ Obj member;
+};</PRE><P>
+Swig correctly parses the result_of class.</P>
+<P>TODO: The return type (the result_of::type member) is not
+calculated by Swig. This needs a much more complex semantic parser.</P>
+<P>Done: Added testcase cpp11_result_of. R11534</P>
+</BODY>
+</HTML>
diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html
new file mode 100644
index 000000000..3caec748e
--- /dev/null
+++ b/Doc/Manual/CPlusPlus11.html
@@ -0,0 +1,942 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>SWIG and C++11</title>
+<link rel="stylesheet" type="text/css" href="style.css">
+</head>
+
+<body bgcolor="#ffffff">
+<H1><a name="CPlusPlus11"></a>7 SWIG and C++11</H1>
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="#CPlusPlus11_Introduction">Introduction</a>
+<li><a href="#CPlusPlus11_Core_language_changes">Core language changes</a>
+<ul>
+<li><a href="#CPlusPlus11_Rvalue_reference_and_move_semantics">Rvalue reference and move semantics</a>
+<li><a href="#CPlusPlus11_Generalized_constant_expressions">Generalized constant expressions</a>
+<li><a href="#CPlusPlus11_Extern_template">Extern template</a>
+<li><a href="#CPlusPlus11_Initializer_lists">Initializer lists</a>
+<li><a href="#CPlusPlus11_Uniform_initialization">Uniform initialization</a>
+<li><a href="#CPlusPlus11_Type_inference">Type inference</a>
+<li><a href="#CPlusPlus11_Range_based_for_loop">Range-based for-loop</a>
+<li><a href="#CPlusPlus11_Lambda_functions_and_expressions">Lambda functions and expressions</a>
+<li><a href="#CPlusPlus11_Alternate_function_syntax">Alternate function syntax</a>
+<li><a href="#CPlusPlus11_Object_construction_improvement">Object construction improvement</a>
+<li><a href="#CPlusPlus11_Null_pointer_constant">Null pointer constant</a>
+<li><a href="#CPlusPlus11_Strongly_typed_enumerations">Strongly typed enumerations</a>
+<li><a href="#CPlusPlus11_Double_angle_brackets">Double angle brackets</a>
+<li><a href="#CPlusPlus11_Explicit_conversion_operators">Explicit conversion operators</a>
+<li><a href="#CPlusPlus11_Alias_templates">Alias templates</a>
+<li><a href="#CPlusPlus11_Unrestricted_unions">Unrestricted unions</a>
+<li><a href="#CPlusPlus11_Variadic_templates">Variadic templates</a>
+<li><a href="#CPlusPlus11_New_string_literals">New string literals</a>
+<li><a href="#CPlusPlus11_User_defined_literals">User-defined literals</a>
+<li><a href="#CPlusPlus11_Thread_local_storage">Thread-local storage</a>
+<li><a href="#CPlusPlus11_Defaulting/deleting_of_standard_functions_on_C++_objects">Defaulting/deleting of standard functions on C++ objects</a>
+<li><a href="#CPlusPlus11_Type_long_long_int">Type long long int</a>
+<li><a href="#CPlusPlus11_Static_assertions">Static assertions</a>
+<li><a href="#CPlusPlus11_Allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object">Allow sizeof to work on members of classes without an explicit object</a>
+</ul>
+<li><a href="#CPlusPlus11_Standard_library_changes">Standard library changes</a>
+<ul>
+<li><a href="#CPlusPlus11_Threading_facilities">Threading facilities</a>
+<li><a href="#CPlusPlus11_Tuple_types">Tuple types and hash tables</a>
+<li><a href="#CPlusPlus11_Regular_expressions">Regular expressions</a>
+<li><a href="#CPlusPlus11_General_purpose_smart_pointers">General-purpose smart pointers</a>
+<li><a href="#CPlusPlus11_Extensible_random_number_facility">Extensible random number facility</a>
+<li><a href="#CPlusPlus11_Wrapper_reference">Wrapper reference</a>
+<li><a href="#CPlusPlus11_Polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
+<li><a href="#CPlusPlus11_Type_traits_for_metaprogramming">Type traits for metaprogramming</a>
+<li><a href="#CPlusPlus11_Uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
+</ul>
+</ul>
+</div>
+<!-- INDEX -->
+
+
+
+<H2><a name="CPlusPlus11_Introduction"></a>7.1 Introduction</H2>
+
+
+<p>This chapter gives you a brief overview about the SWIG
+implementation of the C++11 standard. This part of SWIG is still a work in
+progress. Initial C++11 support for SWIG was written during the
+Google Summer of Code 2009 period.</p>
+<p>SWIG supports all the new C++ syntax changes with some minor limitations
+(decltype expressions, variadic templates number). Wrappers for the
+new STL types (unordered_ containers, result_of, tuples) are not supported
+yet.</p>
+
+<H2><a name="CPlusPlus11_Core_language_changes"></a>7.2 Core language changes</H2>
+
+
+<H3><a name="CPlusPlus11_Rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
+
+
+<p>SWIG correctly parses the new operator &amp;&amp; the same as the reference operator &amp;.</p>
+
+<p>The wrapper for the following code is correctly produced:</p>
+<div class="code"><pre>
+class MyClass {
+ MyClass(MyClass&amp;&amp; p) : ptr(p.ptr) {p.ptr = 0;}
+ MyClass&amp; operator=(MyClass&amp;&amp; p) {
+ std::swap(ptr, p.ptr);
+ return *this;
+ }
+};
+</pre></div>
+
+<H3><a name="CPlusPlus11_Generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
+
+
+<p>SWIG correctly parses the keyword <tt>constexpr</tt>, but ignores its functionality. Constant functions cannot be used as constants.</p>
+
+<div class="code"><pre>
+constexpr int myConstFunc() { return 10; }
+const int a = myConstFunc(); // results in error
+</pre></div>
+
+<p>Users needs to use values or predefined constants when defining the new constant value:</p>
+
+<div class="code"><pre>
+#define MY_CONST 10
+constexpr int myConstFunc() { return MY_CONST; }
+const int a = MY_CONST; // ok
+</pre></div>
+
+<H3><a name="CPlusPlus11_Extern_template"></a>7.2.3 Extern template</H3>
+
+
+<p>SWIG correctly parses the keywords <tt>extern template</tt>. However, the explicit template instantiation is not used by SWIG, a <tt>%template</tt> is still required.</p>
+
+
+<div class="code"><pre>
+extern template class std::vector&lt;MyClass&gt;; // explicit instantiation
+
+...
+
+class MyClass {
+public:
+ int a;
+ int b;
+};
+</pre></div>
+
+<H3><a name="CPlusPlus11_Initializer_lists"></a>7.2.4 Initializer lists</H3>
+
+<p>
+Initializer lists are very much a C++ compiler construct and are not very accessible from wrappers as
+they are intended for compile time initialization of classes using the special <tt>std::initializer_list</tt> type.
+SWIG detects usage of initializer lists and will emit a special informative warning each time one is used:
+</p>
+
+<div class="shell">
+<pre>
+example.i:33: Warning 476: Initialization using std::initializer_list.
+</pre>
+</div>
+
+<p>
+Initializer lists usually appear in constructors but can appear in any function or method.
+They often appear in constructors which are overloaded with alternative approaches to initializing a class,
+such as the std container's push_back method for adding elements to a container.
+The recommended approach then is to simply ignore the initializer-list constructor, for example:
+</p>
+
+<div class="code"><pre>
+%ignore Container::Container(std::initializer_list&lt;int&gt;);
+class Container {
+public:
+ Container(std::initializer_list&lt;int&gt;); // initializer-list constructor
+ Container();
+ void push_back(const int &amp;);
+ ...
+};
+</pre></div>
+
+<p>Alternatively you could modify the class and add another constructor for initialization by some other means,
+for example by a <tt>std::vector</tt>:</p>
+
+<div class="code"><pre>
+%include &lt;std_vector.i&gt;
+class Container {
+public:
+ Container(const std::vector&lt;int&gt; &amp;);
+ Container(std::initializer_list&lt;int&gt;); // initializer-list constructor
+ Container();
+ void push_back(const int &amp;);
+ ...
+};
+</pre></div>
+
+<p>And then call this constructor from your target language, for example, in Python, the following will call the constructor taking the <tt>std::vector</tt>:</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; c = Container( [1,2,3,4] )
+</pre></div>
+
+<p>
+If you are unable to modify the class being wrapped, consider ignoring the initializer-list constructor and using
+%extend to add in an alternative constructor:
+</p>
+
+<div class="code"><pre>
+%include &lt;std_vector.i&gt;
+%extend Container {
+ Container(const std::vector&lt;int&gt; &amp;elements) {
+ Container *c = new Container();
+ for (int element : elements)
+ c-&gt;push_back(element);
+ return c;
+ }
+}
+
+%ignore Container::Container(std::initializer_list&lt;int&gt;);
+
+class Container {
+public:
+ Container(std::initializer_list&lt;int&gt;); // initializer-list constructor
+ Container();
+ void push_back(const int &amp;);
+ ...
+};
+</pre></div>
+
+<p>
+The above makes the wrappers look is as if the class had been declared as follows:
+</p>
+
+<div class="code"><pre>
+%include &lt;std_vector.i&gt;
+class Container {
+public:
+ Container(const std::vector&lt;int&gt; &amp;);
+// Container(std::initializer_list&lt;int&gt;); // initializer-list constructor (ignored)
+ Container();
+ void push_back(const int &amp;);
+ ...
+};
+</pre></div>
+
+<p>
+<tt>std::initializer_list</tt> is simply a container that can only be initialized at compile time.
+As it is just a C++ type, it is possible to write typemaps for a target language container to map onto
+<tt>std::initializer_list</tt>. However, this can only be done for a fixed number of elements as
+initializer lists are not designed to be constructed with a variable number of arguments at runtime.
+The example below is a very simple approach which ignores any parameters passed in and merely initializes
+with a fixed list of fixed integer values chosen at compile time:
+</p>
+
+<div class="code"><pre>
+%typemap(in) std::initializer_list&lt;int&gt; {
+ $1 = {10, 20, 30, 40, 50};
+}
+class Container {
+public:
+ Container(std::initializer_list&lt;int&gt;); // initializer-list constructor
+ Container();
+ void push_back(const int &amp;);
+ ...
+};
+</pre></div>
+
+<p>
+Any attempt at passing in values from the target language will be ignored and replaced by <tt>{10, 20, 30, 40, 50}</tt>.
+Needless to say, this approach is very limited, but could be improved upon, but only slightly.
+A typemap could be written to map a fixed number of elements on to the <tt>std::initializer_list</tt>,
+but with values decided at runtime.
+The typemaps would be target language specific.
+</p>
+
+<p>
+Note that the default typemap for <tt>std::initializer_list</tt> does nothing but issue the warning
+and hence any user supplied typemaps will override it and suppress the warning.
+</p>
+
+<H3><a name="CPlusPlus11_Uniform_initialization"></a>7.2.5 Uniform initialization</H3>
+
+
+<p>The curly brackets {} for member initialization are fully
+supported by SWIG:</p>
+
+<div class="code"><pre>
+struct BasicStruct {
+ int x;
+ double y;
+};
+
+struct AltStruct {
+ AltStruct(int x, double y) : x_{x}, y_{y} {}
+
+ int x_;
+ double y_;
+};
+
+BasicStruct var1{5, 3.2}; // only fills the struct components
+AltStruct var2{2, 4.3}; // calls the constructor
+</pre></div>
+
+<p>Uniform initialization does not affect usage from the target language, for example in Python:</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; a = AltStruct(10, 142.15)
+&gt;&gt;&gt; a.x_
+10
+&gt;&gt;&gt; a.y_
+142.15
+</pre></div>
+
+<H3><a name="CPlusPlus11_Type_inference"></a>7.2.6 Type inference</H3>
+
+
+<p>SWIG supports <tt>decltype()</tt> with some limitations. Single
+variables are allowed, however, expressions are not supported yet. For
+example, the following code will work:</p>
+<div class="code"><pre>
+int i;
+decltype(i) j;
+</pre></div>
+
+<p>However, using an expression inside the decltype results in syntax error:</p>
+<div class="code"><pre>
+int i; int j;
+decltype(i+j) k; // syntax error
+</pre></div>
+
+<H3><a name="CPlusPlus11_Range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
+
+
+<p>This feature is part of the implementation block only. SWIG
+ignores it.</p>
+
+<H3><a name="CPlusPlus11_Lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
+
+
+<p>SWIG correctly parses most of the Lambda functions syntax. For example:</p>
+<div class="code"><pre>
+auto val = [] { return something; };
+auto sum = [](int x, int y) { return x+y; };
+auto sum = [](int x, int y) -&gt; int { return x+y; };
+</pre></div>
+
+<p>The lambda functions are removed from the wrappers for now, because of the lack of support
+for closures (scope of the lambda functions) in the target languages.</p>
+
+<p>
+Lambda functions used to create variables can also be parsed, but due to limited support of <tt>auto</tt> when
+the type is deduced from the expression, the variables are simply ignored.
+</p>
+
+<div class="code"><pre>
+auto six = [](int x, int y) { return x+y; }(4, 2);
+</pre></div>
+
+<p>
+Better support should be available in a later release.
+</p>
+
+<H3><a name="CPlusPlus11_Alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
+
+
+<p>SWIG fully supports the new definition of functions. For example:</p>
+<div class="code"><pre>
+struct SomeStruct {
+ int FuncName(int x, int y);
+};
+</pre></div>
+
+<p>can now be written as in C++11:</p>
+
+<div class="code"><pre>
+struct SomeStruct {
+ auto FuncName(int x, int y) -&gt; int;
+};
+
+auto SomeStruct::FuncName(int x, int y) -&gt; int {
+ return x + y;
+}
+</pre></div>
+
+<p>The usage in the target languages remains the same, for example in Python:</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; a = SomeStruct()
+&gt;&gt;&gt; a.FuncName(10,5)
+15
+</pre></div>
+
+<p>SWIG will also deal with type inference for the return type, as per the limitations described earlier. For example:</p>
+<div class="code"><pre>
+auto square(float a, float b) -&gt; decltype(a);
+</pre></div>
+
+<H3><a name="CPlusPlus11_Object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
+
+
+<p>
+SWIG is able to handle constructor delegation, such as:
+</p>
+
+<div class="code"><pre>
+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; }
+};
+</pre></div>
+
+<p>
+Constructor inheritance is parsed correctly, but the additional constructors are not currently added to the derived proxy class in the target language. Example is shown below:
+<!--
+The extra constructors provided by the <tt>using</tt> syntax will add the appropriate constructors into the target language proxy derived classes.
+In the example below a wrapper for the <tt>DerivedClass(int)</tt> is added to <tt>DerivedClass</tt>:
+-->
+</p>
+
+<div class="code"><pre>
+class BaseClass {
+public:
+ BaseClass(int iValue);
+};
+
+class DerivedClass: public BaseClass {
+ public:
+ using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
+};
+</pre></div>
+
+<H3><a name="CPlusPlus11_Null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
+
+
+<p>The <tt>nullptr</tt> constant is largely unimportant in wrappers. In the few places it has an effect, it is treated like <tt>NULL</tt>.</p>
+
+<H3><a name="CPlusPlus11_Strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>
+
+
+<p>SWIG parses the new <tt>enum class</tt> syntax and forward declarator for the enums:</p>
+<div class="code"><pre>
+enum class MyEnum : unsigned int;
+</pre></div>
+
+<p>The strongly typed enumerations are treated the same as the ordinary and anonymous enums.
+This is because SWIG doesn't support nested classes. This is usually not a problem, however,
+there may be some name clashes. For example, the following code:</p>
+
+<div class="code"><pre>
+class Color {
+ enum class PrintingColors : unsigned int {
+ Cyan, Magenta, Yellow, Black
+ };
+
+ enum class BasicColors {
+ Red, Green, Blue
+ };
+
+ enum class AllColors {
+ // produces warnings because of duplicate names
+ Yellow, Orange, Red, Magenta, Blue, Cyan, Green, Pink, Black, White
+ };
+};
+</pre></div>
+
+<p>A workaround is to write these as a series of separated classes containing anonymous enums:</p>
+
+<div class="code"><pre>
+class PrintingColors {
+ enum : unsigned int {
+ Cyan, Magenta, Yellow, Black
+ };
+};
+
+class BasicColors {
+ enum : unsigned int {
+ Red, Green, Blue
+ };
+};
+
+class AllColors {
+ enum : unsigned int {
+ Yellow, Orange, Red, Magenta, Blue, Cyan, Green, Pink, Black, White
+ };
+};
+</pre></div>
+
+<H3><a name="CPlusPlus11_Double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
+
+
+<p>SWIG correctly parses the symbols &gt;&gt; as closing the
+template block, if found inside it at the top level, or as the right
+shift operator &gt;&gt; otherwise.</p>
+
+<div class="code"><pre>
+std::vector&lt;std::vector&lt;int&gt;&gt; myIntTable;
+</pre></div>
+
+<H3><a name="CPlusPlus11_Explicit_conversion_operators"></a>7.2.14 Explicit conversion operators</H3>
+
+
+<p>SWIG correctly parses the keyword <tt>explicit</tt> both for operators and constructors.
+For example:</p>
+
+<div class="code"><pre>
+class U {
+public:
+ int u;
+};
+
+class V {
+public:
+ int v;
+};
+
+class TestClass {
+public:
+ //implicit converting constructor
+ TestClass( U const &amp;val ) { t=val.u; }
+ // explicit constructor
+ explicit TestClass( V const &amp;val ) { t=val.v; }
+
+ int t;
+};
+</pre></div>
+
+<p>
+The usage of explicit constructors and operators is somehow specific to C++ when assigning the value
+of one object to another one of different type or translating one type to another. It requires both operator and function overloading features,
+which are not supported by the majority of SWIG target languages. Also the constructors and operators are not particulary useful in any
+SWIG target languages, because all use their own facilities (eg. classes Cloneable and Comparable in Java)
+to achieve particular copy and compare behaviours.
+</p>
+
+<H3><a name="CPlusPlus11_Alias_templates"></a>7.2.15 Alias templates</H3>
+
+<p>
+The following is an example of an alias template:
+
+<div class="code"><pre>
+template&lt; typename T1, typename T2, int &gt;
+class SomeType {
+ T1 a;
+ T2 b;
+ int c;
+};
+
+template&lt; typename T2 &gt;
+using TypedefName = SomeType&lt;char*, T2, 5&gt;;
+</pre></div>
+
+<p>
+These are partially supported as SWIG will parse these and identify them, however, they are ignored as they are not added to the type system. A warning such as the following is issued:
+</p>
+
+<div class="shell">
+<pre>
+example.i:13: Warning 342: The 'using' keyword in template aliasing is not fully supported yet.
+</pre>
+</div>
+
+<p>
+Similarly for non-template type aliasing:
+</p>
+
+<div class="code"><pre>
+using PFD = void (*)(double); // New introduced syntax
+</pre></div>
+
+<p>
+A warning will be issued:
+</p>
+
+<div class="shell">
+<pre>
+example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
+</pre>
+</div>
+
+
+<p>The equivalent old style typedefs can be used as a workaround:</p>
+
+<div class="code"><pre>
+typedef void (*PFD)(double); // The old style
+</pre></div>
+
+<H3><a name="CPlusPlus11_Unrestricted_unions"></a>7.2.16 Unrestricted unions</H3>
+
+
+<p>SWIG fully supports any type inside a union even if it does not
+define a trivial constructor. For example, the wrapper for the following
+code correctly provides access to all members in the union:</p>
+
+<div class="code"><pre>
+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(&amp;p) point();
+ }
+} p1;
+</pre></div>
+
+<H3><a name="CPlusPlus11_Variadic_templates"></a>7.2.17 Variadic templates</H3>
+
+
+<p>SWIG supports the variadic templates syntax (inside the &lt;&gt;
+block, variadic class inheritance and variadic constructor and
+initializers) with some limitations. The following code is correctly parsed:</p>
+
+<div class="code"><pre>
+template &lt;typename... BaseClasses&gt; class ClassName : public BaseClasses... {
+public:
+ ClassName (BaseClasses&amp;&amp;... baseClasses) : BaseClasses(baseClasses)... {}
+}
+</pre></div>
+
+<p>
+For now however, the <tt>%template</tt> directive only accepts one parameter substitution
+for the variable template parameters.
+</p>
+
+<div class="code"><pre>
+%template(MyVariant1) ClassName&lt;&gt; // zero argument not supported yet
+%template(MyVariant2) ClassName&lt;int&gt; // ok
+%template(MyVariant3) ClassName&lt;int, int&gt; // too many arguments not supported yet
+</pre></div>
+
+<p>Support for the variadic <tt>sizeof()</tt> function is correctly parsed:</p>
+
+<div class="code"><pre>
+const int SIZE = sizeof...(ClassName&lt;int, int&gt;);
+</pre></div>
+
+<p>
+In the above example <tt>SIZE</tt> is of course wrapped as a constant.
+</p>
+
+<H3><a name="CPlusPlus11_New_string_literals"></a>7.2.18 New string literals</H3>
+
+
+<p>SWIG supports unicode string constants and raw string literals.</p>
+
+<div class="code"><pre>
+// 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
+const char *xx = ")I'm an \"ascii\" \\ string.";
+const char *ee = R"XXX()I'm an "ascii" \ string.)XXX"; // same as xx
+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";
+</pre></div>
+
+<p>Note: SWIG currently incorrectly parses the odd number of double quotes
+inside the string due to SWIG's C++ preprocessor.</p>
+
+<H3><a name="CPlusPlus11_User_defined_literals"></a>7.2.19 User-defined literals</H3>
+
+
+<p>
+SWIG parses the declaration of user-defined literals, that is, the <tt>operator "" _mysuffix()</tt> function syntax.
+</p>
+
+<p>
+Some examples are the raw literal:
+</p>
+<div class="code"><pre>
+OutputType operator "" _myRawLiteral(const char * value);
+</pre></div>
+
+<p>
+numeric cooked literals:
+</p>
+<div class="code"><pre>
+OutputType operator "" _mySuffixIntegral(unsigned long long);
+OutputType operator "" _mySuffixFloat(long double);
+</pre></div>
+
+<p>
+and cooked string literals:
+</p>
+<div class="code"><pre>
+OutputType operator "" _mySuffix(const char * string_values, size_t num_chars);
+OutputType operator "" _mySuffix(const wchar_t * string_values, size_t num_chars);
+OutputType operator "" _mySuffix(const char16_t * string_values, size_t num_chars);
+OutputType operator "" _mySuffix(const char32_t * string_values, size_t num_chars);
+</pre></div>
+
+<p>
+Like other operators that SWIG parses, a warning is given about renaming the operator in order for it to be wrapped:
+</p>
+
+<div class="shell"><pre>
+example.i:27: Warning 503: Can't wrap 'operator "" _myRawLiteral' unless renamed to a valid identifier.
+</pre></div>
+
+<p>
+If %rename is used, then it can be called like any other wrapped method.
+Currently you need to specify the full declaration including parameters for %rename:
+</p>
+
+<div class="code"><pre>
+%rename(MyRawLiteral) operator"" _myRawLiteral(const char * value);
+</pre></div>
+
+<p>
+Or if you just wish to ignore it altogether:
+</p>
+
+<div class="code"><pre>
+%ignore operator "" _myRawLiteral(const char * value);
+</pre></div>
+
+<p>
+Note that use of user-defined literals such as the following still give a syntax error:
+</p>
+
+<div class="code"><pre>
+OutputType var1 = "1234"_suffix;
+OutputType var2 = 1234_suffix;
+OutputType var3 = 3.1416_suffix;
+</pre></div>
+
+<H3><a name="CPlusPlus11_Thread_local_storage"></a>7.2.20 Thread-local storage</H3>
+
+
+<p>SWIG correctly parses the <tt>thread_local</tt> keyword. For example, variable
+reachable by the current thread can be defined as:</p>
+
+<div class="code"><pre>
+struct A {
+ static thread_local int val;
+};
+thread_local int global_val;
+</pre></div>
+
+<p>
+The use of the <tt>thread_local</tt> storage specifier does not affect the wrapping process; it does not modify
+the wrapper code compared to when it is not specified.
+A variable will be thread local if accessed from different threads from the target language in the
+same way that it will be thread local if accessed from C++ code.
+</p>
+
+<H3><a name="CPlusPlus11_Defaulting/deleting_of_standard_functions_on_C++_objects"></a>7.2.21 Defaulting/deleting of standard functions on C++ objects</H3>
+
+
+<p>SWIG correctly parses the <tt>= delete</tt> and <tt>= default</tt>
+keywords. For example:</p>
+
+<div class="code"><pre>
+struct NonCopyable {
+ NonCopyable&amp; operator=(const NonCopyable&amp;) = delete; /* Removes operator= */
+ NonCopyable(const NonCopyable&amp;) = delete; /* Removed copy constructor */
+ NonCopyable() = default; /* Explicitly allows the empty constructor */
+ void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
+};
+</pre></div>
+
+<p>This feature is specific to C++ only. The defaulting/deleting is currently ignored, because SWIG
+automatically produces wrappers for special constructors and operators specific to the target language.</p>
+
+<H3><a name="CPlusPlus11_Type_long_long_int"></a>7.2.22 Type long long int</H3>
+
+
+<p>SWIG correctly parses and uses the new <tt>long long</tt> type already introduced in C99 some time ago.</p>
+
+<H3><a name="CPlusPlus11_Static_assertions"></a>7.2.23 Static assertions</H3>
+
+
+<p>SWIG correctly parses and calls the new <tt>static_assert</tt> function.</p>
+
+<div class="code"><pre>
+template &lt;typename T&gt;
+struct Check {
+ static_assert(sizeof(int) &lt;= sizeof(T), "not big enough");
+};
+</pre></div>
+
+<H3><a name="CPlusPlus11_Allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object"></a>7.2.24 Allow sizeof to work on members of classes without an explicit object</H3>
+
+
+<p>SWIG correctly calls the sizeof() on types as well as on the
+objects. For example:</p>
+
+<div class="code"><pre>
+struct A {
+ int member;
+};
+
+const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11
+</pre></div>
+
+<p>In Python:</p>
+<div class="targetlang"><pre>
+&gt;&gt;&gt; SIZE
+8
+</pre></div>
+
+<H2><a name="CPlusPlus11_Standard_library_changes"></a>7.3 Standard library changes</H2>
+
+
+<H3><a name="CPlusPlus11_Threading_facilities"></a>7.3.1 Threading facilities</H3>
+
+
+<p>SWIG does not currently wrap or use any of the new threading
+classes introduced (thread, mutex, locks, condition variables, task). The main reason is that
+SWIG target languages offer their own threading facilities that do not rely on C++.</p>
+
+<H3><a name="CPlusPlus11_Tuple_types"></a>7.3.2 Tuple types and hash tables</H3>
+
+
+<p>SWIG does not wrap the new tuple types and the unordered_ container classes yet. Variadic template support is working so it is possible to
+include the tuple header file; it is parsed without any problems.</p>
+
+<H3><a name="CPlusPlus11_Regular_expressions"></a>7.3.3 Regular expressions</H3>
+
+
+<p>SWIG does not wrap the new C++11 regular expressions classes, because the SWIG target languages use their own facilities for this.</p>
+
+<H3><a name="CPlusPlus11_General_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
+
+
+<p>
+SWIG provides special smart pointer handling for <tt>std::tr1::shared_ptr</tt> in the same way it has support for <tt>boost::shared_ptr</tt>.
+There is no special smart pointer handling available for <tt>std::weak_ptr</tt> and <tt>std::unique_ptr</tt>.
+</p>
+
+<H3><a name="CPlusPlus11_Extensible_random_number_facility"></a>7.3.5 Extensible random number facility</H3>
+
+
+<p>This feature extends and standardizes the standard library only and does not effect the C++ language and SWIG.</p>
+
+<H3><a name="CPlusPlus11_Wrapper_reference"></a>7.3.6 Wrapper reference</H3>
+
+
+<p>The new ref and cref classes are used to instantiate a parameter as a reference of a template function. For example:</p>
+
+<div class="code"><pre>
+void f( int &amp;r ) { r++; }
+
+// Template function.
+template&lt; class F, class P &gt; void g( F f, P t ) { f(t); }
+
+int main() {
+ int i = 0 ;
+ g( f, i ) ; // 'g&lt;void ( int &amp;r ), int&gt;' is instantiated
+ // then 'i' will not be modified.
+ cout &lt;&lt; i &lt;&lt; endl ; // Output -&gt; 0
+
+ g( f, ref(i) ) ; // 'g&lt;void(int &amp;r),reference_wrapper&lt;int&gt;&gt;' is instantiated
+ // then 'i' will be modified.
+ cout &lt;&lt; i &lt;&lt; endl ; // Output -&gt; 1
+}
+</pre></div>
+
+<p>The ref and cref classes are not wrapped by SWIG because the SWIG target languages do not support referencing.</p>
+
+<H3><a name="CPlusPlus11_Polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
+
+
+<p>
+SWIG supports functor classes in some languages in a very natural way.
+However nothing is provided yet for the new <tt>std::function</tt> template.
+SWIG will parse usage of the template like any other template.
+</p>
+
+<div class="code"><pre>
+%rename(__call__) Test::operator(); // Default renaming used for Python
+
+struct Test {
+ bool operator()(int x, int y); // function object
+};
+
+#include &lt;functional&gt;
+std::function&lt;void (int, int)&gt; pF = Test; // function template wrapper
+
+</pre></div>
+
+<p>
+Example of supported usage of the plain functor from Python is shown below.
+It does not involve <tt>std::function</tt>.
+</p>
+
+<div class="targetlang">
+t = Test()
+b = t(1,2) # invoke C++ function object
+</pre></div>
+
+<H3><a name="CPlusPlus11_Type_traits_for_metaprogramming"></a>7.3.8 Type traits for metaprogramming</H3>
+
+
+<p>The new C++ metaprogramming is useful at compile time and is aimed specifically for C++ development:</p>
+
+<div class="code"><pre>
+// First way of operating.
+template&lt; bool B &gt; struct algorithm {
+ template&lt; class T1, class T2 &gt; int do_it( T1&amp;, T2&amp; ) { /*...*/ }
+};
+// Second way of operating.
+template&lt;&gt; struct algorithm&lt;true&gt; {
+ template&lt; class T1, class T2 &gt; int do_it( T1, T2 ) { /*...*/ }
+};
+// Instantiating 'elaborate' will automatically instantiate the correct way to operate.
+template&lt; class T1, class T2 &gt; int elaborate( T1 A, T2 B ) {
+ // Use the second way only if 'T1' is an integer and if 'T2' is
+ // in floating point, otherwise use the first way.
+ return algorithm&lt; is_integral&lt;T1&gt;::value &amp;&amp; is_floating_point&lt;T2&gt;::value &gt;::do_it( A, B );
+}
+</pre></div>
+
+<p>SWIG correctly parses the template specialization, template types and values inside the &lt;&gt; block and the new helper functions: is_convertible, is_integral, is_const etc.
+However, SWIG still explicitly requires concrete types when using the <tt>%template</tt> directive, so the C++ metaprogramming features are not really of interest at runtime in the target languages.</p>
+
+<H3><a name="CPlusPlus11_Uniform_method_for_computing_return_type_of_function_objects"></a>7.3.9 Uniform method for computing return type of function objects</H3>
+
+
+<p>SWIG does not wrap the new result_of class introduced in the &lt;functional&gt; header and map the result_of::type to the concrete type yet. For example:</p>
+<div class="code"><pre>
+%inline %{
+#include &lt;functional&gt;
+double square(double x) {
+ return (x * x);
+}
+
+template&lt;class Fun, class Arg&gt;
+typename std::result_of&lt;Fun(Arg)&gt;::type test_result_impl(Fun fun, Arg arg) {
+ return fun(arg);
+}
+%}
+
+%template(test_result) test_result_impl&lt;double(*)(double), double&gt;;
+%constant double (*SQUARE)(double) = square;
+</pre></div>
+
+<p>will result in:</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; test_result_impl(SQUARE, 5.0)
+&lt;SWIG Object of type 'std::result_of&lt; Fun(Arg) &gt;::type *' at 0x7faf99ed8a50&gt;
+</pre></div>
+
+<p>Instead, please use <tt>decltype()</tt> where possible for now.</p>
+</body>
+</html>
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index cf4c38d7e..aac415952 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -498,6 +498,7 @@ example.i(4) : Syntax error in input.
<li>471. Unable to use return type <em>type</em> in director method
<li>474. Method <em>method</em> usage of the optimal attribute ignored in the out typemap as the following cannot be used to generate optimal code: <em>code</em>
<li>475. Multiple calls to <em>method</em> might be generated due to optimal attribute usage in the out typemap.
+<li>476. Initialization using std::initializer_list.
</ul>
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 40e227164..45d35e793 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -4,6 +4,7 @@ Windows.html
Scripting.html
SWIG.html
SWIGPlus.html
+CPlusPlus11.html
Preprocessor.html
Library.html
Arguments.html
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index e9b70f961..b986774b6 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -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
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 381a49f7b..0f3f82629 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -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
diff --git a/Examples/test-suite/cpp11_alternate_function_syntax.i b/Examples/test-suite/cpp11_alternate_function_syntax.i
new file mode 100644
index 000000000..227a1c8c8
--- /dev/null
+++ b/Examples/test-suite/cpp11_alternate_function_syntax.i
@@ -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;
+}
+%}
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
new file mode 100644
index 000000000..95fe5fa2b
--- /dev/null
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -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; }
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_decltype.i b/Examples/test-suite/cpp11_decltype.i
new file mode 100644
index 000000000..deedd5953
--- /dev/null
+++ b/Examples/test-suite/cpp11_decltype.i
@@ -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;
+ }
+ };
+ %}
diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i
new file mode 100644
index 000000000..be4cc6cc9
--- /dev/null
+++ b/Examples/test-suite/cpp11_default_delete.i
@@ -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 */
+};
+%}
diff --git a/Examples/test-suite/cpp11_delegating_constructors.i b/Examples/test-suite/cpp11_delegating_constructors.i
new file mode 100644
index 000000000..ca5aa326e
--- /dev/null
+++ b/Examples/test-suite/cpp11_delegating_constructors.i
@@ -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; }
+};
+%}
diff --git a/Examples/test-suite/cpp11_explicit_conversion_operators.i b/Examples/test-suite/cpp11_explicit_conversion_operators.i
new file mode 100644
index 000000000..5e3ba03df
--- /dev/null
+++ b/Examples/test-suite/cpp11_explicit_conversion_operators.i
@@ -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;
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_function_objects.i b/Examples/test-suite/cpp11_function_objects.i
new file mode 100644
index 000000000..fb75edea6
--- /dev/null
+++ b/Examples/test-suite/cpp11_function_objects.i
@@ -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;
+}
+
+%}
+
diff --git a/Examples/test-suite/cpp11_hash_tables.i b/Examples/test-suite/cpp11_hash_tables.i
new file mode 100644
index 000000000..4f68cbac5
--- /dev/null
+++ b/Examples/test-suite/cpp11_hash_tables.i
@@ -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;
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_inheriting_constructors.i b/Examples/test-suite/cpp11_inheriting_constructors.i
new file mode 100644
index 000000000..e1adb4caa
--- /dev/null
+++ b/Examples/test-suite/cpp11_inheriting_constructors.i
@@ -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
+};
+%}
diff --git a/Examples/test-suite/cpp11_initializer_list.i b/Examples/test-suite/cpp11_initializer_list.i
new file mode 100644
index 000000000..58d2ecc50
--- /dev/null
+++ b/Examples/test-suite/cpp11_initializer_list.i
@@ -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() {}
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_initializer_list_extend.i b/Examples/test-suite/cpp11_initializer_list_extend.i
new file mode 100644
index 000000000..02ad1312e
--- /dev/null
+++ b/Examples/test-suite/cpp11_initializer_list_extend.i
@@ -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&) {}
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i
new file mode 100644
index 000000000..87c7196d8
--- /dev/null
+++ b/Examples/test-suite/cpp11_lambda_functions.i
@@ -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; })());
+%}
+
diff --git a/Examples/test-suite/cpp11_null_pointer_constant.i b/Examples/test-suite/cpp11_null_pointer_constant.i
new file mode 100644
index 000000000..0b3276a44
--- /dev/null
+++ b/Examples/test-suite/cpp11_null_pointer_constant.i
@@ -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) {}
+};
+%}
diff --git a/Examples/test-suite/cpp11_raw_string_literals.i b/Examples/test-suite/cpp11_raw_string_literals.i
new file mode 100644
index 000000000..6fd13a0d0
--- /dev/null
+++ b/Examples/test-suite/cpp11_raw_string_literals.i
@@ -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";
+%}
+
diff --git a/Examples/test-suite/cpp11_result_of.i b/Examples/test-suite/cpp11_result_of.i
new file mode 100644
index 000000000..6d98ec0c0
--- /dev/null
+++ b/Examples/test-suite/cpp11_result_of.i
@@ -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;
diff --git a/Examples/test-suite/cpp11_rvalue_reference.i b/Examples/test-suite/cpp11_rvalue_reference.i
new file mode 100644
index 000000000..45ee06354
--- /dev/null
+++ b/Examples/test-suite/cpp11_rvalue_reference.i
@@ -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;
+};
+%}
diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i
new file mode 100644
index 000000000..4ef871c63
--- /dev/null
+++ b/Examples/test-suite/cpp11_rvalue_reference2.i
@@ -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>;
+
+
diff --git a/Examples/test-suite/cpp11_rvalue_reference3.i b/Examples/test-suite/cpp11_rvalue_reference3.i
new file mode 100644
index 000000000..c65309945
--- /dev/null
+++ b/Examples/test-suite/cpp11_rvalue_reference3.i
@@ -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) {}
+};
+%}
diff --git a/Examples/test-suite/cpp11_sizeof_object.i b/Examples/test-suite/cpp11_sizeof_object.i
new file mode 100644
index 000000000..fca8a8ccc
--- /dev/null
+++ b/Examples/test-suite/cpp11_sizeof_object.i
@@ -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);
+%}
diff --git a/Examples/test-suite/cpp11_static_assert.i b/Examples/test-suite/cpp11_static_assert.i
new file mode 100644
index 000000000..8d616f96c
--- /dev/null
+++ b/Examples/test-suite/cpp11_static_assert.i
@@ -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");
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_strongly_typed_enumerations.i b/Examples/test-suite/cpp11_strongly_typed_enumerations.i
new file mode 100644
index 000000000..ed466369e
--- /dev/null
+++ b/Examples/test-suite/cpp11_strongly_typed_enumerations.i
@@ -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;
+};
+*/
+%}
+
diff --git a/Examples/test-suite/cpp11_template_double_brackets.i b/Examples/test-suite/cpp11_template_double_brackets.i
new file mode 100644
index 000000000..15fe4903b
--- /dev/null
+++ b/Examples/test-suite/cpp11_template_double_brackets.i
@@ -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 &);
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_template_explicit.i b/Examples/test-suite/cpp11_template_explicit.i
new file mode 100644
index 000000000..80a30d283
--- /dev/null
+++ b/Examples/test-suite/cpp11_template_explicit.i
@@ -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*>;
+%}
+
diff --git a/Examples/test-suite/cpp11_template_typedefs.i b/Examples/test-suite/cpp11_template_typedefs.i
new file mode 100644
index 000000000..ea46706a9
--- /dev/null
+++ b/Examples/test-suite/cpp11_template_typedefs.i
@@ -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
+%}
+
diff --git a/Examples/test-suite/cpp11_thread_local.i b/Examples/test-suite/cpp11_thread_local.i
new file mode 100644
index 000000000..6a1019824
--- /dev/null
+++ b/Examples/test-suite/cpp11_thread_local.i
@@ -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;
+%}
diff --git a/Examples/test-suite/cpp11_uniform_initialization.i b/Examples/test-suite/cpp11_uniform_initialization.i
new file mode 100644
index 000000000..07fb81280
--- /dev/null
+++ b/Examples/test-suite/cpp11_uniform_initialization.i
@@ -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} };
+%}
+
diff --git a/Examples/test-suite/cpp11_unrestricted_unions.i b/Examples/test-suite/cpp11_unrestricted_unions.i
new file mode 100644
index 000000000..5facaafe1
--- /dev/null
+++ b/Examples/test-suite/cpp11_unrestricted_unions.i
@@ -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;
+%}
+
diff --git a/Examples/test-suite/cpp11_userdefined_literals.i b/Examples/test-suite/cpp11_userdefined_literals.i
new file mode 100644
index 000000000..43103cc8c
--- /dev/null
+++ b/Examples/test-suite/cpp11_userdefined_literals.i
@@ -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;
+%}
+
diff --git a/Examples/test-suite/cpp11_variadic_templates.i b/Examples/test-suite/cpp11_variadic_templates.i
new file mode 100644
index 000000000..15ab4eece
--- /dev/null
+++ b/Examples/test-suite/cpp11_variadic_templates.i
@@ -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>;
+
diff --git a/Examples/test-suite/csharp_features.i b/Examples/test-suite/csharp_features.i
index 578a56a10..f77e3fc9c 100644
--- a/Examples/test-suite/csharp_features.i
+++ b/Examples/test-suite/csharp_features.i
@@ -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'){}
};
%}
diff --git a/Examples/test-suite/java/cpp11_lambda_functions_runme.java b/Examples/test-suite/java/cpp11_lambda_functions_runme.java
new file mode 100644
index 000000000..a0d310c7c
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_lambda_functions_runme.java
@@ -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);
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_thread_local_runme.java b/Examples/test-suite/java/cpp11_thread_local_runme.java
new file mode 100644
index 000000000..a645fbabf
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_thread_local_runme.java
@@ -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();
+ }
+}
diff --git a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py
new file mode 100644
index 000000000..0a1c45716
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py
@@ -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.")
+
diff --git a/Examples/test-suite/python/cpp11_decltype_runme.py b/Examples/test-suite/python/cpp11_decltype_runme.py
new file mode 100644
index 000000000..bfcbbec79
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_decltype_runme.py
@@ -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."
+
diff --git a/Examples/test-suite/python/cpp11_function_objects_runme.py b/Examples/test-suite/python/cpp11_function_objects_runme.py
new file mode 100644
index 000000000..aac7f9c5f
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_function_objects_runme.py
@@ -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))
+
diff --git a/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py b/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py
new file mode 100644
index 000000000..eedf8f148
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py
@@ -0,0 +1,4 @@
+import cpp11_initializer_list_extend
+
+c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] )
+
diff --git a/Examples/test-suite/python/cpp11_initializer_list_runme.py b/Examples/test-suite/python/cpp11_initializer_list_runme.py
new file mode 100644
index 000000000..395cd610d
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_initializer_list_runme.py
@@ -0,0 +1,5 @@
+import cpp11_initializer_list
+
+a = cpp11_initializer_list.A()
+a = cpp11_initializer_list.A(11.1)
+
diff --git a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py
new file mode 100644
index 000000000..d304c139d
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py
@@ -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")
+
diff --git a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py
new file mode 100644
index 000000000..32282d8d8
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py
@@ -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
+
+
diff --git a/Examples/test-suite/python/cpp11_result_of_runme.py b/Examples/test-suite/python/cpp11_result_of_runme.py
new file mode 100644
index 000000000..a97dd7ccc
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_result_of_runme.py
@@ -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."
diff --git a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py
new file mode 100644
index 000000000..a72a3e63b
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py
@@ -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")
+
diff --git a/Examples/test-suite/python/cpp11_thread_local_runme.py b/Examples/test-suite/python/cpp11_thread_local_runme.py
new file mode 100644
index 000000000..59a657488
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_thread_local_runme.py
@@ -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
+
diff --git a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py
new file mode 100644
index 000000000..85c3b2478
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py
@@ -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
diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg
index f08f87c3c..152e5e6f0 100644
--- a/Lib/allegrocl/allegrocl.swg
+++ b/Lib/allegrocl/allegrocl.swg
@@ -17,8 +17,7 @@
enum SWIGTYPE "(cl::setq ACL_ffresult $body)";
%typemap(lout) void "$body";
#ifdef __cplusplus
-%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *,
- SWIGTYPE &
+%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
%{ (cl:let* ((address $body)
(new-inst (cl:make-instance '$lclass :foreign-address address)))
(cl:when (cl:and $owner (cl:not (cl:zerop address)))
@@ -27,7 +26,7 @@
%typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))";
#else
-%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE
+%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE
%{ (cl:let* ((address $body)
(new-inst (cl:make-instance '$lclass :foreign-address address)))
(cl:setq ACL_ffresult new-inst)) %}
@@ -67,6 +66,7 @@
%typemap(ffitype) void ":void";
%typemap(ffitype) enum SWIGTYPE ":int";
%typemap(ffitype) SWIGTYPE & "(* :void)";
+%typemap(ffitype) SWIGTYPE && "(* :void)";
/* const typemaps
idea: marshall all primitive c types to their respective lisp types
@@ -102,7 +102,7 @@ and error if a setf operation is performed on the address of this object.
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[],
- SWIGTYPE[ANY], SWIGTYPE &, const SWIGTYPE "$1_ltype";
+ SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE &&, const SWIGTYPE "$1_ltype";
%typemap(ctype) SWIGTYPE "$&1_type";
%typemap(in) bool "$1 = (bool)$input;";
@@ -112,7 +112,7 @@ and error if a setf operation is performed on the address of this object.
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[],
- SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;";
+ SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;";
%typemap(in) SWIGTYPE "$1 = *$input;";
/* We don't need to do any actual C-side typechecking, but need to
@@ -167,7 +167,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
int, signed int, unsigned int,
long, signed long, unsigned long,
enum SWIGTYPE { $1 = 1; };
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &,
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&,
SWIGTYPE[], SWIGTYPE[ANY],
SWIGTYPE { $1 = 1; };
@@ -192,7 +192,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
long, signed long, unsigned long,
float, double, long double, char *, void *,
enum SWIGTYPE, SWIGTYPE *,
- SWIGTYPE[ANY], SWIGTYPE & "$result = $1;";
+ SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;";
#ifdef __cplusplus
%typemap(out) SWIGTYPE "$result = new $1_ltype($1);";
#else
@@ -228,6 +228,7 @@ $body)"
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/cffi/cffi.swg b/Lib/cffi/cffi.swg
index 427a8dc17..3ad767ef8 100644
--- a/Lib/cffi/cffi.swg
+++ b/Lib/cffi/cffi.swg
@@ -67,7 +67,7 @@
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *,
- SWIGTYPE[ANY], SWIGTYPE & "$1_ltype";
+ SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1_ltype";
%typemap(ctype) SWIGTYPE "$&1_type";
%typemap(in) bool "$1 = (bool)$input;";
@@ -77,7 +77,7 @@
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *,
- SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;";
+ SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;";
%typemap(in) SWIGTYPE "$1 = *$input;";
%typemap(out) void "";
@@ -88,7 +88,7 @@
long, signed long, unsigned long,
float, double, long double, char *, void *,
enum SWIGTYPE, SWIGTYPE *,
- SWIGTYPE[ANY], SWIGTYPE & "$result = $1;";
+ SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;";
#ifdef __cplusplus
%typemap(out) SWIGTYPE "$result = new $1_type($1);";
#else
@@ -109,7 +109,7 @@
int, signed int, unsigned int,
long, signed long, unsigned long,
enum SWIGTYPE { $1 = 1; };
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &,
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&,
SWIGTYPE[ANY], SWIGTYPE { $1 = 1; };
/* This maps C/C++ types to Lisp classes for overload dispatch */
@@ -132,6 +132,7 @@
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg
index 525c1a64c..17f0d0ac3 100644
--- a/Lib/chicken/chicken.swg
+++ b/Lib/chicken/chicken.swg
@@ -149,6 +149,7 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
/* enum SWIGTYPE */
%apply int { enum SWIGTYPE };
%apply const int& { const enum SWIGTYPE& };
+%apply const int& { const enum SWIGTYPE&& };
%typemap(varin) enum SWIGTYPE
{
@@ -178,7 +179,7 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
%typemap(freearg) char * "if ($1 != NULL) { free ($1); }"
/* Pointers, references, and arrays */
-%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE & {
+%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && {
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, $disown);
}
@@ -199,6 +200,10 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
$1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
}
+%typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE && {
+ $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
+}
+
%typemap(varin) SWIGTYPE [] {
SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "Type error");
}
@@ -216,7 +221,7 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
$1 = SWIG_MustGetPtr($input, NULL, 1, 0);
}
-%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
$result = SWIG_NewPointerObj($1, $descriptor, $owner);
}
@@ -237,6 +242,11 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
$result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0);
}
+%typemap(varout) SWIGTYPE && {
+ C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
+ $result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0);
+}
+
/* special typemaps for class pointers */
%typemap(in) SWIGTYPE (CLASS::*) {
char err_msg[256];
@@ -531,7 +541,7 @@ $result = C_SCHEME_UNDEFINED;
%typemap(constcode) char *
"static const char *$result = $value;"
-%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
+%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
"static const void *$result = (void*) $value;"
/* ------------------------------------------------------------
@@ -607,7 +617,7 @@ $result = C_SCHEME_UNDEFINED;
$1 = C_swig_is_string ($input);
}
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
$1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
}
@@ -628,6 +638,17 @@ $result = C_SCHEME_UNDEFINED;
}
}
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &&
+{
+ void *ptr = 0;
+ if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) {
+ /* error */
+ $1 = 0;
+ } else {
+ $1 = (ptr != 0);
+ }
+}
+
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
{
void *ptr = 0;
@@ -673,6 +694,12 @@ $result = C_SCHEME_UNDEFINED;
SWIG_Chicken_ThrowException(ptr);
}
+%typemap(throws) SWIGTYPE && {
+ C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
+ C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0);
+ SWIG_Chicken_ThrowException(ptr);
+}
+
/* ------------------------------------------------------------
* ANSI C typemaps
* ------------------------------------------------------------ */
@@ -685,6 +712,7 @@ $result = C_SCHEME_UNDEFINED;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg
index c0b896e16..bd9d8e8b2 100644
--- a/Lib/csharp/csharp.swg
+++ b/Lib/csharp/csharp.swg
@@ -125,6 +125,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(imtype, out="IntPtr") SWIGTYPE & "HandleRef"
%typemap(cstype) SWIGTYPE & "$csclassname"
+%typemap(ctype) SWIGTYPE && "void *"
+%typemap(imtype, out="IntPtr") SWIGTYPE && "HandleRef"
+%typemap(cstype) SWIGTYPE && "$csclassname"
+
/* pointer to a class member */
%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
%typemap(imtype) SWIGTYPE (CLASS::*) "string"
@@ -401,6 +405,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
return $null;
} %}
+%typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input;
+ if (!$1) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
+ return $null;
+ } %}
%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
char buf[128];
@@ -409,6 +418,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$result = SWIG_csharp_string_callback(buf);
%}
%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %}
+%typemap(out) SWIGTYPE && %{ $result = (void *)$1; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
%{ $result = ($1_ltype)$input; %}
@@ -426,12 +436,21 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
return $null;
}
$result = ($1_ltype)$input; %}
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
+%{ if (!$input) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
+ return $null;
+ }
+ $result = ($1_ltype)$input; %}
%typemap(directorin) SWIGTYPE &
%{ $input = ($1_ltype) &$1; %}
+%typemap(directorin) SWIGTYPE &&
+%{ $input = ($1_ltype) &$1; %}
%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)"
%typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)"
-%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle"
+%typemap(csdirectorin) SWIGTYPE && "new $csclassname($iminput, false)"
+%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$csclassname.getCPtr($cscall).Handle"
/* Default array handling */
%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %}
@@ -526,6 +545,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE *const&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)
@@ -544,7 +564,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg);
return $null; %}
-%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY]
+%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [ANY]
%{ (void)$1;
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
return $null; %}
@@ -575,7 +595,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
"$csinput"
%typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
-%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
+%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
/* The csout typemap is used for converting function return types from the return type
@@ -658,6 +678,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ret;
}
+%typemap(csout, excode=SWIGEXCODE) SWIGTYPE && {
+ $csclassname ret = new $csclassname($imcall, $owner);$excode
+ return ret;
+ }
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] {
IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
@@ -671,7 +695,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
/* Properties */
-%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
set {
$imcall;$excode
} %}
@@ -772,6 +796,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ret;
} %}
+%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE && %{
+ get {
+ $csclassname ret = new $csclassname($imcall, $owner);$excode
+ return ret;
+ } %}
%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{
get {
IntPtr cPtr = $imcall;
@@ -816,13 +845,13 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
/* Typemaps used for the generation of proxy and type wrapper class code */
-%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
-%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n"
+%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
+%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n"
%typemap(csinterfaces) SWIGTYPE "IDisposable"
-%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
// csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users.
@@ -859,7 +888,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Typewrapper classes
-%typemap(csbody) TYPE *, TYPE &, TYPE [] %{
+%typemap(csbody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
private HandleRef swigCPtr;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) {
@@ -969,6 +998,7 @@ using System.Runtime.InteropServices;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg
index 70e483fd6..9b4acefc0 100644
--- a/Lib/csharp/enums.swg
+++ b/Lib/csharp/enums.swg
@@ -13,7 +13,7 @@
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = &temp; %}
-%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
+%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
@@ -48,7 +48,7 @@
%typemap(cstype) enum SWIGTYPE "$csclassname"
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
-%typemap(out) enum SWIGTYPE %{ $result = $1; %}
+%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
%typemap(directorin) enum SWIGTYPE "$input = $1;"
diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg
index a193e758a..484443652 100644
--- a/Lib/csharp/enumsimple.swg
+++ b/Lib/csharp/enumsimple.swg
@@ -15,7 +15,7 @@
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = &temp; %}
-%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
+%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
@@ -50,7 +50,7 @@
%typemap(cstype) enum SWIGTYPE "int"
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
-%typemap(out) enum SWIGTYPE %{ $result = $1; %}
+%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
%typemap(directorin) enum SWIGTYPE "$input = $1;"
diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg
index ed483f0cb..772a88013 100644
--- a/Lib/csharp/enumtypesafe.swg
+++ b/Lib/csharp/enumtypesafe.swg
@@ -14,7 +14,7 @@
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = &temp; %}
-%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
+%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
@@ -49,7 +49,7 @@
%typemap(cstype) enum SWIGTYPE "$csclassname"
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
-%typemap(out) enum SWIGTYPE %{ $result = $1; %}
+%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
%typemap(directorin) enum SWIGTYPE "$input = $1;"
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index b00533fa3..3408f422e 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -273,6 +273,21 @@
%typemap(directorout) SWIGTYPE &
%{ *($&1_ltype)&$result = $input; %}
+%typemap(gotype) SWIGTYPE &&
+%{$gotypename%}
+
+%typemap(in) SWIGTYPE &&
+%{ $1 = *($&1_ltype)&$input; %}
+
+%typemap(out) SWIGTYPE &&
+%{ *($&1_ltype)&$result = $1; %}
+
+%typemap(directorin) SWIGTYPE &&
+%{ $input = ($1_ltype)&$1_name; %}
+
+%typemap(directorout) SWIGTYPE &&
+%{ *($&1_ltype)&$result = $input; %}
+
/* C arrays turn into Go pointers. If we know the length we can use a
slice. */
@@ -424,7 +439,7 @@
%typemap(throws) char *
%{ _swig_gopanic($1); %}
-%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
+%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
%{
(void)$1;
_swig_gopanic("C++ $1_type exception thrown");
@@ -530,6 +545,7 @@
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE *const&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)
diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i
index ba447ac28..d818613e7 100644
--- a/Lib/guile/typemaps.i
+++ b/Lib/guile/typemaps.i
@@ -6,10 +6,10 @@
/* Pointers */
-%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
}
-%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "";
+%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "";
%typemap(in) void * {
$1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0);
@@ -24,6 +24,10 @@
$1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
}
+%typemap(varin) SWIGTYPE && {
+ $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
+}
+
%typemap(varin) SWIGTYPE [] {
scm_wrong_type_arg((char *) FUNC_NAME, 1, $input);
}
@@ -41,7 +45,7 @@
$1 = SWIG_MustGetPtr($input, NULL, 1, 0);
}
-%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
$result = SWIG_NewPointerObj ($1, $descriptor, $owner);
}
@@ -58,6 +62,10 @@
$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
}
+%typemap(varout) SWIGTYPE && {
+ $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
+}
+
%typemap(throws) SWIGTYPE {
$&ltype temp = new $ltype($1);
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
@@ -71,6 +79,12 @@
SCM_UNDEFINED));
}
+%typemap(throws) SWIGTYPE && {
+ scm_throw(gh_symbol2scm((char *) "swig-exception"),
+ gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1),
+ SCM_UNDEFINED));
+}
+
%typemap(throws) SWIGTYPE * {
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
scm_listify(SWIG_NewPointerObj($1, $descriptor, 1),
@@ -430,7 +444,7 @@ typedef unsigned long SCM;
$1 = scm_is_string($input) ? 1 : 0;
}
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
$1 = SWIG_CheckState(res);
@@ -450,6 +464,7 @@ typedef unsigned long SCM;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 6126a55e5..84d018083 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -185,6 +185,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(jtype) SWIGTYPE & "long"
%typemap(jstype) SWIGTYPE & "$javaclassname"
+%typemap(jni) SWIGTYPE && "jlong"
+%typemap(jtype) SWIGTYPE && "long"
+%typemap(jstype) SWIGTYPE && "$javaclassname"
+
/* pointer to a class member */
%typemap(jni) SWIGTYPE (CLASS::*) "jstring"
%typemap(jtype) SWIGTYPE (CLASS::*) "String"
@@ -649,6 +653,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
return $null;
} %}
+%typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input;
+ if (!$1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
+ return $null;
+ } %}
%typemap(out) SWIGTYPE *
%{ *($&1_ltype)&$result = $1; %}
%typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
@@ -659,6 +668,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
}
%typemap(out) SWIGTYPE &
%{ *($&1_ltype)&$result = $1; %}
+%typemap(out) SWIGTYPE &&
+%{ *($&1_ltype)&$result = $1; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
%{ $result = *($&1_ltype)&$input; %}
@@ -676,12 +687,21 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
return $null;
}
$result = *($&1_ltype)&$input; %}
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
+%{ if (!$input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
+ return $null;
+ }
+ $result = *($&1_ltype)&$input; %}
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
+%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &&
+%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)"
%typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)"
-%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)"
+%typemap(javadirectorin) SWIGTYPE && "new $javaclassname($jniinput, false)"
+%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$javaclassname.getCPtr($javacall)"
/* Default array handling */
%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
@@ -959,6 +979,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE *const&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)
@@ -978,7 +999,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg);
return $null; %}
-%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
+%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
%{ (void)$1;
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
return $null; %}
@@ -1029,7 +1050,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
jobjectArray
"$javainput"
%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
-%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
+%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
%typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
/* The javaout typemap is used for converting function return types from the return type
@@ -1083,6 +1104,9 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(javaout) SWIGTYPE & {
return new $javaclassname($jnicall, $owner);
}
+%typemap(javaout) SWIGTYPE && {
+ return new $javaclassname($jnicall, $owner);
+ }
%typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
long cPtr = $jnicall;
return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
@@ -1108,11 +1132,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%{ *($1_ltype)&$result = *$1; %}
/* Typemaps used for the generation of proxy and type wrapper class code */
-%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
-%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
+%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
/* javabody typemaps */
@@ -1151,7 +1175,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Typewrapper classes
-%typemap(javabody) TYPE *, TYPE &, TYPE [] %{
+%typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
private long swigCPtr;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) {
@@ -1290,6 +1314,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg
index d3b335129..80c4c04c1 100644
--- a/Lib/lua/lua.swg
+++ b/Lib/lua/lua.swg
@@ -40,7 +40,7 @@
%typemap(consttab) long long, unsigned long long
{SWIG_LUA_CONSTTAB_STRING("$symname", "$value")}
-%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE []
+%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
{ SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor}
// member function pointers
diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg
index f6791a224..c86b40d74 100644
--- a/Lib/lua/luatypemaps.swg
+++ b/Lib/lua/luatypemaps.swg
@@ -68,8 +68,12 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
// and const refs
%typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &($basetype temp)
%{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%}
+%typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &&($basetype temp)
+%{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%}
%typemap(out) const enum SWIGTYPE &
%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%}
+%typemap(out) const enum SWIGTYPE &&
+%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%}
// boolean (which is a special type in lua)
@@ -147,9 +151,18 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
}
%}
+%typemap(in,checkfn="lua_isuserdata") SWIGTYPE&&
+%{
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){
+ SWIG_fail_ptr("$symname",$argnum,$descriptor);
+ }
+%}
+
// out is simple
%typemap(out) SWIGTYPE*,SWIGTYPE&
%{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %}
+%typemap(out) SWIGTYPE*,SWIGTYPE&&
+%{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %}
// dynamic casts
// this uses the SWIG_TypeDynamicCast() which relies on RTTI to find out what the pointer really is
@@ -284,7 +297,7 @@ parameters match which function
const unsigned int &, const unsigned short &, const unsigned long &,
const signed char&, const unsigned char&,
const long long &, const unsigned long long &,
- enum SWIGTYPE, const enum SWIGTYPE&,
+ enum SWIGTYPE, const enum SWIGTYPE&, const enum SWIGTYPE &&,
float, double, const float &, const double&
{
$1 = lua_isnumber(L,$input);
@@ -323,6 +336,15 @@ parameters match which function
}
}
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && {
+ void *ptr;
+ if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) {
+ $1 = 0;
+ } else {
+ $1 = 1;
+ }
+}
+
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
void *ptr;
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) {
@@ -360,6 +382,7 @@ parameters match which function
// Array reference typemaps
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/modula3/modula3.swg b/Lib/modula3/modula3.swg
index 3affdd0de..262f8ead4 100644
--- a/Lib/modula3/modula3.swg
+++ b/Lib/modula3/modula3.swg
@@ -344,6 +344,23 @@
%typemap(m3wrapouttype) SWIGTYPE & "$1_basetype"
%typemap(m3wraprettype) SWIGTYPE & "UNTRACED REF $1_basetype"
+%typemap(ctype) SWIGTYPE && "$1_type"
+%typemap(m3rawtype) const SWIGTYPE && "UNTRACED REF $1_basetype"
+%typemap(m3rawtype) SWIGTYPE && "UNTRACED REF $1_basetype"
+%typemap(m3rawintype) const SWIGTYPE && "$1_basetype"
+%typemap(m3rawinmode) const SWIGTYPE && "READONLY"
+%typemap(m3rawintype) SWIGTYPE && "$1_basetype"
+%typemap(m3rawinmode) SWIGTYPE && "VAR"
+%typemap(m3rawrettype) const SWIGTYPE && "UNTRACED REF $1_basetype"
+%typemap(m3rawrettype) SWIGTYPE && "UNTRACED REF $1_basetype"
+%typemap(m3wraptype) SWIGTYPE && "$1_basetype"
+%typemap(m3wrapintype) const SWIGTYPE && "$1_basetype"
+%typemap(m3wrapinmode) const SWIGTYPE && "READONLY"
+%typemap(m3wrapintype) SWIGTYPE && "$1_basetype"
+%typemap(m3wrapinmode) SWIGTYPE && "VAR"
+%typemap(m3wrapouttype) SWIGTYPE && "$1_basetype"
+%typemap(m3wraprettype) SWIGTYPE && "UNTRACED REF $1_basetype"
+
%typemap(ctype) enum SWIGTYPE "$1_type"
%typemap(m3rawtype) enum SWIGTYPE "C.int"
%typemap(m3rawintype) enum SWIGTYPE "C.int (* $1_type *)"
@@ -468,7 +485,12 @@ $1 = &temp; %}
//SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
RETURN $null;
} %}
-%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %}
+%typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input;
+ if(!$1) {
+ //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
+ RETURN $null;
+ } %}
+%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %}
/* Default array handling */
@@ -552,6 +574,7 @@ $1 = &temp; %}
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)
""
@@ -605,7 +628,7 @@ $1 = &temp; %}
enum SWIGTYPE
"$input"
%typemap(m3in) SWIGTYPE "$&*1_type.getCPtr($input)"
-%typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)"
+%typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)"
/* The m3out typemap is used for converting function return types from the return type
* used in the PInvoke class to the type returned by the proxy, module or type wrapper class. */
@@ -636,13 +659,16 @@ $1 = &temp; %}
%typemap(m3out) SWIGTYPE & %{
RETURN NEW($1_basetype, $imcall, $owner);
%}
+%typemap(m3out) SWIGTYPE && %{
+ RETURN NEW($1_basetype, $imcall, $owner);
+%}
%typemap(m3out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
cPtr := $imcall;
RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner);
%}
/* Properties */
-%typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+%typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
PROCEDURE Set$var (value: $vartype) =
BEGIN
$imcall;
@@ -684,6 +710,10 @@ PROCEDURE Get$var (): $vartype =
get {
RETURN new $1_basetype($imcall, $owner);
} %}
+%typemap(m3varout) SWIGTYPE && %{
+ get {
+ RETURN new $1_basetype($imcall, $owner);
+ } %}
%typemap(m3varout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
get {
IntPtr cPtr = $imcall;
@@ -691,13 +721,13 @@ PROCEDURE Get$var (): $vartype =
} %}
/* Typemaps used for the generation of proxy and type wrapper class code */
-%typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public"
-%typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;"
+%typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public"
+%typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;"
%typemap(m3interfaces) SWIGTYPE "IDisposable"
-%typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
-%typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal"
+%typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal"
%typemap(m3finalize) SWIGTYPE %{
~$1_basetype() {
@@ -724,7 +754,7 @@ PROCEDURE Get$var (): $vartype =
base.Dispose();
}
-%typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+%typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
internal static IntPtr getCPtr($1_basetype obj) {
RETURN (obj == null) ? IntPtr.Zero : obj.swigCPtr;
}
@@ -748,6 +778,7 @@ FROM BlaBla IMPORT Bla;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i
index 4078026ac..9346349bd 100644
--- a/Lib/mzscheme/typemaps.i
+++ b/Lib/mzscheme/typemaps.i
@@ -23,6 +23,10 @@
$1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
}
+%typemap(varin) SWIGTYPE && {
+ $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
+}
+
%typemap(varin) SWIGTYPE [ANY] {
void *temp;
int ii;
@@ -54,16 +58,20 @@
$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
}
+%typemap(varout) SWIGTYPE && {
+ $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
+}
+
/* C++ References */
#ifdef __cplusplus
-%typemap(in) SWIGTYPE &, const SWIGTYPE & {
+%typemap(in) SWIGTYPE &, SWIGTYPE && {
$1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)");
}
-%typemap(out) SWIGTYPE &, const SWIGTYPE & {
+%typemap(out) SWIGTYPE &, SWIGTYPE && {
$result = SWIG_NewPointerObj ($1, $descriptor, $owner);
}
@@ -321,7 +329,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
$1 = (SCHEME_STRINGP($input)) ? 1 : 0;
}
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) {
$1 = 0;
@@ -351,6 +359,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i
index 4c3500690..a13e1552e 100644
--- a/Lib/ocaml/typecheck.i
+++ b/Lib/ocaml/typecheck.i
@@ -129,7 +129,7 @@
}
}
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
$1 = !caml_ptr_val_internal($input, &ptr,$descriptor);
}
diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i
index a15dc16ec..7602ad629 100644
--- a/Lib/ocaml/typemaps.i
+++ b/Lib/ocaml/typemaps.i
@@ -34,11 +34,21 @@
$1 = ($ltype) caml_ptr_val($input,$1_descriptor);
}
+%typemap(in) SWIGTYPE && {
+ /* %typemap(in) SWIGTYPE && */
+ $1 = ($ltype) caml_ptr_val($input,$1_descriptor);
+}
+
%typemap(varin) SWIGTYPE & {
/* %typemap(varin) SWIGTYPE & */
$1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
}
+%typemap(varin) SWIGTYPE && {
+ /* %typemap(varin) SWIGTYPE && */
+ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
+}
+
%typemap(out) SWIGTYPE & {
/* %typemap(out) SWIGTYPE & */
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
@@ -49,6 +59,16 @@
}
}
+%typemap(out) SWIGTYPE && {
+ /* %typemap(out) SWIGTYPE && */
+ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
+ if( fromval ) {
+ $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor));
+ } else {
+ $result = caml_val_ptr ((void *) &$1,$1_descriptor);
+ }
+}
+
#if 0
%typemap(argout) SWIGTYPE & {
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
@@ -63,9 +83,23 @@
caml_val_ptr ((void *) $1,$1_descriptor));
}
}
+%typemap(argout) SWIGTYPE && {
+ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
+ if( fromval ) {
+ swig_result =
+ caml_list_append(swig_result,
+ callback(*fromval,caml_val_ptr((void *) $1,
+ $1_descriptor)));
+ } else {
+ swig_result =
+ caml_list_append(swig_result,
+ caml_val_ptr ((void *) $1,$1_descriptor));
+ }
+}
#endif
%typemap(argout) const SWIGTYPE & { }
+%typemap(argout) const SWIGTYPE && { }
%typemap(in) SWIGTYPE {
$1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ;
@@ -112,6 +146,7 @@
}
%apply SWIGTYPE { const SWIGTYPE & };
+%apply SWIGTYPE { const SWIGTYPE && };
#endif
@@ -329,6 +364,7 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg
index 5df456fd7..fc7100e89 100644
--- a/Lib/perl5/perltypemaps.swg
+++ b/Lib/perl5/perltypemaps.swg
@@ -84,6 +84,9 @@
%typemap(varout,type="$1_descriptor") SWIGTYPE &
"sv_setiv(SvRV($result),PTR2IV(&$1));";
+%typemap(varout,type="$1_descriptor") SWIGTYPE &&
+ "sv_setiv(SvRV($result),PTR2IV(&$1));";
+
%typemap(varout,type="$&1_descriptor") SWIGTYPE
"sv_setiv(SvRV($result), PTR2IV(&$1));";
diff --git a/Lib/php/const.i b/Lib/php/const.i
index 78f3a8a08..82c48022b 100644
--- a/Lib/php/const.i
+++ b/Lib/php/const.i
@@ -31,6 +31,7 @@
%typemap(consttab) SWIGTYPE *,
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE [] {
zval *z_var;
MAKE_STD_ZVAL(z_var);
diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i
index 45fb0223b..1378ae60b 100644
--- a/Lib/php/globalvar.i
+++ b/Lib/php/globalvar.i
@@ -80,7 +80,7 @@
sizeof(zval *), NULL);
}
-%typemap(varinit) SWIGTYPE, SWIGTYPE &
+%typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&
{
zval *z_var;
@@ -210,7 +210,7 @@
}
-%typemap(varin) SWIGTYPE *, SWIGTYPE &
+%typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{
zval **z_var;
$1_ltype _temp;
@@ -336,7 +336,7 @@ deliberate error cos this code looks bogus to me
}
}
-%typemap(varout) SWIGTYPE *, SWIGTYPE &
+%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{
zval **z_var;
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index f27e1fe67..325abbcd4 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -114,6 +114,13 @@
}
}
+%typemap(in) SWIGTYPE &&
+{
+ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
+ SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
+ }
+}
+
%typemap(in) SWIGTYPE *const& ($*ltype temp)
{
if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) {
@@ -131,7 +138,8 @@
%typemap(argout) SWIGTYPE *,
SWIGTYPE [],
- SWIGTYPE&;
+ SWIGTYPE &,
+ SWIGTYPE &&;
%typemap(in) void *
{
@@ -188,12 +196,16 @@
signed char,
unsigned char,
bool,
- size_t,
- enum SWIGTYPE
+ size_t
{
ZVAL_LONG(return_value,$1);
}
+%typemap(out) enum SWIGTYPE
+{
+ ZVAL_LONG(return_value, (long)$1);
+}
+
%typemap(out) long long
%{
if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) {
@@ -226,12 +238,21 @@
const signed char &,
const unsigned char &,
const bool &,
- const size_t &,
- const enum SWIGTYPE &
+ const size_t &
{
ZVAL_LONG(return_value,*$1);
}
+%typemap(out) const enum SWIGTYPE &
+{
+ ZVAL_LONG(return_value, (long)*$1);
+}
+
+%typemap(out) const enum SWIGTYPE &&
+{
+ ZVAL_LONG(return_value, (long)*$1);
+}
+
%typemap(out) const long long &
%{
if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) {
@@ -269,6 +290,11 @@
ZVAL_LONG($input,$1);
}
+%typemap(directorin) enum SWIGTYPE
+{
+ ZVAL_LONG($input, (long)$1_name);
+}
+
%typemap(directorin) char *, char []
{
if(!$1) {
@@ -342,7 +368,8 @@
%typemap(out) SWIGTYPE *,
SWIGTYPE [],
- SWIGTYPE &
+ SWIGTYPE &,
+ SWIGTYPE &&
%{
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
%}
@@ -354,7 +381,8 @@
%typemap(directorin) SWIGTYPE *,
SWIGTYPE [],
- SWIGTYPE &
+ SWIGTYPE &,
+ SWIGTYPE &&
%{
SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2);
%}
@@ -449,6 +477,7 @@
SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE *const&
{
void *tmp;
@@ -479,7 +508,7 @@
return;
}
-%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
+%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
(void)$1;
zend_throw_exception(NULL, const_cast<char*>("C++ $1_type exception thrown"), 0 TSRMLS_CC);
return;
@@ -492,6 +521,7 @@
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg
index 399752a7a..95cc20835 100644
--- a/Lib/pike/pike.swg
+++ b/Lib/pike/pike.swg
@@ -53,6 +53,7 @@ extern "C" {
%typemap(in) SWIGTYPE *,
SWIGTYPE &,
+ SWIGTYPE &&,
SWIGTYPE []
"SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);"
@@ -79,7 +80,8 @@ extern "C" {
const bool & (bool temp),
const long long & ($*1_ltype temp),
const unsigned long long & ($*1_ltype temp),
- const enum SWIGTYPE & ($*1_ltype temp)
+ const enum SWIGTYPE & ($*1_ltype temp),
+ const enum SWIGTYPE && ($*1_ltype temp)
{
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
@@ -113,7 +115,7 @@ extern "C" {
%typemap(out, pikedesc="tStr") char * "push_text($1);";
/* Pointers, references, and arrays */
-%typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));";
+%typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));";
/* Void return value; don't push anything */
%typemap(out, pikedesc="tVoid") void "";
@@ -153,7 +155,8 @@ extern "C" {
const char &, const signed char &, const unsigned char &,
const bool &,
const long long &, const unsigned long long &,
- const enum SWIGTYPE & ($*1_ltype temp)
+ const enum SWIGTYPE & ($*1_ltype temp),
+ const enum SWIGTYPE && ($*1_ltype temp)
"push_int(*($1));";
%typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));";
@@ -216,7 +219,7 @@ extern "C" {
const int &, const short &, const long &,
const unsigned int &, const unsigned short &, const unsigned long &,
const long long &, const unsigned long long &,
- enum SWIGTYPE, enum SWIGTYPE &,
+ enum SWIGTYPE, enum SWIGTYPE &, SWIGTYPE &&,
bool, const bool &
{
$1 = ($input.type == T_INT) ? 1 : 0;
@@ -237,7 +240,7 @@ extern "C" {
$1 = ($input.type == T_STRING) ? 1 : 0;
}
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) {
$1 = 0;
@@ -266,6 +269,7 @@ extern "C" {
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
diff --git a/Lib/python/pydocs.swg b/Lib/python/pydocs.swg
index f4ab9db23..969af92aa 100644
--- a/Lib/python/pydocs.swg
+++ b/Lib/python/pydocs.swg
@@ -5,6 +5,7 @@
%typemap(doc) SWIGTYPE "@param $1_name $1_type";
%typemap(doc) SWIGTYPE * "@param $1_name $1_type";
%typemap(doc) const SWIGTYPE & "@param $1_name $1_type";
+%typemap(doc) const SWIGTYPE && "@param $1_name $1_type";
%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type";
%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "@param $1_name $1_type (input/output)";
@@ -14,6 +15,7 @@
%typemap(doc) SWIGTYPE "$1_name: $1_type";
%typemap(doc) SWIGTYPE * "$1_name: $1_type";
%typemap(doc) const SWIGTYPE & "$1_name: $1_type";
+%typemap(doc) const SWIGTYPE && "$1_name: $1_type";
%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type";
%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "$1_name: $1_type (input/output)";
diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg
index 2f223a839..4e2ae56f4 100644
--- a/Lib/python/pystdcommon.swg
+++ b/Lib/python/pystdcommon.swg
@@ -257,3 +257,5 @@ namespace swig {
#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_unordered_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_unordered_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i
new file mode 100644
index 000000000..b456035e2
--- /dev/null
+++ b/Lib/python/std_unordered_map.i
@@ -0,0 +1,251 @@
+/*
+ Unordered Maps
+*/
+
+%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
+{
+ namespace swig {
+ template <class SwigPySeq, class K, class T >
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::unordered_map<K,T > *unordered_map) {
+ typedef typename std::unordered_map<K,T>::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ unordered_map->insert(value_type(it->first, it->second));
+ }
+ }
+
+ template <class K, class T>
+ struct traits_asptr<std::unordered_map<K,T> > {
+ typedef std::unordered_map<K,T> unordered_map_type;
+ static int asptr(PyObject *obj, unordered_map_type **val) {
+ int res = SWIG_ERROR;
+ if (PyDict_Check(obj)) {
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
+%#if PY_VERSION_HEX >= 0x03000000
+ /* In Python 3.x the ".items()" method return a dict_items object */
+ items = PySequence_Fast(items, ".items() havn't returned a sequence!");
+%#endif
+ res = traits_asptr_stdseq<std::unordered_map<K,T>, std::pair<K, T> >::asptr(items, val);
+ } else {
+ unordered_map_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<unordered_map_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = p;
+ }
+ return res;
+ }
+ };
+
+ template <class K, class T >
+ struct traits_from<std::unordered_map<K,T> > {
+ typedef std::unordered_map<K,T> unordered_map_type;
+ typedef typename unordered_map_type::const_iterator const_iterator;
+ typedef typename unordered_map_type::size_type size_type;
+
+ static PyObject *from(const unordered_map_type& unordered_map) {
+ swig_type_info *desc = swig::type_info<unordered_map_type>();
+ if (desc && desc->clientdata) {
+ return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN);
+ } else {
+ size_type size = unordered_map.size();
+ int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_OverflowError,
+ "unordered_map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject *obj = PyDict_New();
+ for (const_iterator i= unordered_map.begin(); i!= unordered_map.end(); ++i) {
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
+ PyDict_SetItem(obj, key, val);
+ }
+ return obj;
+ }
+ }
+ };
+
+ template <class ValueType>
+ struct from_key_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef PyObject *result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v.first);
+ }
+ };
+
+ template <class ValueType>
+ struct from_value_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef PyObject *result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v.second);
+ }
+ };
+
+ template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
+ struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
+ {
+ SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
+ {
+ }
+ };
+
+
+ template<class OutIterator,
+ class FromOper = from_key_oper<typename OutIterator::value_type> >
+ struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
+ {
+ SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+ {
+ }
+ };
+
+ template<typename OutIter>
+ inline SwigPyIterator*
+ make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
+ {
+ return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
+ }
+
+ template<class OutIterator,
+ class FromOper = from_value_oper<typename OutIterator::value_type> >
+ struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
+ {
+ SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+ {
+ }
+ };
+
+
+ template<typename OutIter>
+ inline SwigPyIterator*
+ make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
+ {
+ return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
+ }
+ }
+}
+
+%define %swig_unordered_map_common(Map...)
+ %swig_sequence_iterator(Map);
+ %swig_container_methods(Map)
+
+ %extend {
+ mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) {
+ Map::const_iterator i = self->find(key);
+ if (i != self->end())
+ return i->second;
+ else
+ throw std::out_of_range("key not found");
+ }
+
+ void __delitem__(const key_type& key) throw (std::out_of_range) {
+ Map::iterator i = self->find(key);
+ if (i != self->end())
+ self->erase(i);
+ else
+ throw std::out_of_range("key not found");
+ }
+
+ bool has_key(const key_type& key) const {
+ Map::const_iterator i = self->find(key);
+ return i != self->end();
+ }
+
+ PyObject* keys() {
+ Map::size_type size = self->size();
+ int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_OverflowError,
+ "unordered_map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject* keyList = PyList_New(pysize);
+ Map::const_iterator i = self->begin();
+ for (int j = 0; j < pysize; ++i, ++j) {
+ PyList_SET_ITEM(keyList, j, swig::from(i->first));
+ }
+ return keyList;
+ }
+
+ PyObject* values() {
+ Map::size_type size = self->size();
+ int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_OverflowError,
+ "unordered_map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject* valList = PyList_New(pysize);
+ Map::const_iterator i = self->begin();
+ for (int j = 0; j < pysize; ++i, ++j) {
+ PyList_SET_ITEM(valList, j, swig::from(i->second));
+ }
+ return valList;
+ }
+
+ PyObject* items() {
+ Map::size_type size = self->size();
+ int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_OverflowError,
+ "unordered_map size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject* itemList = PyList_New(pysize);
+ Map::const_iterator i = self->begin();
+ for (int j = 0; j < pysize; ++i, ++j) {
+ PyList_SET_ITEM(itemList, j, swig::from(*i));
+ }
+ return itemList;
+ }
+
+ // Python 2.2 methods
+ bool __contains__(const key_type& key) {
+ return self->find(key) != self->end();
+ }
+
+ %newobject key_iterator(PyObject **PYTHON_SELF);
+ swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) {
+ return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+ }
+
+ %newobject value_iterator(PyObject **PYTHON_SELF);
+ swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) {
+ return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
+ }
+
+ %pythoncode {def __iter__(self): return self.key_iterator()}
+ %pythoncode {def iterkeys(self): return self.key_iterator()}
+ %pythoncode {def itervalues(self): return self.value_iterator()}
+ %pythoncode {def iteritems(self): return self.iterator()}
+ }
+%enddef
+
+%define %swig_unordered_map_methods(Map...)
+ %swig_unordered_map_common(Map)
+ %extend {
+ void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
+ (*self)[key] = x;
+ }
+ }
+%enddef
+
+
+%include <std/std_unordered_map.i>
diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i
new file mode 100644
index 000000000..adf86f251
--- /dev/null
+++ b/Lib/python/std_unordered_multimap.i
@@ -0,0 +1,79 @@
+/*
+ Unordered Multimaps
+*/
+%include <std_unordered_map.i>
+
+%fragment("StdUnorderedMultimapTraits","header",fragment="StdSequenceTraits")
+{
+ namespace swig {
+ template <class SwigPySeq, class K, class T >
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::unordered_multimap<K,T > *unordered_multimap) {
+ typedef typename std::unordered_multimap<K,T>::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ unordered_multimap->insert(value_type(it->first, it->second));
+ }
+ }
+
+ template <class K, class T>
+ struct traits_asptr<std::unordered_multimap<K,T> > {
+ typedef std::unordered_multimap<K,T> unordered_multimap_type;
+ static int asptr(PyObject *obj, std::unordered_multimap<K,T> **val) {
+ int res = SWIG_ERROR;
+ if (PyDict_Check(obj)) {
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
+ return traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
+ } else {
+ unordered_multimap_type *p;
+ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<unordered_multimap_type>(),0);
+ if (SWIG_IsOK(res) && val) *val = p;
+ }
+ return res;
+ }
+ };
+
+ template <class K, class T >
+ struct traits_from<std::unordered_multimap<K,T> > {
+ typedef std::unordered_multimap<K,T> unordered_multimap_type;
+ typedef typename unordered_multimap_type::const_iterator const_iterator;
+ typedef typename unordered_multimap_type::size_type size_type;
+
+ static PyObject *from(const unordered_multimap_type& unordered_multimap) {
+ swig_type_info *desc = swig::type_info<unordered_multimap_type>();
+ if (desc && desc->clientdata) {
+ return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN);
+ } else {
+ size_type size = unordered_multimap.size();
+ int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
+ if (pysize < 0) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(PyExc_OverflowError,
+ "unordered_multimap size not valid in python");
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ return NULL;
+ }
+ PyObject *obj = PyDict_New();
+ for (const_iterator i= unordered_multimap.begin(); i!= unordered_multimap.end(); ++i) {
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
+ PyDict_SetItem(obj, key, val);
+ }
+ return obj;
+ }
+ }
+ };
+ }
+}
+
+%define %swig_unordered_multimap_methods(Type...)
+ %swig_map_common(Type);
+ %extend {
+ void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
+ self->insert(Type::value_type(key,x));
+ }
+ }
+%enddef
+
+%include <std/std_unordered_multimap.i>
+
diff --git a/Lib/python/std_unordered_multiset.i b/Lib/python/std_unordered_multiset.i
new file mode 100644
index 000000000..d5b9ff61c
--- /dev/null
+++ b/Lib/python/std_unordered_multiset.i
@@ -0,0 +1,41 @@
+/*
+ Unordered Multisets
+*/
+
+%include <std_unordered_set.i>
+
+%fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class SwigPySeq, class T>
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::unordered_multiset<T>* seq) {
+ // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+ }
+
+ template <class T>
+ struct traits_asptr<std::unordered_multiset<T> > {
+ static int asptr(PyObject *obj, std::unordered_multiset<T> **m) {
+ return traits_asptr_stdseq<std::unordered_multiset<T> >::asptr(obj, m);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::unordered_multiset<T> > {
+ static PyObject *from(const std::unordered_multiset<T>& vec) {
+ return traits_from_stdseq<std::unordered_multiset<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+#define %swig_unordered_multiset_methods(Set...) %swig_set_methods(Set)
+
+
+
+%include <std/std_unordered_multiset.i>
diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i
new file mode 100644
index 000000000..a021cb4ed
--- /dev/null
+++ b/Lib/python/std_unordered_set.i
@@ -0,0 +1,55 @@
+/*
+ Unordered Sets
+*/
+
+%fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class SwigPySeq, class T>
+ inline void
+ assign(const SwigPySeq& swigpyseq, std::unordered_set<T>* seq) {
+ // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+ }
+
+ template <class T>
+ struct traits_asptr<std::unordered_set<T> > {
+ static int asptr(PyObject *obj, std::unordered_set<T> **s) {
+ return traits_asptr_stdseq<std::unordered_set<T> >::asptr(obj, s);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::unordered_set<T> > {
+ static PyObject *from(const std::unordered_set<T>& vec) {
+ return traits_from_stdseq<std::unordered_set<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+%define %swig_unordered_set_methods(unordered_set...)
+ %swig_sequence_iterator(unordered_set);
+ %swig_container_methods(unordered_set);
+
+ %extend {
+ void append(value_type x) {
+ self->insert(x);
+ }
+
+ bool __contains__(value_type x) {
+ return self->find(x) != self->end();
+ }
+
+ value_type __getitem__(difference_type i) const throw (std::out_of_range) {
+ return *(swig::cgetpos(self, i));
+ }
+
+ };
+%enddef
+
+%include <std/std_unordered_set.i>
diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg
index b86a618d9..9e5aa7b6d 100644
--- a/Lib/r/rtype.swg
+++ b/Lib/r/rtype.swg
@@ -16,9 +16,11 @@
%typemap("rtype") enum SWIGTYPE * "character";
%typemap("rtype") enum SWIGTYPE *const "character";
%typemap("rtype") enum SWIGTYPE & "character";
+%typemap("rtype") enum SWIGTYPE && "character";
%typemap("rtype") SWIGTYPE * "$R_class";
%typemap("rtype") SWIGTYPE *const "$R_class";
%typemap("rtype") SWIGTYPE & "$R_class";
+%typemap("rtype") SWIGTYPE && "$R_class";
%typemap("rtype") SWIGTYPE "$&R_class";
%typemap("rtypecheck") int, int &, long, long &
@@ -85,12 +87,14 @@
%{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE &
%{ $input = enumToInteger($input, "$R_class"); %}
+%typemap(scoercein) enum SWIGTYPE &&
+ %{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE *
%{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE *const
%{ $input = enumToInteger($input, "$R_class"); %}
-%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &
+%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&
%{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref") %}
/*
@@ -100,6 +104,9 @@
%typemap(scoercein) SWIGTYPE &
%{ $input = coerceIfNotSubclass($input, "$R_class") %}
+%typemap(scoercein) SWIGTYPE &&
+ %{ $input = coerceIfNotSubclass($input, "$R_class") %}
+
%typemap(scoercein) SWIGTYPE
%{ $input = coerceIfNotSubclass($input, "$&R_class") %}
*/
@@ -133,6 +140,9 @@ string &, std::string &
%typemap(scoerceout) enum SWIGTYPE &
%{ $result = enumFromInteger($result, "$R_class"); %}
+%typemap(scoerceout) enum SWIGTYPE &&
+ %{ $result = enumFromInteger($result, "$R_class"); %}
+
%typemap(scoerceout) enum SWIGTYPE *
%{ $result = enumToInteger($result, "$R_class"); %}
@@ -159,6 +169,9 @@ string &, std::string &
%typemap(scoerceout) SWIGTYPE &
%{ $result <- new("$R_class", ref=$result) ; %}
+ %typemap(scoerceout) SWIGTYPE &&
+ %{ $result <- new("$R_class", ref=$result) ; %}
+
%typemap(scoerceout) SWIGTYPE *
%{ $result <- new("$R_class", ref=$result) ; %}
diff --git a/Lib/std/std_multimap.i b/Lib/std/std_multimap.i
index 5a2cf38d7..39f674da5 100644
--- a/Lib/std/std_multimap.i
+++ b/Lib/std/std_multimap.i
@@ -1,5 +1,5 @@
//
-// std::map
+// std::multimap
//
%include <std_map.i>
diff --git a/Lib/std/std_multiset.i b/Lib/std/std_multiset.i
index 98a7fb9d7..b63fb92b9 100644
--- a/Lib/std/std_multiset.i
+++ b/Lib/std/std_multiset.i
@@ -1,5 +1,5 @@
//
-// std::set
+// std::multiset
//
%include <std_set.i>
diff --git a/Lib/std/std_unordered_map.i b/Lib/std/std_unordered_map.i
new file mode 100644
index 000000000..3c36d78e3
--- /dev/null
+++ b/Lib/std/std_unordered_map.i
@@ -0,0 +1,127 @@
+//
+// std::unordered_map
+// Work in progress - the code is not compilable yet:
+// operator--() and constructor(compare function) not available for unordered_
+// types
+//
+
+%include <std_pair.i>
+%include <std_container.i>
+
+%define %std_unordered_map_methods_common(unordered_map...)
+ %std_container_methods(unordered_map);
+
+ size_type erase(const key_type& x);
+ size_type count(const key_type& x) const;
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+// iterator insert(iterator position, const value_type& x);
+ void erase(iterator position);
+ void erase(iterator first, iterator last);
+
+ iterator find(const key_type& x);
+ iterator lower_bound(const key_type& x);
+ iterator upper_bound(const key_type& x);
+#endif
+%enddef
+
+%define %std_unordered_map_methods(unordered_map...)
+ %std_unordered_map_methods_common(unordered_map);
+
+ #ifdef SWIG_EXPORT_ITERATOR_METHODS
+// iterator insert(const value_type& x);
+ #endif
+%enddef
+
+
+// ------------------------------------------------------------------------
+// std::unordered_map
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::unordered_map<T>), f(const std::unordered_map<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::unordered_map<T> can be passed.
+// -- f(std::unordered_map<T>&), f(std::unordered_map<T>*):
+// the parameter may be modified; therefore, only a wrapped std::unordered_map
+// can be passed.
+// -- std::unordered_map<T> f(), const std::unordered_map<T>& f():
+// the unordered_map is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::unordered_map<T>& f(), std::unordered_map<T>* f():
+// the unordered_map is returned by reference; therefore, a wrapped std::unordered_map
+// is returned
+// -- const std::unordered_map<T>* f(), f(const std::unordered_map<T>*):
+// for consistency, they expect and return a plain unordered_map pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <unordered_map>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+ template<class _Key, class _Tp, class _Compare = std::less<_Key >,
+ class _Alloc = allocator<std::pair<const _Key, _Tp > > >
+ class unordered_map {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef std::pair<const _Key, _Tp> value_type;
+
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header",
+ fragment=SWIG_Traits_frag(_Key),
+ fragment=SWIG_Traits_frag(_Tp),
+ fragment="StdPairTraits") {
+ namespace swig {
+ template <> struct traits<std::pair< _Key, _Tp > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::pair<" #_Key "," #_Tp " >";
+ }
+ };
+ }
+ }
+
+ %fragment(SWIG_Traits_frag(std::unordered_map<_Key, _Tp, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
+ fragment="StdMapTraits") {
+ namespace swig {
+ template <> struct traits<std::unordered_map<_Key, _Tp, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::unordered_map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map<_Key, _Tp, _Compare, _Alloc >);
+
+ unordered_map( const _Compare& );
+
+#ifdef %swig_unordered_map_methods
+ // Add swig/language extra methods
+ %swig_unordered_map_methods(std::unordered_map<_Key, _Tp, _Compare, _Alloc >);
+#endif
+
+ %std_unordered_map_methods(unordered_map);
+ };
+
+}
diff --git a/Lib/std/std_unordered_multimap.i b/Lib/std/std_unordered_multimap.i
new file mode 100644
index 000000000..74efb2896
--- /dev/null
+++ b/Lib/std/std_unordered_multimap.i
@@ -0,0 +1,90 @@
+//
+// std::unordered_multimap
+// Work in progress - the code is not compilable yet:
+// operator--() and constructor(compare function) not available for unordered_
+// types
+//
+
+%include <std_unordered_map.i>
+
+
+%define %std_unordered_multimap_methods(mmap...)
+ %std_map_methods_common(mmap);
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ std::pair<iterator,iterator> equal_range(const key_type& x);
+ std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
+#endif
+%enddef
+
+// ------------------------------------------------------------------------
+// std::unordered_multimap
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::unordered_multimap<T>), f(const std::unordered_multimap<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::unordered_multimap<T> can be passed.
+// -- f(std::unordered_multimap<T>&), f(std::unordered_multimap<T>*):
+// the parameter may be modified; therefore, only a wrapped std::unordered_multimap
+// can be passed.
+// -- std::unordered_multimap<T> f(), const std::unordered_multimap<T>& f():
+// the map is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::unordered_multimap<T>& f(), std::unordered_multimap<T>* f():
+// the map is returned by reference; therefore, a wrapped std::unordered_multimap
+// is returned
+// -- const std::unordered_multimap<T>* f(), f(const std::unordered_multimap<T>*):
+// for consistency, they expect and return a plain map pointer.
+// ------------------------------------------------------------------------
+
+
+// exported class
+
+
+namespace std {
+ template<class _Key, class _Tp, class _Compare = std::less<_Key >,
+ class _Alloc = allocator<std::pair<const _Key, _Tp > > >
+ class unordered_multimap {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key key_type;
+ typedef _Tp mapped_type;
+ typedef std::pair<const _Key, _Tp> value_type;
+
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+ %traits_swigtype(_Tp);
+
+ %fragment(SWIG_Traits_frag(std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
+ fragment="StdMultimapTraits") {
+ namespace swig {
+ template <> struct traits<std::unordered_multimap<_Key, _Tp, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::unordered_multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >);
+
+ unordered_multimap( const _Compare& );
+
+#ifdef %swig_unordered_multimap_methods
+ // Add swig/language extra methods
+ %swig_unordered_multimap_methods(std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >);
+#endif
+
+ %std_unordered_multimap_methods(unordered_multimap);
+ };
+}
diff --git a/Lib/std/std_unordered_multiset.i b/Lib/std/std_unordered_multiset.i
new file mode 100644
index 000000000..56b971011
--- /dev/null
+++ b/Lib/std/std_unordered_multiset.i
@@ -0,0 +1,86 @@
+//
+// std::unordered_multiset
+// Work in progress - the code is not compilable yet:
+// operator--() and constructor(compare function) not available for unordered_
+// types
+//
+
+%include <std_unordered_set.i>
+
+// Unordered Multiset
+
+%define %std_unordered_multiset_methods(unordered_multiset...)
+ %std_unordered_set_methods_common(unordered_multiset);
+%enddef
+
+
+// ------------------------------------------------------------------------
+// std::unordered_multiset
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::unordered_multiset<T>), f(const std::unordered_multiset<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::unordered_multiset<T> can be passed.
+// -- f(std::unordered_multiset<T>&), f(std::unordered_multiset<T>*):
+// the parameter may be modified; therefore, only a wrapped std::unordered_multiset
+// can be passed.
+// -- std::unordered_multiset<T> f(), const std::unordered_multiset<T>& f():
+// the set is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::unordered_multiset<T>& f(), std::unordered_multiset<T>* f():
+// the set is returned by reference; therefore, a wrapped std::unordered_multiset
+// is returned
+// -- const std::unordered_multiset<T>* f(), f(const std::unordered_multiset<T>*):
+// for consistency, they expect and return a plain set pointer.
+// ------------------------------------------------------------------------
+
+
+// exported classes
+
+namespace std {
+
+ //unordered_multiset
+
+ template <class _Key, class _Compare = std::less<_Key>,
+ class _Alloc = allocator<_Key> >
+ class unordered_multiset {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Key value_type;
+ typedef _Key key_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+
+ %fragment(SWIG_Traits_frag(std::unordered_multiset<_Key, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Key),
+ fragment="StdMultisetTraits") {
+ namespace swig {
+ template <> struct traits<std::unordered_multiset<_Key, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::unordered_multiset<" #_Key "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset<_Key, _Compare, _Alloc >);
+
+ unordered_multiset( const _Compare& );
+
+#ifdef %swig_unordered_multiset_methods
+ // Add swig/language extra methods
+ %swig_unordered_multiset_methods(std::unordered_multiset<_Key, _Compare, _Alloc >);
+#endif
+
+ %std_unordered_multiset_methods(unordered_multiset);
+ };
+}
diff --git a/Lib/std/std_unordered_set.i b/Lib/std/std_unordered_set.i
new file mode 100644
index 000000000..4cdfd65a5
--- /dev/null
+++ b/Lib/std/std_unordered_set.i
@@ -0,0 +1,119 @@
+//
+// std::unordered_set
+// Work in progress - the code is not compilable yet:
+// operator--() and constructor(compare function) not available for unordered_
+// types
+//
+
+%include <std_container.i>
+%include <std_pair.i>
+
+// Unordered Set
+%define %std_unordered_set_methods_common(unordered_set...)
+ unordered_set();
+ unordered_set( const unordered_set& );
+
+ bool empty() const;
+ size_type size() const;
+ void clear();
+
+ void swap(unordered_set& v);
+
+
+ size_type erase(const key_type& x);
+ size_type count(const key_type& x) const;
+
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ class iterator;
+
+ iterator begin();
+ iterator end();
+
+ void erase(iterator pos);
+ void erase(iterator first, iterator last);
+
+ iterator find(const key_type& x);
+ std::pair<iterator,iterator> equal_range(const key_type& x);
+#endif
+%enddef
+
+%define %std_unordered_set_methods(unordered_set...)
+ %std_unordered_set_methods_common(unordered_set);
+#ifdef SWIG_EXPORT_ITERATOR_METHODS
+ std::pair<iterator,bool> insert(const value_type& __x);
+#endif
+%enddef
+
+// ------------------------------------------------------------------------
+// std::unordered_set
+//
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::unordered_set<T>), f(const std::unordered_set<T>&):
+// the parameter being read-only, either a sequence or a
+// previously wrapped std::unordered_set<T> can be passed.
+// -- f(std::unordered_set<T>&), f(std::unordered_set<T>*):
+// the parameter may be modified; therefore, only a wrapped std::unordered_set
+// can be passed.
+// -- std::unordered_set<T> f(), const std::unordered_set<T>& f():
+// the unordered_set is returned by copy; therefore, a sequence of T:s
+// is returned which is most easily used in other functions
+// -- std::unordered_set<T>& f(), std::unordered_set<T>* f():
+// the unordered_set is returned by reference; therefore, a wrapped std::unordered_set
+// is returned
+// -- const std::unordered_set<T>* f(), f(const std::unordered_set<T>*):
+// for consistency, they expect and return a plain unordered_set pointer.
+// ------------------------------------------------------------------------
+
+%{
+#include <unordered_set>
+%}
+
+// exported classes
+
+namespace std {
+
+ template <class _Key, class _Hash = std::hash<_Key>,
+ class _Compare = std::equal_to<_Key>,
+ class _Alloc = allocator<_Key> >
+ class unordered_set {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Hash hasher;
+ typedef _Key value_type;
+ typedef _Key key_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _Alloc allocator_type;
+
+ %traits_swigtype(_Key);
+
+ %fragment(SWIG_Traits_frag(std::unordered_set<_Key, _Hash, _Compare, _Alloc >), "header",
+ fragment=SWIG_Traits_frag(_Key),
+ fragment="StdUnorderedSetTraits") {
+ namespace swig {
+ template <> struct traits<std::unordered_set<_Key, _Hash, _Compare, _Alloc > > {
+ typedef pointer_category category;
+ static const char* type_name() {
+ return "std::unordered_set<" #_Key "," #_Hash "," #_Compare "," #_Alloc " >";
+ }
+ };
+ }
+ }
+
+ %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set<_Key, _Hash, _Compare, _Alloc >);
+
+ unordered_set( const _Compare& );
+
+#ifdef %swig_unordered_set_methods
+ // Add swig/language extra methods
+ %swig_unordered_set_methods(std::unordered_set<_Key, _Hash, _Compare, _Alloc >);
+#endif
+
+ %std_unordered_set_methods(unordered_set);
+ };
+}
diff --git a/Lib/swig.swg b/Lib/swig.swg
index 97e7c80a4..ad6b7b64b 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -310,6 +310,88 @@ static int NAME(TYPE x) {
%include <swigwarnings.swg>
/* -----------------------------------------------------------------------------
+ * Overloading support
+ * ----------------------------------------------------------------------------- */
+
+/*
+ * Function/method overloading support. This is done through typemaps,
+ * but also involve a precedence level.
+ */
+
+/* Macro for overload resolution */
+
+%define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef
+
+/* Macros for precedence levels */
+
+%define SWIG_TYPECHECK_POINTER 0 %enddef
+%define SWIG_TYPECHECK_ITERATOR 5 %enddef
+%define SWIG_TYPECHECK_VOIDPTR 10 %enddef
+%define SWIG_TYPECHECK_BOOL 15 %enddef
+%define SWIG_TYPECHECK_UINT8 20 %enddef
+%define SWIG_TYPECHECK_INT8 25 %enddef
+%define SWIG_TYPECHECK_UINT16 30 %enddef
+%define SWIG_TYPECHECK_INT16 35 %enddef
+%define SWIG_TYPECHECK_UINT32 40 %enddef
+%define SWIG_TYPECHECK_INT32 45 %enddef
+%define SWIG_TYPECHECK_SIZE 47 %enddef
+%define SWIG_TYPECHECK_PTRDIFF 48 %enddef
+%define SWIG_TYPECHECK_UINT64 50 %enddef
+%define SWIG_TYPECHECK_INT64 55 %enddef
+%define SWIG_TYPECHECK_UINT128 60 %enddef
+%define SWIG_TYPECHECK_INT128 65 %enddef
+%define SWIG_TYPECHECK_INTEGER 70 %enddef
+%define SWIG_TYPECHECK_FLOAT 80 %enddef
+%define SWIG_TYPECHECK_DOUBLE 90 %enddef
+%define SWIG_TYPECHECK_CPLXFLT 95 %enddef
+%define SWIG_TYPECHECK_CPLXDBL 100 %enddef
+%define SWIG_TYPECHECK_COMPLEX 105 %enddef
+%define SWIG_TYPECHECK_UNICHAR 110 %enddef
+%define SWIG_TYPECHECK_STDUNISTRING 115 %enddef
+%define SWIG_TYPECHECK_UNISTRING 120 %enddef
+%define SWIG_TYPECHECK_CHAR 130 %enddef
+%define SWIG_TYPECHECK_STDSTRING 135 %enddef
+%define SWIG_TYPECHECK_STRING 140 %enddef
+%define SWIG_TYPECHECK_PAIR 150 %enddef
+%define SWIG_TYPECHECK_VECTOR 160 %enddef
+%define SWIG_TYPECHECK_DEQUE 170 %enddef
+%define SWIG_TYPECHECK_LIST 180 %enddef
+%define SWIG_TYPECHECK_SET 190 %enddef
+%define SWIG_TYPECHECK_MULTISET 200 %enddef
+%define SWIG_TYPECHECK_MAP 210 %enddef
+%define SWIG_TYPECHECK_MULTIMAP 220 %enddef
+%define SWIG_TYPECHECK_STACK 230 %enddef
+%define SWIG_TYPECHECK_QUEUE 240 %enddef
+
+%define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef
+%define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef
+%define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef
+%define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef
+%define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef
+%define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef
+%define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef
+%define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef
+%define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef
+%define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef
+%define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef
+
+%define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef
+%define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef
+%define SWIG_TYPECHECK_INT8_PTR 2025 %enddef
+%define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef
+%define SWIG_TYPECHECK_INT16_PTR 2035 %enddef
+%define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef
+%define SWIG_TYPECHECK_INT32_PTR 2045 %enddef
+%define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef
+%define SWIG_TYPECHECK_INT64_PTR 2055 %enddef
+%define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef
+%define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef
+%define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef
+
+%define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef
+
+
+/* -----------------------------------------------------------------------------
* Default handling of certain overloaded operators
* ----------------------------------------------------------------------------- */
@@ -340,6 +422,10 @@ static int NAME(TYPE x) {
/* Define std namespace */
namespace std {
+ /* Warn about std::initializer_list usage. The constructor/method where used should probably be ignored. See docs. */
+ template<typename T> class initializer_list {};
+ %typemap(in, warning=SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG) initializer_list<T> ""
+ %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) initializer_list<T> ""
}
#endif
@@ -501,89 +587,6 @@ namespace std {
}
/* -----------------------------------------------------------------------------
- * Overloading support
- * ----------------------------------------------------------------------------- */
-
-/*
- * Function/method overloading support. This is done through typemaps,
- * but also involve a precedence level.
- */
-
-/* Macro for overload resolution */
-
-%define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef
-
-/* Macros for precedence levels */
-
-%define SWIG_TYPECHECK_POINTER 0 %enddef
-%define SWIG_TYPECHECK_ITERATOR 5 %enddef
-%define SWIG_TYPECHECK_VOIDPTR 10 %enddef
-%define SWIG_TYPECHECK_BOOL 15 %enddef
-%define SWIG_TYPECHECK_UINT8 20 %enddef
-%define SWIG_TYPECHECK_INT8 25 %enddef
-%define SWIG_TYPECHECK_UINT16 30 %enddef
-%define SWIG_TYPECHECK_INT16 35 %enddef
-%define SWIG_TYPECHECK_UINT32 40 %enddef
-%define SWIG_TYPECHECK_INT32 45 %enddef
-%define SWIG_TYPECHECK_SIZE 47 %enddef
-%define SWIG_TYPECHECK_PTRDIFF 48 %enddef
-%define SWIG_TYPECHECK_UINT64 50 %enddef
-%define SWIG_TYPECHECK_INT64 55 %enddef
-%define SWIG_TYPECHECK_UINT128 60 %enddef
-%define SWIG_TYPECHECK_INT128 65 %enddef
-%define SWIG_TYPECHECK_INTEGER 70 %enddef
-%define SWIG_TYPECHECK_FLOAT 80 %enddef
-%define SWIG_TYPECHECK_DOUBLE 90 %enddef
-%define SWIG_TYPECHECK_CPLXFLT 95 %enddef
-%define SWIG_TYPECHECK_CPLXDBL 100 %enddef
-%define SWIG_TYPECHECK_COMPLEX 105 %enddef
-%define SWIG_TYPECHECK_UNICHAR 110 %enddef
-%define SWIG_TYPECHECK_STDUNISTRING 115 %enddef
-%define SWIG_TYPECHECK_UNISTRING 120 %enddef
-%define SWIG_TYPECHECK_CHAR 130 %enddef
-%define SWIG_TYPECHECK_STDSTRING 135 %enddef
-%define SWIG_TYPECHECK_STRING 140 %enddef
-%define SWIG_TYPECHECK_PAIR 150 %enddef
-%define SWIG_TYPECHECK_VECTOR 160 %enddef
-%define SWIG_TYPECHECK_DEQUE 170 %enddef
-%define SWIG_TYPECHECK_LIST 180 %enddef
-%define SWIG_TYPECHECK_SET 190 %enddef
-%define SWIG_TYPECHECK_MULTISET 200 %enddef
-%define SWIG_TYPECHECK_MAP 210 %enddef
-%define SWIG_TYPECHECK_MULTIMAP 220 %enddef
-%define SWIG_TYPECHECK_STACK 230 %enddef
-%define SWIG_TYPECHECK_QUEUE 240 %enddef
-
-%define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef
-%define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef
-%define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef
-%define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef
-%define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef
-%define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef
-%define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef
-%define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef
-%define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef
-%define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef
-%define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef
-
-%define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef
-%define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef
-%define SWIG_TYPECHECK_INT8_PTR 2025 %enddef
-%define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef
-%define SWIG_TYPECHECK_INT16_PTR 2035 %enddef
-%define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef
-%define SWIG_TYPECHECK_INT32_PTR 2045 %enddef
-%define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef
-%define SWIG_TYPECHECK_INT64_PTR 2055 %enddef
-%define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef
-%define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef
-%define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef
-
-
-%define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef
-
-
-/* -----------------------------------------------------------------------------
* Runtime code
* ----------------------------------------------------------------------------- */
diff --git a/Lib/swigwarnings.swg b/Lib/swigwarnings.swg
index 21498ebd3..34c98fbda 100644
--- a/Lib/swigwarnings.swg
+++ b/Lib/swigwarnings.swg
@@ -54,6 +54,7 @@
%define SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG "454:Setting a pointer/reference variable may leak memory." %enddef
%define SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG "470:Thread/reentrant unsafe wrapping, consider returning by value instead." %enddef
%define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG "473:Returning a pointer or reference in a director method is not recommended." %enddef
+%define SWIGWARN_TYPEMAP_INITIALIZER_LIST_MSG "476:Initialization using std::initializer_list." %enddef
/* -----------------------------------------------------------------------------
* Operator related warning messages
diff --git a/Lib/tcl/tcltypemaps.swg b/Lib/tcl/tcltypemaps.swg
index 2b4e06e9d..ad31bcfc9 100644
--- a/Lib/tcl/tcltypemaps.swg
+++ b/Lib/tcl/tcltypemaps.swg
@@ -66,7 +66,7 @@
#if 1
// Old 1.3.25 typemaps needed to avoid premature object deletion
-%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] {
+%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE &&INSTANCE, SWIGTYPE INSTANCE[] {
Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1), $1_descriptor,0));
}
@@ -86,5 +86,6 @@
%typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE;
%typemap(out) SWIGTYPE *const = SWIGTYPE *;
%typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE;
+%typemap(out) SWIGTYPE && = SWIGTYPE &&INSTANCE;
%typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[];
%typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE;
diff --git a/Lib/typemaps/enumint.swg b/Lib/typemaps/enumint.swg
index 854d6f3e1..d048bb6bf 100644
--- a/Lib/typemaps/enumint.swg
+++ b/Lib/typemaps/enumint.swg
@@ -3,9 +3,20 @@
* ------------------------------------------------------------ */
%apply int { enum SWIGTYPE };
-%apply const int& { const enum SWIGTYPE& };
+%apply const int& { const enum SWIGTYPE & };
+%apply const int& { const enum SWIGTYPE && };
-%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) {
+%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE & (int val, int ecode, $basetype temp) {
+ ecode = SWIG_AsVal(int)($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$type", $symname, $argnum);
+ } else {
+ temp = %static_cast(val,$basetype);
+ $1 = &temp;
+ }
+}
+
+%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE && (int val, int ecode, $basetype temp) {
ecode = SWIG_AsVal(int)($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$type", $symname, $argnum);
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index 4f5e01afa..5e92790d8 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -67,6 +67,41 @@
}
#endif
+/* Rvalue reference */
+%typemap(in, noblock=1) SWIGTYPE && (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg) SWIGTYPE && "";
+
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(in,noblock=1,implicitconv=1) const SWIGTYPE && (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE &&
+{
+ if (SWIG_IsNewObj(res$argnum)) %delete($1);
+}
+#else
+%typemap(in,noblock=1) const SWIGTYPE && (void *argp, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+#endif
+
/* By value */
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(in,implicitconv=1) SWIGTYPE (void *argp, int res = 0) {
@@ -102,7 +137,7 @@
* ----------------------------------------------------------------------------- */
/* Pointers, references */
-%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] {
+%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[] {
%set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags));
}
@@ -235,6 +270,18 @@
$1 = *(%reinterpret_cast(argp, $ltype));
}
+%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE && {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %variable_nullref("$type", "$name");
+ }
+ $1 = *(%reinterpret_cast(argp, $ltype));
+}
+
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(varin,implicitconv=1) SWIGTYPE {
void *argp = 0;
@@ -284,6 +331,10 @@
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
}
+%typemap(varout, noblock=1) SWIGTYPE && {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
+}
+
/* Value */
%typemap(varout, noblock=1) SWIGTYPE {
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags));
@@ -311,12 +362,23 @@
$1 = SWIG_CheckState(res);
}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ $1 = SWIG_CheckState(res);
+}
+
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & {
int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag);
$1 = SWIG_CheckState(res);
}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag);
+ $1 = SWIG_CheckState(res);
+}
+
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE {
int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag);
$1 = SWIG_CheckState(res);
@@ -327,6 +389,11 @@
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
$1 = SWIG_CheckState(res);
}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ $1 = SWIG_CheckState(res);
+}
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE {
void *vptr = 0;
@@ -355,6 +422,10 @@
$input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags);
}
+%typemap(directorin,noblock=1) SWIGTYPE && {
+ $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
+}
+
/* directorout */
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) {
@@ -406,6 +477,22 @@
}
}
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ SWIGTYPE &&(void *swig_argp, int swig_res, swig_owntype own) {
+ swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ if (!swig_argp) { %dirout_nullref("$type"); }
+ $result = %reinterpret_cast(swig_argp, $ltype);
+ swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */);
+}
+%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE && {
+ if (director) {
+ SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
+ }
+}
+
#endif /* SWIG_DIRECTOR_TYPEMAPS */
@@ -413,7 +500,7 @@
* --- Constants ---
* ------------------------------------------------------------ */
-%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
%set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags));
}
@@ -441,6 +528,10 @@
%raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
}
+%typemap(throws,noblock=1) SWIGTYPE && {
+ %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
+}
+
%typemap(throws,noblock=1) (...) {
SWIG_exception_fail(SWIG_RuntimeError,"unknown exception");
}
diff --git a/Makefile.in b/Makefile.in
index c7972832c..9db1a7efc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -22,6 +22,7 @@ TARGET = $(TARGET_NOEXE)@EXEEXT@
SOURCE = Source
CCACHE = CCache
DOCS = Doc/Manual
+HAVE_CXX11_COMPILER = @HAVE_CXX11_COMPILER@
RUNPIPE = \>/dev/null
swig: libfiles source ccache
@@ -278,7 +279,7 @@ check-%-test-suite:
echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\
else \
echo $(ACTION)ing $* test-suite; \
- (cd $$dir && $(MAKE) -k -s $(ACTION)) \
+ (cd $$dir && $(MAKE) -k -s $(ACTION) HAVE_CXX11_COMPILER=$(HAVE_CXX11_COMPILER)) \
|| passed=false; \
fi; \
test $$passed = true
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index 791cf5949..e91dfb3d3 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -246,6 +246,8 @@ static int yylook(void) {
return GREATERTHANOREQUALTO;
case SWIG_TOKEN_RSHIFT:
return RSHIFT;
+ case SWIG_TOKEN_ARROW:
+ return ARROW;
case SWIG_TOKEN_PERIOD:
return PERIOD;
case SWIG_TOKEN_MODULO:
@@ -283,6 +285,10 @@ static int yylook(void) {
case SWIG_TOKEN_STRING:
yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
return STRING;
+
+ case SWIG_TOKEN_WSTRING:
+ yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
+ return WSTRING;
case SWIG_TOKEN_CHAR:
yylval.str = NewString(Scanner_text(scan));
@@ -291,7 +297,15 @@ static int yylook(void) {
Printf(stdout,"%d\n", Len(Scanner_text(scan)));
}
return CHARCONST;
-
+
+ case SWIG_TOKEN_WCHAR:
+ yylval.str = NewString(Scanner_text(scan));
+ if (Len(yylval.str) == 0) {
+ Swig_error(cparse_file, cparse_line, "Empty character constant\n");
+ Printf(stdout,"%d\n", Len(Scanner_text(scan)));
+ }
+ return WCHARCONST;
+
/* Numbers */
case SWIG_TOKEN_INT:
@@ -542,8 +556,16 @@ int yylex(void) {
return (PROTECTED);
if (strcmp(yytext, "friend") == 0)
return (FRIEND);
+ if (strcmp(yytext, "constexpr") == 0)
+ return (CONSTEXPR);
+ if (strcmp(yytext, "thread_local") == 0)
+ return (THREAD_LOCAL);
+ if (strcmp(yytext, "decltype") == 0)
+ return (DECLTYPE);
if (strcmp(yytext, "virtual") == 0)
return (VIRTUAL);
+ if (strcmp(yytext, "static_assert") == 0)
+ return (STATIC_ASSERT);
if (strcmp(yytext, "operator") == 0) {
int nexttok;
String *s = NewString("operator ");
@@ -592,6 +614,11 @@ int yylex(void) {
yylval.str = s;
return OPERATOR;
}
+ } else if (nexttok == SWIG_TOKEN_STRING) {
+ /* Operator "" or user-defined string literal ""_suffix */
+ Append(s,"\"\"");
+ yylval.str = s;
+ return OPERATOR;
} else if (nexttok == SWIG_TOKEN_ID) {
/* We have an identifier. This could be any number of things. It could be a named version of
an operator (e.g., 'and_eq') or it could be a conversion operator. To deal with this, we're
@@ -688,6 +715,8 @@ int yylex(void) {
return (yylex());
if (strcmp(yytext, "explicit") == 0)
return (EXPLICIT);
+ if (strcmp(yytext, "auto") == 0)
+ return (AUTO);
if (strcmp(yytext, "export") == 0)
return (yylex());
if (strcmp(yytext, "typename") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 92c518e1f..ce0c91c43 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -13,8 +13,13 @@
* some point. Beware.
* ----------------------------------------------------------------------------- */
-%{
+/*
+Removed until we know more about the min versions of Bison and Yacc required for this
+to work, see Byacc man page: http://invisible-island.net/byacc/manpage/yacc.html
+%expect 6
+*/
+%{
#define yylex yylex
#include "swig.h"
@@ -1485,8 +1490,9 @@ static void new_feature(const char *featurename, String *val, Hash *featureattri
/* check if a function declaration is a plain C object */
static int is_cfunction(Node *n) {
- if (!cparse_cplusplus || cparse_externc) return 1;
- if (Cmp(Getattr(n,"storage"),"externc") == 0) {
+ if (!cparse_cplusplus || cparse_externc)
+ return 1;
+ if (Swig_storage_isexternc(n)) {
return 1;
}
return 0;
@@ -1690,9 +1696,9 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token <id> ID
%token <str> HBLOCK
%token <id> POUND
-%token <id> STRING
+%token <id> STRING WSTRING
%token <loc> INCLUDE IMPORT INSERT
-%token <str> CHARCONST
+%token <str> CHARCONST WCHARCONST
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
%token <intvalue> TYPEDEF
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
@@ -1702,7 +1708,8 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token ILLEGAL CONSTANT
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
%token ENUM
-%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT
+%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT AUTO
+%token STATIC_ASSERT CONSTEXPR THREAD_LOCAL DECLTYPE /* C++11 keywords */
%token USING
%token <node> NAMESPACE
%token NATIVE INLINE
@@ -1710,6 +1717,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token WARN
%token LESSTHAN GREATERTHAN DELETE_KW
%token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO
+%token ARROW
%token QUESTIONMARK
%token TYPES PARMS
%token NONID DSTAR DCNOT
@@ -1743,28 +1751,29 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <node> types_directive template_directive warn_directive ;
/* C declarations */
-%type <node> c_declaration c_decl c_decl_tail c_enum_decl c_enum_forward_decl c_constructor_decl ;
+%type <node> c_declaration c_decl c_decl_tail c_enum_key c_enum_inherit c_enum_decl c_enum_forward_decl c_constructor_decl;
%type <node> enumlist edecl;
/* C++ declarations */
-%type <node> cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl;
+%type <node> cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl cpp_alternate_rettype;
%type <node> cpp_members cpp_member;
-%type <node> cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator;
+%type <node> cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator cpp_static_assert;
%type <node> cpp_swig_directive cpp_temp_possible cpp_nested cpp_opt_declarators ;
-%type <node> cpp_using_decl cpp_namespace_decl cpp_catch_decl ;
+%type <node> cpp_using_decl cpp_namespace_decl cpp_catch_decl cpp_lambda_decl;
%type <node> kwargs options;
/* Misc */
%type <dtype> initializer cpp_const ;
%type <id> storage_class;
-%type <pl> parms ptail rawparms varargs_parms;
+%type <pl> parms ptail rawparms varargs_parms ;
%type <pl> templateparameters templateparameterstail;
%type <p> parm valparm rawvalparms valparms valptail ;
%type <p> typemap_parm tm_list tm_tail ;
%type <p> templateparameter ;
%type <id> templcpptype cpptype access_specifier;
-%type <node> base_specifier
-%type <type> type rawtype type_right ;
+%type <node> base_specifier;
+%type <str> ellipsis variadic;
+%type <type> type rawtype type_right anon_bitfield_type decltype ;
%type <bases> base_list inherit raw_inherit;
%type <dtype> definetype def_args etype;
%type <dtype> expr exprnum exprcompound valexpr;
@@ -1781,13 +1790,15 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <decl> abstract_declarator direct_abstract_declarator ctor_end;
%type <tmap> typemap_type;
%type <str> idcolon idcolontail idcolonnt idcolontailnt idtemplate stringbrace stringbracesemi;
-%type <id> string stringnum ;
+%type <id> string stringnum wstring;
%type <tparms> template_parms;
%type <dtype> cpp_end cpp_vend;
%type <intvalue> rename_namewarn;
%type <ptype> type_specifier primitive_type_list ;
%type <node> fname stringtype;
%type <node> featattr;
+%type <node> lambda_introducer lambda_body;
+%type <pl> lambda_tail;
%type <node> optional_constant_directive;
%%
@@ -2846,6 +2857,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
Node *n;
Symtab *tscope = 0;
int specialized = 0;
+ int variadic = 0;
$$ = 0;
@@ -2903,11 +2915,13 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
Parm *tparms = Getattr(nn,"templateparms");
if (!tparms) {
specialized = 1;
+ } else if (Getattr(tparms,"variadic") && strncmp(Char(Getattr(tparms,"variadic")), "1", 1)==0) {
+ variadic = 1;
}
- if (nnisclass && !specialized && ((ParmList_len($7) > ParmList_len(tparms)))) {
+ if (nnisclass && !variadic && !specialized && (ParmList_len($7) > ParmList_len(tparms))) {
Swig_error(cparse_file, cparse_line, "Too many template parameters. Maximum of %d.\n", ParmList_len(tparms));
- } else if (nnisclass && !specialized && ((ParmList_len($7) < ParmList_numrequired(tparms)))) {
- Swig_error(cparse_file, cparse_line, "Not enough template parameters specified. %d required.\n", ParmList_numrequired(tparms));
+ } else if (nnisclass && !specialized && ((ParmList_len($7) < (ParmList_numrequired(tparms) - (variadic?1:0))))) { /* Variadic parameter is optional */
+ Swig_error(cparse_file, cparse_line, "Not enough template parameters specified. %d required.\n", (ParmList_numrequired(tparms)-(variadic?1:0)) );
} else if (!nnisclass && ((ParmList_len($7) != ParmList_len(tparms)))) {
/* must be an overloaded templated method - ignore it as it is overloaded with a different number of template parameters */
nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions */
@@ -2966,6 +2980,11 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
if (!p && tp) {
p = tp;
def_supplied = 1;
+ } else if (p && !tp) { /* Variadic template - tp < p */
+ SWIG_WARN_NODE_BEGIN(nn);
+ Swig_warning(WARN_CPP11_VARIADIC_TEMPLATE,cparse_file, cparse_line,"Only the first variadic template argument is currently supported.\n");
+ SWIG_WARN_NODE_END(nn);
+ break;
}
}
@@ -3162,6 +3181,34 @@ c_declaration : c_decl {
appendChild($$,firstChild($5));
}
}
+ | cpp_lambda_decl {
+ $$ = $1;
+ SWIG_WARN_NODE_BEGIN($$);
+ Swig_warning(WARN_CPP11_LAMBDA, cparse_file, cparse_line, "Lambda expressions and closures are not fully supported yet.\n");
+ SWIG_WARN_NODE_END($$);
+ }
+ | USING idcolon EQUAL {
+ skip_decl();
+ $$ = new_node("using");
+ Setattr($$,"name",$2);
+ add_symbols($$);
+ SWIG_WARN_NODE_BEGIN($$);
+ Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line, "The 'using' keyword in type aliasing is not fully supported yet.\n");
+ SWIG_WARN_NODE_END($$);
+
+ $$ = 0; /* TODO - ignored for now */
+ }
+ | TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL {
+ skip_decl();
+ $$ = new_node("using");
+ Setattr($$,"name",$6);
+ add_symbols($$);
+ SWIG_WARN_NODE_BEGIN($$);
+ Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line, "The 'using' keyword in template aliasing is not fully supported yet.\n");
+ SWIG_WARN_NODE_END($$);
+
+ $$ = 0; /* TODO - ignored for now */
+ }
;
/* ------------------------------------------------------------
@@ -3225,6 +3272,61 @@ c_decl : storage_class type declarator initializer c_decl_tail {
set_nextSibling($$,$5);
}
}
+ /* Alternate function syntax introduced in C++11:
+ auto funcName(int x, int y) -> int; */
+ | storage_class AUTO declarator ARROW cpp_alternate_rettype initializer c_decl_tail {
+ $$ = new_node("cdecl");
+ if ($6.qualifier) SwigType_push($3.type,$6.qualifier);
+ Setattr($$,"type",$5);
+ Setattr($$,"storage",$1);
+ Setattr($$,"name",$3.id);
+ Setattr($$,"decl",$3.type);
+ Setattr($$,"parms",$3.parms);
+ Setattr($$,"value",$6.val);
+ Setattr($$,"throws",$6.throws);
+ Setattr($$,"throw",$6.throwf);
+ if (!$7) {
+ if (Len(scanner_ccode)) {
+ String *code = Copy(scanner_ccode);
+ Setattr($$,"code",code);
+ Delete(code);
+ }
+ } else {
+ Node *n = $7;
+ while (n) {
+ String *type = Copy($5);
+ Setattr(n,"type",type);
+ Setattr(n,"storage",$1);
+ n = nextSibling(n);
+ Delete(type);
+ }
+ }
+ if ($6.bitfield) {
+ Setattr($$,"bitfield", $6.bitfield);
+ }
+
+ if (Strstr($3.id,"::")) {
+ String *p = Swig_scopename_prefix($3.id);
+ if (p) {
+ if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) ||
+ (inclass && Strcmp(p,Classprefix) == 0)) {
+ String *lstr = Swig_scopename_last($3.id);
+ Setattr($$,"name",lstr);
+ Delete(lstr);
+ set_nextSibling($$,$7);
+ } else {
+ Delete($$);
+ $$ = $7;
+ }
+ Delete(p);
+ } else {
+ Delete($$);
+ $$ = $7;
+ }
+ } else {
+ set_nextSibling($$,$7);
+ }
+ }
;
/* Allow lists of variables and functions to be built up */
@@ -3287,16 +3389,102 @@ initializer : def_args {
}
;
+cpp_alternate_rettype : primitive_type { $$ = $1; }
+ | TYPE_BOOL { $$ = $1; }
+ | TYPE_VOID { $$ = $1; }
+ | TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
+ | TYPE_RAW { $$ = $1; }
+ | idcolon { $$ = $1; }
+ | decltype { $$ = $1; }
+ ;
/* ------------------------------------------------------------
- enum Name;
+ Lambda functions and expressions, such as:
+ auto myFunc = [] { return something; };
+ auto myFunc = [](int x, int y) { return x+y; };
+ auto myFunc = [](int x, int y) -> int { return x+y; };
+ auto myFunc = [](int x, int y) throw() -> int { return x+y; };
+ auto six = [](int x, int y) { return x+y; }(4, 2);
------------------------------------------------------------ */
+cpp_lambda_decl : storage_class AUTO idcolon EQUAL lambda_introducer LPAREN parms RPAREN cpp_const lambda_body lambda_tail {
+ $$ = new_node("lambda");
+ Setattr($$,"name",$3);
+ add_symbols($$);
+ }
+ | storage_class AUTO idcolon EQUAL lambda_introducer LPAREN parms RPAREN cpp_const ARROW type lambda_body lambda_tail {
+ $$ = new_node("lambda");
+ Setattr($$,"name",$3);
+ add_symbols($$);
+ }
+ | storage_class AUTO idcolon EQUAL lambda_introducer lambda_body lambda_tail {
+ $$ = new_node("lambda");
+ Setattr($$,"name",$3);
+ add_symbols($$);
+ }
+ ;
-c_enum_forward_decl : storage_class ENUM ID SEMI {
+lambda_introducer : LBRACKET {
+ skip_balanced('[',']');
+ $$ = 0;
+ }
+ ;
+
+lambda_body : LBRACE {
+ skip_balanced('{','}');
+ $$ = 0;
+ }
+
+lambda_tail : SEMI {
+ $$ = 0;
+ }
+ | LPAREN {
+ skip_balanced('(',')');
+ } SEMI {
+ $$ = 0;
+ }
+ ;
+
+/* ------------------------------------------------------------
+ enum
+ or
+ enum class
+ ------------------------------------------------------------ */
+
+c_enum_key : ENUM {
+ $$ = (char *)"enum";
+ }
+ | ENUM CLASS {
+ $$ = (char *)"enum class";
+ }
+ | ENUM STRUCT {
+ $$ = (char *)"enum struct";
+ }
+ ;
+
+/* ------------------------------------------------------------
+ base enum type (eg. unsigned short)
+ ------------------------------------------------------------ */
+
+c_enum_inherit : COLON type_right {
+ $$ = $2;
+ }
+ | empty { $$ = 0; }
+ ;
+/* ------------------------------------------------------------
+ enum [class] Name;
+ enum [class] Name [: base_type];
+ ------------------------------------------------------------ */
+
+c_enum_forward_decl : storage_class c_enum_key ename c_enum_inherit SEMI {
SwigType *ty = 0;
+ int scopedenum = $3 && !Equal($2, "enum");
$$ = new_node("enumforward");
ty = NewStringf("enum %s", $3);
+ Setattr($$,"enumkey",$2);
+ if (scopedenum)
+ SetFlag($$, "scopedenum");
Setattr($$,"name",$3);
+ Setattr($$,"inherit",$4);
Setattr($$,"type",ty);
Setattr($$,"sym:weak", "1");
add_symbols($$);
@@ -3304,52 +3492,78 @@ c_enum_forward_decl : storage_class ENUM ID SEMI {
;
/* ------------------------------------------------------------
- enum { ... }
+ enum [class] Name [: base_type] { ... };
+ or
+ enum [class] Name [: base_type] { ... } MyEnum [= ...];
* ------------------------------------------------------------ */
-c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI {
+c_enum_decl : storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBRACE SEMI {
SwigType *ty = 0;
+ int scopedenum = $3 && !Equal($2, "enum");
$$ = new_node("enum");
ty = NewStringf("enum %s", $3);
+ Setattr($$,"enumkey",$2);
+ if (scopedenum)
+ SetFlag($$, "scopedenum");
Setattr($$,"name",$3);
+ Setattr($$,"inherit",$4);
Setattr($$,"type",ty);
- appendChild($$,$5);
- add_symbols($$); /* Add to tag space */
- add_symbols($5); /* Add enum values to id space */
+ appendChild($$,$6);
+ add_symbols($$); /* Add to tag space */
+
+ if (scopedenum) {
+ Swig_symbol_newscope();
+ Swig_symbol_setscopename($3);
+ Delete(Namespaceprefix);
+ Namespaceprefix = Swig_symbol_qualifiedscopename(0);
+ }
+
+ add_symbols($6); /* Add enum values to appropriate enum or enum class scope */
+
+ if (scopedenum) {
+ Setattr($$,"symtab", Swig_symbol_popscope());
+ Delete(Namespaceprefix);
+ Namespaceprefix = Swig_symbol_qualifiedscopename(0);
+ }
}
- | storage_class ENUM ename LBRACE enumlist RBRACE declarator initializer c_decl_tail {
+ | storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBRACE declarator initializer c_decl_tail {
Node *n;
SwigType *ty = 0;
String *unnamed = 0;
int unnamedinstance = 0;
+ int scopedenum = $3 && !Equal($2, "enum");
$$ = new_node("enum");
+ Setattr($$,"enumkey",$2);
+ if (scopedenum)
+ SetFlag($$, "scopedenum");
+ Setattr($$,"inherit",$4);
if ($3) {
Setattr($$,"name",$3);
ty = NewStringf("enum %s", $3);
- } else if ($7.id) {
+ } else if ($8.id) {
unnamed = make_unnamed();
ty = NewStringf("enum %s", unnamed);
Setattr($$,"unnamed",unnamed);
/* name is not set for unnamed enum instances, e.g. enum { foo } Instance; */
if ($1 && Cmp($1,"typedef") == 0) {
- Setattr($$,"name",$7.id);
+ Setattr($$,"name",$8.id);
} else {
unnamedinstance = 1;
}
Setattr($$,"storage",$1);
}
- if ($7.id && Cmp($1,"typedef") == 0) {
- Setattr($$,"tdname",$7.id);
+ if ($8.id && Cmp($1,"typedef") == 0) {
+ Setattr($$,"tdname",$8.id);
Setattr($$,"allows_typedef","1");
}
- appendChild($$,$5);
+ appendChild($$,$6);
n = new_node("cdecl");
Setattr(n,"type",ty);
- Setattr(n,"name",$7.id);
+ Setattr(n,"name",$8.id);
Setattr(n,"storage",$1);
- Setattr(n,"decl",$7.type);
- Setattr(n,"parms",$7.parms);
+ Setattr(n,"decl",$8.type);
+ Setattr(n,"parms",$8.parms);
Setattr(n,"unnamed",unnamed);
if (unnamedinstance) {
@@ -3359,8 +3573,8 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI {
SetFlag(n,"unnamedinstance");
Delete(cty);
}
- if ($9) {
- Node *p = $9;
+ if ($10) {
+ Node *p = $10;
set_nextSibling(n,p);
while (p) {
SwigType *cty = Copy(ty);
@@ -3380,8 +3594,8 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI {
/* Ensure that typedef enum ABC {foo} XYZ; uses XYZ for sym:name, like structs.
* Note that class_rename/yyrename are bit of a mess so used this simple approach to change the name. */
- if ($7.id && $3 && Cmp($1,"typedef") == 0) {
- String *name = NewString($7.id);
+ if ($8.id && $3 && Cmp($1,"typedef") == 0) {
+ String *name = NewString($8.id);
Setattr($$, "parser:makename", name);
Delete(name);
}
@@ -3389,7 +3603,22 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI {
add_symbols($$); /* Add enum to tag space */
set_nextSibling($$,n);
Delete(n);
- add_symbols($5); /* Add enum values to id space */
+
+ if (scopedenum) {
+ Swig_symbol_newscope();
+ Swig_symbol_setscopename($3);
+ Delete(Namespaceprefix);
+ Namespaceprefix = Swig_symbol_qualifiedscopename(0);
+ }
+
+ add_symbols($6); /* Add enum values to appropriate enum or enum class scope */
+
+ if (scopedenum) {
+ Setattr($$,"symtab", Swig_symbol_popscope());
+ Delete(Namespaceprefix);
+ Namespaceprefix = Swig_symbol_qualifiedscopename(0);
+ }
+
add_symbols(n);
Delete(unnamed);
}
@@ -4147,10 +4376,18 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN {
template_parameters = 0;
if (inclass)
nested_template--;
- }
+ }
+
+ /* Explicit template instantiation */
| TEMPLATE cpptype idcolon {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
- $$ = 0;
+ $$ = 0;
+ }
+
+ /* Explicit template instantiation without the translation unit */
+ | EXTERN TEMPLATE cpptype idcolon {
+ Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
+ $$ = 0;
}
;
@@ -4163,6 +4400,9 @@ cpp_temp_possible: c_decl {
| cpp_constructor_decl {
$$ = $1;
}
+ | cpp_static_assert {
+ $$ = $1;
+ }
| cpp_template_decl {
$$ = 0;
}
@@ -4191,6 +4431,12 @@ template_parms : templateparameters {
if ((strncmp(type,"class ",6) == 0) || (strncmp(type,"typename ", 9) == 0)) {
char *t = strchr(type,' ');
Setattr(p,"name", t+1);
+ } else
+ /* Variadic template args */
+ if ((strncmp(type,"class... ",9) == 0) || (strncmp(type,"typename... ", 12) == 0)) {
+ char *t = strchr(type,' ');
+ Setattr(p,"name", t+1);
+ Setattr(p,"variadic", "1");
} else {
/*
Swig_error(cparse_file, cparse_line, "Missing template parameter name\n");
@@ -4409,6 +4655,7 @@ cpp_member : c_declaration { $$ = $1; }
default_arguments($$);
}
| cpp_destructor_decl { $$ = $1; }
+ | cpp_static_assert { $$ = $1; }
| cpp_protection_decl { $$ = $1; }
| cpp_swig_directive { $$ = $1; }
| cpp_conversion_operator { $$ = $1; }
@@ -4434,21 +4681,21 @@ cpp_member : c_declaration { $$ = $1; }
cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
if (Classprefix) {
- SwigType *decl = NewStringEmpty();
- $$ = new_node("constructor");
- Setattr($$,"storage",$1);
- Setattr($$,"name",$2);
- Setattr($$,"parms",$4);
- SwigType_add_function(decl,$4);
- Setattr($$,"decl",decl);
- Setattr($$,"throws",$6.throws);
- Setattr($$,"throw",$6.throwf);
- if (Len(scanner_ccode)) {
- String *code = Copy(scanner_ccode);
- Setattr($$,"code",code);
- Delete(code);
- }
- SetFlag($$,"feature:new");
+ SwigType *decl = NewStringEmpty();
+ $$ = new_node("constructor");
+ Setattr($$,"storage",$1);
+ Setattr($$,"name",$2);
+ Setattr($$,"parms",$4);
+ SwigType_add_function(decl,$4);
+ Setattr($$,"decl",decl);
+ Setattr($$,"throws",$6.throws);
+ Setattr($$,"throw",$6.throwf);
+ if (Len(scanner_ccode)) {
+ String *code = Copy(scanner_ccode);
+ Setattr($$,"code",code);
+ Delete(code);
+ }
+ SetFlag($$,"feature:new");
} else {
$$ = 0;
}
@@ -4544,6 +4791,23 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
Setattr($$,"conversion_operator","1");
add_symbols($$);
}
+ | storage_class COPERATOR type LAND LPAREN parms RPAREN cpp_vend {
+ SwigType *decl;
+ $$ = new_node("cdecl");
+ Setattr($$,"type",$3);
+ Setattr($$,"name",$2);
+ Setattr($$,"storage",$1);
+ decl = NewStringEmpty();
+ SwigType_add_rvalue_reference(decl);
+ SwigType_add_function(decl,$6);
+ if ($8.qualifier) {
+ SwigType_push(decl,$8.qualifier);
+ }
+ Setattr($$,"decl",decl);
+ Setattr($$,"parms",$6);
+ Setattr($$,"conversion_operator","1");
+ add_symbols($$);
+ }
| storage_class COPERATOR type pointer AND LPAREN parms RPAREN cpp_vend {
SwigType *decl;
@@ -4589,6 +4853,13 @@ cpp_catch_decl : CATCH LPAREN parms RPAREN LBRACE {
}
;
+/* static_assert(bool, const char*); */
+cpp_static_assert : STATIC_ASSERT LPAREN {
+ skip_balanced('(',')');
+ $$ = 0;
+ }
+ ;
+
/* public: */
cpp_protection_decl : PUBLIC COLON {
$$ = new_node("access");
@@ -4748,16 +5019,42 @@ cpp_vend : cpp_const SEMI {
;
-anonymous_bitfield : storage_class type COLON expr SEMI { };
+anonymous_bitfield : storage_class anon_bitfield_type COLON expr SEMI { };
+
+/* Equals type_right without the ENUM keyword and cpptype (templates etc.): */
+anon_bitfield_type : primitive_type { $$ = $1;
+ /* Printf(stdout,"primitive = '%s'\n", $$);*/
+ }
+ | TYPE_BOOL { $$ = $1; }
+ | TYPE_VOID { $$ = $1; }
+ | TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
+ | TYPE_RAW { $$ = $1; }
+
+ | idcolon {
+ $$ = $1;
+ }
+ ;
/* ======================================================================
* PRIMITIVES
* ====================================================================== */
storage_class : EXTERN { $$ = "extern"; }
- | EXTERN string {
+ | EXTERN string {
if (strcmp($2,"C") == 0) {
$$ = "externc";
+ } else if (strcmp($2,"C++") == 0) {
+ $$ = "extern";
+ } else {
+ Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
+ $$ = 0;
+ }
+ }
+ | EXTERN string THREAD_LOCAL {
+ if (strcmp($2,"C") == 0) {
+ $$ = "externc thread_local";
+ } else if (strcmp($2,"C++") == 0) {
+ $$ = "extern thread_local";
} else {
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
$$ = 0;
@@ -4768,6 +5065,12 @@ storage_class : EXTERN { $$ = "extern"; }
| VIRTUAL { $$ = "virtual"; }
| FRIEND { $$ = "friend"; }
| EXPLICIT { $$ = "explicit"; }
+ | CONSTEXPR { $$ = "constexpr"; }
+ | THREAD_LOCAL { $$ = "thread_local"; }
+ | THREAD_LOCAL STATIC { $$ = "static thread_local"; }
+ | STATIC THREAD_LOCAL { $$ = "static thread_local"; }
+ | EXTERN THREAD_LOCAL { $$ = "extern thread_local"; }
+ | THREAD_LOCAL EXTERN { $$ = "extern thread_local"; }
| empty { $$ = 0; }
;
@@ -4918,7 +5221,7 @@ def_args : EQUAL definetype {
}
| EQUAL LBRACE {
skip_balanced('{','}');
- $$.val = 0;
+ $$.val = NewString(scanner_ccode);
$$.rawval = 0;
$$.type = T_INT;
$$.bitfield = 0;
@@ -5017,11 +5320,20 @@ declarator : pointer notso_direct_declarator {
}
$$.type = $1;
}
+ | pointer LAND notso_direct_declarator {
+ $$ = $3;
+ SwigType_add_rvalue_reference($1);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
| direct_declarator {
$$ = $1;
if (!$$.type) $$.type = NewStringEmpty();
}
- | AND notso_direct_declarator {
+ | AND notso_direct_declarator {
$$ = $2;
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
@@ -5030,6 +5342,17 @@ declarator : pointer notso_direct_declarator {
Delete($2.type);
}
}
+ | LAND notso_direct_declarator {
+ /* Introduced in C++11, move operator && */
+ /* Adds one S/R conflict */
+ $$ = $2;
+ $$.type = NewStringEmpty();
+ SwigType_add_rvalue_reference($$.type);
+ if ($2.type) {
+ SwigType_push($$.type,$2.type);
+ Delete($2.type);
+ }
+ }
| idcolon DSTAR notso_direct_declarator {
SwigType *t = NewStringEmpty();
@@ -5074,6 +5397,124 @@ declarator : pointer notso_direct_declarator {
}
$$.type = t;
}
+
+ /* Variadic versions eg. MyClasses&... myIds */
+
+ | pointer PERIOD PERIOD PERIOD notso_direct_declarator {
+ $$ = $5;
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
+ | pointer AND PERIOD PERIOD PERIOD notso_direct_declarator {
+ $$ = $6;
+ SwigType_add_reference($1);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
+ | pointer LAND PERIOD PERIOD PERIOD notso_direct_declarator {
+ $$ = $6;
+ SwigType_add_rvalue_reference($1);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
+ | PERIOD PERIOD PERIOD direct_declarator {
+ $$ = $4;
+ if (!$$.type) $$.type = NewStringEmpty();
+ }
+ | AND PERIOD PERIOD PERIOD notso_direct_declarator {
+ $$ = $5;
+ $$.type = NewStringEmpty();
+ SwigType_add_reference($$.type);
+ if ($5.type) {
+ SwigType_push($$.type,$5.type);
+ Delete($5.type);
+ }
+ }
+ | LAND PERIOD PERIOD PERIOD notso_direct_declarator {
+ /* Introduced in C++11, move operator && */
+ /* Adds one S/R conflict */
+ $$ = $5;
+ $$.type = NewStringEmpty();
+ SwigType_add_rvalue_reference($$.type);
+ if ($5.type) {
+ SwigType_push($$.type,$5.type);
+ Delete($5.type);
+ }
+ }
+ | idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator {
+ SwigType *t = NewStringEmpty();
+
+ $$ = $6;
+ SwigType_add_memberpointer(t,$1);
+ if ($$.type) {
+ SwigType_push(t,$$.type);
+ Delete($$.type);
+ }
+ $$.type = t;
+ }
+ | pointer idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator {
+ SwigType *t = NewStringEmpty();
+ $$ = $7;
+ SwigType_add_memberpointer(t,$2);
+ SwigType_push($1,t);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ Delete(t);
+ }
+ | pointer idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
+ $$ = $8;
+ SwigType_add_memberpointer($1,$2);
+ SwigType_add_reference($1);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
+ | pointer idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
+ $$ = $8;
+ SwigType_add_memberpointer($1,$2);
+ SwigType_add_rvalue_reference($1);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
+ | idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
+ SwigType *t = NewStringEmpty();
+ $$ = $7;
+ SwigType_add_memberpointer(t,$1);
+ SwigType_add_reference(t);
+ if ($$.type) {
+ SwigType_push(t,$$.type);
+ Delete($$.type);
+ }
+ $$.type = t;
+ }
+ | idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
+ SwigType *t = NewStringEmpty();
+ $$ = $7;
+ SwigType_add_memberpointer(t,$1);
+ SwigType_add_rvalue_reference(t);
+ if ($$.type) {
+ SwigType_push(t,$$.type);
+ Delete($$.type);
+ }
+ $$.type = t;
+ }
;
notso_direct_declarator : idcolon {
@@ -5174,7 +5615,7 @@ direct_declarator : idcolon {
$$.parms = 0;
$$.have_parms = 0;
}
-
+
| NOT idcolon {
$$.id = Char(NewStringf("~%s",$2));
$$.type = 0;
@@ -5207,6 +5648,13 @@ direct_declarator : idcolon {
}
SwigType_add_reference($$.type);
}
+ | LPAREN LAND direct_declarator RPAREN {
+ $$ = $3;
+ if (!$$.type) {
+ $$.type = NewStringEmpty();
+ }
+ SwigType_add_rvalue_reference($$.type);
+ }
| LPAREN idcolon DSTAR direct_declarator RPAREN {
SwigType *t;
$$ = $4;
@@ -5256,6 +5704,28 @@ direct_declarator : idcolon {
Delete($$.type);
$$.type = t;
}
+ }
+ /* User-defined string literals. eg.
+ int operator"" _mySuffix(const char* val, int length) {...} */
+ /* This produces one S/R conflict. */
+ | OPERATOR ID LPAREN parms RPAREN {
+ SwigType *t;
+ Append($1, " "); /* intervening space is mandatory */
+ Append($1, Char($2));
+ $$.id = Char($1);
+ t = NewStringEmpty();
+ SwigType_add_function(t,$4);
+ if (!$$.have_parms) {
+ $$.parms = $4;
+ $$.have_parms = 1;
+ }
+ if (!$$.type) {
+ $$.type = t;
+ } else {
+ SwigType_push(t, $$.type);
+ Delete($$.type);
+ $$.type = t;
+ }
}
;
@@ -5278,6 +5748,13 @@ abstract_declarator : pointer {
$$.parms = 0;
$$.have_parms = 0;
}
+ | pointer LAND {
+ $$.type = $1;
+ SwigType_add_rvalue_reference($$.type);
+ $$.id = 0;
+ $$.parms = 0;
+ $$.have_parms = 0;
+ }
| pointer AND direct_abstract_declarator {
$$ = $3;
SwigType_add_reference($1);
@@ -5287,6 +5764,15 @@ abstract_declarator : pointer {
}
$$.type = $1;
}
+ | pointer LAND direct_abstract_declarator {
+ $$ = $3;
+ SwigType_add_rvalue_reference($1);
+ if ($$.type) {
+ SwigType_push($1,$$.type);
+ Delete($$.type);
+ }
+ $$.type = $1;
+ }
| direct_abstract_declarator {
$$ = $1;
}
@@ -5299,13 +5785,29 @@ abstract_declarator : pointer {
Delete($2.type);
}
}
- | AND {
+ | LAND direct_abstract_declarator {
+ $$ = $2;
+ $$.type = NewStringEmpty();
+ SwigType_add_rvalue_reference($$.type);
+ if ($2.type) {
+ SwigType_push($$.type,$2.type);
+ Delete($2.type);
+ }
+ }
+ | AND {
$$.id = 0;
$$.parms = 0;
$$.have_parms = 0;
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
}
+ | LAND {
+ $$.id = 0;
+ $$.parms = 0;
+ $$.have_parms = 0;
+ $$.type = NewStringEmpty();
+ SwigType_add_rvalue_reference($$.type);
+ }
| idcolon DSTAR {
$$.type = NewStringEmpty();
SwigType_add_memberpointer($$.type,$1);
@@ -5470,7 +5972,7 @@ type_right : primitive_type { $$ = $1;
| TYPE_BOOL { $$ = $1; }
| TYPE_VOID { $$ = $1; }
| TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
- | ENUM idcolon { $$ = NewStringf("enum %s", $2); }
+ | c_enum_key idcolon { $$ = NewStringf("enum %s", $2); }
| TYPE_RAW { $$ = $1; }
| idcolon {
@@ -5479,6 +5981,19 @@ type_right : primitive_type { $$ = $1;
| cpptype idcolon {
$$ = NewStringf("%s %s", $1, $2);
}
+ | decltype {
+ $$ = $1;
+ }
+ ;
+
+decltype : DECLTYPE LPAREN idcolon RPAREN {
+ Node *n = Swig_symbol_clookup($3,0);
+ if (!n) {
+ Swig_error(cparse_file, cparse_line, "Identifier %s not defined.\n", $3);
+ } else {
+ $$ = Getattr(n, "type");
+ }
+ }
;
primitive_type : primitive_type_list {
@@ -5625,7 +6140,7 @@ definetype : { /* scanner_check_typedef(); */ } expr {
$$ = $2;
if ($$.type == T_STRING) {
$$.rawval = NewStringf("\"%(escape)s\"",$$.val);
- } else if ($$.type != T_CHAR) {
+ } else if ($$.type != T_CHAR && $$.type != T_WSTRING && $$.type != T_WCHAR) {
$$.rawval = 0;
}
$$.bitfield = 0;
@@ -5739,7 +6254,17 @@ valexpr : exprnum { $$ = $1; }
$$.val = NewStringf("sizeof(%s)",SwigType_str($3,0));
$$.type = T_ULONG;
}
+ | SIZEOF PERIOD PERIOD PERIOD LPAREN type parameter_declarator RPAREN {
+ SwigType_push($6,$7.type);
+ $$.val = NewStringf("sizeof...(%s)",SwigType_str($6,0));
+ $$.type = T_ULONG;
+ }
| exprcompound { $$ = $1; }
+ | wstring {
+ $$.val = NewString($1);
+ $$.rawval = NewStringf("L\"%s\"", $$.val);
+ $$.type = T_WSTRING;
+ }
| CHARCONST {
$$.val = NewString($1);
if (Len($$.val)) {
@@ -5752,6 +6277,18 @@ valexpr : exprnum { $$ = $1; }
$$.throws = 0;
$$.throwf = 0;
}
+ | WCHARCONST {
+ $$.val = NewString($1);
+ if (Len($$.val)) {
+ $$.rawval = NewStringf("L\'%s\'", $$.val);
+ } else {
+ $$.rawval = NewString("L'\\0'");
+ }
+ $$.type = T_WCHAR;
+ $$.bitfield = 0;
+ $$.throws = 0;
+ $$.throwf = 0;
+ }
/* grouping */
| LPAREN expr RPAREN %prec CAST {
@@ -5792,6 +6329,13 @@ valexpr : exprnum { $$ = $1; }
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val);
}
}
+ | LPAREN expr LAND RPAREN expr %prec CAST {
+ $$ = $5;
+ if ($5.type != T_STRING) {
+ SwigType_add_rvalue_reference($2.val);
+ $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val);
+ }
+ }
| LPAREN expr pointer AND RPAREN expr %prec CAST {
$$ = $6;
if ($6.type != T_STRING) {
@@ -5800,10 +6344,22 @@ valexpr : exprnum { $$ = $1; }
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $6.val);
}
}
+ | LPAREN expr pointer LAND RPAREN expr %prec CAST {
+ $$ = $6;
+ if ($6.type != T_STRING) {
+ SwigType_push($2.val,$3);
+ SwigType_add_rvalue_reference($2.val);
+ $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $6.val);
+ }
+ }
| AND expr {
$$ = $2;
$$.val = NewStringf("&%s",$2.val);
}
+ | LAND expr {
+ $$ = $2;
+ $$.val = NewStringf("&&%s",$2.val);
+ }
| STAR expr {
$$ = $2;
$$.val = NewStringf("*%s",$2.val);
@@ -5932,6 +6488,19 @@ exprcompound : expr PLUS expr {
}
;
+ellipsis : PERIOD PERIOD PERIOD {
+ $$ = NewString("...");
+ }
+ ;
+
+variadic : ellipsis {
+ $$ = $1;
+ }
+ | empty {
+ $$ = 0;
+ }
+ ;
+
inherit : raw_inherit {
$$ = $1;
}
@@ -5969,7 +6538,7 @@ base_list : base_specifier {
base_specifier : opt_virtual {
$<intvalue>$ = cparse_line;
- } idcolon {
+ } idcolon variadic {
$$ = NewHash();
Setfile($$,cparse_file);
Setline($$,$<intvalue>2);
@@ -5982,10 +6551,12 @@ base_specifier : opt_virtual {
} else {
Setattr($$,"access","public");
}
+ if ($4)
+ SetFlag($$, "variadic");
}
| opt_virtual access_specifier {
$<intvalue>$ = cparse_line;
- } opt_virtual idcolon {
+ } opt_virtual idcolon variadic {
$$ = NewHash();
Setfile($$,cparse_file);
Setline($$,$<intvalue>3);
@@ -5996,6 +6567,8 @@ base_specifier : opt_virtual {
if (Strcmp($2,"public") != 0) {
Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
}
+ if ($6)
+ SetFlag($$, "variadic");
}
;
@@ -6013,6 +6586,14 @@ templcpptype : CLASS {
$$ = (char *)"typename";
if (!inherit_list) last_cpptype = $$;
}
+ | CLASS PERIOD PERIOD PERIOD {
+ $$ = (char *)"class...";
+ if (!inherit_list) last_cpptype = $$;
+ }
+ | TYPENAME PERIOD PERIOD PERIOD {
+ $$ = (char *)"typename...";
+ if (!inherit_list) last_cpptype = $$;
+ }
;
cpptype : templcpptype {
@@ -6098,12 +6679,26 @@ ctor_initializer : COLON mem_initializer_list
mem_initializer_list : mem_initializer
| mem_initializer_list COMMA mem_initializer
+ | mem_initializer PERIOD PERIOD PERIOD
+ | mem_initializer_list COMMA mem_initializer PERIOD PERIOD PERIOD
;
mem_initializer : idcolon LPAREN {
- skip_balanced('(',')');
- Clear(scanner_ccode);
- }
+ skip_balanced('(',')');
+ Clear(scanner_ccode);
+ }
+ /* Uniform initialization in C++11.
+ Example:
+ struct MyStruct {
+ MyStruct(int x, double y) : x_{x}, y_{y} {}
+ int x_;
+ double y_;
+ };
+ */
+ | idcolon LBRACE {
+ skip_balanced('{','}');
+ Clear(scanner_ccode);
+ }
;
template_decl : LESSTHAN valparms GREATERTHAN {
@@ -6122,7 +6717,7 @@ idstring : ID { $$ = $1; }
idstringopt : idstring { $$ = $1; }
| empty { $$ = 0; }
;
-
+
idcolon : idtemplate idcolontail {
$$ = 0;
if (!$$) $$ = NewStringf("%s%s", $1,$2);
@@ -6134,7 +6729,7 @@ idcolon : idtemplate idcolontail {
}
| idtemplate {
$$ = NewString($1);
- }
+ }
| NONID DCOLON idtemplate {
$$ = NewStringf("::%s",$3);
}
@@ -6221,6 +6816,21 @@ string : string STRING {
}
| STRING { $$ = $1;}
;
+/* Concatenated wide strings: L"str1" L"str2" */
+wstring : wstring WSTRING {
+ $$ = (char *) malloc(strlen($1)+strlen($2)+1);
+ strcpy($$,$1);
+ strcat($$,$2);
+ }
+/* Concatenated wide string and normal string literal: L"str1" "str2" */
+/*not all the compilers support this concatenation mode, so perhaps better to postpone it*/
+ /*| wstring STRING { here $2 comes unescaped, we have to escape it back first via NewStringf("%(escape)s)"
+ $$ = (char *) malloc(strlen($1)+strlen($2)+1);
+ strcpy($$,$1);
+ strcat($$,$2);
+ }*/
+ | WSTRING { $$ = $1;}
+ ;
stringbrace : string {
$$ = NewString($1);
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index daf8b1791..4856d9e44 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -91,6 +91,11 @@
#define WARN_PARSE_NAMED_NESTED_CLASS 325
#define WARN_PARSE_EXTEND_NAME 326
+#define WARN_CPP11_LAMBDA 340
+#define WARN_CPP11_ALIAS_DECLARATION 341
+#define WARN_CPP11_ALIAS_TEMPLATE 342
+#define WARN_CPP11_VARIADIC_TEMPLATE 343
+
#define WARN_IGNORE_OPERATOR_NEW 350 /* new */
#define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */
#define WARN_IGNORE_OPERATOR_PLUS 352 /* + */
@@ -170,6 +175,7 @@
#define WARN_TYPEMAP_DIRECTOROUT_PTR 473
#define WARN_TYPEMAP_OUT_OPTIMAL_IGNORED 474
#define WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE 475
+#define WARN_TYPEMAP_INITIALIZER_LIST 476
/* -- Fragments -- */
#define WARN_FRAGMENT_NOT_FOUND 490
diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
index 5320d9689..dee044bf3 100644
--- a/Source/Modules/allocate.cxx
+++ b/Source/Modules/allocate.cxx
@@ -771,7 +771,7 @@ Allocate():
/* Check to see if this is a static member or not. If so, we add an attribute
cplus:staticbase that saves the current class */
- if (checkAttribute(n, "storage", "static")) {
+ if (Swig_storage_isstatic(n)) {
Setattr(n, "cplus:staticbase", inclass);
}
diff --git a/Source/Modules/browser.cxx b/Source/Modules/browser.cxx
index f5ceae5b1..217b40a7e 100644
--- a/Source/Modules/browser.cxx
+++ b/Source/Modules/browser.cxx
@@ -136,6 +136,12 @@ public:
return SWIG_OK;
}
+ virtual int lambdaDeclaration(Node *n) {
+ show_attributes(n);
+ emit_children(n);
+ return SWIG_OK;
+ }
+
virtual int enumDeclaration(Node *n) {
show_attributes(n);
emit_children(n);
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx
index 29de9f9ed..0b1153d61 100644
--- a/Source/Modules/cffi.cxx
+++ b/Source/Modules/cffi.cxx
@@ -506,11 +506,6 @@ int CFFI::functionWrapper(Node *n) {
void CFFI::emit_defun(Node *n, String *name) {
-
- // String *storage=Getattr(n,"storage");
- // if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc")))
- // return SWIG_OK;
-
String *func_name = Getattr(n, "sym:name");
ParmList *pl = Getattr(n, "parms");
@@ -583,12 +578,6 @@ int CFFI::constantWrapper(Node *n) {
}
int CFFI::variableWrapper(Node *n) {
- // String *storage=Getattr(n,"storage");
- // Printf(stdout,"\"%s\" %s)\n",storage,Getattr(n, "sym:name"));
-
- // if(!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc")))
- // return SWIG_OK;
-
String *var_name = Getattr(n, "sym:name");
String *lisp_type = Swig_typemap_lookup("cin", n, "", 0);
String *lisp_name = lispify_name(n, var_name, "'variable");
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index 4290b5452..e7d971faa 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -148,7 +148,7 @@ int CLISP::top(Node *n) {
int CLISP::functionWrapper(Node *n) {
is_function = 1;
String *storage = Getattr(n, "storage");
- if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc"))))
+ if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && !Swig_storage_isexternc(n))))
return SWIG_OK;
String *func_name = Getattr(n, "sym:name");
@@ -217,10 +217,9 @@ int CLISP::constantWrapper(Node *n) {
int CLISP::variableWrapper(Node *n) {
is_function = 0;
- // SwigType *type=;
String *storage = Getattr(n, "storage");
- if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc"))))
+ if (!extern_all_flag && (!storage || (!Swig_storage_isextern(n) && !Swig_storage_isexternc(n))))
return SWIG_OK;
String *var_name = Getattr(n, "sym:name");
diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx
index 5fa5bcad5..ffd799cfd 100644
--- a/Source/Modules/contract.cxx
+++ b/Source/Modules/contract.cxx
@@ -307,7 +307,7 @@ int Contracts::cDeclaration(Node *n) {
return SWIG_OK;
if (Getattr(n, "feature:contract"))
- ret = emit_contract(n, (InClass && !checkAttribute(n, "storage", "static")));
+ ret = emit_contract(n, InClass && !Swig_storage_isstatic(n));
return ret;
}
diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx
index 4cb38d0aa..2fdda5a12 100644
--- a/Source/Modules/directors.cxx
+++ b/Source/Modules/directors.cxx
@@ -275,8 +275,8 @@ String *Swig_method_decl(SwigType *rettype, SwigType *decl, const_String_or_char
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
// TODO: why is the storage element removed in staticmemberfunctionHandler ??
if ((!is_public(n) && (is_member_director(n) || GetFlag(n, "explicitcall"))) ||
- (is_non_virtual_protected_access(n) && !(checkAttribute(n, "staticmemberfunctionHandler:storage", "static") ||
- checkAttribute(n, "storage", "static"))
+ (is_non_virtual_protected_access(n) && !(Swig_storage_isstatic_custom(n, "staticmemberfunctionHandler:storage") ||
+ Swig_storage_isstatic(n))
&& !Equal(nodeType(n), "constructor"))) {
Node *parent = Getattr(n, "parentNode");
String *dirname;
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index fa706cb62..52e2459b7 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -1611,7 +1611,7 @@ private:
return goComplexConstant(n, type);
}
- if (Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "static") == 0) {
+ if (Swig_storage_isstatic(n)) {
return goComplexConstant(n, type);
}
@@ -4860,7 +4860,7 @@ private:
bool isStatic(Node *n) {
String *storage = Getattr(n, "storage");
- return (storage && (Strcmp(storage, "static") == 0 || Strcmp(storage, "friend") == 0) && (!SmartPointer || !Getattr(n, "allocate:smartpointeraccess")));
+ return (storage && (Swig_storage_isstatic(n) || Strcmp(storage, "friend") == 0) && (!SmartPointer || !Getattr(n, "allocate:smartpointeraccess")));
}
/* ----------------------------------------------------------------------
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index a62084499..e50a50a6d 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -137,6 +137,8 @@ int Dispatcher::emit_one(Node *n) {
ret = namespaceDeclaration(n);
} else if (strcmp(tag, "template") == 0) {
ret = templateDeclaration(n);
+ } else if (strcmp(tag, "lambda") == 0) {
+ ret = lambdaDeclaration(n);
}
/* ===============================================================
@@ -282,6 +284,9 @@ int Dispatcher::classDeclaration(Node *n) {
int Dispatcher::templateDeclaration(Node *n) {
return defaultHandler(n);
}
+int Dispatcher::lambdaDeclaration(Node *n) {
+ return defaultHandler(n);
+}
int Dispatcher::classforwardDeclaration(Node *n) {
return defaultHandler(n);
}
@@ -951,7 +956,7 @@ int Language::cDeclaration(Node *n) {
if (AddExtern) {
if (f_header) {
- if ((Cmp(storage, "extern") == 0) || (ForceExtern && !storage)) {
+ if (Swig_storage_isextern(n) || (ForceExtern && !storage)) {
/* we don't need the 'extern' part in the C/C++ declaration,
and it produces some problems when namespace and SUN
Studio is used.
@@ -981,7 +986,7 @@ int Language::cDeclaration(Node *n) {
}
}
Printf(f_header, ";\n");
- } else if (Cmp(storage, "externc") == 0) {
+ } else if (Swig_storage_isexternc(n)) {
/* here 'extern "C"' is needed */
String *str = SwigType_str(ty, name);
Printf(f_header, "extern \"C\" %s;\n", str);
@@ -1013,12 +1018,12 @@ int Language::cDeclaration(Node *n) {
if (Getattr(n, "nested"))
SetFlag(n, "feature:immutable");
if (!CurrentClass) {
- if ((Cmp(storage, "extern") == 0) || ForceExtern) {
- f_header = Swig_filebyname("header");
+ if (Swig_storage_isextern(n) || ForceExtern) {
if (AddExtern) {
+ f_header = Swig_filebyname("header");
if (f_header) {
String *str = SwigType_str(ty, name);
- Printf(f_header, "extern %s;\n", str);
+ Printf(f_header, "%s %s;\n", Getattr(n, "storage"), str);
Delete(str);
}
}
@@ -1054,7 +1059,7 @@ int Language::cDeclaration(Node *n) {
int Language::functionHandler(Node *n) {
String *storage = Getattr(n, "storage");
int isfriend = CurrentClass && Cmp(storage, "friend") == 0;
- int isstatic = CurrentClass && Cmp(storage, "static") == 0 && !(SmartPointer && Getattr(n, "allocate:smartpointeraccess"));
+ int isstatic = CurrentClass && Swig_storage_isstatic(n) && !(SmartPointer && Getattr(n, "allocate:smartpointeraccess"));
Parm *p = Getattr(n, "parms");
if (GetFlag(n, "feature:del")) {
/* the method acts like a delete operator, ie, we need to disown the parameter */
@@ -1362,7 +1367,6 @@ int Language::variableHandler(Node *n) {
if (!CurrentClass) {
globalvariableHandler(n);
} else {
- String *storage = Getattr(n, "storage");
Swig_save("variableHandler", n, "feature:immutable", NIL);
if (SmartPointer) {
/* If a smart-pointer and it's a constant access, we have to set immutable */
@@ -1370,7 +1374,7 @@ int Language::variableHandler(Node *n) {
SetFlag(n, "feature:immutable");
}
}
- if ((Cmp(storage, "static") == 0) && !(SmartPointer && Getattr(n, "allocate:smartpointeraccess"))) {
+ if (Swig_storage_isstatic(n) && !(SmartPointer && Getattr(n, "allocate:smartpointeraccess"))) {
staticmembervariableHandler(n);
} else {
membervariableHandler(n);
@@ -1424,7 +1428,7 @@ int Language::membervariableHandler(Node *n) {
String *target = 0;
if (!Extend) {
if (SmartPointer) {
- if (checkAttribute(n, "storage", "static")) {
+ if (Swig_storage_isstatic(n)) {
Node *sn = Getattr(n, "cplus:staticbase");
String *base = Getattr(sn, "name");
target = NewStringf("%s::%s", base, name);
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index 35ebc9ad4..65a1ad701 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -518,7 +518,7 @@ public:
else
return v;
}
- if (Strcmp(v, "NULL") == 0)
+ if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
return NewString("true");
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 652bd1e63..4ade67250 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -1324,6 +1324,7 @@ public:
break;
}
case T_REFERENCE:
+ case T_RVALUE_REFERENCE:
case T_USER:
case T_ARRAY:
Clear(value);
@@ -1366,6 +1367,7 @@ public:
}
}
if (Strcmp(value, "NULL") == 0 ||
+ Strcmp(value, "nullptr") == 0 ||
Strcmp(value, "0") == 0 ||
Strcmp(value, "0L") == 0) {
Clear(value);
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 98f6cac09..1022f9fa0 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1563,7 +1563,7 @@ public:
return NewString("True");
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
return NewString("False");
- if (Strcmp(v, "NULL") == 0)
+ if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
}
return 0;
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index 3d2c27dad..5ff599d54 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -788,7 +788,7 @@ private:
else
return v;
}
- if (Strcmp(v, "NULL") == 0)
+ if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
return NewString("True");
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 4fcf013eb..3a7e8a8d6 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -99,6 +99,7 @@ public:
virtual int usingDeclaration(Node *n);
virtual int namespaceDeclaration(Node *n);
virtual int templateDeclaration(Node *n);
+ virtual int lambdaDeclaration(Node *n);
enum AccessMode { PUBLIC, PRIVATE, PROTECTED };
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 2346c94e1..7eebfe80b 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -524,7 +524,7 @@ class TypePass:private Dispatcher {
}
/* ------------------------------------------------------------
- * namespaceDeclaration()
+ * templateDeclaration()
* ------------------------------------------------------------ */
virtual int templateDeclaration(Node *n) {
@@ -544,6 +544,14 @@ class TypePass:private Dispatcher {
}
/* ------------------------------------------------------------
+ * lambdaDeclaration()
+ * ------------------------------------------------------------ */
+
+ virtual int lambdaDeclaration(Node *) {
+ return SWIG_OK;
+ }
+
+ /* ------------------------------------------------------------
* classforwardDeclaration()
* ------------------------------------------------------------ */
@@ -844,16 +852,17 @@ class TypePass:private Dispatcher {
virtual int enumvalueDeclaration(Node *n) {
String *name = Getattr(n, "name");
String *value = Getattr(n, "value");
+ String *scopedenum = Getattr(parentNode(n), "scopedenum");
if (!value)
value = name;
if (Strcmp(value, name) == 0) {
String *new_value;
- if ((nsname || inclass) && cparse_cplusplus) {
+ if ((nsname || inclass || scopedenum) && cparse_cplusplus) {
new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
} else {
new_value = NewString(value);
}
- if ((nsname || inclass) && !cparse_cplusplus) {
+ if ((nsname || inclass || scopedenum) && !cparse_cplusplus) {
String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */
}
@@ -986,7 +995,7 @@ class TypePass:private Dispatcher {
String *symname = Getattr(n, "sym:name");
while (c) {
if (Strcmp(nodeType(c), "cdecl") == 0) {
- if (!(checkAttribute(c, "storage", "static")
+ if (!(Swig_storage_isstatic(c)
|| checkAttribute(c, "storage", "typedef")
|| checkAttribute(c, "storage", "friend")
|| (Getattr(c, "feature:extend") && !Getattr(c, "code"))
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index c7e101842..6f8fa39e9 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -88,6 +88,19 @@ static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_Str
Delete(lstrname);
}
break;
+ case T_RVALUE_REFERENCE:
+ if (value) {
+ String *lstrname = SwigType_lstr(t, name);
+ String *lstr = SwigType_lstr(t, 0);
+ Printf(decl, "%s = (%s) &%s_defrvalue", lstrname, lstr, name);
+ Delete(lstrname);
+ Delete(lstr);
+ } else {
+ String *lstrname = SwigType_lstr(t, name);
+ Printf(decl, "%s = 0", lstrname);
+ Delete(lstrname);
+ }
+ break;
case T_VOID:
break;
case T_VARARGS:
@@ -253,7 +266,35 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
Delete(defname);
Delete(defvalue);
}
- } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) {
+ } else if (tycode == T_RVALUE_REFERENCE) {
+ if (pvalue) {
+ SwigType *tvalue;
+ String *defname, *defvalue, *rvalue, *qvalue;
+ rvalue = SwigType_typedef_resolve_all(pvalue);
+ qvalue = SwigType_typedef_qualified(rvalue);
+ defname = NewStringf("%s_defrvalue", lname);
+ tvalue = Copy(type);
+ SwigType_del_rvalue_reference(tvalue);
+ tycode = SwigType_type(tvalue);
+ if (tycode != T_USER) {
+ /* plain primitive type, we copy the the def value */
+ String *lstr = SwigType_lstr(tvalue, defname);
+ defvalue = NewStringf("%s = %s", lstr, qvalue);
+ Delete(lstr);
+ } else {
+ /* user type, we copy the reference value */
+ String *str = SwigType_str(type, defname);
+ defvalue = NewStringf("%s = %s", str, qvalue);
+ Delete(str);
+ }
+ Wrapper_add_localv(w, defname, defvalue, NIL);
+ Delete(tvalue);
+ Delete(rvalue);
+ Delete(qvalue);
+ Delete(defname);
+ Delete(defvalue);
+ }
+ } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING) || (tycode == T_WSTRING))) {
pvalue = (String *) "0";
}
if (!altty) {
@@ -293,6 +334,23 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or
Delete(lstr);
}
break;
+ case T_RVALUE_REFERENCE:
+ {
+ String *const_lvalue_str;
+ String *lstr = SwigType_lstr(t, 0);
+ SwigType *tt = Copy(t);
+ SwigType_del_rvalue_reference(tt);
+ SwigType_add_qualifier(tt, "const");
+ SwigType_add_reference(tt);
+ const_lvalue_str = SwigType_rcaststr(tt, 0);
+
+ Printf(fcall, "%s = (%s) &%s", name, lstr, const_lvalue_str);
+
+ Delete(const_lvalue_str);
+ Delete(tt);
+ Delete(lstr);
+ }
+ break;
case T_USER:
Printf(fcall, "%s = ", name);
break;
@@ -864,7 +922,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
self = NewString("(*(this))->");
is_smart_pointer_overload = 1;
}
- else if (Cmp(Getattr(n, "storage"), "static") == 0) {
+ else if (Swig_storage_isstatic(n)) {
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
String *ctname = SwigType_namestr(cname);
self = NewStringf("(*(%s const *)this)->", ctname);
@@ -1006,7 +1064,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
String *func = NewStringf("%s(", mangled);
String *cres;
- if (Cmp(Getattr(n, "storage"), "static") != 0) {
+ if (!Swig_storage_isstatic(n)) {
String *pname = Swig_cparm_name(pp, i);
String *ctname = SwigType_namestr(cname);
String *fadd = 0;
@@ -1409,7 +1467,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
int varcref = flags & CWRAP_NATURAL_VAR;
if (flags & CWRAP_SMART_POINTER) {
- if (checkAttribute(n, "storage", "static")) {
+ if (Swig_storage_isstatic(n)) {
Node *sn = Getattr(n, "cplus:staticbase");
String *base = Getattr(sn, "name");
self = NewStringf("%s::", base);
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index 651b94cf1..596f6b424 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -263,6 +263,49 @@ void Swig_filename_unescape(String *filename) {
}
/* -----------------------------------------------------------------------------
+ * Swig_storage_isextern()
+ *
+ * Determine if the storage class specifier is extern (but not externc)
+ * ----------------------------------------------------------------------------- */
+
+int Swig_storage_isextern(Node *n) {
+ const String *storage = Getattr(n, "storage");
+ return storage ? Strcmp(storage, "extern") == 0 || Strncmp(storage, "extern ", 7) == 0 : 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_storage_isexternc()
+ *
+ * Determine if the storage class specifier is externc (but not plain extern)
+ * ----------------------------------------------------------------------------- */
+
+int Swig_storage_isexternc(Node *n) {
+ const String *storage = Getattr(n, "storage");
+ return storage ? Strcmp(storage, "externc") == 0 || Strncmp(storage, "externc ", 8) == 0 : 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_storage_isstatic_custom()
+ *
+ * Determine if the storage class specifier is static
+ * ----------------------------------------------------------------------------- */
+
+int Swig_storage_isstatic_custom(Node *n, const_String_or_char_ptr storage_name) {
+ const String *storage = Getattr(n, storage_name);
+ return storage ? Strncmp(storage, "static", 6) == 0 : 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_storage_isstatic()
+ *
+ * Determine if the storage class specifier is static
+ * ----------------------------------------------------------------------------- */
+
+int Swig_storage_isstatic(Node *n) {
+ return Swig_storage_isstatic_custom(n, "storage");
+}
+
+/* -----------------------------------------------------------------------------
* Swig_string_escape()
*
* Takes a string object and produces a string with escape codes added to it.
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index a4bff35af..119f816dc 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -938,8 +938,7 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) {
}
/* static functions */
- if ((Cmp(a_storage, "static") == 0)
- || (Cmp(b_storage, "static") == 0)) {
+ if (Swig_storage_isstatic(a) || Swig_storage_isstatic(b)) {
if (Cmp(a_storage, b_storage) != 0)
return 0;
}
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index ed2d43b51..181d9aa74 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -35,6 +35,7 @@ struct Scanner {
String *error; /* Last error message (if any) */
int error_line; /* Error line number */
int freeze_line; /* Suspend line number updates */
+ List *brackets; /* Current level of < > brackets on each level */
};
typedef struct Locator {
@@ -44,6 +45,9 @@ typedef struct Locator {
} Locator;
static int follow_locators = 0;
+void Scanner_push_brackets(Scanner*);
+void Scanner_clear_brackets(Scanner*);
+
/* -----------------------------------------------------------------------------
* NewScanner()
*
@@ -65,6 +69,8 @@ Scanner *NewScanner(void) {
s->error = 0;
s->error_line = 0;
s->freeze_line = 0;
+ s->brackets = NewList();
+ Scanner_push_brackets(s);
return s;
}
@@ -77,12 +83,13 @@ Scanner *NewScanner(void) {
void DelScanner(Scanner * s) {
assert(s);
Delete(s->scanobjs);
+ Delete(s->brackets);
Delete(s->text);
Delete(s->file);
Delete(s->error);
Delete(s->str);
free(s->idstart);
- free(s);
+ free(s);
}
/* -----------------------------------------------------------------------------
@@ -96,6 +103,7 @@ void Scanner_clear(Scanner * s) {
Delete(s->str);
Clear(s->text);
Clear(s->scanobjs);
+ Scanner_clear_brackets(s);
Delete(s->error);
s->str = 0;
s->error = 0;
@@ -261,6 +269,74 @@ static void freeze_line(Scanner *s, int val) {
}
/* -----------------------------------------------------------------------------
+ * Scanner_brackets()
+ *
+ * Returns the number of brackets at the current depth.
+ * ----------------------------------------------------------------------------- */
+int*
+Scanner_brackets(Scanner *s) {
+ return (int*)(**((void***)Getitem(s->brackets, 0))); /* TODO: Use VoidObj*->ptr instead of void** */
+}
+
+/* -----------------------------------------------------------------------------
+ * Scanner_clear_brackets()
+ *
+ * Resets the current depth and clears all brackets.
+ * Usually called at the end of statements;
+ * ----------------------------------------------------------------------------- */
+void
+Scanner_clear_brackets(Scanner *s) {
+ Clear(s->brackets);
+ Scanner_push_brackets(s); /* base bracket count should always be created */
+}
+
+/* -----------------------------------------------------------------------------
+ * Scanner_inc_brackets()
+ *
+ * Increases the number of brackets at the current depth.
+ * Usually called when '<' was found.
+ * ----------------------------------------------------------------------------- */
+void
+Scanner_inc_brackets(Scanner *s) {
+ (*Scanner_brackets(s))++;
+}
+
+/* -----------------------------------------------------------------------------
+ * Scanner_dec_brackets()
+ *
+ * Decreases the number of brackets at the current depth.
+ * Usually called when '>' was found.
+ * ----------------------------------------------------------------------------- */
+void
+Scanner_dec_brackets(Scanner *s) {
+ (*Scanner_brackets(s))--;
+}
+
+/* -----------------------------------------------------------------------------
+ * Scanner_push_brackets()
+ *
+ * Increases the depth of brackets.
+ * Usually called when '(' was found.
+ * ----------------------------------------------------------------------------- */
+void
+Scanner_push_brackets(Scanner *s) {
+ int *newInt = malloc(sizeof(int));
+ *newInt = 0;
+ Push(s->brackets, NewVoid(newInt, free));
+}
+
+/* -----------------------------------------------------------------------------
+ * Scanner_pop_brackets()
+ *
+ * Decreases the depth of brackets.
+ * Usually called when ')' was found.
+ * ----------------------------------------------------------------------------- */
+void
+Scanner_pop_brackets(Scanner *s) {
+ Delitem(s->brackets, 0);
+}
+
+/* -----------------------------------------------------------------------------
* retract()
*
* Retract n characters
@@ -407,13 +483,15 @@ static void get_escape(Scanner *s) {
* ----------------------------------------------------------------------------- */
static int look(Scanner * s) {
- int state;
+ int state = 0;
int c = 0;
+ String *str_delimiter = 0;
- state = 0;
Clear(s->text);
s->start_line = s->line;
Setfile(s->text, Getfile(s->str));
+
+
while (1) {
switch (state) {
case 0:
@@ -435,24 +513,30 @@ static int look(Scanner * s) {
case 1000:
if ((c = nextchar(s)) == 0)
- return (0);
+ return (0);
if (c == '%')
state = 4; /* Possibly a SWIG directive */
-
- /* Look for possible identifiers */
-
+
+ /* Look for possible identifiers or unicode/delimiter strings */
else if ((isalpha(c)) || (c == '_') ||
- (s->idstart && strchr(s->idstart, c)))
+ (s->idstart && strchr(s->idstart, c))) {
state = 7;
+ }
/* Look for single character symbols */
- else if (c == '(')
+ else if (c == '(') {
+ Scanner_push_brackets(s);
return SWIG_TOKEN_LPAREN;
- else if (c == ')')
+ }
+ else if (c == ')') {
+ Scanner_pop_brackets(s);
return SWIG_TOKEN_RPAREN;
- else if (c == ';')
+ }
+ else if (c == ';') {
+ Scanner_clear_brackets(s);
return SWIG_TOKEN_SEMI;
+ }
else if (c == ',')
return SWIG_TOKEN_COMMA;
else if (c == '*')
@@ -502,16 +586,16 @@ static int look(Scanner * s) {
state = 1; /* Comment (maybe) */
s->start_line = s->line;
}
- else if (c == '\"') {
- state = 2; /* Possibly a string */
- s->start_line = s->line;
- Clear(s->text);
- }
else if (c == ':')
state = 5; /* maybe double colon */
else if (c == '0')
state = 83; /* An octal or hex value */
+ else if (c == '\"') {
+ state = 2; /* A string constant */
+ s->start_line = s->line;
+ Clear(s->text);
+ }
else if (c == '\'') {
s->start_line = s->line;
Clear(s->text);
@@ -590,18 +674,63 @@ static int look(Scanner * s) {
break;
case 2: /* Processing a string */
+ if (!str_delimiter) {
+ state=20;
+ break;
+ }
+
if ((c = nextchar(s)) == 0) {
Swig_error(cparse_file, cparse_start_line, "Unterminated string\n");
return SWIG_TOKEN_ERROR;
}
- if (c == '\"') {
- Delitem(s->text, DOH_END);
- return SWIG_TOKEN_STRING;
- } else if (c == '\\') {
- Delitem(s->text, DOH_END);
- get_escape(s);
- } else
- state = 2;
+ else if (c == '(') {
+ state = 20;
+ }
+ else {
+ char temp[2] = { 0, 0 };
+ temp[0] = c;
+ Append( str_delimiter, temp );
+ }
+
+ break;
+
+ case 20: /* Inside the string */
+ if ((c = nextchar(s)) == 0) {
+ Swig_error(cparse_file, cparse_start_line, "Unterminated string\n");
+ return SWIG_TOKEN_ERROR;
+ }
+
+ if (!str_delimiter) { /* Ordinary string: "value" */
+ if (c == '\"') {
+ Delitem(s->text, DOH_END);
+ return SWIG_TOKEN_STRING;
+ } else if (c == '\\') {
+ Delitem(s->text, DOH_END);
+ get_escape(s);
+ }
+ } else { /* Custom delimiter string: R"XXXX(value)XXXX" */
+ if (c==')') {
+ int i=0;
+ String *end_delimiter = NewStringEmpty();
+ while ((c = nextchar(s)) != 0 && c!='\"') {
+ char temp[2] = { 0, 0 };
+ temp[0] = c;
+ Append( end_delimiter, temp );
+ i++;
+ }
+
+ if (Strcmp( str_delimiter, end_delimiter )==0) {
+ Delete( end_delimiter ); /* Correct end delimiter )XXXX" occured */
+ Delete( str_delimiter );
+ str_delimiter = 0;
+ return SWIG_TOKEN_STRING;
+ } else { /* Incorrect end delimiter occured */
+ retract( s, i );
+ Delete( end_delimiter );
+ }
+ }
+ }
+
break;
case 3: /* Maybe a not equals */
@@ -719,6 +848,7 @@ static int look(Scanner * s) {
break;
case 60: /* shift operators */
+ Scanner_inc_brackets(s);
if ((c = nextchar(s)) == 0)
return SWIG_TOKEN_LESSTHAN;
if (c == '<')
@@ -731,9 +861,10 @@ static int look(Scanner * s) {
}
break;
case 61:
+ Scanner_dec_brackets(s);
if ((c = nextchar(s)) == 0)
return SWIG_TOKEN_GREATERTHAN;
- if (c == '>')
+ if (c == '>' && ((*Scanner_brackets(s))<0)) /* go to double >> only, if no template < has been used */
state = 250;
else if (c == '=')
return SWIG_TOKEN_GTEQUAL;
@@ -742,18 +873,108 @@ static int look(Scanner * s) {
return SWIG_TOKEN_GREATERTHAN;
}
break;
- case 7: /* Identifier */
- if ((c = nextchar(s)) == 0)
+
+ case 7: /* Identifier or true/false or unicode/custom delimiter string */
+ if (c == 'R') { /* Possibly CUSTOM DELIMITER string */
+ state = 72;
+ break;
+ }
+ else if (c == 'L') { /* Probably identifier but may be a wide string literal */
+ state = 77;
+ break;
+ }
+ else if (c != 'u' && c != 'U') { /* Definitely an identifier */
+ state = 70;
+ break;
+ }
+
+ if ((c = nextchar(s)) == 0) {
+ state = 76;
+ }
+ else if (c == '\"') { /* Definitely u, U or L string */
+ retract(s, 1);
+ state = 1000;
+ }
+ else if (c == 'R') { /* Possibly CUSTOM DELIMITER u, U, L string */
+ state = 73;
+ }
+ else if (c == '8') { /* Possibly u8 string */
state = 71;
+ }
+ else {
+ retract(s, 1); /* Definitely an identifier */
+ state = 70;
+ }
+ break;
+
+ case 70: /* Identifier */
+ if ((c = nextchar(s)) == 0)
+ state = 76;
else if (isalnum(c) || (c == '_') || (c == '$')) {
- state = 7;
+ state = 70;
} else {
retract(s, 1);
- state = 71;
+ state = 76;
+ }
+ break;
+
+ case 71: /* Possibly u8 string */
+ if ((c = nextchar(s)) == 0) {
+ state = 76;
+ }
+ else if (c=='\"') {
+ retract(s, 1); /* Definitely u8 string */
+ state = 1000;
+ }
+ else if (c=='R') {
+ state = 74; /* Possibly CUSTOM DELIMITER u8 string */
+ }
+ else {
+ retract(s, 2); /* Definitely an identifier. Retract 8" */
+ state = 70;
}
+
+ break;
+
+ case 72: /* Possibly CUSTOM DELIMITER string */
+ case 73:
+ case 74:
+ if ((c = nextchar(s)) == 0) {
+ state = 76;
+ }
+ else if (c=='\"') {
+ retract(s, 1); /* Definitely custom delimiter u, U or L string */
+ str_delimiter = NewStringEmpty();
+ state = 1000;
+ }
+ else {
+ if (state==72) {
+ retract(s, 1); /* Definitely an identifier. Retract ? */
+ }
+ else if (state==73) {
+ retract(s, 2); /* Definitely an identifier. Retract R? */
+ }
+ else if (state==74) {
+ retract(s, 3); /* Definitely an identifier. Retract 8R? */
+ }
+ state = 70;
+ }
+
break;
- case 71: /* Identifier or true/false */
+ case 75: /* Special identifier $ */
+ if ((c = nextchar(s)) == 0)
+ return SWIG_TOKEN_DOLLAR;
+ if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) {
+ state = 70;
+ } else {
+ retract(s,1);
+ if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR;
+ state = 76;
+ }
+ break;
+
+ case 76: /* Identifier or true/false */
if (cparse_cplusplus) {
if (Strcmp(s->text, "true") == 0)
return SWIG_TOKEN_BOOL;
@@ -763,15 +984,56 @@ static int look(Scanner * s) {
return SWIG_TOKEN_ID;
break;
- case 75: /* Special identifier $ */
+ case 77: /*identifier or wide string literal*/
if ((c = nextchar(s)) == 0)
- return SWIG_TOKEN_DOLLAR;
- if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) {
+ return SWIG_TOKEN_ID;
+ else if (c == '\"') {
+ s->start_line = s->line;
+ Clear(s->text);
+ state = 78;
+ }
+ else if (c == '\'') {
+ s->start_line = s->line;
+ Clear(s->text);
+ state = 79;
+ }
+ else if (isalnum(c) || (c == '_') || (c == '$'))
state = 7;
- } else {
- retract(s,1);
- if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR;
- state = 71;
+ else {
+ retract(s, 1);
+ return SWIG_TOKEN_ID;
+ }
+ break;
+
+ case 78: /* Processing a wide string literal*/
+ if ((c = nextchar(s)) == 0) {
+ Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n");
+ return SWIG_TOKEN_ERROR;
+ }
+ if (c == '\"') {
+ Delitem(s->text, DOH_END);
+ return SWIG_TOKEN_WSTRING;
+ } else if (c == '\\') {
+ if ((c = nextchar(s)) == 0) {
+ Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n");
+ return SWIG_TOKEN_ERROR;
+ }
+ }
+ break;
+
+ case 79: /* Processing a wide char literal */
+ if ((c = nextchar(s)) == 0) {
+ Swig_error(cparse_file, cparse_start_line, "Unterminated wide character constant\n");
+ return SWIG_TOKEN_ERROR;
+ }
+ if (c == '\'') {
+ Delitem(s->text, DOH_END);
+ return (SWIG_TOKEN_WCHAR);
+ } else if (c == '\\') {
+ if ((c = nextchar(s)) == 0) {
+ Swig_error(cparse_file, cparse_start_line, "Unterminated wide character literal\n");
+ return SWIG_TOKEN_ERROR;
+ }
}
break;
@@ -1049,6 +1311,7 @@ static int look(Scanner * s) {
break;
case 240: /* LSHIFT, LSEQUAL */
+ Scanner_inc_brackets(s);
if ((c = nextchar(s)) == 0)
return SWIG_TOKEN_LSHIFT;
else if (c == '=')
@@ -1060,6 +1323,7 @@ static int look(Scanner * s) {
break;
case 250: /* RSHIFT, RSEQUAL */
+ Scanner_dec_brackets(s);
if ((c = nextchar(s)) == 0)
return SWIG_TOKEN_RSHIFT;
else if (c == '=')
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index fcaf54093..4b72bdaa2 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -41,6 +41,7 @@
*
* 'p.' = Pointer (*)
* 'r.' = Reference (&)
+ * 'z.' = Rvalue reference (&&)
* 'a(n).' = Array of size n [n]
* 'f(..,..).' = Function with arguments (args)
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
@@ -128,12 +129,21 @@ SwigType *NewSwigType(int t) {
case T_UCHAR:
return NewString("unsigned char");
break;
- case T_STRING:{
+ case T_STRING: {
SwigType *t = NewString("char");
SwigType_add_pointer(t);
return t;
break;
}
+ case T_WCHAR:
+ return NewString("wchar_t");
+ break;
+ case T_WSTRING: {
+ SwigType *t = NewString("wchar_t");
+ SwigType_add_pointer(t);
+ return t;
+ break;
+ }
case T_LONGLONG:
return NewString("long long");
break;
@@ -143,6 +153,9 @@ SwigType *NewSwigType(int t) {
case T_VOID:
return NewString("void");
break;
+ case T_AUTO:
+ return NewString("auto");
+ break;
default:
break;
}
@@ -230,7 +243,7 @@ int SwigType_isconst(const SwigType *t) {
int SwigType_ismutable(const SwigType *t) {
int r;
SwigType *qt = SwigType_typedef_resolve_all(t);
- if (SwigType_isreference(qt) || SwigType_isarray(qt)) {
+ if (SwigType_isreference(qt) || SwigType_isrvalue_reference(qt) || SwigType_isarray(qt)) {
Delete(SwigType_pop(qt));
}
r = SwigType_isconst(qt);
@@ -573,6 +586,12 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
Insert(result, 0, "(");
Append(result, ")");
}
+ } else if (SwigType_isrvalue_reference(element)) {
+ Insert(result, 0, "&&");
+ if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
+ Insert(result, 0, "(");
+ Append(result, ")");
+ }
} else if (SwigType_isarray(element)) {
DOH *size;
Append(result, "[");
@@ -637,7 +656,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
SwigType *tt = Copy(tc);
td = 0;
while ((td = SwigType_typedef_resolve(tt))) {
- if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
+ if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td) || SwigType_isrvalue_reference(td))) {
/* We need to use the typedef type */
Delete(tt);
break;
@@ -676,6 +695,13 @@ SwigType *SwigType_ltype(const SwigType *s) {
Append(result, "p.");
}
firstarray = 0;
+ } else if (SwigType_isrvalue_reference(element)) {
+ if (notypeconv) {
+ Append(result, element);
+ } else {
+ Append(result, "p.");
+ }
+ firstarray = 0;
} else if (SwigType_isarray(element) && firstarray) {
if (notypeconv) {
Append(result, element);
@@ -755,14 +781,14 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
rs = s;
}
- if ((SwigType_isconst(rs) || SwigType_isarray(rs) || SwigType_isreference(rs))) {
+ if ((SwigType_isconst(rs) || SwigType_isarray(rs) || SwigType_isreference(rs) || SwigType_isrvalue_reference(rs))) {
td = 0;
} else {
td = SwigType_typedef_resolve(rs);
}
if (td) {
- if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
+ if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td) || SwigType_isrvalue_reference(td))) {
elements = SwigType_split(td);
} else {
elements = SwigType_split(rs);
@@ -821,6 +847,15 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
}
if (!isfunction)
isreference = 1;
+ } else if (SwigType_isrvalue_reference(element)) {
+ Insert(result, 0, "&&");
+ if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
+ Insert(result, 0, "(");
+ Append(result, ")");
+ }
+ if (!isfunction)
+ isreference = 1;
+ clear = 0;
} else if (SwigType_isarray(element)) {
DOH *size;
if (firstarray && !isreference) {
@@ -897,6 +932,12 @@ String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) {
Delete(str);
if (name)
Append(result, name);
+ } else if (SwigType_isrvalue_reference(s)) {
+ String *str = SwigType_str(s, 0);
+ Printf(result, "(%s)", str);
+ Delete(str);
+ if (name)
+ Append(result, name);
} else if (SwigType_isqualifier(s)) {
String *lstr = SwigType_lstr(s, 0);
Printf(result, "(%s)%s", lstr, name);
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 42fd9238e..b730ab04d 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -79,6 +79,7 @@ extern "C" {
#define T_FLTCPLX 23
#define T_DBLCPLX 24
#define T_NUMERIC 25
+#define T_AUTO 26
#define T_COMPLEX T_DBLCPLX
@@ -95,10 +96,14 @@ extern "C" {
#define T_FUNCTION 37
#define T_MPOINTER 38
#define T_VARARGS 39
+#define T_RVALUE_REFERENCE 40
+#define T_WSTRING 41
+
#define T_SYMBOL 98
#define T_ERROR 99
+
/* --- File interface --- */
#include "swigfile.h"
@@ -124,6 +129,8 @@ extern "C" {
extern SwigType *SwigType_pop_arrays(SwigType *t);
extern SwigType *SwigType_add_reference(SwigType *t);
extern SwigType *SwigType_del_reference(SwigType *t);
+ extern SwigType *SwigType_add_rvalue_reference(SwigType *t);
+ extern SwigType *SwigType_del_rvalue_reference(SwigType *t);
extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual);
extern SwigType *SwigType_del_qualifier(SwigType *t);
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
@@ -147,6 +154,7 @@ extern "C" {
extern int SwigType_ismemberpointer(const SwigType *t);
extern int SwigType_isreference(const SwigType *t);
extern int SwigType_isreference_return(const SwigType *t);
+ extern int SwigType_isrvalue_reference(const SwigType *t);
extern int SwigType_isarray(const SwigType *t);
extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
extern int SwigType_isfunction(const SwigType *t);
@@ -307,6 +315,10 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_filename_correct(String *filename);
extern String *Swig_filename_escape(String *filename);
extern void Swig_filename_unescape(String *filename);
+ extern int Swig_storage_isextern(Node *n);
+ extern int Swig_storage_isexternc(Node *n);
+ extern int Swig_storage_isstatic_custom(Node *n, const_String_or_char_ptr storage);
+ extern int Swig_storage_isstatic(Node *n);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
extern void Swig_scopename_split(const String *s, String **prefix, String **last);
diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
index a2d5911bd..017ef58d5 100644
--- a/Source/Swig/swigscan.h
+++ b/Source/Swig/swigscan.h
@@ -67,6 +67,9 @@ extern void Scanner_locator(Scanner *, String *loc);
#define SWIG_TOKEN_QUESTION 30 /* ? */
#define SWIG_TOKEN_COMMENT 31 /* C or C++ comment */
#define SWIG_TOKEN_BOOL 32 /* true or false */
+#define SWIG_TOKEN_WSTRING 33 /* L"str" */
+#define SWIG_TOKEN_WCHAR 34 /* L'c' */
+
#define SWIG_TOKEN_ILLEGAL 99
#define SWIG_TOKEN_ERROR -1
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index a607e92b8..981b0b436 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -1039,13 +1039,13 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
$*n_ltype
*/
- if (SwigType_ispointer(ftype) || (SwigType_isarray(ftype)) || (SwigType_isreference(ftype))) {
- if (!(SwigType_isarray(type) || SwigType_ispointer(type) || SwigType_isreference(type))) {
+ if (SwigType_ispointer(ftype) || (SwigType_isarray(ftype)) || (SwigType_isreference(ftype)) || (SwigType_isrvalue_reference(ftype))) {
+ if (!(SwigType_isarray(type) || SwigType_ispointer(type) || SwigType_isreference(type) || SwigType_isrvalue_reference(type))) {
star_type = Copy(ftype);
} else {
star_type = Copy(type);
}
- if (!SwigType_isreference(star_type)) {
+ if (!(SwigType_isreference(star_type) || SwigType_isrvalue_reference(star_type))) {
if (SwigType_isarray(star_type)) {
SwigType_del_element(star_type);
} else {
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c
index 56892f3f8..903d1357c 100644
--- a/Source/Swig/typeobj.c
+++ b/Source/Swig/typeobj.c
@@ -44,6 +44,7 @@
*
* 'p.' = Pointer (*)
* 'r.' = Reference (&)
+ * 'z.' = Rvalue reference (&&)
* 'a(n).' = Array of size n [n]
* 'f(..,..).' = Function with arguments (args)
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
@@ -77,6 +78,7 @@
*
* SwigType_add_pointer()
* SwigType_add_reference()
+ * SwigType_add_rvalue_reference()
* SwigType_add_array()
*
* These are used to build new types. There are also functions to undo these
@@ -84,12 +86,14 @@
*
* SwigType_del_pointer()
* SwigType_del_reference()
+ * SwigType_del_rvalue_reference()
* SwigType_del_array()
*
* In addition, there are query functions
*
* SwigType_ispointer()
* SwigType_isreference()
+ * SwigType_isrvalue_reference()
* SwigType_isarray()
*
* Finally, there are some data extraction functions that can be used to
@@ -415,6 +419,41 @@ int SwigType_isreference(const SwigType *t) {
}
/* -----------------------------------------------------------------------------
+ * Rvalue References
+ *
+ * SwigType_add_rvalue_reference()
+ * SwigType_del_rvalue_reference()
+ * SwigType_isrvalue_reference()
+ *
+ * Add, remove, and test if a type is a rvalue reference. The deletion and query
+ * functions take into account qualifiers (if any).
+ * ----------------------------------------------------------------------------- */
+
+SwigType *SwigType_add_rvalue_reference(SwigType *t) {
+ Insert(t, 0, "z.");
+ return t;
+}
+
+SwigType *SwigType_del_rvalue_reference(SwigType *t) {
+ char *c = Char(t);
+ int check = strncmp(c, "z.", 2);
+ assert(check == 0);
+ Delslice(t, 0, 2);
+ return t;
+}
+
+int SwigType_isrvalue_reference(const SwigType *t) {
+ char *c;
+ if (!t)
+ return 0;
+ c = Char(t);
+ if (strncmp(c, "z.", 2) == 0) {
+ return 1;
+ }
+ return 0;
+}
+
+/* -----------------------------------------------------------------------------
* Qualifiers
*
* SwigType_add_qualifier()
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index c10ffbfb5..1552703c6 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -1282,6 +1282,8 @@ int SwigType_type(const SwigType *t) {
if (strncmp(c, "p.", 2) == 0) {
if (SwigType_type(c + 2) == T_CHAR)
return T_STRING;
+ else if (SwigType_type(c + 2) == T_WCHAR)
+ return T_WSTRING;
else
return T_POINTER;
}
@@ -1289,6 +1291,8 @@ int SwigType_type(const SwigType *t) {
return T_ARRAY;
if (strncmp(c, "r.", 2) == 0)
return T_REFERENCE;
+ if (strncmp(c, "z.", 2) == 0)
+ return T_RVALUE_REFERENCE;
if (strncmp(c, "m(", 2) == 0)
return T_MPOINTER;
if (strncmp(c, "q(", 2) == 0) {
@@ -1322,6 +1326,8 @@ int SwigType_type(const SwigType *t) {
return T_SCHAR;
if (strcmp(c, "unsigned char") == 0)
return T_UCHAR;
+ if (strcmp(c, "wchar_t") == 0)
+ return T_WCHAR;
if (strcmp(c, "float") == 0)
return T_FLOAT;
if (strcmp(c, "double") == 0)
@@ -1344,6 +1350,8 @@ int SwigType_type(const SwigType *t) {
return T_ULONGLONG;
if (strncmp(c, "enum ", 5) == 0)
return T_INT;
+ if (strcmp(c, "auto") == 0)
+ return T_AUTO;
if (strcmp(c, "v(...)") == 0)
return T_VARARGS;
@@ -1621,6 +1629,11 @@ void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr cl
SwigType_del_reference(tt);
SwigType_add_pointer(tt);
SwigType_remember_clientdata(tt, clientdata);
+ } else if (SwigType_isrvalue_reference(t)) {
+ SwigType *tt = Copy(t);
+ SwigType_del_rvalue_reference(tt);
+ SwigType_add_pointer(tt);
+ SwigType_remember_clientdata(tt, clientdata);
}
}
diff --git a/Tools/config/ax_cxx_compile_stdcxx_11.m4 b/Tools/config/ax_cxx_compile_stdcxx_11.m4
new file mode 100644
index 000000000..138ca2aca
--- /dev/null
+++ b/Tools/config/ax_cxx_compile_stdcxx_11.m4
@@ -0,0 +1,121 @@
+# ============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+# AX_CXX_COMPILE_STDCXX_11([ext|noext], [nostop])
+#
+# DESCRIPTION
+#
+# Check for baseline language coverage in the compiler for the C++11
+# standard; if necessary, add switches to CXXFLAGS to enable support.
+# CXX11FLAGS will also contain any necessary switches to enable support.
+# HAVE_CXX11_COMPILER will additionally be set to yes if there is support.
+# If the second argument is not specified, errors out if no mode that
+# supports C++11 baseline syntax can be found. The first argument, if
+# specified, indicates whether you insist on an extended mode
+# (e.g. -std=gnu++11) or a strict conformance mode (e.g. -std=c++11).
+# If neither is specified, you get whatever works, with preference for an
+# extended mode.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
+# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
+# Copyright (c) 2012 William Fulton <wsf@fultondesigns.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = static_cast<check_type&&>(c);
+])
+
+AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
+ m4_if([$1], [], [],
+ [$1], [ext], [],
+ [$1], [noext], [],
+ [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
+ m4_if([$2], [], [],
+ [$2], [nostop], [],
+ [m4_fatal([invalid argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl
+ AC_LANG_ASSERT([C++])dnl
+ ac_success=no
+ CXX11FLAGS=
+ AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
+ ax_cv_cxx_compile_cxx11,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+ [ax_cv_cxx_compile_cxx11=yes],
+ [ax_cv_cxx_compile_cxx11=no])])
+ if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+ ac_success=yes
+ fi
+
+ m4_if([$1], [noext], [], [dnl
+ if test x$ac_success = xno; then
+ for switch in -std=gnu++11 -std=gnu++0x; do
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+ AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+ $cachevar,
+ [ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $switch"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+ [eval $cachevar=yes],
+ [eval $cachevar=no])
+ CXXFLAGS="$ac_save_CXXFLAGS"])
+ if eval test x\$$cachevar = xyes; then
+ CXXFLAGS="$CXXFLAGS $switch"
+ CXX11FLAGS=$switch
+ ac_success=yes
+ break
+ fi
+ done
+ fi])
+
+ m4_if([$1], [ext], [], [dnl
+ if test x$ac_success = xno; then
+ for switch in -std=c++11 -std=c++0x; do
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+ AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+ $cachevar,
+ [ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $switch"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+ [eval $cachevar=yes],
+ [eval $cachevar=no])
+ CXXFLAGS="$ac_save_CXXFLAGS"])
+ if eval test x\$$cachevar = xyes; then
+ CXXFLAGS="$CXXFLAGS $switch"
+ CXX11FLAGS=$switch
+ ac_success=yes
+ break
+ fi
+ done
+ fi])
+
+ if test x$ac_success = xno; then
+ if test x$2 != xnostop; then
+ AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
+ fi
+ else
+ HAVE_CXX11_COMPILER=yes
+ fi
+])
diff --git a/configure.ac b/configure.ac
index 2d1c4a592..557138dbc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -318,16 +318,39 @@ fi
AC_MSG_RESULT($LINKFORSHARED)
# Optional CFLAGS used to silence/enhance compiler warnings on some platforms.
-AC_MSG_CHECKING(PLATFLAGS)
+AC_MSG_CHECKING(PLATCFLAGS)
case $host in
*-*-solaris*) if test "$GCC" = yes
- then PLATFLAGS=
- else PLATFLAGS=
- # else PLATFLAGS="-errtags=yes" # Need more work as C examples use ld for linking
+ then PLATCFLAGS=
+ else PLATCFLAGS=
+ # else PLATCFLAGS="-errtags=yes" # Need more work as C examples use ld for linking
fi;;
- *) PLATFLAGS=
+ *) PLATCFLAGS=
esac
-AC_MSG_RESULT($PLATFLAGS)
+AC_MSG_RESULT($PLATCFLAGS)
+
+# Add switch if necessary to enable C++11 support - just for tests
+AC_ARG_ENABLE([cpp11-testing], AS_HELP_STRING([--enable-cpp11-testing], [enable C++11 testing if supported by compiler (default disabled)]), [enable_cpp11_testing=$enableval], [enable_cpp11_testing=no])
+AC_MSG_CHECKING([whether to enable C++11 testing])
+AC_MSG_RESULT([$enable_cpp11_testing])
+
+PLATCXXFLAGS="$PLATCFLAGS"
+if test x"$enable_cpp11_testing" = xyes; then
+ AC_LANG_PUSH([C++])
+ CXXFLAGS_SAVED=$CXXFLAGS
+ AX_CXX_COMPILE_STDCXX_11([noext], [nostop])
+ CXXFLAGS=$CXXFLAGS_SAVED
+ AC_LANG_POP([C++])
+ if test x"$CXX11FLAGS" != x; then
+ PLATCXXFLAGS="$CXX11FLAGS $PLATCXXFLAGS"
+ fi
+ AC_MSG_CHECKING([for C++11 enabled compiler])
+ if test x"$HAVE_CXX11_COMPILER" = x; then
+ AC_MSG_RESULT([no])
+ else
+ AC_MSG_RESULT([$HAVE_CXX11_COMPILER])
+ fi
+fi
# Set info about shared libraries.
AC_SUBST(SO)
@@ -336,7 +359,9 @@ AC_SUBST(CCSHARED)
AC_SUBST(CXXSHARED)
AC_SUBST(TRYLINKINGWITHCXX)
AC_SUBST(RPATH)
-AC_SUBST(PLATFLAGS)
+AC_SUBST(PLATCFLAGS)
+AC_SUBST(PLATCXXFLAGS)
+AC_SUBST(HAVE_CXX11_COMPILER)
AC_SUBST(LINKFORSHARED)
# This variation is needed on OS-X because there is no (apparent) consistency in shared library naming.