Added support for cpp0x uniform initialization.

Added testcases.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11413 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matevz Jekovec 2009-07-17 10:21:25 +00:00
commit 63a7f06afb
3 changed files with 33 additions and 1 deletions

View file

@ -405,7 +405,8 @@ CPP0X_TEST_CASES = \
cpp0x_raw_string_literals \
cpp0x_static_assert \
cpp0x_template_explicit \
cpp0x_thread_local
cpp0x_thread_local \
cpp0x_uniform_initialization
# cpp0x_smart_pointers # not supported by standard library yet
# cpp0x_constexpr # not supported by any compilers yet

View file

@ -0,0 +1,20 @@
%module cpp0x_uniform_initialization
%inline %{
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
%}

View file

@ -5846,6 +5846,17 @@ mem_initializer : idcolon LPAREN {
skip_balanced('(',')');
Clear(scanner_ccode);
}
| idcolon LBRACE {
/* Uniform initialization. eg.
struct MyStruct {
MyStruct(int x, double y) : x_{x}, y_{y} {}
int x_;
double y_;
};
*/
skip_balanced('{','}');
Clear(scanner_ccode);
}
;
template_decl : LESSTHAN valparms GREATERTHAN {