SWIGTYPE && input typemaps now assume object has been moved

Replicated Java implementation.

Fully implemented for:
- C#
- D
- Guile
- Javascript (UTL)
- Lua
- MzScheme
- Octave (UTL)
- Perl (UTL)
- PHP
- Python (UTL)
- Ruby (UTL)
- Tcl (UTL)

PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
This commit is contained in:
William S Fulton 2022-08-20 15:40:53 +01:00
commit e139a36511
31 changed files with 931 additions and 46 deletions

View file

@ -8,9 +8,6 @@
* C++ layer when passed as a parameter to a wrapped function.
* ----------------------------------------------------------------------------- */
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv);
#define %set_output(obj) $result = obj
%define %auto_ptr(TYPE)
%typemap(in, noblock=1) std::auto_ptr< TYPE > (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);

View file

@ -8,9 +8,6 @@
* C++ layer when passed as a parameter to a wrapped function.
* ----------------------------------------------------------------------------- */
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv);
#define %set_output(obj) $result = obj
%define %unique_ptr(TYPE)
%typemap(in, noblock=1) std::unique_ptr< TYPE > (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);

View file

@ -4,7 +4,7 @@
#define %set_output(obj) $result = obj
#define %set_varoutput(obj) $result = obj
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv);
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv)
#define %as_voidptr(ptr) (void*)(ptr)
@ -72,9 +72,23 @@
#ifdef __cplusplus
%typemap(in) SWIGTYPE &, SWIGTYPE && {
%typemap(in) SWIGTYPE & {
$1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)");
if ($1 == NULL) scheme_signal_error(FUNC_NAME ": swig-type-error (null reference)");
}
%typemap(in, noblock=1, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) {
res = SWIG_ConvertPtr($input, &argp, $descriptor, SWIG_POINTER_RELEASE);
if (!SWIG_IsOK(res)) {
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
scheme_signal_error(FUNC_NAME ": cannot release ownership as memory is not owned for argument $argnum of type '$1_type'");
} else {
%argument_fail(res, "$1_type", $symname, $argnum);
}
}
if (argp == NULL) scheme_signal_error(FUNC_NAME ": swig-type-error (null reference)");
$1 = ($1_ltype)argp;
rvrdeleter.reset($1);
}
%typemap(out) SWIGTYPE &, SWIGTYPE && {