| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "tr1_memory.h" | 32 #include "tr1_memory.h" |
| 33 | 33 |
| 34 namespace v8 | 34 namespace v8 |
| 35 { | 35 { |
| 36 class Arguments; | 36 class Arguments; |
| 37 class Isolate; | 37 class Isolate; |
| 38 class Value; | 38 class Value; |
| 39 class Context; | 39 class Context; |
| 40 template<class T> class Handle; | 40 template<class T> class Handle; |
| 41 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); | 41 template<typename T> class FunctionCallbackInfo; |
| 42 typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>& info); |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace AdblockPlus | 45 namespace AdblockPlus |
| 45 { | 46 { |
| 46 class JsEngine; | 47 class JsEngine; |
| 47 | 48 |
| 48 /** | 49 /** |
| 49 * Shared smart pointer to a `JsEngine` instance. | 50 * Shared smart pointer to a `JsEngine` instance. |
| 50 */ | 51 */ |
| 51 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; | 52 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 */ | 159 */ |
| 159 JsValuePtr NewObject(); | 160 JsValuePtr NewObject(); |
| 160 | 161 |
| 161 /** | 162 /** |
| 162 * Creates a JavaScript function that invokes a C++ callback. | 163 * Creates a JavaScript function that invokes a C++ callback. |
| 163 * @param callback C++ callback to invoke. The callback receives a | 164 * @param callback C++ callback to invoke. The callback receives a |
| 164 * `v8::Arguments` object and can use `FromArguments()` to retrieve | 165 * `v8::Arguments` object and can use `FromArguments()` to retrieve |
| 165 * the current `JsEngine`. | 166 * the current `JsEngine`. |
| 166 * @return New `JsValue` instance. | 167 * @return New `JsValue` instance. |
| 167 */ | 168 */ |
| 168 JsValuePtr NewCallback(v8::InvocationCallback callback); | 169 JsValuePtr NewCallback(v8::FunctionCallback callback); |
| 169 | 170 |
| 170 /** | 171 /** |
| 171 * Returns a `JsEngine` instance contained in a `v8::Arguments` object. | 172 * Returns a `JsEngine` instance contained in a `v8::Arguments` object. |
| 172 * Use this in callbacks created via `NewCallback()` to retrieve the current | 173 * Use this in callbacks created via `NewCallback()` to retrieve the current |
| 173 * `JsEngine`. | 174 * `JsEngine`. |
| 174 * @param arguments `v8::Arguments` object containing the `JsEngine` | 175 * @param arguments `v8::Arguments` object containing the `JsEngine` |
| 175 * instance. | 176 * instance. |
| 176 * @return `JsEngine` instance from `v8::Arguments`. | 177 * @return `JsEngine` instance from `v8::Arguments`. |
| 177 */ | 178 */ |
| 178 static JsEnginePtr FromArguments(const v8::Arguments& arguments); | 179 static JsEnginePtr FromArguments(const v8::FunctionCallbackInfo<v8::Value>&
arguments); |
| 179 | 180 |
| 180 /** | 181 /** |
| 181 * Converts v8 arguments to `JsValue` objects. | 182 * Converts v8 arguments to `JsValue` objects. |
| 182 * @param arguments `v8::Arguments` object containing the arguments to | 183 * @param arguments `v8::Arguments` object containing the arguments to |
| 183 * convert. | 184 * convert. |
| 184 * @return List of arguments converted to `JsValue` objects. | 185 * @return List of arguments converted to `JsValue` objects. |
| 185 */ | 186 */ |
| 186 JsValueList ConvertArguments(const v8::Arguments& arguments); | 187 JsValueList ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& argu
ments); |
| 187 | 188 |
| 188 /** | 189 /** |
| 189 * @see `SetFileSystem()`. | 190 * @see `SetFileSystem()`. |
| 190 */ | 191 */ |
| 191 FileSystemPtr GetFileSystem(); | 192 FileSystemPtr GetFileSystem(); |
| 192 | 193 |
| 193 /** | 194 /** |
| 194 * Sets the `FileSystem` implementation used for all file I/O. | 195 * Sets the `FileSystem` implementation used for all file I/O. |
| 195 * Setting this is optional, the engine will use a `DefaultFileSystem` | 196 * Setting this is optional, the engine will use a `DefaultFileSystem` |
| 196 * instance by default, which might be sufficient. | 197 * instance by default, which might be sufficient. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 223 * instance by default, which might be sufficient. | 224 * instance by default, which might be sufficient. |
| 224 * @param The `LogSystem` instance to use. | 225 * @param The `LogSystem` instance to use. |
| 225 */ | 226 */ |
| 226 void SetLogSystem(LogSystemPtr val); | 227 void SetLogSystem(LogSystemPtr val); |
| 227 | 228 |
| 228 private: | 229 private: |
| 229 JsEngine(); | 230 JsEngine(); |
| 230 FileSystemPtr fileSystem; | 231 FileSystemPtr fileSystem; |
| 231 WebRequestPtr webRequest; | 232 WebRequestPtr webRequest; |
| 232 LogSystemPtr logSystem; | 233 LogSystemPtr logSystem; |
| 233 std::unique_ptr<v8::Persistent<v8::Context>> context; | 234 std::unique_ptr<v8::UniquePersistent<v8::Context>> context; |
| 234 EventMap eventCallbacks; | 235 EventMap eventCallbacks; |
| 235 }; | 236 }; |
| 236 } | 237 } |
| 237 | 238 |
| 238 #endif | 239 #endif |
| OLD | NEW |