| 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 #include <AdblockPlus/JsValue.h> | 
| 7 | 8 | 
| 8 namespace AdblockPlus | 9 namespace AdblockPlus | 
| 9 { | 10 { | 
| 10   class ErrorCallback; | 11   class ErrorCallback; | 
| 11   class FileReader; | 12   class FileReader; | 
| 12   class WebRequest; | 13   class WebRequest; | 
| 13 | 14 | 
| 14   class JsError : public std::runtime_error | 15   class JsError : public std::runtime_error | 
| 15   { | 16   { | 
| 16   public: | 17   public: | 
| 17     explicit JsError(const v8::Handle<v8::Value> exception, | 18     explicit JsError(const v8::Handle<v8::Value> exception, | 
| 18         const v8::Handle<v8::Message> message); | 19         const v8::Handle<v8::Message> message); | 
| 19   }; | 20   }; | 
| 20 | 21 | 
| 21   class JsEngine | 22   class JsEngine | 
| 22   { | 23   { | 
|  | 24     friend class JsValue; | 
|  | 25 | 
| 23   public: | 26   public: | 
| 24     JsEngine(const FileReader* const fileReader, | 27     JsEngine(const FileReader* const fileReader, | 
| 25              WebRequest* const webRequest, | 28              WebRequest* const webRequest, | 
| 26              ErrorCallback* const errorCallback); | 29              ErrorCallback* const errorCallback); | 
| 27     std::string Evaluate(const std::string& source, | 30     JsValuePtr Evaluate(const std::string& source, | 
| 28         const std::string& filename = ""); | 31         const std::string& filename = ""); | 
| 29     void Load(const std::string& scriptPath); | 32     void Load(const std::string& scriptPath); | 
| 30     void Gc(); | 33     void Gc(); | 
|  | 34     JsValuePtr NewValue(const std::string& val); | 
|  | 35     JsValuePtr NewValue(int64_t val); | 
|  | 36     JsValuePtr NewValue(bool val); | 
|  | 37 | 
|  | 38     class Context | 
|  | 39     { | 
|  | 40     public: | 
|  | 41       Context(const JsEngine& jsEngine); | 
|  | 42       virtual inline ~Context() {}; | 
|  | 43 | 
|  | 44     private: | 
|  | 45       const v8::Locker locker; | 
|  | 46       const v8::HandleScope handleScope; | 
|  | 47       const v8::Context::Scope contextScope; | 
|  | 48     }; | 
| 31 | 49 | 
| 32   private: | 50   private: | 
| 33     const FileReader* const fileReader; | 51     const FileReader* const fileReader; | 
|  | 52     v8::Isolate* isolate; | 
| 34     v8::Persistent<v8::Context> context; | 53     v8::Persistent<v8::Context> context; | 
| 35   }; | 54   }; | 
| 36 } | 55 } | 
| 37 | 56 | 
| 38 #endif | 57 #endif | 
| OLD | NEW | 
|---|