Fix unrestricted unions testcase and add runtime example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13849 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4c2a1abd6b
commit
e25da884cb
4 changed files with 4061 additions and 5 deletions
|
|
@ -439,19 +439,24 @@ typedef void (*PFD)(double); // The old style
|
||||||
|
|
||||||
<p>SWIG fully supports any type inside a union even if it does not
|
<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
|
define a trivial constructor. For example, the wrapper for the following
|
||||||
code is correctly produced:</p>
|
code correctly provides access to all members in the union:</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
struct point {
|
struct point {
|
||||||
point() {}
|
point() {}
|
||||||
point(int x, int y): x_(x), y_(y) {}
|
point(int x, int y) : x_(x), y_(y) {}
|
||||||
int x_, y_;
|
int x_, y_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <new> // For placement 'new' in the constructor below
|
||||||
union P {
|
union P {
|
||||||
int z;
|
int z;
|
||||||
double w;
|
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++03; legal in C++11.
|
||||||
|
// Due to the point member, a constructor definition is required.
|
||||||
|
P() {
|
||||||
|
new(&p) point();
|
||||||
|
}
|
||||||
} p1;
|
} p1;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,7 @@ CPP0X_TEST_CASES = \
|
||||||
cpp0x_template_double_brackets \
|
cpp0x_template_double_brackets \
|
||||||
cpp0x_template_explicit \
|
cpp0x_template_explicit \
|
||||||
cpp0x_uniform_initialization \
|
cpp0x_uniform_initialization \
|
||||||
|
cpp0x_unrestricted_unions \
|
||||||
cpp0x_userdefined_literals \
|
cpp0x_userdefined_literals \
|
||||||
cpp0x_variadic_templates
|
cpp0x_variadic_templates
|
||||||
|
|
||||||
|
|
@ -456,7 +457,6 @@ CPP0X_TEST_CASES = \
|
||||||
# cpp0x_lambda_functions \ # not supported by GCC or MSVC yet
|
# cpp0x_lambda_functions \ # not supported by GCC or MSVC yet
|
||||||
# cpp0x_template_typedefs \ # not supported by any compiler yet (now in gcc-4.7)
|
# cpp0x_template_typedefs \ # not supported by any compiler yet (now in gcc-4.7)
|
||||||
# cpp0x_thread_local \ # not supported by any compiler yet
|
# cpp0x_thread_local \ # not supported by any compiler yet
|
||||||
# cpp0x_unrestricted_unions \ # not supported by any compiler yet (now in gcc-4.6 but generates internal compiler error)
|
|
||||||
|
|
||||||
# Broken C++0x test cases.
|
# Broken C++0x test cases.
|
||||||
CPP0X_TEST_BROKEN =
|
CPP0X_TEST_BROKEN =
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,15 @@ struct point {
|
||||||
int x_, y_;
|
int x_, y_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <new> // For placement 'new' in the constructor below
|
||||||
union P {
|
union P {
|
||||||
int z;
|
int z;
|
||||||
double w;
|
double w;
|
||||||
point p;
|
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;
|
} p1;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
4046
Examples/test-suite/python/cpp0x_unrestricted_unions_wrap.cxx
Normal file
4046
Examples/test-suite/python/cpp0x_unrestricted_unions_wrap.cxx
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue