mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 14:01:53 +00:00
Merge pull request #297 from stesie/remove-tsrm-fluff
Remove TSRM fluff
This commit is contained in:
commit
880d0b2fef
@ -79,13 +79,13 @@ extern "C" {
|
||||
|
||||
|
||||
/* Convert zval into V8 value */
|
||||
v8::Handle<v8::Value> zval_to_v8js(zval *, v8::Isolate *);
|
||||
v8::Local<v8::Value> zval_to_v8js(zval *, v8::Isolate *);
|
||||
|
||||
/* Convert zend_long into V8 value */
|
||||
v8::Handle<v8::Value> zend_long_to_v8js(zend_long, v8::Isolate *);
|
||||
v8::Local<v8::Value> zend_long_to_v8js(zend_long, v8::Isolate *);
|
||||
|
||||
/* Convert V8 value into zval */
|
||||
int v8js_to_zval(v8::Handle<v8::Value>, zval *, int, v8::Isolate * TSRMLS_DC);
|
||||
int v8js_to_zval(v8::Local<v8::Value>, zval *, int, v8::Isolate *);
|
||||
|
||||
struct v8js_accessor_ctx
|
||||
{
|
||||
@ -93,10 +93,10 @@ struct v8js_accessor_ctx
|
||||
v8::Isolate *isolate;
|
||||
};
|
||||
|
||||
void v8js_accessor_ctx_dtor(v8js_accessor_ctx * TSRMLS_DC);
|
||||
void v8js_accessor_ctx_dtor(v8js_accessor_ctx *);
|
||||
|
||||
/* Register accessors into passed object */
|
||||
void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8::Local<v8::FunctionTemplate>, zval *, v8::Isolate * TSRMLS_DC);
|
||||
void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8::Local<v8::FunctionTemplate>, zval *, v8::Isolate *);
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
@ -159,7 +159,7 @@ struct _v8js_process_globals {
|
||||
extern struct _v8js_process_globals v8js_process_globals;
|
||||
|
||||
/* Register builtin methods into passed object */
|
||||
void v8js_register_methods(v8::Handle<v8::ObjectTemplate>, v8js_ctx *c);
|
||||
void v8js_register_methods(v8::Local<v8::ObjectTemplate>, v8js_ctx *c);
|
||||
|
||||
#endif /* PHP_V8JS_MACROS_H */
|
||||
|
||||
|
@ -29,7 +29,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
static zval v8js_array_access_dispatch(zend_object *object, const char *method_name, int param_count,
|
||||
uint32_t index, zval zvalue TSRMLS_DC) /* {{{ */
|
||||
uint32_t index, zval zvalue) /* {{{ */
|
||||
{
|
||||
zend_fcall_info fci;
|
||||
zval php_value;
|
||||
@ -52,7 +52,7 @@ static zval v8js_array_access_dispatch(zend_object *object, const char *method_n
|
||||
fci.object = object;
|
||||
fci.no_separation = 0;
|
||||
|
||||
zend_call_function(&fci, NULL TSRMLS_CC);
|
||||
zend_call_function(&fci, NULL);
|
||||
zval_dtor(&fci.function_name);
|
||||
return php_value;
|
||||
}
|
||||
@ -65,15 +65,13 @@ void v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo<v8:
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
zval zvalue;
|
||||
ZVAL_UNDEF(&zvalue);
|
||||
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetGet", 1, index, zvalue TSRMLS_CC);
|
||||
v8::Local<v8::Value> ret_value = zval_to_v8js(&php_value, isolate TSRMLS_CC);
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetGet", 1, index, zvalue);
|
||||
v8::Local<v8::Value> ret_value = zval_to_v8js(&php_value, isolate);
|
||||
zval_ptr_dtor(&php_value);
|
||||
|
||||
info.GetReturnValue().Set(ret_value);
|
||||
@ -86,19 +84,17 @@ void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
zval zvalue;
|
||||
ZVAL_UNDEF(&zvalue);
|
||||
|
||||
if (v8js_to_zval(value, &zvalue, 0, isolate TSRMLS_CC) != SUCCESS) {
|
||||
info.GetReturnValue().Set(v8::Handle<v8::Value>());
|
||||
if (v8js_to_zval(value, &zvalue, 0, isolate) != SUCCESS) {
|
||||
info.GetReturnValue().Set(v8::Local<v8::Value>());
|
||||
return;
|
||||
}
|
||||
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue TSRMLS_CC);
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue);
|
||||
zval_ptr_dtor(&php_value);
|
||||
|
||||
/* simply pass back the value to tell we intercepted the call
|
||||
@ -112,15 +108,15 @@ void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
|
||||
/* }}} */
|
||||
|
||||
|
||||
static int v8js_array_access_get_count_result(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
static int v8js_array_access_get_count_result(zend_object *object) /* {{{ */
|
||||
{
|
||||
zval zvalue;
|
||||
ZVAL_UNDEF(&zvalue);
|
||||
|
||||
zval php_value = v8js_array_access_dispatch(object, "count", 0, 0, zvalue TSRMLS_CC);
|
||||
zval php_value = v8js_array_access_dispatch(object, "count", 0, 0, zvalue);
|
||||
|
||||
if(Z_TYPE(php_value) != IS_LONG) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-numeric return value from count() method");
|
||||
php_error_docref(NULL, E_WARNING, "Non-numeric return value from count() method");
|
||||
zval_ptr_dtor(&php_value);
|
||||
return 0;
|
||||
}
|
||||
@ -137,15 +133,15 @@ static int v8js_array_access_get_count_result(zend_object *object TSRMLS_DC) /*
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static bool v8js_array_access_isset_p(zend_object *object, int index TSRMLS_DC) /* {{{ */
|
||||
static bool v8js_array_access_isset_p(zend_object *object, int index) /* {{{ */
|
||||
{
|
||||
zval zvalue;
|
||||
ZVAL_UNDEF(&zvalue);
|
||||
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetExists", 1, index, zvalue TSRMLS_CC);
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetExists", 1, index, zvalue);
|
||||
|
||||
if(Z_TYPE(php_value) != IS_TRUE && Z_TYPE(php_value) != IS_FALSE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-boolean return value from offsetExists() method");
|
||||
php_error_docref(NULL, E_WARNING, "Non-boolean return value from offsetExists() method");
|
||||
zval_ptr_dtor(&php_value);
|
||||
return false;
|
||||
}
|
||||
@ -160,11 +156,9 @@ static void v8js_array_access_length(v8::Local<v8::String> property, const v8::P
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
int length = v8js_array_access_get_count_result(object TSRMLS_CC);
|
||||
int length = v8js_array_access_get_count_result(object);
|
||||
info.GetReturnValue().Set(V8JS_INT(length));
|
||||
}
|
||||
/* }}} */
|
||||
@ -174,14 +168,12 @@ void v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo<v8
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
zval zvalue;
|
||||
ZVAL_UNDEF(&zvalue);
|
||||
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetUnset", 1, index, zvalue TSRMLS_CC);
|
||||
zval php_value = v8js_array_access_dispatch(object, "offsetUnset", 1, index, zvalue);
|
||||
zval_ptr_dtor(&php_value);
|
||||
|
||||
info.GetReturnValue().Set(V8JS_BOOL(true));
|
||||
@ -193,13 +185,11 @@ void v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo<v8::
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
/* If index is set, then return an integer encoding a v8::PropertyAttribute;
|
||||
* otherwise we're expected to return an empty handle. */
|
||||
if(v8js_array_access_isset_p(object, index TSRMLS_CC)) {
|
||||
if(v8js_array_access_isset_p(object, index)) {
|
||||
info.GetReturnValue().Set(V8JS_UINT(v8::PropertyAttribute::None));
|
||||
}
|
||||
}
|
||||
@ -211,17 +201,15 @@ void v8js_array_access_enumerator(const v8::PropertyCallbackInfo<v8::Array>& inf
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
int length = v8js_array_access_get_count_result(object TSRMLS_CC);
|
||||
int length = v8js_array_access_get_count_result(object);
|
||||
v8::Local<v8::Array> result = v8::Array::New(isolate, length);
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(int j = 0; j < length; j ++) {
|
||||
if(v8js_array_access_isset_p(object, j TSRMLS_CC)) {
|
||||
if(v8js_array_access_isset_p(object, j)) {
|
||||
result->Set(i ++, V8JS_INT(j));
|
||||
}
|
||||
}
|
||||
|
103
v8js_class.cc
103
v8js_class.cc
@ -82,11 +82,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
static void v8js_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
static void v8js_free_storage(zend_object *object) /* {{{ */
|
||||
{
|
||||
v8js_ctx *c = v8js_ctx_fetch_object(object);
|
||||
|
||||
zend_object_std_dtor(&c->std TSRMLS_CC);
|
||||
zend_object_std_dtor(&c->std);
|
||||
|
||||
zval_ptr_dtor(&c->pending_exception);
|
||||
zval_ptr_dtor(&c->module_normaliser);
|
||||
@ -134,7 +134,7 @@ static void v8js_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
/* Clear contexts */
|
||||
for (std::vector<v8js_accessor_ctx*>::iterator it = c->accessor_list.begin();
|
||||
it != c->accessor_list.end(); ++it) {
|
||||
v8js_accessor_ctx_dtor(*it TSRMLS_CC);
|
||||
v8js_accessor_ctx_dtor(*it);
|
||||
}
|
||||
c->accessor_list.~vector();
|
||||
|
||||
@ -204,16 +204,15 @@ static void v8js_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_object* v8js_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */
|
||||
static zend_object* v8js_new(zend_class_entry *ce) /* {{{ */
|
||||
{
|
||||
v8js_ctx *c;
|
||||
|
||||
c = (v8js_ctx *) ecalloc(1, sizeof(*c) + zend_object_properties_size(ce));
|
||||
zend_object_std_init(&c->std, ce TSRMLS_CC);
|
||||
zend_object_std_init(&c->std, ce);
|
||||
object_properties_init(&c->std, ce);
|
||||
|
||||
c->std.handlers = &v8js_object_handlers;
|
||||
TSRMLS_SET_CTX(c->zts_ctx);
|
||||
|
||||
new(&c->object_name) v8::Persistent<v8::String>();
|
||||
new(&c->context) v8::Persistent<v8::Context>();
|
||||
@ -340,12 +339,12 @@ static PHP_METHOD(V8Js, __construct)
|
||||
return;
|
||||
}
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Saabz", &object_name, &vars_arr, &exts_arr, &report_uncaught, &snapshot_blob) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|Saabz", &object_name, &vars_arr, &exts_arr, &report_uncaught, &snapshot_blob) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize V8 */
|
||||
v8js_v8_init(TSRMLS_C);
|
||||
v8js_v8_init();
|
||||
|
||||
/* Throw PHP exception if uncaught exceptions exist */
|
||||
c->report_uncaught = report_uncaught;
|
||||
@ -372,7 +371,7 @@ static PHP_METHOD(V8Js, __construct)
|
||||
c->snapshot_blob.raw_size = static_cast<int>(Z_STRLEN_P(snapshot_blob));
|
||||
c->create_params.snapshot_blob = &c->snapshot_blob;
|
||||
} else {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument snapshot_blob expected to be of string type");
|
||||
php_error_docref(NULL, E_WARNING, "Argument snapshot_blob expected to be of string type");
|
||||
}
|
||||
}
|
||||
|
||||
@ -462,7 +461,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) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Set name for the PHP JS object */
|
||||
@ -490,12 +489,12 @@ static PHP_METHOD(V8Js, __construct)
|
||||
V8JS_GLOBAL(isolate)->ForceSet(object_name_js, php_obj, v8::ReadOnly);
|
||||
|
||||
/* Export public property values */
|
||||
HashTable *properties = zend_std_get_properties(getThis() TSRMLS_CC);
|
||||
HashTable *properties = zend_std_get_properties(getThis());
|
||||
zval *value;
|
||||
zend_string *member;
|
||||
|
||||
ZEND_HASH_FOREACH_STR_KEY(properties, member) {
|
||||
zend_property_info *property_info = zend_get_property_info(c->std.ce, member, 1 TSRMLS_CC);
|
||||
zend_property_info *property_info = zend_get_property_info(c->std.ce, member, 1);
|
||||
if(property_info &&
|
||||
property_info != ZEND_WRONG_PROPERTY_INFO &&
|
||||
(property_info->flags & ZEND_ACC_PUBLIC)) {
|
||||
@ -510,7 +509,7 @@ static PHP_METHOD(V8Js, __construct)
|
||||
|
||||
/* Write value to PHP JS object */
|
||||
value = OBJ_PROP(Z_OBJ_P(getThis()), property_info->offset);
|
||||
php_obj->ForceSet(key, zval_to_v8js(value, isolate TSRMLS_CC), v8::ReadOnly);
|
||||
php_obj->ForceSet(key, zval_to_v8js(value, isolate), v8::ReadOnly);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
@ -595,7 +594,7 @@ static PHP_METHOD(V8Js, __construct)
|
||||
PHP_METHOD(V8Js, __sleep)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Js instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Js instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -605,12 +604,12 @@ PHP_METHOD(V8Js, __sleep)
|
||||
PHP_METHOD(V8Js, __wakeup)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Js instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Js instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void v8js_compile_script(zval *this_ptr, const zend_string *str, const zend_string *identifier, v8js_script **ret TSRMLS_DC)
|
||||
static void v8js_compile_script(zval *this_ptr, const zend_string *str, const zend_string *identifier, v8js_script **ret)
|
||||
{
|
||||
v8js_script *res = NULL;
|
||||
|
||||
@ -642,7 +641,7 @@ static void v8js_compile_script(zval *this_ptr, const zend_string *str, const ze
|
||||
|
||||
/* Compile errors? */
|
||||
if (script.IsEmpty()) {
|
||||
v8js_throw_script_exception(c->isolate, &try_catch TSRMLS_CC);
|
||||
v8js_throw_script_exception(c->isolate, &try_catch);
|
||||
return;
|
||||
}
|
||||
res = (v8js_script *)emalloc(sizeof(v8js_script));
|
||||
@ -655,7 +654,7 @@ static void v8js_compile_script(zval *this_ptr, const zend_string *str, const ze
|
||||
return;
|
||||
}
|
||||
|
||||
static void 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)
|
||||
{
|
||||
v8js_ctx *c = Z_V8JS_CTX_OBJ_P(this_ptr);
|
||||
|
||||
@ -681,7 +680,7 @@ static void v8js_execute_script(zval *this_ptr, v8js_script *res, long flags, lo
|
||||
return script->Run();
|
||||
};
|
||||
|
||||
v8js_v8_call(c, return_value, flags, time_limit, memory_limit, v8_call TSRMLS_CC);
|
||||
v8js_v8_call(c, return_value, flags, time_limit, memory_limit, v8_call);
|
||||
}
|
||||
|
||||
if(V8JSG(fatal_error_abort)) {
|
||||
@ -699,17 +698,17 @@ static PHP_METHOD(V8Js, executeString)
|
||||
long flags = V8JS_FLAG_NONE, time_limit = 0, memory_limit = 0;
|
||||
v8js_script *res = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|Slll", &str, &identifier, &flags, &time_limit, &memory_limit) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|Slll", &str, &identifier, &flags, &time_limit, &memory_limit) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
v8js_compile_script(getThis(), str, identifier, &res TSRMLS_CC);
|
||||
v8js_compile_script(getThis(), str, identifier, &res);
|
||||
if (!res) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
zend_try {
|
||||
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);
|
||||
v8js_script_free(res);
|
||||
}
|
||||
zend_catch {
|
||||
@ -730,11 +729,11 @@ static PHP_METHOD(V8Js, compileString)
|
||||
zend_string *str = NULL, *identifier = NULL;
|
||||
v8js_script *res = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &identifier) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S", &str, &identifier) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
v8js_compile_script(getThis(), str, identifier, &res TSRMLS_CC);
|
||||
v8js_compile_script(getThis(), str, identifier, &res);
|
||||
if (res) {
|
||||
RETVAL_RES(zend_register_resource(res, le_v8js_script));
|
||||
|
||||
@ -754,7 +753,7 @@ static PHP_METHOD(V8Js, executeScript)
|
||||
zval *zscript;
|
||||
v8js_script *res;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|lll", &zscript, &flags, &time_limit, &memory_limit) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|lll", &zscript, &flags, &time_limit, &memory_limit) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -762,7 +761,7 @@ static PHP_METHOD(V8Js, executeScript)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -775,11 +774,11 @@ static PHP_METHOD(V8Js, checkString)
|
||||
|
||||
v8js_script *res = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
v8js_compile_script(getThis(), str, identifier, &res TSRMLS_CC);
|
||||
v8js_compile_script(getThis(), str, identifier, &res);
|
||||
zend_string_release(identifier);
|
||||
|
||||
if (!res) {
|
||||
@ -836,7 +835,7 @@ static PHP_METHOD(V8Js, setModuleNormaliser)
|
||||
v8js_ctx *c;
|
||||
zval *callable;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callable) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callable) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -852,7 +851,7 @@ static PHP_METHOD(V8Js, setModuleLoader)
|
||||
v8js_ctx *c;
|
||||
zval *callable;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callable) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callable) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -868,7 +867,7 @@ static PHP_METHOD(V8Js, setTimeLimit)
|
||||
v8js_ctx *c;
|
||||
long time_limit = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &time_limit) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &time_limit) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -904,7 +903,7 @@ static PHP_METHOD(V8Js, setMemoryLimit)
|
||||
v8js_ctx *c;
|
||||
long memory_limit = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &memory_limit) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &memory_limit) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -935,7 +934,7 @@ static PHP_METHOD(V8Js, setAverageObjectSize)
|
||||
v8js_ctx *c;
|
||||
long average_object_size = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &average_object_size) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &average_object_size) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -979,7 +978,7 @@ static void v8js_script_dtor(zend_resource *rsrc) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int v8js_register_extension(zend_string *name, zend_string *source, zval *deps_arr, zend_bool auto_enable TSRMLS_DC) /* {{{ */
|
||||
static int v8js_register_extension(zend_string *name, zend_string *source, zval *deps_arr, zend_bool auto_enable) /* {{{ */
|
||||
{
|
||||
v8js_jsext *jsext = NULL;
|
||||
|
||||
@ -1003,7 +1002,7 @@ static int v8js_register_extension(zend_string *name, zend_string *source, zval
|
||||
jsext->deps_count = zend_hash_num_elements(Z_ARRVAL_P(deps_arr));
|
||||
|
||||
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_error_docref(NULL, E_WARNING, "Invalid dependency array passed");
|
||||
v8js_jsext_free_storage(jsext);
|
||||
#ifdef ZTS
|
||||
v8js_process_globals.lock.unlock();
|
||||
@ -1057,15 +1056,15 @@ static PHP_METHOD(V8Js, registerExtension)
|
||||
zval *deps_arr = NULL;
|
||||
zend_bool auto_enable = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ab", &ext_name, &script, &deps_arr, &auto_enable) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ab", &ext_name, &script, &deps_arr, &auto_enable) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ZSTR_LEN(ext_name)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Extension name cannot be empty");
|
||||
php_error_docref(NULL, E_WARNING, "Extension name cannot be empty");
|
||||
} else if (!ZSTR_LEN(script)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Script cannot be empty");
|
||||
} else if (v8js_register_extension(ext_name, script, deps_arr, auto_enable TSRMLS_CC) == SUCCESS) {
|
||||
php_error_docref(NULL, E_WARNING, "Script cannot be empty");
|
||||
} else if (v8js_register_extension(ext_name, script, deps_arr, auto_enable) == SUCCESS) {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
RETURN_FALSE;
|
||||
@ -1121,22 +1120,22 @@ static PHP_METHOD(V8Js, createSnapshot)
|
||||
{
|
||||
zend_string *script;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &script) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &script) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ZSTR_LEN(script)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Script cannot be empty");
|
||||
php_error_docref(NULL, E_WARNING, "Script cannot be empty");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Initialize V8, if not already done. */
|
||||
v8js_v8_init(TSRMLS_C);
|
||||
v8js_v8_init();
|
||||
|
||||
v8::StartupData snapshot_blob = v8::V8::CreateSnapshotDataBlob(ZSTR_VAL(script));
|
||||
|
||||
if (!snapshot_blob.data) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to create V8 heap snapshot. Check $embed_source for errors.");
|
||||
php_error_docref(NULL, E_WARNING, "Failed to create V8 heap snapshot. Check $embed_source for errors.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@ -1253,12 +1252,12 @@ const zend_function_entry v8js_methods[] = { /* {{{ */
|
||||
|
||||
/* V8Js object handlers */
|
||||
|
||||
static void v8js_write_property(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC) /* {{{ */
|
||||
static void v8js_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
|
||||
{
|
||||
V8JS_BEGIN_CTX(c, object)
|
||||
|
||||
/* Check whether member is public, if so, export to V8. */
|
||||
zend_property_info *property_info = zend_get_property_info(c->std.ce, Z_STR_P(member), 1 TSRMLS_CC);
|
||||
zend_property_info *property_info = zend_get_property_info(c->std.ce, Z_STR_P(member), 1);
|
||||
if(!property_info ||
|
||||
(property_info != ZEND_WRONG_PROPERTY_INFO &&
|
||||
(property_info->flags & ZEND_ACC_PUBLIC))) {
|
||||
@ -1274,7 +1273,7 @@ static void v8js_write_property(zval *object, zval *member, zval *value, void **
|
||||
|
||||
/* Write value to PHP JS object */
|
||||
v8::Local<v8::Value> key = V8JS_SYML(Z_STRVAL_P(member), static_cast<int>(Z_STRLEN_P(member)));
|
||||
jsobj->ForceSet(key, zval_to_v8js(value, isolate TSRMLS_CC), v8::ReadOnly);
|
||||
jsobj->ForceSet(key, zval_to_v8js(value, isolate), v8::ReadOnly);
|
||||
}
|
||||
|
||||
/* Write value to PHP object */
|
||||
@ -1282,7 +1281,7 @@ static void v8js_write_property(zval *object, zval *member, zval *value, void **
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void v8js_unset_property(zval *object, zval *member, void **cache_slot TSRMLS_DC) /* {{{ */
|
||||
static void v8js_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */
|
||||
{
|
||||
V8JS_BEGIN_CTX(c, object)
|
||||
|
||||
@ -1311,7 +1310,7 @@ 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 = zend_register_internal_class(&ce);
|
||||
php_ce_v8js->create_object = v8js_new;
|
||||
|
||||
/* V8Js handlers */
|
||||
@ -1321,11 +1320,11 @@ PHP_MINIT_FUNCTION(v8js_class) /* {{{ */
|
||||
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);
|
||||
zend_declare_class_constant_string(php_ce_v8js, ZEND_STRL("V8_VERSION"), PHP_V8_VERSION);
|
||||
|
||||
zend_declare_class_constant_long(php_ce_v8js, ZEND_STRL("FLAG_NONE"), V8JS_FLAG_NONE TSRMLS_CC);
|
||||
zend_declare_class_constant_long(php_ce_v8js, ZEND_STRL("FLAG_FORCE_ARRAY"), V8JS_FLAG_FORCE_ARRAY TSRMLS_CC);
|
||||
zend_declare_class_constant_long(php_ce_v8js, ZEND_STRL("FLAG_PROPAGATE_PHP_EXCEPTIONS"), V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS TSRMLS_CC);
|
||||
zend_declare_class_constant_long(php_ce_v8js, ZEND_STRL("FLAG_NONE"), V8JS_FLAG_NONE);
|
||||
zend_declare_class_constant_long(php_ce_v8js, ZEND_STRL("FLAG_FORCE_ARRAY"), V8JS_FLAG_FORCE_ARRAY);
|
||||
zend_declare_class_constant_long(php_ce_v8js, ZEND_STRL("FLAG_PROPAGATE_PHP_EXCEPTIONS"), V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS);
|
||||
|
||||
le_v8js_script = zend_register_list_destructors_ex(v8js_script_dtor, NULL, PHP_V8JS_SCRIPT_RES_NAME, module_number);
|
||||
|
||||
|
10
v8js_class.h
10
v8js_class.h
@ -74,20 +74,10 @@ struct v8js_ctx {
|
||||
zval zval_snapshot_blob;
|
||||
v8::StartupData snapshot_blob;
|
||||
|
||||
#ifdef ZTS
|
||||
void ***zts_ctx;
|
||||
#endif
|
||||
|
||||
zend_object std;
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
#ifdef ZTS
|
||||
# define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((v8js_ctx *) isolate->GetData(0))->zts_ctx);
|
||||
#else
|
||||
# define V8JS_TSRMLS_FETCH()
|
||||
#endif
|
||||
|
||||
static inline struct v8js_ctx *v8js_ctx_fetch_object(zend_object *obj) {
|
||||
return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ extern "C" {
|
||||
#include "zend_exceptions.h"
|
||||
}
|
||||
|
||||
static int v8js_is_assoc_array(HashTable *myht TSRMLS_DC) /* {{{ */
|
||||
static int v8js_is_assoc_array(HashTable *myht) /* {{{ */
|
||||
{
|
||||
zend_string *key;
|
||||
zend_ulong index, idx = 0;
|
||||
@ -57,14 +57,14 @@ static int v8js_is_assoc_array(HashTable *myht TSRMLS_DC) /* {{{ */
|
||||
/* }}} */
|
||||
|
||||
|
||||
static v8::Handle<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
|
||||
static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
HashTable *myht = HASH_OF(value);
|
||||
int i = myht ? zend_hash_num_elements(myht) : 0;
|
||||
|
||||
/* Return object if dealing with assoc array */
|
||||
if (i > 0 && v8js_is_assoc_array(myht TSRMLS_CC)) {
|
||||
return v8js_hash_to_jsobj(value, isolate TSRMLS_CC);
|
||||
if (i > 0 && v8js_is_assoc_array(myht)) {
|
||||
return v8js_hash_to_jsobj(value, isolate);
|
||||
}
|
||||
|
||||
v8::Local<v8::Array> newarr;
|
||||
@ -89,7 +89,7 @@ static v8::Handle<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolat
|
||||
ZEND_HASH_INC_APPLY_COUNT(myht);
|
||||
}
|
||||
|
||||
newarr->Set(index++, zval_to_v8js(data, isolate TSRMLS_CC));
|
||||
newarr->Set(index++, zval_to_v8js(data, isolate));
|
||||
|
||||
if (tmp_ht) {
|
||||
ZEND_HASH_DEC_APPLY_COUNT(myht);
|
||||
@ -100,7 +100,7 @@ static v8::Handle<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolat
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
v8::Handle<v8::Value> zend_long_to_v8js(zend_long v, v8::Isolate *isolate) /* {{{ */
|
||||
v8::Local<v8::Value> zend_long_to_v8js(zend_long v, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
if (v < - std::numeric_limits<int32_t>::min() || v > std::numeric_limits<int32_t>::max()) {
|
||||
return V8JS_FLOAT(static_cast<double>(v));
|
||||
@ -110,9 +110,9 @@ v8::Handle<v8::Value> zend_long_to_v8js(zend_long v, v8::Isolate *isolate) /* {{
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate) /* {{{ */
|
||||
v8::Local<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
v8::Handle<v8::Value> jsValue;
|
||||
v8::Local<v8::Value> jsValue;
|
||||
zend_string *value_str;
|
||||
zend_class_entry *ce;
|
||||
|
||||
@ -127,21 +127,21 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate) /* {{{ */
|
||||
break;
|
||||
|
||||
case IS_ARRAY:
|
||||
jsValue = v8js_hash_to_jsarr(value, isolate TSRMLS_CC);
|
||||
jsValue = v8js_hash_to_jsarr(value, isolate);
|
||||
break;
|
||||
|
||||
case IS_OBJECT:
|
||||
if (V8JSG(use_date)) {
|
||||
ce = php_date_get_date_ce();
|
||||
if (instanceof_function(Z_OBJCE_P(value), ce TSRMLS_CC)) {
|
||||
if (instanceof_function(Z_OBJCE_P(value), ce)) {
|
||||
zval dtval;
|
||||
zend_call_method_with_0_params(value, NULL, NULL, "getTimestamp", &dtval);
|
||||
jsValue = V8JS_DATE(((double)Z_LVAL(dtval) * 1000.0));
|
||||
zval_dtor(&dtval);
|
||||
} else
|
||||
jsValue = v8js_hash_to_jsobj(value, isolate TSRMLS_CC);
|
||||
jsValue = v8js_hash_to_jsobj(value, isolate);
|
||||
} else
|
||||
jsValue = v8js_hash_to_jsobj(value, isolate TSRMLS_CC);
|
||||
jsValue = v8js_hash_to_jsobj(value, isolate);
|
||||
break;
|
||||
|
||||
case IS_STRING:
|
||||
@ -186,7 +186,7 @@ v8::Handle<v8::Value> zval_to_v8js(zval *value, v8::Isolate *isolate) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int v8js_to_zval(v8::Handle<v8::Value> jsValue, zval *return_value, int flags, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
|
||||
int v8js_to_zval(v8::Local<v8::Value> jsValue, zval *return_value, int flags, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
if (jsValue->IsString())
|
||||
{
|
||||
@ -231,8 +231,8 @@ int v8js_to_zval(v8::Handle<v8::Value> jsValue, zval *return_value, int flags, v
|
||||
}
|
||||
|
||||
zend_class_entry *ce = php_date_get_date_ce();
|
||||
php_date_instantiate(ce, return_value TSRMLS_CC);
|
||||
if (!php_date_initialize(Z_PHPDATE_P(return_value), date_str, strlen(date_str), NULL, NULL, 0 TSRMLS_CC)) {
|
||||
php_date_instantiate(ce, return_value);
|
||||
if (!php_date_initialize(Z_PHPDATE_P(return_value), date_str, strlen(date_str), NULL, NULL, 0)) {
|
||||
efree(date_str);
|
||||
return FAILURE;
|
||||
}
|
||||
@ -254,9 +254,9 @@ int v8js_to_zval(v8::Handle<v8::Value> jsValue, zval *return_value, int flags, v
|
||||
|
||||
if ((flags & V8JS_FLAG_FORCE_ARRAY && !jsValue->IsFunction()) || jsValue->IsArray()) {
|
||||
array_init(return_value);
|
||||
return v8js_get_properties_hash(jsValue, Z_ARRVAL_P(return_value), flags, isolate TSRMLS_CC);
|
||||
return v8js_get_properties_hash(jsValue, Z_ARRVAL_P(return_value), flags, isolate);
|
||||
} else {
|
||||
v8js_v8object_create(return_value, jsValue, flags, isolate TSRMLS_CC);
|
||||
v8js_v8object_create(return_value, jsValue, flags, isolate);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -37,11 +37,11 @@ zend_class_entry *php_ce_v8js_memory_limit_exception;
|
||||
|
||||
/* {{{ Class: V8JsScriptException */
|
||||
|
||||
void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::TryCatch *try_catch TSRMLS_DC) /* {{{ */
|
||||
void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::TryCatch *try_catch) /* {{{ */
|
||||
{
|
||||
v8::String::Utf8Value exception(try_catch->Exception());
|
||||
const char *exception_string = ToCString(exception);
|
||||
v8::Handle<v8::Message> tc_message = try_catch->Message();
|
||||
v8::Local<v8::Message> tc_message = try_catch->Message();
|
||||
const char *filename_string, *sourceline_string;
|
||||
char *message_string;
|
||||
int linenum, start_col, end_col;
|
||||
@ -49,7 +49,7 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
|
||||
object_init_ex(return_value, php_ce_v8js_script_exception);
|
||||
|
||||
#define PHPV8_EXPROP(type, name, value) \
|
||||
zend_update_property##type(php_ce_v8js_script_exception, return_value, #name, sizeof(#name) - 1, value TSRMLS_CC);
|
||||
zend_update_property##type(php_ce_v8js_script_exception, return_value, #name, sizeof(#name) - 1, value);
|
||||
|
||||
if (tc_message.IsEmpty()) {
|
||||
spprintf(&message_string, 0, "%s", exception_string);
|
||||
@ -84,8 +84,8 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
|
||||
if(try_catch->Exception()->IsObject() && try_catch->Exception()->ToObject()->InternalFieldCount() == 2) {
|
||||
zend_object *php_exception = reinterpret_cast<zend_object *>(try_catch->Exception()->ToObject()->GetAlignedPointerFromInternalField(1));
|
||||
|
||||
zend_class_entry *exception_ce = zend_exception_get_default(TSRMLS_C);
|
||||
if (instanceof_function(php_exception->ce, exception_ce TSRMLS_CC)) {
|
||||
zend_class_entry *exception_ce = zend_exception_get_default();
|
||||
if (instanceof_function(php_exception->ce, exception_ce)) {
|
||||
++GC_REFCOUNT(php_exception);
|
||||
zend_exception_set_previous(Z_OBJ_P(return_value), php_exception);
|
||||
}
|
||||
@ -98,17 +98,17 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void v8js_throw_script_exception(v8::Isolate *isolate, v8::TryCatch *try_catch TSRMLS_DC) /* {{{ */
|
||||
void v8js_throw_script_exception(v8::Isolate *isolate, v8::TryCatch *try_catch) /* {{{ */
|
||||
{
|
||||
v8::String::Utf8Value exception(try_catch->Exception());
|
||||
const char *exception_string = ToCString(exception);
|
||||
zval zexception;
|
||||
|
||||
if (try_catch->Message().IsEmpty()) {
|
||||
zend_throw_exception(php_ce_v8js_script_exception, (char *) exception_string, 0 TSRMLS_CC);
|
||||
zend_throw_exception(php_ce_v8js_script_exception, (char *) exception_string, 0);
|
||||
} else {
|
||||
v8js_create_script_exception(&zexception, isolate, try_catch TSRMLS_CC);
|
||||
zend_throw_exception_object(&zexception TSRMLS_CC);
|
||||
v8js_create_script_exception(&zexception, isolate, try_catch);
|
||||
zend_throw_exception_object(&zexception);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -121,7 +121,7 @@ void v8js_throw_script_exception(v8::Isolate *isolate, v8::TryCatch *try_catch T
|
||||
if (zend_parse_parameters_none() == FAILURE) { \
|
||||
return; \
|
||||
} \
|
||||
value = zend_read_property(php_ce_v8js_script_exception, getThis(), #property, sizeof(#property) - 1, 0, &rv TSRMLS_CC); \
|
||||
value = zend_read_property(php_ce_v8js_script_exception, getThis(), #property, sizeof(#property) - 1, 0, &rv); \
|
||||
RETURN_ZVAL(value, 1, 0); \
|
||||
}
|
||||
|
||||
@ -213,29 +213,29 @@ PHP_MINIT_FUNCTION(v8js_exceptions) /* {{{ */
|
||||
|
||||
/* V8JsException Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8JsException", v8js_exception_methods);
|
||||
php_ce_v8js_exception = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException TSRMLS_CC);
|
||||
php_ce_v8js_exception = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException);
|
||||
|
||||
/* V8JsScriptException Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8JsScriptException", v8js_script_exception_methods);
|
||||
php_ce_v8js_script_exception = zend_register_internal_class_ex(&ce, php_ce_v8js_exception TSRMLS_CC);
|
||||
php_ce_v8js_script_exception = zend_register_internal_class_ex(&ce, php_ce_v8js_exception);
|
||||
php_ce_v8js_script_exception->ce_flags |= ZEND_ACC_FINAL;
|
||||
|
||||
/* Add custom JS specific properties */
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsFileName"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsLineNumber"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsStartColumn"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsEndColumn"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsSourceLine"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsTrace"), ZEND_ACC_PROTECTED TSRMLS_CC);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsFileName"), ZEND_ACC_PROTECTED);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsLineNumber"), ZEND_ACC_PROTECTED);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsStartColumn"), ZEND_ACC_PROTECTED);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsEndColumn"), ZEND_ACC_PROTECTED);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsSourceLine"), ZEND_ACC_PROTECTED);
|
||||
zend_declare_property_null(php_ce_v8js_script_exception, ZEND_STRL("JsTrace"), ZEND_ACC_PROTECTED);
|
||||
|
||||
/* V8JsTimeLimitException Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8JsTimeLimitException", v8js_time_limit_exception_methods);
|
||||
php_ce_v8js_time_limit_exception = zend_register_internal_class_ex(&ce, php_ce_v8js_exception TSRMLS_CC);
|
||||
php_ce_v8js_time_limit_exception = zend_register_internal_class_ex(&ce, php_ce_v8js_exception);
|
||||
php_ce_v8js_time_limit_exception->ce_flags |= ZEND_ACC_FINAL;
|
||||
|
||||
/* V8JsMemoryLimitException Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8JsMemoryLimitException", v8js_memory_limit_exception_methods);
|
||||
php_ce_v8js_memory_limit_exception = zend_register_internal_class_ex(&ce, php_ce_v8js_exception TSRMLS_CC);
|
||||
php_ce_v8js_memory_limit_exception = zend_register_internal_class_ex(&ce, php_ce_v8js_exception);
|
||||
php_ce_v8js_memory_limit_exception->ce_flags |= ZEND_ACC_FINAL;
|
||||
|
||||
return SUCCESS;
|
||||
|
@ -20,8 +20,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 v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::TryCatch *try_catch TSRMLS_DC);
|
||||
void v8js_throw_script_exception(v8::Isolate *isolate, v8::TryCatch *try_catch TSRMLS_DC);
|
||||
void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::TryCatch *try_catch);
|
||||
void v8js_throw_script_exception(v8::Isolate *isolate, v8::TryCatch *try_catch);
|
||||
|
||||
PHP_MINIT_FUNCTION(v8js_exceptions);
|
||||
|
||||
|
@ -55,7 +55,7 @@ V8JS_METHOD(print) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int level TSRMLS_DC) /* {{{ */
|
||||
static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int level) /* {{{ */
|
||||
{
|
||||
if (level > 1) {
|
||||
php_printf("%*c", (level - 1) * 2, ' ');
|
||||
@ -135,7 +135,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
|
||||
|
||||
for (unsigned i = 0; i < length; i++) {
|
||||
php_printf("%*c[%d] =>\n", level * 2, ' ', i);
|
||||
v8js_dumper(isolate, array->Get(i), level + 1 TSRMLS_CC);
|
||||
v8js_dumper(isolate, array->Get(i), level + 1);
|
||||
}
|
||||
|
||||
if (level > 1) {
|
||||
@ -172,7 +172,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
|
||||
v8::Local<v8::String> key = keys->Get(i)->ToString();
|
||||
v8::String::Utf8Value kname(key);
|
||||
php_printf("%*c[\"%s\"] =>\n", level * 2, ' ', ToCString(kname));
|
||||
v8js_dumper(isolate, object->Get(key), level + 1 TSRMLS_CC);
|
||||
v8js_dumper(isolate, object->Get(key), level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,10 +193,9 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
|
||||
V8JS_METHOD(var_dump) /* {{{ */
|
||||
{
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
for (int i = 0; i < info.Length(); i++) {
|
||||
v8js_dumper(isolate, info[i], 1 TSRMLS_CC);
|
||||
v8js_dumper(isolate, info[i], 1);
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(V8JS_NULL);
|
||||
@ -206,7 +205,6 @@ V8JS_METHOD(var_dump) /* {{{ */
|
||||
V8JS_METHOD(require)
|
||||
{
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
// Get the extension context
|
||||
v8::Local<v8::External> data = v8::Local<v8::External>::Cast(info.Data());
|
||||
@ -244,7 +242,7 @@ V8JS_METHOD(require)
|
||||
ZVAL_STRING(¶ms[1], module_id);
|
||||
|
||||
call_result = call_user_function_ex(EG(function_table), NULL, &c->module_normaliser,
|
||||
&normaliser_result, 2, params, 0, NULL TSRMLS_CC);
|
||||
&normaliser_result, 2, params, 0, NULL);
|
||||
}
|
||||
|
||||
isolate->Enter();
|
||||
@ -270,7 +268,7 @@ V8JS_METHOD(require)
|
||||
// Check if an exception was thrown
|
||||
if (EG(exception)) {
|
||||
// Clear the PHP exception and throw it in V8 instead
|
||||
zend_clear_exception(TSRMLS_C);
|
||||
zend_clear_exception();
|
||||
info.GetReturnValue().Set(isolate->ThrowException(V8JS_SYM("Module normaliser callback exception")));
|
||||
return;
|
||||
}
|
||||
@ -360,7 +358,7 @@ V8JS_METHOD(require)
|
||||
|
||||
zend_try {
|
||||
ZVAL_STRING(¶ms[0], normalised_module_id);
|
||||
call_result = call_user_function_ex(EG(function_table), NULL, &c->module_loader, &module_code, 1, params, 0, NULL TSRMLS_CC);
|
||||
call_result = call_user_function_ex(EG(function_table), NULL, &c->module_loader, &module_code, 1, params, 0, NULL);
|
||||
}
|
||||
zend_catch {
|
||||
v8js_terminate_execution(isolate);
|
||||
@ -392,7 +390,7 @@ V8JS_METHOD(require)
|
||||
efree(normalised_path);
|
||||
|
||||
// Clear the PHP exception and throw it in V8 instead
|
||||
zend_clear_exception(TSRMLS_C);
|
||||
zend_clear_exception();
|
||||
info.GetReturnValue().Set(isolate->ThrowException(V8JS_SYM("Module loader callback exception")));
|
||||
return;
|
||||
}
|
||||
@ -502,7 +500,7 @@ V8JS_METHOD(require)
|
||||
info.GetReturnValue().Set(newobj);
|
||||
}
|
||||
|
||||
void v8js_register_methods(v8::Handle<v8::ObjectTemplate> global, v8js_ctx *c) /* {{{ */
|
||||
void v8js_register_methods(v8::Local<v8::ObjectTemplate> global, v8js_ctx *c) /* {{{ */
|
||||
{
|
||||
v8::Isolate *isolate = c->isolate;
|
||||
global->Set(V8JS_SYM("exit"), v8::FunctionTemplate::New(isolate, V8JS_MN(exit)), v8::ReadOnly);
|
||||
|
@ -35,9 +35,9 @@ extern "C" {
|
||||
static void v8js_weak_object_callback(const v8::WeakCallbackInfo<zend_object> &data);
|
||||
|
||||
/* Callback for PHP methods and functions */
|
||||
static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v8::Isolate *isolate, const v8::FunctionCallbackInfo<v8::Value>& info TSRMLS_DC) /* {{{ */
|
||||
static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v8::Isolate *isolate, const v8::FunctionCallbackInfo<v8::Value>& info) /* {{{ */
|
||||
{
|
||||
v8::Handle<v8::Value> return_value = V8JS_NULL;
|
||||
v8::Local<v8::Value> return_value = V8JS_NULL;
|
||||
zend_fcall_info fci;
|
||||
zend_fcall_info_cache fcc;
|
||||
zval fname, retval;
|
||||
@ -106,7 +106,7 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v
|
||||
ZVAL_OBJ(&fci.params[i], object);
|
||||
Z_ADDREF_P(&fci.params[i]);
|
||||
} else {
|
||||
if (v8js_to_zval(info[i], &fci.params[i], ctx->flags, isolate TSRMLS_CC) == FAILURE) {
|
||||
if (v8js_to_zval(info[i], &fci.params[i], ctx->flags, isolate) == FAILURE) {
|
||||
error_len = spprintf(&error, 0, "converting parameter #%d passed to %s() failed", i + 1, method_ptr->common.function_name);
|
||||
|
||||
if (error_len > std::numeric_limits<int>::max()) {
|
||||
@ -143,7 +143,7 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v
|
||||
fcc.called_scope = object->ce;
|
||||
fcc.object = object;
|
||||
|
||||
zend_call_function(&fci, &fcc TSRMLS_CC);
|
||||
zend_call_function(&fci, &fcc);
|
||||
}
|
||||
zend_catch {
|
||||
v8js_terminate_execution(isolate);
|
||||
@ -166,8 +166,8 @@ failure:
|
||||
if(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) {
|
||||
zval tmp_zv;
|
||||
ZVAL_OBJ(&tmp_zv, EG(exception));
|
||||
return_value = isolate->ThrowException(zval_to_v8js(&tmp_zv, isolate TSRMLS_CC));
|
||||
zend_clear_exception(TSRMLS_C);
|
||||
return_value = isolate->ThrowException(zval_to_v8js(&tmp_zv, isolate));
|
||||
zend_clear_exception();
|
||||
} else {
|
||||
v8js_terminate_execution(isolate);
|
||||
}
|
||||
@ -175,7 +175,7 @@ failure:
|
||||
// special case: "return $this"
|
||||
return_value = info.Holder();
|
||||
} else {
|
||||
return_value = zval_to_v8js(&retval, isolate TSRMLS_CC);
|
||||
return_value = zval_to_v8js(&retval, isolate);
|
||||
}
|
||||
|
||||
zval_ptr_dtor(&retval);
|
||||
@ -191,7 +191,6 @@ void v8js_php_callback(const v8::FunctionCallbackInfo<v8::Value>& info) /* {{{ *
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
zend_function *method_ptr;
|
||||
|
||||
@ -199,10 +198,10 @@ void v8js_php_callback(const v8::FunctionCallbackInfo<v8::Value>& info) /* {{{ *
|
||||
if (!info.Data().IsEmpty() && info.Data()->IsExternal()) {
|
||||
method_ptr = static_cast<zend_function *>(v8::External::Cast(*info.Data())->Value());
|
||||
} else {
|
||||
method_ptr = zend_get_closure_invoke_method(object TSRMLS_CC);
|
||||
method_ptr = zend_get_closure_invoke_method(object);
|
||||
}
|
||||
|
||||
return v8js_call_php_func(object, method_ptr, isolate, info TSRMLS_CC);
|
||||
return v8js_call_php_func(object, method_ptr, isolate, info);
|
||||
}
|
||||
|
||||
/* Callback for PHP constructor calls */
|
||||
@ -211,7 +210,7 @@ static void v8js_construct_callback(const v8::FunctionCallbackInfo<v8::Value>& i
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
info.GetReturnValue().Set(V8JS_UNDEFINED);
|
||||
|
||||
v8::Handle<v8::Object> newobj = info.This();
|
||||
v8::Local<v8::Object> newobj = info.This();
|
||||
zval value;
|
||||
|
||||
if (!info.IsConstructCall()) {
|
||||
@ -243,7 +242,6 @@ static void v8js_construct_callback(const v8::FunctionCallbackInfo<v8::Value>& i
|
||||
Z_ADDREF_P(&value);
|
||||
} else {
|
||||
// Object created from JavaScript context. Need to create PHP object first.
|
||||
V8JS_TSRMLS_FETCH();
|
||||
zend_class_entry *ce = static_cast<zend_class_entry *>(ext_ce->Value());
|
||||
zend_function *ctor_ptr = ce->constructor;
|
||||
|
||||
@ -257,7 +255,7 @@ static void v8js_construct_callback(const v8::FunctionCallbackInfo<v8::Value>& i
|
||||
|
||||
// Call __construct function
|
||||
if (ctor_ptr != NULL) {
|
||||
v8js_call_php_func(Z_OBJ(value), ctor_ptr, isolate, info TSRMLS_CC);
|
||||
v8js_call_php_func(Z_OBJ(value), ctor_ptr, isolate, info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +320,6 @@ static void v8js_named_property_enumerator(const v8::PropertyCallbackInfo<v8::Ar
|
||||
v8::Local<v8::Array> result = v8::Array::New(isolate, 0);
|
||||
uint32_t result_len = 0;
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
zend_class_entry *ce;
|
||||
void *ptr;
|
||||
HashTable *proptable;
|
||||
@ -425,8 +422,6 @@ static void v8js_invoke_callback(const v8::FunctionCallbackInfo<v8::Value>& info
|
||||
v8::Local<v8::Value> *argv = static_cast<v8::Local<v8::Value> *>(alloca(sizeof(v8::Local<v8::Value>) * argc));
|
||||
v8::Local<v8::Value> result;
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
for (i=0; i<argc; i++) {
|
||||
new(&argv[i]) v8::Local<v8::Value>;
|
||||
argv[i] = info[i];
|
||||
@ -438,7 +433,7 @@ static void v8js_invoke_callback(const v8::FunctionCallbackInfo<v8::Value>& info
|
||||
v8::Local<v8::String> str = self->GetConstructorName()->ToString();
|
||||
v8::String::Utf8Value str_value(str);
|
||||
zend_string *constructor_name = zend_string_init(ToCString(str_value), str->Utf8Length(), 0);
|
||||
zend_class_entry *ce = zend_lookup_class(constructor_name TSRMLS_CC);
|
||||
zend_class_entry *ce = zend_lookup_class(constructor_name);
|
||||
zend_string_release(constructor_name);
|
||||
|
||||
v8::Local<v8::FunctionTemplate> new_tpl;
|
||||
@ -460,12 +455,11 @@ static void v8js_fake_call_impl(const v8::FunctionCallbackInfo<v8::Value>& info)
|
||||
{
|
||||
v8::Isolate *isolate = info.GetIsolate();
|
||||
v8::Local<v8::Object> self = info.Holder();
|
||||
v8::Handle<v8::Value> return_value = V8JS_NULL;
|
||||
v8::Local<v8::Value> return_value = V8JS_NULL;
|
||||
|
||||
char *error;
|
||||
size_t error_len;
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
zend_class_entry *ce;
|
||||
zend_object *object = reinterpret_cast<zend_object *>(self->GetAlignedPointerFromInternalField(1));
|
||||
ce = object->ce;
|
||||
@ -535,7 +529,7 @@ static void v8js_fake_call_impl(const v8::FunctionCallbackInfo<v8::Value>& info)
|
||||
|
||||
// okay, look up the method name and manually invoke it.
|
||||
const zend_object_handlers *h = object->handlers;
|
||||
zend_function *method_ptr = h->get_method(&object, method_name, NULL TSRMLS_CC);
|
||||
zend_function *method_ptr = h->get_method(&object, method_name, NULL);
|
||||
zend_string_release(method_name);
|
||||
|
||||
if (method_ptr == NULL ||
|
||||
@ -590,7 +584,6 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
|
||||
v8::Local<v8::Value> ret_value;
|
||||
v8::Local<v8::Function> cb;
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
zend_class_entry *scope, *ce;
|
||||
zend_function *method_ptr = NULL;
|
||||
zval php_value;
|
||||
@ -674,7 +667,7 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
|
||||
ret_value = V8JS_BOOL(false);
|
||||
} else {
|
||||
/* shouldn't reach here! but bail safely */
|
||||
ret_value = v8::Handle<v8::Value>();
|
||||
ret_value = v8::Local<v8::Value>();
|
||||
}
|
||||
} else {
|
||||
if (name[0]=='$') {
|
||||
@ -687,20 +680,20 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
|
||||
|
||||
if (callback_type == V8JS_PROP_GETTER) {
|
||||
/* Nope, not a method -- must be a (case-sensitive) property */
|
||||
zend_property_info *property_info = zend_get_property_info(ce, Z_STR(zname), 1 TSRMLS_CC);
|
||||
zend_property_info *property_info = zend_get_property_info(ce, Z_STR(zname), 1);
|
||||
|
||||
if(!property_info ||
|
||||
(property_info != ZEND_WRONG_PROPERTY_INFO &&
|
||||
property_info->flags & ZEND_ACC_PUBLIC)) {
|
||||
zval *property_val = zend_read_property(NULL, &zobject, name, name_len, true, &php_value TSRMLS_CC);
|
||||
zval *property_val = zend_read_property(NULL, &zobject, name, name_len, true, &php_value);
|
||||
// special case uninitialized_zval_ptr and return an empty value
|
||||
// (indicating that we don't intercept this property) if the
|
||||
// property doesn't exist.
|
||||
if (property_val == &EG(uninitialized_zval)) {
|
||||
ret_value = v8::Handle<v8::Value>();
|
||||
ret_value = v8::Local<v8::Value>();
|
||||
} else {
|
||||
// wrap it
|
||||
ret_value = zval_to_v8js(property_val, isolate TSRMLS_CC);
|
||||
ret_value = zval_to_v8js(property_val, isolate);
|
||||
/* We don't own the reference to php_value... unless the
|
||||
* returned refcount was 0, in which case the below code
|
||||
* will free it. */
|
||||
@ -713,21 +706,21 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
|
||||
&& ((ce->__get->common.fn_flags & ZEND_ACC_PUBLIC) != 0)) {
|
||||
/* Okay, let's call __get. */
|
||||
zend_call_method_with_1_params(&zobject, ce, &ce->__get, ZEND_GET_FUNC_NAME, &php_value, &zname);
|
||||
ret_value = zval_to_v8js(&php_value, isolate TSRMLS_CC);
|
||||
ret_value = zval_to_v8js(&php_value, isolate);
|
||||
zval_ptr_dtor(&php_value);
|
||||
}
|
||||
|
||||
} else if (callback_type == V8JS_PROP_SETTER) {
|
||||
if (v8js_to_zval(set_value, &php_value, ctx->flags, isolate TSRMLS_CC) != SUCCESS) {
|
||||
ret_value = v8::Handle<v8::Value>();
|
||||
if (v8js_to_zval(set_value, &php_value, ctx->flags, isolate) != SUCCESS) {
|
||||
ret_value = v8::Local<v8::Value>();
|
||||
}
|
||||
else {
|
||||
zend_property_info *property_info = zend_get_property_info(ce, Z_STR(zname), 1 TSRMLS_CC);
|
||||
zend_property_info *property_info = zend_get_property_info(ce, Z_STR(zname), 1);
|
||||
|
||||
if(!property_info ||
|
||||
(property_info != ZEND_WRONG_PROPERTY_INFO &&
|
||||
property_info->flags & ZEND_ACC_PUBLIC)) {
|
||||
zend_update_property(scope, &zobject, name, name_len, &php_value TSRMLS_CC);
|
||||
zend_update_property(scope, &zobject, name, name_len, &php_value);
|
||||
ret_value = set_value;
|
||||
}
|
||||
else if (ce->__set
|
||||
@ -736,7 +729,7 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
|
||||
/* Okay, let's call __set. */
|
||||
zval php_ret_value;
|
||||
zend_call_method_with_2_params(&zobject, ce, &ce->__set, ZEND_SET_FUNC_NAME, &php_ret_value, &zname, &php_value);
|
||||
ret_value = zval_to_v8js(&php_ret_value, isolate TSRMLS_CC);
|
||||
ret_value = zval_to_v8js(&php_ret_value, isolate);
|
||||
zval_ptr_dtor(&php_ret_value);
|
||||
}
|
||||
}
|
||||
@ -749,27 +742,27 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> property
|
||||
const zend_object_handlers *h = object->handlers;
|
||||
|
||||
if (callback_type == V8JS_PROP_QUERY) {
|
||||
if (h->has_property(&zobject, &zname, 0, NULL TSRMLS_CC)) {
|
||||
if (h->has_property(&zobject, &zname, 0, NULL)) {
|
||||
ret_value = V8JS_UINT(v8::None);
|
||||
} else {
|
||||
ret_value = v8::Handle<v8::Value>(); // empty handle
|
||||
ret_value = v8::Local<v8::Value>(); // empty handle
|
||||
}
|
||||
} else {
|
||||
zend_property_info *property_info = zend_get_property_info(ce, Z_STR(zname), 1 TSRMLS_CC);
|
||||
zend_property_info *property_info = zend_get_property_info(ce, Z_STR(zname), 1);
|
||||
|
||||
if(!property_info ||
|
||||
(property_info != ZEND_WRONG_PROPERTY_INFO &&
|
||||
property_info->flags & ZEND_ACC_PUBLIC)) {
|
||||
h->unset_property(&zobject, &zname, NULL TSRMLS_CC);
|
||||
h->unset_property(&zobject, &zname, NULL);
|
||||
ret_value = V8JS_TRUE();
|
||||
}
|
||||
else {
|
||||
ret_value = v8::Handle<v8::Value>(); // empty handle
|
||||
ret_value = v8::Local<v8::Value>(); // empty handle
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* shouldn't reach here! but bail safely */
|
||||
ret_value = v8::Handle<v8::Value>();
|
||||
ret_value = v8::Local<v8::Value>();
|
||||
}
|
||||
|
||||
zval_ptr_dtor(&zname);
|
||||
@ -813,7 +806,7 @@ static void v8js_named_property_deleter(v8::Local<v8::String> property, const v8
|
||||
|
||||
|
||||
|
||||
static v8::Handle<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_entry *ce, zval *value TSRMLS_DC) /* {{{ */
|
||||
static v8::Local<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_entry *ce, zval *value) /* {{{ */
|
||||
{
|
||||
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
|
||||
v8::Local<v8::FunctionTemplate> new_tpl;
|
||||
@ -911,8 +904,8 @@ static v8::Handle<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_
|
||||
}
|
||||
|
||||
// Create v8 wrapper object
|
||||
v8::Handle<v8::Value> external = v8::External::New(isolate, Z_OBJ_P(value));
|
||||
v8::Handle<v8::Object> newobj = new_tpl->GetFunction()->NewInstance(1, &external);
|
||||
v8::Local<v8::Value> external = v8::External::New(isolate, Z_OBJ_P(value));
|
||||
v8::Local<v8::Object> newobj = new_tpl->GetFunction()->NewInstance(1, &external);
|
||||
|
||||
if (ce == zend_ce_closure) {
|
||||
// free uncached function template when object is freed
|
||||
@ -925,7 +918,7 @@ static v8::Handle<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_class_
|
||||
/* }}} */
|
||||
|
||||
|
||||
static v8::Handle<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zval *value TSRMLS_DC) /* {{{ */
|
||||
static v8::Local<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zval *value) /* {{{ */
|
||||
{
|
||||
int i;
|
||||
zend_string *key;
|
||||
@ -948,7 +941,7 @@ static v8::Handle<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zv
|
||||
new_tpl = v8::Local<v8::FunctionTemplate>::New(isolate, ctx->array_tmpl);
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> newobj = new_tpl->InstanceTemplate()->NewInstance();
|
||||
v8::Local<v8::Object> newobj = new_tpl->InstanceTemplate()->NewInstance();
|
||||
|
||||
HashTable *myht = HASH_OF(value);
|
||||
i = myht ? zend_hash_num_elements(myht) : 0;
|
||||
@ -1003,7 +996,7 @@ static v8::Handle<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zv
|
||||
/* }}} */
|
||||
|
||||
|
||||
v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
|
||||
v8::Local<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
HashTable *myht;
|
||||
zend_class_entry *ce = NULL;
|
||||
@ -1025,7 +1018,7 @@ v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML
|
||||
v8js_v8object *c = Z_V8JS_V8OBJECT_OBJ_P(value);
|
||||
|
||||
if(isolate != c->ctx->isolate) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "V8Function object passed to wrong V8Js instance");
|
||||
php_error_docref(NULL, E_WARNING, "V8Function object passed to wrong V8Js instance");
|
||||
return V8JS_NULL;
|
||||
}
|
||||
|
||||
@ -1034,7 +1027,7 @@ v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML
|
||||
|
||||
/* If it's a PHP object, wrap it */
|
||||
if (ce) {
|
||||
v8::Local<v8::Value> wrapped_object = v8js_wrap_object(isolate, ce, value TSRMLS_CC);
|
||||
v8::Local<v8::Value> wrapped_object = v8js_wrap_object(isolate, ce, value);
|
||||
|
||||
if (ce == zend_ce_generator) {
|
||||
/* Wrap PHP Generator object in a wrapper function that provides
|
||||
@ -1047,7 +1040,7 @@ v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRML
|
||||
|
||||
/* Associative PHP arrays cannot be wrapped to JS arrays, convert them to
|
||||
* JS objects and attach all their array keys as properties. */
|
||||
return v8js_wrap_array_to_object(isolate, value TSRMLS_CC);
|
||||
return v8js_wrap_array_to_object(isolate, value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef V8JS_OBJECT_EXPORT_H
|
||||
#define V8JS_OBJECT_EXPORT_H
|
||||
|
||||
v8::Handle<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate TSRMLS_DC);
|
||||
v8::Local<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate);
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
@ -124,7 +124,7 @@ void v8js_timer_thread(zend_v8js_globals *globals) /* {{{ */
|
||||
/* }}} */
|
||||
|
||||
|
||||
void v8js_timer_push(long time_limit, long memory_limit, v8js_ctx *c TSRMLS_DC) /* {{{ */
|
||||
void v8js_timer_push(long time_limit, long memory_limit, v8js_ctx *c) /* {{{ */
|
||||
{
|
||||
V8JSG(timer_mutex).lock();
|
||||
|
||||
|
@ -25,7 +25,7 @@ struct v8js_timer_ctx
|
||||
};
|
||||
|
||||
void v8js_timer_thread(zend_v8js_globals *globals);
|
||||
void v8js_timer_push(long time_limit, long memory_limit, v8js_ctx *c TSRMLS_DC);
|
||||
void v8js_timer_push(long time_limit, long memory_limit, v8js_ctx *c);
|
||||
|
||||
#endif /* V8JS_TIMER_H */
|
||||
|
||||
|
22
v8js_v8.cc
22
v8js_v8.cc
@ -32,7 +32,7 @@ extern "C" {
|
||||
#include <libplatform/libplatform.h>
|
||||
|
||||
|
||||
void v8js_v8_init(TSRMLS_D) /* {{{ */
|
||||
void v8js_v8_init() /* {{{ */
|
||||
{
|
||||
/* Run only once; thread-local test first */
|
||||
if (V8JSG(v8_initialized)) {
|
||||
@ -96,7 +96,7 @@ void v8js_v8_init(TSRMLS_D) /* {{{ */
|
||||
*/
|
||||
void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
long flags, long time_limit, long memory_limit,
|
||||
std::function< v8::Local<v8::Value>(v8::Isolate *) >& v8_call TSRMLS_DC) /* {{{ */
|
||||
std::function< v8::Local<v8::Value>(v8::Isolate *) >& v8_call) /* {{{ */
|
||||
{
|
||||
char *tz = NULL;
|
||||
|
||||
@ -138,7 +138,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
|
||||
/* Always pass the timer to the stack so there can be follow-up changes to
|
||||
* the time & memory limit. */
|
||||
v8js_timer_push(time_limit, memory_limit, c TSRMLS_CC);
|
||||
v8js_timer_push(time_limit, memory_limit, c);
|
||||
|
||||
/* Execute script */
|
||||
c->in_execution++;
|
||||
@ -163,7 +163,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
if (c->time_limit_hit) {
|
||||
// Execution has been terminated due to time limit
|
||||
sprintf(exception_string, "Script time limit of %lu milliseconds exceeded", time_limit);
|
||||
zend_throw_exception(php_ce_v8js_time_limit_exception, exception_string, 0 TSRMLS_CC);
|
||||
zend_throw_exception(php_ce_v8js_time_limit_exception, exception_string, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
if (c->memory_limit_hit) {
|
||||
// Execution has been terminated due to memory limit
|
||||
sprintf(exception_string, "Script memory limit of %lu bytes exceeded", memory_limit);
|
||||
zend_throw_exception(php_ce_v8js_memory_limit_exception, exception_string, 0 TSRMLS_CC);
|
||||
zend_throw_exception(php_ce_v8js_memory_limit_exception, exception_string, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
|
||||
/* There was pending exception left from earlier executions -> throw to PHP */
|
||||
if (Z_TYPE(c->pending_exception) == IS_OBJECT) {
|
||||
zend_throw_exception_object(&c->pending_exception TSRMLS_CC);
|
||||
zend_throw_exception_object(&c->pending_exception);
|
||||
ZVAL_NULL(&c->pending_exception);
|
||||
}
|
||||
|
||||
@ -208,13 +208,13 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
|
||||
/* Report immediately if report_uncaught is true */
|
||||
if (c->report_uncaught) {
|
||||
v8js_throw_script_exception(c->isolate, &try_catch TSRMLS_CC);
|
||||
v8js_throw_script_exception(c->isolate, &try_catch);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Exception thrown from JS, preserve it for future execution */
|
||||
if (result.IsEmpty()) {
|
||||
v8js_create_script_exception(&c->pending_exception, c->isolate, &try_catch TSRMLS_CC);
|
||||
v8js_create_script_exception(&c->pending_exception, c->isolate, &try_catch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
|
||||
/* Convert V8 value to PHP value */
|
||||
if (return_value && !result.IsEmpty()) {
|
||||
v8js_to_zval(result, *return_value, flags, c->isolate TSRMLS_CC);
|
||||
v8js_to_zval(result, *return_value, flags, c->isolate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ void v8js_terminate_execution(v8::Isolate *isolate) /* {{{ */
|
||||
/* }}} */
|
||||
|
||||
|
||||
int v8js_get_properties_hash(v8::Handle<v8::Value> jsValue, HashTable *retval, int flags, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
|
||||
int v8js_get_properties_hash(v8::Local<v8::Value> jsValue, HashTable *retval, int flags, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
v8::Local<v8::Object> jsObj = jsValue->ToObject();
|
||||
|
||||
@ -288,7 +288,7 @@ int v8js_get_properties_hash(v8::Handle<v8::Value> jsValue, HashTable *retval, i
|
||||
Z_ADDREF_P(&value);
|
||||
}
|
||||
else {
|
||||
if (v8js_to_zval(jsVal, &value, flags, isolate TSRMLS_CC) == FAILURE) {
|
||||
if (v8js_to_zval(jsVal, &value, flags, isolate) == FAILURE) {
|
||||
zval_ptr_dtor(&value);
|
||||
return FAILURE;
|
||||
}
|
||||
|
@ -51,14 +51,14 @@ static inline const char * ToCString(const v8::String::Utf8Value &value) /* {{{
|
||||
|
||||
|
||||
|
||||
void v8js_v8_init(TSRMLS_D);
|
||||
void v8js_v8_init();
|
||||
void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
||||
long flags, long time_limit, long memory_limit,
|
||||
std::function< v8::Local<v8::Value>(v8::Isolate *) >& v8_call TSRMLS_DC);
|
||||
std::function< v8::Local<v8::Value>(v8::Isolate *) >& v8_call);
|
||||
void v8js_terminate_execution(v8::Isolate *isolate);
|
||||
|
||||
/* Fetch V8 object properties */
|
||||
int v8js_get_properties_hash(v8::Handle<v8::Value> jsValue, HashTable *retval, int flags, v8::Isolate *isolate TSRMLS_DC);
|
||||
int v8js_get_properties_hash(v8::Local<v8::Value> jsValue, HashTable *retval, int flags, v8::Isolate *isolate);
|
||||
|
||||
#define V8JS_CTX_PROLOGUE_EX(ctx, ret) \
|
||||
if (!V8JSG(v8_initialized)) { \
|
||||
|
@ -46,7 +46,7 @@ static zend_object_handlers v8js_v8generator_handlers;
|
||||
|
||||
/* V8 Object handlers */
|
||||
|
||||
static int v8js_v8object_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot TSRMLS_DC) /* {{{ */
|
||||
static int v8js_v8object_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */
|
||||
{
|
||||
/* param has_set_exists:
|
||||
* 0 (has) whether property exists and is not NULL - isset()
|
||||
@ -58,7 +58,7 @@ static int v8js_v8object_has_property(zval *object, zval *member, int has_set_ex
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -115,14 +115,14 @@ static int v8js_v8object_has_property(zval *object, zval *member, int has_set_ex
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zval *v8js_v8object_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC) /* {{{ */
|
||||
static zval *v8js_v8object_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */
|
||||
{
|
||||
zval *retval = rv;
|
||||
v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ static zval *v8js_v8object_read_property(zval *object, zval *member, int type, v
|
||||
if (jsObj->HasRealNamedProperty(jsKey) || jsObj->HasRealNamedCallbackProperty(jsKey)) {
|
||||
jsVal = jsObj->Get(jsKey);
|
||||
|
||||
if (v8js_to_zval(jsVal, retval, obj->flags, isolate TSRMLS_CC) == SUCCESS) {
|
||||
if (v8js_to_zval(jsVal, retval, obj->flags, isolate) == SUCCESS) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@ -155,13 +155,13 @@ static zval *v8js_v8object_read_property(zval *object, zval *member, int type, v
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void v8js_v8object_write_property(zval *object, zval *member, zval *value, void **cache_slot TSRMLS_DC) /* {{{ */
|
||||
static void v8js_v8object_write_property(zval *object, zval *member, zval *value, void **cache_slot ) /* {{{ */
|
||||
{
|
||||
v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -180,13 +180,13 @@ static void v8js_v8object_write_property(zval *object, zval *member, zval *value
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void v8js_v8object_unset_property(zval *object, zval *member, void **cache_slot TSRMLS_DC) /* {{{ */
|
||||
static void v8js_v8object_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */
|
||||
{
|
||||
v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ static void v8js_v8object_unset_property(zval *object, zval *member, void **cach
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static HashTable *v8js_v8object_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
||||
static HashTable *v8js_v8object_get_properties(zval *object) /* {{{ */
|
||||
{
|
||||
v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
|
||||
|
||||
@ -230,14 +230,14 @@ static HashTable *v8js_v8object_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
V8JS_CTX_PROLOGUE_EX(obj->ctx, NULL);
|
||||
v8::Local<v8::Value> v8obj = v8::Local<v8::Value>::New(isolate, obj->v8obj);
|
||||
|
||||
if (v8js_get_properties_hash(v8obj, obj->properties, obj->flags, isolate TSRMLS_CC) == SUCCESS) {
|
||||
if (v8js_get_properties_hash(v8obj, obj->properties, obj->flags, isolate) == SUCCESS) {
|
||||
return obj->properties;
|
||||
}
|
||||
|
||||
@ -245,21 +245,21 @@ static HashTable *v8js_v8object_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static HashTable *v8js_v8object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
|
||||
static HashTable *v8js_v8object_get_debug_info(zval *object, int *is_temp) /* {{{ */
|
||||
{
|
||||
*is_temp = 0;
|
||||
return v8js_v8object_get_properties(object TSRMLS_CC);
|
||||
return v8js_v8object_get_properties(object);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_function *v8js_v8object_get_method(zend_object **object_ptr, zend_string *method, const zval *key TSRMLS_DC) /* {{{ */
|
||||
static zend_function *v8js_v8object_get_method(zend_object **object_ptr, zend_string *method, const zval *key) /* {{{ */
|
||||
{
|
||||
v8js_v8object *obj = v8js_v8object_fetch_object(*object_ptr);
|
||||
zend_function *f;
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ static int v8js_v8object_call_method(zend_string *method, zend_object *object, I
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ static int v8js_v8object_call_method(zend_string *method, zend_object *object, I
|
||||
/* std::function relies on its dtor to be executed, otherwise it leaks
|
||||
* some memory on bailout. */
|
||||
{
|
||||
std::function< v8::Local<v8::Value>(v8::Isolate *) > v8_call = [obj, method, argc, argv, object, &return_value TSRMLS_CC](v8::Isolate *isolate) {
|
||||
std::function< v8::Local<v8::Value>(v8::Isolate *) > v8_call = [obj, method, argc, argv, object, &return_value](v8::Isolate *isolate) {
|
||||
int i = 0;
|
||||
|
||||
v8::Local<v8::String> method_name = V8JS_SYML(ZSTR_VAL(method), static_cast<int>(ZSTR_LEN(method)));
|
||||
@ -346,7 +346,7 @@ static int v8js_v8object_call_method(zend_string *method, zend_object *object, I
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
new(&jsArgv[i]) v8::Local<v8::Value>;
|
||||
jsArgv[i] = v8::Local<v8::Value>::New(isolate, zval_to_v8js(&argv[i], isolate TSRMLS_CC));
|
||||
jsArgv[i] = v8::Local<v8::Value>::New(isolate, zval_to_v8js(&argv[i], isolate));
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> result = cb->Call(thisObj, argc, jsArgv);
|
||||
@ -361,7 +361,7 @@ static int v8js_v8object_call_method(zend_string *method, zend_object *object, I
|
||||
return result;
|
||||
};
|
||||
|
||||
v8js_v8_call(obj->ctx, &return_value, obj->flags, obj->ctx->time_limit, obj->ctx->memory_limit, v8_call TSRMLS_CC);
|
||||
v8js_v8_call(obj->ctx, &return_value, obj->flags, obj->ctx->time_limit, obj->ctx->memory_limit, v8_call);
|
||||
}
|
||||
|
||||
if (argc > 0) {
|
||||
@ -378,14 +378,14 @@ static int v8js_v8object_call_method(zend_string *method, zend_object *object, I
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int v8js_v8object_get_closure(zval *object, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **zobj_ptr TSRMLS_DC) /* {{{ */
|
||||
static int v8js_v8object_get_closure(zval *object, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **zobj_ptr) /* {{{ */
|
||||
{
|
||||
zend_function *invoke;
|
||||
v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
|
||||
|
||||
if (!obj->ctx) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0 TSRMLS_CC);
|
||||
"Can't access V8Object after V8Js instance is destroyed!", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ static int v8js_v8object_get_closure(zval *object, zend_class_entry **ce_ptr, ze
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void v8js_v8object_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
static void v8js_v8object_free_storage(zend_object *object) /* {{{ */
|
||||
{
|
||||
v8js_v8object *c = v8js_v8object_fetch_object(object);
|
||||
|
||||
@ -422,7 +422,7 @@ static void v8js_v8object_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
c->properties = NULL;
|
||||
}
|
||||
|
||||
zend_object_std_dtor(&c->std TSRMLS_CC);
|
||||
zend_object_std_dtor(&c->std);
|
||||
|
||||
if(c->ctx) {
|
||||
c->v8obj.Reset();
|
||||
@ -431,12 +431,12 @@ static void v8js_v8object_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_object *v8js_v8object_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */
|
||||
static zend_object *v8js_v8object_new(zend_class_entry *ce) /* {{{ */
|
||||
{
|
||||
v8js_v8object *c;
|
||||
c = (v8js_v8object *) ecalloc(1, sizeof(v8js_v8object) + zend_object_properties_size(ce));
|
||||
|
||||
zend_object_std_init(&c->std, ce TSRMLS_CC);
|
||||
zend_object_std_init(&c->std, ce);
|
||||
c->std.handlers = &v8js_v8object_handlers;
|
||||
new(&c->v8obj) v8::Persistent<v8::Value>();
|
||||
|
||||
@ -454,7 +454,7 @@ static zend_object *v8js_v8object_new(zend_class_entry *ce TSRMLS_DC) /* {{{ */
|
||||
PHP_METHOD(V8Object,__construct)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
|
||||
"Can't directly construct V8 objects!", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -464,7 +464,7 @@ PHP_METHOD(V8Object,__construct)
|
||||
PHP_METHOD(V8Object, __sleep)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Object instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Object instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -474,7 +474,7 @@ PHP_METHOD(V8Object, __sleep)
|
||||
PHP_METHOD(V8Object, __wakeup)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Object instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Object instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -484,7 +484,7 @@ PHP_METHOD(V8Object, __wakeup)
|
||||
PHP_METHOD(V8Function,__construct)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
|
||||
"Can't directly construct V8 objects!", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -494,7 +494,7 @@ PHP_METHOD(V8Function,__construct)
|
||||
PHP_METHOD(V8Function, __sleep)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Function instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Function instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -504,7 +504,7 @@ PHP_METHOD(V8Function, __sleep)
|
||||
PHP_METHOD(V8Function, __wakeup)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Function instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Function instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -601,7 +601,7 @@ static zend_function *v8js_v8generator_get_method(zend_object **object_ptr, zend
|
||||
PHP_METHOD(V8Generator,__construct)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"Can't directly construct V8 objects!", 0 TSRMLS_CC);
|
||||
"Can't directly construct V8 objects!", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -611,7 +611,7 @@ PHP_METHOD(V8Generator,__construct)
|
||||
PHP_METHOD(V8Generator, __sleep)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Generator instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Generator instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -621,7 +621,7 @@ PHP_METHOD(V8Generator, __sleep)
|
||||
PHP_METHOD(V8Generator, __wakeup)
|
||||
{
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"You cannot serialize or unserialize V8Generator instances", 0 TSRMLS_CC);
|
||||
"You cannot serialize or unserialize V8Generator instances", 0);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
@ -665,7 +665,7 @@ PHP_METHOD(V8Generator, rewind)
|
||||
|
||||
if(g->primed) {
|
||||
zend_throw_exception(php_ce_v8js_exception,
|
||||
"V8Generator::rewind not supported by ES6", 0 TSRMLS_CC);
|
||||
"V8Generator::rewind not supported by ES6", 0);
|
||||
|
||||
}
|
||||
|
||||
@ -688,7 +688,7 @@ PHP_METHOD(V8Generator, valid)
|
||||
/* }}} */
|
||||
|
||||
|
||||
void v8js_v8object_create(zval *res, v8::Handle<v8::Value> value, int flags, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
|
||||
void v8js_v8object_create(zval *res, v8::Local<v8::Value> value, int flags, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
|
||||
|
||||
@ -766,19 +766,19 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
|
||||
|
||||
/* V8Object Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8Object", v8js_v8object_methods);
|
||||
php_ce_v8object = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
php_ce_v8object = zend_register_internal_class(&ce);
|
||||
php_ce_v8object->ce_flags |= ZEND_ACC_FINAL;
|
||||
php_ce_v8object->create_object = v8js_v8object_new;
|
||||
|
||||
/* V8Function Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8Function", v8js_v8function_methods);
|
||||
php_ce_v8function = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
php_ce_v8function = zend_register_internal_class(&ce);
|
||||
php_ce_v8function->ce_flags |= ZEND_ACC_FINAL;
|
||||
php_ce_v8function->create_object = v8js_v8object_new;
|
||||
|
||||
/* V8Generator Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8Generator", v8js_v8generator_methods);
|
||||
php_ce_v8generator = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
php_ce_v8generator = zend_register_internal_class(&ce);
|
||||
php_ce_v8generator->ce_flags |= ZEND_ACC_FINAL;
|
||||
php_ce_v8generator->create_object = v8js_v8generator_new;
|
||||
|
||||
|
@ -28,7 +28,7 @@ extern zend_class_entry *php_ce_v8object;
|
||||
extern zend_class_entry *php_ce_v8function;
|
||||
|
||||
/* Create PHP V8 object */
|
||||
void v8js_v8object_create(zval *, v8::Handle<v8::Value>, int, v8::Isolate * TSRMLS_DC);
|
||||
void v8js_v8object_create(zval *, v8::Local<v8::Value>, int, v8::Isolate *);
|
||||
|
||||
static inline v8js_v8object *v8js_v8object_fetch_object(zend_object *obj) {
|
||||
return (v8js_v8object *)((char *)obj - XtOffsetOf(struct v8js_v8object, std));
|
||||
|
@ -27,30 +27,28 @@ extern "C" {
|
||||
|
||||
static void v8js_fetch_php_variable(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) /* {{{ */
|
||||
{
|
||||
v8::Handle<v8::External> data = v8::Handle<v8::External>::Cast(info.Data());
|
||||
v8::Local<v8::External> data = v8::Local<v8::External>::Cast(info.Data());
|
||||
v8js_accessor_ctx *ctx = static_cast<v8js_accessor_ctx *>(data->Value());
|
||||
v8::Isolate *isolate = ctx->isolate;
|
||||
zval *variable;
|
||||
|
||||
V8JS_TSRMLS_FETCH();
|
||||
|
||||
zend_is_auto_global(ctx->variable_name TSRMLS_CC);
|
||||
zend_is_auto_global(ctx->variable_name);
|
||||
|
||||
if ((variable = zend_hash_find(&EG(symbol_table), ctx->variable_name))) {
|
||||
info.GetReturnValue().Set(zval_to_v8js(variable, isolate TSRMLS_CC));
|
||||
info.GetReturnValue().Set(zval_to_v8js(variable, isolate));
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void v8js_accessor_ctx_dtor(v8js_accessor_ctx *ctx TSRMLS_DC) /* {{{ */
|
||||
void v8js_accessor_ctx_dtor(v8js_accessor_ctx *ctx) /* {{{ */
|
||||
{
|
||||
zend_string_release(ctx->variable_name);
|
||||
efree(ctx);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8::Local<v8::FunctionTemplate> php_obj_t, zval *array, v8::Isolate *isolate TSRMLS_DC) /* {{{ */
|
||||
void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8::Local<v8::FunctionTemplate> php_obj_t, zval *array, v8::Isolate *isolate) /* {{{ */
|
||||
{
|
||||
zend_string *property_name;
|
||||
zval *item;
|
||||
|
Loading…
Reference in New Issue
Block a user