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.
|
||
|---|---|---|
| .. | ||
| attribute.swg | ||
| carrays.swg | ||
| cdata.swg | ||
| cmalloc.swg | ||
| cpointer.swg | ||
| cstring.swg | ||
| cstrings.swg | ||
| cwstring.swg | ||
| enumint.swg | ||
| exception.swg | ||
| factory.swg | ||
| fragments.swg | ||
| implicit.swg | ||
| inoutlist.swg | ||
| misctypes.swg | ||
| primtypes.swg | ||
| ptrtypes.swg | ||
| README | ||
| std_except.swg | ||
| std_string.swg | ||
| std_strings.swg | ||
| std_wstring.swg | ||
| string.swg | ||
| strings.swg | ||
| swigmacros.swg | ||
| swigobject.swg | ||
| swigtype.swg | ||
| swigtypemaps.swg | ||
| typemaps.swg | ||
| valtypes.swg | ||
| void.swg | ||
| wstring.swg | ||
Still in development, but if you are interested into looking around,
start with
swigtypemaps.swg
which is the head file. Also read the docs for %fragments in
fragments.swg
and follow the definitions in one of the supported languages:
python, perl, ruby, tcl
/* -----------------------------------------------------------------------------
* Internal typemap specializations
* ----------------------------------------------------------------------------- */
carrays.swg Implement the carrays.i library
cdata.swg Implement the cdata.i library
cmalloc.swg Implement the cmalloc.i library
cpointer.swg Implement the cpointer.i library
cstring.swg Implement the cstring.i library typemaps for char *
cwstring.swg Implement the cstring.i library typemaps for wchar_t *
exception.swg Implement the exception.i library
implicit.swg Allow the use of implicit C++ constructors
string.swg Typemaps for char * string
wstring.swg Typemaps for wchar_t * string
std_string.swg Typemaps for std::string
std_wstring.swg Typemaps for std::wstring
swigtype.swg Typemaps for the SWIGTYPE type
void.swg Typemaps for the 'void' type
enumint.swg Typemaps for enums treated as 'int'
swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc.
misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc)
ptrtypes.swg Typemaps for types with a 'ptr' behavior
valtypes.swg Typemaps for 'by value' types
inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list
primtypes.swg Common macros to manage primitive types (short,int,double,etc)
cstrings.swg Common macros to implemented the cstring/cwstring libraries
std_strings.swg Common macros to implemented the std::string/std::wstring typemaps
strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *)
swigmacros.swg Basic macros
fragments.swg Macros for fragment manipulations
typemaps.swg The old typemaps.i library, not needed anymore