OLD | NEW |
1 #include <AdblockPlus/JsEngine.h> | |
2 #include <AdblockPlus/JsValue.h> | 1 #include <AdblockPlus/JsValue.h> |
3 #include <AdblockPlus/ErrorCallback.h> | 2 #include <AdblockPlus/ErrorCallback.h> |
4 #include <sstream> | 3 #include <sstream> |
5 | 4 |
6 #include "ConsoleJsObject.h" | 5 #include "ConsoleJsObject.h" |
7 | 6 |
8 namespace | 7 namespace |
9 { | 8 { |
10 v8::Handle<v8::Value> ErrorCallback(const v8::Arguments& arguments) | 9 v8::Handle<v8::Value> ErrorCallback(const v8::Arguments& arguments) |
11 { | 10 { |
12 AdblockPlus::JsEngine& jsEngine = AdblockPlus::JsEngine::FromArguments(argum
ents); | 11 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); |
13 const AdblockPlus::JsEngine::Context context(jsEngine); | 12 const AdblockPlus::JsEngine::Context context(jsEngine); |
14 AdblockPlus::JsValueList converted = jsEngine.ConvertArguments(arguments); | 13 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
15 | 14 |
16 std::stringstream message; | 15 std::stringstream message; |
17 for (size_t i = 0; i < converted.size(); i++) | 16 for (size_t i = 0; i < converted.size(); i++) |
18 message << converted[i]->AsString(); | 17 message << converted[i]->AsString(); |
19 | 18 |
20 AdblockPlus::ErrorCallbackPtr callback = jsEngine.GetErrorCallback(); | 19 AdblockPlus::ErrorCallbackPtr callback = jsEngine->GetErrorCallback(); |
21 (*callback)(message.str()); | 20 (*callback)(message.str()); |
22 return v8::Undefined(); | 21 return v8::Undefined(); |
23 } | 22 } |
24 | 23 |
25 v8::Handle<v8::Value> TraceCallback(const v8::Arguments& arguments) | 24 v8::Handle<v8::Value> TraceCallback(const v8::Arguments& arguments) |
26 { | 25 { |
27 return v8::Undefined(); | 26 return v8::Undefined(); |
28 } | 27 } |
29 } | 28 } |
30 | 29 |
31 AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup( | 30 AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup( |
32 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj) | 31 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj) |
33 { | 32 { |
34 obj->SetProperty("error", jsEngine.NewCallback(::ErrorCallback)); | 33 obj->SetProperty("error", jsEngine->NewCallback(::ErrorCallback)); |
35 obj->SetProperty("trace", jsEngine.NewCallback(::TraceCallback)); | 34 obj->SetProperty("trace", jsEngine->NewCallback(::TraceCallback)); |
36 return obj; | 35 return obj; |
37 } | 36 } |
OLD | NEW |