Remove unnecessary functions from Scripting, support strings in actor properties 46/73846/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 9 Jun 2016 17:24:04 +0000 (18:24 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 10 Jun 2016 17:36:12 +0000 (18:36 +0100)
- Removed unused methods from Scripting
- Parse property string to set AnchorPoint & ParentOrigin
- Modify some of the property helper macros to output DALi coding standard variables

Change-Id: Ic600ee626aec7f6355edfb792232d329d19bf074

automated-tests/src/dali-devel/utc-Dali-Scripting.cpp
automated-tests/src/dali/utc-Dali-Actor.cpp
dali/devel-api/scripting/scripting.cpp
dali/devel-api/scripting/scripting.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/layer-impl.cpp
dali/internal/event/common/property-helper.cpp [new file with mode: 0644]
dali/internal/event/common/property-helper.h
dali/internal/file.list

index f6e5b05..734151c 100644 (file)
@@ -140,65 +140,6 @@ void TestEnumStrings(
 
 } // anon namespace
 
-
-
-int UtcDaliScriptingGetColorMode(void)
-{
-  for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i )
-  {
-    tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value );
-    DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, (int)GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION );
-    DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION );
-  }
-
-  DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, GetColorMode("INVALID_ARG"), TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliScriptingGetPositionInheritanceMode(void)
-{
-  for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i )
-  {
-    tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value );
-    DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, (int)GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION );
-    DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION );
-  }
-
-  DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[0].value, (int)GetPositionInheritanceMode("INVALID_ARG"), TEST_LOCATION );
-  END_TEST;
-}
-
-
-int UtcDaliScriptingGetDrawMode(void)
-{
-  for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i )
-  {
-    tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value );
-    DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, (int)GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION );
-    DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION );
-  }
-
-  DALI_TEST_EQUALS( DRAW_MODE_VALUES[0].value, (int)GetDrawMode( "INVALID_ARG" ), TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliScriptingGetAnchorConstant(void)
-{
-  DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION );
-  DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( Vector3(), GetAnchorConstant("INVALID_ARG"), TEST_LOCATION );
-  END_TEST;
-}
-
 int UtcDaliScriptingNewImageNegative01(void)
 {
   // Invalid filename
index 61bdd8d..6dcde41 100644 (file)
@@ -2990,3 +2990,154 @@ int UtcDaliActorGetHierachyDepth(void)
   END_TEST;
 }
 
