Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: swig/swig
...
head fork: swig/swig
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
Commits on Nov 20, 2013
@wsfulton wsfulton 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
e566c5f
@wsfulton wsfulton Correct html references 7a8dd4b
View
164 Doc/Manual/CPlusPlus11.html
@@ -10,45 +10,45 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
-<li><a href="#CPlusPlus11_Introduction">Introduction</a>
-<li><a href="#CPlusPlus11_Core_language_changes">Core language changes</a>
+<li><a href="#CPlusPlus11_introduction">Introduction</a>
+<li><a href="#CPlusPlus11_core_language_changes">Core language changes</a>
<ul>
-<li><a href="#CPlusPlus11_Rvalue_reference_and_move_semantics">Rvalue reference and move semantics</a>
-<li><a href="#CPlusPlus11_Generalized_constant_expressions">Generalized constant expressions</a>
-<li><a href="#CPlusPlus11_Extern_template">Extern template</a>
-<li><a href="#CPlusPlus11_Initializer_lists">Initializer lists</a>
-<li><a href="#CPlusPlus11_Uniform_initialization">Uniform initialization</a>
-<li><a href="#CPlusPlus11_Type_inference">Type inference</a>
-<li><a href="#CPlusPlus11_Range_based_for_loop">Range-based for-loop</a>
-<li><a href="#CPlusPlus11_Lambda_functions_and_expressions">Lambda functions and expressions</a>
-<li><a href="#CPlusPlus11_Alternate_function_syntax">Alternate function syntax</a>
-<li><a href="#CPlusPlus11_Object_construction_improvement">Object construction improvement</a>
-<li><a href="#CPlusPlus11_Null_pointer_constant">Null pointer constant</a>
-<li><a href="#CPlusPlus11_Strongly_typed_enumerations">Strongly typed enumerations</a>
-<li><a href="#CPlusPlus11_Double_angle_brackets">Double angle brackets</a>
-<li><a href="#CPlusPlus11_Explicit_conversion_operators">Explicit conversion operators</a>
-<li><a href="#CPlusPlus11_Alias_templates">Alias templates</a>
-<li><a href="#CPlusPlus11_Unrestricted_unions">Unrestricted unions</a>
-<li><a href="#CPlusPlus11_Variadic_templates">Variadic templates</a>
-<li><a href="#CPlusPlus11_New_string_literals">New string literals</a>
-<li><a href="#CPlusPlus11_User_defined_literals">User-defined literals</a>
-<li><a href="#CPlusPlus11_Thread_local_storage">Thread-local storage</a>
-<li><a href="#CPlusPlus11_Defaulting/deleting_of_standard_functions_on_C++_objects">Defaulting/deleting of standard functions on C++ objects</a>
-<li><a href="#CPlusPlus11_Type_long_long_int">Type long long int</a>
-<li><a href="#CPlusPlus11_Static_assertions">Static assertions</a>
-<li><a href="#CPlusPlus11_Allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object">Allow sizeof to work on members of classes without an explicit object</a>
+<li><a href="#CPlusPlus11_rvalue_reference_and_move_semantics">Rvalue reference and move semantics</a>
+<li><a href="#CPlusPlus11_generalized_constant_expressions">Generalized constant expressions</a>
+<li><a href="#CPlusPlus11_extern_template">Extern template</a>
+<li><a href="#CPlusPlus11_initializer_lists">Initializer lists</a>
+<li><a href="#CPlusPlus11_uniform_initialization">Uniform initialization</a>
+<li><a href="#CPlusPlus11_type_inference">Type inference</a>
+<li><a href="#CPlusPlus11_range_based_for_loop">Range-based for-loop</a>
+<li><a href="#CPlusPlus11_lambda_functions_and_expressions">Lambda functions and expressions</a>
+<li><a href="#CPlusPlus11_alternate_function_syntax">Alternate function syntax</a>
+<li><a href="#CPlusPlus11_object_construction_improvement">Object construction improvement</a>
+<li><a href="#CPlusPlus11_null_pointer_constant">Null pointer constant</a>
+<li><a href="#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
+<li><a href="#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
+<li><a href="#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
+<li><a href="#CPlusPlus11_alias_templates">Alias templates</a>
+<li><a href="#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
+<li><a href="#CPlusPlus11_variadic_templates">Variadic templates</a>
+<li><a href="#CPlusPlus11_new_string_literals">New string literals</a>
+<li><a href="#CPlusPlus11_user_defined_literals">User-defined literals</a>
+<li><a href="#CPlusPlus11_thread_local_storage">Thread-local storage</a>
+<li><a href="#CPlusPlus11_defaulted_deleted">Explicitly defaulted functions and deleted functions</a>
+<li><a href="#CPlusPlus11_type_long_long_int">Type long long int</a>
+<li><a href="#CPlusPlus11_static_assertions">Static assertions</a>
+<li><a href="#CPlusPlus11_allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object">Allow sizeof to work on members of classes without an explicit object</a>
</ul>
-<li><a href="#CPlusPlus11_Standard_library_changes">Standard library changes</a>
+<li><a href="#CPlusPlus11_standard_library_changes">Standard library changes</a>
<ul>
-<li><a href="#CPlusPlus11_Threading_facilities">Threading facilities</a>
-<li><a href="#CPlusPlus11_Tuple_types">Tuple types and hash tables</a>
-<li><a href="#CPlusPlus11_Regular_expressions">Regular expressions</a>
-<li><a href="#CPlusPlus11_General_purpose_smart_pointers">General-purpose smart pointers</a>
-<li><a href="#CPlusPlus11_Extensible_random_number_facility">Extensible random number facility</a>
-<li><a href="#CPlusPlus11_Wrapper_reference">Wrapper reference</a>
-<li><a href="#CPlusPlus11_Polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
-<li><a href="#CPlusPlus11_Type_traits_for_metaprogramming">Type traits for metaprogramming</a>
-<li><a href="#CPlusPlus11_Uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
+<li><a href="#CPlusPlus11_threading_facilities">Threading facilities</a>
+<li><a href="#CPlusPlus11_tuple_types">Tuple types and hash tables</a>
+<li><a href="#CPlusPlus11_regular_expressions">Regular expressions</a>
+<li><a href="#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
+<li><a href="#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
+<li><a href="#CPlusPlus11_wrapper_reference">Wrapper reference</a>
+<li><a href="#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
+<li><a href="#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
+<li><a href="#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
</ul>
</ul>
</div>
@@ -56,7 +56,7 @@
-<H2><a name="CPlusPlus11_Introduction"></a>7.1 Introduction</H2>
+<H2><a name="CPlusPlus11_introduction"></a>7.1 Introduction</H2>
<p>This chapter gives you a brief overview about the SWIG
@@ -68,10 +68,10 @@
new STL types (unordered_ containers, result_of, tuples) are not supported
yet.</p>
-<H2><a name="CPlusPlus11_Core_language_changes"></a>7.2 Core language changes</H2>
+<H2><a name="CPlusPlus11_core_language_changes"></a>7.2 Core language changes</H2>
-<H3><a name="CPlusPlus11_Rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
+<H3><a name="CPlusPlus11_rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
<p>SWIG correctly parses the new operator &amp;&amp; the same as the reference operator &amp;.</p>
@@ -87,7 +87,7 @@
};
</pre></div>
-<H3><a name="CPlusPlus11_Generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
+<H3><a name="CPlusPlus11_generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
<p>SWIG correctly parses the keyword <tt>constexpr</tt>, but ignores its functionality. Constant functions cannot be used as constants.</p>
@@ -105,7 +105,7 @@
const int a = MY_CONST; // ok
</pre></div>
-<H3><a name="CPlusPlus11_Extern_template"></a>7.2.3 Extern template</H3>
+<H3><a name="CPlusPlus11_extern_template"></a>7.2.3 Extern template</H3>
<p>SWIG correctly parses the keywords <tt>extern template</tt>. However, the explicit template instantiation is not used by SWIG, a <tt>%template</tt> is still required.</p>
@@ -123,7 +123,8 @@
};
</pre></div>
-<H3><a name="CPlusPlus11_Initializer_lists"></a>7.2.4 Initializer lists</H3>
+<H3><a name="CPlusPlus11_initializer_lists"></a>7.2.4 Initializer lists</H3>
+
<p>
Initializer lists are very much a C++ compiler construct and are not very accessible from wrappers as
@@ -254,7 +255,7 @@
and hence any user supplied typemaps will override it and suppress the warning.
</p>
-<H3><a name="CPlusPlus11_Uniform_initialization"></a>7.2.5 Uniform initialization</H3>
+<H3><a name="CPlusPlus11_uniform_initialization"></a>7.2.5 Uniform initialization</H3>
<p>The curly brackets {} for member initialization are fully
@@ -287,7 +288,7 @@
142.15
</pre></div>
-<H3><a name="CPlusPlus11_Type_inference"></a>7.2.6 Type inference</H3>
+<H3><a name="CPlusPlus11_type_inference"></a>7.2.6 Type inference</H3>
<p>SWIG supports <tt>decltype()</tt> with some limitations. Single
@@ -304,13 +305,13 @@
decltype(i+j) k; // syntax error
</pre></div>
-<H3><a name="CPlusPlus11_Range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
+<H3><a name="CPlusPlus11_range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
<p>This feature is part of the implementation block only. SWIG
ignores it.</p>
-<H3><a name="CPlusPlus11_Lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
+<H3><a name="CPlusPlus11_lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
<p>SWIG correctly parses most of the Lambda functions syntax. For example:</p>
@@ -336,7 +337,7 @@
Better support should be available in a later release.
</p>
-<H3><a name="CPlusPlus11_Alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
+<H3><a name="CPlusPlus11_alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
<p>SWIG fully supports the new definition of functions. For example:</p>
@@ -371,7 +372,7 @@
auto square(float a, float b) -&gt; decltype(a);
</pre></div>
-<H3><a name="CPlusPlus11_Object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
+<H3><a name="CPlusPlus11_object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
<p>
@@ -412,12 +413,12 @@
};
</pre></div>
-<H3><a name="CPlusPlus11_Null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
+<H3><a name="CPlusPlus11_null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
<p>The <tt>nullptr</tt> constant is largely unimportant in wrappers. In the few places it has an effect, it is treated like <tt>NULL</tt>.</p>
-<H3><a name="CPlusPlus11_Strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>
+<H3><a name="CPlusPlus11_strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>
<p>SWIG parses the new <tt>enum class</tt> syntax and forward declarator for the enums:</p>
@@ -468,7 +469,7 @@
};
</pre></div>
-<H3><a name="CPlusPlus11_Double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
+<H3><a name="CPlusPlus11_double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
<p>SWIG correctly parses the symbols &gt;&gt; as closing the
@@ -479,7 +480,7 @@
std::vector&lt;std::vector&lt;int&gt;&gt; myIntTable;
</pre></div>
-<H3><a name="CPlusPlus11_Explicit_conversion_operators"></a>7.2.14 Explicit conversion operators</H3>
+<H3><a name="CPlusPlus11_explicit_conversion_operators"></a>7.2.14 Explicit conversion operators</H3>
<p>SWIG correctly parses the keyword <tt>explicit</tt> both for operators and constructors.
@@ -515,7 +516,8 @@
to achieve particular copy and compare behaviours.
</p>
-<H3><a name="CPlusPlus11_Alias_templates"></a>7.2.15 Alias templates</H3>
+<H3><a name="CPlusPlus11_alias_templates"></a>7.2.15 Alias templates</H3>
+
<p>
The following is an example of an alias template:
@@ -567,7 +569,7 @@
typedef void (*PFD)(double); // The old style
</pre></div>
-<H3><a name="CPlusPlus11_Unrestricted_unions"></a>7.2.16 Unrestricted unions</H3>
+<H3><a name="CPlusPlus11_unrestricted_unions"></a>7.2.16 Unrestricted unions</H3>
<p>SWIG fully supports any type inside a union even if it does not
@@ -593,7 +595,7 @@
} p1;
</pre></div>
-<H3><a name="CPlusPlus11_Variadic_templates"></a>7.2.17 Variadic templates</H3>
+<H3><a name="CPlusPlus11_variadic_templates"></a>7.2.17 Variadic templates</H3>
<p>SWIG supports the variadic templates syntax (inside the &lt;&gt;
@@ -628,7 +630,7 @@
In the above example <tt>SIZE</tt> is of course wrapped as a constant.
</p>
-<H3><a name="CPlusPlus11_New_string_literals"></a>7.2.18 New string literals</H3>
+<H3><a name="CPlusPlus11_new_string_literals"></a>7.2.18 New string literals</H3>
<p>SWIG supports unicode string constants and raw string literals.</p>
@@ -652,7 +654,7 @@
<p>Note: SWIG currently incorrectly parses the odd number of double quotes
inside the string due to SWIG's C++ preprocessor.</p>
-<H3><a name="CPlusPlus11_User_defined_literals"></a>7.2.19 User-defined literals</H3>
+<H3><a name="CPlusPlus11_user_defined_literals"></a>7.2.19 User-defined literals</H3>
<p>
@@ -719,7 +721,7 @@
OutputType var3 = 3.1416_suffix;
</pre></div>
-<H3><a name="CPlusPlus11_Thread_local_storage"></a>7.2.20 Thread-local storage</H3>
+<H3><a name="CPlusPlus11_thread_local_storage"></a>7.2.20 Thread-local storage</H3>
<p>SWIG correctly parses the <tt>thread_local</tt> keyword. For example, variable
@@ -739,30 +741,34 @@
same way that it will be thread local if accessed from C++ code.
</p>
-<H3><a name="CPlusPlus11_Defaulting/deleting_of_standard_functions_on_C++_objects"></a>7.2.21 Defaulting/deleting of standard functions on C++ objects</H3>
+<H3><a name="CPlusPlus11_defaulted_deleted"></a>7.2.21 Explicitly defaulted functions and deleted functions</H3>
-<p>SWIG correctly parses the <tt>= delete</tt> and <tt>= default</tt>
-keywords. For example:</p>
+<p>SWIG handles explicitly defaulted functions, that is, <tt>= default</tt> added to a function declaration. Deleted definitions, which are also called deleted functions, have <tt>= delete</tt> added to the function declaration.
+For example:</p>
<div class="code"><pre>
struct NonCopyable {
NonCopyable&amp; operator=(const NonCopyable&amp;) = delete; /* Removes operator= */
- NonCopyable(const NonCopyable&amp;) = delete; /* Removed copy constructor */
- NonCopyable() = default; /* Explicitly allows the empty constructor */
- void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
+ NonCopyable(const NonCopyable&amp;) = delete; /* Removed copy constructor */
+ NonCopyable() = default; /* Explicitly allows the empty constructor */
+ void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
};
</pre></div>
-<p>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.</p>
+<p>
+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.
+</p>
-<H3><a name="CPlusPlus11_Type_long_long_int"></a>7.2.22 Type long long int</H3>
+<H3><a name="CPlusPlus11_type_long_long_int"></a>7.2.22 Type long long int</H3>
<p>SWIG correctly parses and uses the new <tt>long long</tt> type already introduced in C99 some time ago.</p>
-<H3><a name="CPlusPlus11_Static_assertions"></a>7.2.23 Static assertions</H3>
+<H3><a name="CPlusPlus11_static_assertions"></a>7.2.23 Static assertions</H3>
<p>SWIG correctly parses and calls the new <tt>static_assert</tt> function.</p>
@@ -774,7 +780,7 @@
};
</pre></div>
-<H3><a name="CPlusPlus11_Allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object"></a>7.2.24 Allow sizeof to work on members of classes without an explicit object</H3>
+<H3><a name="CPlusPlus11_allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object"></a>7.2.24 Allow sizeof to work on members of classes without an explicit object</H3>
<p>SWIG correctly calls the sizeof() on types as well as on the
@@ -794,28 +800,28 @@
8
</pre></div>
-<H2><a name="CPlusPlus11_Standard_library_changes"></a>7.3 Standard library changes</H2>
+<H2><a name="CPlusPlus11_standard_library_changes"></a>7.3 Standard library changes</H2>
-<H3><a name="CPlusPlus11_Threading_facilities"></a>7.3.1 Threading facilities</H3>
+<H3><a name="CPlusPlus11_threading_facilities"></a>7.3.1 Threading facilities</H3>
<p>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++.</p>
-<H3><a name="CPlusPlus11_Tuple_types"></a>7.3.2 Tuple types and hash tables</H3>
+<H3><a name="CPlusPlus11_tuple_types"></a>7.3.2 Tuple types and hash tables</H3>
<p>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.</p>
-<H3><a name="CPlusPlus11_Regular_expressions"></a>7.3.3 Regular expressions</H3>
+<H3><a name="CPlusPlus11_regular_expressions"></a>7.3.3 Regular expressions</H3>
<p>SWIG does not wrap the new C++11 regular expressions classes, because the SWIG target languages use their own facilities for this.</p>
-<H3><a name="CPlusPlus11_General_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
+<H3><a name="CPlusPlus11_general_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
<p>
@@ -823,12 +829,12 @@
There is no special smart pointer handling available for <tt>std::weak_ptr</tt> and <tt>std::unique_ptr</tt>.
</p>
-<H3><a name="CPlusPlus11_Extensible_random_number_facility"></a>7.3.5 Extensible random number facility</H3>
+<H3><a name="CPlusPlus11_extensible_random_number_facility"></a>7.3.5 Extensible random number facility</H3>
<p>This feature extends and standardizes the standard library only and does not effect the C++ language and SWIG.</p>
-<H3><a name="CPlusPlus11_Wrapper_reference"></a>7.3.6 Wrapper reference</H3>
+<H3><a name="CPlusPlus11_wrapper_reference"></a>7.3.6 Wrapper reference</H3>
<p>The new ref and cref classes are used to instantiate a parameter as a reference of a template function. For example:</p>
@@ -853,7 +859,7 @@
<p>The ref and cref classes are not wrapped by SWIG because the SWIG target languages do not support referencing.</p>
-<H3><a name="CPlusPlus11_Polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
+<H3><a name="CPlusPlus11_polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
<p>
@@ -884,7 +890,7 @@
b = t(1,2) # invoke C++ function object
</pre></div>
-<H3><a name="CPlusPlus11_Type_traits_for_metaprogramming"></a>7.3.8 Type traits for metaprogramming</H3>
+<H3><a name="CPlusPlus11_type_traits_for_metaprogramming"></a>7.3.8 Type traits for metaprogramming</H3>
<p>The new C++ metaprogramming is useful at compile time and is aimed specifically for C++ development:</p>
@@ -909,7 +915,7 @@
<p>SWIG correctly parses the template specialization, template types and values inside the &lt;&gt; block and the new helper functions: is_convertible, is_integral, is_const etc.
However, SWIG still explicitly requires concrete types when using the <tt>%template</tt> directive, so the C++ metaprogramming features are not really of interest at runtime in the target languages.</p>
-<H3><a name="CPlusPlus11_Uniform_method_for_computing_return_type_of_function_objects"></a>7.3.9 Uniform method for computing return type of function objects</H3>
+<H3><a name="CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects"></a>7.3.9 Uniform method for computing return type of function objects</H3>
<p>SWIG does not wrap the new result_of class introduced in the &lt;functional&gt; header and map the result_of::type to the concrete type yet. For example:</p>
View
14 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;
+%}
View
7 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; }
+%}
View
2  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 \
View
64 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 <stdlib.h>
+%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<class T> void f(T) = delete; /* Only accept int */
+ void func(int i) {}
+ virtual void fff(int) = delete;
+ virtual ~A2() = default;
+ template<class T> 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;
};
%}
View
3  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);
}
View
66 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 <str> ellipsis variadic;
%type <type> type rawtype type_right anon_bitfield_type decltype ;
%type <bases> base_list inherit raw_inherit;
-%type <dtype> definetype def_args etype;
+%type <dtype> definetype def_args etype default_delete deleted_definition explicit_default;
%type <dtype> expr exprnum exprcompound valexpr;
%type <id> ename ;
%type <id> 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; }
;
View
26 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"))) {

No commit comments for this range

Something went wrong with that request. Please try again.