diff --git a/php_v8js_macros.h b/php_v8js_macros.h index 8da8861..f180ae3 100644 --- a/php_v8js_macros.h +++ b/php_v8js_macros.h @@ -129,6 +129,16 @@ struct php_v8js_timer_ctx php_v8js_ctx *v8js_ctx; }; +/* {{{ Object container */ +struct php_v8js_object { + zend_object std; + v8::Persistent v8obj; + int flags; + v8::Isolate *isolate; +}; +/* }}} */ + + /* Module globals */ ZEND_BEGIN_MODULE_GLOBALS(v8js) int v8_initialized; diff --git a/tests/function_passback.phpt b/tests/function_passback.phpt new file mode 100644 index 0000000..ec6b974 --- /dev/null +++ b/tests/function_passback.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test V8::executeString() : Call passed-back function +--SKIPIF-- + +--FILE-- +executeString($JS, 'basic.js'); +$v8->func = get_object_vars( $exports )['hello']; + +echo $v8->executeString('PHP.func();')."\n"; + +?> +===EOF=== +--EXPECT-- +hello +===EOF=== diff --git a/v8js.cc b/v8js.cc index 3826636..34d9d10 100644 --- a/v8js.cc +++ b/v8js.cc @@ -101,15 +101,6 @@ struct php_v8js_jsext { }; /* }}} */ -/* {{{ Object container */ -struct php_v8js_object { - zend_object std; - v8::Persistent v8obj; - int flags; - v8::Isolate *isolate; -}; -/* }}} */ - #ifdef COMPILE_DL_V8JS ZEND_GET_MODULE(v8js) #endif diff --git a/v8js_convert.cc b/v8js_convert.cc index 76a7830..5ba0d2d 100644 --- a/v8js_convert.cc +++ b/v8js_convert.cc @@ -371,7 +371,10 @@ static v8::Handle php_v8js_hash_to_jsobj(zval *value, v8::Isolate *is } /* Object methods */ - if (ce) { + if (ce == php_ce_v8_function) { + php_v8js_object *c = (php_v8js_object *) zend_object_store_get_object(value TSRMLS_CC); + return c->v8obj; + } else if (ce) { v8::Handle new_tpl; bool cached_tpl = true; static TemplateCache tpl_map;