| 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; | 182 const v8::TryCatch tryCatch(jsEngine->GetIsolate()); |
| 183 const auto contentEnd = content.cend(); | 183 const auto contentEnd = content.cend(); |
| 184 auto stringBegin = SkipEndOfLine(content.begin(), contentEnd); | 184 auto stringBegin = SkipEndOfLine(content.begin(), contentEnd); |
| 185 do | 185 do |
| 186 { | 186 { |
| 187 auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd); | 187 auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd); |
| 188 auto jsLine = Utils::StringBufferToV8String(jsEngine->GetIsolate
(), StringBuffer(stringBegin, stringEnd)).As<v8::Value>(); | 188 auto jsLine = Utils::StringBufferToV8String(jsEngine->GetIsolate
(), StringBuffer(stringBegin, stringEnd)).As<v8::Value>(); |
| 189 processFunc->Call(globalContext, 1, &jsLine); | 189 processFunc->Call(globalContext, 1, &jsLine); |
| 190 if (tryCatch.HasCaught()) | 190 if (tryCatch.HasCaught()) |
| 191 throw JsError(tryCatch.Exception(), tryCatch.Message()); | 191 throw JsError(tryCatch.Exception(), tryCatch.Message()); |
| 192 stringBegin = SkipEndOfLine(stringEnd, contentEnd); | 192 stringBegin = SkipEndOfLine(stringEnd, contentEnd); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) | 359 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) |
| 360 { | 360 { |
| 361 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback::V8Callback)); | 361 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback::V8Callback)); |
| 362 obj.SetProperty("readFromFile", jsEngine.NewCallback(::ReadFromFileCallback::V
8Callback)); | 362 obj.SetProperty("readFromFile", jsEngine.NewCallback(::ReadFromFileCallback::V
8Callback)); |
| 363 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); | 363 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); |
| 364 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); | 364 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); |
| 365 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); | 365 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); |
| 366 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); | 366 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); |
| 367 return obj; | 367 return obj; |
| 368 } | 368 } |
| OLD | NEW |