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: Make read write deal with binary buffers. Created July 6, 2017, 12:19 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:
Left: Side by side diff | Download
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
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 std::vector<char> AdblockPlus::JsValue::AsBuffer() const 130 StringBuffer AdblockPlus::JsValue::AsStringBuffer() const
sergei 2017/07/06 14:14:05 Since there is a buffer type in JS, what about cal
hub 2017/07/06 14:33:31 I'm ok with AsStringBuffer() like we have AsString
131 { 131 {
132 const JsContext context(*jsEngine); 132 const JsContext context(*jsEngine);
133 return Utils::BufferFromV8String(UnwrapValue()); 133 return Utils::StringBufferFromV8String(UnwrapValue());
134 } 134 }
135 135
136 int64_t AdblockPlus::JsValue::AsInt() const 136 int64_t AdblockPlus::JsValue::AsInt() const
137 { 137 {
138 const JsContext context(*jsEngine); 138 const JsContext context(*jsEngine);
139 return UnwrapValue()->IntegerValue(); 139 return UnwrapValue()->IntegerValue();
140 } 140 }
141 141
142 bool AdblockPlus::JsValue::AsBool() const 142 bool AdblockPlus::JsValue::AsBool() const
143 { 143 {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 { 202 {
203 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value); 203 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value);
204 } 204 }
205 205
206 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)
207 { 207 {
208 const JsContext context(*jsEngine); 208 const JsContext context(*jsEngine);
209 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val)); 209 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val));
210 } 210 }
211 211
212 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::vecto r<char>& val) 212 void AdblockPlus::JsValue::SetStringBufferProperty(const std::string& name, cons t StringBuffer& val)
hub 2017/07/06 14:33:32 I'll rename it to SetStringProperty then.
sergei 2017/07/07 13:29:27 Could you please rename it?
hub 2017/07/07 13:39:20 Sorry, I had the change shelved by mistake. Curren
213 { 213 {
214 const JsContext context(*jsEngine); 214 const JsContext context(*jsEngine);
215 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val)); 215 SetProperty(name, Utils::StringBufferToV8String(jsEngine->GetIsolate(), val));
216 } 216 }
217 217
218 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val) 218 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val)
219 { 219 {
220 const JsContext context(*jsEngine); 220 const JsContext context(*jsEngine);
221 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val)); 221 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val));
222 } 222 }
223 223
224 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)
225 { 225 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const v8::TryCatch tryCatch; 287 const v8::TryCatch tryCatch;
288 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); 288 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue());
289 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), 289 v8::Local<v8::Value> result = func->Call(thisObj, args.size(),
290 args.size() ? &args[0] : nullptr); 290 args.size() ? &args[0] : nullptr);
291 291
292 if (tryCatch.HasCaught()) 292 if (tryCatch.HasCaught())
293 throw JsError(tryCatch.Exception(), tryCatch.Message()); 293 throw JsError(tryCatch.Exception(), tryCatch.Message());
294 294
295 return JsValue(jsEngine, result); 295 return JsValue(jsEngine, result);
296 } 296 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld