LEFT | RIGHT |
1 #ifndef ADBLOCKPLUS_JS_ENGINE_H | 1 #ifndef ADBLOCKPLUS_JS_ENGINE_H |
2 #define ADBLOCKPLUS_JS_ENGINE_H | 2 #define ADBLOCKPLUS_JS_ENGINE_H |
3 | 3 |
4 #include <stdexcept> | 4 #include <stdexcept> |
5 #include <string> | 5 #include <string> |
6 #include <v8.h> | 6 #include <v8.h> |
7 #include <AdblockPlus/JsValue.h> | 7 #include <AdblockPlus/JsValue.h> |
8 | 8 |
9 namespace AdblockPlus | 9 namespace AdblockPlus |
10 { | 10 { |
| 11 struct AppInfo; |
11 class FileSystem; | 12 class FileSystem; |
12 class WebRequest; | 13 class WebRequest; |
13 class ErrorCallback; | 14 class ErrorCallback; |
14 | 15 |
15 class JsError : public std::runtime_error | 16 class JsError : public std::runtime_error |
16 { | 17 { |
17 public: | 18 public: |
18 explicit JsError(const v8::Handle<v8::Value> exception, | 19 explicit JsError(const v8::Handle<v8::Value> exception, |
19 const v8::Handle<v8::Message> message); | 20 const v8::Handle<v8::Message> message); |
20 }; | 21 }; |
21 | 22 |
22 class JsEngine | 23 class JsEngine |
23 { | 24 { |
24 friend class JsValue; | 25 friend class JsValue; |
25 | 26 |
26 public: | 27 public: |
27 JsEngine(FileSystem* const fileReader, | 28 JsEngine(const AppInfo& appInfo, |
| 29 FileSystem* const fileReader, |
28 WebRequest* const webRequest, | 30 WebRequest* const webRequest, |
29 ErrorCallback* const errorCallback); | 31 ErrorCallback* const errorCallback); |
30 JsValuePtr Evaluate(const std::string& source, | 32 JsValuePtr Evaluate(const std::string& source, |
31 const std::string& filename = ""); | 33 const std::string& filename = ""); |
32 void Load(const std::string& scriptPath); | 34 void Load(const std::string& scriptPath); |
33 void Gc(); | 35 void Gc(); |
34 JsValuePtr NewValue(const std::string& val); | 36 JsValuePtr NewValue(const std::string& val); |
35 JsValuePtr NewValue(int64_t val); | 37 JsValuePtr NewValue(int64_t val); |
36 JsValuePtr NewValue(bool val); | 38 JsValuePtr NewValue(bool val); |
37 inline JsValuePtr NewValue(const char* val) | 39 inline JsValuePtr NewValue(const char* val) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 private: | 77 private: |
76 FileSystem& fileSystem; | 78 FileSystem& fileSystem; |
77 WebRequest& webRequest; | 79 WebRequest& webRequest; |
78 ErrorCallback& errorCallback; | 80 ErrorCallback& errorCallback; |
79 v8::Isolate* isolate; | 81 v8::Isolate* isolate; |
80 v8::Persistent<v8::Context> context; | 82 v8::Persistent<v8::Context> context; |
81 }; | 83 }; |
82 } | 84 } |
83 | 85 |
84 #endif | 86 #endif |
LEFT | RIGHT |