+int UtcDaliActorAnchorPointPropertyAsString(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+  // Invalid should not change anything
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
+  DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliActorParentOriginPropertyAsString(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+  // Invalid should not change anything
+  actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
+  DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliActorColorModePropertyAsString(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
+  DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
+  DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
+  DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
+  DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
+
+  // Invalid should not change anything
+  actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
+  DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliActorPositionInheritancePropertyAsString(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
+  DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
+  DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
+  DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
+  DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+
+  // Invalid should not change anything
+  actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
+  DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliActorDrawModePropertyAsString(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+
+  actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
+  DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
+  DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
+  DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+
+  // Invalid should not change anything
+  actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
+  DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+
+  END_TEST;
+}
index 978fcaf..55bca88 100644 (file)
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/property-array.h>
 #include <dali/internal/common/image-attributes.h>
+#include <dali/internal/event/common/property-helper.h>
 #include <dali/internal/event/images/resource-image-impl.h>
 #include <dali/internal/event/images/frame-buffer-image-impl.h>
 #include <dali/internal/event/images/buffer-image-impl.h>
-#include <dali/internal/event/effects/shader-effect-impl.h>
 
 namespace Dali
 {
@@ -39,51 +39,6 @@ namespace
 {
 
 // Tables used here for converting strings to the enumerations and vice versa
-struct AnchorValue
-{
-  const char* name;
-  const Vector3 value;
-};
-const AnchorValue ANCHOR_CONSTANT_TABLE[] =
-{
-  { "TOP_LEFT",               ParentOrigin::TOP_LEFT               },
-  { "TOP_CENTER",             ParentOrigin::TOP_CENTER             },
-  { "TOP_RIGHT",              ParentOrigin::TOP_RIGHT              },
-  { "CENTER_LEFT",            ParentOrigin::CENTER_LEFT            },
-  { "CENTER",                 ParentOrigin::CENTER                 },
-  { "CENTER_RIGHT",           ParentOrigin::CENTER_RIGHT           },
-  { "BOTTOM_LEFT",            ParentOrigin::BOTTOM_LEFT            },
-  { "BOTTOM_CENTER",          ParentOrigin::BOTTOM_CENTER          },
-  { "BOTTOM_RIGHT",           ParentOrigin::BOTTOM_RIGHT           },
-};
-const unsigned int ANCHOR_CONSTANT_TABLE_COUNT = sizeof( ANCHOR_CONSTANT_TABLE ) / sizeof( ANCHOR_CONSTANT_TABLE[0] );
-
-const StringEnum COLOR_MODE_TABLE[] =
-{
-  { "USE_OWN_COLOR",                    USE_OWN_COLOR                    },
-  { "USE_PARENT_COLOR",                 USE_PARENT_COLOR                 },
-  { "USE_OWN_MULTIPLY_PARENT_COLOR",    USE_OWN_MULTIPLY_PARENT_COLOR    },
-  { "USE_OWN_MULTIPLY_PARENT_ALPHA",    USE_OWN_MULTIPLY_PARENT_ALPHA    },
-};
-const unsigned int COLOR_MODE_TABLE_COUNT = sizeof( COLOR_MODE_TABLE ) / sizeof( COLOR_MODE_TABLE[0] );
-
-const StringEnum POSITION_INHERITANCE_MODE_TABLE[] =
-{
-  { "INHERIT_PARENT_POSITION",                    INHERIT_PARENT_POSITION                    },
-  { "USE_PARENT_POSITION",                        USE_PARENT_POSITION                        },
-  { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION",    USE_PARENT_POSITION_PLUS_LOCAL_POSITION    },
-  { "DONT_INHERIT_POSITION",                      DONT_INHERIT_POSITION                      },
-};
-const unsigned int POSITION_INHERITANCE_MODE_TABLE_COUNT = sizeof( POSITION_INHERITANCE_MODE_TABLE ) / sizeof( POSITION_INHERITANCE_MODE_TABLE[0] );
-
-const StringEnum DRAW_MODE_TABLE[] =
-{
-  { "NORMAL",     DrawMode::NORMAL     },
-  { "OVERLAY_2D", DrawMode::OVERLAY_2D },
-  { "STENCIL",    DrawMode::STENCIL    },
-};
-const unsigned int DRAW_MODE_TABLE_COUNT = sizeof( DRAW_MODE_TABLE ) / sizeof( DRAW_MODE_TABLE[0] );
-
 const StringEnum IMAGE_LOAD_POLICY_TABLE[] =
 {
   { "IMMEDIATE", ResourceImage::IMMEDIATE },
@@ -154,53 +109,6 @@ const char* ImageTypeName[] = { "ResourceImage", "FrameBufferImage", "BufferImag
 enum ImageType                { RESOURCE_IMAGE,  FRAME_BUFFER_IMAGE, BUFFER_IMAGE };
 const unsigned int imageTypeCount = sizeof( ImageTypeName ) / sizeof( const char* );
 
-bool CompareEnums( const char * a, const char * b, size_t& size )
-{
-  size = 0;
-  while( ( *a != '\0' ) && ( *b != '\0' ) && ( *a != ',') && ( *b != ',') )
-  {
-    ++size;
-    char ca = *a;
-    char cb = *b;
-
-    if( ( ( ca == '-' ) || ( ca == '_') ) &&
-        ( ( cb == '-' ) || ( cb == '_') ) )
-    {
-      ++a;
-      ++b;
-      continue;
-    }
-
-    if( ( 'A' <= ca ) && ( ca <= 'Z') )
-    {
-      ca = ca + ( 'a' - 'A' );
-    }
-
-    if( ( 'A' <= cb ) && ( cb <= 'Z') )
-    {
-      cb = cb + ( 'a' - 'A' );
-    }
-
-    if( ca != cb )
-    {
-      return false;
-    }
-
-    ++a;
-    ++b;
-  }
-
-  // enums can be comma separated so check ends and comma
-  if( ( ( *a == '\0' ) && ( *b == '\0' ) ) ||
-      ( ( *a == '\0' ) && ( *b == ','  ) ) ||
-      ( ( *a == ','  ) && ( *b == '\0' ) ) )
-  {
-    return true;
-  }
-
-  return false;
-}
-
 } // unnamed namespace
 
 bool EnumStringToInteger( const char * const value, const StringEnum* const enumTable, unsigned int tableCount, unsigned int& integerEnum )
@@ -222,7 +130,7 @@ bool EnumStringToInteger( const char * const value, const StringEnum* const enum
 
       for ( unsigned int i = 0; i < tableCount; ++i )
       {
-        if( CompareEnums( pValue, table->string, size ) )
+        if( Internal::CompareTokens( pValue, table->string, size ) )
         {
           found = true;
           ret |= table->value;
@@ -262,7 +170,7 @@ unsigned int FindEnumIndex( const char* value, const StringEnum* table, unsigned
   for ( unsigned int i = 0; i < tableCount; ++i, ++index )
   {
     size_t sizeIgnored = 0;
-    if( CompareEnums( value, table->string, sizeIgnored ) )
+    if( Internal::CompareTokens( value, table->string, sizeIgnored ) )
     {
       found = true;
       break;
@@ -276,78 +184,6 @@ unsigned int FindEnumIndex( const char* value, const StringEnum* table, unsigned
   return index;
 }
 
-ColorMode GetColorMode( const std::string& value )
-{
-  // return default on error
-  ColorMode mode( USE_OWN_MULTIPLY_PARENT_ALPHA );
-  GetEnumeration< ColorMode >( value.c_str(), COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT, mode );
-  return mode;
-}
-
-
-std::string GetColorMode( ColorMode value )
-{
-  const char* name = GetEnumerationName< ColorMode >( value, COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT );
-  if( name )
-  {
-    return std::string( name );
-  }
-  return std::string();
-}
-
-PositionInheritanceMode GetPositionInheritanceMode( const std::string& value )
-{
-  // return default on error
-  PositionInheritanceMode mode( INHERIT_PARENT_POSITION );
-  GetEnumeration< PositionInheritanceMode >( value.c_str(), POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT, mode );
-  return mode;
-}
-
-
-std::string GetPositionInheritanceMode( PositionInheritanceMode value )
-{
-  const char* name = GetEnumerationName< PositionInheritanceMode >( value, POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
-  if( name )
-  {
-    return std::string( name );
-  }
-  return std::string();
-}
-
-
-DrawMode::Type GetDrawMode( const std::string& value )
-{
-  // return default on error
-  DrawMode::Type mode( DrawMode::NORMAL );
-  GetEnumeration< DrawMode::Type >( value.c_str(), DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT, mode );
-  return mode;
-}
-
-
-std::string GetDrawMode( DrawMode::Type value )
-{
-  const char* name = GetEnumerationName< DrawMode::Type >( value, DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
-  if( name )
-  {
-    return std::string( name );
-  }
-  return std::string();
-}
-
-
-Vector3 GetAnchorConstant( const std::string& value )
-{
-  for( unsigned int i = 0; i < ANCHOR_CONSTANT_TABLE_COUNT; ++i )
-  {
-    size_t sizeIgnored = 0;
-    if( CompareEnums( value.c_str(), ANCHOR_CONSTANT_TABLE[ i ].name, sizeIgnored ) )
-    {
-      return ANCHOR_CONSTANT_TABLE[ i ].value;
-    }
-  }
-  return Vector3();
-}
-
 
 Image NewImage( const Property::Value& property )
 {
@@ -516,57 +352,6 @@ Image NewImage( const Property::Value& property )
 } // Image NewImage( Property::Value map )
 
 
-ShaderEffect NewShaderEffect( const Property::Value& property )
-{
-  Internal::ShaderEffectPtr ret;
-
-  const Property::Map* map = property.GetMap();
-  if( map )
-  {
-    ret = Internal::ShaderEffect::New( Dali::ShaderEffect::HINT_NONE ); // hint can be reset if in map
-
-    const Property::Value* value = map->Find( "program" );
-    if( value )
-    {
-      Property::Index index = ret->GetPropertyIndex( "program" );
-      ret->SetProperty( index, *value );
-    }
-
-    for( unsigned int i = 0; i < map->Count(); ++i )
-    {
-      const std::string& key = map->GetKey( i );
-      if( key != "program" )
-      {
-        Property::Index index = ret->GetPropertyIndex( key );
-
-        const Property::Value& value = map->GetValue( i );
-        if( Property::INVALID_INDEX != index )
-        {
-          ret->SetProperty( index, value );
-        }
-        else
-        {
-          // if its not a property then register it as a uniform (making a custom property)
-          if( value.GetType() == Property::INTEGER )
-          {
-            // valid uniforms are floats, vec3's etc so we recast if the user accidentally
-            // set as integer. Note the map could have come from json script.
-            Property::Value asFloat( static_cast<float>( value.Get<int>() ) );
-            ret->SetUniform( key, asFloat, Dali::ShaderEffect::COORDINATE_TYPE_DEFAULT );
-          }
-          else
-          {
-            ret->SetUniform( key, value, Dali::ShaderEffect::COORDINATE_TYPE_DEFAULT );
-          }
-        }
-      }
-    }
-  }
-
-  return Dali::ShaderEffect(ret.Get());
-}
-
-
 Actor NewActor( const Property::Map& map )
 {
   BaseHandle handle;
@@ -613,34 +398,6 @@ Actor NewActor( const Property::Map& map )
           actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
         }
       }
-      else if( key ==  "parentOrigin" )
-      {
-        // Parent Origin can be a string constant as well as a Vector3
-
-        const Property::Type type( value.GetType() );
-        if ( type == Property::VECTOR3 )
-        {
-          actor.SetParentOrigin( value.Get< Vector3 >() );
-        }
-        else if( type == Property::STRING )
-        {
-          actor.SetParentOrigin( GetAnchorConstant( value.Get< std::string >() ) );
-        }
-      }
-      else if( key ==  "anchorPoint" )
-      {
-        // Anchor Point can be a string constant as well as a Vector3
-
-        const Property::Type type( value.GetType() );
-        if ( type == Property::VECTOR3 )
-        {
-          actor.SetAnchorPoint( value.Get< Vector3 >() );
-        }
-        else if( type == Property::STRING )
-        {
-          actor.SetAnchorPoint( GetAnchorConstant( value.Get< std::string >() ) );
-        }
-      }
       else
       {
         Property::Index index( actor.GetPropertyIndex( key ) );
index a543c34..544c48f 100644 (file)
@@ -147,62 +147,6 @@ const char * GetLinearEnumerationName( T value, const StringEnum* table, unsigne
 }
 
 /**
- * @brief Takes a string and returns the appropriate color mode.
- *
- * @param[in] value The input string
- * @return    The corresponding color-mode.
- */
-DALI_IMPORT_API ColorMode GetColorMode( const std::string& value );
-
-/**
- * @brief Takes a color mode and returns the appropriate string equivalent.
- *
- * @param[in] value The color mode
- * @return    The corresponding string.
- */
-DALI_IMPORT_API std::string GetColorMode( ColorMode value );
-
-/**
- * @brief Takes a string and returns the appropriate position inheritance mode.
- *
- * @param[in] value The input string
- * @return    The corresponding position-inheritance-mode.
- */
-DALI_IMPORT_API PositionInheritanceMode GetPositionInheritanceMode( const std::string& value );
-
-/**
- * @brief Takes a position inheritance mode and returns the string equivalent.
- *
- * @param[in] value The position-inheritance-mode.
- * @return    The corresponding string.
- */
-DALI_IMPORT_API std::string GetPositionInheritanceMode( PositionInheritanceMode value );
-
-/**
- * @brief Takes a string and returns the appropriate draw mode.
- *
- * @param[in] value The input string
- * @return    The corresponding draw-mode.
- */
-DALI_IMPORT_API DrawMode::Type GetDrawMode( const std::string& value );
-
-/**
- * @brief Takes a draw-mode and returns the string equivalent.
- *
- * @param[in] value The draw-mode.
- * @return    The corresponding string.
- */
-DALI_IMPORT_API std::string GetDrawMode( DrawMode::Type value );
-
-/**
- * @brief Takes a string and returns the appropriate anchor-point or parent-origin constant.
- *
- * @param[in] value The input string
- * @return    The corresponding anchor-point or parent-origin constant.
- */
-DALI_IMPORT_API Vector3 GetAnchorConstant( const std::string& value );
-
-/**
  * @brief Creates object with data from the property value map.
  *
  * @param[in] property The property value map with the following valid fields:
@@ -225,39 +169,6 @@ DALI_IMPORT_API Vector3 GetAnchorConstant( const std::string& value );
 DALI_IMPORT_API Image NewImage( const Property::Value& property );
 
 /**
- * @brief Creates object with data from the property value map.
- *
- * @param[in] property The property value map with the following valid fields:
- * @code
- * // a program can be specified as string or a filename.
- * // some fields may be ignored depending on the geometry-type
- * "program":        type Map
- * {
- *   "vertex":                 type std::string
- *   "fragment":               type std::string
- *   "vertexPrefix":           type std::string
- *   "fragmentPrefix":         type std::string
- *   "textVertex":             type std::string
- *   "textFragment":           type std::string
- *   "vertexFilename":         type std::string
- *   "fragmentFilename":       type std::string
- *   "vertexPrefixFilename":   type std::string
- *   "fragmentPrefixFilename": type std::string
- *   "textVertexFilename":     type std::string
- *   "textFragmentFilename":   type std::string
- *   "geometryType":           type std::string (enum)
- *   "geometryHints":          type std::string (enum)
- * }
- * // uniforms must be specified to be registered
- * "uUniform1":       type float,
- * "uUniform2":       type float, etc
- * @endcode
- *
- * @return A pointer to a newly created object.
- */
-DALI_IMPORT_API ShaderEffect NewShaderEffect( const Property::Value& property );
-
-/**
  * @brief Creates an actor with the date from the property value map.
  *
  * @param[in] map The property value map with the properties (and hierarchy) of the actor required
index b306888..5bddf6a 100644 (file)
@@ -32,6 +32,7 @@
 #include <dali/public-api/math/vector3.h>
 #include <dali/public-api/math/radian.h>
 #include <dali/public-api/object/type-registry.h>
+
 #include <dali/devel-api/scripting/scripting.h>
 
 #include <dali/internal/common/internal-constants.h>
@@ -59,37 +60,6 @@ using Dali::Internal::SceneGraph::PropertyBase;
 
 namespace Dali
 {
-namespace ResizePolicy
-{
-
-namespace
-{
-DALI_ENUM_TO_STRING_TABLE_BEGIN( Type )
-DALI_ENUM_TO_STRING( FIXED )
-DALI_ENUM_TO_STRING( USE_NATURAL_SIZE )
-DALI_ENUM_TO_STRING( FILL_TO_PARENT )
-DALI_ENUM_TO_STRING( SIZE_RELATIVE_TO_PARENT )
-DALI_ENUM_TO_STRING( SIZE_FIXED_OFFSET_FROM_PARENT )
-DALI_ENUM_TO_STRING( FIT_TO_CHILDREN )
-DALI_ENUM_TO_STRING( DIMENSION_DEPENDENCY )
-DALI_ENUM_TO_STRING( USE_ASSIGNED_SIZE )
-DALI_ENUM_TO_STRING_TABLE_END( Type )
-
-} // unnamed namespace
-} // ResizePolicy
-
-namespace SizeScalePolicy
-{
-namespace
-{
-// Enumeration to / from string conversion tables
-DALI_ENUM_TO_STRING_TABLE_BEGIN( Type )
-DALI_ENUM_TO_STRING( USE_SIZE_SET )
-DALI_ENUM_TO_STRING( FIT_WITH_ASPECT_RATIO )
-DALI_ENUM_TO_STRING( FILL_WITH_ASPECT_RATIO )
-DALI_ENUM_TO_STRING_TABLE_END( Type )
-} // unnamed namespace
-} // SizeScalePolicy
 
 namespace Internal
 {
@@ -263,6 +233,81 @@ SignalConnectorType signalConnector6( mType, SIGNAL_ON_RELAYOUT, &Actor::DoConne
 TypeAction a1( mType, ACTION_SHOW, &Actor::DoAction );
 TypeAction a2( mType, ACTION_HIDE, &Actor::DoAction );
 
+struct AnchorValue
+{
+  const char* name;
+  const Vector3& value;
+};
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE( AnchorValue, ANCHOR_CONSTANT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, TOP_LEFT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, TOP_CENTER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, TOP_RIGHT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, CENTER_LEFT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, CENTER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, CENTER_RIGHT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, BOTTOM_LEFT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, BOTTOM_CENTER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( AnchorPoint, BOTTOM_RIGHT )
+DALI_ENUM_TO_STRING_TABLE_END( ANCHOR_CONSTANT )
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( COLOR_MODE )
+DALI_ENUM_TO_STRING( USE_OWN_COLOR )
+DALI_ENUM_TO_STRING( USE_PARENT_COLOR )
+DALI_ENUM_TO_STRING( USE_OWN_MULTIPLY_PARENT_COLOR )
+DALI_ENUM_TO_STRING( USE_OWN_MULTIPLY_PARENT_ALPHA )
+DALI_ENUM_TO_STRING_TABLE_END( COLOR_MODE )
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( POSITION_INHERITANCE_MODE )
+DALI_ENUM_TO_STRING( INHERIT_PARENT_POSITION )
+DALI_ENUM_TO_STRING( USE_PARENT_POSITION )
+DALI_ENUM_TO_STRING( USE_PARENT_POSITION_PLUS_LOCAL_POSITION )
+DALI_ENUM_TO_STRING( DONT_INHERIT_POSITION )
+DALI_ENUM_TO_STRING_TABLE_END( POSITION_INHERITANCE_MODE )
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( DRAW_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DrawMode, NORMAL )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DrawMode, OVERLAY_2D )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DrawMode, STENCIL )
+DALI_ENUM_TO_STRING_TABLE_END( DRAW_MODE )
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( RESIZE_POLICY )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, FIXED )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, USE_NATURAL_SIZE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, FILL_TO_PARENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, SIZE_RELATIVE_TO_PARENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, SIZE_FIXED_OFFSET_FROM_PARENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, FIT_TO_CHILDREN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, DIMENSION_DEPENDENCY )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ResizePolicy, USE_ASSIGNED_SIZE )
+DALI_ENUM_TO_STRING_TABLE_END( RESIZE_POLICY )
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SIZE_SCALE_POLICY )
+DALI_ENUM_TO_STRING_WITH_SCOPE( SizeScalePolicy, USE_SIZE_SET )
+DALI_ENUM_TO_STRING_WITH_SCOPE( SizeScalePolicy, FIT_WITH_ASPECT_RATIO )
+DALI_ENUM_TO_STRING_WITH_SCOPE( SizeScalePolicy, FILL_WITH_ASPECT_RATIO )
+DALI_ENUM_TO_STRING_TABLE_END( SIZE_SCALE_POLICY )
+
+bool GetAnchorPointConstant( const std::string& value, Vector3& anchor )
+{
+  for( unsigned int i = 0; i < ANCHOR_CONSTANT_TABLE_COUNT; ++i )
+  {
+    size_t sizeIgnored = 0;
+    if( CompareTokens( value.c_str(), ANCHOR_CONSTANT_TABLE[ i ].name, sizeIgnored ) )
+    {
+      anchor = ANCHOR_CONSTANT_TABLE[ i ].value;
+      return true;
+    }
+  }
+  return false;
+}
+
+inline bool GetParentOriginConstant( const std::string& value, Vector3& parentOrigin )
+{
+  // Values are the same so just use the same table as anchor-point
+  return GetAnchorPointConstant( value, parentOrigin );
+}
+
 /**
  * @brief Extract a given dimension from a Vector2
  *
@@ -2274,7 +2319,21 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
   {
     case Dali::Actor::Property::PARENT_ORIGIN:
     {
-      SetParentOrigin( property.Get< Vector3 >() );
+      Property::Type type = property.GetType();
+      if( type == Property::VECTOR3 )
+      {
+        SetParentOrigin( property.Get< Vector3 >() );
+      }
+      else if ( type == Property::STRING )
+      {
+        std::string parentOriginString;
+        property.Get( parentOriginString );
+        Vector3 parentOrigin;
+        if( GetParentOriginConstant( parentOriginString, parentOrigin ) )
+        {
+          SetParentOrigin( parentOrigin );
+        }
+      }
       break;
     }
 
@@ -2298,7 +2357,21 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
 
     case Dali::Actor::Property::ANCHOR_POINT:
     {
-      SetAnchorPoint( property.Get< Vector3 >() );
+      Property::Type type = property.GetType();
+      if( type == Property::VECTOR3 )
+      {
+        SetAnchorPoint( property.Get< Vector3 >() );
+      }
+      else if ( type == Property::STRING )
+      {
+        std::string anchorPointString;
+        property.Get( anchorPointString );
+        Vector3 anchor;
+        if( GetAnchorPointConstant( anchorPointString, anchor ) )
+        {
+          SetAnchorPoint( anchor );
+        }
+      }
       break;
     }
 
@@ -2472,19 +2545,31 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
 
     case Dali::Actor::Property::COLOR_MODE:
     {
-      SetColorMode( Scripting::GetColorMode( property.Get< std::string >() ) );
+      ColorMode mode;
+      if ( Scripting::GetEnumeration< ColorMode >( property.Get< std::string >().c_str(), COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT, mode ) )
+      {
+        SetColorMode( mode );
+      }
       break;
     }
 
     case Dali::Actor::Property::POSITION_INHERITANCE:
     {
-      SetPositionInheritanceMode( Scripting::GetPositionInheritanceMode( property.Get< std::string >() ) );
+      PositionInheritanceMode mode;
+      if( Scripting::GetEnumeration< PositionInheritanceMode >( property.Get< std::string >().c_str(), POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT, mode ) )
+      {
+        SetPositionInheritanceMode( mode );
+      }
       break;
     }
 
     case Dali::Actor::Property::DRAW_MODE:
     {
-      SetDrawMode( Scripting::GetDrawMode( property.Get< std::string >() ) );
+      DrawMode::Type mode;
+      if( Scripting::GetEnumeration< DrawMode::Type >( property.Get< std::string >().c_str(), DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT, mode ) )
+      {
+        SetDrawMode( mode );
+      }
       break;
     }
 
@@ -2497,7 +2582,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
     case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
     {
       ResizePolicy::Type type;
-      if( Scripting::GetEnumeration< ResizePolicy::Type >( property.Get< std::string >().c_str(), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount, type ) )
+      if( Scripting::GetEnumeration< ResizePolicy::Type >( property.Get< std::string >().c_str(), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT, type ) )
       {
         SetResizePolicy( type, Dimension::WIDTH );
       }
@@ -2507,7 +2592,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
     case Dali::Actor::Property::HEIGHT_RESIZE_POLICY:
     {
       ResizePolicy::Type type;
-      if( Scripting::GetEnumeration< ResizePolicy::Type >( property.Get< std::string >().c_str(), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount, type ) )
+      if( Scripting::GetEnumeration< ResizePolicy::Type >( property.Get< std::string >().c_str(), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT, type ) )
       {
         SetResizePolicy( type, Dimension::HEIGHT );
       }
@@ -2517,7 +2602,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
     case Dali::Actor::Property::SIZE_SCALE_POLICY:
     {
       SizeScalePolicy::Type type;
-      if( Scripting::GetEnumeration< SizeScalePolicy::Type >( property.Get< std::string >().c_str(), SizeScalePolicy::TypeTable, SizeScalePolicy::TypeTableCount, type ) )
+      if( Scripting::GetEnumeration< SizeScalePolicy::Type >( property.Get< std::string >().c_str(), SIZE_SCALE_POLICY_TABLE, SIZE_SCALE_POLICY_TABLE_COUNT, type ) )
       {
         SetSizeScalePolicy( type );
       }
@@ -2985,19 +3070,19 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const
 
     case Dali::Actor::Property::COLOR_MODE:
     {
-      value = Scripting::GetColorMode( GetColorMode() );
+      value = Scripting::GetLinearEnumerationName< ColorMode >( GetColorMode(), COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT );
       break;
     }
 
     case Dali::Actor::Property::POSITION_INHERITANCE:
     {
-      value = Scripting::GetPositionInheritanceMode( GetPositionInheritanceMode() );
+      value = Scripting::GetLinearEnumerationName< PositionInheritanceMode >( GetPositionInheritanceMode(), POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
       break;
     }
 
     case Dali::Actor::Property::DRAW_MODE:
     {
-      value = Scripting::GetDrawMode( GetDrawMode() );
+      value = Scripting::GetEnumerationName< DrawMode::Type >( GetDrawMode(), DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
       break;
     }
 
@@ -3009,19 +3094,19 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const
 
     case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
     {
-      value = Scripting::GetLinearEnumerationName< ResizePolicy::Type >( GetResizePolicy( Dimension::WIDTH ), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount );
+      value = Scripting::GetLinearEnumerationName< ResizePolicy::Type >( GetResizePolicy( Dimension::WIDTH ), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT );
       break;
     }
 
     case Dali::Actor::Property::HEIGHT_RESIZE_POLICY:
     {
-      value = Scripting::GetLinearEnumerationName< ResizePolicy::Type >( GetResizePolicy( Dimension::HEIGHT ), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount );
+      value = Scripting::GetLinearEnumerationName< ResizePolicy::Type >( GetResizePolicy( Dimension::HEIGHT ), RESIZE_POLICY_TABLE, RESIZE_POLICY_TABLE_COUNT );
       break;
     }
 
     case Dali::Actor::Property::SIZE_SCALE_POLICY:
     {
-      value = Scripting::GetLinearEnumerationName< SizeScalePolicy::Type >( GetSizeScalePolicy(), SizeScalePolicy::TypeTable, SizeScalePolicy::TypeTableCount );
+      value = Scripting::GetLinearEnumerationName< SizeScalePolicy::Type >( GetSizeScalePolicy(), SIZE_SCALE_POLICY_TABLE, SIZE_SCALE_POLICY_TABLE_COUNT );
       break;
     }
 
index 7051f99..e8b77a8 100644 (file)
@@ -38,10 +38,10 @@ namespace
 
 typedef Layer::Behavior Behavior;
 
-DALI_ENUM_TO_STRING_TABLE_BEGIN( Behavior )
-DALI_ENUM_TO_STRING_INSIDE_CLASS( Layer, LAYER_2D )
-DALI_ENUM_TO_STRING_INSIDE_CLASS( Layer, LAYER_3D )
-DALI_ENUM_TO_STRING_TABLE_END( Behavior )
+DALI_ENUM_TO_STRING_TABLE_BEGIN( BEHAVIOR )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_2D )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_3D )
+DALI_ENUM_TO_STRING_TABLE_END( BEHAVIOR )
 
 } // namespace
 
@@ -482,7 +482,7 @@ void Layer::SetDefaultProperty( Property::Index index, const Property::Value& pr
       case Dali::Layer::Property::BEHAVIOR:
       {
         Behavior behavior(Dali::Layer::LAYER_2D);
-        if( Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BehaviorTable, BehaviorTableCount, behavior ) )
+        if( Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT, behavior ) )
         {
           SetBehavior( behavior );
         }
@@ -521,7 +521,7 @@ Property::Value Layer::GetDefaultProperty( Property::Index index ) const
       }
       case Dali::Layer::Property::BEHAVIOR:
       {
-        ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BehaviorTable, BehaviorTableCount );
+        ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT );
         break;
       }
       default:
diff --git a/dali/internal/event/common/property-helper.cpp b/dali/internal/event/common/property-helper.cpp
new file mode 100644 (file)
index 0000000..4a39ab4
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// HEADER
+#include <dali/internal/event/common/property-helper.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+bool CompareTokens( const char * first, const char * second, size_t& size )
+{
+  size = 0;
+  while( ( *first != '\0' ) && ( *second != '\0' ) && ( *first != ',') && ( *second != ',') )
+  {
+    ++size;
+    char ca = *first;
+    char cb = *second;
+
+    if( ( ( ca == '-' ) || ( ca == '_') ) &&
+        ( ( cb == '-' ) || ( cb == '_') ) )
+    {
+      ++first;
+      ++second;
+      continue;
+    }
+
+    if( ( 'A' <= ca ) && ( ca <= 'Z') )
+    {
+      ca = ca + ( 'a' - 'A' );
+    }
+
+    if( ( 'A' <= cb ) && ( cb <= 'Z') )
+    {
+      cb = cb + ( 'a' - 'A' );
+    }
+
+    if( ca != cb )
+    {
+      return false;
+    }
+
+    ++first;
+    ++second;
+  }
+
+  // enums can be comma separated so check ends and comma
+  if( ( ( *first == '\0' ) && ( *second == '\0' ) ) ||
+      ( ( *first == '\0' ) && ( *second == ','  ) ) ||
+      ( ( *first == ','  ) && ( *second == '\0' ) ) )
+  {
+    return true;
+  }
+
+  return false;
+}
+
+} // namespace Internal
+
+} // namespace Dali
index 6f9e793..a3a4cd5 100644 (file)
@@ -77,30 +77,47 @@ struct PropertyDetails
 #endif
 
 /**
- * Macros for creating enumeration to string tables.
+ * Macros for creating value, typically enumerations, to string tables.
  * Example:
  *
- * DALI_ENUM_TO_STRING_TABLE_BEGIN( SizeMode )
+ * DALI_ENUM_TO_STRING_TABLE_BEGIN( SIZE_MODE )
  * DALI_ENUM_TO_STRING( USE_OWN_SIZE )
  * DALI_ENUM_TO_STRING( SIZE_EQUAL_TO_PARENT )
- * DALI_ENUM_TO_STRING_TABLE_END( SizeMode )
+ * DALI_ENUM_TO_STRING_TABLE_END( SIZE_MODE )
  *
  * Creates:
- * const Scripting::StringEnum< SizeMode > SizeModeTable[] = {
+ * const Scripting::StringEnum< SizeMode > SIZE_MODE_TABLE[] = {
  * { "USE_OWN_SIZE", USE_OWN_SIZE },
  * { "SIZE_EQUAL_TO_PARENT", SIZE_EQUAL_TO_PARENT },
- * }; const unsigned int SizeModeTableCount = sizeof( SizeModeTable ) / sizeof( SizeModeTable[0] );
+ * }; const unsigned int SIZE_MODE_TABLE_COUNT = sizeof( SIZE_MODE_TABLE ) / sizeof( SIZE_MODE_TABLE[0] );
+ *
+ * By default, Dali::Scripting::StringEnum is used as the type for the table, however, a different type can be specified by using
+ * DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE.
  */
-#define DALI_ENUM_TO_STRING_TABLE_BEGIN( t ) const Dali::Scripting::StringEnum t##Table[] = {
-#define DALI_ENUM_TO_STRING_TABLE_END( t )   }; const unsigned int t##TableCount = sizeof( t##Table ) / sizeof( t##Table[0] );
+#define DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE( type, t ) const type t##_TABLE[] = {
+#define DALI_ENUM_TO_STRING_TABLE_BEGIN( t ) DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE( Dali::Scripting::StringEnum, t )
+#define DALI_ENUM_TO_STRING_TABLE_END( t )   }; const unsigned int t##_TABLE_COUNT = sizeof( t##_TABLE ) / sizeof( t##_TABLE[0] );
 #define DALI_ENUM_TO_STRING( s ) { #s, s },
 
 /**
- * DALI_ENUM_TO_STRING_INSIDE_CLASS
- * Example converts ( Layer, LAYER_2D) to ( "LAYER_2D", Layer::Layer2D)
+ * Adds a value, typically an enum, to the table within a scope but without the scope name
+ * Example converts ( Layer, LAYER_2D ) to ( "LAYER_2D", Layer::Layer2D )
  */
-#define DALI_ENUM_TO_STRING_INSIDE_CLASS( className, enumName) { #enumName, className::enumName },
+#define DALI_ENUM_TO_STRING_WITH_SCOPE( className, enumName ) { #enumName, className::enumName },
 
+/**
+ * @brief Case insensitive string comparison.
+ *
+ * Additionally, '-' and '_' can be used interchangeably as well.
+ * Returns if both strings have a ',' or a '\0' at the same point.
+ *
+ * @param[in]   first   The first string.
+ * @param[in]   second  The string to compare it to.
+ * @param[out]  size    The size of the string.
+ *
+ * @return true if strings are the same
+ */
+bool CompareTokens( const char * first, const char * second, size_t& size );
 
 } // namespace Internal
 
index 98eba58..92a2e1f 100644 (file)
@@ -35,6 +35,7 @@ internal_src_files = \
   $(internal_src_dir)/event/common/property-conditions-impl.cpp  \
   $(internal_src_dir)/event/common/property-notification-impl.cpp  \
   $(internal_src_dir)/event/common/property-notification-manager.cpp \
+  $(internal_src_dir)/event/common/property-helper.cpp \
   $(internal_src_dir)/event/common/stage-impl.cpp \
   $(internal_src_dir)/event/common/system-overlay-impl.cpp \
   $(internal_src_dir)/event/common/thread-local-storage.cpp \