diff --git a/CREDITS b/CREDITS
index 22f8125..ab4424c 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,2 +1,3 @@
v8js
Jani Taskinen
+Patrick Reilly
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..943d756
--- /dev/null
+++ b/README.md
@@ -0,0 +1,74 @@
+V8Js
+====
+
+This is a PHP extension for Google's V8 Javascript engine
+
+
+Minimum requirements
+--------------------
+
+- V8 JavaScript Engine library version 2.5.8 (trunk)
+
+ V8 is Google's open source JavaScript engine.
+ V8 is written in C++ and is used in Google Chrome, the open source browser from Google.
+ V8 implements ECMAScript as specified in ECMA-262, 5th edition, and runs on Windows (XP or newer),
+ Mac OS X (10.5 or newer), and Linux systems that use IA-32, x64, or ARM processors.
+ V8 can run standalone, or can be embedded into any C++ application.
+ You can find more information here:
+
+
+- PHP 5.3.3+ (non-ZTS build preferred)
+ Note: V8 engine is not natively thread safe and this extension
+ has not been designed to work around it either yet and might or
+ might not work properly with ZTS enabled PHP. :)
+
+
+API
+===
+
+ class V8Js
+ {
+ /* Constants */
+
+ const string V8_VERSION;
+ const int FLAG_NONE;
+ const int FLAG_FORCE_ARRAY;
+
+ /* Methods */
+
+ // Initializes and starts V8 engine and Returns new V8Js object with it's own V8 context.
+ public __construct ( [string object_name = "PHP" [, array variables = NULL [, array extensions = NULL [, bool report_uncaught_exceptions = TRUE]]] )
+
+ // Compiles and executes script in object's context with optional identifier string.
+ public mixed V8Js::executeString( string script [, string identifier [, int flags = V8Js::FLAG_NONE]])
+
+ // Returns uncaught pending exception or null if there is no pending exception.
+ public V8JsException V8Js::getPendingException( void )
+
+ /** Static methods **/
+
+ // Registers persistent context independent global Javascript extension.
+ // NOTE! These extensions exist until PHP is shutdown and they need to be registered before V8 is initialized.
+ // For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created!
+ public static bool V8Js::registerExtension(string ext_name, string script [, array deps [, bool auto_enable = FALSE]])
+
+ // Returns extensions successfully registered with V8Js::registerExtension().
+ public static array V8Js::getExtensions( void )
+ }
+
+ final class V8JsException extends Exception
+ {
+ /* Properties */
+ protected string JsFileName = NULL;
+ protected int JsLineNumber = NULL;
+ protected string JsSourceLine = NULL;
+ protected string JsTrace = NULL;
+
+ /* Methods */
+ final public string getJsFileName( void )
+ final public int getJsLineNumber( void )
+ final public string getJsSourceLine( void )
+ final public string getJsTrace( void )
+ }
+
+
diff --git a/config.m4 b/config.m4
index e80db06..2b13bfd 100644
--- a/config.m4
+++ b/config.m4
@@ -51,7 +51,7 @@ int main ()
return 0;
}
return 1;
-}], [ac_cv_v8_version=`cat ./conftestval`], [ac_cv_v8_version=NONE], [ac_cv_v8_version=NONE])
+}], [ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`], [ac_cv_v8_version=NONE], [ac_cv_v8_version=NONE])
AC_LANG_RESTORE
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
diff --git a/package.xml b/package.xml
index f7b7f2a..314872c 100644
--- a/package.xml
+++ b/package.xml
@@ -15,16 +15,16 @@ http://pear.php.net/dtd/package-2.0.xsd">
jani@php.net
yes
-
- 2012-06-12
+ 2012-07-06
0.1.30.1.3
betabeta
PHP
- Fixed build in PHP 5.4+
- Fixed bug #59553 (can't build due to missing class member)
+- Fixed crash bug in setting v8.flags ini directive.
+- Added notice to registerExtension() if trying to use it when V8 is already initialized.
-
@@ -63,14 +63,5 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Added notice to registerExtension() if trying to use it when V8 is already initialized.
-
- 2010-12-30
- 0.1.00.1.0
- betabeta
- PHP
-
-- Initial PECL release.
-
-
diff --git a/php_v8js.h b/php_v8js.h
index 3b2fb46..e5c644a 100644
--- a/php_v8js.h
+++ b/php_v8js.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2010 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -13,10 +13,11 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jani Taskinen |
+ | Author: Patrick Reilly |
+----------------------------------------------------------------------+
*/
-/* $Id$ */
+/* $Id:$ */
#ifndef PHP_V8JS_H
#define PHP_V8JS_H
diff --git a/php_v8js_macros.h b/php_v8js_macros.h
index 8d9f5ee..a5ed06e 100644
--- a/php_v8js_macros.h
+++ b/php_v8js_macros.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2010 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -13,10 +13,11 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jani Taskinen |
+ | Author: Patrick Reilly |
+----------------------------------------------------------------------+
*/
-/* $Id$ */
+/* $Id$ */¬
#ifndef PHP_V8JS_MACROS_H
#define PHP_V8JS_MACROS_H
diff --git a/tests/object_method_call.phpt b/tests/object_method_call.phpt
index 186d4a3..c103bed 100644
--- a/tests/object_method_call.phpt
+++ b/tests/object_method_call.phpt
@@ -2,6 +2,8 @@
Test V8::executeString() : Calling methods of object passed from PHP
--SKIPIF--
+--INI--
+date.timezone=UTC
--FILE--
setTimeZone(new DateTimeZone(ini_get('date.timezone')));
+ echo $date->format(DateTime::RFC1123), "\n";
+ var_dump($b);
+ }
}
$a = new V8Js();
@@ -39,10 +47,9 @@ try {
}
try {
- date_default_timezone_set("UTC");
echo "\nTEST: Javascript Date -> PHP DateTime\n";
echo "======================================\n";
- $a->executeString("date = new Date('September 8, 1975 09:00:00'); print(date + '\\n'); PHP.myobj.mytest(date, 'foo');", "test6.js");
+ $a->executeString("date = new Date('September 8, 1975 09:00:00 GMT'); print(date.toUTCString() + '\\n'); PHP.myobj.mydatetest(date, 'foo');", "test6.js");
} catch (V8JsException $e) {
echo $e->getMessage(), "\n";
}
@@ -93,26 +100,18 @@ array(4) {
TEST: Javascript Date -> PHP DateTime
======================================
-Mon Sep 08 1975 09:00:00 GMT+0200 (EET)
-array(2) {
- [0]=>
- object(DateTime)#4 (3) {
- ["date"]=>
- string(19) "1975-09-08 09:00:00"
- ["timezone_type"]=>
- int(1)
- ["timezone"]=>
- string(6) "+02:00"
- }
- [1]=>
- string(3) "foo"
-}
+Mon, 08 Sep 1975 09:00:00 GMT
+Mon, 08 Sep 1975 09:00:00 +0000
+string(3) "foo"
array(3) {
[0]=>
- object(V8Object)#4 (2) {
+ object(V8Object)#4 (3) {
["mytest"]=>
object(V8Function)#6 (0) {
}
+ ["mydatetest"]=>
+ object(V8Function)#7 (0) {
+ }
["foo"]=>
string(8) "ORIGINAL"
}
@@ -132,8 +131,11 @@ array(3) {
[1]=>
string(3) "bar"
[2]=>
- object(V8Object)#5 (2) {
+ object(V8Object)#5 (3) {
["mytest"]=>
+ object(V8Function)#7 (0) {
+ }
+ ["mydatetest"]=>
object(V8Function)#6 (0) {
}
["foo"]=>
diff --git a/tests/return_value.phpt b/tests/return_value.phpt
index 0cffac3..910cf88 100644
--- a/tests/return_value.phpt
+++ b/tests/return_value.phpt
@@ -2,6 +2,8 @@
Test V8::executeString() : Return values
--SKIPIF--
+--INI--
+date.timezone=UTC
--FILE--
executeString("test(PHP.myobj);", "test1.js"));
var_dump($a->executeString("test(new Array(1,2,3));", "test2.js"));
var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
-var_dump($a->executeString("test(new Date('September 8, 1975 09:00:00'));", "test4.js"));
+$date = $a->executeString("test(new Date('September 8, 1975 09:00:00 GMT'));", "test4.js");
+$date->setTimeZone(new DateTimeZone('GMT'));
+echo $date->format(DateTime::RFC1123), "\n";
var_dump($a->executeString("test(1234567890);", "test5.js"));
var_dump($a->executeString("test(123.456789);", "test6.js"));
var_dump($a->executeString("test('some string');", "test7.js"));
@@ -66,14 +70,7 @@ array(2) {
[1]=>
string(3) "bar"
}
-object(DateTime)#3 (3) {
- ["date"]=>
- string(19) "1975-09-08 09:00:00"
- ["timezone_type"]=>
- int(1)
- ["timezone"]=>
- string(6) "+02:00"
-}
+Mon, 08 Sep 1975 09:00:00 +0000
int(1234567890)
float(123.456789)
string(11) "some string"
diff --git a/v8js.cc b/v8js.cc
index 7cb38da..2f068b8 100644
--- a/v8js.cc
+++ b/v8js.cc
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2010 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -13,13 +13,14 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jani Taskinen |
+ | Author: Patrick Reilly |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#define V8JS_DEBUG 0
-
+#define PHP_V8_VERSION "0.1.4"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/v8js_convert.cc b/v8js_convert.cc
index efb8d4a..a6ff654 100644
--- a/v8js_convert.cc
+++ b/v8js_convert.cc
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2010 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -13,6 +13,7 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jani Taskinen |
+ | Author: Patrick Reilly |
+----------------------------------------------------------------------+
*/
@@ -36,7 +37,7 @@ extern "C" {
static v8::Handle php_v8js_php_callback(const v8::Arguments &args) /* {{{ */
{
v8::Handle return_value;
- zval *value = reinterpret_cast(args.This()->GetPointerFromInternalField(0));
+ zval *value = reinterpret_cast(args.This()->GetAlignedPointerFromInternalField(0));
zend_function *method_ptr;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
@@ -49,7 +50,7 @@ static v8::Handle php_v8js_php_callback(const v8::Arguments &args) /*
/* Set method_ptr from v8::External or fetch the closure invoker */
if (!args.Data().IsEmpty() && args.Data()->IsExternal()) {
- method_ptr = static_cast(v8::External::Unwrap(args.Data()));
+ method_ptr = static_cast(v8::External::Cast(*args.Data())->Value());
} else {
method_ptr = zend_get_closure_invoke_method(value TSRMLS_CC);
}
@@ -185,9 +186,9 @@ static v8::Handle php_v8js_property_caller(const v8::Arguments &args)
argv[i] = args[i];
}
value = cb->Call(self, argc, argv);
- }
+ }
else /* __call() */
- {
+ {
v8::Local argsarr = v8::Array::New(argc);
for (; i < argc; ++i) {
argsarr->Set(i, args[i]);
@@ -383,7 +384,7 @@ static v8::Handle php_v8js_hash_to_jsobj(zval *value TSRMLS_DC) /* {{
newobj->SetHiddenValue(V8JS_SYM(ZEND_ISSET_FUNC_NAME), PHP_V8JS_CALLBACK(isset_ptr));
}
}
- newobj->SetPointerInInternalField(0, (void *) value);
+ newobj->SetAlignedPointerInInternalField(0, (void *) value);
} else {
new_tpl->SetClassName(V8JS_SYM("Array"));
newobj = new_tpl->InstanceTemplate()->NewInstance();
@@ -517,7 +518,7 @@ v8::Handle zval_to_v8js(zval *value TSRMLS_DC) /* {{{ */
jsValue = V8JS_NULL;
break;
}
- return jsValue;
+ return jsValue;
}
/* }}} */
diff --git a/v8js_methods.cc b/v8js_methods.cc
index 4f23dab..a02d8c5 100644
--- a/v8js_methods.cc
+++ b/v8js_methods.cc
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2010 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -13,6 +13,7 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jani Taskinen |
+ | Author: Patrick Reilly |
+----------------------------------------------------------------------+
*/
diff --git a/v8js_variables.cc b/v8js_variables.cc
index 8cb4b7e..062b7b6 100644
--- a/v8js_variables.cc
+++ b/v8js_variables.cc
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2010 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -13,10 +13,11 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jani Taskinen |
+ | Author: Patrick Reilly |
+----------------------------------------------------------------------+
*/
-/* $Id$ */
+/* $Id:$ */
#ifdef HAVE_CONFIG_H
#include "config.h"