Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
2 #include <sstream> | 2 #include <sstream> |
3 | 3 |
4 #include "GlobalJsObject.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 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 const v8::Local<v8::Object> global = context->Global(); | 102 const v8::Local<v8::Object> global = context->Global(); |
103 const v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( | 103 const v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( |
104 global->Get(v8::String::New(functionName.c_str()))); | 104 global->Get(v8::String::New(functionName.c_str()))); |
105 const v8::TryCatch tryCatch; | 105 const v8::TryCatch tryCatch; |
106 const v8::Local<v8::Value> result = function->Call(function, 0, 0); | 106 const v8::Local<v8::Value> result = function->Call(function, 0, 0); |
107 CheckTryCatch(tryCatch); | 107 CheckTryCatch(tryCatch); |
108 const v8::String::AsciiValue ascii(result); | 108 const v8::String::AsciiValue ascii(result); |
109 return *ascii; | 109 return *ascii; |
110 } | 110 } |
111 | 111 |
112 std::string AdblockPlus::JsEngine::GetGlobal(const std::string& name) | 112 std::string AdblockPlus::JsEngine::GetVariable(const std::string& name) |
Wladimir Palant
2013/04/08 08:36:00
This name got me thoroughly confused. Please renam
Felix Dahlke
2013/04/08 13:07:49
Sure. Called it "GetVariable" since I think that "
| |
113 { | 113 { |
114 const v8::Locker locker(v8::Isolate::GetCurrent()); | 114 const v8::Locker locker(v8::Isolate::GetCurrent()); |
115 const v8::HandleScope handleScope; | 115 const v8::HandleScope handleScope; |
116 const v8::Context::Scope contextScope(context); | 116 const v8::Context::Scope contextScope(context); |
117 const v8::Local<v8::Object> global = context->Global(); | 117 const v8::Local<v8::Object> global = context->Global(); |
118 const v8::Local<v8::Value> value = global->Get(v8::String::New(name.c_str())); | 118 const v8::Local<v8::Value> value = global->Get(v8::String::New(name.c_str())); |
119 if (value->IsUndefined()) | 119 if (value->IsUndefined()) |
120 return ""; | 120 return ""; |
121 const v8::String::AsciiValue ascii(value); | 121 const v8::String::AsciiValue ascii(value); |
122 return *ascii; | 122 return *ascii; |
123 } | 123 } |
124 | 124 |
125 void AdblockPlus::JsEngine::Gc() | 125 void AdblockPlus::JsEngine::Gc() |
126 { | 126 { |
127 while (!v8::V8::IdleNotification()); | 127 while (!v8::V8::IdleNotification()); |
128 } | 128 } |
LEFT | RIGHT |