[php] Fix director upcall check
This resolves an issue uncovered by adding a _runme.php for testcase director_alternating.
This commit is contained in:
parent
87c2e7d71a
commit
7b929dce82
3 changed files with 18 additions and 11 deletions
11
Examples/test-suite/php/director_alternating_runme.php
Normal file
11
Examples/test-suite/php/director_alternating_runme.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
|
||||
check::functions(array('getBar','idFromGetBar'));
|
||||
check::classes(array('Foo','Bar','Baz','director_alternating'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$id = director_alternating::getBar()->id();
|
||||
check::equal($id, director_alternating::idFromGetBar(), "idFromGetBar() failed");
|
||||
|
|
@ -99,6 +99,8 @@ namespace Swig {
|
|||
}
|
||||
}
|
||||
|
||||
zend_object *swig_get_self() const { return Z_OBJ(swig_self); }
|
||||
|
||||
void swig_disown() const {
|
||||
if (!swig_disown_flag) {
|
||||
swig_disown_flag = true;
|
||||
|
|
@ -106,13 +108,6 @@ namespace Swig {
|
|||
}
|
||||
}
|
||||
|
||||
static bool swig_is_overridden_method(const char *cname, zval *z) {
|
||||
zend_string * cname_str = zend_string_init(cname, strlen(cname), 0);
|
||||
zend_class_entry *ce = zend_lookup_class(cname_str);
|
||||
zend_string_release(cname_str);
|
||||
return ce == Z_OBJCE_P(z);
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void swig_acquire_ownership(Type *vptr) const {
|
||||
if (vptr) {
|
||||
|
|
|
|||
|
|
@ -1336,9 +1336,10 @@ public:
|
|||
}
|
||||
|
||||
if (is_member_director(n)) {
|
||||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Append(f->code, "director = SWIG_DIRECTOR_CAST(arg1);\n");
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method(\"%s%s\", ZEND_THIS);\n",
|
||||
prefix, Swig_class_name(Swig_methodclass(n)));
|
||||
Printf(f->code, "upcall = (director && (director->swig_get_self()==Z_OBJ_P(ZEND_THIS)));\n");
|
||||
}
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
|
|
@ -1904,8 +1905,8 @@ public:
|
|||
Delete(director_ctor_code);
|
||||
director_ctor_code = NewStringEmpty();
|
||||
director_prot_ctor_code = NewStringEmpty();
|
||||
Printf(director_ctor_code, "if (Swig::Director::swig_is_overridden_method(\"%s\", arg0)) { /* not subclassed */\n", class_name);
|
||||
Printf(director_prot_ctor_code, "if (Swig::Director::swig_is_overridden_method(\"%s\", arg0)) { /* not subclassed */\n", class_name);
|
||||
Printf(director_ctor_code, "if (Z_OBJCE_P(arg0) == SWIG_Php_ce_%s) { /* not subclassed */\n", class_name);
|
||||
Printf(director_prot_ctor_code, "if (Z_OBJCE_P(arg0) == SWIG_Php_ce_%s) { /* not subclassed */\n", class_name);
|
||||
Printf(director_ctor_code, " %s = new %s(%s);\n", Swig_cresult_name(), ctype, args);
|
||||
Printf(director_prot_ctor_code,
|
||||
" zend_throw_exception(zend_ce_type_error, \"accessing abstract class or protected constructor\", 0);\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue