diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 24dd4f6e3..1e27b54b0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -409,13 +409,14 @@ CPP0X_TEST_CASES = \ cpp0x_function_objects \ cpp0x_strongly_typed_enumerations \ cpp0x_rvalue_reference \ - cpp0x_variadic_templates -# cpp0x_alternate_function_syntax # not fully implemented yet + cpp0x_variadic_templates \ + cpp0x_alternate_function_syntax # cpp0x_hash_types # not fully implemented yet -# cpp0x_unrestricted_unions # not supported by any compilers yet -# cpp0x_smart_pointers # not supported by standard library yet -# cpp0x_constexpr # not supported by any compilers yet -# cpp0x_thread_local # not supported by any compilers yet +# cpp0x_null_pointer_constant # not supported by any compilers yet +# cpp0x_unrestricted_unions # not supported by any compilers yet +# cpp0x_smart_pointers # not supported by standard library yet +# cpp0x_constexpr # not supported by any compilers yet +# cpp0x_thread_local # not supported by any compilers yet # Broken C++0x test cases. CPP0X_TEST_BROKEN = diff --git a/Examples/test-suite/cpp0x_alternate_function_syntax.i b/Examples/test-suite/cpp0x_alternate_function_syntax.i index ed3cb6729..b17223626 100644 --- a/Examples/test-suite/cpp0x_alternate_function_syntax.i +++ b/Examples/test-suite/cpp0x_alternate_function_syntax.i @@ -2,10 +2,15 @@ %inline %{ struct SomeStruct { - auto FuncName(int x, int y) -> int; + int addNormal(int x, int y); + auto addAlternate(int x, int y) -> int; }; -auto SomeStruct::FuncName(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/cpp0x_null_pointer_constant.i b/Examples/test-suite/cpp0x_null_pointer_constant.i new file mode 100644 index 000000000..9057f04be --- /dev/null +++ b/Examples/test-suite/cpp0x_null_pointer_constant.i @@ -0,0 +1,16 @@ +/* This testcase checks whether Swig correctly treats the new nullptr_t + constant introduced in C++0x. +*/ + +%module cpp0x_null_pointer_constant + +%inline %{ +#include + +class A { +public: + A() : _myA(std::nullptr) { } + + A *_myA; +}; +%} diff --git a/Examples/test-suite/python/cpp0x_alternate_function_syntax_runme.py b/Examples/test-suite/python/cpp0x_alternate_function_syntax_runme.py new file mode 100644 index 000000000..8005cfab7 --- /dev/null +++ b/Examples/test-suite/python/cpp0x_alternate_function_syntax_runme.py @@ -0,0 +1,13 @@ +import cpp0x_alternate_function_syntax + +a = cpp0x_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/cpp0x_null_pointer_constant_runme.py b/Examples/test-suite/python/cpp0x_null_pointer_constant_runme.py new file mode 100644 index 000000000..b80dcaf2f --- /dev/null +++ b/Examples/test-suite/python/cpp0x_null_pointer_constant_runme.py @@ -0,0 +1,15 @@ +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") + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index c8e7e284d..f3a73f38a 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3001,7 +3001,7 @@ c_decl : storage_class type declarator initializer c_decl_tail { /* Alternate function syntax introduced in C++0x: auto funcName(int x, int y) -> int; */ | storage_class AUTO declarator ARROW cpp_alternate_rettype initializer c_decl_tail { -/* $$ = new_node("cdecl"); + $$ = new_node("cdecl"); if ($6.qualifier) SwigType_push($3.type,$6.qualifier); Setattr($$,"type",$5); Setattr($$,"storage",$1); @@ -3051,7 +3051,7 @@ c_decl : storage_class type declarator initializer c_decl_tail { } } else { set_nextSibling($$,$7); - } */ + } } ;