Loosen tuple type checking between numeric types 30/122130/1
authorSomin Kim <somin926.kim@samsung.com>
Thu, 30 Mar 2017 08:29:26 +0000 (17:29 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Thu, 30 Mar 2017 08:32:34 +0000 (17:32 +0900)
Change-Id: I98425ba02f510104a27ad1e62b08ea2917742290
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
src/shared/Tuple.cpp

index e668ff3..101c644 100644 (file)
@@ -84,15 +84,27 @@ unsigned int Tuple::size()
 
 bool Tuple::getAt(unsigned int idx, int64_t* val)
 {
-       IF_FAIL_RETURN(__verify(idx, G_VARIANT_TYPE_INT64), false);
-       *val = g_variant_get_int64(__elements[idx]);
+       if (__verify(idx, G_VARIANT_TYPE_INT64)) {
+               *val = g_variant_get_int64(__elements[idx]);
+       } else if (__verify(idx, G_VARIANT_TYPE_DOUBLE)) {
+               *val = g_variant_get_double(__elements[idx]);
+       } else {
+               return false;
+       }
+
        return true;
 }
 
 bool Tuple::getAt(unsigned int idx, double* val)
 {
-       IF_FAIL_RETURN(__verify(idx, G_VARIANT_TYPE_DOUBLE), false);
-       *val = g_variant_get_double(__elements[idx]);
+       if (__verify(idx, G_VARIANT_TYPE_DOUBLE)) {
+               *val = g_variant_get_double(__elements[idx]);
+       } else if (__verify(idx, G_VARIANT_TYPE_INT64)) {
+               *val = g_variant_get_int64(__elements[idx]);
+       } else {
+               return false;
+       }
+
        return true;
 }