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

Side by Side Diff: src/JsValue.cpp

Issue 6193234183192576: Issue 1197 - change local copy of v8 (to 4.3.15) to work with Visual Studio 2013 (Closed)
Patch Set: rebase and update Created May 17, 2016, 3:18 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/Utils.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <vector> 18 #include <vector>
19 #include <AdblockPlus.h> 19 #include <AdblockPlus.h>
20 20
21 #include "JsContext.h" 21 #include "JsContext.h"
22 #include "JsError.h" 22 #include "JsError.h"
23 #include "Utils.h" 23 #include "Utils.h"
24 24
25 AdblockPlus::JsValue::JsValue(AdblockPlus::JsEnginePtr jsEngine, 25 AdblockPlus::JsValue::JsValue(AdblockPlus::JsEnginePtr jsEngine,
26 v8::Handle<v8::Value> value) 26 v8::Handle<v8::Value> value)
27 : jsEngine(jsEngine), 27 : jsEngine(jsEngine),
28 value(new v8::Persistent<v8::Value>(jsEngine->GetIsolate(), value)) 28 value(new v8::UniquePersistent<v8::Value>(jsEngine->GetIsolate(), value))
29 { 29 {
30 } 30 }
31 31
32 AdblockPlus::JsValue::JsValue(AdblockPlus::JsValue&& src) 32 AdblockPlus::JsValue::JsValue(AdblockPlus::JsValue&& src)
33 : jsEngine(src.jsEngine), 33 : jsEngine(src.jsEngine),
34 value(std::move(src.value)) 34 value(std::move(src.value))
35 { 35 {
36 } 36 }
37 37
38 AdblockPlus::JsValue::~JsValue() 38 AdblockPlus::JsValue::~JsValue()
39 { 39 {
40 if (value)
41 {
42 value->Dispose();
43 value.reset();
44 }
45 } 40 }
46 41
47 bool AdblockPlus::JsValue::IsUndefined() const 42 bool AdblockPlus::JsValue::IsUndefined() const
48 { 43 {
49 const JsContext context(jsEngine); 44 const JsContext context(jsEngine);
50 return UnwrapValue()->IsUndefined(); 45 return UnwrapValue()->IsUndefined();
51 } 46 }
52 47
53 bool AdblockPlus::JsValue::IsNull() const 48 bool AdblockPlus::JsValue::IsNull() const
54 { 49 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 180
186 void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValuePtr & val) 181 void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValuePtr & val)
187 { 182 {
188 const JsContext context(jsEngine); 183 const JsContext context(jsEngine);
189 SetProperty(name, val->UnwrapValue()); 184 SetProperty(name, val->UnwrapValue());
190 } 185 }
191 186
192 void AdblockPlus::JsValue::SetProperty(const std::string& name, bool val) 187 void AdblockPlus::JsValue::SetProperty(const std::string& name, bool val)
193 { 188 {
194 const JsContext context(jsEngine); 189 const JsContext context(jsEngine);
195 SetProperty(name, v8::Boolean::New(val)); 190 SetProperty(name, v8::Boolean::New(jsEngine->GetIsolate(), val));
196 } 191 }
197 192
198 std::string AdblockPlus::JsValue::GetClass() const 193 std::string AdblockPlus::JsValue::GetClass() const
199 { 194 {
200 if (!IsObject()) 195 if (!IsObject())
201 throw new std::runtime_error("Cannot get constructor of a non-object"); 196 throw new std::runtime_error("Cannot get constructor of a non-object");
202 197
203 const JsContext context(jsEngine); 198 const JsContext context(jsEngine);
204 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue()); 199 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue());
205 return Utils::FromV8String(obj->GetConstructorName()); 200 return Utils::FromV8String(obj->GetConstructorName());
(...skipping 30 matching lines...) Expand all
236 return JsValuePtr(new JsValue(jsEngine, result)); 231 return JsValuePtr(new JsValue(jsEngine, result));
237 } 232 }
238 233
239 AdblockPlus::JsValuePtr AdblockPlus::JsValue::Call(const JsValue& arg) const 234 AdblockPlus::JsValuePtr AdblockPlus::JsValue::Call(const JsValue& arg) const
240 { 235 {
241 const JsContext context(jsEngine); 236 const JsContext context(jsEngine);
242 JsValueList params; 237 JsValueList params;
243 params.push_back(JsValuePtr(new JsValue(arg.jsEngine, arg.UnwrapValue()))); 238 params.push_back(JsValuePtr(new JsValue(arg.jsEngine, arg.UnwrapValue())));
244 return Call(params); 239 return Call(params);
245 } 240 }
OLDNEW
« no previous file with comments | « src/JsEngine.cpp ('k') | src/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld