Enabled alternate function syntax and added runtime testcases.
Added support for null pointer constant introduced in C++0x. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11484 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e7fd659ae5
commit
a7e9a105d9
6 changed files with 60 additions and 10 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
16
Examples/test-suite/cpp0x_null_pointer_constant.i
Normal file
16
Examples/test-suite/cpp0x_null_pointer_constant.i
Normal file
|
|
@ -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 <cstddef>
|
||||
|
||||
class A {
|
||||
public:
|
||||
A() : _myA(std::nullptr) { }
|
||||
|
||||
A *_myA;
|
||||
};
|
||||
%}
|
||||
|
|
@ -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.")
|
||||
|
||||
|
|
@ -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")
|
||||
|
||||
|
|
@ -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);
|
||||
} */
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue