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

Merge pull request #440 from stesie/php-7.4-support

PHP 7.4 support
This commit is contained in:
Stefan Siegl 2020-04-03 15:33:33 +02:00 committed by GitHub
commit c03cb4b345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 421 additions and 599 deletions

46
.dockerignore Normal file
View File

@ -0,0 +1,46 @@
*.lo
*.o
.deps
.libs
Dockerfile.tmp
Makefile
Makefile.fragments
Makefile.global
Makefile.objects
acinclude.m4
aclocal.m4
autom4te.cache/*
build/*
config.guess
config.h
config.h.in
*.log
config.nice
config.status
config.sub
configure
configure.in
configure.ac
*~
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
modules/*
v8js.la
v8js-*.tgz
run-tests.php
.*.sw[poq]
tests/*.diff
tests/*.exp
tests/*.out
tests/*.php
tests/*.sh
tests/*.mem
.vagrant
tmp-php.ini
coverage_report/**

22
Dockerfile.jenkins Normal file
View File

@ -0,0 +1,22 @@
ARG V8VER
FROM stesie/libv8-${V8VER}:latest
ARG PHPVER
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
ENV NO_INTERACTION=1
ENV REPORT_EXIT_STATUS=1
RUN apt-get update -q
RUN apt-get install -y wget autoconf build-essential libreadline-dev pkg-config
RUN wget https://www.php.net/distributions/php-${PHPVER}.tar.gz && \
tar xzf php-${PHPVER}.tar.gz
ADD . /php-${PHPVER}/ext/v8js
WORKDIR /php-${PHPVER}
RUN ./buildconf --force
RUN ./configure --disable-all --with-readline --enable-cli --enable-json --enable-maintainer-zts --with-v8js=/opt/libv8-$V8VER/ CFLAGS="-fsanitize=address -g -O0" CXXFLAGS="-fsanitize=address -g -O0"
RUN sed -e "s/^EXTRA_LIBS.*/& -lv8_libplatform -ldl/" -i Makefile
RUN make -j5

34
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,34 @@
pipeline {
agent none
stages {
stage('BuildAndTest') {
matrix {
agent any
axes {
axis {
name 'PHPVER'
values '7.3.16', '7.4.4'
}
axis {
name 'V8VER'
values '7.9'
}
}
stages {
stage('Build') {
steps {
echo "Building w/ V8 ${V8VER}, PHP ${PHPVER} as Docker image ${BUILD_TAG}-${V8VER}-${PHPVER}"
sh "docker build -f Dockerfile.jenkins --build-arg V8VER=${V8VER} --build-arg PHPVER=${PHPVER} -t ${BUILD_TAG}-${V8VER}-${PHPVER} ."
}
}
stage('Test') {
steps {
echo "Running test on ${BUILD_TAG}-${V8VER}-${PHPVER}"
sh "docker run --rm -t ${BUILD_TAG}-${V8VER}-${PHPVER} make test TESTS='ext/v8js/tests/*.phpt'"
}
}
}
}
}
}
}

24
Vagrantfile vendored
View File

@ -77,6 +77,30 @@ Vagrant.configure("2") do |config|
end end
} }
config.vm.define "php-7.4" do |i|
i.vm.synced_folder ".", "/data/v8js"
i.vm.provision "shell", inline: <<-SHELL
gpg --keyserver keys.gnupg.net --recv 7F438280EF8D349F
gpg --armor --export 7F438280EF8D349F | apt-key add -
apt-get update
apt-get install -y software-properties-common gdb tmux git tig curl apache2-utils lcov
add-apt-repository ppa:stesie/libv8
apt-get update
apt-get install -y libv8-7.5-dbg libv8-7.5-dev
test -x /tmp/php-src || git clone https://github.com/php/php-src.git /tmp/php-src -b PHP-7.4 --depth 1
cd /tmp/php-src
apt-get install -y build-essential bison re2c libreadline-dev
./buildconf
./configure --disable-all --with-readline
make -j4
make install
SHELL
end
config.vm.provision "shell", privileged: false, inline: <<-SHELL config.vm.provision "shell", privileged: false, inline: <<-SHELL
sudo mkdir -p /data/build && sudo chown $USER:$USER /data/build sudo mkdir -p /data/build && sudo chown $USER:$USER /data/build
SHELL SHELL

