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

Unified Diff: src/JsEngine.cpp

Issue 29416579: Issue 5034 - Part 1: Pass a JsValue directly to SetProperty() and return from GetProperty() (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Remove JsValue test Created April 19, 2017, 2:46 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
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | src/JsValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -140,24 +140,25 @@
JsEnginePtr result(new JsEngine(isolate, std::move(timer)));
const v8::Locker locker(result->GetIsolate());
const v8::Isolate::Scope isolateScope(result->GetIsolate());
const v8::HandleScope handleScope(result->GetIsolate());
result->context.reset(new v8::Persistent<v8::Context>(result->GetIsolate(),
v8::Context::New(result->GetIsolate())));
- AdblockPlus::GlobalJsObject::Setup(*result, appInfo, result->GetGlobalObject());
+ auto global = result->GetGlobalObject();
+ AdblockPlus::GlobalJsObject::Setup(*result, appInfo, global);
return result;
}
-AdblockPlus::JsValuePtr AdblockPlus::JsEngine::GetGlobalObject()
+AdblockPlus::JsValue AdblockPlus::JsEngine::GetGlobalObject()
{
JsContext context(shared_from_this());
- return JsValuePtr(new JsValue(shared_from_this(), context.GetV8Context()->Global()));
+ return JsValue(shared_from_this(), context.GetV8Context()->Global());
}
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& source,
const std::string& filename)
{
const JsContext context(shared_from_this());
const v8::TryCatch tryCatch;
const v8::Handle<v8::Script> script = CompileScript(GetIsolate(), source,
@@ -321,15 +322,13 @@
if (!val)
throw std::runtime_error("LogSystem cannot be null");
logSystem = val;
}
void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
- const AdblockPlus::JsValuePtr& value)
+ const AdblockPlus::JsValue& value)
{
auto global = GetGlobalObject();
- if (!global)
- throw std::runtime_error("Global object cannot be null");
- global->SetProperty(name, value);
+ global.SetProperty(name, value);
}
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | src/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld