+v8::Local<v8::Object> DaliWrapper::CreateWrapperForNodeJS( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate);
+
+ mInstanceCreated = true;
+
+ mWrapper = new DaliWrapper( RUNNING_IN_NODE_JS, isolate );
+
+ v8::Local<v8::Object> dali = mWrapper->CreateDaliObject();
+
+ // As we running inside node, we already have an isolate and context
+ return handleScope.Escape( dali );
+}
+
+v8::Local<v8::Object> DaliWrapper::CreateDaliObject()
+{
+ v8::EscapableHandleScope handleScope( mIsolate );
+
+ // Create dali object used for creating objects, and accessing constant values
+ // e.g. var x = new dali.Actor(), or var col = dali.COLOR_RED;
+
+ v8::Local<v8::ObjectTemplate> daliObjectTemplate = NewDaliObjectTemplate( mIsolate );
+
+ // add dali.staqe
+ v8::Local<v8::Object> stageObject = StageWrapper::WrapStage( mIsolate, Stage::GetCurrent() );
+ daliObjectTemplate->Set( v8::String::NewFromUtf8( mIsolate, "stage") , stageObject );
+
+ v8::Local<v8::Object> keyboardObject = KeyboardFocusManagerWrapper::WrapKeyboardFocusManager( mIsolate,Toolkit::KeyboardFocusManager::Get() );
+ daliObjectTemplate->Set( v8::String::NewFromUtf8( mIsolate, "keyboardFocusManager") , keyboardObject );
+
+
+ //create an instance of the template
+ v8::Local<v8::Object> daliObject = daliObjectTemplate->NewInstance();
+
+ ConstantsWrapper::AddDaliConstants( mIsolate, daliObject);
+
+ daliObject->Set( v8::String::NewFromUtf8( mIsolate, "V8_VERSION") ,v8::String::NewFromUtf8( mIsolate, v8::V8::GetVersion() ));
+
+ return handleScope.Escape( daliObject );
+}
+
+