OLD | NEW |
1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
2 #include <sstream> | 2 #include <sstream> |
3 | 3 |
4 #include "ConsoleJsObject.h" | 4 #include "GlobalJsObject.h" |
5 | 5 |
6 namespace | 6 namespace |
7 { | 7 { |
8 v8::Handle<v8::Context> CreateContext( | 8 v8::Handle<v8::Context> CreateContext( |
9 AdblockPlus::ErrorCallback& errorCallback) | 9 AdblockPlus::ErrorCallback& errorCallback) |
10 { | 10 { |
11 const v8::HandleScope handleScope; | 11 const v8::HandleScope handleScope; |
12 const v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); | 12 const v8::Handle<v8::ObjectTemplate> global = |
13 global->Set(v8::String::New("console"), | 13 AdblockPlus::GlobalJsObject::Create(errorCallback); |
14 AdblockPlus::ConsoleJsObject::Create(errorCallback)); | |
15 return v8::Context::New(0, global); | 14 return v8::Context::New(0, global); |
16 } | 15 } |
17 | 16 |
18 v8::Handle<v8::Script> CompileScript(const char* source, const char* filename) | 17 v8::Handle<v8::Script> CompileScript(const char* source, const char* filename) |
19 { | 18 { |
20 const v8::Handle<v8::String> v8Source = v8::String::New(source); | 19 const v8::Handle<v8::String> v8Source = v8::String::New(source); |
21 if (filename && filename[0]) | 20 if (filename && filename[0]) |
22 { | 21 { |
23 const v8::Handle<v8::String> v8Filename = v8::String::New(filename); | 22 const v8::Handle<v8::String> v8Filename = v8::String::New(filename); |
24 return v8::Script::Compile(v8Source, v8Filename); | 23 return v8::Script::Compile(v8Source, v8Filename); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 const v8::Local<v8::Value> result = function->Call(function, 0, 0); | 103 const v8::Local<v8::Value> result = function->Call(function, 0, 0); |
105 CheckTryCatch(tryCatch); | 104 CheckTryCatch(tryCatch); |
106 const v8::String::AsciiValue ascii(result); | 105 const v8::String::AsciiValue ascii(result); |
107 return *ascii; | 106 return *ascii; |
108 } | 107 } |
109 | 108 |
110 void AdblockPlus::JsEngine::Gc() | 109 void AdblockPlus::JsEngine::Gc() |
111 { | 110 { |
112 while (!v8::V8::IdleNotification()); | 111 while (!v8::V8::IdleNotification()); |
113 } | 112 } |
OLD | NEW |