From dad7c93ca0a923e7d2671347cee711d180dd0338 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Sep 2022 08:36:25 +0100 Subject: 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 --- Lib/guile/swigmove.i | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Lib/guile/swigmove.i (limited to 'Lib/guile') diff --git a/Lib/guile/swigmove.i b/Lib/guile/swigmove.i new file mode 100644 index 000000000..87ab91ead --- /dev/null +++ b/Lib/guile/swigmove.i @@ -0,0 +1,19 @@ +/* ----------------------------------------------------------------------------- + * swigmove.i + * + * Input typemaps library for implementing full move semantics when passing + * parameters by value. + * ----------------------------------------------------------------------------- */ + +%typemap(in, noblock=1) SWIGTYPE MOVE (void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $&1_descriptor, SWIG_POINTER_RELEASE); + if (!SWIG_IsOK(res)) { + if (res == SWIG_ERROR_RELEASE_NOT_OWNED) { + %releasenotowned_fail(res, "$1_type", $symname, $argnum); + } else { + %argument_fail(res, "$1_type", $symname, $argnum); + } + } + if (!argp) { %argument_nullref("$1_type", $symname, $argnum); } + SwigValueWrapper< $1_ltype >::reset($1, ($&1_type)argp); +} -- cgit v1.2.1