mirror of
https://github.com/phpv8/v8js.git
synced 2025-01-03 11:21:51 +00:00
Store flags in v8js_ctx class instead of v8 hidden value
This commit is contained in:
parent
187b97060f
commit
f7a592052f
@ -80,10 +80,6 @@ extern "C" {
|
|||||||
# define V8JS_CONST (char *)
|
# define V8JS_CONST (char *)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Global flags */
|
|
||||||
#define V8JS_GLOBAL_SET_FLAGS(isolate,flags) V8JS_GLOBAL(isolate)->SetHiddenValue(V8JS_SYM("__php_flags__"), V8JS_INT(flags))
|
|
||||||
#define V8JS_GLOBAL_GET_FLAGS(isolate) V8JS_GLOBAL(isolate)->GetHiddenValue(V8JS_SYM("__php_flags__"))->IntegerValue();
|
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
#define V8JS_FLAG_NONE (1<<0)
|
#define V8JS_FLAG_NONE (1<<0)
|
||||||
#define V8JS_FLAG_FORCE_ARRAY (1<<1)
|
#define V8JS_FLAG_FORCE_ARRAY (1<<1)
|
||||||
|
@ -40,6 +40,8 @@ struct v8js_ctx {
|
|||||||
int in_execution;
|
int in_execution;
|
||||||
v8::Isolate *isolate;
|
v8::Isolate *isolate;
|
||||||
|
|
||||||
|
long flags;
|
||||||
|
|
||||||
long time_limit;
|
long time_limit;
|
||||||
bool time_limit_hit;
|
bool time_limit_hit;
|
||||||
long memory_limit;
|
long memory_limit;
|
||||||
|
@ -39,7 +39,7 @@ static void v8js_call_php_func(zval *value, zend_class_entry *ce, zend_function
|
|||||||
zval fname, *retval_ptr = NULL, **argv = NULL;
|
zval fname, *retval_ptr = NULL, **argv = NULL;
|
||||||
zend_uint argc = info.Length(), min_num_args = 0, max_num_args = 0;
|
zend_uint argc = info.Length(), min_num_args = 0, max_num_args = 0;
|
||||||
char *error;
|
char *error;
|
||||||
int error_len, i, flags = V8JS_FLAG_NONE;
|
int error_len, i;
|
||||||
|
|
||||||
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
|
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
|
||||||
|
|
||||||
@ -84,7 +84,6 @@ static void v8js_call_php_func(zval *value, zend_class_entry *ce, zend_function
|
|||||||
|
|
||||||
/* Convert parameters passed from V8 */
|
/* Convert parameters passed from V8 */
|
||||||
if (argc) {
|
if (argc) {
|
||||||
flags = V8JS_GLOBAL_GET_FLAGS(isolate);
|
|
||||||
fci.params = (zval ***) safe_emalloc(argc, sizeof(zval **), 0);
|
fci.params = (zval ***) safe_emalloc(argc, sizeof(zval **), 0);
|
||||||
argv = (zval **) safe_emalloc(argc, sizeof(zval *), 0);
|
argv = (zval **) safe_emalloc(argc, sizeof(zval *), 0);
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
@ -98,7 +97,7 @@ static void v8js_call_php_func(zval *value, zend_class_entry *ce, zend_function
|
|||||||
Z_ADDREF_P(argv[i]);
|
Z_ADDREF_P(argv[i]);
|
||||||
} else {
|
} else {
|
||||||
MAKE_STD_ZVAL(argv[i]);
|
MAKE_STD_ZVAL(argv[i]);
|
||||||
if (v8js_to_zval(info[i], argv[i], flags, isolate TSRMLS_CC) == FAILURE) {
|
if (v8js_to_zval(info[i], argv[i], ctx->flags, isolate TSRMLS_CC) == FAILURE) {
|
||||||
fci.param_count++;
|
fci.param_count++;
|
||||||
error_len = spprintf(&error, 0, "converting parameter #%d passed to %s() failed", i + 1, method_ptr->common.function_name);
|
error_len = spprintf(&error, 0, "converting parameter #%d passed to %s() failed", i + 1, method_ptr->common.function_name);
|
||||||
return_value = V8JS_THROW(isolate, Error, error, error_len);
|
return_value = V8JS_THROW(isolate, Error, error, error_len);
|
||||||
@ -529,6 +528,8 @@ inline v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> p
|
|||||||
const char *method_name;
|
const char *method_name;
|
||||||
uint method_name_len;
|
uint method_name_len;
|
||||||
|
|
||||||
|
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
|
||||||
|
|
||||||
v8::Local<v8::Object> self = info.Holder();
|
v8::Local<v8::Object> self = info.Holder();
|
||||||
v8::Local<v8::Value> ret_value;
|
v8::Local<v8::Value> ret_value;
|
||||||
v8::Local<v8::Function> cb;
|
v8::Local<v8::Function> cb;
|
||||||
@ -652,9 +653,8 @@ inline v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> p
|
|||||||
zval_ptr_dtor(&php_value);
|
zval_ptr_dtor(&php_value);
|
||||||
}
|
}
|
||||||
} else if (callback_type == V8JS_PROP_SETTER) {
|
} else if (callback_type == V8JS_PROP_SETTER) {
|
||||||
int flags = V8JS_GLOBAL_GET_FLAGS(isolate);
|
|
||||||
MAKE_STD_ZVAL(php_value);
|
MAKE_STD_ZVAL(php_value);
|
||||||
if (v8js_to_zval(set_value, php_value, flags, isolate TSRMLS_CC) != SUCCESS) {
|
if (v8js_to_zval(set_value, php_value, ctx->flags, isolate TSRMLS_CC) != SUCCESS) {
|
||||||
ret_value = v8::Handle<v8::Value>();
|
ret_value = v8::Handle<v8::Value>();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -77,7 +77,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
|
|||||||
v8::TryCatch try_catch;
|
v8::TryCatch try_catch;
|
||||||
|
|
||||||
/* Set flags for runtime use */
|
/* Set flags for runtime use */
|
||||||
V8JS_GLOBAL_SET_FLAGS(isolate, flags);
|
c->flags = flags;
|
||||||
|
|
||||||
/* Check if timezone has been changed and notify V8 */
|
/* Check if timezone has been changed and notify V8 */
|
||||||
tz = getenv("TZ");
|
tz = getenv("TZ");
|
||||||
|
Loading…
Reference in New Issue
Block a user