diff --git a/README.md b/README.md index 14f22d4..04cbd35 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Minimum requirements 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. - This extension makes use of V8 isolates to ensure separation between multiple V8Js instances and uses the new isolate-based mechanism to throw exceptions, hence the need for 3.22.3 or above. + This extension makes use of V8 isolates to ensure separation between multiple V8Js instances and uses the new isolate-based mechanism to throw exceptions, hence the need for 3.24.10 or above. For a detailed overview of which V8 version V8Js can be successfully built against, see the [Jenkins V8Js job list](http://jenkins.brokenpipe.de/view/v8js-with-v8-versions/). diff --git a/php_v8js_macros.h b/php_v8js_macros.h index 9562db4..04a7f51 100644 --- a/php_v8js_macros.h +++ b/php_v8js_macros.h @@ -44,24 +44,11 @@ extern "C" { #define V8JS_SYML(v, l) v8::String::NewFromUtf8(isolate, v, v8::String::kInternalizedString, l) #define V8JS_STR(v) v8::String::NewFromUtf8(isolate, v) #define V8JS_STRL(v, l) v8::String::NewFromUtf8(isolate, v, v8::String::kNormalString, l) - -#if PHP_V8_API_VERSION < 3024010 -#define V8JS_INT(v) v8::Integer::New(v, isolate) -#define V8JS_UINT(v) v8::Integer::NewFromUnsigned(v, isolate) -#else #define V8JS_INT(v) v8::Integer::New(isolate, v) #define V8JS_UINT(v) v8::Integer::NewFromUnsigned(isolate, v) -#endif - #define V8JS_FLOAT(v) v8::Number::New(isolate, v) #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) -#endif - #define V8JS_NULL v8::Null(isolate) #define V8JS_UNDEFINED v8::Undefined(isolate) #define V8JS_MN(name) v8js_method_##name @@ -69,29 +56,6 @@ extern "C" { #define V8JS_THROW(isolate, type, message, message_len) (isolate)->ThrowException(v8::Exception::type(V8JS_STRL(message, message_len))) #define V8JS_GLOBAL(isolate) ((isolate)->GetCurrentContext()->Global()) -#if PHP_V8_API_VERSION < 3022000 -/* CopyablePersistentTraits is only part of V8 from 3.22.0 on, - to be compatible with lower versions add our own (compatible) version. */ -namespace v8 { - template - struct CopyablePersistentTraits { - typedef Persistent > CopyablePersistent; - static const bool kResetInDestructor = true; - template -#if PHP_V8_API_VERSION >= 3021015 - static V8_INLINE void Copy(const Persistent& source, - CopyablePersistent* dest) -#else - V8_INLINE(static void Copy(const Persistent& source, - CopyablePersistent* dest)) -#endif - { - // do nothing, just allow copy - } - }; -} -#endif - /* Abbreviate long type names */ typedef v8::Persistent > v8js_tmpl_t; typedef v8::Persistent > v8js_persistent_obj_t; @@ -100,15 +64,8 @@ typedef v8::Persistent > v8 #define PHPJS_OBJECT_KEY "phpjs::object" /* Helper macros */ -#if PHP_V8_API_VERSION < 2005009 -# define V8JS_GET_CLASS_NAME(var, obj) \ - /* Hack to prevent calling possibly set user-defined __toString() messing class name */ \ - v8::Local constructor = v8::Local::Cast(obj->Get(V8JS_SYM("constructor"))); \ - v8::String::Utf8Value var(constructor->GetName()); -#else -# define V8JS_GET_CLASS_NAME(var, obj) \ +#define V8JS_GET_CLASS_NAME(var, obj) \ v8::String::Utf8Value var(obj->GetConstructorName()); -#endif #if ZEND_MODULE_API_NO >= 20100409 # define ZEND_HASH_KEY_DC , const zend_literal *key @@ -209,12 +166,7 @@ struct php_v8js_ctx { /* }}} */ #ifdef ZTS -# if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ -# define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((php_v8js_ctx *) isolate->GetData())->zts_ctx); -# else -# define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((php_v8js_ctx *) isolate->GetData(0))->zts_ctx); -# endif +# define V8JS_TSRMLS_FETCH() TSRMLS_FETCH_FROM_CTX(((php_v8js_ctx *) isolate->GetData(0))->zts_ctx); #else # define V8JS_TSRMLS_FETCH() #endif diff --git a/v8js.cc b/v8js.cc index a877b05..7b1b9b5 100644 --- a/v8js.cc +++ b/v8js.cc @@ -606,13 +606,7 @@ PHP_METHOD(V8Function,__construct) void php_v8js_create_v8(zval *res, v8::Handle value, int flags, v8::Isolate *isolate TSRMLS_DC) /* {{{ */ { -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif - php_v8js_object *c; object_init_ex(res, value->IsFunction() ? php_ce_v8_function : php_ce_v8_object); @@ -924,12 +918,7 @@ static PHP_METHOD(V8Js, __construct) c->pending_exception = NULL; c->in_execution = 0; c->isolate = v8::Isolate::New(); -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - c->isolate->SetData(c); -#else c->isolate->SetData(0, c); -#endif c->time_limit_hit = false; c->memory_limit_hit = false; c->module_loader = NULL; @@ -1212,11 +1201,7 @@ static void php_v8js_execute_script(zval *this_ptr, php_v8js_script *res, long f 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); -#endif free(c->tz); c->tz = strdup(tz); diff --git a/v8js_convert.cc b/v8js_convert.cc index fa930ee..cd62815 100644 --- a/v8js_convert.cc +++ b/v8js_convert.cc @@ -78,12 +78,7 @@ static void php_v8js_call_php_func(zval *value, zend_class_entry *ce, zend_funct char *error; int error_len, i, flags = V8JS_FLAG_NONE; -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif /* Set parameter limits */ min_num_args = method_ptr->common.required_num_args; @@ -278,12 +273,7 @@ static void php_v8js_construct_callback(const v8::FunctionCallbackInfo ext_tmpl = v8::Local::Cast(cons_data->Get(0)); v8::Local ext_ce = v8::Local::Cast(cons_data->Get(1)); -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif if (info[0]->IsExternal()) { // Object created by v8js in php_v8js_hash_to_jsobj, PHP object passed as v8::External. @@ -364,12 +354,7 @@ static void php_v8js_weak_object_callback(const v8::WeakCallbackDataGetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif ctx->weak_objects.at(value).Reset(); ctx->weak_objects.erase(value); @@ -384,12 +369,7 @@ static void php_v8js_weak_closure_callback(const v8::WeakCallbackDataReset(); delete persist_tpl_; -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif ctx->weak_closures.at(persist_tpl_).Reset(); ctx->weak_closures.erase(persist_tpl_); @@ -520,12 +500,7 @@ static void php_v8js_invoke_callback(const v8::FunctionCallbackInfo& } if (info.IsConstructCall()) { -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif v8::String::Utf8Value str(self->GetConstructorName()->ToString()); const char *constructor_name = ToCString(str); @@ -916,12 +891,7 @@ static v8::Handle php_v8js_hash_to_jsobj(zval *value, v8::Isolate *is return v8obj; } else if (ce) { -#if PHP_V8_API_VERSION <= 3023008 - /* Until V8 3.23.8 Isolate could only take one external pointer. */ - php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(); -#else php_v8js_ctx *ctx = (php_v8js_ctx *) isolate->GetData(0); -#endif v8::Local new_tpl; v8js_tmpl_t *persist_tpl_; diff --git a/v8js_methods.cc b/v8js_methods.cc index 949266e..3e7e9ae 100644 --- a/v8js_methods.cc +++ b/v8js_methods.cc @@ -113,12 +113,10 @@ static void _php_v8js_dumper(v8::Isolate *isolate, v8::Local var, int // fake the fields of a PHP DateTime php_printf("Date(%s)\n", valstr); } -#if PHP_V8_API_VERSION >= 2003007 else if (var->IsRegExp()) { php_printf("regexp(%s)\n", valstr); } -#endif else if (var->IsArray()) { v8::Local array = v8::Local::Cast(var);