diff --git a/tests/issue_183_003.phpt b/tests/issue_183_003.phpt new file mode 100644 index 0000000..1a96c3f --- /dev/null +++ b/tests/issue_183_003.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test V8::executeString() : Method access on derived classes (V8Js methods) +--SKIPIF-- + +--FILE-- +executeString($JS); + +?> +===EOF=== +--EXPECTF-- +string(8) "function" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(9) "undefined" +string(6) "caught" +===EOF=== diff --git a/v8js_class.cc b/v8js_class.cc index 27f2457..5b121ae 100644 --- a/v8js_class.cc +++ b/v8js_class.cc @@ -46,6 +46,9 @@ static zend_class_entry *php_ce_v8js; static zend_object_handlers v8js_object_handlers; /* }}} */ +/* Forward declare v8js_methods, actually "static" but not possible in C++ */ +extern const zend_function_entry v8js_methods[]; + typedef struct _v8js_script { char *name; v8js_ctx *ctx; @@ -526,6 +529,19 @@ static PHP_METHOD(V8Js, __construct) continue; } + const zend_function_entry *fe; + for (fe = v8js_methods; fe->fname; fe ++) { + if (fe->fname == method_ptr->common.function_name) { + break; + } + } + + if(fe->fname) { + /* Method belongs to \V8Js class itself, never export to V8, even if + * it is overriden in a derived class. */ + continue; + } + v8::Local method_name = V8JS_STR(method_ptr->common.function_name); v8::Local ft; @@ -1119,7 +1135,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_setmemorylimit, 0, 0, 1) ZEND_END_ARG_INFO() -static const zend_function_entry v8js_methods[] = { /* {{{ */ +const zend_function_entry v8js_methods[] = { /* {{{ */ PHP_ME(V8Js, __construct, arginfo_v8js_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(V8Js, __sleep, arginfo_v8js_sleep, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(V8Js, __wakeup, arginfo_v8js_sleep, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)