Provide SWIGTYPE MOVE typemaps in swigmove.i

For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.

Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).

Issue #999
This commit is contained in:
William S Fulton 2022-09-16 08:36:25 +01:00
commit dad7c93ca0
41 changed files with 909 additions and 19 deletions

18
Lib/lua/swigmove.i Normal file
View file

@ -0,0 +1,18 @@
/* -----------------------------------------------------------------------------
* swigmove.i
*
* Input typemaps library for implementing full move semantics when passing
* parameters by value.
* ----------------------------------------------------------------------------- */
%typemap(in, checkfn="lua_isuserdata", noblock=1) SWIGTYPE MOVE (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr(L, $input, &argp, $&1_descriptor, SWIG_POINTER_RELEASE);
if (!SWIG_IsOK(res)) {
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
lua_pushfstring(L, "Cannot release ownership as memory is not owned for argument $argnum of type '$1_type' in $symname"); SWIG_fail;
} else {
SWIG_fail_ptr("$symname", $argnum, $&1_descriptor);
}
}
SwigValueWrapper< $1_ltype >::reset($1, ($&1_type)argp);
}