mirror of https://github.com/swig/swig
Rename all C++0x to C++11 and cpp0x to cpp11
This commit is contained in:
parent
173c4b3bba
commit
738cc36aab
|
@ -24,15 +24,15 @@
|
|||
</STYLE>
|
||||
</HEAD>
|
||||
<BODY LANG="en-US" DIR="LTR">
|
||||
<H1 CLASS="western"><U>C++0x support for SWIG</U></H1>
|
||||
<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 support for the Swig.
|
||||
This area of Swig is a work in progress. Initial C++0x support for
|
||||
<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++0x features status</H1>
|
||||
<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>
|
||||
|
@ -63,12 +63,12 @@ operator=(ClassType&&):</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&& to Swig parser. Added testcase
|
||||
cpp0x_rvalue_reference.i. Operator && is treated the same as
|
||||
cpp11_rvalue_reference.i. Operator && is treated the same as
|
||||
operator &. 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++0x you can define functions as constant expressions.
|
||||
<P>In C++11 you can define functions as constant expressions.
|
||||
Functions need to return constant value in form "return expr",
|
||||
where expr is a constant expression.
|
||||
</P>
|
||||
|
@ -84,7 +84,7 @@ 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
|
||||
cpp0x_constexpr. R11322</P>
|
||||
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>
|
||||
|
@ -94,7 +94,7 @@ 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<MyClass>;'. Added testcase cpp0x_template_explicit.
|
||||
std::vector<MyClass>;'. Added testcase cpp11_template_explicit.
|
||||
R11385 , R11386</P>
|
||||
<H2>Initializer lists [done]</H2>
|
||||
<P>Initializer list is a new type in standard library:
|
||||
|
@ -117,11 +117,11 @@ 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
|
||||
cpp0x_initializer_list. R11450</P>
|
||||
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++0x standard will allow the following:</P>
|
||||
<P>The new C++11 standard will allow the following:</P>
|
||||
<PRE>struct IdString {
|
||||
std::string name;
|
||||
int identifier;
|
||||
|
@ -132,7 +132,7 @@ IdString GetString() {
|
|||
}</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++0x:</P>
|
||||
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>
|
||||
|
@ -154,12 +154,12 @@ 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++0x introduced with
|
||||
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 cpp0x_uniform_initialization. R11413</P>
|
||||
constructor. Added testcase cpp11_uniform_initialization. R11413</P>
|
||||
<H2>Type inference [partially done]</H2>
|
||||
<P>A new keyword 'auto' is introduced in C++0x:</P>
|
||||
<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
|
||||
|
@ -184,7 +184,7 @@ introduce a new SwigType for this.</P>
|
|||
only.
|
||||
</P>
|
||||
<H2>Lambda functions and expressions [done]</H2>
|
||||
<P>C++0x introduces lambda functions defined as:</P>
|
||||
<P>C++11 introduces lambda functions defined as:</P>
|
||||
<PRE STYLE="margin-bottom: 0.5cm">[](int x, int y) -> 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 '->' can be
|
||||
|
@ -210,14 +210,14 @@ 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 cpp0x_lambda_functions.i. R11491, R11492</P>
|
||||
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< typename LHS, typename RHS>
|
||||
decltype(lhs+rhs) AddingFunc(const LHS &lhs, const RHS &rhs) {return lhs + rhs;} //Not legal C++0x</PRE><P>
|
||||
The solution C++0x offers is the combination of the 'auto' keyword
|
||||
decltype(lhs+rhs) AddingFunc(const LHS &lhs, const RHS &rhs) {return lhs + rhs;} //Not legal C++11</PRE><P>
|
||||
The solution C++11 offers is the combination of the 'auto' keyword
|
||||
before and '-> rettype' after the function declaration:</P>
|
||||
<PRE>template< typename LHS, typename RHS>
|
||||
auto AddingFunc(const LHS &lhs, const RHS &rhs) -> decltype(lhs+rhs) {return lhs + rhs;}</PRE><P>
|
||||
|
@ -233,13 +233,13 @@ auto SomeStruct::FuncName(int x, int y) -> int {
|
|||
}</PRE><P>
|
||||
Done: Added support for the 'auto' return type. Added support for the
|
||||
'-> type' after the funtion declaration. Added testcases
|
||||
cpp0x_alternate_function_syntax.i and
|
||||
cpp0x_alternate_function_syntax_runme.py. R11414</P>
|
||||
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++0x adds support for the "concepts". The
|
||||
and unreadable. C++11 adds support for the "concepts". 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.
|
||||
|
@ -293,7 +293,7 @@ other constructs commonly associated with classes:
|
|||
T top(const std::vector<T>& v) { return v.back(); }
|
||||
bool empty(const std::vector<T>& v) { return v.empty(); }
|
||||
};</PRE><P>
|
||||
Axioms are a facility pertaining to concepts supplied by C++0x to
|
||||
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>
|
||||
|
@ -306,7 +306,7 @@ Semigroup can be defined with an axiom Associativity as:
|
|||
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++0x standard.
|
||||
<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
|
||||
|
@ -335,7 +335,7 @@ the inherited class:
|
|||
};</PRE><P>
|
||||
Swig already correctly parses and produces the correct wrapper for
|
||||
the “using” keyword.</P>
|
||||
<P>Done: Added testcase cpp0x_constructors.i which covers both
|
||||
<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
|
||||
|
@ -351,11 +351,11 @@ this feature.</P>
|
|||
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 cpp0x_null_pointer_constant.i and
|
||||
cpp0x_null_pointer_constant_runme.py to prove the nullptr
|
||||
<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++0x introduces a new syntax for strongly typed enum declaration:
|
||||
<P>C++11 introduces a new syntax for strongly typed enum declaration:
|
||||
</P>
|
||||
<PRE> enum class Enumeration {
|
||||
Val1,
|
||||
|
@ -371,16 +371,16 @@ int etc.:
|
|||
<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++0x; no size is explicitly specified.
|
||||
enum Enum2 : unsigned int; //Legal in C++0x.
|
||||
enum class Enum3; //Legal in C++0x, because enum class declarations have a default type of "int".
|
||||
enum class Enum4: unsigned int; //Legal C++0x.
|
||||
enum Enum2 : unsigned short; //Illegal in C++0x, because Enum2 was previously declared with a different type.</PRE><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 "int".
|
||||
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 cpp0x_strongly_typed_enums.i
|
||||
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
|
||||
|
@ -396,7 +396,7 @@ following article as a base:
|
|||
</P>
|
||||
<P>Done: Added support for angle brackets. Used the preferred
|
||||
"Approach 1". Added a testcase named
|
||||
cpp0x_template_double_brackets. R11245</P>
|
||||
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
|
||||
|
@ -407,9 +407,9 @@ supported in any target language (eg. python, php).
|
|||
</P>
|
||||
<P>Done: Swig already supports the keyword "explicit" for
|
||||
function types as well. Added test case
|
||||
cpp0x_explicit_conversion_operators. R11323</P>
|
||||
cpp11_explicit_conversion_operators. R11323</P>
|
||||
<H2>Template typedefs [partially done]</H2>
|
||||
<P>The new C++0x will allow creation of wrapper around the template.
|
||||
<P>The new C++11 will allow creation of wrapper around the template.
|
||||
For example, if we want to do this:</P>
|
||||
<PRE>template< typename first, typename second, int third>
|
||||
class SomeType;
|
||||
|
@ -433,7 +433,7 @@ 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<int> intList;</PRE><P>
|
||||
Done: Expanded support for the new 'using' syntax and template
|
||||
aliasing. Added testcase cpp0x_template_typedefs. R11533</P>
|
||||
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
|
||||
|
@ -443,7 +443,7 @@ 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++0x standard allows usage of types with
|
||||
constructors only. The new C++11 standard allows usage of types with
|
||||
non-trivial constructors as well:</P>
|
||||
<PRE> struct point {
|
||||
point() {}
|
||||
|
@ -453,14 +453,14 @@ non-trivial constructors as well:</P>
|
|||
union P {
|
||||
int z;
|
||||
double w;
|
||||
point p; // Illegal in C++; point has a non-trivial constructor. However, this is legal in C++0x.
|
||||
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 cpp0x_unrestricted_unions. R11435, R11447</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++0x offers the following syntax:</P>
|
||||
<P>The new C++11 offers the following syntax:</P>
|
||||
<PRE STYLE="margin-bottom: 0.5cm">template<typename... Values> class tuple;</PRE><P>
|
||||
This can be used for example:</P>
|
||||
<PRE STYLE="margin-bottom: 0.5cm">class tuple<int, std::vector<int>, std::map<std::string, std::vector<int>>> someInstanceName;</PRE><P>
|
||||
|
@ -502,7 +502,7 @@ A new extension to sizeof is also introduced with this feature. The
|
|||
}
|
||||
// SomeStruct<Type1, Type2>::size is 2 and SomeStruct<>::size is 0</PRE><P>
|
||||
Done: Added syntax support for 'typename' or 'class' + ... + id.
|
||||
Added testcase cpp0x_variadic_templates. R11458</P>
|
||||
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>
|
||||
|
@ -510,11 +510,11 @@ Extended Swig syntax to support sizeof...(Args). R11467</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++0x Unicode and custom
|
||||
<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 cpp0x_raw_string_literals. R11327</P>
|
||||
UTF string. Also added test case cpp11_raw_string_literals. R11327</P>
|
||||
<P>Done: Added R"DELIMITER[, ]DELIMITER" 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
|
||||
|
@ -524,7 +524,7 @@ Source/Preprocessor/cpp.c.</P>
|
|||
<P>C++ has different suffix literals. eg. 12.5f marks the number 12.5
|
||||
as float.
|
||||
</P>
|
||||
<P>C++0x allows user to define his own suffix for the strings always
|
||||
<P>C++11 allows user to define his own suffix for the strings always
|
||||
starting with the underscore (_). eg. int a = "hello"_mySuffix;
|
||||
</P>
|
||||
<P>The syntax is similar to other operator overloading functions:
|
||||
|
@ -548,18 +548,18 @@ Another possibility is to use variadic templates:
|
|||
This instantiates the literal processing function as
|
||||
operator""_Suffix<'1', '2', '3', '4'>. In this form,
|
||||
there is no terminating null character to the string. The main
|
||||
purpose to doing this is to use C++0x's constexpr keyword and the
|
||||
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 cpp0x_userdefined_literals.i. R11494</P>
|
||||
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++0x introduces keyword "thread_local" which marks
|
||||
<P>New C++11 introduces keyword "thread_local" which marks
|
||||
the following variable dynamically located depending on the current
|
||||
thread when using the address-of (&) operator.
|
||||
</P>
|
||||
|
@ -569,7 +569,7 @@ thread when using the address-of (&) operator.
|
|||
thread_local int val;
|
||||
};</PRE><P>
|
||||
Done: Add "thread_local" keyword to Swig. Added testcase
|
||||
cpp0x_thread_local. R11393</P>
|
||||
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.
|
||||
|
@ -600,11 +600,11 @@ the standard functions brought by C++ itself.
|
|||
Ignored: Swig already parses the keywords "= delete" and "=
|
||||
default". These keywords are used for built-in functions (copy
|
||||
constructor, operator= etc.), which are ignored by Swig anyway.</P>
|
||||
<P>Done: Added testcase cpp0x_default_delete. R11535</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++0x. Most C++ compilers supported it though.
|
||||
C++11. Most C++ compilers supported it though.
|
||||
</P>
|
||||
<P>Done: Swig already parses the C code including the long long type.
|
||||
</P>
|
||||
|
@ -616,18 +616,18 @@ C++0x. Most C++ compilers supported it though.
|
|||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};</PRE><P>
|
||||
Done: Added syntax support for "static_assert()". Added
|
||||
test case cpp0x_static_assert. R11369</P>
|
||||
test case cpp11_static_assert. R11369</P>
|
||||
<H2>Allow sizeof to work on members of classes without an explicit
|
||||
object [done]</H2>
|
||||
<P>C++0x allows calls of sizeof to concrete objects as well:
|
||||
<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++0x</PRE><P>
|
||||
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 cpp0x_sizeof_objects. R11538
|
||||
<P>Done: Added testcase cpp11_sizeof_objects. R11538
|
||||
</P>
|
||||
<H2>Threading facilities [ignored]</H2>
|
||||
<P>C++0x will add the following classes to the standard library:
|
||||
<P>C++11 will add the following classes to the standard library:
|
||||
</P>
|
||||
<PRE> * std::thread
|
||||
* std::mutex, std::recursive_mutex
|
||||
|
@ -637,7 +637,7 @@ This kind of syntax is already supported by Swig.</P>
|
|||
Ignored: No changes to the language itself is made.
|
||||
</P>
|
||||
<H2>Tuple types [TODO]</H2>
|
||||
<P>Tuple is array of various types. C++0x introduced this feature
|
||||
<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 <class ...Types> class tuple;</PRE><P>
|
||||
Constructor is automatically generated filling the tuple elements.
|
||||
|
@ -655,7 +655,7 @@ 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<> class.</P>
|
||||
<H2>Hash tables [TODO]</H2>
|
||||
<P>C++0x introduces the "unordered" version of existing
|
||||
<P>C++11 introduces the "unordered" version of existing
|
||||
types, which in practice work faster than the linear types:
|
||||
</P>
|
||||
<PRE> - unordered set
|
||||
|
@ -671,7 +671,7 @@ 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++0x: basic_regex and
|
||||
<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
|
||||
|
@ -725,9 +725,9 @@ changes to Swig needed.
|
|||
};</PRE><P>
|
||||
Swig already supports the two.</P>
|
||||
<P>Done: Added a runtime testcase for function objects
|
||||
cpp0x_function_objects. R11419.</P>
|
||||
cpp11_function_objects. R11419.</P>
|
||||
<H2>Type traits for metaprogramming [ignored]</H2>
|
||||
<P>C++0x adds a new header file <type_traits> which includes
|
||||
<P>C++11 adds a new header file <type_traits> which includes
|
||||
helper functions to determine the template type while initializing
|
||||
the object at compile time.
|
||||
</P>
|
||||
|
@ -783,6 +783,6 @@ class calculus_ver2 {
|
|||
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 cpp0x_result_of. R11534</P>
|
||||
<P>Done: Added testcase cpp11_result_of. R11534</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</HTML>
|
|
@ -1,54 +1,54 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>SWIG and C++0x</title>
|
||||
<title>SWIG and C++11</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
<H1><a name="Cpp0x"></a>7 SWIG and C++0x</H1>
|
||||
<H1><a name="CPlusPlus11"></a>7 SWIG and C++11</H1>
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="#Cpp0x_Introduction">Introduction</a>
|
||||
<li><a href="#Cpp0x_Core_language_changes">Core language changes</a>
|
||||
<li><a href="#CPlusPlus11_Introduction">Introduction</a>
|
||||
<li><a href="#CPlusPlus11_Core_language_changes">Core language changes</a>
|
||||
<ul>
|
||||
<li><a href="#Cpp0x_Rvalue_reference_and_move_semantics">Rvalue reference and move semantics</a>
|
||||
<li><a href="#Cpp0x_Generalized_constant_expressions">Generalized constant expressions</a>
|
||||
<li><a href="#Cpp0x_Extern_template">Extern template</a>
|
||||
<li><a href="#Cpp0x_Initializer_lists">Initializer lists</a>
|
||||
<li><a href="#Cpp0x_Uniform_initialization">Uniform initialization</a>
|
||||
<li><a href="#Cpp0x_Type_inference">Type inference</a>
|
||||
<li><a href="#Cpp0x_Range_based_for_loop">Range-based for-loop</a>
|
||||
<li><a href="#Cpp0x_Lambda_functions_and_expressions">Lambda functions and expressions</a>
|
||||
<li><a href="#Cpp0x_Alternate_function_syntax">Alternate function syntax</a>
|
||||
<li><a href="#Cpp0x_Object_construction_improvement">Object construction improvement</a>
|
||||
<li><a href="#Cpp0x_Null_pointer_constant">Null pointer constant</a>
|
||||
<li><a href="#Cpp0x_Strongly_typed_enumerations">Strongly typed enumerations</a>
|
||||
<li><a href="#Cpp0x_Double_angle_brackets">Double angle brackets</a>
|
||||
<li><a href="#Cpp0x_Explicit_conversion_operators">Explicit conversion operators</a>
|
||||
<li><a href="#Cpp0x_Alias_templates">Alias templates</a>
|
||||
<li><a href="#Cpp0x_Unrestricted_unions">Unrestricted unions</a>
|
||||
<li><a href="#Cpp0x_Variadic_templates">Variadic templates</a>
|
||||
<li><a href="#Cpp0x_New_string_literals">New string literals</a>
|
||||
<li><a href="#Cpp0x_User_defined_literals">User-defined literals</a>
|
||||
<li><a href="#Cpp0x_Thread_local_storage">Thread-local storage</a>
|
||||
<li><a href="#Cpp0x_Defaulting/deleting_of_standard_functions_on_C++_objects">Defaulting/deleting of standard functions on C++ objects</a>
|
||||
<li><a href="#Cpp0x_Type_long_long_int">Type long long int</a>
|
||||
<li><a href="#Cpp0x_Static_assertions">Static assertions</a>
|
||||
<li><a href="#Cpp0x_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>
|
||||
<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="#Cpp0x_Standard_library_changes">Standard library changes</a>
|
||||
<li><a href="#CPlusPlus11_Standard_library_changes">Standard library changes</a>
|
||||
<ul>
|
||||
<li><a href="#Cpp0x_Threading_facilities">Threading facilities</a>
|
||||
<li><a href="#Cpp0x_Tuple_types">Tuple types and hash tables</a>
|
||||
<li><a href="#Cpp0x_Regular_expressions">Regular expressions</a>
|
||||
<li><a href="#Cpp0x_General_purpose_smart_pointers">General-purpose smart pointers</a>
|
||||
<li><a href="#Cpp0x_Extensible_random_number_facility">Extensible random number facility</a>
|
||||
<li><a href="#Cpp0x_Wrapper_reference">Wrapper reference</a>
|
||||
<li><a href="#Cpp0x_Polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
|
||||
<li><a href="#Cpp0x_Type_traits_for_metaprogramming">Type traits for metaprogramming</a>
|
||||
<li><a href="#Cpp0x_Uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
|
||||
<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>
|
||||
|
@ -56,22 +56,22 @@
|
|||
|
||||
|
||||
|
||||
<H2><a name="Cpp0x_Introduction"></a>7.1 Introduction</H2>
|
||||
<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++0x standard. This part of SWIG is still a work in
|
||||
progress. Initial C++0x support for SWIG was written during the
|
||||
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="Cpp0x_Core_language_changes"></a>7.2 Core language changes</H2>
|
||||
<H2><a name="CPlusPlus11_Core_language_changes"></a>7.2 Core language changes</H2>
|
||||
|
||||
|
||||
<H3><a name="Cpp0x_Rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
|
||||
<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 && the same as the reference operator &.</p>
|
||||
|
@ -87,7 +87,7 @@ class MyClass {
|
|||
};
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
|
||||
<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>
|
||||
|
@ -105,7 +105,7 @@ constexpr int myConstFunc() { return MY_CONST; }
|
|||
const int a = MY_CONST; // ok
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Extern_template"></a>7.2.3 Extern template</H3>
|
||||
<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>
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
};
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Initializer_lists"></a>7.2.4 Initializer lists</H3>
|
||||
<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
|
||||
|
@ -254,7 +254,7 @@ Note that the default typemap for <tt>std::initializer_list</tt> does nothing bu
|
|||
and hence any user supplied typemaps will override it and suppress the warning.
|
||||
</p>
|
||||
|
||||
<H3><a name="Cpp0x_Uniform_initialization"></a>7.2.5 Uniform initialization</H3>
|
||||
<H3><a name="CPlusPlus11_Uniform_initialization"></a>7.2.5 Uniform initialization</H3>
|
||||
|
||||
|
||||
<p>The curly brackets {} for member initialization are fully
|
||||
|
@ -287,7 +287,7 @@ AltStruct var2{2, 4.3}; // calls the constructor
|
|||
142.15
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Type_inference"></a>7.2.6 Type inference</H3>
|
||||
<H3><a name="CPlusPlus11_Type_inference"></a>7.2.6 Type inference</H3>
|
||||
|
||||
|
||||
<p>SWIG supports <tt>decltype()</tt> with some limitations. Single
|
||||
|
@ -304,13 +304,13 @@ int i; int j;
|
|||
decltype(i+j) k; // syntax error
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
|
||||
<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="Cpp0x_Lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
|
||||
<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>
|
||||
|
@ -336,7 +336,7 @@ auto six = [](int x, int y) { return x+y; }(4, 2);
|
|||
Better support should be available in a later release.
|
||||
</p>
|
||||
|
||||
<H3><a name="Cpp0x_Alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
|
||||
<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>
|
||||
|
@ -346,7 +346,7 @@ struct SomeStruct {
|
|||
};
|
||||
</pre></div>
|
||||
|
||||
<p>can now be written as in C++0x:</p>
|
||||
<p>can now be written as in C++11:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
struct SomeStruct {
|
||||
|
@ -371,7 +371,7 @@ auto SomeStruct::FuncName(int x, int y) -> int {
|
|||
auto square(float a, float b) -> decltype(a);
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
|
||||
<H3><a name="CPlusPlus11_Object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
@ -412,12 +412,12 @@ class DerivedClass: public BaseClass {
|
|||
};
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
|
||||
<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="Cpp0x_Strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>
|
||||
<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>
|
||||
|
@ -468,7 +468,7 @@ class AllColors {
|
|||
};
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
|
||||
<H3><a name="CPlusPlus11_Double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
|
||||
|
||||
|
||||
<p>SWIG correctly parses the symbols >> as closing the
|
||||
|
@ -479,7 +479,7 @@ shift operator >> otherwise.</p>
|
|||
std::vector<std::vector<int>> myIntTable;
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Explicit_conversion_operators"></a>7.2.14 Explicit conversion operators</H3>
|
||||
<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.
|
||||
|
@ -515,7 +515,7 @@ SWIG target languages, because all use their own facilities (eg. classes Cloneab
|
|||
to achieve particular copy and compare behaviours.
|
||||
</p>
|
||||
|
||||
<H3><a name="Cpp0x_Alias_templates"></a>7.2.15 Alias templates</H3>
|
||||
<H3><a name="CPlusPlus11_Alias_templates"></a>7.2.15 Alias templates</H3>
|
||||
|
||||
<p>
|
||||
The following is an example of an alias template:
|
||||
|
@ -567,7 +567,7 @@ example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully sup
|
|||
typedef void (*PFD)(double); // The old style
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Unrestricted_unions"></a>7.2.16 Unrestricted unions</H3>
|
||||
<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
|
||||
|
@ -593,7 +593,7 @@ union P {
|
|||
} p1;
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Variadic_templates"></a>7.2.17 Variadic templates</H3>
|
||||
<H3><a name="CPlusPlus11_Variadic_templates"></a>7.2.17 Variadic templates</H3>
|
||||
|
||||
|
||||
<p>SWIG supports the variadic templates syntax (inside the <>
|
||||
|
@ -628,7 +628,7 @@ const int SIZE = sizeof...(ClassName<int, int>);
|
|||
In the above example <tt>SIZE</tt> is of course wrapped as a constant.
|
||||
</p>
|
||||
|
||||
<H3><a name="Cpp0x_New_string_literals"></a>7.2.18 New string literals</H3>
|
||||
<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>
|
||||
|
@ -652,7 +652,7 @@ const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";
|
|||
<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="Cpp0x_User_defined_literals"></a>7.2.19 User-defined literals</H3>
|
||||
<H3><a name="CPlusPlus11_User_defined_literals"></a>7.2.19 User-defined literals</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
@ -719,7 +719,7 @@ OutputType var2 = 1234_suffix;
|
|||
OutputType var3 = 3.1416_suffix;
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Thread_local_storage"></a>7.2.20 Thread-local storage</H3>
|
||||
<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
|
||||
|
@ -739,7 +739,7 @@ A variable will be thread local if accessed from different threads from the targ
|
|||
same way that it will be thread local if accessed from C++ code.
|
||||
</p>
|
||||
|
||||
<H3><a name="Cpp0x_Defaulting/deleting_of_standard_functions_on_C++_objects"></a>7.2.21 Defaulting/deleting of standard functions on C++ objects</H3>
|
||||
<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>
|
||||
|
@ -757,12 +757,12 @@ struct NonCopyable {
|
|||
<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="Cpp0x_Type_long_long_int"></a>7.2.22 Type long long int</H3>
|
||||
<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="Cpp0x_Static_assertions"></a>7.2.23 Static assertions</H3>
|
||||
<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>
|
||||
|
@ -774,7 +774,7 @@ struct Check {
|
|||
};
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_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>
|
||||
<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
|
||||
|
@ -785,7 +785,7 @@ struct A {
|
|||
int member;
|
||||
};
|
||||
|
||||
const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++0x
|
||||
const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11
|
||||
</pre></div>
|
||||
|
||||
<p>In Python:</p>
|
||||
|
@ -794,28 +794,28 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++0x
|
|||
8
|
||||
</pre></div>
|
||||
|
||||
<H2><a name="Cpp0x_Standard_library_changes"></a>7.3 Standard library changes</H2>
|
||||
<H2><a name="CPlusPlus11_Standard_library_changes"></a>7.3 Standard library changes</H2>
|
||||
|
||||
|
||||
<H3><a name="Cpp0x_Threading_facilities"></a>7.3.1 Threading facilities</H3>
|
||||
<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="Cpp0x_Tuple_types"></a>7.3.2 Tuple types and hash tables</H3>
|
||||
<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="Cpp0x_Regular_expressions"></a>7.3.3 Regular expressions</H3>
|
||||
<H3><a name="CPlusPlus11_Regular_expressions"></a>7.3.3 Regular expressions</H3>
|
||||
|
||||
|
||||
<p>SWIG does not wrap the new C++0x regular expressions classes, because the SWIG target languages use their own facilities for this.</p>
|
||||
<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="Cpp0x_General_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
|
||||
<H3><a name="CPlusPlus11_General_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
@ -823,12 +823,12 @@ SWIG provides special smart pointer handling for <tt>std::tr1::shared_ptr</tt> i
|
|||
There is no special smart pointer handling available for <tt>std::weak_ptr</tt> and <tt>std::unique_ptr</tt>.
|
||||
</p>
|
||||
|
||||
<H3><a name="Cpp0x_Extensible_random_number_facility"></a>7.3.5 Extensible random number facility</H3>
|
||||
<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="Cpp0x_Wrapper_reference"></a>7.3.6 Wrapper reference</H3>
|
||||
<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>
|
||||
|
@ -853,7 +853,7 @@ int main() {
|
|||
|
||||
<p>The ref and cref classes are not wrapped by SWIG because the SWIG target languages do not support referencing.</p>
|
||||
|
||||
<H3><a name="Cpp0x_Polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
|
||||
<H3><a name="CPlusPlus11_Polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
@ -884,7 +884,7 @@ t = Test()
|
|||
b = t(1,2) # invoke C++ function object
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Cpp0x_Type_traits_for_metaprogramming"></a>7.3.8 Type traits for metaprogramming</H3>
|
||||
<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>
|
||||
|
@ -909,7 +909,7 @@ template< class T1, class T2 > int elaborate( T1 A, T2 B ) {
|
|||
<p>SWIG correctly parses the template specialization, template types and values inside the <> 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="Cpp0x_Uniform_method_for_computing_return_type_of_function_objects"></a>7.3.9 Uniform method for computing return type of function objects</H3>
|
||||
<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 <functional> header and map the result_of::type to the concrete type yet. For example:</p>
|
|
@ -4,7 +4,7 @@ Windows.html
|
|||
Scripting.html
|
||||
SWIG.html
|
||||
SWIGPlus.html
|
||||
Cpp0x.html
|
||||
CPlusPlus11.html
|
||||
Preprocessor.html
|
||||
Library.html
|
||||
Arguments.html
|
||||
|
|
|
@ -87,7 +87,7 @@ CPP_TEST_BROKEN += \
|
|||
overload_complicated \
|
||||
template_default_pointer \
|
||||
template_expr \
|
||||
$(CPP0X_TEST_BROKEN)
|
||||
$(CPP11_TEST_BROKEN)
|
||||
|
||||
|
||||
# Broken C test cases. (Can be run individually using: make testcase.ctest)
|
||||
|
@ -97,7 +97,7 @@ C_TEST_BROKEN += \
|
|||
|
||||
# C++ test cases. (Can be run individually using: make testcase.cpptest)
|
||||
CPP_TEST_CASES += \
|
||||
$(CPP0X_TEST_CASES) \
|
||||
$(CPP11_TEST_CASES) \
|
||||
abstract_access \
|
||||
abstract_inherit \
|
||||
abstract_inherit_ok \
|
||||
|
@ -476,41 +476,41 @@ CPP_TEST_CASES += \
|
|||
wallkw \
|
||||
wrapmacro
|
||||
|
||||
# C++0x test cases.
|
||||
CPP0X_TEST_CASES = \
|
||||
cpp0x_alternate_function_syntax \
|
||||
cpp0x_constexpr \
|
||||
cpp0x_decltype \
|
||||
cpp0x_default_delete \
|
||||
cpp0x_delegating_constructors \
|
||||
cpp0x_explicit_conversion_operators \
|
||||
cpp0x_function_objects \
|
||||
cpp0x_initializer_list \
|
||||
cpp0x_initializer_list_extend \
|
||||
cpp0x_lambda_functions \
|
||||
cpp0x_null_pointer_constant \
|
||||
cpp0x_raw_string_literals \
|
||||
cpp0x_rvalue_reference \
|
||||
cpp0x_rvalue_reference2 \
|
||||
cpp0x_rvalue_reference3 \
|
||||
cpp0x_sizeof_object \
|
||||
cpp0x_static_assert \
|
||||
cpp0x_strongly_typed_enumerations \
|
||||
cpp0x_template_double_brackets \
|
||||
cpp0x_template_explicit \
|
||||
cpp0x_template_typedefs \
|
||||
cpp0x_uniform_initialization \
|
||||
cpp0x_unrestricted_unions \
|
||||
cpp0x_userdefined_literals \
|
||||
cpp0x_variadic_templates
|
||||
# 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
|
||||
|
||||
# cpp0x_inheriting_constructors \ # not supported by gcc-4.7
|
||||
# cpp0x_hash_tables \ # not fully implemented yet
|
||||
# cpp0x_result_of \ # SWIG does not support
|
||||
# cpp0x_thread_local \ # needs gcc-4.8
|
||||
# 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++0x test cases.
|
||||
CPP0X_TEST_BROKEN =
|
||||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN =
|
||||
|
||||
#
|
||||
# Put all the heavy STD/STL cases here, where they can be skipped if needed
|
||||
|
@ -626,7 +626,7 @@ all: $(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES)
|
|||
|
||||
check: $(NOT_BROKEN_TEST_CASES)
|
||||
|
||||
check-cpp11: $(CPP0X_TEST_CASES:=.cpptest)
|
||||
check-cpp11: $(CPP11_TEST_CASES:=.cpptest)
|
||||
|
||||
# partialcheck target runs SWIG only, ie no compilation or running of tests (for a subset of languages)
|
||||
partialcheck:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly uses the new alternate functions
|
||||
declarations and definitions introduced in C++0x. */
|
||||
%module cpp0x_alternate_function_syntax
|
||||
declarations and definitions introduced in C++11. */
|
||||
%module cpp11_alternate_function_syntax
|
||||
|
||||
%inline %{
|
||||
struct SomeStruct {
|
|
@ -1,7 +1,7 @@
|
|||
/* This interface tests whether SWIG supports the new "constexpr" keyword
|
||||
introduced by C++0x.
|
||||
introduced by C++11.
|
||||
*/
|
||||
%module cpp0x_constexpr
|
||||
%module cpp11_constexpr
|
||||
|
||||
%inline %{
|
||||
class TestClass {
|
|
@ -1,7 +1,7 @@
|
|||
/* This testcase checks whether SWIG correctly uses the new 'decltype()'
|
||||
introduced in C++0x.
|
||||
introduced in C++11.
|
||||
*/
|
||||
%module cpp0x_decltype
|
||||
%module cpp11_decltype
|
||||
|
||||
%inline %{
|
||||
class A {
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly parses the default and delete
|
||||
keywords which keep or remove default C++ object construction functions. */
|
||||
%module cpp0x_default_delete
|
||||
%module cpp11_default_delete
|
||||
|
||||
%{
|
||||
#include <stdlib.h>
|
|
@ -1,7 +1,7 @@
|
|||
/* This test checks whether SWIG correctly parses the new delegating
|
||||
constructors.
|
||||
*/
|
||||
%module cpp0x_delegating_constructors
|
||||
%module cpp11_delegating_constructors
|
||||
|
||||
%inline %{
|
||||
class A {
|
|
@ -1,7 +1,7 @@
|
|||
/* This interface checks whether SWIG correctly compiles the new
|
||||
explicit conversion operators feature introduced in C++0x.
|
||||
explicit conversion operators feature introduced in C++11.
|
||||
*/
|
||||
%module cpp0x_explicit_conversion_operators
|
||||
%module cpp11_explicit_conversion_operators
|
||||
|
||||
%inline %{
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
Function objects are objects which overload the operator() function.
|
||||
The std::function does not provide any seamless support in the target languages yet.
|
||||
*/
|
||||
%module cpp0x_function_objects
|
||||
%module cpp11_function_objects
|
||||
|
||||
%rename(__call__) Test::operator();
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks the new wrappers for the new unordered_ STL types
|
||||
introduced in C++0x. */
|
||||
%module cpp0x_hash_tables
|
||||
introduced in C++11. */
|
||||
%module cpp11_hash_tables
|
||||
|
||||
%inline %{
|
||||
#include <set>
|
|
@ -1,7 +1,7 @@
|
|||
/* This test checks whether SWIG correctly parses the new constructor
|
||||
inheritance.
|
||||
*/
|
||||
%module cpp0x_inheriting_constructors
|
||||
%module cpp11_inheriting_constructors
|
||||
|
||||
%inline %{
|
||||
class BaseClass {
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase shows a few simple ways to deal with the new initializer_list
|
||||
introduced in C++0x. */
|
||||
%module cpp0x_initializer_list
|
||||
introduced in C++11. */
|
||||
%module cpp11_initializer_list
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_INITIALIZER_LIST) B::B;
|
||||
%ignore A::A(std::initializer_list<int>);
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase shows how to replace std_initializer_list with std_vector. */
|
||||
|
||||
%module cpp0x_initializer_list_extend
|
||||
%module cpp11_initializer_list_extend
|
||||
|
||||
%ignore Container::Container(std::initializer_list<int>);
|
||||
%include <std_vector.i>
|
|
@ -1,9 +1,9 @@
|
|||
/* This testcase checks whether SWIG correctly parses the lambda expressions
|
||||
and closure syntax introduced in C++0x.
|
||||
and closure syntax introduced in C++11.
|
||||
SWIG supports only lambda syntax and doesn't produce any wrapper code for
|
||||
this.
|
||||
*/
|
||||
%module cpp0x_lambda_functions
|
||||
%module cpp11_lambda_functions
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda1;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) lambda2;
|
|
@ -1,8 +1,8 @@
|
|||
/* This testcase checks whether SWIG correctly treats the new nullptr_t
|
||||
constant introduced in C++0x.
|
||||
constant introduced in C++11.
|
||||
*/
|
||||
|
||||
%module cpp0x_null_pointer_constant
|
||||
%module cpp11_null_pointer_constant
|
||||
|
||||
%feature("autodoc") A::NullPtrMethod; // Triggers conversion of nullptr to None, nil etc in target language
|
||||
%feature("compactdefaultargs") A::NullPtrMethod;
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
This module also tests whether SWIG correctly parses custom string delimiters.
|
||||
*/
|
||||
%module cpp0x_raw_string_literals
|
||||
%module cpp11_raw_string_literals
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) bb;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) ee;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) gg;
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly uses the new result_of class
|
||||
and its templating capabilities introduced in C++0x. */
|
||||
%module cpp0x_result_of
|
||||
and its templating capabilities introduced in C++11. */
|
||||
%module cpp11_result_of
|
||||
|
||||
%inline %{
|
||||
#include <functional>
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly parses the double ampersand &&
|
||||
move operator which is currently mapped to the reference & operator. */
|
||||
%module cpp0x_rvalue_reference
|
||||
%module cpp11_rvalue_reference
|
||||
|
||||
%inline %{
|
||||
#include <utility>
|
|
@ -1,4 +1,4 @@
|
|||
%module cpp0x_rvalue_reference2
|
||||
%module cpp11_rvalue_reference2
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) globalrrval;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
%module cpp0x_rvalue_reference3
|
||||
%module cpp11_rvalue_reference3
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly uses the sizeof() on the
|
||||
concrete objects and not only types introduced in C++0x. */
|
||||
%module cpp0x_sizeof_object
|
||||
concrete objects and not only types introduced in C++11. */
|
||||
%module cpp11_sizeof_object
|
||||
|
||||
%inline %{
|
||||
struct B {
|
|
@ -1,7 +1,7 @@
|
|||
/* This test case checks whether SWIG correctly parses and ignores the
|
||||
keywords "static_assert()" inside the class or struct.
|
||||
*/
|
||||
%module cpp0x_static_assert
|
||||
%module cpp11_static_assert
|
||||
|
||||
%inline %{
|
||||
template <typename T>
|
|
@ -1,7 +1,7 @@
|
|||
/* 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 cpp0x_strongly_typed_enumerations
|
||||
%module cpp11_strongly_typed_enumerations
|
||||
%warnfilter(302) Val1;
|
||||
%warnfilter(302) Val2;
|
||||
%warnfilter(302) Val3;
|
||||
|
@ -30,13 +30,13 @@ enum class Enum2 : short {
|
|||
%}
|
||||
|
||||
// SWIG should fail this one
|
||||
enum Enum2 : unsigned short; // Illegal in C++0x, because Enum2 was previously declared with a different type.
|
||||
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++0x.
|
||||
enum class Enum5; // Legal in C++0x, because enum class declarations have a default type of "int".
|
||||
enum class Enum6 : unsigned int; // Legal C++0x.
|
||||
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
|
|
@ -1,8 +1,8 @@
|
|||
/* 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++0x standard.
|
||||
introduced in new C++11 standard.
|
||||
*/
|
||||
%module cpp0x_template_double_brackets
|
||||
%module cpp11_template_double_brackets
|
||||
%inline %{
|
||||
#include <map>
|
||||
std::map<int,std::map<int, double>> map1;
|
|
@ -1,8 +1,8 @@
|
|||
/* This unit tests whether SWIG correctly parses the code and makes wrappers
|
||||
for the new C++0x extern templates (explicit template instantiation without
|
||||
for the new C++11 extern templates (explicit template instantiation without
|
||||
using the translation unit).
|
||||
*/
|
||||
%module cpp0x_template_explicit
|
||||
%module cpp11_template_explicit
|
||||
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_EXPLICIT_TEMPLATE
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* This testcase checks whether SWIG correctly parses alias templates. */
|
||||
%module cpp0x_template_typedefs
|
||||
%module cpp11_template_typedefs
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly parses the 'thread_local' storage specifier */
|
||||
|
||||
%module cpp0x_thread_local
|
||||
%module cpp11_thread_local
|
||||
|
||||
%inline %{
|
||||
struct ThreadLocals {
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG syntactically correctly parses the initialization syntax using
|
||||
{} braces for uniform member initialization. */
|
||||
%module cpp0x_uniform_initialization
|
||||
%module cpp11_uniform_initialization
|
||||
|
||||
%include <std_vector.i>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly parses the support for types
|
||||
without the defined trivial constructor in the unions. */
|
||||
%module cpp0x_unrestricted_unions
|
||||
%module cpp11_unrestricted_unions
|
||||
|
||||
%inline %{
|
||||
struct point {
|
|
@ -1,6 +1,6 @@
|
|||
/* This testcase checks whether SWIG correctly parses the user-defined literals
|
||||
introduced in C++0x. */
|
||||
%module cpp0x_userdefined_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);
|
|
@ -3,7 +3,7 @@
|
|||
the template brackets, new functions sizeof... and multiple inheritance
|
||||
using variadic number of classes.
|
||||
*/
|
||||
%module cpp0x_variadic_templates
|
||||
%module cpp11_variadic_templates
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiArgs;
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) SizeOf;
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiInherit;
|
|
@ -1,10 +1,10 @@
|
|||
import cpp0x_lambda_functions.*;
|
||||
import cpp11_lambda_functions.*;
|
||||
|
||||
public class cpp0x_lambda_functions_runme {
|
||||
public class cpp11_lambda_functions_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp0x_lambda_functions");
|
||||
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);
|
||||
|
@ -18,11 +18,11 @@ public class cpp0x_lambda_functions_runme {
|
|||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
check(cpp0x_lambda_functions.runLambda1(), 11);
|
||||
check(cpp0x_lambda_functions.runLambda2(), 11);
|
||||
check(cpp0x_lambda_functions.runLambda3(), 11);
|
||||
check(cpp0x_lambda_functions.runLambda4(), 11);
|
||||
check(cpp0x_lambda_functions.runLambda5(), 1);
|
||||
check(cpp0x_lambda_functions.runLambda5(), 2);
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import cpp0x_thread_local.*;
|
||||
import cpp11_thread_local.*;
|
||||
|
||||
public class cpp0x_thread_local_runme {
|
||||
public class cpp11_thread_local_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp0x_thread_local");
|
||||
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);
|
||||
|
@ -20,32 +20,32 @@ public class cpp0x_thread_local_runme {
|
|||
if (ThreadLocals.tscval99 != 99)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setEtval(-11);
|
||||
if (cpp0x_thread_local.getEtval() != -11)
|
||||
cpp11_thread_local.setEtval(-11);
|
||||
if (cpp11_thread_local.getEtval() != -11)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setStval(-22);
|
||||
if (cpp0x_thread_local.getStval() != -22)
|
||||
cpp11_thread_local.setStval(-22);
|
||||
if (cpp11_thread_local.getStval() != -22)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setTsval(-33);
|
||||
if (cpp0x_thread_local.getTsval() != -33)
|
||||
cpp11_thread_local.setTsval(-33);
|
||||
if (cpp11_thread_local.getTsval() != -33)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setEtval(-44);
|
||||
if (cpp0x_thread_local.getEtval() != -44)
|
||||
cpp11_thread_local.setEtval(-44);
|
||||
if (cpp11_thread_local.getEtval() != -44)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setTeval(-55);
|
||||
if (cpp0x_thread_local.getTeval() != -55)
|
||||
cpp11_thread_local.setTeval(-55);
|
||||
if (cpp11_thread_local.getTeval() != -55)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setEctval(-55);
|
||||
if (cpp0x_thread_local.getEctval() != -55)
|
||||
cpp11_thread_local.setEctval(-55);
|
||||
if (cpp11_thread_local.getEctval() != -55)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp0x_thread_local.setEcpptval(-66);
|
||||
if (cpp0x_thread_local.getEcpptval() != -66)
|
||||
cpp11_thread_local.setEcpptval(-66);
|
||||
if (cpp11_thread_local.getEcpptval() != -66)
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
import cpp0x_function_objects
|
||||
import sys
|
||||
|
||||
t = cpp0x_function_objects.Test()
|
||||
if t.value != 0:
|
||||
raise RuntimeError("Runtime cpp0x_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 cpp0x_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
import cpp0x_initializer_list_extend
|
||||
|
||||
c = cpp0x_initializer_list_extend.Container( [10, 20, 30, 40] )
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import cpp0x_initializer_list
|
||||
|
||||
a = cpp0x_initializer_list.A()
|
||||
a = cpp0x_initializer_list.A(11.1)
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
import cpp0x_null_pointer_constant
|
||||
|
||||
a = cpp0x_null_pointer_constant.A()
|
||||
|
||||
if a._myA != None:
|
||||
raise RuntimeError, ("cpp0x_null_pointer_constant: _myA should be None, but is ", a._myA)
|
||||
|
||||
b = cpp0x_null_pointer_constant.A()
|
||||
if a._myA != b._myA:
|
||||
raise RuntimeError, ("cpp0x_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
|
||||
|
||||
a._myA = cpp0x_null_pointer_constant.A()
|
||||
if a._myA == None:
|
||||
raise RuntimeError, ("cpp0x_null_pointer_constant: _myA should be object, but is None")
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
import cpp0x_result_of
|
||||
if cpp0x_result_of.test_result(cpp0x_result_of.square, 3.0) != 9.0:
|
||||
raise RuntimeError, "test_result(square, 3.0) is not 9.0."
|
|
@ -1,6 +1,6 @@
|
|||
import cpp0x_alternate_function_syntax
|
||||
import cpp11_alternate_function_syntax
|
||||
|
||||
a = cpp0x_alternate_function_syntax.SomeStruct()
|
||||
a = cpp11_alternate_function_syntax.SomeStruct()
|
||||
|
||||
res = a.addNormal(4,5)
|
||||
if res != 9:
|
|
@ -1,6 +1,6 @@
|
|||
import cpp0x_decltype
|
||||
import cpp11_decltype
|
||||
|
||||
a = cpp0x_decltype.A()
|
||||
a = cpp11_decltype.A()
|
||||
a.i = 5
|
||||
if a.i != 5:
|
||||
raise RuntimeError, "Assignment to a.i failed."
|
|
@ -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))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import cpp11_initializer_list_extend
|
||||
|
||||
c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] )
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import cpp11_initializer_list
|
||||
|
||||
a = cpp11_initializer_list.A()
|
||||
a = cpp11_initializer_list.A(11.1)
|
||||
|
|
@ -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")
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from cpp0x_raw_string_literals import *
|
||||
from cpp11_raw_string_literals import *
|
||||
|
||||
if cvar.L != 100:
|
||||
raise RuntimeError
|
|
@ -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."
|
|
@ -1,6 +1,6 @@
|
|||
import cpp0x_rvalue_reference
|
||||
import cpp11_rvalue_reference
|
||||
|
||||
a = cpp0x_rvalue_reference.A()
|
||||
a = cpp11_rvalue_reference.A()
|
||||
|
||||
a.setAcopy(5)
|
||||
if a.getAcopy() != 5:
|
|
@ -1,4 +1,4 @@
|
|||
from cpp0x_thread_local import *
|
||||
from cpp11_thread_local import *
|
||||
|
||||
t = ThreadLocals()
|
||||
if t.stval != 11:
|
|
@ -1,13 +1,13 @@
|
|||
import cpp0x_uniform_initialization
|
||||
import cpp11_uniform_initialization
|
||||
|
||||
var1 = cpp0x_uniform_initialization.cvar.var1
|
||||
var1 = cpp11_uniform_initialization.cvar.var1
|
||||
if var1.x != 5:
|
||||
raise RuntimeError
|
||||
var2 = cpp0x_uniform_initialization.cvar.var2
|
||||
var2 = cpp11_uniform_initialization.cvar.var2
|
||||
if var2.getX() != 2:
|
||||
raise RuntimeError
|
||||
|
||||
m = cpp0x_uniform_initialization.MoreInit()
|
||||
m = cpp11_uniform_initialization.MoreInit()
|
||||
if m.charptr != None:
|
||||
raise RuntimeError, m.charptr
|
||||
m.charptr = "hello sir"
|
|
@ -1710,7 +1710,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
|
||||
%token ENUM
|
||||
%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT AUTO
|
||||
%token STATIC_ASSERT CONSTEXPR THREAD_LOCAL DECLTYPE /* C++0x keywords */
|
||||
%token STATIC_ASSERT CONSTEXPR THREAD_LOCAL DECLTYPE /* C++11 keywords */
|
||||
%token USING
|
||||
%token <node> NAMESPACE
|
||||
%token NATIVE INLINE
|
||||
|
@ -3258,7 +3258,7 @@ c_decl : storage_class type declarator initializer c_decl_tail {
|
|||
set_nextSibling($$,$5);
|
||||
}
|
||||
}
|
||||
/* Alternate function syntax introduced in C++0x:
|
||||
/* 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");
|
||||
|
@ -5330,7 +5330,7 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
}
|
||||
| LAND notso_direct_declarator {
|
||||
/* Introduced in C++0x, move operator && */
|
||||
/* Introduced in C++11, move operator && */
|
||||
/* Adds one S/R conflict */
|
||||
$$ = $2;
|
||||
$$.type = NewStringEmpty();
|
||||
|
@ -5427,7 +5427,7 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
}
|
||||
| LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
/* Introduced in C++0x, move operator && */
|
||||
/* Introduced in C++11, move operator && */
|
||||
/* Adds one S/R conflict */
|
||||
$$ = $5;
|
||||
$$.type = NewStringEmpty();
|
||||
|
@ -6673,7 +6673,7 @@ mem_initializer : idcolon LPAREN {
|
|||
skip_balanced('(',')');
|
||||
Clear(scanner_ccode);
|
||||
}
|
||||
/* Uniform initialization in C++0x.
|
||||
/* Uniform initialization in C++11.
|
||||
Example:
|
||||
struct MyStruct {
|
||||
MyStruct(int x, double y) : x_{x}, y_{y} {}
|
||||
|
|
Loading…
Reference in New Issue