Index: src/JsEngine.cpp |
diff --git a/src/JsEngine.cpp b/src/JsEngine.cpp |
index ce75e1b0f822be5187628d16e6fe1b067212753e..649b625f66f58eac80d7f4ce6d5bc6e3e7da6f46 100644 |
--- a/src/JsEngine.cpp |
+++ b/src/JsEngine.cpp |
@@ -21,6 +21,7 @@ |
#include "JsContext.h" |
#include "JsError.h" |
#include "Utils.h" |
+#include <libplatform/libplatform.h> |
namespace |
{ |
@@ -47,14 +48,19 @@ namespace |
class V8Initializer |
{ |
V8Initializer() |
+ : platform(v8::platform::CreateDefaultPlatform()) |
{ |
+ v8::V8::InitializePlatform(platform); |
v8::V8::Initialize(); |
} |
~V8Initializer() |
{ |
v8::V8::Dispose(); |
+ v8::V8::ShutdownPlatform(); |
+ delete platform; |
} |
+ v8::Platform* platform; |
public: |
static void Init() |
{ |
@@ -89,7 +95,7 @@ AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) |
const v8::Isolate::Scope isolateScope(result->isolate); |
const v8::HandleScope handleScope(result->isolate); |
- result->context.reset(new v8::Persistent<v8::Context>(result->isolate, |
+ result->context.reset(new v8::UniquePersistent<v8::Context>(result->isolate, |
v8::Context::New(result->isolate))); |
v8::Local<v8::Object> globalContext = v8::Local<v8::Context>::New( |
result->isolate, *result->context)->Global(); |
@@ -131,7 +137,7 @@ void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, AdblockPl |
void AdblockPlus::JsEngine::Gc() |
{ |
- while (!v8::V8::IdleNotification()); |
+ while (!isolate->IdleNotification(1000)); |
} |
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val) |
@@ -151,17 +157,17 @@ AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(int64_t val) |
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(bool val) |
{ |
const JsContext context(shared_from_this()); |
- return JsValuePtr(new JsValue(shared_from_this(), v8::Boolean::New(val))); |
+ return JsValuePtr(new JsValue(shared_from_this(), v8::Boolean::New(isolate, val))); |
} |
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewObject() |
{ |
const JsContext context(shared_from_this()); |
- return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New())); |
+ return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New(isolate))); |
} |
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback( |
- v8::InvocationCallback callback) |
+ v8::FunctionCallback callback) |
{ |
const JsContext context(shared_from_this()); |
@@ -169,12 +175,12 @@ AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback( |
// it's no longer used |
std::tr1::weak_ptr<JsEngine>* data = |
new std::tr1::weak_ptr<JsEngine>(shared_from_this()); |
- v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(callback, |
- v8::External::New(data)); |
+ v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, callback, |
+ v8::External::New(isolate, data)); |
return JsValuePtr(new JsValue(shared_from_this(), templ->GetFunction())); |
} |
-AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::Arguments& arguments) |
+AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
{ |
const v8::Local<const v8::External> external = |
v8::Local<const v8::External>::Cast(arguments.Data()); |
@@ -186,7 +192,7 @@ AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::Argument |
return result; |
} |
-AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Arguments& arguments) |
+AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
{ |
const JsContext context(shared_from_this()); |
JsValueList list; |