| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 if (!jsEngine) | 172 if (!jsEngine) |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 const JsContext context(*jsEngine); | 175 const JsContext context(*jsEngine); |
| 176 auto jsValues = jsEngine->GetJsValues(weakData->weakProcessFunc); | 176 auto jsValues = jsEngine->GetJsValues(weakData->weakProcessFunc); |
| 177 auto processFunc = jsValues[0].UnwrapValue().As<v8::Function>(); | 177 auto processFunc = jsValues[0].UnwrapValue().As<v8::Function>(); |
| 178 auto globalContext = context.GetV8Context()->Global(); | 178 auto globalContext = context.GetV8Context()->Global(); |
| 179 if (!globalContext->IsObject()) | 179 if (!globalContext->IsObject()) |
| 180 throw std::runtime_error("`this` pointer has to be an object"); | 180 throw std::runtime_error("`this` pointer has to be an object"); |
| 181 | 181 |
| 182 const v8::TryCatch tryCatch(jsEngine->GetIsolate()); | 182 auto isolate = jsEngine->GetIsolate(); |
| 183 const v8::TryCatch tryCatch(isolate); | |
| 183 const auto contentEnd = content.cend(); | 184 const auto contentEnd = content.cend(); |
| 184 auto stringBegin = SkipEndOfLine(content.begin(), contentEnd); | 185 auto stringBegin = SkipEndOfLine(content.begin(), contentEnd); |
| 186 auto v8Context = isolate->GetCurrentContext(); | |
| 185 do | 187 do |
| 186 { | 188 { |
| 187 auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd); | 189 auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd); |
| 188 auto jsLine = Utils::StringBufferToV8String(jsEngine->GetIsolate (), StringBuffer(stringBegin, stringEnd)).As<v8::Value>(); | 190 auto jsLine = Utils::StringBufferToV8String(isolate, StringBuffe r(stringBegin, stringEnd)).As<v8::Value>(); |
| 189 processFunc->Call(globalContext, 1, &jsLine); | 191 processFunc->Call(v8Context, globalContext, 1, &jsLine); |
|
hub
2018/06/18 12:59:02
I get this warning here:
../src/FileSystemJsObjec
sergei
2018/06/18 13:00:19
Yeah, that's because the impl is not complete yet.
| |
| 190 if (tryCatch.HasCaught()) | 192 if (tryCatch.HasCaught()) |
| 191 throw JsError(tryCatch.Exception(), tryCatch.Message()); | 193 throw JsError(isolate, tryCatch.Exception(), tryCatch.Message( )); |
| 192 stringBegin = SkipEndOfLine(stringEnd, contentEnd); | 194 stringBegin = SkipEndOfLine(stringEnd, contentEnd); |
| 193 } while (stringBegin != contentEnd); | 195 } while (stringBegin != contentEnd); |
| 194 jsEngine->GetJsValues(weakData->weakResolveCallback)[0].Call(); | 196 jsEngine->GetJsValues(weakData->weakResolveCallback)[0].Call(); |
| 195 }, [weakData](const std::string& error) | 197 }, [weakData](const std::string& error) |
| 196 { | 198 { |
| 197 if (error.empty()) | 199 if (error.empty()) |
| 198 return; | 200 return; |
| 199 auto jsEngine = weakData->weakJsEngine.lock(); | 201 auto jsEngine = weakData->weakJsEngine.lock(); |
| 200 if (!jsEngine) | 202 if (!jsEngine) |
| 201 return; | 203 return; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) | 361 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) |
| 360 { | 362 { |
| 361 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback::V8Callback)); | 363 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback::V8Callback)); |
| 362 obj.SetProperty("readFromFile", jsEngine.NewCallback(::ReadFromFileCallback::V 8Callback)); | 364 obj.SetProperty("readFromFile", jsEngine.NewCallback(::ReadFromFileCallback::V 8Callback)); |
| 363 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); | 365 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); |
| 364 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); | 366 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); |
| 365 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); | 367 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); |
| 366 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); | 368 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); |
| 367 return obj; | 369 return obj; |
| 368 } | 370 } |
| OLD | NEW |