mirror of
https://github.com/phpv8/v8js.git
synced 2025-01-03 10:21:51 +00:00
Fix strdup+getenv behaviour; multi api version support, closes #86
This commit is contained in:
parent
ddbef50ea6
commit
0355a95c78
@ -62,7 +62,13 @@ extern "C" {
|
|||||||
|
|
||||||
#define V8JS_FLOAT(v) v8::Number::New(isolate, v)
|
#define V8JS_FLOAT(v) v8::Number::New(isolate, v)
|
||||||
#define V8JS_BOOL(v) ((v)?v8::True(isolate):v8::False(isolate))
|
#define V8JS_BOOL(v) ((v)?v8::True(isolate):v8::False(isolate))
|
||||||
|
|
||||||
|
#if PHP_V8_API_VERSION <= 3023012
|
||||||
|
#define V8JS_DATE(v) v8::Date::New(v)
|
||||||
|
#else
|
||||||
#define V8JS_DATE(v) v8::Date::New(isolate, v)
|
#define V8JS_DATE(v) v8::Date::New(isolate, v)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define V8JS_NULL v8::Null(isolate)
|
#define V8JS_NULL v8::Null(isolate)
|
||||||
#define V8JS_UNDEFINED v8::Undefined(isolate)
|
#define V8JS_UNDEFINED v8::Undefined(isolate)
|
||||||
#define V8JS_MN(name) v8js_method_##name
|
#define V8JS_MN(name) v8js_method_##name
|
||||||
|
21
v8js.cc
21
v8js.cc
@ -643,6 +643,9 @@ static void php_v8js_free_storage(void *object TSRMLS_DC) /* {{{ */
|
|||||||
}
|
}
|
||||||
c->weak_closures.~map();
|
c->weak_closures.~map();
|
||||||
|
|
||||||
|
if(c->tz != NULL) {
|
||||||
|
free(c->tz);
|
||||||
|
}
|
||||||
|
|
||||||
c->modules_stack.~vector();
|
c->modules_stack.~vector();
|
||||||
c->modules_base.~vector();
|
c->modules_base.~vector();
|
||||||
@ -1083,12 +1086,22 @@ static PHP_METHOD(V8Js, executeString)
|
|||||||
|
|
||||||
/* Check if timezone has been changed and notify V8 */
|
/* Check if timezone has been changed and notify V8 */
|
||||||
tz = getenv("TZ");
|
tz = getenv("TZ");
|
||||||
if (c->tz != NULL) {
|
|
||||||
if (c->tz != NULL && strcmp(c->tz, tz) != 0) {
|
if (tz != NULL) {
|
||||||
|
if (c->tz == NULL) {
|
||||||
|
c->tz = strdup(tz);
|
||||||
|
}
|
||||||
|
else if (strcmp(c->tz, tz) != 0) {
|
||||||
|
#if PHP_V8_API_VERSION <= 3023012
|
||||||
|
v8::Date::DateTimeConfigurationChangeNotification();
|
||||||
|
#else
|
||||||
v8::Date::DateTimeConfigurationChangeNotification(c->isolate);
|
v8::Date::DateTimeConfigurationChangeNotification(c->isolate);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
free(c->tz);
|
||||||
|
c->tz = strdup(tz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c->tz = tz;
|
|
||||||
|
|
||||||
if (time_limit > 0 || memory_limit > 0) {
|
if (time_limit > 0 || memory_limit > 0) {
|
||||||
// If timer thread is not running then start it
|
// If timer thread is not running then start it
|
||||||
@ -1201,7 +1214,7 @@ static PHP_METHOD(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. */
|
/* 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::String> source = V8JS_STRL(str, str_len);
|
||||||
v8::Local<v8::Script> script = v8::Script::New(source, sname);
|
v8::Local<v8::Script> script = v8::Script::Compile(source, sname);
|
||||||
|
|
||||||
/* Compile errors? */
|
/* Compile errors? */
|
||||||
if (script.IsEmpty()) {
|
if (script.IsEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user