[PHP] Fix out typemap for member function pointers
The existing typemap was just broken - it correctly created the resource and then did nothing with it, and instead tried to register the member pointer as a normal pointer, which is never going to work as it's larger than a normal pointer. Add cpp_basic_runme.php as a regression test for this.
This commit is contained in:
parent
888e9c6fec
commit
a4015acaca
3 changed files with 24 additions and 5 deletions
|
|
@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.11 (in progress)
|
Version 3.0.11 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2016-09-02: olly
|
||||||
|
[PHP] Fix out typemap for member function pointers.
|
||||||
|
|
||||||
2016-08-22: wsfulton
|
2016-08-22: wsfulton
|
||||||
[Python] The following builtin slots can be customized like other slots via the
|
[Python] The following builtin slots can be customized like other slots via the
|
||||||
"python:<x>" and "python:slot" features where <x> is the appropriate slot name:
|
"python:<x>" and "python:slot" features where <x> is the appropriate slot name:
|
||||||
|
|
|
||||||
20
Examples/test-suite/php/cpp_basic_runme.php
Normal file
20
Examples/test-suite/php/cpp_basic_runme.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require "tests.php";
|
||||||
|
require "cpp_basic.php";
|
||||||
|
|
||||||
|
// New functions
|
||||||
|
check::functions(array(foo_func1,foo_func2,foo___str__,foosubsub___str__,bar_test,bar_testfoo,get_func1_ptr,get_func2_ptr,test_func_ptr,fl_window_show));
|
||||||
|
// New classes
|
||||||
|
check::classes(array(cpp_basic,Foo,FooSub,FooSubSub,Bar,Fl_Window));
|
||||||
|
// New vars
|
||||||
|
check::globals(array(foo_num,foo_func_ptr,bar_fptr,bar_fref,bar_fval,bar_cint,bar_global_fptr,bar_global_fref,bar_global_fval));
|
||||||
|
|
||||||
|
$f = new Foo(3);
|
||||||
|
$f->func_ptr = get_func1_ptr();
|
||||||
|
check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work");
|
||||||
|
$f->func_ptr = get_func2_ptr();
|
||||||
|
check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work");
|
||||||
|
|
||||||
|
check::done();
|
||||||
|
?>
|
||||||
|
|
@ -393,11 +393,7 @@
|
||||||
{
|
{
|
||||||
void * p = emalloc(sizeof($1));
|
void * p = emalloc(sizeof($1));
|
||||||
memcpy(p, &$1, sizeof($1));
|
memcpy(p, &$1, sizeof($1));
|
||||||
zval * resource;
|
ZEND_REGISTER_RESOURCE(return_value, p, swig_member_ptr);
|
||||||
MAKE_STD_ZVAL(resource);
|
|
||||||
ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr);
|
|
||||||
|
|
||||||
SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue