From: Jee-Yong Um Date: Tue, 5 Jul 2016 13:23:47 +0000 (+0900) Subject: edje: add recursive hash search helper X-Git-Tag: submit/tizen/20160711.050109~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=841091db12db3eb2b48b2f6c307ea937db3d9973;p=platform%2Fupstream%2Fefl.git edje: add recursive hash search helper Change-Id: I6ddc249aabb54cdaf5f61c3d05573deca98453a9 Signed-Off-By: Jee-Yong Um --- diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index 965b0ea..e206b4a 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -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;