Delegating constructors and inheriting constructors clarification and split of tests

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13852 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-09-25 20:22:15 +00:00
commit 4db087d81f
5 changed files with 63 additions and 34 deletions

View file

@ -263,9 +263,31 @@ auto square(float a, float b) -> decltype(a);
<H3><a name="Cpp0x_Object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
<p>SWIG correctly parses and includes the external functions
(constructor delegation and constructor inheritance) into the class
using the <tt>using</tt> keyword.</p>
<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 {

View file

@ -434,6 +434,7 @@ CPP0X_TEST_CASES = \
cpp0x_constexpr \
cpp0x_decltype \
cpp0x_default_delete \
cpp0x_delegating_constructors \
cpp0x_explicit_conversion_operators \
cpp0x_function_objects \
cpp0x_initializer_list \
@ -453,7 +454,7 @@ CPP0X_TEST_CASES = \
cpp0x_userdefined_literals \
cpp0x_variadic_templates
# cpp0x_constructors \ # not supported by any compiler yet
# cpp0x_inheriting_constructors \ # not supported by gcc-4.7
# cpp0x_hash_tables \ # not fully implemented yet
# cpp0x_lambda_functions \ # not supported by GCC or MSVC yet
# cpp0x_thread_local \ # not supported by any compiler yet

View file

@ -1,30 +0,0 @@
/* This test checks whether SWIG correctly parses the new delegating
constructors and constructor inheritance.
*/
%module cpp0x_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
};
class A {
public:
int a;
int b;
int c;
A() : A( 10 ) {}
A(int aa) : A(aa, 20) {}
A(int aa, int bb) : A(aa, bb, 30) {}
A(int aa, int bb, int cc) { a=aa; b=bb; c=cc; }
};
%}

View file

@ -0,0 +1,18 @@
/* This test checks whether SWIG correctly parses the new delegating
constructors.
*/
%module cpp0x_delegating_constructors
%inline %{
class A {
public:
int a;
int b;
int c;
A() : A( 10 ) {}
A(int aa) : A(aa, 20) {}
A(int aa, int bb) : A(aa, bb, 30) {}
A(int aa, int bb, int cc) { a=aa; b=bb; c=cc; }
};
%}

View file

@ -0,0 +1,18 @@
/* This test checks whether SWIG correctly parses the new constructor
inheritance.
*/
%module cpp0x_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
};
%}