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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 18 matching lines...) Expand all Loading... |
29 #include <AdblockPlus/JsValue.h> | 29 #include <AdblockPlus/JsValue.h> |
30 #include <AdblockPlus/WebRequest.h> | 30 #include <AdblockPlus/WebRequest.h> |
31 | 31 |
32 namespace v8 | 32 namespace v8 |
33 { | 33 { |
34 class Arguments; | 34 class Arguments; |
35 class Isolate; | 35 class Isolate; |
36 class Value; | 36 class Value; |
37 class Context; | 37 class Context; |
38 template<class T> class Handle; | 38 template<class T> class Handle; |
39 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); | 39 template<typename T> class FunctionCallbackInfo; |
| 40 typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>& info); |
40 } | 41 } |
41 | 42 |
42 namespace AdblockPlus | 43 namespace AdblockPlus |
43 { | 44 { |
44 class JsEngine; | 45 class JsEngine; |
45 | 46 |
46 /** | 47 /** |
47 * Shared smart pointer to a `JsEngine` instance. | 48 * Shared smart pointer to a `JsEngine` instance. |
48 */ | 49 */ |
49 typedef std::shared_ptr<JsEngine> JsEnginePtr; | 50 typedef std::shared_ptr<JsEngine> JsEnginePtr; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 */ | 169 */ |
169 JsValuePtr NewObject(); | 170 JsValuePtr NewObject(); |
170 | 171 |
171 /** | 172 /** |
172 * Creates a JavaScript function that invokes a C++ callback. | 173 * Creates a JavaScript function that invokes a C++ callback. |
173 * @param callback C++ callback to invoke. The callback receives a | 174 * @param callback C++ callback to invoke. The callback receives a |
174 * `v8::Arguments` object and can use `FromArguments()` to retrieve | 175 * `v8::Arguments` object and can use `FromArguments()` to retrieve |
175 * the current `JsEngine`. | 176 * the current `JsEngine`. |
176 * @return New `JsValue` instance. | 177 * @return New `JsValue` instance. |
177 */ | 178 */ |
178 JsValuePtr NewCallback(v8::InvocationCallback callback); | 179 JsValuePtr NewCallback(v8::FunctionCallback callback); |
179 | 180 |
180 /** | 181 /** |
181 * Returns a `JsEngine` instance contained in a `v8::Arguments` object. | 182 * Returns a `JsEngine` instance contained in a `v8::Arguments` object. |
182 * Use this in callbacks created via `NewCallback()` to retrieve the current | 183 * Use this in callbacks created via `NewCallback()` to retrieve the current |
183 * `JsEngine`. | 184 * `JsEngine`. |
184 * @param arguments `v8::Arguments` object containing the `JsEngine` | 185 * @param arguments `v8::Arguments` object containing the `JsEngine` |
185 * instance. | 186 * instance. |
186 * @return `JsEngine` instance from `v8::Arguments`. | 187 * @return `JsEngine` instance from `v8::Arguments`. |
187 */ | 188 */ |
188 static JsEnginePtr FromArguments(const v8::Arguments& arguments); | 189 static JsEnginePtr FromArguments(const v8::FunctionCallbackInfo<v8::Value>&
arguments); |
189 | 190 |
190 /** | 191 /** |
191 * Converts v8 arguments to `JsValue` objects. | 192 * Converts v8 arguments to `JsValue` objects. |
192 * @param arguments `v8::Arguments` object containing the arguments to | 193 * @param arguments `v8::Arguments` object containing the arguments to |
193 * convert. | 194 * convert. |
194 * @return List of arguments converted to `JsValue` objects. | 195 * @return List of arguments converted to `JsValue` objects. |
195 */ | 196 */ |
196 JsValueList ConvertArguments(const v8::Arguments& arguments); | 197 JsValueList ConvertArguments(const v8::FunctionCallbackInfo<v8::Value>& argu
ments); |
197 | 198 |
198 /** | 199 /** |
199 * @see `SetFileSystem()`. | 200 * @see `SetFileSystem()`. |
200 */ | 201 */ |
201 FileSystemPtr GetFileSystem(); | 202 FileSystemPtr GetFileSystem(); |
202 | 203 |
203 /** | 204 /** |
204 * Sets the `FileSystem` implementation used for all file I/O. | 205 * Sets the `FileSystem` implementation used for all file I/O. |
205 * Setting this is optional, the engine will use a `DefaultFileSystem` | 206 * Setting this is optional, the engine will use a `DefaultFileSystem` |
206 * instance by default, which might be sufficient. | 207 * instance by default, which might be sufficient. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 private: | 254 private: |
254 explicit JsEngine(const ScopedV8IsolatePtr& isolate); | 255 explicit JsEngine(const ScopedV8IsolatePtr& isolate); |
255 | 256 |
256 /// Isolate must be disposed only after disposing of all objects which are | 257 /// Isolate must be disposed only after disposing of all objects which are |
257 /// using it. | 258 /// using it. |
258 ScopedV8IsolatePtr isolate; | 259 ScopedV8IsolatePtr isolate; |
259 | 260 |
260 FileSystemPtr fileSystem; | 261 FileSystemPtr fileSystem; |
261 WebRequestPtr webRequest; | 262 WebRequestPtr webRequest; |
262 LogSystemPtr logSystem; | 263 LogSystemPtr logSystem; |
263 std::unique_ptr<v8::Persistent<v8::Context>> context; | 264 std::unique_ptr<v8::UniquePersistent<v8::Context>> context; |
264 EventMap eventCallbacks; | 265 EventMap eventCallbacks; |
265 JsValuePtr globalJsObject; | 266 JsValuePtr globalJsObject; |
266 }; | 267 }; |
267 } | 268 } |
268 | 269 |
269 #endif | 270 #endif |
OLD | NEW |