Fix in typemap for void** and void*&

Mark the parameter as "byref" and write back through the reference
after the call.

Adjust testcase argout to uncomment the part that's meant to test this,
and to remove lingering traces of PHP's old call-time pass-by-reference
(which was completely removed before PHP 7).

Fixes #1457
This commit is contained in:
Olly Betts 2021-04-14 17:05:19 +12:00
commit 451998f27b
2 changed files with 6 additions and 12 deletions

View file

@ -157,7 +157,7 @@
/* Special case when void* is passed by reference so it can be made to point
to opaque api structs */
%typemap(in) void ** ($*1_ltype ptr, int force),
%typemap(in, byref=1) void ** ($*1_ltype ptr, int force),
void *& ($*1_ltype ptr, int force)
{
/* If they pass NULL by reference, make it into a void*
@ -184,8 +184,8 @@
%typemap(argout) void **,
void *&
%{
if (force$argnum) {
SWIG_SetPointerZval(&$input, (void*) ptr$argnum, $*1_descriptor, 1);
if (force$argnum && Z_ISREF($input)) {
SWIG_SetPointerZval(Z_REFVAL($input), (void*) ptr$argnum, $*1_descriptor, 1);
}
%}