#ifndef SRC_NODE_CONTEXTIFY_H_ #define SRC_NODE_CONTEXTIFY_H_ #include "node_internals.h" #include "node_watchdog.h" #include "base_object-inl.h" namespace node { namespace contextify { class ContextifyContext { protected: // V8 reserves the first field in context objects for the debugger. We use the // second field to hold a reference to the sandbox object. enum { kSandboxObjectIndex = 1 }; Environment* const env_; Persistent context_; public: ContextifyContext(Environment* env, v8::Local sandbox_obj, v8::Local options_obj); v8::Local CreateDataWrapper(Environment* env); v8::Local CreateV8Context(Environment* env, v8::Local sandbox_obj, v8::Local options_obj); static void Init(Environment* env, v8::Local target); static ContextifyContext* ContextFromContextifiedSandbox( Environment* env, const v8::Local& sandbox); inline Environment* env() const { return env_; } inline v8::Local context() const { return PersistentToLocal(env()->isolate(), context_); } inline v8::Local global_proxy() const { return context()->Global(); } inline v8::Local sandbox() const { return v8::Local::Cast( context()->GetEmbedderData(kSandboxObjectIndex)); } private: static void MakeContext(const v8::FunctionCallbackInfo& args); static void IsContext(const v8::FunctionCallbackInfo& args); static void WeakCallback( const v8::WeakCallbackInfo& data); static void PropertyGetterCallback( v8::Local property, const v8::PropertyCallbackInfo& args); static void PropertySetterCallback( v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& args); static void PropertyDescriptorCallback( v8::Local property, const v8::PropertyCallbackInfo& args); static void PropertyDefinerCallback( v8::Local property, const v8::PropertyDescriptor& desc, const v8::PropertyCallbackInfo& args); static void PropertyDeleterCallback( v8::Local property, const v8::PropertyCallbackInfo& args); static void PropertyEnumeratorCallback( const v8::PropertyCallbackInfo& args); static void IndexedPropertyGetterCallback( uint32_t index, const v8::PropertyCallbackInfo& args); static void IndexedPropertySetterCallback( uint32_t index, v8::Local value, const v8::PropertyCallbackInfo& args); static void IndexedPropertyDescriptorCallback( uint32_t index, const v8::PropertyCallbackInfo& args); static void IndexedPropertyDefinerCallback( uint32_t index, const v8::PropertyDescriptor& desc, const v8::PropertyCallbackInfo& args); static void IndexedPropertyDeleterCallback( uint32_t index, const v8::PropertyCallbackInfo& args); }; v8::Maybe GetBreakOnSigintArg( Environment* env, v8::Local options); v8::Maybe GetTimeoutArg( Environment* env, v8::Local options); v8::MaybeLocal GetLineOffsetArg( Environment* env, v8::Local options); v8::MaybeLocal GetColumnOffsetArg( Environment* env, v8::Local options); v8::MaybeLocal GetContextArg( Environment* env, v8::Local options); } // namespace contextify } // namespace node #endif // SRC_NODE_CONTEXTIFY_H_