edje: add recursive hash search helper 51/78451/4
authorJee-Yong Um <conr2d@gmail.com>
Tue, 5 Jul 2016 13:23:47 +0000 (22:23 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Fri, 8 Jul 2016 00:08:03 +0000 (17:08 -0700)
Change-Id: I6ddc249aabb54cdaf5f61c3d05573deca98453a9
Signed-Off-By: Jee-Yong Um <jc9.um@samsung.com>
src/lib/edje/edje_util.c

index 965b0ea..e206b4a 100644 (file)
@@ -5113,6 +5113,55 @@ _edje_real_part_get(const Edje *ed, const char *part)
    return NULL;
 }
 
+//TIZEN_ONLY(20160705): add recursive hash search helper
+void *
+_edje_hash_find_helper(const Eina_Hash *hash, const char *key)
+{
+   void *data;
+   int i, j;
+   char **tokens;
+   unsigned int tokens_count = 0;
+   Eina_Strbuf *buf = NULL;
+
+   data = eina_hash_find(hash, key);
+   if (data)
+     return data;
+
+   tokens = eina_str_split_full(key, "/", 0, &tokens_count);
+
+   if ((tokens) && (tokens_count > 1))
+     {
+        buf = eina_strbuf_new();
+
+        for (i = tokens_count - 2; i >= 0; i--)
+          {
+             for (j = 0; j < i; j++)
+               {
+                  eina_strbuf_append(buf, tokens[j]);
+                  eina_strbuf_append(buf, "/");
+               }
+             eina_strbuf_append(buf, tokens[tokens_count - 1]);
+
+             data = eina_hash_find(hash, eina_strbuf_string_get(buf));
+             if (data) break;
+
+             eina_strbuf_reset(buf);
+          }
+     }
+
+   if (buf)
+     {
+        eina_strbuf_free(buf);
+     }
+   if (tokens)
+     {
+        free(tokens[0]);
+        free(tokens);
+     }
+   return data;
+}
+//
+
 Edje_Color_Class *
 _edje_color_class_find(const Edje *ed, const char *color_class)
 {
@@ -5121,15 +5170,20 @@ _edje_color_class_find(const Edje *ed, const char *color_class)
    if ((!ed) || (!color_class)) return NULL;
 
    /* first look through the object scope */
-   cc = eina_hash_find(ed->color_classes, color_class);
+//TIZEN_ONLY(20160705): add recursive hash search helper
+   //cc = eina_hash_find(ed->color_classes, color_class);
+   cc = _edje_hash_find_helper(ed->color_classes, color_class);
    if (cc) return cc;
 
    /* next look through the global scope */
-   cc = eina_hash_find(_edje_color_class_hash, color_class);
+   //cc = eina_hash_find(_edje_color_class_hash, color_class);
+   cc = _edje_hash_find_helper(_edje_color_class_hash, color_class);
    if (cc) return cc;
 
    /* finally, look through the file scope */
-   cc = eina_hash_find(ed->file->color_hash, color_class);
+   //cc = eina_hash_find(ed->file->color_hash, color_class);
+   cc = _edje_hash_find_helper(ed->file->color_hash, color_class);
+//
    if (cc) return cc;
 
    return NULL;