View File

@ -29,16 +29,17 @@
#include <mutex> #include <mutex>
#include <cmath> #include <cmath>
#ifndef 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" { 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.h"
#include "php_v8js.h" #include "php_v8js.h"
} }

View File

@ -54,22 +54,22 @@ try {
?> ?>
===EOF=== ===EOF===
--EXPECTF-- --EXPECTREGEX--
Warning: Creating default object from empty value in %s%eissue_250_001.php on line 9 (?:Warning\: Creating default object from empty value in [^\r\n]+\/issue_250_001\.php on line 9\s*)+
object(TestObject)#%d (3) { object\(TestObject\)\#\d+ \(3\) \{
["data":"TestObject":private]=> \["data"\:"TestObject"\:private\]\=\>
object(V8Object)#%d (0) { object\(V8Object\)\#\d+ \(0\) \{
} \}
["meta":"TestObject":private]=> \["meta"\:"TestObject"\:private\]\=\>
array(0) { array\(0\) \{
} \}
["a"]=> \["a"\]\=\>
object(stdClass)#%d (1) { object\(stdClass\)\#\d+ \(1\) \{
["b"]=> \["b"\]\=\>
object(stdClass)#%d (1) { object\(stdClass\)\#\d+ \(1\) \{
["title"]=> \["title"\]\=\>
string(4) "ouch" string\(4\) "ouch"
} \}
} \}
} \}
===EOF=== \=\=\=EOF\=\=\=

View File

@ -1,10 +1,7 @@
--TEST-- --TEST--
Test V8::executeString() : var_dump Test V8::executeString() : var_dump
--SKIPIF-- --SKIPIF--
<?php <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
require_once(dirname(__FILE__) . '/skipif.inc');
if (PHP_VERSION_ID >= 70300) die('skip Only for php version < 7.3');
?>
--INI-- --INI--
date.timezone=UTC date.timezone=UTC
--FILE-- --FILE--
@ -73,246 +70,250 @@ try {
} }
?> ?>
===EOF=== ===EOF===
--EXPECTF-- --EXPECTREGEX--
---- PHP var_dump of PHP object ---- \-\-\-\- PHP var_dump of PHP object \-\-\-\-
array(11) { array\(11\) \{
["null"]=> \["null"\]\=\>
NULL NULL
["bool"]=> \["bool"\]\=\>
bool(true) bool\(true\)
["string"]=> \["string"\]\=\>
string(6) "string" string\(6\) "string"
["uint"]=> \["uint"\]\=\>
int(1) int\(1\)
["int"]=> \["int"\]\=\>
int(-1) int\(\-1\)
["number"]=> \["number"\]\=\>
float(3.141592654) float\(3\.141592654\)
["date"]=> \["date"\]\=\>
object(DateTime)#%d (3) { object\(DateTime\)\#\d+ \(3\) \{
["date"]=> \["date"\]\=\>
string(%d) "1976-09-27 09:00:00%r(\.0+)?%r" string\(\d+\) "1976\-09\-27 09\:00\:00((\.0+)?)"
["timezone_type"]=> \["timezone_type"\]\=\>
int(3) int\(3\)
["timezone"]=> \["timezone"\]\=\>
string(3) "UTC" string\(3\) "UTC"
} \}
["array"]=> \["array"\]\=\>
array(3) { array\(3\) \{
[0]=> \[0\]\=\>
int(1) int\(1\)
[1]=> \[1\]\=\>
int(2) int\(2\)
[2]=> \[2\]\=\>
int(3) int\(3\)
} \}
["object"]=> \["object"\]\=\>
array(1) { array\(1\) \{
["field"]=> \["field"\]\=\>
string(3) "foo" string\(3\) "foo"
} \}
["function"]=> \["function"\]\=\>
object(Closure)#%d (1) { object\(Closure\)\#\d+ \(1\) \{
["parameter"]=> \["parameter"\]\=\>
array(1) { array\(1\) \{
["$x"]=> \["\$x"\]\=\>
string(10) "<required>" string\(10\) "\<required\>"
} \}
} \}
["phpobject"]=> \["phpobject"\]\=\>
object(Foo)#%d (1) { object\(Foo\)\#\d+ \(1\) \{
["field"]=> \["field"\]\=\>
string(3) "php" string\(3\) "php"
} \}
} \}
--- JS var_dump of PHP object ---- \-\-\- JS var_dump of PHP object \-\-\-\-
array (11) { array \(11\) \{
["null"] => \["null"\] \=\>
NULL NULL
["bool"] => \["bool"\] \=\>
bool(true) bool\(true\)
["string"] => \["string"\] \=\>
string(6) "string" string\(6\) "string"
["uint"] => \["uint"\] \=\>
int(1) int\(1\)
["int"] => \["int"\] \=\>
int(-1) int\(\-1\)
["number"] => \["number"\] \=\>
float(3.141593) float\(3\.141593\)
["date"] => \["date"\] \=\>
object(DateTime)#%d (18) { object\(DateTime\)\#\d+ \(\d+\) \{(?:
["createFromFormat"] => \["createFromImmutable"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \})?
["getLastErrors"] => \["createFromFormat"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["format"] => \["getLastErrors"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["modify"] => \["format"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["add"] => \["modify"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["sub"] => \["add"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["getTimezone"] => \["sub"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["setTimezone"] => \["getTimezone"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["getOffset"] => \["setTimezone"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["setTime"] => \["getOffset"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["setDate"] => \["setTime"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["setISODate"] => \["setDate"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["setTimestamp"] => \["setISODate"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["getTimestamp"] => \["setTimestamp"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["diff"] => \["getTimestamp"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function () { [native code] } function \(\) \{ \[native code\] \}
} \}
["$date"] => \["diff"\] \=\>
string(%d) "1976-09-27 09:00:00%r(\.0+)?%r" object\(Closure\)\#\d+ \{
["$timezone_type"] => function \(\) \{ \[native code\] \}
int(3) \}(?:(?:the following block is missing from PHP 7.4 on){0}
["$timezone"] => \["\$date"\] \=\>
string(3) "UTC" string\(\d+\) "1976\-09\-27 09\:00\:00((\.0+)?)"
} \["\$timezone_type"\] \=\>
["array"] => int\(3\)
array(3) { \["\$timezone"\] \=\>
[0] => string\(3\) "UTC"
int(1) )?\s*\}
[1] => \["array"\] \=\>
int(2) array\(3\) \{
[2] => \[0\] \=\>
int(3) int\(1\)
} \[1\] \=\>
["object"] => int\(2\)
array (1) { \[2\] \=\>
["field"] => int\(3\)
string(3) "foo" \}
} \["object"\] \=\>
["function"] => array \(1\) \{
object(Closure)#%d (0) { \["field"\] \=\>
} string\(3\) "foo"
["phpobject"] => \}
object(Foo)#%d (1) { \["function"\] \=\>
["$field"] => object\(Closure\)\#\d+ \(0\) \{
string(3) "php" \}
} \["phpobject"\] \=\>
} object\(Foo\)\#\d+ \(1\) \{
--- JS var_dump of JS object ---- \["\$field"\] \=\>
object(Object)#%d (12) { string\(3\) "php"
["undefined"] => \}
\}
\-\-\- JS var_dump of JS object \-\-\-\-
object\(Object\)\#\d+ \(12\) \{
\["undefined"\] \=\>
NULL NULL
["null"] => \["null"\] \=\>
NULL NULL
["bool"] => \["bool"\] \=\>
bool(true) bool\(true\)
["string"] => \["string"\] \=\>
string(6) "string" string\(6\) "string"
["uint"] => \["uint"\] \=\>
int(1) int\(1\)
["int"] => \["int"\] \=\>
int(-1) int\(\-1\)
["number"] => \["number"\] \=\>
float(3.141593) float\(3\.141593\)
["regexp"] => \["regexp"\] \=\>
regexp(/regexp/) regexp\(\/regexp\/\)
["array"] => \["array"\] \=\>
array(3) { array\(3\) \{
[0] => \[0\] \=\>
int(1) int\(1\)
[1] => \[1\] \=\>
int(2) int\(2\)
[2] => \[2\] \=\>
int(3) int\(3\)
} \}
["object"] => \["object"\] \=\>
object(Object)#%d (1) { object\(Object\)\#\d+ \(1\) \{
["field"] => \["field"\] \=\>
string(3) "foo" string\(3\) "foo"
} \}
["function"] => \["function"\] \=\>
object(Closure)#%d { object\(Closure\)\#\d+ \{
function id(x) { return x; } function id\(x\) \{ return x; \}
} \}
["phpobject"] => \["phpobject"\] \=\>
object(Foo)#%d (1) { object\(Foo\)\#\d+ \(1\) \{
["$field"] => \["\$field"\] \=\>
string(3) "php" string\(3\) "php"
} \}
} \}
--- PHP var_dump of JS object ---- \-\-\- PHP var_dump of JS object \-\-\-\-
object(V8Object)#%d (12) { object\(V8Object\)\#\d+ \(12\) \{
["undefined"]=> \["undefined"\]\=\>
NULL NULL
["null"]=> \["null"\]\=\>
NULL NULL
["bool"]=> \["bool"\]\=\>
bool(true) bool\(true\)
["string"]=> \["string"\]\=\>
string(6) "string" string\(6\) "string"
["uint"]=> \["uint"\]\=\>
int(1) int\(1\)
["int"]=> \["int"\]\=\>
int(-1) int\(\-1\)
["number"]=> \["number"\]\=\>
float(3.141592654) float\(3\.141592654\)
["regexp"]=> \["regexp"\]\=\>
object(V8Object)#%d (0) { object\(V8Object\)\#\d+ \(0\) \{
} \}
["array"]=> \["array"\]\=\>
array(3) { array\(3\) \{
[0]=> \[0\]\=\>
int(1) int\(1\)
[1]=> \[1\]\=\>
int(2) int\(2\)
[2]=> \[2\]\=\>
int(3) int\(3\)
} \}
["object"]=> \["object"\]\=\>
object(V8Object)#%d (1) { object\(V8Object\)\#\d+ \(1\) \{
["field"]=> \["field"\]\=\>
string(3) "foo" string\(3\) "foo"
} \}
["function"]=> \["function"\]\=\>
object(V8Function)#%d (0) { object\(V8Function\)\#\d+ \(0\) \{
} \}
["phpobject"]=> \["phpobject"\]\=\>
object(Foo)#%d (1) { object\(Foo\)\#\d+ \(1\) \{
["field"]=> \["field"\]\=\>
string(3) "php" string\(3\) "php"
} \}
} \}
===EOF=== \=\=\=EOF\=\=\=

View File

@ -1,322 +0,0 @@
--TEST--
Test V8::executeString() : var_dump
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (PHP_VERSION_ID < 70300) die('skip Only for php version >= 7.3');
?>
--INI--
date.timezone=UTC
--FILE--
<?php
# Test var_dump of various types
$JS = <<< EOT
print("--- JS var_dump of PHP object ----\\n");
var_dump(PHP.phptypes);
print("--- JS var_dump of JS object ----\\n");
var types = {
undefined: undefined,
null: null,
bool: true,
string: "string",
uint: 1,
int: -1,
number: 3.141592654,
// XXX this gets parsed with local timezone,
// which is bad for test repeatability.
//date: new Date('September 27, 1976 09:00:00 GMT'),
regexp: /regexp/,
array: [1,2,3],
object: { field: "foo" },
function: function id(x) { return x; },
phpobject: PHP.obj
};
var_dump(types);
print("--- PHP var_dump of JS object ----\\n");
types;
EOT;
class Foo {
var $field = "php";
}
$v8 = new V8Js();
$v8->obj = new Foo;
$phptypes = $v8->phptypes = array(
"null" => NULL,
"bool" => true,
"string" => "string",
"uint" => 1,
"int" => -1,
"number" => 3.141592654,
"date" => new DateTime('September 27, 1976 09:00:00 UTC', new DateTimeZone('UTC')),
//"regexp" => new Regexp('/regexp/'), /* no native PHP regex type */
"array" => array(1,2,3),
"object" => array( "field" => "foo" ),
"function" => (function ($x) { return $x; }),
"phpobject" => new Foo
);
echo "---- PHP var_dump of PHP object ----\n";
var_dump($phptypes);
try {
var_dump($v8->executeString($JS, 'var_dump.js'));
} catch (V8JsScriptException $e) {
echo "Error!\n";
var_dump($e);
}
?>
===EOF===
--EXPECTF--
---- PHP var_dump of PHP object ----
array(11) {
["null"]=>
NULL
["bool"]=>
bool(true)
["string"]=>
string(6) "string"
["uint"]=>
int(1)
["int"]=>
int(-1)
["number"]=>
float(3.141592654)
["date"]=>
object(DateTime)#%d (3) {
["date"]=>
string(%d) "1976-09-27 09:00:00%r(\.0+)?%r"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["array"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
["object"]=>
array(1) {
["field"]=>
string(3) "foo"
}
["function"]=>
object(Closure)#%d (1) {
["parameter"]=>
array(1) {
["$x"]=>
string(10) "<required>"
}
}
["phpobject"]=>
object(Foo)#%d (1) {
["field"]=>
string(3) "php"
}
}
--- JS var_dump of PHP object ----
array (11) {
["null"] =>
NULL
["bool"] =>
bool(true)
["string"] =>
string(6) "string"
["uint"] =>
int(1)
["int"] =>
int(-1)
["number"] =>
float(3.141593)
["date"] =>
object(DateTime)#%d (19) {
["createFromImmutable"] =>
object(Closure)#%d {
function () { [native code] }
}
["createFromFormat"] =>
object(Closure)#%d {
function () { [native code] }
}
["getLastErrors"] =>
object(Closure)#%d {
function () { [native code] }
}
["format"] =>
object(Closure)#%d {
function () { [native code] }
}
["modify"] =>
object(Closure)#%d {
function () { [native code] }
}
["add"] =>
object(Closure)#%d {
function () { [native code] }
}
["sub"] =>
object(Closure)#%d {
function () { [native code] }
}
["getTimezone"] =>
object(Closure)#%d {
function () { [native code] }
}
["setTimezone"] =>
object(Closure)#%d {
function () { [native code] }
}
["getOffset"] =>
object(Closure)#%d {
function () { [native code] }
}
["setTime"] =>
object(Closure)#%d {
function () { [native code] }
}
["setDate"] =>
object(Closure)#%d {
function () { [native code] }
}
["setISODate"] =>
object(Closure)#%d {
function () { [native code] }
}
["setTimestamp"] =>
object(Closure)#%d {
function () { [native code] }
}
["getTimestamp"] =>
object(Closure)#%d {
function () { [native code] }
}
["diff"] =>
object(Closure)#%d {
function () { [native code] }
}
["$date"] =>
string(%d) "1976-09-27 09:00:00%r(\.0+)?%r"
["$timezone_type"] =>
int(3)
["$timezone"] =>
string(3) "UTC"
}
["array"] =>
array(3) {
[0] =>
int(1)
[1] =>
int(2)
[2] =>
int(3)
}
["object"] =>
array (1) {
["field"] =>
string(3) "foo"
}
["function"] =>
object(Closure)#%d (0) {
}
["phpobject"] =>
object(Foo)#%d (1) {
["$field"] =>
string(3) "php"
}
}
--- JS var_dump of JS object ----
object(Object)#%d (12) {
["undefined"] =>
NULL
["null"] =>
NULL
["bool"] =>
bool(true)
["string"] =>
string(6) "string"
["uint"] =>
int(1)
["int"] =>
int(-1)
["number"] =>
float(3.141593)
["regexp"] =>
regexp(/regexp/)
["array"] =>
array(3) {
[0] =>
int(1)
[1] =>
int(2)
[2] =>
int(3)
}
["object"] =>
object(Object)#%d (1) {
["field"] =>
string(3) "foo"
}
["function"] =>
object(Closure)#%d {
function id(x) { return x; }
}
["phpobject"] =>
object(Foo)#%d (1) {
["$field"] =>
string(3) "php"
}
}
--- PHP var_dump of JS object ----
object(V8Object)#%d (12) {
["undefined"]=>
NULL
["null"]=>
NULL
["bool"]=>
bool(true)
["string"]=>
string(6) "string"
["uint"]=>
int(1)
["int"]=>
int(-1)
["number"]=>
float(3.141592654)
["regexp"]=>
object(V8Object)#%d (0) {
}
["array"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
["object"]=>
object(V8Object)#%d (1) {
["field"]=>
string(3) "foo"
}
["function"]=>
object(V8Function)#%d (0) {
}
["phpobject"]=>
object(Foo)#%d (1) {
["field"]=>
string(3) "php"
}
}
===EOF===

View File

@ -1307,9 +1307,10 @@ const zend_function_entry v8js_methods[] = { /* {{{ */
/* V8Js object handlers */ /* V8Js object handlers */
static void 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_BEGIN_CTX(c, object) v8js_ctx *c = Z_V8JS_CTX_OBJ_P(object);
V8JS_CTX_PROLOGUE_EX(c, SINCE74(value,));
/* Check whether member is public, if so, export to V8. */ /* 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); zend_property_info *property_info = zend_get_property_info(c->std.ce, Z_STR_P(member), 1);
@ -1323,7 +1324,7 @@ static void v8js_write_property(zval *object, zval *member, zval *value, void **
if (Z_STRLEN_P(member) > std::numeric_limits<int>::max()) { if (Z_STRLEN_P(member) > std::numeric_limits<int>::max()) {
zend_throw_exception(php_ce_v8js_exception, zend_throw_exception(php_ce_v8js_exception,
"Property name exceeds maximum supported length", 0); "Property name exceeds maximum supported length", 0);
return; return SINCE74(value,);
} }
/* Write value to PHP JS object */ /* Write value to PHP JS object */
@ -1332,7 +1333,7 @@ static void v8js_write_property(zval *object, zval *member, zval *value, void **
} }
/* Write value to PHP object */ /* Write value to PHP object */
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); 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 */ #endif /* V8JS_V8_H */
/* /*

View File

@ -161,29 +161,37 @@ 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 ) /* {{{ */ static zval *v8js_v8object_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */
{
return NULL;
}
/* }}} */
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); v8js_v8object *obj = Z_V8JS_V8OBJECT_OBJ_P(object);
if (!obj->ctx) { if (!obj->ctx) {
zend_throw_exception(php_ce_v8js_exception, zend_throw_exception(php_ce_v8js_exception,
"Can't access V8Object after V8Js instance is destroyed!", 0); "Can't access V8Object after V8Js instance is destroyed!", 0);
return; return SINCE74(value,);
} }
V8JS_CTX_PROLOGUE(obj->ctx); V8JS_CTX_PROLOGUE_EX(obj->ctx, SINCE74(value,));
v8::Local<v8::Value> v8objHandle = v8::Local<v8::Value>::New(isolate, obj->v8obj); v8::Local<v8::Value> v8objHandle = v8::Local<v8::Value>::New(isolate, obj->v8obj);
if (Z_STRLEN_P(member) > std::numeric_limits<int>::max()) { if (Z_STRLEN_P(member) > std::numeric_limits<int>::max()) {
zend_throw_exception(php_ce_v8js_exception, zend_throw_exception(php_ce_v8js_exception,
"Member name length exceeds maximum supported length", 0); "Member name length exceeds maximum supported length", 0);
return; return SINCE74(value,);
} }
v8::Local<v8::Object> v8obj; v8::Local<v8::Object> v8obj;
if (v8objHandle->IsObject() && v8objHandle->ToObject(v8_context).ToLocal(&v8obj)) { if (v8objHandle->IsObject() && v8objHandle->ToObject(v8_context).ToLocal(&v8obj)) {
v8obj->CreateDataProperty(v8_context, V8JS_ZSYM(Z_STR_P(member)), zval_to_v8js(value, isolate)); v8obj->CreateDataProperty(v8_context, V8JS_ZSYM(Z_STR_P(member)), zval_to_v8js(value, isolate));
} }
return SINCE74(value,);
} }
/* }}} */ /* }}} */
@ -812,7 +820,7 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
memcpy(&v8js_v8object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&v8js_v8object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
v8js_v8object_handlers.clone_obj = NULL; v8js_v8object_handlers.clone_obj = NULL;
v8js_v8object_handlers.cast_object = NULL; v8js_v8object_handlers.cast_object = NULL;
v8js_v8object_handlers.get_property_ptr_ptr = NULL; v8js_v8object_handlers.get_property_ptr_ptr = v8js_v8object_get_property_ptr_ptr;
v8js_v8object_handlers.has_property = v8js_v8object_has_property; v8js_v8object_handlers.has_property = v8js_v8object_has_property;
v8js_v8object_handlers.read_property = v8js_v8object_read_property; v8js_v8object_handlers.read_property = v8js_v8object_read_property;
v8js_v8object_handlers.write_property = v8js_v8object_write_property; v8js_v8object_handlers.write_property = v8js_v8object_write_property;