Index: include/AdblockPlus/JsEngine.h |
=================================================================== |
--- a/include/AdblockPlus/JsEngine.h |
+++ b/include/AdblockPlus/JsEngine.h |
@@ -17,41 +17,44 @@ |
#ifndef ADBLOCK_PLUS_JS_ENGINE_H |
#define ADBLOCK_PLUS_JS_ENGINE_H |
#include <map> |
#include <stdexcept> |
#include <stdint.h> |
#include <string> |
-#include <v8.h> |
#include <AdblockPlus/AppInfo.h> |
#include <AdblockPlus/tr1_functional.h> |
#include <AdblockPlus/LogSystem.h> |
#include <AdblockPlus/FileSystem.h> |
#include <AdblockPlus/JsValue.h> |
#include <AdblockPlus/WebRequest.h> |
#include "tr1_memory.h" |
+namespace v8 |
+{ |
+ class Arguments; |
+ class Isolate; |
+ class Context; |
+ template <class T> class Handle; |
+ template <class T> class Persistent; |
+ typedef Handle<Value>(*InvocationCallback)(const Arguments &args); |
+} |
+ |
namespace AdblockPlus |
{ |
- class JsError : public std::runtime_error |
- { |
- public: |
- JsError(const v8::Handle<v8::Value> exception, |
- const v8::Handle<v8::Message> message); |
- }; |
- |
class JsEngine; |
typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; |
class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> |
{ |
friend class JsValue; |
+ friend class JsContext; |
public: |
typedef std::tr1::function<void()> EventCallback; |
typedef std::map<std::string, EventCallback> EventMap; |
static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); |
void SetEventCallback(const std::string& eventName, EventCallback callback); |
void RemoveEventCallback(const std::string& eventName); |
@@ -83,33 +86,21 @@ namespace AdblockPlus |
FileSystemPtr GetFileSystem(); |
void SetFileSystem(FileSystemPtr val); |
WebRequestPtr GetWebRequest(); |
void SetWebRequest(WebRequestPtr val); |
LogSystemPtr GetLogSystem(); |
void SetLogSystem(LogSystemPtr val); |
- class Context |
- { |
- public: |
- Context(const JsEnginePtr jsEngine); |
- virtual inline ~Context() {}; |
- |
- private: |
- const v8::Locker locker; |
- const v8::HandleScope handleScope; |
- const v8::Context::Scope contextScope; |
- }; |
- |
private: |
JsEngine(); |
FileSystemPtr fileSystem; |
WebRequestPtr webRequest; |
LogSystemPtr logSystem; |
v8::Isolate* isolate; |
- v8::Persistent<v8::Context> context; |
+ std::auto_ptr<v8::Persistent<v8::Context> > context; |
EventMap eventCallbacks; |
}; |
} |
#endif |