|
@@ -54,10 +54,27 @@ static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
|
|
|
|
|
return SUCCESS;
|
|
|
}
|
|
|
+
|
|
|
+static ZEND_INI_MH(v8js_OnUpdateUseDate) /* {{{ */
|
|
|
+{
|
|
|
+ bool value;
|
|
|
+ if (new_value_length==2 && strcasecmp("on", new_value)==0) {
|
|
|
+ value = (bool) 1;
|
|
|
+ } else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
|
|
|
+ value = (bool) 1;
|
|
|
+ } else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
|
|
|
+ value = (bool) 1;
|
|
|
+ } else {
|
|
|
+ value = (bool) atoi(new_value);
|
|
|
+ }
|
|
|
+ V8JSG(use_date) = value;
|
|
|
+ return SUCCESS;
|
|
|
+}
|
|
|
/* }}} */
|
|
|
|
|
|
ZEND_INI_BEGIN() /* {{{ */
|
|
|
ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags)
|
|
|
+ ZEND_INI_ENTRY("v8js.use_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate)
|
|
|
ZEND_INI_END()
|
|
|
/* }}} */
|
|
|
|
|
@@ -261,7 +278,7 @@ int php_v8js_v8_get_properties_hash(v8::Handle<v8::Value> jsValue, HashTable *re
|
|
|
v8::Local<v8::String> jsKey = jsKeys->Get(i)->ToString();
|
|
|
|
|
|
/* Skip any prototype properties */
|
|
|
- if (!jsObj->HasRealNamedProperty(jsKey) && !jsObj->HasRealNamedCallbackProperty(jsKey) && !jsObj->HasRealIndexedProperty(i)) {
|
|
|
+ if (!jsObj->HasOwnProperty(jsKey) && !jsObj->HasRealNamedProperty(jsKey) && !jsObj->HasRealNamedCallbackProperty(jsKey)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -1030,7 +1047,7 @@ static void php_v8js_timer_thread(TSRMLS_D)
|
|
|
*/
|
|
|
static PHP_METHOD(V8Js, executeString)
|
|
|
{
|
|
|
- char *str = NULL, *identifier = NULL;
|
|
|
+ char *str = NULL, *identifier = NULL, *tz = NULL;
|
|
|
int str_len = 0, identifier_len = 0;
|
|
|
long flags = V8JS_FLAG_NONE, time_limit = 0, memory_limit = 0;
|
|
|
|
|
@@ -1064,6 +1081,15 @@ static PHP_METHOD(V8Js, executeString)
|
|
|
/* Set flags for runtime use */
|
|
|
V8JS_GLOBAL_SET_FLAGS(isolate, flags);
|
|
|
|
|
|
+ /* Check if timezone has been changed and notify V8 */
|
|
|
+ tz = getenv("TZ");
|
|
|
+ if (c->tz != NULL) {
|
|
|
+ if (c->tz != NULL && strcmp(c->tz, tz) != 0) {
|
|
|
+ v8::Date::DateTimeConfigurationChangeNotification(c->isolate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ c->tz = tz;
|
|
|
+
|
|
|
if (time_limit > 0 || memory_limit > 0) {
|
|
|
// If timer thread is not running then start it
|
|
|
if (!V8JSG(timer_thread)) {
|
|
@@ -1153,6 +1179,40 @@ static PHP_METHOD(V8Js, executeString)
|
|
|
}
|
|
|
/* }}} */
|
|
|
|
|
|
+/* {{{ proto mixed V8Js::checkString(string script)
|
|
|
+ */
|
|
|
+static PHP_METHOD(V8Js, checkString)
|
|
|
+{
|
|
|
+ char *str = NULL;
|
|
|
+ int str_len = 0;
|
|
|
+ long flags = V8JS_FLAG_NONE, time_limit = 0, memory_limit = 0;
|
|
|
+
|
|
|
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ V8JS_BEGIN_CTX(c, getThis())
|
|
|
+
|
|
|
+ /* Catch JS exceptions */
|
|
|
+ v8::TryCatch try_catch;
|
|
|
+
|
|
|
+ /* Set script identifier */
|
|
|
+ v8::Local<v8::String> sname = V8JS_SYM("V8Js::checkString()");
|
|
|
+
|
|
|
+ /* Compiles a string context independently. TODO: Add a php function which calls this and returns the result as resource which can be executed later. */
|
|
|
+ v8::Local<v8::String> source = V8JS_STRL(str, str_len);
|
|
|
+ v8::Local<v8::Script> script = v8::Script::New(source, sname);
|
|
|
+
|
|
|
+ /* Compile errors? */
|
|
|
+ if (script.IsEmpty()) {
|
|
|
+ php_v8js_throw_script_exception(&try_catch TSRMLS_CC);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ RETURN_TRUE;
|
|
|
+}
|
|
|
+/* }}} */
|
|
|
+
|
|
|
+
|
|
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
|
|
/* {{{ proto void V8Js::__destruct()
|
|
|
__destruct for V8Js */
|
|
@@ -1407,6 +1467,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_executestring, 0, 0, 1)
|
|
|
ZEND_ARG_INFO(0, memory_limit)
|
|
|
ZEND_END_ARG_INFO()
|
|
|
|
|
|
+ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_checkstring, 0, 0, 1)
|
|
|
+ ZEND_ARG_INFO(0, script)
|
|
|
+ZEND_END_ARG_INFO()
|
|
|
+
|
|
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_v8js_destruct, 0, 0, 0)
|
|
|
ZEND_END_ARG_INFO()
|
|
@@ -1454,6 +1518,7 @@ static const zend_function_entry v8_function_methods[] = { /* {{{ */
|
|
|
static const zend_function_entry v8js_methods[] = { /* {{{ */
|
|
|
PHP_ME(V8Js, __construct, arginfo_v8js_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
|
|
|
PHP_ME(V8Js, executeString, arginfo_v8js_executestring, ZEND_ACC_PUBLIC)
|
|
|
+ PHP_ME(V8Js, checkString, arginfo_v8js_checkstring, ZEND_ACC_PUBLIC)
|
|
|
PHP_ME(V8Js, getPendingException, arginfo_v8js_getpendingexception, ZEND_ACC_PUBLIC)
|
|
|
PHP_ME(V8Js, setModuleLoader, arginfo_v8js_setmoduleloader, ZEND_ACC_PUBLIC)
|
|
|
PHP_ME(V8Js, registerExtension, arginfo_v8js_registerextension, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
|