0
0
mirror of https://github.com/phpv8/v8js.git synced 2025-01-05 14:01:53 +00:00

PHP 7.3 Compatibility

This commit is contained in:
Jan-E 2018-07-04 00:29:00 +02:00
parent 6fc0c216d8
commit 997df065d3
5 changed files with 30 additions and 5 deletions

View File

@ -166,6 +166,13 @@ extern struct _v8js_process_globals v8js_process_globals;
/* Register builtin methods into passed object */
void v8js_register_methods(v8::Local<v8::ObjectTemplate>, v8js_ctx *c);
#ifdef ZEND_HASH_INC_APPLY_COUNT
# define GC_PROTECT_RECURSION(ht) ZEND_HASH_INC_APPLY_COUNT(ht)
#endif
#ifdef ZEND_HASH_DEC_APPLY_COUNT
# define GC_UNPROTECT_RECURSION(ht) ZEND_HASH_DEC_APPLY_COUNT(ht)
#endif
#endif /* PHP_V8JS_MACROS_H */
/*

View File

@ -70,7 +70,11 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
v8::Local<v8::Array> newarr;
/* Prevent recursion */
#if PHP_VERSION_ID >= 70300
if (myht && GC_IS_RECURSIVE(myht)) {
#else
if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 1) {
#endif
return V8JS_NULL;
}
@ -86,13 +90,13 @@ static v8::Local<v8::Value> v8js_hash_to_jsarr(zval *value, v8::Isolate *isolate
tmp_ht = HASH_OF(data);
if (tmp_ht) {
ZEND_HASH_INC_APPLY_COUNT(myht);
GC_PROTECT_RECURSION(myht);
}
newarr->Set(index++, zval_to_v8js(data, isolate));
if (tmp_ht) {
ZEND_HASH_DEC_APPLY_COUNT(myht);
GC_UNPROTECT_RECURSION(myht);
}
} ZEND_HASH_FOREACH_END();
}

View File

@ -88,7 +88,11 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8::
zend_class_entry *exception_ce = zend_exception_get_default();
if (instanceof_function(php_exception->ce, exception_ce)) {
#ifdef GC_ADDREF
GC_ADDREF(php_exception);
#else
++GC_REFCOUNT(php_exception);
#endif
zend_exception_set_previous(Z_OBJ_P(return_value), php_exception);
}
}

View File

@ -137,7 +137,9 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v
zend_try {
/* zend_fcall_info_cache */
#if PHP_VERSION_ID < 70300
fcc.initialized = 1;
#endif
fcc.function_handler = method_ptr;
fcc.calling_scope = object->ce;
fcc.called_scope = object->ce;
@ -959,14 +961,14 @@ static v8::Local<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zva
tmp_ht = HASH_OF(data);
if (tmp_ht) {
ZEND_HASH_INC_APPLY_COUNT(tmp_ht);
GC_PROTECT_RECURSION(tmp_ht);
}
if (key) {
if (ZSTR_VAL(key)[0] == '\0' && Z_TYPE_P(value) == IS_OBJECT) {
/* Skip protected and private members. */
if (tmp_ht) {
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
GC_UNPROTECT_RECURSION(tmp_ht);
}
continue;
}
@ -990,7 +992,7 @@ static v8::Local<v8::Object> v8js_wrap_array_to_object(v8::Isolate *isolate, zva
}
if (tmp_ht) {
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
GC_UNPROTECT_RECURSION(tmp_ht);
}
} ZEND_HASH_FOREACH_END();
}
@ -1013,7 +1015,11 @@ v8::Local<v8::Value> v8js_hash_to_jsobj(zval *value, v8::Isolate *isolate) /* {{
}
/* Prevent recursion */
#if PHP_VERSION_ID >= 70300
if (myht && GC_IS_RECURSIVE(myht)) {
#else
if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 1) {
#endif
return V8JS_NULL;
}

View File

@ -210,7 +210,11 @@ static HashTable *v8js_v8object_get_properties(zval *object) /* {{{ */
v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
if (obj->properties == NULL) {
#if PHP_VERSION_ID >= 70300
if (zend_gc_collect_cycles()) {
#else
if (GC_G(gc_active)) {
#endif
/* the garbage collector is running, don't create more zvals */
return NULL;
}