diff --git a/php_v8js_macros.h b/php_v8js_macros.h index baca44a..8c70aa7 100644 --- a/php_v8js_macros.h +++ b/php_v8js_macros.h @@ -108,7 +108,7 @@ struct v8js_accessor_ctx void v8js_accessor_ctx_dtor(v8js_accessor_ctx * TSRMLS_DC); /* Register accessors into passed object */ -void php_v8js_register_accessors(std::vector *accessor_list, v8::Local, zval *, v8::Isolate * TSRMLS_DC); +void v8js_register_accessors(std::vector *accessor_list, v8::Local, zval *, v8::Isolate * TSRMLS_DC); /* Resource declaration */ @@ -142,15 +142,7 @@ ZEND_EXTERN_MODULE_GLOBALS(v8js) #endif /* Register builtin methods into passed object */ -void php_v8js_register_methods(v8::Handle, v8js_ctx *c); - -typedef struct _v8js_script { - char *name; - v8::Isolate *isolate; - v8::Persistent> *script; -} v8js_script; - -static void v8js_script_free(v8js_script *res, bool dispose_persistent); +void v8js_register_methods(v8::Handle, v8js_ctx *c); #endif /* PHP_V8JS_MACROS_H */ diff --git a/v8js_array_access.cc b/v8js_array_access.cc index 9a0c259..b55a313 100644 --- a/v8js_array_access.cc +++ b/v8js_array_access.cc @@ -27,7 +27,7 @@ extern "C" { #include "v8js_object_export.h" -static zval *php_v8js_array_access_dispatch(zval *object, const char *method_name, int param_count, +static zval *v8js_array_access_dispatch(zval *object, const char *method_name, int param_count, uint32_t index, zval *zvalue_ptr TSRMLS_DC) /* {{{ */ { zend_class_entry *ce = Z_OBJCE_P(object); @@ -66,7 +66,7 @@ static zval *php_v8js_array_access_dispatch(zval *object, const char *method_nam -void php_v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo& info) /* {{{ */ +void v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -76,7 +76,7 @@ void php_v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo v8::Local php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY)); zval *object = reinterpret_cast(v8::External::Cast(*php_object)->Value()); - zval *php_value = php_v8js_array_access_dispatch(object, "offsetGet", 1, index, NULL TSRMLS_CC); + zval *php_value = v8js_array_access_dispatch(object, "offsetGet", 1, index, NULL TSRMLS_CC); v8::Local ret_value = zval_to_v8js(php_value, isolate TSRMLS_CC); zval_ptr_dtor(&php_value); @@ -84,7 +84,7 @@ void php_v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo } /* }}} */ -void php_v8js_array_access_setter(uint32_t index, v8::Local value, +void v8js_array_access_setter(uint32_t index, v8::Local value, const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); @@ -102,7 +102,7 @@ void php_v8js_array_access_setter(uint32_t index, v8::Local value, return; } - zval *php_value = php_v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue_ptr TSRMLS_CC); + zval *php_value = v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue_ptr TSRMLS_CC); zval_ptr_dtor(&php_value); /* simply pass back the value to tell we intercepted the call @@ -116,9 +116,9 @@ void php_v8js_array_access_setter(uint32_t index, v8::Local value, /* }}} */ -static int php_v8js_array_access_get_count_result(zval *object TSRMLS_DC) /* {{{ */ +static int v8js_array_access_get_count_result(zval *object TSRMLS_DC) /* {{{ */ { - zval *php_value = php_v8js_array_access_dispatch(object, "count", 0, 0, NULL TSRMLS_CC); + zval *php_value = v8js_array_access_dispatch(object, "count", 0, 0, NULL TSRMLS_CC); if(Z_TYPE_P(php_value) != IS_LONG) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-numeric return value from count() method"); @@ -132,9 +132,9 @@ static int php_v8js_array_access_get_count_result(zval *object TSRMLS_DC) /* {{{ } /* }}} */ -static bool php_v8js_array_access_isset_p(zval *object, int index TSRMLS_DC) /* {{{ */ +static bool v8js_array_access_isset_p(zval *object, int index TSRMLS_DC) /* {{{ */ { - zval *php_value = php_v8js_array_access_dispatch(object, "offsetExists", 1, index, NULL TSRMLS_CC); + zval *php_value = v8js_array_access_dispatch(object, "offsetExists", 1, index, NULL TSRMLS_CC); if(Z_TYPE_P(php_value) != IS_BOOL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-boolean return value from offsetExists() method"); @@ -149,7 +149,7 @@ static bool php_v8js_array_access_isset_p(zval *object, int index TSRMLS_DC) /* /* }}} */ -static void php_v8js_array_access_length(v8::Local property, const v8::PropertyCallbackInfo& info) /* {{{ */ +static void v8js_array_access_length(v8::Local property, const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -159,12 +159,12 @@ static void php_v8js_array_access_length(v8::Local property, const v v8::Local php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY)); zval *object = reinterpret_cast(v8::External::Cast(*php_object)->Value()); - int length = php_v8js_array_access_get_count_result(object TSRMLS_CC); + int length = v8js_array_access_get_count_result(object TSRMLS_CC); info.GetReturnValue().Set(V8JS_INT(length)); } /* }}} */ -void php_v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo& info) /* {{{ */ +void v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -174,14 +174,14 @@ void php_v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInf v8::Local php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY)); zval *object = reinterpret_cast(v8::External::Cast(*php_object)->Value()); - zval *php_value = php_v8js_array_access_dispatch(object, "offsetUnset", 1, index, NULL TSRMLS_CC); + zval *php_value = v8js_array_access_dispatch(object, "offsetUnset", 1, index, NULL TSRMLS_CC); zval_ptr_dtor(&php_value); info.GetReturnValue().Set(V8JS_BOOL(true)); } /* }}} */ -void php_v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo& info) /* {{{ */ +void v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -193,14 +193,14 @@ void php_v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo< /* If index is set, then return an integer encoding a v8::PropertyAttribute; * otherwise we're expected to return an empty handle. */ - if(php_v8js_array_access_isset_p(object, index TSRMLS_CC)) { + if(v8js_array_access_isset_p(object, index TSRMLS_CC)) { info.GetReturnValue().Set(V8JS_UINT(v8::PropertyAttribute::None)); } } /* }}} */ -void php_v8js_array_access_enumerator(const v8::PropertyCallbackInfo& info) /* {{{ */ +void v8js_array_access_enumerator(const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -210,13 +210,13 @@ void php_v8js_array_access_enumerator(const v8::PropertyCallbackInfo& v8::Local php_object = self->GetHiddenValue(V8JS_SYM(PHPJS_OBJECT_KEY)); zval *object = reinterpret_cast(v8::External::Cast(*php_object)->Value()); - int length = php_v8js_array_access_get_count_result(object TSRMLS_CC); + int length = v8js_array_access_get_count_result(object TSRMLS_CC); v8::Local result = v8::Array::New(isolate, length); int i = 0; for(int j = 0; j < length; j ++) { - if(php_v8js_array_access_isset_p(object, j TSRMLS_CC)) { + if(v8js_array_access_isset_p(object, j TSRMLS_CC)) { result->Set(i ++, V8JS_INT(j)); } } @@ -228,17 +228,17 @@ void php_v8js_array_access_enumerator(const v8::PropertyCallbackInfo& -void php_v8js_array_access_named_getter(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ +void v8js_array_access_named_getter(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ { v8::String::Utf8Value cstr(property); const char *name = ToCString(cstr); if(strcmp(name, "length") == 0) { - php_v8js_array_access_length(property, info); + v8js_array_access_length(property, info); return; } - v8::Local ret_value = php_v8js_named_property_callback(property, info, V8JS_PROP_GETTER); + v8::Local ret_value = v8js_named_property_callback(property, info, V8JS_PROP_GETTER); if(ret_value.IsEmpty()) { v8::Isolate *isolate = info.GetIsolate(); diff --git a/v8js_array_access.h b/v8js_array_access.h index 58bd63e..f12051e 100644 --- a/v8js_array_access.h +++ b/v8js_array_access.h @@ -14,18 +14,18 @@ #define V8JS_ARRAY_ACCESS_H /* Indexed Property Handlers */ -void php_v8js_array_access_getter(uint32_t index, +void v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo& info); -void php_v8js_array_access_setter(uint32_t index, v8::Local value, +void v8js_array_access_setter(uint32_t index, v8::Local value, const v8::PropertyCallbackInfo& info); -void php_v8js_array_access_enumerator(const v8::PropertyCallbackInfo& info); -void php_v8js_array_access_deleter(uint32_t index, +void v8js_array_access_enumerator(const v8::PropertyCallbackInfo& info); +void v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo& info); -void php_v8js_array_access_query(uint32_t index, +void v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo& info); /* Named Property Handlers */ -void php_v8js_array_access_named_getter(v8::Local property, +void v8js_array_access_named_getter(v8::Local property, const v8::PropertyCallbackInfo &info); #endif /* V8JS_ARRAY_ACCESS_H */ diff --git a/v8js_class.cc b/v8js_class.cc index 71cdc76..ed5f02f 100644 --- a/v8js_class.cc +++ b/v8js_class.cc @@ -43,10 +43,18 @@ static zend_class_entry *php_ce_v8js; static zend_object_handlers v8js_object_handlers; /* }}} */ +typedef struct _v8js_script { + char *name; + v8::Isolate *isolate; + v8::Persistent> *script; +} v8js_script; + +static void v8js_script_free(v8js_script *res, bool dispose_persistent); + int le_v8js_script; /* {{{ Extension container */ -struct php_v8js_jsext { +struct v8js_jsext { zend_bool auto_enable; HashTable *deps_ht; const char **deps; @@ -61,7 +69,7 @@ static v8js_ctx *v8js_debug_context; static int v8js_debug_auto_break_mode; #endif -static void php_v8js_free_storage(void *object TSRMLS_DC) /* {{{ */ +static void v8js_free_storage(void *object TSRMLS_DC) /* {{{ */ { v8js_ctx *c = (v8js_ctx *) object; @@ -161,7 +169,7 @@ static void php_v8js_free_storage(void *object TSRMLS_DC) /* {{{ */ } /* }}} */ -static zend_object_value php_v8js_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ +static zend_object_value v8js_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ { zend_object_value retval; v8js_ctx *c; @@ -194,14 +202,14 @@ static zend_object_value php_v8js_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */ new(&c->v8js_v8objects) std::list(); - retval.handle = zend_objects_store_put(c, NULL, (zend_objects_free_object_storage_t) php_v8js_free_storage, NULL TSRMLS_CC); + retval.handle = zend_objects_store_put(c, NULL, (zend_objects_free_object_storage_t) v8js_free_storage, NULL TSRMLS_CC); retval.handlers = &v8js_object_handlers; return retval; } /* }}} */ -static void _php_v8js_free_ext_strarr(const char **arr, int count) /* {{{ */ +static void v8js_free_ext_strarr(const char **arr, int count) /* {{{ */ { int i; @@ -216,21 +224,21 @@ static void _php_v8js_free_ext_strarr(const char **arr, int count) /* {{{ */ } /* }}} */ -static void php_v8js_jsext_dtor(php_v8js_jsext *jsext) /* {{{ */ +static void v8js_jsext_dtor(v8js_jsext *jsext) /* {{{ */ { if (jsext->deps_ht) { zend_hash_destroy(jsext->deps_ht); free(jsext->deps_ht); } if (jsext->deps) { - _php_v8js_free_ext_strarr(jsext->deps, jsext->deps_count); + v8js_free_ext_strarr(jsext->deps, jsext->deps_count); } free(jsext->name); free(jsext->source); } /* }}} */ -static int _php_v8js_create_ext_strarr(const char ***retval, int count, HashTable *ht) /* {{{ */ +static int v8js_create_ext_strarr(const char ***retval, int count, HashTable *ht) /* {{{ */ { const char **exts = NULL; HashPosition pos; @@ -243,7 +251,7 @@ static int _php_v8js_create_ext_strarr(const char ***retval, int count, HashTabl if (Z_TYPE_PP(tmp) == IS_STRING) { exts[i++] = zend_strndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); } else { - _php_v8js_free_ext_strarr(exts, i); + v8js_free_ext_strarr(exts, i); return FAILURE; } zend_hash_move_forward_ex(ht, &pos); @@ -254,7 +262,7 @@ static int _php_v8js_create_ext_strarr(const char ***retval, int count, HashTabl } /* }}} */ -static void php_v8js_fatal_error_handler(const char *location, const char *message) /* {{{ */ +static void v8js_fatal_error_handler(const char *location, const char *message) /* {{{ */ { v8::Isolate *isolate = v8::Isolate::GetCurrent(); if (isolate) { @@ -332,7 +340,7 @@ static PHP_METHOD(V8Js, __construct) if (exts_arr) { exts_count = zend_hash_num_elements(Z_ARRVAL_P(exts_arr)); - if (_php_v8js_create_ext_strarr(&exts, exts_count, Z_ARRVAL_P(exts_arr)) == FAILURE) { + if (v8js_create_ext_strarr(&exts, exts_count, Z_ARRVAL_P(exts_arr)) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid extensions array passed"); return; } @@ -351,7 +359,7 @@ static PHP_METHOD(V8Js, __construct) /* Redirect fatal errors to PHP error handler */ // This needs to be done within the context isolate - v8::V8::SetFatalErrorHandler(php_v8js_fatal_error_handler); + v8::V8::SetFatalErrorHandler(v8js_fatal_error_handler); /* Create global template for global object */ // Now we are using multiple isolates this needs to be created for every context @@ -362,7 +370,7 @@ static PHP_METHOD(V8Js, __construct) c->global_template.Reset(isolate, tpl); /* Register builtin methods */ - php_v8js_register_methods(tpl->InstanceTemplate(), c); + v8js_register_methods(tpl->InstanceTemplate(), c); /* Create context */ v8::Local context = v8::Context::New(isolate, &extension_conf, tpl->InstanceTemplate()); @@ -370,7 +378,7 @@ static PHP_METHOD(V8Js, __construct) c->context.Reset(isolate, context); if (exts) { - _php_v8js_free_ext_strarr(exts, exts_count); + v8js_free_ext_strarr(exts, exts_count); } /* If extensions have errors, context will be empty. (NOTE: This is V8 stuff, they expect the passed sources to compile :) */ @@ -400,7 +408,7 @@ static PHP_METHOD(V8Js, __construct) /* Register Get accessor for passed variables */ if (vars_arr && zend_hash_num_elements(Z_ARRVAL_P(vars_arr)) > 0) { - php_v8js_register_accessors(&c->accessor_list, php_obj_t, vars_arr, isolate TSRMLS_CC); + v8js_register_accessors(&c->accessor_list, php_obj_t, vars_arr, isolate TSRMLS_CC); } /* Set name for the PHP JS object */ @@ -461,7 +469,7 @@ PHP_METHOD(V8Js, __wakeup) } /* }}} */ -static void php_v8js_compile_script(zval *this_ptr, const char *str, int str_len, const char *identifier, int identifier_len, v8js_script **ret TSRMLS_DC) +static void v8js_compile_script(zval *this_ptr, const char *str, int str_len, const char *identifier, int identifier_len, v8js_script **ret TSRMLS_DC) { v8js_script *res = NULL; @@ -479,7 +487,7 @@ static void php_v8js_compile_script(zval *this_ptr, const char *str, int str_len /* Compile errors? */ if (script.IsEmpty()) { - php_v8js_throw_script_exception(&try_catch TSRMLS_CC); + v8js_throw_script_exception(&try_catch TSRMLS_CC); return; } res = (v8js_script *)emalloc(sizeof(v8js_script)); @@ -492,7 +500,7 @@ static void php_v8js_compile_script(zval *this_ptr, const char *str, int str_len return; } -static void php_v8js_execute_script(zval *this_ptr, v8js_script *res, long flags, long time_limit, long memory_limit, zval **return_value TSRMLS_DC) +static void v8js_execute_script(zval *this_ptr, v8js_script *res, long flags, long time_limit, long memory_limit, zval **return_value TSRMLS_DC) { v8js_ctx *c = (v8js_ctx *) zend_object_store_get_object(getThis() TSRMLS_CC); @@ -531,11 +539,11 @@ static PHP_METHOD(V8Js, executeString) return; } - php_v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res TSRMLS_CC); + v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res TSRMLS_CC); if (!res) { RETURN_FALSE; } - php_v8js_execute_script(getThis(), res, flags, time_limit, memory_limit, &return_value TSRMLS_CC); + v8js_execute_script(getThis(), res, flags, time_limit, memory_limit, &return_value TSRMLS_CC); v8js_script_free(res, true); efree(res); } @@ -554,7 +562,7 @@ static PHP_METHOD(V8Js, compileString) return; } - php_v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res TSRMLS_CC); + v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res TSRMLS_CC); if (res) { ZEND_REGISTER_RESOURCE(return_value, res, le_v8js_script); } @@ -578,7 +586,7 @@ static PHP_METHOD(V8Js, executeScript) ZEND_FETCH_RESOURCE(res, v8js_script*, &zscript, -1, PHP_V8JS_SCRIPT_RES_NAME, le_v8js_script); ZEND_VERIFY_RESOURCE(res); - php_v8js_execute_script(getThis(), res, flags, time_limit, memory_limit, &return_value TSRMLS_CC); + v8js_execute_script(getThis(), res, flags, time_limit, memory_limit, &return_value TSRMLS_CC); } /* }}} */ @@ -597,7 +605,7 @@ static PHP_METHOD(V8Js, checkString) return; } - php_v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res TSRMLS_CC); + v8js_compile_script(getThis(), str, str_len, identifier, identifier_len, &res TSRMLS_CC); if (!res) { RETURN_FALSE; } @@ -798,7 +806,7 @@ static PHP_METHOD(V8Js, setMemoryLimit) } /* }}} */ -static void php_v8js_persistent_zval_ctor(zval **p) /* {{{ */ +static void v8js_persistent_zval_ctor(zval **p) /* {{{ */ { zval *orig_ptr = *p; *p = (zval *) malloc(sizeof(zval)); @@ -814,7 +822,7 @@ static void php_v8js_persistent_zval_ctor(zval **p) /* {{{ */ } /* }}} */ -static void php_v8js_persistent_zval_dtor(zval **p) /* {{{ */ +static void v8js_persistent_zval_dtor(zval **p) /* {{{ */ { switch (Z_TYPE_P(*p)) { case IS_STRING: @@ -849,25 +857,25 @@ static void v8js_script_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ } /* }}} */ -static int php_v8js_register_extension(char *name, uint name_len, char *source, uint source_len, zval *deps_arr, zend_bool auto_enable TSRMLS_DC) /* {{{ */ +static int v8js_register_extension(char *name, uint name_len, char *source, uint source_len, zval *deps_arr, zend_bool auto_enable TSRMLS_DC) /* {{{ */ { - php_v8js_jsext *jsext = NULL; + v8js_jsext *jsext = NULL; if (!V8JSG(extensions)) { V8JSG(extensions) = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init(V8JSG(extensions), 1, NULL, (dtor_func_t) php_v8js_jsext_dtor, 1); + zend_hash_init(V8JSG(extensions), 1, NULL, (dtor_func_t) v8js_jsext_dtor, 1); } else if (zend_hash_exists(V8JSG(extensions), name, name_len + 1)) { return FAILURE; } - jsext = (php_v8js_jsext *) calloc(1, sizeof(php_v8js_jsext)); + jsext = (v8js_jsext *) calloc(1, sizeof(v8js_jsext)); if (deps_arr) { jsext->deps_count = zend_hash_num_elements(Z_ARRVAL_P(deps_arr)); - if (_php_v8js_create_ext_strarr(&jsext->deps, jsext->deps_count, Z_ARRVAL_P(deps_arr)) == FAILURE) { + if (v8js_create_ext_strarr(&jsext->deps, jsext->deps_count, Z_ARRVAL_P(deps_arr)) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid dependency array passed"); - php_v8js_jsext_dtor(jsext); + v8js_jsext_dtor(jsext); free(jsext); return FAILURE; } @@ -879,12 +887,12 @@ static int php_v8js_register_extension(char *name, uint name_len, char *source, if (jsext->deps) { jsext->deps_ht = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init(jsext->deps_ht, jsext->deps_count, NULL, (dtor_func_t) php_v8js_persistent_zval_dtor, 1); - zend_hash_copy(jsext->deps_ht, Z_ARRVAL_P(deps_arr), (copy_ctor_func_t) php_v8js_persistent_zval_ctor, NULL, sizeof(zval *)); + zend_hash_init(jsext->deps_ht, jsext->deps_count, NULL, (dtor_func_t) v8js_persistent_zval_dtor, 1); + zend_hash_copy(jsext->deps_ht, Z_ARRVAL_P(deps_arr), (copy_ctor_func_t) v8js_persistent_zval_ctor, NULL, sizeof(zval *)); } - if (zend_hash_add(V8JSG(extensions), name, name_len + 1, jsext, sizeof(php_v8js_jsext), NULL) == FAILURE) { - php_v8js_jsext_dtor(jsext); + if (zend_hash_add(V8JSG(extensions), name, name_len + 1, jsext, sizeof(v8js_jsext), NULL) == FAILURE) { + v8js_jsext_dtor(jsext); free(jsext); return FAILURE; } @@ -916,7 +924,7 @@ static PHP_METHOD(V8Js, registerExtension) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Extension name cannot be empty"); } else if (!script_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Script cannot be empty"); - } else if (php_v8js_register_extension(ext_name, ext_name_len, script, script_len, deps_arr, auto_enable TSRMLS_CC) == SUCCESS) { + } else if (v8js_register_extension(ext_name, ext_name_len, script, script_len, deps_arr, auto_enable TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; @@ -929,7 +937,7 @@ static PHP_METHOD(V8Js, registerExtension) */ static PHP_METHOD(V8Js, getExtensions) { - php_v8js_jsext *jsext; + v8js_jsext *jsext; zval *ext, *deps_arr; HashPosition pos; ulong index; @@ -1067,7 +1075,7 @@ static const zend_function_entry v8js_methods[] = { /* {{{ */ /* V8Js object handlers */ -static void php_v8js_write_property(zval *object, zval *member, zval *value ZEND_HASH_KEY_DC TSRMLS_DC) /* {{{ */ +static void v8js_write_property(zval *object, zval *member, zval *value ZEND_HASH_KEY_DC TSRMLS_DC) /* {{{ */ { V8JS_BEGIN_CTX(c, object) @@ -1087,7 +1095,7 @@ static void php_v8js_write_property(zval *object, zval *member, zval *value ZEND } /* }}} */ -static void php_v8js_unset_property(zval *object, zval *member ZEND_HASH_KEY_DC TSRMLS_DC) /* {{{ */ +static void v8js_unset_property(zval *object, zval *member ZEND_HASH_KEY_DC TSRMLS_DC) /* {{{ */ { V8JS_BEGIN_CTX(c, object) @@ -1110,13 +1118,13 @@ PHP_MINIT_FUNCTION(v8js_class) /* {{{ */ /* V8Js Class */ INIT_CLASS_ENTRY(ce, "V8Js", v8js_methods); php_ce_v8js = zend_register_internal_class(&ce TSRMLS_CC); - php_ce_v8js->create_object = php_v8js_new; + php_ce_v8js->create_object = v8js_new; /* V8Js handlers */ memcpy(&v8js_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); v8js_object_handlers.clone_obj = NULL; - v8js_object_handlers.write_property = php_v8js_write_property; - v8js_object_handlers.unset_property = php_v8js_unset_property; + v8js_object_handlers.write_property = v8js_write_property; + v8js_object_handlers.unset_property = v8js_unset_property; /* V8Js Class Constants */ zend_declare_class_constant_string(php_ce_v8js, ZEND_STRL("V8_VERSION"), PHP_V8_VERSION TSRMLS_CC); diff --git a/v8js_commonjs.cc b/v8js_commonjs.cc index a7291b6..b737051 100644 --- a/v8js_commonjs.cc +++ b/v8js_commonjs.cc @@ -22,7 +22,7 @@ extern "C" { #include "php_v8js_macros.h" -void php_v8js_commonjs_split_terms(char *identifier, std::vector &terms) +void v8js_commonjs_split_terms(char *identifier, std::vector &terms) { char *term = (char *)malloc(PATH_MAX), *ptr = term; @@ -58,14 +58,14 @@ void php_v8js_commonjs_split_terms(char *identifier, std::vector &terms) } } -void php_v8js_commonjs_normalise_identifier(char *base, char *identifier, char *normalised_path, char *module_name) +void v8js_commonjs_normalise_identifier(char *base, char *identifier, char *normalised_path, char *module_name) { std::vector id_terms, terms; - php_v8js_commonjs_split_terms(identifier, id_terms); + v8js_commonjs_split_terms(identifier, id_terms); // If we have a relative module identifier then include the base terms if (!strcmp(id_terms.front(), ".") || !strcmp(id_terms.front(), "..")) { - php_v8js_commonjs_split_terms(base, terms); + v8js_commonjs_split_terms(base, terms); } terms.insert(terms.end(), id_terms.begin(), id_terms.end()); diff --git a/v8js_convert.cc b/v8js_convert.cc index 38c649c..e9caf54 100644 --- a/v8js_convert.cc +++ b/v8js_convert.cc @@ -31,7 +31,7 @@ extern "C" { #include #include -static int _php_v8js_is_assoc_array(HashTable *myht TSRMLS_DC) /* {{{ */ +static int v8js_is_assoc_array(HashTable *myht TSRMLS_DC) /* {{{ */ { int i; char *key; @@ -54,14 +54,14 @@ static int _php_v8js_is_assoc_array(HashTable *myht TSRMLS_DC) /* {{{ */ /* }}} */ -static v8::Handle php_v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ +static v8::Handle v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ { HashTable *myht = HASH_OF(value); int i = myht ? zend_hash_num_elements(myht) : 0; /* Return object if dealing with assoc array */ - if (i > 0 && _php_v8js_is_assoc_array(myht TSRMLS_CC)) { - return php_v8js_hash_to_jsobj(value, isolate TSRMLS_CC); + if (i > 0 && v8js_is_assoc_array(myht TSRMLS_CC)) { + return v8js_hash_to_jsobj(value, isolate TSRMLS_CC); } v8::Local newarr; @@ -110,7 +110,7 @@ v8::Handle zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC) switch (Z_TYPE_P(value)) { case IS_ARRAY: - jsValue = php_v8js_hash_to_jsarr(value, isolate TSRMLS_CC); + jsValue = v8js_hash_to_jsarr(value, isolate TSRMLS_CC); break; case IS_OBJECT: @@ -126,9 +126,9 @@ v8::Handle zval_to_v8js(zval *value, v8::Isolate *isolate TSRMLS_DC) else jsValue = V8JS_NULL; } else - jsValue = php_v8js_hash_to_jsobj(value, isolate TSRMLS_CC); + jsValue = v8js_hash_to_jsobj(value, isolate TSRMLS_CC); } else - jsValue = php_v8js_hash_to_jsobj(value, isolate TSRMLS_CC); + jsValue = v8js_hash_to_jsobj(value, isolate TSRMLS_CC); break; case IS_STRING: diff --git a/v8js_exceptions.cc b/v8js_exceptions.cc index a2b6c00..e2ecc71 100644 --- a/v8js_exceptions.cc +++ b/v8js_exceptions.cc @@ -38,7 +38,7 @@ zend_class_entry *php_ce_v8js_memory_limit_exception; /* {{{ Class: V8JsScriptException */ -void php_v8js_create_script_exception(zval *return_value, v8::TryCatch *try_catch TSRMLS_DC) /* {{{ */ +void v8js_create_script_exception(zval *return_value, v8::TryCatch *try_catch TSRMLS_DC) /* {{{ */ { v8::String::Utf8Value exception(try_catch->Exception()); const char *exception_string = ToCString(exception); @@ -89,7 +89,7 @@ void php_v8js_create_script_exception(zval *return_value, v8::TryCatch *try_catc } /* }}} */ -void php_v8js_throw_script_exception(v8::TryCatch *try_catch TSRMLS_DC) /* {{{ */ +void v8js_throw_script_exception(v8::TryCatch *try_catch TSRMLS_DC) /* {{{ */ { v8::String::Utf8Value exception(try_catch->Exception()); const char *exception_string = ToCString(exception); @@ -99,7 +99,7 @@ void php_v8js_throw_script_exception(v8::TryCatch *try_catch TSRMLS_DC) /* {{{ * zend_throw_exception(php_ce_v8js_script_exception, (char *) exception_string, 0 TSRMLS_CC); } else { MAKE_STD_ZVAL(zexception); - php_v8js_create_script_exception(zexception, try_catch TSRMLS_CC); + v8js_create_script_exception(zexception, try_catch TSRMLS_CC); zend_throw_exception_object(zexception TSRMLS_CC); } } diff --git a/v8js_exceptions.h b/v8js_exceptions.h index e4291b4..e1ca0b7 100644 --- a/v8js_exceptions.h +++ b/v8js_exceptions.h @@ -19,8 +19,8 @@ extern zend_class_entry *php_ce_v8js_script_exception; extern zend_class_entry *php_ce_v8js_time_limit_exception; extern zend_class_entry *php_ce_v8js_memory_limit_exception; -void php_v8js_create_script_exception(zval *return_value, v8::TryCatch *try_catch TSRMLS_DC); -void php_v8js_throw_script_exception(v8::TryCatch *try_catch TSRMLS_DC); +void v8js_create_script_exception(zval *return_value, v8::TryCatch *try_catch TSRMLS_DC); +void v8js_throw_script_exception(v8::TryCatch *try_catch TSRMLS_DC); PHP_MINIT_FUNCTION(v8js_exceptions); diff --git a/v8js_methods.cc b/v8js_methods.cc index 373b492..3535cd2 100644 --- a/v8js_methods.cc +++ b/v8js_methods.cc @@ -22,7 +22,7 @@ extern "C" { } /* Forward declarations */ -void php_v8js_commonjs_normalise_identifier(char *base, char *identifier, char *normalised_path, char *module_name); +void v8js_commonjs_normalise_identifier(char *base, char *identifier, char *normalised_path, char *module_name); /* global.exit - terminate execution */ V8JS_METHOD(exit) /* {{{ */ @@ -54,7 +54,7 @@ V8JS_METHOD(print) /* {{{ */ } /* }}} */ -static void _php_v8js_dumper(v8::Isolate *isolate, v8::Local var, int level TSRMLS_DC) /* {{{ */ +static void v8js_dumper(v8::Isolate *isolate, v8::Local var, int level TSRMLS_DC) /* {{{ */ { if (level > 1) { php_printf("%*c", (level - 1) * 2, ' '); @@ -124,7 +124,7 @@ static void _php_v8js_dumper(v8::Isolate *isolate, v8::Local var, int for (unsigned i = 0; i < length; i++) { php_printf("%*c[%d] =>\n", level * 2, ' ', i); - _php_v8js_dumper(isolate, array->Get(i), level + 1 TSRMLS_CC); + v8js_dumper(isolate, array->Get(i), level + 1 TSRMLS_CC); } if (level > 1) { @@ -161,7 +161,7 @@ static void _php_v8js_dumper(v8::Isolate *isolate, v8::Local var, int v8::Local key = keys->Get(i)->ToString(); v8::String::Utf8Value kname(key); php_printf("%*c[\"%s\"] =>\n", level * 2, ' ', ToCString(kname)); - _php_v8js_dumper(isolate, object->Get(key), level + 1 TSRMLS_CC); + v8js_dumper(isolate, object->Get(key), level + 1 TSRMLS_CC); } } @@ -185,7 +185,7 @@ V8JS_METHOD(var_dump) /* {{{ */ V8JS_TSRMLS_FETCH(); for (int i = 0; i < info.Length(); i++) { - _php_v8js_dumper(isolate, info[i], 1 TSRMLS_CC); + v8js_dumper(isolate, info[i], 1 TSRMLS_CC); } info.GetReturnValue().Set(V8JS_NULL); @@ -214,7 +214,7 @@ V8JS_METHOD(require) char *normalised_path = (char *)emalloc(PATH_MAX); char *module_name = (char *)emalloc(PATH_MAX); - php_v8js_commonjs_normalise_identifier(c->modules_base.back(), module_id, normalised_path, module_name); + v8js_commonjs_normalise_identifier(c->modules_base.back(), module_id, normalised_path, module_name); efree(module_id); char *normalised_module_id = (char *)emalloc(strlen(normalised_path)+1+strlen(module_name)+1); @@ -389,7 +389,7 @@ V8JS_METHOD(require) efree(normalised_module_id); } -void php_v8js_register_methods(v8::Handle global, v8js_ctx *c) /* {{{ */ +void v8js_register_methods(v8::Handle global, v8js_ctx *c) /* {{{ */ { v8::Isolate *isolate = c->isolate; global->Set(V8JS_SYM("exit"), v8::FunctionTemplate::New(isolate, V8JS_MN(exit)), v8::ReadOnly); diff --git a/v8js_object_export.cc b/v8js_object_export.cc index c4e8df9..6581061 100644 --- a/v8js_object_export.cc +++ b/v8js_object_export.cc @@ -28,10 +28,10 @@ extern "C" { #include "v8js_object_export.h" #include "v8js_v8object_class.h" -static void php_v8js_weak_object_callback(const v8::WeakCallbackData &data); +static void v8js_weak_object_callback(const v8::WeakCallbackData &data); /* Callback for PHP methods and functions */ -static void php_v8js_call_php_func(zval *value, zend_class_entry *ce, zend_function *method_ptr, v8::Isolate *isolate, const v8::FunctionCallbackInfo& info TSRMLS_DC) /* {{{ */ +static void v8js_call_php_func(zval *value, zend_class_entry *ce, zend_function *method_ptr, v8::Isolate *isolate, const v8::FunctionCallbackInfo& info TSRMLS_DC) /* {{{ */ { v8::Handle return_value; zend_fcall_info fci; @@ -161,7 +161,7 @@ failure: /* }}} */ /* Callback for PHP methods and functions */ -static void php_v8js_php_callback(const v8::FunctionCallbackInfo& info) /* {{{ */ +static void v8js_php_callback(const v8::FunctionCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -178,11 +178,11 @@ static void php_v8js_php_callback(const v8::FunctionCallbackInfo& inf method_ptr = zend_get_closure_invoke_method(value TSRMLS_CC); } - return php_v8js_call_php_func(value, ce, method_ptr, isolate, info TSRMLS_CC); + return v8js_call_php_func(value, ce, method_ptr, isolate, info TSRMLS_CC); } /* Callback for PHP constructor calls */ -static void php_v8js_construct_callback(const v8::FunctionCallbackInfo& info) /* {{{ */ +static void v8js_construct_callback(const v8::FunctionCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); info.GetReturnValue().Set(V8JS_UNDEFINED); @@ -203,7 +203,7 @@ static void php_v8js_construct_callback(const v8::FunctionCallbackInfoGetData(0); if (info[0]->IsExternal()) { - // Object created by v8js in php_v8js_hash_to_jsobj, PHP object passed as v8::External. + // Object created by v8js in v8js_hash_to_jsobj, PHP object passed as v8::External. php_object = v8::Local::Cast(info[0]); value = reinterpret_cast(php_object->Value()); @@ -235,7 +235,7 @@ static void php_v8js_construct_callback(const v8::FunctionCallbackInfoweak_objects[value].Reset(isolate, newobj); - ctx->weak_objects[value].SetWeak(value, php_v8js_weak_object_callback); + ctx->weak_objects[value].SetWeak(value, v8js_weak_object_callback); // Just tell v8 that we're allocating some external memory // (for the moment we just always tell 1k instead of trying to find out actual values) @@ -256,7 +256,7 @@ static void php_v8js_construct_callback(const v8::FunctionCallbackInfo &data) { +static void v8js_weak_object_callback(const v8::WeakCallbackData &data) { v8::Isolate *isolate = data.GetIsolate(); zval *value = data.GetParameter(); @@ -270,7 +270,7 @@ static void php_v8js_weak_object_callback(const v8::WeakCallbackDataAdjustAmountOfExternalAllocatedMemory(-1024); } -static void php_v8js_weak_closure_callback(const v8::WeakCallbackData &data) { +static void v8js_weak_closure_callback(const v8::WeakCallbackData &data) { v8::Isolate *isolate = data.GetIsolate(); v8js_tmpl_t *persist_tpl_ = data.GetParameter(); @@ -293,10 +293,10 @@ static void php_v8js_weak_closure_callback(const v8::WeakCallbackDataGetFunction() + v8::FunctionTemplate::New((isolate), v8js_php_callback, v8::External::New((isolate), mptr), v8::Signature::New((isolate), tmpl))->GetFunction() -static void php_v8js_named_property_enumerator(const v8::PropertyCallbackInfo &info) /* {{{ */ +static void v8js_named_property_enumerator(const v8::PropertyCallbackInfo &info) /* {{{ */ { // note: 'special' properties like 'constructor' are not enumerated. v8::Isolate *isolate = info.GetIsolate(); @@ -393,7 +393,7 @@ static void php_v8js_named_property_enumerator(const v8::PropertyCallbackInfo& info) /* {{{ */ +static void v8js_invoke_callback(const v8::FunctionCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -432,7 +432,7 @@ static void php_v8js_invoke_callback(const v8::FunctionCallbackInfo& // this is a magic '__call' implementation for PHP classes which don't actually // have a '__call' magic function. This way we can always force a method // call (as opposed to a property get) from JavaScript using __call. -static void php_v8js_fake_call_impl(const v8::FunctionCallbackInfo& info) /* {{{ */ +static void v8js_fake_call_impl(const v8::FunctionCallbackInfo& info) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::Local self = info.Holder(); @@ -500,7 +500,7 @@ static void php_v8js_fake_call_impl(const v8::FunctionCallbackInfo& i v8::Local tmpl = v8::Local::New (isolate, *reinterpret_cast(self->GetAlignedPointerFromInternalField(0))); - // use php_v8js_php_callback to actually execute the method + // use v8js_php_callback to actually execute the method v8::Local cb = PHP_V8JS_CALLBACK(isolate, method_ptr, tmpl); uint32_t i, argc = args->Length(); v8::Local *argv = static_cast *>(alloca(sizeof(v8::Local) * argc)); @@ -515,7 +515,7 @@ static void php_v8js_fake_call_impl(const v8::FunctionCallbackInfo& i /* This method handles named property and method get/set/query/delete. */ template -inline v8::Local php_v8js_named_property_callback(v8::Local property, const v8::PropertyCallbackInfo &info, property_op_t callback_type, v8::Local set_value) /* {{{ */ +inline v8::Local v8js_named_property_callback(v8::Local property, const v8::PropertyCallbackInfo &info, property_op_t callback_type, v8::Local set_value) /* {{{ */ { v8::Isolate *isolate = info.GetIsolate(); v8::String::Utf8Value cstr(property); @@ -570,7 +570,7 @@ inline v8::Local php_v8js_named_property_callback(v8::Local cb = v8::FunctionTemplate::New(isolate, - php_v8js_fake_call_impl, V8JS_NULL, + v8js_fake_call_impl, V8JS_NULL, v8::Signature::New(isolate, tmpl))->GetFunction(); cb->SetName(property); ret_value = cb; @@ -735,30 +735,30 @@ inline v8::Local php_v8js_named_property_callback(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ +static void v8js_named_property_getter(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ { - info.GetReturnValue().Set(php_v8js_named_property_callback(property, info, V8JS_PROP_GETTER)); + info.GetReturnValue().Set(v8js_named_property_callback(property, info, V8JS_PROP_GETTER)); } /* }}} */ -static void php_v8js_named_property_setter(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo &info) /* {{{ */ +static void v8js_named_property_setter(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo &info) /* {{{ */ { - info.GetReturnValue().Set(php_v8js_named_property_callback(property, info, V8JS_PROP_SETTER, value)); + info.GetReturnValue().Set(v8js_named_property_callback(property, info, V8JS_PROP_SETTER, value)); } /* }}} */ -static void php_v8js_named_property_query(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ +static void v8js_named_property_query(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ { - v8::Local r = php_v8js_named_property_callback(property, info, V8JS_PROP_QUERY); + v8::Local r = v8js_named_property_callback(property, info, V8JS_PROP_QUERY); if (!r.IsEmpty()) { info.GetReturnValue().Set(r->ToInteger()); } } /* }}} */ -static void php_v8js_named_property_deleter(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ +static void v8js_named_property_deleter(v8::Local property, const v8::PropertyCallbackInfo &info) /* {{{ */ { - v8::Local r = php_v8js_named_property_callback(property, info, V8JS_PROP_DELETER); + v8::Local r = v8js_named_property_callback(property, info, V8JS_PROP_DELETER); if (!r.IsEmpty()) { info.GetReturnValue().Set(r->ToBoolean()); } @@ -767,7 +767,7 @@ static void php_v8js_named_property_deleter(v8::Local property, cons -static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_class_entry *ce, zval *value TSRMLS_DC) /* {{{ */ +static v8::Handle v8js_wrap_object(v8::Isolate *isolate, zend_class_entry *ce, zval *value TSRMLS_DC) /* {{{ */ { v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0); v8::Local new_tpl; @@ -787,8 +787,8 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl if (ce == zend_ce_closure) { /* Got a closure, mustn't cache ... */ persist_tpl_ = new v8js_tmpl_t(isolate, new_tpl); - /* We'll free persist_tpl_ via php_v8js_weak_closure_callback, below */ - new_tpl->InstanceTemplate()->SetCallAsFunctionHandler(php_v8js_php_callback); + /* We'll free persist_tpl_ via v8js_weak_closure_callback, below */ + new_tpl->InstanceTemplate()->SetCallAsFunctionHandler(v8js_php_callback); } else { /* Add new v8::FunctionTemplate to tpl_map, as long as it is not a closure. */ persist_tpl_ = &ctx->template_cache[ce->name]; @@ -796,8 +796,8 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl /* We'll free persist_tpl_ when template_cache is destroyed */ v8::Local inst_tpl = new_tpl->InstanceTemplate(); - v8::NamedPropertyGetterCallback getter = php_v8js_named_property_getter; - v8::NamedPropertyEnumeratorCallback enumerator = php_v8js_named_property_enumerator; + v8::NamedPropertyGetterCallback getter = v8js_named_property_getter; + v8::NamedPropertyEnumeratorCallback enumerator = v8js_named_property_enumerator; /* Check for ArrayAccess object */ if (V8JSG(use_array_access) && ce) { @@ -814,16 +814,16 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl } if(has_array_access && has_countable) { - inst_tpl->SetIndexedPropertyHandler(php_v8js_array_access_getter, - php_v8js_array_access_setter, - php_v8js_array_access_query, - php_v8js_array_access_deleter, - php_v8js_array_access_enumerator); + inst_tpl->SetIndexedPropertyHandler(v8js_array_access_getter, + v8js_array_access_setter, + v8js_array_access_query, + v8js_array_access_deleter, + v8js_array_access_enumerator); /* Switch to special ArrayAccess getter, which falls back to - * php_v8js_named_property_getter, but possibly bridges the + * v8js_named_property_getter, but possibly bridges the * call to Array.prototype functions. */ - getter = php_v8js_array_access_named_getter; + getter = v8js_array_access_named_getter; /* Overwrite enumerator, since for(... in ...) loop should * not see the methods but iterate over the elements. */ @@ -835,9 +835,9 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl // Finish setup of new_tpl inst_tpl->SetNamedPropertyHandler (getter, /* getter */ - php_v8js_named_property_setter, /* setter */ - php_v8js_named_property_query, /* query */ - php_v8js_named_property_deleter, /* deleter */ + v8js_named_property_setter, /* setter */ + v8js_named_property_query, /* query */ + v8js_named_property_deleter, /* deleter */ enumerator, /* enumerator */ V8JS_NULL /* data */ ); @@ -847,13 +847,13 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl sizeof(ZEND_INVOKE_FUNC_NAME), (void**)&invoke_method_ptr) == SUCCESS && invoke_method_ptr->common.fn_flags & ZEND_ACC_PUBLIC) { - new_tpl->InstanceTemplate()->SetCallAsFunctionHandler(php_v8js_invoke_callback, PHP_V8JS_CALLBACK(isolate, invoke_method_ptr, new_tpl)); + new_tpl->InstanceTemplate()->SetCallAsFunctionHandler(v8js_invoke_callback, PHP_V8JS_CALLBACK(isolate, invoke_method_ptr, new_tpl)); } } v8::Local call_handler_data = v8::Array::New(isolate, 2); call_handler_data->Set(0, v8::External::New(isolate, persist_tpl_)); call_handler_data->Set(1, v8::External::New(isolate, ce)); - new_tpl->SetCallHandler(php_v8js_construct_callback, call_handler_data); + new_tpl->SetCallHandler(v8js_construct_callback, call_handler_data); } // Create v8 wrapper object @@ -863,7 +863,7 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl if (ce == zend_ce_closure) { // free uncached function template when object is freed ctx->weak_closures[persist_tpl_].Reset(isolate, newobj); - ctx->weak_closures[persist_tpl_].SetWeak(persist_tpl_, php_v8js_weak_closure_callback); + ctx->weak_closures[persist_tpl_].SetWeak(persist_tpl_, v8js_weak_closure_callback); } return newobj; @@ -871,7 +871,7 @@ static v8::Handle php_v8js_wrap_object(v8::Isolate *isolate, zend_cl /* }}} */ -static v8::Handle php_v8js_wrap_array_to_object(v8::Isolate *isolate, zval *value TSRMLS_DC) /* {{{ */ +static v8::Handle v8js_wrap_array_to_object(v8::Isolate *isolate, zval *value TSRMLS_DC) /* {{{ */ { int i; HashPosition pos; @@ -936,7 +936,7 @@ static v8::Handle php_v8js_wrap_array_to_object(v8::Isolate *isolate /* }}} */ -v8::Handle php_v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ +v8::Handle v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ { HashTable *myht; zend_class_entry *ce = NULL; @@ -967,12 +967,12 @@ v8::Handle php_v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate T /* If it's a PHP object, wrap it */ if (ce) { - return php_v8js_wrap_object(isolate, ce, value TSRMLS_CC); + return v8js_wrap_object(isolate, ce, value TSRMLS_CC); } /* Associative PHP arrays cannot be wrapped to JS arrays, convert them to * JS objects and attach all their array keys as properties. */ - return php_v8js_wrap_array_to_object(isolate, value TSRMLS_CC); + return v8js_wrap_array_to_object(isolate, value TSRMLS_CC); } /* }}} */ diff --git a/v8js_object_export.h b/v8js_object_export.h index 94b786e..72c48a7 100644 --- a/v8js_object_export.h +++ b/v8js_object_export.h @@ -14,7 +14,7 @@ #ifndef V8JS_OBJECT_EXPORT_H #define V8JS_OBJECT_EXPORT_H -v8::Handle php_v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRMLS_DC); +v8::Handle v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRMLS_DC); typedef enum { @@ -25,7 +25,7 @@ typedef enum { } property_op_t; template -v8::Local php_v8js_named_property_callback(v8::Local property, +v8::Local v8js_named_property_callback(v8::Local property, const v8::PropertyCallbackInfo &info, property_op_t callback_type, v8::Local set_value = v8::Local()); diff --git a/v8js_v8.cc b/v8js_v8.cc index 13060f3..df51244 100644 --- a/v8js_v8.cc +++ b/v8js_v8.cc @@ -133,7 +133,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value, efree(timer_ctx); - /* Check for fatal error marker possibly set by php_v8js_error_handler; just + /* Check for fatal error marker possibly set by v8js_error_handler; just * rethrow the error since we're now out of V8. */ if(V8JSG(fatal_error_abort)) { zend_bailout(); @@ -174,14 +174,14 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value, /* Report immediately if report_uncaught is true */ if (c->report_uncaught) { - php_v8js_throw_script_exception(&try_catch TSRMLS_CC); + v8js_throw_script_exception(&try_catch TSRMLS_CC); return; } /* Exception thrown from JS, preserve it for future execution */ if (result.IsEmpty()) { MAKE_STD_ZVAL(c->pending_exception); - php_v8js_create_script_exception(c->pending_exception, &try_catch TSRMLS_CC); + v8js_create_script_exception(c->pending_exception, &try_catch TSRMLS_CC); return; } } diff --git a/v8js_variables.cc b/v8js_variables.cc index 134bb93..220d5d2 100644 --- a/v8js_variables.cc +++ b/v8js_variables.cc @@ -25,7 +25,7 @@ extern "C" { #include #include -static void php_v8js_fetch_php_variable(v8::Local name, const v8::PropertyCallbackInfo& info) /* {{{ */ +static void v8js_fetch_php_variable(v8::Local name, const v8::PropertyCallbackInfo& info) /* {{{ */ { v8::Handle data = v8::Handle::Cast(info.Data()); v8js_accessor_ctx *ctx = static_cast(data->Value()); @@ -50,7 +50,7 @@ void v8js_accessor_ctx_dtor(v8js_accessor_ctx *ctx TSRMLS_DC) /* {{{ */ } /* }}} */ -void php_v8js_register_accessors(std::vector *accessor_list, v8::Local php_obj_t, zval *array, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ +void v8js_register_accessors(std::vector *accessor_list, v8::Local php_obj_t, zval *array, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ { char *property_name; uint property_name_len; @@ -86,7 +86,7 @@ void php_v8js_register_accessors(std::vector *accessor_list, ctx->isolate = isolate; /* Set the variable fetch callback for given symbol on named property */ - php_obj->SetAccessor(V8JS_STRL(property_name, property_name_len - 1), php_v8js_fetch_php_variable, NULL, v8::External::New(isolate, ctx), v8::PROHIBITS_OVERWRITING, v8::ReadOnly, v8::AccessorSignature::New(isolate, php_obj_t)); + php_obj->SetAccessor(V8JS_STRL(property_name, property_name_len - 1), v8js_fetch_php_variable, NULL, v8::External::New(isolate, ctx), v8::PROHIBITS_OVERWRITING, v8::ReadOnly, v8::AccessorSignature::New(isolate, php_obj_t)); /* record the context so we can free it later */ accessor_list->push_back(ctx);