X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Fdali-wrapper.h;h=f1767e4fd06265cec1c3930c97afc70d0903ea09;hp=27d4fd31aa94faedc0d158d82ad834bc601dcb23;hb=c4a92ccf72121cbe2a015711e4253e8d16f28fef;hpb=928136dbb9e23970f3894eabc7c8b224003b77be diff --git a/plugins/dali-script-v8/src/dali-wrapper.h b/plugins/dali-script-v8/src/dali-wrapper.h index 27d4fd3..f1767e4 100644 --- a/plugins/dali-script-v8/src/dali-wrapper.h +++ b/plugins/dali-script-v8/src/dali-wrapper.h @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include + #include namespace Dali @@ -65,12 +66,25 @@ namespace V8Plugin */ class DALI_INTERNAL DaliWrapper { + public: /** - * Constructor + * @brief whether the wrapper is running in standalone using V8, + * or inside Node.JS using V8 */ - DaliWrapper(); + enum RunMode + { + RUNNING_STANDALONE, + RUNNING_IN_NODE_JS + }; + + /** + * @brief Constructor + * @param[in] runMode whether the wrapper is running standalone or inside Node.JS + * @param[in] isolate v8 isolate ( can be null if running standalone ) + */ + DaliWrapper( RunMode runMode, v8::Isolate* isolate ); /** * non virtual destructor, not intended as a base class @@ -85,6 +99,12 @@ public: static DaliWrapper& Get(); /** + * Intialize DaliWrapper for running inside NodeJS + */ + static v8::Local CreateWrapperForNodeJS( v8::Isolate* isolate); + + + /** * Set V8 engine configuration flags * * @param[in] flags Configruation flags (See v8 documentation) @@ -101,16 +121,18 @@ public: * * @param[in] sourceCode The buffer containing javascript to execute * @param[in] sourceFileName Filename associated with the buffer (for error tracing) + * @return true on success, false on failure */ - void ExecuteBuffer(const std::string &sourceCode, const std::string &sourceFileName); + bool ExecuteBuffer(const std::string &sourceCode, const std::string &sourceFileName); /** * Excute the buffer in the v8 context * * @param[in] sourceFileName Filename associated with the buffer (for error tracing) + * @return true on success, false on failure */ - void ExecuteFile( const std::string& sourceFileName); + bool ExecuteFile( const std::string& sourceFileName); /** @@ -122,14 +144,21 @@ public: private: /** - * Create V8 context + * @brief Apply global objects like console.log and require() to the context */ - void CreateContext(); + void ApplyGlobalObjectsToContext( v8::Local context ); /** - * Initialize DaliWrapper + * @brief Initialize DaliWrapper for running standalone + * Creates a new isolate + * */ - void Initialize(); + void InitializeStandAlone(); + + /** + * @brief create dali namespace/object + */ + v8::Local CreateDaliObject(); /** * Create Dali ObjectTemplate @@ -148,9 +177,8 @@ private: GarbageCollector mGarbageCollector; ///< DALi garbage collector ModuleLoader mModuleLoader; ///< Module loader v8::Persistent mContext; ///< A sandboxed execution context with its own set of built-in objects and functions. - v8::Persistent mGlobalObjectTemplate; ///< Global object template for storing things like dali global object v8::Isolate* mIsolate; ///< represents an isolated instance of the V8 engine. - + RunMode mRunMode; };