diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2022-08-20 15:40:53 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2022-08-31 19:40:14 +0100 |
commit | e139a3651157a42e0086b15ce9df5dcba48cf4b2 (patch) | |
tree | 22d0c28382122bb3cd6b291d3dfa5a86e4e1d9b5 /Lib/php | |
parent | 0634883089550070c55e53a9f788a6794f3efaf2 (diff) | |
download | swig-e139a3651157a42e0086b15ce9df5dcba48cf4b2.tar.gz |
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
Diffstat (limited to 'Lib/php')
-rw-r--r-- | Lib/php/php.swg | 21 | ||||
-rw-r--r-- | Lib/php/std_auto_ptr.i | 4 | ||||
-rw-r--r-- | Lib/php/std_unique_ptr.i | 4 |
3 files changed, 23 insertions, 6 deletions
diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 26944a1af..04b7075b7 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -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) diff --git a/Lib/php/std_auto_ptr.i b/Lib/php/std_auto_ptr.i index 7df497e60..bd07dbdb5 100644 --- a/Lib/php/std_auto_ptr.i +++ b/Lib/php/std_auto_ptr.i @@ -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; } } diff --git a/Lib/php/std_unique_ptr.i b/Lib/php/std_unique_ptr.i index 591f580cb..168273663 100644 --- a/Lib/php/std_unique_ptr.i +++ b/Lib/php/std_unique_ptr.i @@ -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; } } |