summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2021-12-23 12:45:12 +1300
committerOlly Betts <olly@survex.com>2021-12-23 13:52:26 +1300
commitb18bd0815f0689d15680dcb8b86afd100676567c (patch)
treec1c432b8fbb69083143d3761649f1a68eddababd
parente85a6538b924ecef89ef4723bebef95993821d6c (diff)
downloadswig-b18bd0815f0689d15680dcb8b86afd100676567c.tar.gz
Add some missing phptype annotations
See #2027
-rw-r--r--Examples/test-suite/php/argout_runme.php13
-rw-r--r--Examples/test-suite/php/li_factory_runme.php3
-rw-r--r--Lib/php/factory.i2
-rw-r--r--Lib/php/php.swg2
-rw-r--r--Lib/php/typemaps.i6
5 files changed, 16 insertions, 10 deletions
diff --git a/Examples/test-suite/php/argout_runme.php b/Examples/test-suite/php/argout_runme.php
index d233cf0f6..554d07756 100644
--- a/Examples/test-suite/php/argout_runme.php
+++ b/Examples/test-suite/php/argout_runme.php
@@ -20,11 +20,14 @@ $tr=copy_intp(4);
check::equal(4,inctr($tr),"4==incr($tr)");
check::equal(5,intp_value($tr),"5==$tr");
-# Check the voidhandle call, first with null
+# Check the voidhandle call, first with NULL and then with the SWIG\p_void we
+# get from the first call.
$handle=NULL;
-voidhandle($handle);
-check::equal(get_class($handle),"SWIG\\_p_void",'$handle is not _p_void');
-$handledata=handle($handle);
-check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
+for ($i=0; $i != 1; $i++) {
+ voidhandle($handle);
+ check::equal(get_class($handle),"SWIG\\_p_void",'$handle is not _p_void');
+ $handledata=handle($handle);
+ check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
+}
check::done();
diff --git a/Examples/test-suite/php/li_factory_runme.php b/Examples/test-suite/php/li_factory_runme.php
index 3ccdd035f..bdc2f007a 100644
--- a/Examples/test-suite/php/li_factory_runme.php
+++ b/Examples/test-suite/php/li_factory_runme.php
@@ -17,4 +17,7 @@ $point = Geometry::create(Geometry::POINT);
$w = $point->width();
check::equal($w, 1.0, "w failed");
+$point = Geometry::create(42);
+check::equal($point, NULL, "NULL failed");
+
check::done();
diff --git a/Lib/php/factory.i b/Lib/php/factory.i
index 5a1f9dc06..5f2b397ec 100644
--- a/Lib/php/factory.i
+++ b/Lib/php/factory.i
@@ -100,7 +100,7 @@ if (!dcast) {
}%enddef
%define %factory(Method,Types...)
-%typemap(out) Method {
+%typemap(out, phptype="?SWIGTYPE") Method {
int dcast = 0;
%formacro(%_factory_dispatch, Types)
if (!dcast) {
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index 137ab44fc..aca8f6825 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -176,7 +176,7 @@
/* Special case when void* is passed by reference so it can be made to point
to opaque api structs */
-%typemap(in, byref=1) void ** ($*1_ltype ptr, int force),
+%typemap(in, phptype="?SWIG\\_p_void", 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*
diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i
index c15497b98..321b1202c 100644
--- a/Lib/php/typemaps.i
+++ b/Lib/php/typemaps.i
@@ -52,7 +52,7 @@
%enddef
%define DOUBLE_TYPEMAP(TYPE)
-%typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp)
+%typemap(in, phptype="float") TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp)
%{
temp = (TYPE) zval_get_double(&$input);
$1 = &temp;
@@ -65,7 +65,7 @@
ZVAL_DOUBLE(&o, temp$argnum);
t_output_helper($result, &o);
}
-%typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue)
+%typemap(in, phptype="float") TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue)
%{
dvalue = (TYPE) zval_get_double(&$input);
$1 = &dvalue;
@@ -90,7 +90,7 @@
ZVAL_LONG(&o, temp$argnum);
t_output_helper($result, &o);
}
-%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
+%typemap(in, phptype="int") TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
%{
lvalue = (TYPE) zval_get_long(&$input);
$1 = &lvalue;