summaryrefslogtreecommitdiff
path: root/Lib/php
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-06-22 12:52:06 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-06-30 17:26:48 +0100
commitbf36bf7d8aa8d130f30d0cbb2c260966f96bc108 (patch)
tree3a5bc569e4112ff55db9c0c2e28ad35392ddf698 /Lib/php
parent6ccef6dae1dee6d569642d49f449c40e8d432627 (diff)
downloadswig-bf36bf7d8aa8d130f30d0cbb2c260966f96bc108.tar.gz
Movable and move-only types supported in "out" typemaps.
Enhance SWIGTYPE "out" typemaps to use std::move when copying objects, thereby making use of move semantics when wrapping a function returning by value if the returned type supports move semantics. Wrapping functions that return move only types 'by value' now work out the box without having to provide custom typemaps. The implementation removed all casts in the "out" typemaps to allow the compiler to appropriately choose calling a move constructor, where possible, otherwise a copy constructor. The implementation alsoand required modifying SwigValueWrapper to change a cast operator from: SwigValueWrapper::operator T&() const; to #if __cplusplus >=201103L SwigValueWrapper::operator T&&() const; #else SwigValueWrapper::operator T&() const; #endif This is not backwards compatible for C++11 and later when using the valuewrapper feature if a cast is explicitly being made in user supplied "out" typemaps. Suggested change in custom "out" typemaps for C++11 and later code: 1. Try remove the cast altogether to let the compiler use an appropriate implicit cast. 2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the __cplusplus macro if all versions of C++ need to be supported. Issue #999 Closes #1044 More about the commit: Added some missing "varout" typemaps for Ocaml which was falling back to use "out" typemaps as they were missing. Ruby std::set fix for SwigValueWrapper C++11 changes.
Diffstat (limited to 'Lib/php')
-rw-r--r--Lib/php/php.swg2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index ffcffde70..7d6d5f29d 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -443,7 +443,7 @@
%typemap(out, phptype="SWIGTYPE") SWIGTYPE
{
#ifdef __cplusplus
- $&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1);
+ $&1_ltype resultobj = new $1_ltype($1);
#else
$&1_ltype resultobj = ($&1_ltype) malloc(sizeof($1_type));
memcpy(resultobj, &$1, sizeof($1_type));