Move SwigValueWrapper to header section

Recent change to SwigValueWrapper required the <utility> header.
Included headers should be after the include of the language
specific header files (which go into the earlier runtime section).

Testcase required -Winit-list-lifetime warning suppression change
for Perl which somehow lost the warning suppression when put
into the %begin section.
This commit is contained in:
William S Fulton 2022-09-09 07:49:48 +01:00
commit 0c2d0fea0f
2 changed files with 5 additions and 6 deletions

View file

@ -10,7 +10,7 @@
$1 = {"Ab", "Fab"}; $1 = {"Ab", "Fab"};
%} %}
%begin %{ %runtime %{
#if __GNUC__ >= 9 #if __GNUC__ >= 9
/* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */ /* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */
/* incorrect warning for C::C(std::initializer_list<const char *>) */ /* incorrect warning for C::C(std::initializer_list<const char *>) */

View file

@ -665,7 +665,9 @@ namespace std {
*/ */
#ifdef __cplusplus #ifdef __cplusplus
%insert("runtime") %{ // Placed in the header section to ensure the language specific header files are
// the first included headers and not <utility>
%insert("header") %{
#ifdef __cplusplus #ifdef __cplusplus
#include <utility> #include <utility>
/* SwigValueWrapper is described in swig.swg */ /* SwigValueWrapper is described in swig.swg */
@ -688,7 +690,7 @@ public:
operator T&() const { return *pointer.ptr; } operator T&() const { return *pointer.ptr; }
#endif #endif
T *operator&() const { return pointer.ptr; } T *operator&() const { return pointer.ptr; }
};%} };
/* /*
* SwigValueInit() is a generic initialisation solution as the following approach: * SwigValueInit() is a generic initialisation solution as the following approach:
@ -699,13 +701,10 @@ public:
* *
* unsigned int c_result = unsigned int(); * unsigned int c_result = unsigned int();
*/ */
%insert("runtime") %{
template <typename T> T SwigValueInit() { template <typename T> T SwigValueInit() {
return T(); return T();
} }
%}
%insert("runtime") %{
#if __cplusplus >=201103L #if __cplusplus >=201103L
# define SWIG_STD_MOVE(OBJ) std::move(OBJ) # define SWIG_STD_MOVE(OBJ) std::move(OBJ)
#else #else