Builder support for unsigned int property conversion
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Mon, 9 Jun 2014 15:14:41 +0000 (16:14 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 11 Jun 2014 08:01:52 +0000 (09:01 +0100)
[problem]      Builder was unable to convert property values to unsigned int
[cause]        Used integer comparison
[solution]     Added a property to unsigned int conversion

Change-Id: I6ccfac3561d016c197e18e518df35ccf9783c505

base/dali-toolkit/internal/builder/builder-set-property.cpp
base/dali-toolkit/internal/builder/replacement.cpp
base/dali-toolkit/internal/builder/replacement.h

index ac3c564..71ae7a0 100644 (file)
@@ -206,7 +206,7 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::V
     }
     case Property::UNSIGNED_INTEGER:
     {
-      if( OptionalInteger v = replacer.IsInteger(node) )
+      if( OptionalUnsignedInt v = replacer.IsUnsignedInteger( node) )
       {
         if( *v >= 0 ) // with a loss of resolution....
         {
index f5b6709..259cb87 100644 (file)
@@ -378,6 +378,27 @@ OptionalInteger Replacement::IsInteger( const TreeNode & node ) const
   return ret;
 }
 
+OptionalUnsignedInt Replacement::IsUnsignedInteger( const TreeNode & node ) const
+{
+  OptionalUnsignedInt ret;
+  if( OptionalString replace = HasFullReplacement( node ) )
+  {
+    Property::Value value = GetFullReplacement( *replace );
+    if( Property::UNSIGNED_INTEGER == value.GetType() )
+    {
+      ret = value.Get<unsigned int>();
+    }
+  }
+  else
+  {
+    if ( OptionalInteger i = ::IsInteger( node ) )
+    {
+      ret = OptionalUnsignedInt(static_cast<unsigned int>(*i) );
+    }
+  }
+  return ret;
+}
+
 OptionalVector2 Replacement::IsVector2( const TreeNode & node ) const
 {
   OptionalVector2 ret;
index 1cd5b88..71e55d0 100644 (file)
@@ -99,6 +99,13 @@ public:
    * @param node The TreeNode to check
    * @return Optional value
    */
+  OptionalUnsignedInt IsUnsignedInteger( const TreeNode & node ) const;
+
+  /* @brief Check node for a type
+   *
+   * @param node The TreeNode to check
+   * @return Optional value
+   */
   OptionalVector2 IsVector2( const TreeNode & node ) const;
 
   /* @brief Check node for a type