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

Side by Side Diff: src/JsValue.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Fixed comment Created April 13, 2017, 3:45 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/JsEngine.cpp ('k') | src/WebRequestJsObject.cpp » ('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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 v8::Local<v8::String> property = Utils::ToV8String(jsEngine->GetIsolate(), nam e); 166 v8::Local<v8::String> property = Utils::ToV8String(jsEngine->GetIsolate(), nam e);
167 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue()); 167 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue());
168 obj->Set(property, val); 168 obj->Set(property, val);
169 } 169 }
170 170
171 v8::Local<v8::Value> AdblockPlus::JsValue::UnwrapValue() const 171 v8::Local<v8::Value> AdblockPlus::JsValue::UnwrapValue() const
172 { 172 {
173 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value); 173 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value);
174 } 174 }
175 175
176 JsValue AdblockPlus::JsValue::Clone() const
177 {
178 return JsValue(jsEngine, UnwrapValue());
179 }
180
176 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::strin g& val) 181 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::strin g& val)
177 { 182 {
178 const JsContext context(jsEngine); 183 const JsContext context(jsEngine);
179 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val)); 184 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val));
180 } 185 }
181 186
182 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val) 187 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val)
183 { 188 {
184 const JsContext context(jsEngine); 189 const JsContext context(jsEngine);
185 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val)); 190 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 const v8::TryCatch tryCatch; 248 const v8::TryCatch tryCatch;
244 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); 249 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue());
245 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), 250 v8::Local<v8::Value> result = func->Call(thisObj, args.size(),
246 args.size() ? &args[0] : nullptr); 251 args.size() ? &args[0] : nullptr);
247 252
248 if (tryCatch.HasCaught()) 253 if (tryCatch.HasCaught())
249 throw JsError(tryCatch.Exception(), tryCatch.Message()); 254 throw JsError(tryCatch.Exception(), tryCatch.Message());
250 255
251 return JsValue(jsEngine, result); 256 return JsValue(jsEngine, result);
252 } 257 }
OLDNEW
« no previous file with comments | « src/JsEngine.cpp ('k') | src/WebRequestJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld