From ed7febb2c542ec2c735aaf411e25c36ef4ce002a Mon Sep 17 00:00:00 2001 From: Jee-Yong Um Date: Fri, 23 Sep 2016 11:56:19 +0900 Subject: [PATCH] edje_cc: allow combine lazEDC keywords Summary: Fix parsing error which occurs when lazEDC keyword is combined with other keyword by period. (like parts.rect) @fix Test Plan: Download attached file and run "make" Reviewers: Hermet, cedric, jpeg Subscribers: taxi2se Differential Revision: https://phab.enlightenment.org/D4309 --- src/Makefile_Edje.am | 2 ++ src/bin/edje/edje_cc.h | 3 +- src/bin/edje/edje_cc_handlers.c | 6 ++-- src/bin/edje/edje_cc_parse.c | 43 +++++++++++++++++++++++++-- src/tests/edje/data/test_combine_keywords.edc | 10 +++++++ src/tests/edje/edje_test_edje.c | 15 ++++++++++ 6 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 src/tests/edje/data/test_combine_keywords.edc diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am index 4ecaa65..5c3e0de 100644 --- a/src/Makefile_Edje.am +++ b/src/Makefile_Edje.am @@ -273,6 +273,7 @@ tests/edje/data/test_color_class.edc \ tests/edje/data/test_swallows.edc \ tests/edje/data/test_box.edc \ tests/edje/data/test_table.edc \ +tests/edje/data/test_combine_keywords.edc \ tests/edje/data/filter.lua @@ -312,6 +313,7 @@ EDJE_TEST_FILES = tests/edje/data/test_layout.edj \ tests/edje/data/test_color_class.edj \ tests/edje/data/test_box.edj \ tests/edje/data/test_table.edj \ + tests/edje/data/test_combine_keywords.edj \ $(NULL) CLEANFILES += $(EDJE_TEST_FILES) diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h index 91371ba..9e47283 100644 --- a/src/bin/edje/edje_cc.h +++ b/src/bin/edje/edje_cc.h @@ -247,7 +247,8 @@ void using_file(const char *filename, const char type); void error_and_abort(Eet_File *ef, const char *fmt, ...); void stack_push_quick(const char *str); -void stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free); +char *stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free); +void stack_replace_quick(const char *token); Eina_Bool edje_cc_handlers_wildcard(void); void edje_cc_handlers_hierarchy_alloc(void); void edje_cc_handlers_hierarchy_free(void); diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index efe728f..b0fdb49 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -5951,8 +5951,7 @@ ob_collections_group_parts_part_short(void) "vector", EDJE_PART_TYPE_VECTOR, NULL); - stack_pop_quick(EINA_TRUE, EINA_TRUE); - stack_push_quick("part"); + stack_replace_quick("part"); _part_create(); _part_type_set(type); } @@ -7990,8 +7989,7 @@ ob_collections_group_parts_part_description(void) static void ob_collections_group_parts_part_desc(void) { - stack_pop_quick(EINA_TRUE, EINA_TRUE); - stack_push_quick("description"); + stack_replace_quick("description"); ob_collections_group_parts_part_description(); } diff --git a/src/bin/edje/edje_cc_parse.c b/src/bin/edje/edje_cc_parse.c index 525c71d..e5a7386 100644 --- a/src/bin/edje/edje_cc_parse.c +++ b/src/bin/edje/edje_cc_parse.c @@ -672,7 +672,7 @@ stack_push_quick(const char *str) eina_strbuf_append(stack_buf, s); } -void +char * stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free) { char *tmp, *str; @@ -690,7 +690,46 @@ stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free) eina_strbuf_length_get(stack_buf) - strlen(tmp) - 1, eina_strbuf_length_get(stack_buf)); /* remove: '.tmp' */ stack = eina_list_remove_list(stack, eina_list_last(stack)); - if (do_free) free(str); + if (do_free) + { + free(str); + str = NULL; + } + return str; +} + +/* replace the top of stack with given token */ +void +stack_replace_quick(const char *token) +{ + char *str; + + str = stack_pop_quick(EINA_FALSE, EINA_FALSE); + if ((str) && strchr(str, '.')) + { + char *end, *tmp = str; + Eina_Strbuf *buf; + + end = strchr(tmp, '.'); + if (end) + tmp = end + 1; + + buf = eina_strbuf_new(); + eina_strbuf_append(buf, str); + eina_strbuf_remove(buf, + eina_strbuf_length_get(buf) - strlen(tmp), + eina_strbuf_length_get(buf)); + eina_strbuf_append(buf, token); + + stack_push_quick(eina_strbuf_string_get(buf)); + + eina_strbuf_free(buf); + free(str); + } + else + { + stack_push_quick(token); + } } static const char * diff --git a/src/tests/edje/data/test_combine_keywords.edc b/src/tests/edje/data/test_combine_keywords.edc new file mode 100644 index 0000000..76b70a0 --- /dev/null +++ b/src/tests/edje/data/test_combine_keywords.edc @@ -0,0 +1,10 @@ +collections { + group { "test_group"; + parts.rect { "base"; + } + } + group { "test_group2"; + parts.rect { "base"; + } + } +} diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c index c681e02..e2723d8 100644 --- a/src/tests/edje/edje_test_edje.c +++ b/src/tests/edje/edje_test_edje.c @@ -711,6 +711,20 @@ START_TEST(edje_test_table_eoapi) } END_TEST +START_TEST(edje_test_combine_keywords) +{ + Evas *evas; + Evas_Object *obj; + + evas = EDJE_TEST_INIT_EVAS(); + + obj = edje_object_add(evas); + fail_unless(edje_object_file_set(obj, test_layout_get("test_combine_keywords.edj"), "test_group")); + + EDJE_TEST_FREE_EVAS(); +} +END_TEST + void edje_test_edje(TCase *tc) { tcase_add_test(tc, edje_test_edje_init); @@ -731,4 +745,5 @@ void edje_test_edje(TCase *tc) tcase_add_test(tc, edje_test_box_eoapi); tcase_add_test(tc, edje_test_table); tcase_add_test(tc, edje_test_table_eoapi); + tcase_add_test(tc, edje_test_combine_keywords); } -- 2.7.4