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

Unified Diff: src/JsValue.cpp

Issue 29417624: Issue 5034 - Part 4: JsEngine::Evaluate() return a JsValue (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Rebased again Created April 20, 2017, 1:02 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/JsEngine.cpp ('k') | src/Notification.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsValue.cpp
===================================================================
--- a/src/JsValue.cpp
+++ b/src/JsValue.cpp
@@ -220,22 +220,30 @@
if (!IsObject())
throw new std::runtime_error("Cannot get constructor of a non-object");
const JsContext context(jsEngine);
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue());
return Utils::FromV8String(obj->GetConstructorName());
}
-JsValue JsValue::Call(const JsValueList& params, const JsValuePtr& thisPtr) const
+JsValue JsValue::Call(const JsValueList& params) const
{
const JsContext context(jsEngine);
- v8::Local<v8::Object> thisObj = thisPtr ?
- v8::Local<v8::Object>::Cast(thisPtr->UnwrapValue()) :
- context.GetV8Context()->Global();
+ std::vector<v8::Handle<v8::Value>> argv;
+ for (const auto& param : params)
+ argv.push_back(param.UnwrapValue());
+
+ return Call(argv, context.GetV8Context()->Global());
+}
+
+JsValue JsValue::Call(const JsValueList& params, const JsValue& thisValue) const
+{
+ const JsContext context(jsEngine);
+ v8::Local<v8::Object> thisObj = v8::Local<v8::Object>::Cast(thisValue.UnwrapValue());
std::vector<v8::Handle<v8::Value>> argv;
for (const auto& param : params)
argv.push_back(param.UnwrapValue());
return Call(argv, thisObj);
}
« no previous file with comments | « src/JsEngine.cpp ('k') | src/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld