From e566c5fa7f4b8af527c9f13f6eabd84bfc38a897 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Nov 2013 00:13:38 +0000 Subject: Add support for parsing C++11 =delete and =default Although this was documented as working, it wasn't implemented %typemap(default) failed without the idstring changes Add some C tests using the C++ keyword delete --- Doc/Manual/CPlusPlus11.html | 22 ++++++---- Examples/test-suite/c_delete.i | 14 +++++++ Examples/test-suite/c_delete_function.i | 7 ++++ Examples/test-suite/common.mk | 2 + Examples/test-suite/cpp11_default_delete.i | 64 +++++++++++++++++++++++++---- Source/CParse/cscanner.c | 3 ++ Source/CParse/parser.y | 66 +++++++++++++++++++++++++++--- Source/Modules/allocate.cxx | 26 ++++++++---- 8 files changed, 173 insertions(+), 31 deletions(-) create mode 100644 Examples/test-suite/c_delete.i create mode 100644 Examples/test-suite/c_delete_function.i diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index 3caec748e..95d748791 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -33,7 +33,7 @@
  • New string literals
  • User-defined literals
  • Thread-local storage -
  • Defaulting/deleting of standard functions on C++ objects +
  • Defaulting/deleting of standard functions on C++ objects
  • Type long long int
  • Static assertions
  • Allow sizeof to work on members of classes without an explicit object @@ -739,23 +739,27 @@ A variable will be thread local if accessed from different threads from the targ same way that it will be thread local if accessed from C++ code.

    -

    7.2.21 Defaulting/deleting of standard functions on C++ objects

    +

    7.2.21 Explicitly defaulted functions and deleted functions

    -

    SWIG correctly parses the = delete and = default -keywords. For example:

    +

    SWIG handles explicitly defaulted functions, that is, = default added to a function declaration. Deleted definitions, which are also called deleted functions, have = delete added to the function declaration. +For example:

     struct NonCopyable {
       NonCopyable& operator=(const NonCopyable&) = delete; /* Removes operator= */
    -  NonCopyable(const NonCopyable&) = delete;            /* Removed copy constructor */
    -  NonCopyable() = default;                             /* Explicitly allows the empty constructor */
    -  void *operator new(std::size_t) = delete;            /* Removes new NonCopyable */
    +  NonCopyable(const NonCopyable&) = delete;                /* Removed copy constructor */
    +  NonCopyable() = default;                                     /* Explicitly allows the empty constructor */
    +  void *operator new(std::size_t) = delete;                    /* Removes new NonCopyable */
     };
     
    -

    This feature is specific to C++ only. The defaulting/deleting is currently ignored, because SWIG -automatically produces wrappers for special constructors and operators specific to the target language.

    +

    +Wrappers for deleted functions will not be available in the target language. +Wrappers for defaulted functions will of course be available in the target language. +Explicitly defaulted functions have no direct effect for SWIG wrapping as the declaration is handled +much like any other method declaration parsed by SWIG. +

    7.2.22 Type long long int

    diff --git a/Examples/test-suite/c_delete.i b/Examples/test-suite/c_delete.i new file mode 100644 index 000000000..d47032095 --- /dev/null +++ b/Examples/test-suite/c_delete.i @@ -0,0 +1,14 @@ +%module c_delete + +/* check C++ delete keyword is okay in C wrappers */ + +%inline %{ +struct delete { + int delete; +}; +%} + +%rename(DeleteGlobalVariable) delete; +%inline %{ +int delete = 0; +%} diff --git a/Examples/test-suite/c_delete_function.i b/Examples/test-suite/c_delete_function.i new file mode 100644 index 000000000..e1fba7495 --- /dev/null +++ b/Examples/test-suite/c_delete_function.i @@ -0,0 +1,7 @@ +%module c_delete_function + +/* check C++ delete keyword is okay in C wrappers */ + +%inline %{ +double delete(double d) { return d; } +%} diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e25d36715..0d360830d 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -552,6 +552,8 @@ endif C_TEST_CASES += \ arrays \ bom_utf8 \ + c_delete \ + c_delete_function \ char_constant \ const_const \ constant_expr \ diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i index be4cc6cc9..49a677060 100644 --- a/Examples/test-suite/cpp11_default_delete.i +++ b/Examples/test-suite/cpp11_default_delete.i @@ -1,9 +1,12 @@ -/* This testcase checks whether SWIG correctly parses the default and delete - keywords which keep or remove default C++ object construction functions. */ +/* This testcase checks whether SWIG correctly parses C++11 explicitly defaulted functions and deleted functions */ %module cpp11_default_delete -%{ -#include +%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&); +%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&); + +%rename(Assignment) *::operator=; + +%inline %{ class NonCopyable { public: @@ -14,11 +17,56 @@ public: }; struct A1 { - void f(int i); - void f(double i) = delete; /* Don't cast double to int. Compiler returns an error */ + void func(int i) {} + A1() = default; + ~A1() = default; + void func(double i) = delete; /* Don't cast double to int. Compiler returns an error */ +private: + A1(const A1&); }; +A1::A1(const A1&) = default; + struct A2 { - void f(int i); - template void f(T) = delete; /* Only accept int */ + void func(int i) {} + virtual void fff(int) = delete; + virtual ~A2() = default; + template void func(T) = delete; +}; + +struct trivial { + trivial() = default; + trivial(const trivial&) = default; + trivial(trivial&&) = default; + trivial& operator=(const trivial&) = default; + trivial& operator=(trivial&&) = default; + ~trivial() = default; +}; + +struct nontrivial1 { + nontrivial1(); +}; +nontrivial1::nontrivial1() = default; + +struct sometype { + sometype() = delete; + sometype(int) = delete; + sometype(double); +}; +sometype::sometype(double) {} + +/* Not working with prerelease of gcc-4.8 +struct nonew { + void *operator new(std::size_t) = delete; + void *operator new[](std::size_t) = delete; +}; +*/ + +struct moveonly { + moveonly() = default; + moveonly(const moveonly&) = delete; + moveonly(moveonly&&) = default; + moveonly& operator=(const moveonly&) = delete; + moveonly& operator=(moveonly&&) = default; + ~moveonly() = default; }; %} diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index e91dfb3d3..8b484f8a7 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -728,6 +728,9 @@ int yylex(void) { if (strcmp(yytext, "delete") == 0) { return (DELETE_KW); } + if (strcmp(yytext, "default") == 0) { + return (DEFAULT); + } if (strcmp(yytext, "using") == 0) { return (USING); } diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index ce0c91c43..1328d6e0d 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -447,6 +447,14 @@ static void add_symbols(Node *n) { n = nextSibling(n); continue; } + if (cparse_cplusplus) { + String *value = Getattr(n, "value"); + if (value && Strcmp(value, "delete") == 0) { + /* C++11 deleted definition / deleted function */ + SetFlag(n,"deleted"); + SetFlag(n,"feature:ignore"); + } + } if (only_csymbol || GetFlag(n,"feature:ignore")) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); @@ -1715,7 +1723,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %token NATIVE INLINE %token TYPEMAP EXCEPT ECHO APPLY CLEAR SWIGTEMPLATE FRAGMENT %token WARN -%token LESSTHAN GREATERTHAN DELETE_KW +%token LESSTHAN GREATERTHAN DELETE_KW DEFAULT %token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO %token ARROW %token QUESTIONMARK @@ -1775,7 +1783,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type ellipsis variadic; %type type rawtype type_right anon_bitfield_type decltype ; %type base_list inherit raw_inherit; -%type definetype def_args etype; +%type definetype def_args etype default_delete deleted_definition explicit_default; %type expr exprnum exprcompound valexpr; %type ename ; %type template_decl; @@ -4696,6 +4704,8 @@ cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { Delete(code); } SetFlag($$,"feature:new"); + if ($6.defarg) + Setattr($$,"value",$6.defarg); } else { $$ = 0; } @@ -4723,6 +4733,8 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { } Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); + if ($6.val) + Setattr($$,"value",$6.val); add_symbols($$); } @@ -4738,9 +4750,8 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { Delete(name); Setattr($$,"throws",$7.throws); Setattr($$,"throw",$7.throwf); - if ($7.val) { - Setattr($$,"value","0"); - } + if ($7.val) + Setattr($$,"value",$7.val); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); @@ -4982,11 +4993,19 @@ cpp_swig_directive: pragma_directive { $$ = $1; } cpp_end : cpp_const SEMI { Clear(scanner_ccode); + $$.val = 0; + $$.throws = $1.throws; + $$.throwf = $1.throwf; + } + | cpp_const EQUAL default_delete SEMI { + Clear(scanner_ccode); + $$.val = $3.val; $$.throws = $1.throws; $$.throwf = $1.throwf; } | cpp_const LBRACE { skip_balanced('{','}'); + $$.val = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; } @@ -6143,11 +6162,15 @@ definetype : { /* scanner_check_typedef(); */ } expr { } else if ($$.type != T_CHAR && $$.type != T_WSTRING && $$.type != T_WCHAR) { $$.rawval = 0; } + $$.qualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; scanner_ignore_typedef(); } + | default_delete { + $$ = $1; + } /* | string { $$.val = NewString($1); @@ -6160,6 +6183,38 @@ definetype : { /* scanner_check_typedef(); */ } expr { */ ; +default_delete : deleted_definition { + $$ = $1; + } + | explicit_default { + $$ = $1; + } + ; + +/* For C++ deleted definition '= delete' */ +deleted_definition : DELETE_KW { + $$.val = NewString("delete"); + $$.rawval = 0; + $$.type = T_STRING; + $$.qualifier = 0; + $$.bitfield = 0; + $$.throws = 0; + $$.throwf = 0; + } + ; + +/* For C++ explicitly defaulted functions '= default' */ +explicit_default : DEFAULT { + $$.val = NewString("default"); + $$.rawval = 0; + $$.type = T_STRING; + $$.qualifier = 0; + $$.bitfield = 0; + $$.throws = 0; + $$.throwf = 0; + } + ; + /* Some stuff for handling enums */ ename : ID { $$ = $1; } @@ -6711,6 +6766,7 @@ template_decl : LESSTHAN valparms GREATERTHAN { ; idstring : ID { $$ = $1; } + | default_delete { $$ = $1.val; } | string { $$ = $1; } ; diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index dee044bf3..b7daae59c 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -659,7 +659,7 @@ Allocate(): } if (!Getattr(n, "allocate:has_destructor")) { - /* No destructor was defined. We need to check a few things here too */ + /* No destructor was defined */ List *bases = Getattr(n, "allbases"); int allows_destruct = 1; @@ -676,13 +676,13 @@ Allocate(): } if (!Getattr(n, "allocate:has_assign")) { - /* No destructor was defined. We need to check a few things here too */ + /* No assignment operator was defined */ List *bases = Getattr(n, "allbases"); int allows_assign = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); - /* If base class does not allow default destructor, we don't allow it either */ + /* If base class does not allow assignment, we don't allow it either */ if (Getattr(n, "allocate:has_assign")) { allows_assign = !Getattr(n, "allocate:noassign"); } @@ -693,13 +693,13 @@ Allocate(): } if (!Getattr(n, "allocate:has_new")) { - /* No destructor was defined. We need to check a few things here too */ + /* No new operator was defined */ List *bases = Getattr(n, "allbases"); int allows_new = 1; for (int i = 0; i < Len(bases); i++) { Node *n = Getitem(bases, i); - /* If base class does not allow default destructor, we don't allow it either */ + /* If base class does not allow new operator, we don't allow it either */ if (Getattr(n, "allocate:has_new")) { allows_new = !Getattr(n, "allocate:nonew"); } @@ -779,18 +779,26 @@ Allocate(): if (cplus_mode != PUBLIC) { if (Strcmp(name, "operator =") == 0) { /* Look for a private assignment operator */ - Setattr(inclass, "allocate:has_assign", "1"); + if (!GetFlag(n, "deleted")) + Setattr(inclass, "allocate:has_assign", "1"); Setattr(inclass, "allocate:noassign", "1"); } else if (Strcmp(name, "operator new") == 0) { /* Look for a private new operator */ - Setattr(inclass, "allocate:has_new", "1"); + if (!GetFlag(n, "deleted")) + Setattr(inclass, "allocate:has_new", "1"); Setattr(inclass, "allocate:nonew", "1"); } } else { if (Strcmp(name, "operator =") == 0) { - Setattr(inclass, "allocate:has_assign", "1"); + if (!GetFlag(n, "deleted")) + Setattr(inclass, "allocate:has_assign", "1"); + else + Setattr(inclass, "allocate:noassign", "1"); } else if (Strcmp(name, "operator new") == 0) { - Setattr(inclass, "allocate:has_new", "1"); + if (!GetFlag(n, "deleted")) + Setattr(inclass, "allocate:has_new", "1"); + else + Setattr(inclass, "allocate:nonew", "1"); } /* Look for smart pointer operator */ if ((Strcmp(name, "operator ->") == 0) && (!GetFlag(n, "feature:ignore"))) { -- cgit v1.2.3 From 7a8dd4bb2d9b34f511596940f2721c1257fccc6b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Nov 2013 22:24:13 +0000 Subject: Correct html references --- Doc/Manual/CPlusPlus11.html | 144 ++++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 71 deletions(-) diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index 95d748791..30b88d6fa 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -10,45 +10,45 @@
    @@ -56,7 +56,7 @@ -

    7.1 Introduction

    +

    7.1 Introduction

    This chapter gives you a brief overview about the SWIG @@ -68,10 +68,10 @@ Google Summer of Code 2009 period.

    new STL types (unordered_ containers, result_of, tuples) are not supported yet.

    -

    7.2 Core language changes

    +

    7.2 Core language changes

    -

    7.2.1 Rvalue reference and move semantics

    +

    7.2.1 Rvalue reference and move semantics

    SWIG correctly parses the new operator && the same as the reference operator &.

    @@ -87,7 +87,7 @@ class MyClass { }; -

    7.2.2 Generalized constant expressions

    +

    7.2.2 Generalized constant expressions

    SWIG correctly parses the keyword constexpr, but ignores its functionality. Constant functions cannot be used as constants.

    @@ -105,7 +105,7 @@ constexpr int myConstFunc() { return MY_CONST; } const int a = MY_CONST; // ok -

    7.2.3 Extern template

    +

    7.2.3 Extern template

    SWIG correctly parses the keywords extern template. However, the explicit template instantiation is not used by SWIG, a %template is still required.

    @@ -123,7 +123,8 @@ public: }; -

    7.2.4 Initializer lists

    +

    7.2.4 Initializer lists

    +

    Initializer lists are very much a C++ compiler construct and are not very accessible from wrappers as @@ -254,7 +255,7 @@ Note that the default typemap for std::initializer_list does nothing bu and hence any user supplied typemaps will override it and suppress the warning.

    -

    7.2.5 Uniform initialization

    +

    7.2.5 Uniform initialization

    The curly brackets {} for member initialization are fully @@ -287,7 +288,7 @@ AltStruct var2{2, 4.3}; // calls the constructor 142.15 -

    7.2.6 Type inference

    +

    7.2.6 Type inference

    SWIG supports decltype() with some limitations. Single @@ -304,13 +305,13 @@ int i; int j; decltype(i+j) k; // syntax error -

    7.2.7 Range-based for-loop

    +

    7.2.7 Range-based for-loop

    This feature is part of the implementation block only. SWIG ignores it.

    -

    7.2.8 Lambda functions and expressions

    +

    7.2.8 Lambda functions and expressions

    SWIG correctly parses most of the Lambda functions syntax. For example:

    @@ -336,7 +337,7 @@ auto six = [](int x, int y) { return x+y; }(4, 2); Better support should be available in a later release.

    -

    7.2.9 Alternate function syntax

    +

    7.2.9 Alternate function syntax

    SWIG fully supports the new definition of functions. For example:

    @@ -371,7 +372,7 @@ auto SomeStruct::FuncName(int x, int y) -> int { auto square(float a, float b) -> decltype(a); -

    7.2.10 Object construction improvement

    +

    7.2.10 Object construction improvement

    @@ -412,12 +413,12 @@ class DerivedClass: public BaseClass { }; -

    7.2.11 Null pointer constant

    +

    7.2.11 Null pointer constant

    The nullptr constant is largely unimportant in wrappers. In the few places it has an effect, it is treated like NULL.

    -

    7.2.12 Strongly typed enumerations

    +

    7.2.12 Strongly typed enumerations

    SWIG parses the new enum class syntax and forward declarator for the enums:

    @@ -468,7 +469,7 @@ class AllColors { }; -

    7.2.13 Double angle brackets

    +

    7.2.13 Double angle brackets

    SWIG correctly parses the symbols >> as closing the @@ -479,7 +480,7 @@ shift operator >> otherwise.

    std::vector<std::vector<int>> myIntTable; -

    7.2.14 Explicit conversion operators

    +

    7.2.14 Explicit conversion operators

    SWIG correctly parses the keyword explicit both for operators and constructors. @@ -515,7 +516,8 @@ SWIG target languages, because all use their own facilities (eg. classes Cloneab to achieve particular copy and compare behaviours.

    -

    7.2.15 Alias templates

    +

    7.2.15 Alias templates

    +

    The following is an example of an alias template: @@ -567,7 +569,7 @@ example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully sup typedef void (*PFD)(double); // The old style -

    7.2.16 Unrestricted unions

    +

    7.2.16 Unrestricted unions

    SWIG fully supports any type inside a union even if it does not @@ -593,7 +595,7 @@ union P { } p1; -

    7.2.17 Variadic templates

    +

    7.2.17 Variadic templates

    SWIG supports the variadic templates syntax (inside the <> @@ -628,7 +630,7 @@ const int SIZE = sizeof...(ClassName<int, int>); In the above example SIZE is of course wrapped as a constant.

    -

    7.2.18 New string literals

    +

    7.2.18 New string literals

    SWIG supports unicode string constants and raw string literals.

    @@ -652,7 +654,7 @@ const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";

    Note: SWIG currently incorrectly parses the odd number of double quotes inside the string due to SWIG's C++ preprocessor.

    -

    7.2.19 User-defined literals

    +

    7.2.19 User-defined literals

    @@ -719,7 +721,7 @@ OutputType var2 = 1234_suffix; OutputType var3 = 3.1416_suffix; -

    7.2.20 Thread-local storage

    +

    7.2.20 Thread-local storage

    SWIG correctly parses the thread_local keyword. For example, variable @@ -761,12 +763,12 @@ Explicitly defaulted functions have no direct effect for SWIG wrapping as the de much like any other method declaration parsed by SWIG.

    -

    7.2.22 Type long long int

    +

    7.2.22 Type long long int

    SWIG correctly parses and uses the new long long type already introduced in C99 some time ago.

    -

    7.2.23 Static assertions

    +

    7.2.23 Static assertions

    SWIG correctly parses and calls the new static_assert function.

    @@ -778,7 +780,7 @@ struct Check { }; -

    7.2.24 Allow sizeof to work on members of classes without an explicit object

    +

    7.2.24 Allow sizeof to work on members of classes without an explicit object

    SWIG correctly calls the sizeof() on types as well as on the @@ -798,28 +800,28 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11 8 -

    7.3 Standard library changes

    +

    7.3 Standard library changes

    -

    7.3.1 Threading facilities

    +

    7.3.1 Threading facilities

    SWIG does not currently wrap or use any of the new threading classes introduced (thread, mutex, locks, condition variables, task). The main reason is that SWIG target languages offer their own threading facilities that do not rely on C++.

    -

    7.3.2 Tuple types and hash tables

    +

    7.3.2 Tuple types and hash tables

    SWIG does not wrap the new tuple types and the unordered_ container classes yet. Variadic template support is working so it is possible to include the tuple header file; it is parsed without any problems.

    -

    7.3.3 Regular expressions

    +

    7.3.3 Regular expressions

    SWIG does not wrap the new C++11 regular expressions classes, because the SWIG target languages use their own facilities for this.

    -

    7.3.4 General-purpose smart pointers

    +

    7.3.4 General-purpose smart pointers

    @@ -827,12 +829,12 @@ SWIG provides special smart pointer handling for std::tr1::shared_ptr i There is no special smart pointer handling available for std::weak_ptr and std::unique_ptr.

    -

    7.3.5 Extensible random number facility

    +

    7.3.5 Extensible random number facility

    This feature extends and standardizes the standard library only and does not effect the C++ language and SWIG.

    -

    7.3.6 Wrapper reference

    +

    7.3.6 Wrapper reference

    The new ref and cref classes are used to instantiate a parameter as a reference of a template function. For example:

    @@ -857,7 +859,7 @@ int main() {

    The ref and cref classes are not wrapped by SWIG because the SWIG target languages do not support referencing.

    -

    7.3.7 Polymorphous wrappers for function objects

    +

    7.3.7 Polymorphous wrappers for function objects

    @@ -888,7 +890,7 @@ t = Test() b = t(1,2) # invoke C++ function object -

    7.3.8 Type traits for metaprogramming

    +

    7.3.8 Type traits for metaprogramming

    The new C++ metaprogramming is useful at compile time and is aimed specifically for C++ development:

    @@ -913,7 +915,7 @@ template< class T1, class T2 > int elaborate( T1 A, T2 B ) {

    SWIG correctly parses the template specialization, template types and values inside the <> block and the new helper functions: is_convertible, is_integral, is_const etc. However, SWIG still explicitly requires concrete types when using the %template directive, so the C++ metaprogramming features are not really of interest at runtime in the target languages.

    -

    7.3.9 Uniform method for computing return type of function objects

    +

    7.3.9 Uniform method for computing return type of function objects

    SWIG does not wrap the new result_of class introduced in the <functional> header and map the result_of::type to the concrete type yet. For example:

    -- cgit v1.2.3 From cdefaaf794398655de5e93c4aa9f20fdb01e2283 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Nov 2013 20:20:34 +0000 Subject: Fixes for c_delete and c_delete_function tests --- Examples/test-suite/c_delete.i | 6 ++++++ Examples/test-suite/c_delete_function.i | 4 ++++ Lib/csharp/csharpkw.swg | 3 +++ 3 files changed, 13 insertions(+) diff --git a/Examples/test-suite/c_delete.i b/Examples/test-suite/c_delete.i index d47032095..632340629 100644 --- a/Examples/test-suite/c_delete.i +++ b/Examples/test-suite/c_delete.i @@ -2,6 +2,10 @@ /* check C++ delete keyword is okay in C wrappers */ +#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD + +#if !defined(SWIGOCTAVE) /* Octave compiles wrappers as C++ */ + %inline %{ struct delete { int delete; @@ -12,3 +16,5 @@ struct delete { %inline %{ int delete = 0; %} + +#endif diff --git a/Examples/test-suite/c_delete_function.i b/Examples/test-suite/c_delete_function.i index e1fba7495..3739ceadc 100644 --- a/Examples/test-suite/c_delete_function.i +++ b/Examples/test-suite/c_delete_function.i @@ -2,6 +2,10 @@ /* check C++ delete keyword is okay in C wrappers */ +#if !defined(SWIGOCTAVE) /* Octave compiles wrappers as C++ */ + %inline %{ double delete(double d) { return d; } %} + +#endif diff --git a/Lib/csharp/csharpkw.swg b/Lib/csharp/csharpkw.swg index 9a6d979f1..43ca5993b 100644 --- a/Lib/csharp/csharpkw.swg +++ b/Lib/csharp/csharpkw.swg @@ -4,6 +4,8 @@ /* Warnings for C# keywords */ #define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x` +#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x` + /* from http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords @@ -88,6 +90,7 @@ CSHARPKW(void); CSHARPKW(volatile); CSHARPKW(while); +CSHARPCLASSKW(delete); #undef CSHARPKW -- cgit v1.2.3 From f4ada30a7e6f0b15ed4a1446675980b6df15b631 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Nov 2013 19:31:59 +0000 Subject: Add support for C++11 noexcept specification in exception specifications --- Doc/Manual/CPlusPlus11.html | 23 ++++++++- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp11_noexcept.i | 48 +++++++++++++++++++ Source/CParse/cscanner.c | 2 + Source/CParse/parser.y | 90 ++++++++++++++++++++++++++++-------- 5 files changed, 144 insertions(+), 20 deletions(-) create mode 100644 Examples/test-suite/cpp11_noexcept.i diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index 30b88d6fa..0d2f22aff 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -37,6 +37,7 @@
  • Type long long int
  • Static assertions
  • Allow sizeof to work on members of classes without an explicit object +
  • Exception specifications and noexcept
  • Standard library changes