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

@ -125,14 +125,31 @@
swig_acquire_ownership_obj((void*)$result, own);
%}
%typemap(in, phptype="SWIGTYPE") SWIGTYPE &,
SWIGTYPE &&
%typemap(in, phptype="SWIGTYPE") SWIGTYPE &
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
return;
}
%}
%typemap(in, 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) {
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of $1_descriptor of $symname");
return;
} else {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
return;
}
}
if (!argp) {
zend_type_error("Invalid null reference for argument $argnum of $1_descriptor of $symname");
return;
}
$1 = ($1_ltype)argp;
rvrdeleter.reset($1);
%}
%typemap(directorout) SWIGTYPE & ($1_ltype tmp),
SWIGTYPE && ($1_ltype tmp)

View file

@ -13,10 +13,10 @@
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
if (!SWIG_IsOK(res)) {
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *' of $symname");
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of $descriptor(TYPE *) of $symname");
return;
} else {
zend_type_error("Expected TYPE * for argument $argnum of $symname");
zend_type_error("Expected $descriptor(TYPE *) for argument $argnum of $symname");
return;
}
}

View file

@ -13,10 +13,10 @@
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
if (!SWIG_IsOK(res)) {
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *' of $symname");
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of $descriptor(TYPE *) of $symname");
return;
} else {
zend_type_error("Expected TYPE * for argument $argnum of $symname");
zend_type_error("Expected $descriptor(TYPE *) for argument $argnum of $symname");
return;
}
}