Merge branch 'tizen' into devel/new_mesh
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / src / actors / actor-wrapper.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "actor-wrapper.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23
24 // INTERNAL INCLUDES
25 #include <actors/layer-api.h>
26 #include <actors/actor-api.h>
27 #include <actors/image-actor-api.h>
28 #include <actors/text-actor-api.h>
29 #include <actors/mesh-actor-api.h>
30 #include <actors/camera-actor-api.h>
31 #include <actors/renderable-actor-api.h>
32 #include <v8-utils.h>
33 #include <dali-wrapper.h>
34
35 namespace Dali
36 {
37
38 namespace V8Plugin
39 {
40
41 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mActorTemplate;
42 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mImageActorTemplate;
43 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mTextActorTemplate;
44 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mMeshActorTemplate;
45 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mCameraActorTemplate;
46 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mLayerActorTemplate;
47 v8::Persistent<v8::ObjectTemplate> ActorWrapper::mTextViewTemplate;
48
49 namespace
50 {
51
52
53 /**
54  * pointer to a persistent template handle
55  */
56 struct ActorTemplate
57 {
58   v8::Persistent<v8::ObjectTemplate>* actorTemplate;
59 };
60
61 /**
62  * array of templates for each type of actor
63  */
64 const ActorTemplate ActorTemplateLookup[]=
65 {
66     { &ActorWrapper::mActorTemplate },        // ACTOR
67     { &ActorWrapper::mImageActorTemplate },   // IMAGE_ACTOR
68     { &ActorWrapper::mTextActorTemplate  },   // TEXT_ACTOR
69     { &ActorWrapper::mMeshActorTemplate  },   // MESH_ACTOR
70     { &ActorWrapper::mLayerActorTemplate },   // LAYER_ACTOR
71     { &ActorWrapper::mCameraActorTemplate},   // CAMERA_ACTOR
72     { &ActorWrapper::mTextViewTemplate }
73 };
74
75 /**
76  * Bitmask of API's that an actor can support
77  */
78 enum ActorApiBitMask
79 {
80   ACTOR_API              = 1 << 0,
81   RENDERABLE_ACTOR_API   = 1 << 1,
82   IMAGE_ACTOR_API        = 1 << 2,
83   TEXT_ACTOR_API         = 1 << 3,
84   MESH_ACTOR_API         = 1 << 4,
85   LAYER_API              = 1 << 5,
86   CAMERA_ACTOR_API       = 1 << 6,
87 };
88
89 /**
90  * structure used for the ActorApiLookup.
91  */
92 struct ActorApiStruct
93 {
94   const char* actorName;
95   ActorWrapper::ActorType actorType;
96   Actor (*constructor)( const v8::FunctionCallbackInfo< v8::Value >& args);
97   int supportApis;
98 };
99
100 /**
101  * Lookup table to match a actor type with a constructor and supported API's.
102  */
103 const ActorApiStruct ActorApiLookup[]=
104 {
105   {"Actor",      ActorWrapper::ACTOR,        ActorApi::New,       ACTOR_API },
106   {"ImageActor", ActorWrapper::IMAGE_ACTOR,  ImageActorApi::New,  ACTOR_API | RENDERABLE_ACTOR_API | IMAGE_ACTOR_API   },
107   {"TextActor",  ActorWrapper::TEXT_ACTOR,   TextActorApi::New,   ACTOR_API | RENDERABLE_ACTOR_API | TEXT_ACTOR_API    },
108   {"MeshActor",  ActorWrapper::MESH_ACTOR,   MeshActorApi::New,   ACTOR_API | RENDERABLE_ACTOR_API | MESH_ACTOR_API    },
109   {"Layer",      ActorWrapper::LAYER_ACTOR,  LayerApi::New,       ACTOR_API | LAYER_API                                },
110   {"CameraActor",ActorWrapper::CAMERA_ACTOR, CameraActorApi::New, ACTOR_API | CAMERA_ACTOR_API                         },
111   {"TextView",   ActorWrapper::TEXT_VIEW,    TextViewApi::New,    ACTOR_API },
112
113 };
114
115 const unsigned int ActorApiLookupCount = sizeof(ActorApiLookup)/sizeof(ActorApiLookup[0]);
116
117
118
119 /**
120  * Creates an actor given a type name
121  * Uses the type registry to create an actor of the correct type
122  */
123 Actor CreateActor( const v8::FunctionCallbackInfo< v8::Value >& args,
124                         const std::string& typeName )
125 {
126   Actor actor;
127
128   ActorWrapper::ActorType actorType = ActorWrapper::GetActorType( typeName );
129
130   // if we don't currently support the actor type, then use type registry to create it
131   if( actorType == ActorWrapper::UNKNOWN_ACTOR )
132   {
133     Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( typeName );
134     if( typeInfo ) // handle, check if it has a value
135     {
136       Dali::BaseHandle handle = typeInfo.CreateInstance();
137       if( handle )
138       {
139         actor = Actor::DownCast( handle );
140       }
141     }
142     else
143     {
144       DALI_SCRIPT_EXCEPTION(args.GetIsolate(),"Unknown actor type");
145       return Actor();
146     }
147   }
148   else
149   {
150     // run the constructor for this type of actor so it can pull out
151     // custom parameters, e.g. new TextActor("hello world"); or ImageActor( MyImage );
152     actor = (ActorApiLookup[actorType].constructor)( args );
153   }
154   return actor;
155 }
156
157
158
159 /**
160  * given an actor type return what api's it supports
161  */
162 int GetActorSupportedApis( ActorWrapper::ActorType type )
163 {
164   return ActorApiLookup[ type].supportApis;
165 }
166
167 /**
168  * Used for the ActorFunctionTable to map function names to functions
169  * with for a specific API
170  */
171 struct ActorFunctions
172 {
173   const char* name;               ///< function name
174   void (*function)( const v8::FunctionCallbackInfo< v8::Value >& args);
175   ActorApiBitMask api;
176 };
177
178 /**
179  * Contains a list of all functions that can be called an
180  * actor / image-actor / mesh-actor/ layer / camera-actor
181  */
182 const ActorFunctions ActorFunctionTable[]=
183 {
184     /**************************************
185     * Actor API (in order of actor.h)
186     * Any properties that have accessor functions are ignored to avoid duplication
187     **************************************/
188     // ignore. GetName()  use Actor.name
189     // ignore. SetName()  use Actor.name
190     { "GetId",             ActorApi::GetId,            ACTOR_API },
191     { "IsRoot",            ActorApi::IsRoot,           ACTOR_API },
192     { "OnStage",           ActorApi::OnStage,          ACTOR_API },
193     { "IsLayer",           ActorApi::IsLayer,          ACTOR_API },
194     { "GetLayer",          ActorApi::GetLayer,         ACTOR_API },
195     { "Add",               ActorApi::AddActor,         ACTOR_API },
196     { "Remove",            ActorApi::RemoveActor,      ACTOR_API },
197     { "IsEqualTo" ,        ActorApi::IsEqualTo,        ACTOR_API },
198     { "Unparent",          ActorApi::Unparent,         ACTOR_API },
199     { "GetChildCount",     ActorApi::GetChildCount,    ACTOR_API },
200     { "GetChildAt"   ,     ActorApi::GetChildAt,       ACTOR_API },
201     { "FindChildByName",   ActorApi::FindChildByName,  ACTOR_API },
202     { "FindChildById",     ActorApi::FindChildById,    ACTOR_API },
203     { "GetParent" ,        ActorApi::GetParent,        ACTOR_API },
204     { "GetActorType" ,     ActorApi::GetActorType,     ACTOR_API }, // custom for javascript
205     { "ApplyPathConstraint",  ActorApi::ApplyPathConstraint,  ACTOR_API }, // custom for javascript
206     { "RemovePathConstraint", ActorApi::RemovePathConstraint, ACTOR_API }, // custom for javascript
207
208     // ignore. SetParentOrigin() use Actor.parentOrigin
209     // ignore. GetCurrentParentOrigin()  use Actor.parentOrigin
210     // ignore. SetAnchorPoint()  use Actor.anchorPoint
211     // ignore. GetCurrentAnchorPoint()  use Actor.anchorPoint
212     // ignore. SetSize() use Actor.size
213     // ignore. GetCurrentSize() use Actor.size
214     // ignore. SetPosition(....) use Actor.position
215     // ignore. SetX, SetY, SetZ,  use Actor.position.x, Actor.position.y, Actor.position.z
216     { "TranslateBy",         ActorApi::TranslateBy,              ACTOR_API },
217     // ignore GetCurrentPosition(). use Actor.position
218     // ignore GetCurrentWorldPosition() use Actor.worldPosition
219     // ignore SetPositionInheritanceMode() use Actor.positionInheritance
220     // ignore GetPositionInheritanceMode()  use Actor.positionInheritance
221     // ignore SetOrientation() use Actor.orientation
222     { "RotateBy",         ActorApi::RotateBy,          ACTOR_API },
223     // ignore GetCurrentOrientation() use Actor.orientation
224     // ignore SetInheritOrientation() use Actor.inheritOrientation
225     // ignore IsOrientationInherited() use Actor.inheritOrientation
226     // ignore GetCurrentWorldOrientation() use Actor.worldOrientation
227     // ignore SetScale() use Actor.scale
228     { "ScaleBy",         ActorApi::ScaleBy,            ACTOR_API },
229     // ignore GetCurrentScale() use Actor.scale
230     // ignore GetCurrentWorldScale() use Actor.worldScale
231     // ignore SetInheritScale() use Actor.inheritScale
232     // ignore IsScaleInherited() use Actor.inheritScale
233     // ignore GetCurrentWorldMatrix() use Actor.worldMatrix
234     // ignore SetVisible() use Actor.visible
235     // ignore IsVisible() use Actor.visible
236     // ignore SetOpacity() use Actor.opacity
237     // ignore GetCurrentOpacity() use Actor.opacity
238     // ignore SetColor() use Actor.color
239     // ignore GetCurrentColor() use Actor.color
240     // ignore SetColorMode() use Actor.colorMode
241     // ignore GetColorMode() use Actor.colorMode
242     // ignore GetCurrentWorldColor() use Actor.worldColor
243     // ignore SetInheritShaderEffect() use Actor.inheritShaderEffect
244     // ignore GetInheritShaderEffect() use Actor.inheritShaderEffect
245     // ignore SetDrawMode() use Actor.drawMode
246     // ignore GetDrawMode() use Actor.drawMode
247     // ignore SetSensitive() use Actor.sensitve
248     // ignore IsSensitive() use Actor.sensitive
249     { "ScreenToLocal"       , ActorApi::ScreenToLocal,         ACTOR_API},
250     // ignore SetLeaveRequired() use Actor.leaveRequired
251     // ignore GetLeaveRequired() use Actor.leaveRequired
252     { "SetKeyboardFocusable", ActorApi::SetKeyboardFocusable,  ACTOR_API }, //-- should this be a property???
253     { "IsKeyboardFocusable" , ActorApi::IsKeyboardFocusable,   ACTOR_API }, //-- should this be a property???
254
255     /**************************************
256      * Renderable Actor API (in order of renderable-actor.h)
257      **************************************/
258     { "SetSortModifier",    RenderableActorApi::SetSortModifier,   RENDERABLE_ACTOR_API  },
259     { "GetSortModifier",    RenderableActorApi::GetSortModifier,   RENDERABLE_ACTOR_API  },
260     { "SetCullFace",        RenderableActorApi::SetCullFace,       RENDERABLE_ACTOR_API  },
261     { "GetCullFace",        RenderableActorApi::GetCullFace,       RENDERABLE_ACTOR_API  },
262     { "SetBlendMode",       RenderableActorApi::SetBlendMode,      RENDERABLE_ACTOR_API  },
263     { "GetBlendMode",       RenderableActorApi::GetBlendMode,      RENDERABLE_ACTOR_API  },
264     { "SetBlendFunc",       RenderableActorApi::SetBlendFunc,      RENDERABLE_ACTOR_API  },
265     { "GetBlendFunc",       RenderableActorApi::GetBlendFunc,      RENDERABLE_ACTOR_API  },
266     { "SetBlendEquation",   RenderableActorApi::SetBlendEquation,  RENDERABLE_ACTOR_API  },
267     { "GetBlendEquation",   RenderableActorApi::GetBlendEquation,  RENDERABLE_ACTOR_API  },
268     { "SetBlendColor",      RenderableActorApi::SetBlendColor,     RENDERABLE_ACTOR_API  },
269     { "GetBlendColor",      RenderableActorApi::GetBlendColor,     RENDERABLE_ACTOR_API  },
270     { "SetShaderEffect",    RenderableActorApi::SetShaderEffect,   RENDERABLE_ACTOR_API  },
271     { "GetShaderEffect",    RenderableActorApi::GetShaderEffect,   RENDERABLE_ACTOR_API  },
272     { "RemoveShaderEffect", RenderableActorApi::RemoveShaderEffect,RENDERABLE_ACTOR_API  },
273
274
275
276
277     /**************************************
278      * Layer  API (in order of layer.h)
279      **************************************/
280     { "GetDepth",           LayerApi::GetDepth,                 LAYER_API  },
281     { "Raise",              LayerApi::Raise,                    LAYER_API  },
282     { "Lower",              LayerApi::Lower,                    LAYER_API  },
283     { "RaiseAbove",         LayerApi::RaiseAbove,               LAYER_API  },
284     { "RaiseBelow",         LayerApi::LowerBelow,               LAYER_API  },
285     { "RaiseToTop",         LayerApi::RaiseToTop,               LAYER_API  },
286     { "LowerToBottom",      LayerApi::ToBottom,                 LAYER_API  },
287     { "MoveAbove",          LayerApi::MoveAbove,                LAYER_API  },
288     { "MoveBelow",          LayerApi::MoveBelow,                LAYER_API  },
289     // ignore SetClipping, use layer.clippingEnable
290     // ignore IsClipping, use layer.clippingEnable
291     // ignore SetClippingBox, use layer.clippingBox
292     { "SetDepthTestDisabled", LayerApi::SetDepthTestDisabled,   LAYER_API },
293     { "IsDepthTestDisabled",  LayerApi::IsDepthTestDisabled,    LAYER_API },
294     // @todo SetSortFunction
295
296     /**************************************
297      * Image Actor API (in order of image-actor.h)
298      **************************************/
299
300     { "SetImage",           ImageActorApi::SetImage,              IMAGE_ACTOR_API },
301     { "GetImage",           ImageActorApi::GetImage,              IMAGE_ACTOR_API },
302     { "SetToNaturalSize",   ImageActorApi::SetToNaturalSize,      IMAGE_ACTOR_API },
303     // ignore SetPixelArea, use imageActor.pixelArea
304     // ignore GetPixelArea, use imageActor.pixelArea
305     { "IsPixelAreaSet",     ImageActorApi::IsPixelAreaSet,        IMAGE_ACTOR_API },
306     { "ClearPixelArea",     ImageActorApi::ClearPixelArea,        IMAGE_ACTOR_API },
307     // ignore SetStyle, use imageActor.style
308     // ignore GetStyle, use imageActor.style
309     // ignore SetNinePatchBorder use imageActor.border
310     // ignore GetNinePatchBorder use imageActor.border
311     // ignore SetFadeIn use imageActor.fadeIn
312     // ignore GetFadeIn use imageActor.fadeIn
313     // ignore SetFadeInDuration use imageActor.fadeInDuration
314     // ignore GetFadeInDuration use imageActor.fadeInDuration
315     //{ "GetCurrentImageSize", ImageActorApi::GetCurrentImageSize,  IMAGE_ACTOR_API },
316
317
318     /**************************************
319      * Text Actor API (in order of text-actor.h)
320      **************************************/
321     //ignore SetText use textActor.text
322     { "SetToNaturalSize",   TextActorApi::SetToNaturalSize,      TEXT_ACTOR_API },
323     // ignore GetFont use textActor.font
324     // ignore SetFont use textActor.font
325     // ignore SetGradient use textActor.gradientColor
326     // ignore GetGradient textActor.gradientColor
327     // ignore SetGradientStartPoint use textActor.gradientStartPoint
328     // ignore GetGradientStartPoint textActor.gradientStartPoint
329     // ignore SetGradientEndPoint use textActor.gradientEndPoint
330     // ignore GetGradientEndPoint textActor.gradientEndPoint
331     // @todo? SetTextStyle ( can use individual properties as a work around )
332     // @todo? GetTextStyle ( can use individual properties as a work around )
333     // ignore SetTextColor use textActor.textColor
334     // ignore GetTextColor use textActor.textColor
335     // ignore SetSmoothEdge use textActor.smoothEdge
336     // ignore SetOutline use textActor.outLineEnable, outlineColor, thicknessWidth
337     // ignore SetGlow use textActor.glowEnable, glowColor, glowIntensity
338     // ignore SetShadow use textActor.shadowEnable, shadowColor, shadowOffset, shadowSize
339     // ignore SetItalics use textActor.italicsAngle ?
340     // ignore GetItalics  @todo add italics flag? or just stick with angle
341     // ignore GetItalicsAngle  use textActor.italicsAngle
342     // ignore SetUnderline use textActor.underline
343     // ignore GetUnderline use textActor.underline
344     // ignore SetWeight use textActor.weight
345     // ignore GetWeight use textActor.weight
346     // ignore SetFontDetectionAutomatic use textActor.fontDetectionAutomatic
347     // ignore IsFontDetectionAutomatic use textActor.fontDetectionAutomatic
348     // ignore GetLoadingState text is loaded synchronously
349     // ignore TextAvailableSignal text is loaded synchronously
350
351     /**************************************
352      * Mesh Actor API (in order of mesh-actor.h)
353      **************************************/
354     // @todo a version of MeshActor::New( mesh )
355     // @todo a version of MeshActor::New( AnimatableMesh )
356     // @todo SetMaterial
357     // @todo GetMaterial
358     // @todo BindBonesToMesh
359
360     /**************************************
361      * Camera Actor API (in order of camera.h)
362      **************************************/
363     // ignore SetType use camera.type
364     // ignore GetType use camera.type
365     // ignore SetProjectionMode use camera.projectionMode
366     // ignore GetProjectionMode use camera.projectionMode
367     // ignore SetFieldOfView use camera.fieldOfView
368     // ignore GetFieldOfView use camera.fieldOfView
369     // ignore SetAspectRatio use camera.aspectRatio
370     // ignore GetAspectRatio use camera.aspectRatio
371     // ignore SetNearClippingPlane use camera.nearPlaneDistance
372     // ignore GetNearClippingPlane use camera.nearPlaneDistance
373     // ignore SetFarClippingPlane use camera.farPlaneDistance
374     // ignore GetFarClippingPlane use camera.farPlaneDistance
375     // ignore GetTargetPosition use camera.targetPosition
376     // ignore SetInvertYAxis use camera.invertYAxis
377     // ignore GetInvertYAxis use camera.invertYAxis
378     { "SetPerspectiveProjection",   CameraActorApi::SetPerspectiveProjection,   CAMERA_ACTOR_API },
379     { "SetOrthographicProjection",  CameraActorApi::SetOrthographicProjection,  CAMERA_ACTOR_API },
380
381 };
382
383 const unsigned int ActorFunctionTableCount = sizeof(ActorFunctionTable)/sizeof(ActorFunctionTable[0]);
384 } //un-named space
385
386
387 ActorWrapper::ActorWrapper( Actor actor,
388               GarbageCollectorInterface& gc )
389 : HandleWrapper( BaseWrappedObject::ACTOR , actor, gc ),
390   mActor( actor )
391
392 {
393 }
394
395 v8::Handle<v8::Object> ActorWrapper::WrapActor(v8::Isolate* isolate, Actor actor )
396 {
397   v8::EscapableHandleScope handleScope( isolate );
398   v8::Local<v8::Object> object = WrapActor( isolate, actor, GetActorType( actor.GetTypeName() ) );
399
400   return handleScope.Escape( object );
401 }
402
403 Actor ActorWrapper::GetActor()
404 {
405   return mActor;
406 }
407
408 v8::Handle<v8::Object> ActorWrapper::WrapActor( v8::Isolate* isolate, Actor actor, ActorType actorType )
409 {
410   v8::EscapableHandleScope handleScope( isolate );
411   v8::Local<v8::ObjectTemplate> objectTemplate;
412
413   objectTemplate = GetActorTemplate( isolate, actorType );
414
415   // create an instance of the template
416   v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
417
418   // create teh actor object
419   ActorWrapper* pointer = new ActorWrapper( actor, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
420
421   // assign the JavaScript object to the wrapper.
422   // This also stores Dali object, in an internal field inside the JavaScript object.
423   pointer->SetJavascriptObject( isolate, localObject );
424
425   return handleScope.Escape( localObject );
426 }
427
428 v8::Local<v8::ObjectTemplate> ActorWrapper::GetActorTemplate( v8::Isolate* isolate, ActorWrapper::ActorType type )
429 {
430   v8::EscapableHandleScope handleScope( isolate );
431   v8::Local<v8::ObjectTemplate> objectTemplate;
432
433   if( ActorTemplateLookup[type].actorTemplate->IsEmpty() )
434   {
435     objectTemplate = MakeDaliActorTemplate( isolate, type );
436     ActorTemplateLookup[type].actorTemplate->Reset( isolate, objectTemplate );
437   }
438   else
439   {
440     // get the object template
441     objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, *ActorTemplateLookup[type].actorTemplate );
442   }
443
444   return handleScope.Escape( objectTemplate );
445 }
446
447 v8::Handle<v8::ObjectTemplate> ActorWrapper::MakeDaliActorTemplate( v8::Isolate* isolate, ActorType actorType )
448 {
449   v8::EscapableHandleScope handleScope( isolate );
450
451   v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
452
453   objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
454
455   // find out what API's this actor supports
456   int supportApis = GetActorSupportedApis( actorType );
457
458   // add our function properties
459   for( unsigned int i = 0; i < ActorFunctionTableCount; ++i )
460   {
461     const ActorFunctions property =  ActorFunctionTable[i];
462
463     // check to see if the actor supports a certain type of API
464     // e.g. ImageActor will support ACTOR_API, RENDERABLE_API and IMAGE_ACTOR_API
465     if( supportApis &  property.api )
466     {
467       std::string funcName = V8Utils::GetJavaScriptFunctionName( property.name);
468
469       objTemplate->Set( v8::String::NewFromUtf8(   isolate, funcName.c_str() ),
470                       v8::FunctionTemplate::New( isolate, property.function ) );
471     }
472   }
473
474   // property handle intercepts property getters and setters and signals
475   HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
476
477
478   return handleScope.Escape( objTemplate );
479 }
480
481 void ActorWrapper::NewActor( const v8::FunctionCallbackInfo< v8::Value >& args)
482 {
483   v8::Isolate* isolate = args.GetIsolate();
484   v8::HandleScope handleScope( isolate );
485
486   if( !args.IsConstructCall() )
487   {
488     DALI_SCRIPT_EXCEPTION( isolate, "constructor called without 'new" );
489     return;
490   }
491
492   // find out the callee function name...e.g. TextActor, ImageActor, MeshActor
493   v8::Local<v8::Function> callee = args.Callee();
494   v8::Local<v8::Value> v8String = callee->GetName();
495   std::string typeName = V8Utils::v8StringToStdString( v8String );
496
497   // create a new actor based on type, using the type registry.
498   Actor actor = CreateActor( args, typeName );
499
500   v8::Local<v8::Object> localObject = WrapActor( isolate, actor );
501
502   args.GetReturnValue().Set( localObject );
503 }
504
505 /**
506  * given an actor type name, e.g. ImageActor returns the type, e.g. ActorWrapper::IMAGE_ACTOR
507  */
508 ActorWrapper::ActorType ActorWrapper::GetActorType( const std::string& name )
509 {
510   for( unsigned int i = 0 ; i < ActorApiLookupCount ; i++ )
511   {
512     if( ActorApiLookup[i].actorName == name )
513     {
514       return ActorApiLookup[i].actorType;
515     }
516   }
517   return ActorWrapper::UNKNOWN_ACTOR;
518 }
519
520
521
522 } // namespace V8Plugin
523
524 } // namespace Dali