OLD | NEW |
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 | 7 |
8 namespace AdblockPlus | 8 namespace AdblockPlus |
9 { | 9 { |
10 class ErrorCallback; | 10 class ErrorCallback; |
11 class FileReader; | 11 class FileReader; |
| 12 class WebRequest; |
12 | 13 |
13 class JsError : public std::runtime_error | 14 class JsError : public std::runtime_error |
14 { | 15 { |
15 public: | 16 public: |
16 explicit JsError(const v8::Handle<v8::Value> exception, | 17 explicit JsError(const v8::Handle<v8::Value> exception, |
17 const v8::Handle<v8::Message> message); | 18 const v8::Handle<v8::Message> message); |
18 }; | 19 }; |
19 | 20 |
20 class JsEngine | 21 class JsEngine |
21 { | 22 { |
22 public: | 23 public: |
23 JsEngine(const FileReader* const fileReader, | 24 JsEngine(const FileReader* const fileReader, |
| 25 WebRequest* const webRequest, |
24 ErrorCallback* const errorCallback); | 26 ErrorCallback* const errorCallback); |
25 void Evaluate(const char* source, const char* filename = NULL); | 27 std::string Evaluate(const char* source, const char* filename = NULL); |
26 void Evaluate(const std::string& source, | 28 std::string Evaluate(const std::string& source, |
27 const std::string& filename = ""); | 29 const std::string& filename = ""); |
28 void Load(const std::string& scriptPath); | 30 void Load(const std::string& scriptPath); |
29 std::string Call(const std::string& functionName); | 31 std::string Call(const std::string& functionName); |
30 std::string GetVariable(const std::string& name); | 32 std::string GetVariable(const std::string& name); |
31 void Gc(); | 33 void Gc(); |
32 | 34 |
33 private: | 35 private: |
34 const FileReader* const fileReader; | 36 const FileReader* const fileReader; |
35 v8::Persistent<v8::Context> context; | 37 v8::Persistent<v8::Context> context; |
36 }; | 38 }; |
37 } | 39 } |
38 | 40 |
39 #endif | 41 #endif |
OLD | NEW |