0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 08:11:52 +00:00

make it compile on PHP 7.3 and 7.4

This commit is contained in:
Stefan Siegl 2020-04-03 10:00:27 +02:00
parent 83c215d4b1
commit e153ff1651
No known key found for this signature in database
GPG Key ID: 73942AF5642F3DDA
4 changed files with 25 additions and 17 deletions

View File

@ -29,16 +29,17 @@
#include <mutex>
#include <cmath>
#if PHP_VERSION_ID < 70400 && !defined(isnan)
/* php.h requires the isnan() macro, which is removed by c++ <cmath> header,
* work around: re-define the macro to std::isnan function */
#define isnan(a) std::isnan(a)
/* likewise isfinite */
#define isfinite(a) std::isfinite(a)
#endif
extern "C" {
#include "php_config.h"
/* work around incompatibilities regarding isnan() and isfinite() macros,
* affecting PHP versions before 7.4. */
#undef HAVE_DECL_ISFINITE
#undef HAVE_DECL_ISNAN
#define HAVE_DECL_ISFINITE 0
#define HAVE_DECL_ISNAN 0
#include "php.h"
#include "php_v8js.h"
}

View File

@ -1307,10 +1307,10 @@ const zend_function_entry v8js_methods[] = { /* {{{ */
/* V8Js object handlers */
static zval* v8js_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
static SINCE74(zval*, void) v8js_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
{
v8js_ctx *c = Z_V8JS_CTX_OBJ_P(object);
V8JS_CTX_PROLOGUE_EX(c, value);
V8JS_CTX_PROLOGUE_EX(c, SINCE74(value,));
/* 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);
@ -1324,7 +1324,7 @@ static zval* v8js_write_property(zval *object, zval *member, zval *value, void *
if (Z_STRLEN_P(member) > std::numeric_limits<int>::max()) {
zend_throw_exception(php_ce_v8js_exception,
"Property name exceeds maximum supported length", 0);
return value;
return SINCE74(value,);
}
/* Write value to PHP JS object */
@ -1333,7 +1333,7 @@ static zval* v8js_write_property(zval *object, zval *member, zval *value, void *
}
/* Write value to PHP object */
return std_object_handlers.write_property(object, member, value, NULL);
SINCE74(return,) std_object_handlers.write_property(object, member, value, NULL);
}
/* }}} */

View File

@ -83,6 +83,13 @@ int v8js_get_properties_hash(v8::Local<v8::Value> jsValue, HashTable *retval, in
V8JS_CTX_PROLOGUE(ctx);
#if PHP_VERSION_ID < 70400
#define SINCE74(x,y) y
#else
#define SINCE74(x,y) x
#endif
#endif /* V8JS_V8_H */
/*

View File

@ -167,23 +167,23 @@ static zval *v8js_v8object_get_property_ptr_ptr(zval *object, zval *member, int
}
/* }}} */
static zval *v8js_v8object_write_property(zval *object, zval *member, zval *value, void **cache_slot ) /* {{{ */
static SINCE74(zval*, 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);
return value;
return SINCE74(value,);
}
V8JS_CTX_PROLOGUE_EX(obj->ctx, value);
V8JS_CTX_PROLOGUE_EX(obj->ctx, SINCE74(value,));
v8::Local<v8::Value> v8objHandle = v8::Local<v8::Value>::New(isolate, obj->v8obj);
if (Z_STRLEN_P(member) > std::numeric_limits<int>::max()) {
zend_throw_exception(php_ce_v8js_exception,
"Member name length exceeds maximum supported length", 0);
return value;
return SINCE74(value,);
}
v8::Local<v8::Object> v8obj;
@ -191,7 +191,7 @@ static zval *v8js_v8object_write_property(zval *object, zval *member, zval *valu
v8obj->CreateDataProperty(v8_context, V8JS_ZSYM(Z_STR_P(member)), zval_to_v8js(value, isolate));
}
return value;
return SINCE74(value,);
}
/* }}} */