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

Delta Between Two Patch Sets: src/JsValue.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Rebased. Corrected most of the review issues. Created July 4, 2017, 7:57 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/JsEngine.cpp ('k') | src/Thread.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 const JsContext context(*jsEngine); 120 const JsContext context(*jsEngine);
121 return UnwrapValue()->IsFunction(); 121 return UnwrapValue()->IsFunction();
122 } 122 }
123 123
124 std::string AdblockPlus::JsValue::AsString() const 124 std::string AdblockPlus::JsValue::AsString() const
125 { 125 {
126 const JsContext context(*jsEngine); 126 const JsContext context(*jsEngine);
127 return Utils::FromV8String(UnwrapValue()); 127 return Utils::FromV8String(UnwrapValue());
128 } 128 }
129 129
130 StringBuffer AdblockPlus::JsValue::AsStringBuffer() const
131 {
132 const JsContext context(*jsEngine);
133 return Utils::StringBufferFromV8String(UnwrapValue());
134 }
135
130 int64_t AdblockPlus::JsValue::AsInt() const 136 int64_t AdblockPlus::JsValue::AsInt() const
131 { 137 {
132 const JsContext context(*jsEngine); 138 const JsContext context(*jsEngine);
133 return UnwrapValue()->IntegerValue(); 139 return UnwrapValue()->IntegerValue();
134 } 140 }
135 141
136 bool AdblockPlus::JsValue::AsBool() const 142 bool AdblockPlus::JsValue::AsBool() const
137 { 143 {
138 const JsContext context(*jsEngine); 144 const JsContext context(*jsEngine);
139 return UnwrapValue()->BooleanValue(); 145 return UnwrapValue()->BooleanValue();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 { 202 {
197 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value); 203 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value);
198 } 204 }
199 205
200 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::strin g& val) 206 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::strin g& val)
201 { 207 {
202 const JsContext context(*jsEngine); 208 const JsContext context(*jsEngine);
203 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val)); 209 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val));
204 } 210 }
205 211
212 void AdblockPlus::JsValue::SetStringBufferProperty(const std::string& name, cons t StringBuffer& val)
213 {
214 const JsContext context(*jsEngine);
215 SetProperty(name, Utils::StringBufferToV8String(jsEngine->GetIsolate(), val));
216 }
217
206 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val) 218 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val)
207 { 219 {
208 const JsContext context(*jsEngine); 220 const JsContext context(*jsEngine);
209 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val)); 221 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val));
210 } 222 }
211 223
212 void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValue& v al) 224 void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValue& v al)
213 { 225 {
214 const JsContext context(*jsEngine); 226 const JsContext context(*jsEngine);
215 SetProperty(name, val.UnwrapValue()); 227 SetProperty(name, val.UnwrapValue());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 const v8::TryCatch tryCatch; 287 const v8::TryCatch tryCatch;
276 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); 288 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue());
277 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), 289 v8::Local<v8::Value> result = func->Call(thisObj, args.size(),
278 args.size() ? &args[0] : nullptr); 290 args.size() ? &args[0] : nullptr);
279 291
280 if (tryCatch.HasCaught()) 292 if (tryCatch.HasCaught())
281 throw JsError(tryCatch.Exception(), tryCatch.Message()); 293 throw JsError(tryCatch.Exception(), tryCatch.Message());
282 294
283 return JsValue(jsEngine, result); 295 return JsValue(jsEngine, result);
284 } 296 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld