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

Side by Side Diff: src/JsValue.cpp

Issue 29409580: Issue 5013 - Make parameter const ref when applicable. (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: the input stream is no longer const. Created April 12, 2017, 3:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/JsError.cpp ('k') | src/Thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 std::string AdblockPlus::JsValue::GetClass() const 200 std::string AdblockPlus::JsValue::GetClass() const
201 { 201 {
202 if (!IsObject()) 202 if (!IsObject())
203 throw new std::runtime_error("Cannot get constructor of a non-object"); 203 throw new std::runtime_error("Cannot get constructor of a non-object");
204 204
205 const JsContext context(jsEngine); 205 const JsContext context(jsEngine);
206 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue()); 206 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue());
207 return Utils::FromV8String(obj->GetConstructorName()); 207 return Utils::FromV8String(obj->GetConstructorName());
208 } 208 }
209 209
210 JsValue JsValue::Call(const JsConstValueList& params, JsValuePtr thisPtr) const 210 JsValue JsValue::Call(const JsConstValueList& params, const JsValuePtr& thisPtr) const
211 { 211 {
212 const JsContext context(jsEngine); 212 const JsContext context(jsEngine);
213 v8::Local<v8::Object> thisObj = thisPtr ? 213 v8::Local<v8::Object> thisObj = thisPtr ?
214 v8::Local<v8::Object>::Cast(thisPtr->UnwrapValue()) : 214 v8::Local<v8::Object>::Cast(thisPtr->UnwrapValue()) :
215 context.GetV8Context()->Global(); 215 context.GetV8Context()->Global();
216 216
217 std::vector<v8::Handle<v8::Value>> argv; 217 std::vector<v8::Handle<v8::Value>> argv;
218 for (const auto& param : params) 218 for (const auto& param : params)
219 argv.push_back(param->UnwrapValue()); 219 argv.push_back(param->UnwrapValue());
220 220
(...skipping 22 matching lines...) Expand all
243 const v8::TryCatch tryCatch; 243 const v8::TryCatch tryCatch;
244 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); 244 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue());
245 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), 245 v8::Local<v8::Value> result = func->Call(thisObj, args.size(),
246 args.size() ? &args[0] : nullptr); 246 args.size() ? &args[0] : nullptr);
247 247
248 if (tryCatch.HasCaught()) 248 if (tryCatch.HasCaught())
249 throw JsError(tryCatch.Exception(), tryCatch.Message()); 249 throw JsError(tryCatch.Exception(), tryCatch.Message());
250 250
251 return JsValue(jsEngine, result); 251 return JsValue(jsEngine, result);
252 } 252 }
OLDNEW
« no previous file with comments | « src/JsError.cpp ('k') | src/Thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld