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