diff --git a/Lib/php4/php4.swg b/Lib/php4/php4.swg index 2ff5fd668..89bb66594 100644 --- a/Lib/php4/php4.swg +++ b/Lib/php4/php4.swg @@ -119,20 +119,22 @@ This bit should go in arginit if arginit support init-ing scripting args */ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ - if ((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input)) { -#ifdef __cplusplus - ptr=new $*1_ltype; -#else - ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); -#endif - $1=&ptr; - /* have to passback arg$arg too */ - force=1; - } else { /* wasn't a pre/ref/thing, OR anything like an int thing */ - force=0; - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); + if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { + /* wasn't a pre/ref/thing, OR anything like an int thing */ + SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); } - } else force=0; + } + force=0; + if (arg1==NULL) { +#ifdef __cplusplus + ptr=new $*1_ltype; +#else + ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); +#endif + $1=&ptr; + /* have to passback arg$arg too */ + force=1; + } } %typemap(argout) void **, void *& diff --git a/Lib/php4/typemaps.i b/Lib/php4/typemaps.i index 2cf725370..f36a8138f 100644 --- a/Lib/php4/typemaps.i +++ b/Lib/php4/typemaps.i @@ -151,20 +151,22 @@ int_typemap(unsigned char); This bit should go in arginit if arginit support init-ing scripting args */ if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ - if ((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input)) { -#ifdef __cplusplus - ptr=new $*1_ltype; -#else - ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); -#endif - $1=&ptr; - /* have to passback arg$arg too */ - force=1; - } else { /* wasn't a pre/ref/thing, OR anything like an int thing */ - force=0; + if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { + /* wasn't a pre/ref/thing, OR anything like an int thing */ SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); } - } else force=0; + } + force=0; + if (arg1==NULL) { +#ifdef __cplusplus + ptr=new $*1_ltype; +#else + ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); +#endif + $1=&ptr; + /* have to passback arg$arg too */ + force=1; + } } %typemap(argout) void **OUTPUT,