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