0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 00:25:18 +00:00

Store flags in v8js_ctx class instead of v8 hidden value

This commit is contained in:
Stefan Siegl 2015-08-21 16:12:12 +02:00
parent 187b97060f
commit f7a592052f
4 changed files with 8 additions and 10 deletions

View File

@ -80,10 +80,6 @@ extern "C" {
# define V8JS_CONST (char *)
#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 */
#define V8JS_FLAG_NONE (1<<0)
#define V8JS_FLAG_FORCE_ARRAY (1<<1)

View File

@ -40,6 +40,8 @@ struct v8js_ctx {
int in_execution;
v8::Isolate *isolate;
long flags;
long time_limit;
bool time_limit_hit;
long memory_limit;

View File

@ -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;
zend_uint argc = info.Length(), min_num_args = 0, max_num_args = 0;
char *error;
int error_len, i, flags = V8JS_FLAG_NONE;
int error_len, i;
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 */
if (argc) {
flags = V8JS_GLOBAL_GET_FLAGS(isolate);
fci.params = (zval ***) safe_emalloc(argc, sizeof(zval **), 0);
argv = (zval **) safe_emalloc(argc, sizeof(zval *), 0);
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]);
} else {
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++;
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);
@ -529,6 +528,8 @@ inline v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::String> p
const char *method_name;
uint method_name_len;
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
v8::Local<v8::Object> self = info.Holder();
v8::Local<v8::Value> ret_value;
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);
}
} else if (callback_type == V8JS_PROP_SETTER) {
int flags = V8JS_GLOBAL_GET_FLAGS(isolate);
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>();
}
else {

View File

@ -77,7 +77,7 @@ void v8js_v8_call(v8js_ctx *c, zval **return_value,
v8::TryCatch try_catch;
/* Set flags for runtime use */
V8JS_GLOBAL_SET_FLAGS(isolate, flags);
c->flags = flags;
/* Check if timezone has been changed and notify V8 */
tz = getenv("TZ");