Merge "Layout Engine - Fix for multiline" into new_text
[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
206     // ignore. SetParentOrigin() use Actor.parentOrigin
207     // ignore. GetCurrentParentOrigin()  use Actor.parentOrigin
208     // ignore. SetAnchorPoint()  use Actor.anchorPoint
209     // ignore. GetCurrentAnchorPoint()  use Actor.anchorPoint
210     // ignore. SetSize() use Actor.size
211     // ignore. GetCurrentSize() use Actor.size
212     // ignore. SetPosition(....) use Actor.position
213     // ignore. SetX, SetY, SetZ,  use Actor.position.x, Actor.position.y, Actor.position.z
214     { "TranslateBy",         ActorApi::TranslateBy,              ACTOR_API },
215     // ignore GetCurrentPosition(). use Actor.position
216     // ignore GetCurrentWorldPosition() use Actor.worldPosition
217     // ignore SetPositionInheritanceMode() use Actor.positionInheritance
218     // ignore GetPositionInheritanceMode()  use Actor.positionInheritance
219     // ignore SetOrientation() use Actor.orientation
220     { "RotateBy",         ActorApi::RotateBy,          ACTOR_API },
221     // ignore GetCurrentOrientation() use Actor.orientation
222     // ignore SetInheritOrientation() use Actor.inheritOrientation
223     // ignore IsOrientationInherited() use Actor.inheritOrientation
224     // ignore GetCurrentWorldOrientation() use Actor.worldOrientation
225     // ignore SetScale() use Actor.scale
226     { "ScaleBy",         ActorApi::ScaleBy,            ACTOR_API },
227     // ignore GetCurrentScale() use Actor.scale
228     // ignore GetCurrentWorldScale() use Actor.worldScale
229     // ignore SetInheritScale() use Actor.inheritScale
230     // ignore IsScaleInherited() use Actor.inheritScale
231     // ignore GetCurrentWorldMatrix() use Actor.worldMatrix
232     // ignore SetVisible() use Actor.visible
233     // ignore IsVisible() use Actor.visible
234     // ignore SetOpacity() use Actor.opacity
235     // ignore GetCurrentOpacity() use Actor.opacity
236     // ignore SetColor() use Actor.color
237     // ignore GetCurrentColor() use Actor.color
238     // ignore SetColorMode() use Actor.colorMode
239     // ignore GetColorMode() use Actor.colorMode
240     // ignore GetCurrentWorldColor() use Actor.worldColor
241     // ignore SetInheritShaderEffect() use Actor.inheritShaderEffect
242     // ignore GetInheritShaderEffect() use Actor.inheritShaderEffect
243     // ignore SetDrawMode() use Actor.drawMode
244     // ignore GetDrawMode() use Actor.drawMode
245     // ignore SetSensitive() use Actor.sensitve
246     // ignore IsSensitive() use Actor.sensitive
247     { "ScreenToLocal"       , ActorApi::ScreenToLocal,         ACTOR_API},
248     // ignore SetLeaveRequired() use Actor.leaveRequired
249     // ignore GetLeaveRequired() use Actor.leaveRequired
250     { "SetKeyboardFocusable", ActorApi::SetKeyboardFocusable,  ACTOR_API }, //-- should this be a property???
251     { "IsKeyboardFocusable" , ActorApi::IsKeyboardFocusable,   ACTOR_API }, //-- should this be a property???
252
253     /**************************************
254      * Renderable Actor API (in order of renderable-actor.h)
255      **************************************/
256     { "SetSortModifier",    RenderableActorApi::SetSortModifier,   RENDERABLE_ACTOR_API  },
257     { "GetSortModifier",    RenderableActorApi::GetSortModifier,   RENDERABLE_ACTOR_API  },
258     { "SetCullFace",        RenderableActorApi::SetCullFace,       RENDERABLE_ACTOR_API  },
259     { "GetCullFace",        RenderableActorApi::GetCullFace,       RENDERABLE_ACTOR_API  },
260     { "SetBlendMode",       RenderableActorApi::SetBlendMode,      RENDERABLE_ACTOR_API  },
261     { "GetBlendMode",       RenderableActorApi::GetBlendMode,      RENDERABLE_ACTOR_API  },
262     { "SetBlendFunc",       RenderableActorApi::SetBlendFunc,      RENDERABLE_ACTOR_API  },
263     { "GetBlendFunc",       RenderableActorApi::GetBlendFunc,      RENDERABLE_ACTOR_API  },
264     { "SetBlendEquation",   RenderableActorApi::SetBlendEquation,  RENDERABLE_ACTOR_API  },
265     { "GetBlendEquation",   RenderableActorApi::GetBlendEquation,  RENDERABLE_ACTOR_API  },
266     { "SetBlendColor",      RenderableActorApi::SetBlendColor,     RENDERABLE_ACTOR_API  },
267     { "GetBlendColor",      RenderableActorApi::GetBlendColor,     RENDERABLE_ACTOR_API  },
268     { "SetShaderEffect",    RenderableActorApi::SetShaderEffect,   RENDERABLE_ACTOR_API  },
269     { "GetShaderEffect",    RenderableActorApi::GetShaderEffect,   RENDERABLE_ACTOR_API  },
270     { "RemoveShaderEffect", RenderableActorApi::RemoveShaderEffect,RENDERABLE_ACTOR_API  },
271
272
273
274
275     /**************************************
276      * Layer  API (in order of layer.h)
277      **************************************/
278     { "GetDepth",           LayerApi::GetDepth,                 LAYER_API  },
279     { "Raise",              LayerApi::Raise,                    LAYER_API  },
280     { "Lower",              LayerApi::Lower,                    LAYER_API  },
281     { "RaiseAbove",         LayerApi::RaiseAbove,               LAYER_API  },
282     { "RaiseBelow",         LayerApi::LowerBelow,               LAYER_API  },
283     { "RaiseToTop",         LayerApi::RaiseToTop,               LAYER_API  },
284     { "LowerToBottom",      LayerApi::ToBottom,                 LAYER_API  },
285     { "MoveAbove",          LayerApi::MoveAbove,                LAYER_API  },
286     { "MoveBelow",          LayerApi::MoveBelow,                LAYER_API  },
287     // ignore SetClipping, use layer.clippingEnable
288     // ignore IsClipping, use layer.clippingEnable
289     // ignore SetClippingBox, use layer.clippingBox
290     { "SetDepthTestDisabled", LayerApi::SetDepthTestDisabled,   LAYER_API },
291     { "IsDepthTestDisabled",  LayerApi::IsDepthTestDisabled,    LAYER_API },
292     // @todo SetSortFunction
293
294     /**************************************
295      * Image Actor API (in order of image-actor.h)
296      **************************************/
297
298     { "SetImage",           ImageActorApi::SetImage,              IMAGE_ACTOR_API },
299     { "GetImage",           ImageActorApi::GetImage,              IMAGE_ACTOR_API },
300     { "SetToNaturalSize",   ImageActorApi::SetToNaturalSize,      IMAGE_ACTOR_API },
301     // ignore SetPixelArea, use imageActor.pixelArea
302     // ignore GetPixelArea, use imageActor.pixelArea
303     { "IsPixelAreaSet",     ImageActorApi::IsPixelAreaSet,        IMAGE_ACTOR_API },
304     { "ClearPixelArea",     ImageActorApi::ClearPixelArea,        IMAGE_ACTOR_API },
305     // ignore SetStyle, use imageActor.style
306     // ignore GetStyle, use imageActor.style
307     // ignore SetNinePatchBorder use imageActor.border
308     // ignore GetNinePatchBorder use imageActor.border
309     // ignore SetFadeIn use imageActor.fadeIn
310     // ignore GetFadeIn use imageActor.fadeIn
311     // ignore SetFadeInDuration use imageActor.fadeInDuration
312     // ignore GetFadeInDuration use imageActor.fadeInDuration
313     //{ "GetCurrentImageSize", ImageActorApi::GetCurrentImageSize,  IMAGE_ACTOR_API },
314
315
316     /**************************************
317      * Text Actor API (in order of text-actor.h)
318      **************************************/
319     //ignore SetText use textActor.text
320     { "SetToNaturalSize",   TextActorApi::SetToNaturalSize,      TEXT_ACTOR_API },
321     // ignore GetFont use textActor.font
322     // ignore SetFont use textActor.font
323     // ignore SetGradient use textActor.gradientColor
324     // ignore GetGradient textActor.gradientColor
325     // ignore SetGradientStartPoint use textActor.gradientStartPoint
326     // ignore GetGradientStartPoint textActor.gradientStartPoint
327     // ignore SetGradientEndPoint use textActor.gradientEndPoint
328     // ignore GetGradientEndPoint textActor.gradientEndPoint
329     // @todo? SetTextStyle ( can use individual properties as a work around )
330     // @todo? GetTextStyle ( can use individual properties as a work around )
331     // ignore SetTextColor use textActor.textColor
332     // ignore GetTextColor use textActor.textColor
333     // ignore SetSmoothEdge use textActor.smoothEdge
334     // ignore SetOutline use textActor.outLineEnable, outlineColor, thicknessWidth
335     // ignore SetGlow use textActor.glowEnable, glowColor, glowIntensity
336     // ignore SetShadow use textActor.shadowEnable, shadowColor, shadowOffset, shadowSize
337     // ignore SetItalics use textActor.italicsAngle ?
338     // ignore GetItalics  @todo add italics flag? or just stick with angle
339     // ignore GetItalicsAngle  use textActor.italicsAngle
340     // ignore SetUnderline use textActor.underline
341     // ignore GetUnderline use textActor.underline
342     // ignore SetWeight use textActor.weight
343     // ignore GetWeight use textActor.weight
344     // ignore SetFontDetectionAutomatic use textActor.fontDetectionAutomatic
345     // ignore IsFontDetectionAutomatic use textActor.fontDetectionAutomatic
346     // ignore GetLoadingState text is loaded synchronously
347     // ignore TextAvailableSignal text is loaded synchronously
348
349     /**************************************
350      * Mesh Actor API (in order of mesh-actor.h)
351      **************************************/
352     // @todo a version of MeshActor::New( mesh )
353     // @todo a version of MeshActor::New( AnimatableMesh )
354     // @todo SetMaterial
355     // @todo GetMaterial
356     // @todo BindBonesToMesh
357
358     /**************************************
359      * Camera Actor API (in order of camera.h)
360      **************************************/
361     // ignore SetType use camera.type
362     // ignore GetType use camera.type
363     // ignore SetProjectionMode use camera.projectionMode
364     // ignore GetProjectionMode use camera.projectionMode
365     // ignore SetFieldOfView use camera.fieldOfView
366     // ignore GetFieldOfView use camera.fieldOfView
367     // ignore SetAspectRatio use camera.aspectRatio
368     // ignore GetAspectRatio use camera.aspectRatio
369     // ignore SetNearClippingPlane use camera.nearPlaneDistance
370     // ignore GetNearClippingPlane use camera.nearPlaneDistance
371     // ignore SetFarClippingPlane use camera.farPlaneDistance
372     // ignore GetFarClippingPlane use camera.farPlaneDistance
373     // ignore GetTargetPosition use camera.targetPosition
374     // ignore SetInvertYAxis use camera.invertYAxis
375     // ignore GetInvertYAxis use camera.invertYAxis
376     { "SetPerspectiveProjection",   CameraActorApi::SetPerspectiveProjection,   CAMERA_ACTOR_API },
377     { "SetOrthographicProjection",  CameraActorApi::SetOrthographicProjection,  CAMERA_ACTOR_API },
378
379 };
380
381 const unsigned int ActorFunctionTableCount = sizeof(ActorFunctionTable)/sizeof(ActorFunctionTable[0]);
382 } //un-named space
383
384
385 ActorWrapper::ActorWrapper( Actor actor,
386               GarbageCollectorInterface& gc )
387 : HandleWrapper( BaseWrappedObject::ACTOR , actor, gc ),
388   mActor( actor )
389
390 {
391 }
392
393 v8::Handle<v8::Object> ActorWrapper::WrapActor(v8::Isolate* isolate, Actor actor )
394 {
395   v8::EscapableHandleScope handleScope( isolate );
396   v8::Local<v8::Object> object = WrapActor( isolate, actor, GetActorType( actor.GetTypeName() ) );
397
398   return handleScope.Escape( object );
399 }
400
401 Actor ActorWrapper::GetActor()
402 {
403   return mActor;
404 }
405
406 v8::Handle<v8::Object> ActorWrapper::WrapActor( v8::Isolate* isolate, Actor actor, ActorType actorType )
407 {
408   v8::EscapableHandleScope handleScope( isolate );
409   v8::Local<v8::ObjectTemplate> objectTemplate;
410
411   objectTemplate = GetActorTemplate( isolate, actorType );
412
413   // create an instance of the template
414   v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
415
416   // create teh actor object
417   ActorWrapper* pointer = new ActorWrapper( actor, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
418
419   // assign the JavaScript object to the wrapper.
420   // This also stores Dali object, in an internal field inside the JavaScript object.
421   pointer->SetJavascriptObject( isolate, localObject );
422
423   return handleScope.Escape( localObject );
424 }
425
426 v8::Local<v8::ObjectTemplate> ActorWrapper::GetActorTemplate( v8::Isolate* isolate, ActorWrapper::ActorType type )
427 {
428   v8::EscapableHandleScope handleScope( isolate );
429   v8::Local<v8::ObjectTemplate> objectTemplate;
430
431   if( ActorTemplateLookup[type].actorTemplate->IsEmpty() )
432   {
433     objectTemplate = MakeDaliActorTemplate( isolate, type );
434     ActorTemplateLookup[type].actorTemplate->Reset( isolate, objectTemplate );
435   }
436   else
437   {
438     // get the object template
439     objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, *ActorTemplateLookup[type].actorTemplate );
440   }
441
442   return handleScope.Escape( objectTemplate );
443 }
444
445 v8::Handle<v8::ObjectTemplate> ActorWrapper::MakeDaliActorTemplate( v8::Isolate* isolate, ActorType actorType )
446 {
447   v8::EscapableHandleScope handleScope( isolate );
448
449   v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
450
451   objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
452
453   // find out what API's this actor supports
454   int supportApis = GetActorSupportedApis( actorType );
455
456   // add our function properties
457   for( unsigned int i = 0; i < ActorFunctionTableCount; ++i )
458   {
459     const ActorFunctions property =  ActorFunctionTable[i];
460
461     // check to see if the actor supports a certain type of API
462     // e.g. ImageActor will support ACTOR_API, RENDERABLE_API and IMAGE_ACTOR_API
463     if( supportApis &  property.api )
464     {
465       std::string funcName = V8Utils::GetJavaScriptFunctionName( property.name);
466
467       objTemplate->Set( v8::String::NewFromUtf8(   isolate, funcName.c_str() ),
468                       v8::FunctionTemplate::New( isolate, property.function ) );
469     }
470   }
471
472   // property handle intercepts property getters and setters and signals
473   HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
474
475
476   return handleScope.Escape( objTemplate );
477 }
478
479 void ActorWrapper::NewActor( const v8::FunctionCallbackInfo< v8::Value >& args)
480 {
481   v8::Isolate* isolate = args.GetIsolate();
482   v8::HandleScope handleScope( isolate );
483
484   if( !args.IsConstructCall() )
485   {
486     DALI_SCRIPT_EXCEPTION( isolate, "constructor called without 'new" );
487     return;
488   }
489
490   // find out the callee function name...e.g. TextActor, ImageActor, MeshActor
491   v8::Local<v8::Function> callee = args.Callee();
492   v8::Local<v8::Value> v8String = callee->GetName();
493   std::string typeName = V8Utils::v8StringToStdString( v8String );
494
495   // create a new actor based on type, using the type registry.
496   Actor actor = CreateActor( args, typeName );
497
498   v8::Local<v8::Object> localObject = WrapActor( isolate, actor );
499
500   args.GetReturnValue().Set( localObject );
501 }
502
503 /**
504  * given an actor type name, e.g. ImageActor returns the type, e.g. ActorWrapper::IMAGE_ACTOR
505  */
506 ActorWrapper::ActorType ActorWrapper::GetActorType( const std::string& name )
507 {
508   for( unsigned int i = 0 ; i < ActorApiLookupCount ; i++ )
509   {
510     if( ActorApiLookup[i].actorName == name )
511     {
512       return ActorApiLookup[i].actorType;
513     }
514   }
515   return ActorWrapper::UNKNOWN_ACTOR;
516 }
517
518
519
520 } // namespace V8Plugin
521
522 } // namespace Dali