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

Unified Diff: src/JsValue.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: Created April 18, 2017, 9:17 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/JsValue.cpp
===================================================================
--- a/src/JsValue.cpp
+++ b/src/JsValue.cpp
@@ -142,25 +142,25 @@
JsValueList properties = JsValuePtr(new JsValue(jsEngine, object->GetOwnPropertyNames()))->AsList();
std::vector<std::string> result;
for (const auto& property : properties)
result.push_back(property->AsString());
return result;
}
-AdblockPlus::JsValuePtr AdblockPlus::JsValue::GetProperty(const std::string& name) const
+AdblockPlus::JsValue AdblockPlus::JsValue::GetProperty(const std::string& name) const
{
if (!IsObject())
throw new std::runtime_error("Attempting to get property of a non-object");
const JsContext context(jsEngine);
v8::Local<v8::String> property = Utils::ToV8String(jsEngine->GetIsolate(), name);
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue());
- return JsValuePtr(new JsValue(jsEngine, obj->Get(property)));
+ return JsValue(jsEngine, obj->Get(property));
}
void AdblockPlus::JsValue::SetProperty(const std::string& name, v8::Handle<v8::Value> val)
{
if (!IsObject())
throw new std::runtime_error("Attempting to set property on a non-object");
v8::Local<v8::String> property = Utils::ToV8String(jsEngine->GetIsolate(), name);
@@ -185,20 +185,20 @@
}
void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val)
{
const JsContext context(jsEngine);
SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val));
}
-void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValuePtr& val)
+void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValue& val)
{
const JsContext context(jsEngine);
- SetProperty(name, val->UnwrapValue());
+ SetProperty(name, val.UnwrapValue());
}
void AdblockPlus::JsValue::SetProperty(const std::string& name, bool val)
{
const JsContext context(jsEngine);
SetProperty(name, v8::Boolean::New(val));
}
« src/JsEngine.cpp ('K') | « src/JsEngine.cpp ('k') | src/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld