Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/GlobalJsObject.cpp

Issue 29417605: Issue 5034 - Part 3: Create plain JsValue instead of JsValuePtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 19, 2017, 5:54 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/GlobalJsObject.cpp
===================================================================
--- a/src/GlobalJsObject.cpp
+++ b/src/GlobalJsObject.cpp
@@ -49,37 +49,37 @@
// used via clearTimeout(). But since we don't seem to need
// clearTimeout(), we can save that for later.
return v8::Undefined();
}
v8::Handle<v8::Value> TriggerEventCallback(const v8::Arguments& arguments)
{
AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments);
- AdblockPlus::JsConstValueList converted = jsEngine->ConvertArguments(arguments);
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
if (converted.size() < 1)
{
v8::Isolate* isolate = arguments.GetIsolate();
return v8::ThrowException(Utils::ToV8String(isolate,
"_triggerEvent expects at least one parameter"));
}
- std::string eventName = converted.front()->AsString();
- converted.erase(converted.begin());
+ std::string eventName = converted.front().AsString();
+ converted.erase(converted.cbegin());
jsEngine->TriggerEvent(eventName, converted);
return v8::Undefined();
}
}
JsValue& GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo,
JsValue& obj)
{
obj.SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback));
obj.SetProperty("_triggerEvent", jsEngine.NewCallback(::TriggerEventCallback));
- obj.SetProperty("_fileSystem",
- FileSystemJsObject::Setup(jsEngine, *jsEngine.NewObject()));
- obj.SetProperty("_webRequest",
- WebRequestJsObject::Setup(jsEngine, *jsEngine.NewObject()));
- obj.SetProperty("console",
- ConsoleJsObject::Setup(jsEngine, *jsEngine.NewObject()));
- obj.SetProperty("_appInfo",
- AppInfoJsObject::Setup(appInfo, *jsEngine.NewObject()));
+ auto value = jsEngine.NewObject();
sergei 2017/04/19 18:56:52 This change is a bit controversial, but OK.
hub 2017/04/19 21:56:49 It is required for lifetime/scope reasons. Otherwi
+ obj.SetProperty("_fileSystem", FileSystemJsObject::Setup(jsEngine, value));
+ value = jsEngine.NewObject();
+ obj.SetProperty("_webRequest", WebRequestJsObject::Setup(jsEngine, value));
+ value = jsEngine.NewObject();
+ obj.SetProperty("console", ConsoleJsObject::Setup(jsEngine, value));
+ value = jsEngine.NewObject();
+ obj.SetProperty("_appInfo", AppInfoJsObject::Setup(appInfo, value));
return obj;
}

Powered by Google App Engine
This is Rietveld