summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJee-Yong Um <conr2d@gmail.com>2016-01-04 15:15:31 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-01-04 15:42:59 -0800
commite12456f3e7fd252640d04c44a4b75340aaede593 (patch)
treee81638c6201139fadb2fd2aa4d9ae11e6f811b30
parent5aa6a73b3461af4d67ba2dfe369ee2da3e11c9b5 (diff)
edje_cc: abort when insert_before/after part doesn't exist
Summary: edje_cc does not check whether insert_before/after part exists. edje_cc will notify a compilation error to developer when insert_before or insert_after part does not exist. T2513 Reviewers: Hermet, NikaWhite Subscribers: cedric, jpeg Maniphest Tasks: T2513 Differential Revision: https://phab.enlightenment.org/D3517 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/bin/edje/edje_cc.h1
-rw-r--r--src/bin/edje/edje_cc_handlers.c14
-rw-r--r--src/bin/edje/edje_cc_out.c36
3 files changed, 46 insertions, 5 deletions
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index b4da941806..aa49caa8a4 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -240,6 +240,7 @@ char *mem_strdup(const char *s);
240#define SZ sizeof 240#define SZ sizeof
241 241
242void using_file(const char *filename, const char type); 242void using_file(const char *filename, const char type);
243Eina_Bool needed_part_exists(Edje_Part_Collection *pc, const char *name);
243 244
244void error_and_abort(Eet_File *ef, const char *fmt, ...); 245void error_and_abort(Eet_File *ef, const char *fmt, ...);
245 246
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 5d830a3235..32c8ba848e 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -5982,11 +5982,16 @@ st_collections_group_parts_part_physics_body(void)
5982static void 5982static void
5983st_collections_group_parts_part_insert_before(void) 5983st_collections_group_parts_part_insert_before(void)
5984{ 5984{
5985 Edje_Part_Collection *pc;
5985 Edje_Part_Parser *epp; 5986 Edje_Part_Parser *epp;
5987 char *name;
5988
5986 check_arg_count(1); 5989 check_arg_count(1);
5987 5990
5991 pc = eina_list_data_get(eina_list_last(edje_collections));
5992 name = parse_str(0);
5988 epp = (Edje_Part_Parser *)current_part; 5993 epp = (Edje_Part_Parser *)current_part;
5989 epp->reorder.insert_before = parse_str(0); 5994 epp->reorder.insert_before = name;
5990} 5995}
5991 5996
5992/** 5997/**
@@ -6005,11 +6010,16 @@ st_collections_group_parts_part_insert_before(void)
6005static void 6010static void
6006st_collections_group_parts_part_insert_after(void) 6011st_collections_group_parts_part_insert_after(void)
6007{ 6012{
6013 Edje_Part_Collection *pc;
6008 Edje_Part_Parser *epp; 6014 Edje_Part_Parser *epp;
6015 char *name;
6016
6009 check_arg_count(1); 6017 check_arg_count(1);
6010 6018
6019 pc = eina_list_data_get(eina_list_last(edje_collections));
6020 name = parse_str(0);
6011 epp = (Edje_Part_Parser *)current_part; 6021 epp = (Edje_Part_Parser *)current_part;
6012 epp->reorder.insert_after = parse_str(0); 6022 epp->reorder.insert_after = name;
6013} 6023}
6014 6024
6015/** 6025/**
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index c5c439aefe..cc11fad5e0 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -2609,6 +2609,8 @@ reorder_parts(void)
2609 if (ep->reorder.insert_before && 2609 if (ep->reorder.insert_before &&
2610 !strcmp(ep->reorder.insert_before, pc->parts[j]->name)) 2610 !strcmp(ep->reorder.insert_before, pc->parts[j]->name))
2611 { 2611 {
2612 needed_part_exists(pc, ep->reorder.insert_before);
2613
2612 ep2 = (Edje_Part_Parser *)pc->parts[j]; 2614 ep2 = (Edje_Part_Parser *)pc->parts[j];
2613 if (ep2->reorder.after) 2615 if (ep2->reorder.after)
2614 ERR("The part \"%s\" is ambiguous ordered part.", 2616 ERR("The part \"%s\" is ambiguous ordered part.",
@@ -2619,7 +2621,7 @@ reorder_parts(void)
2619 /* Need it to be able to insert an element before the first */ 2621 /* Need it to be able to insert an element before the first */
2620 if (j == 0) k = 0; 2622 if (j == 0) k = 0;
2621 else k = j - 1; 2623 else k = j - 1;
2622 found = EINA_TRUE; 2624 found = EINA_TRUE;
2623 ep2->reorder.linked_prev += ep->reorder.linked_prev + 1; 2625 ep2->reorder.linked_prev += ep->reorder.linked_prev + 1;
2624 ep->reorder.before = (Edje_Part_Parser *)pc->parts[j]; 2626 ep->reorder.before = (Edje_Part_Parser *)pc->parts[j];
2625 while (ep2->reorder.before) 2627 while (ep2->reorder.before)
@@ -2630,15 +2632,17 @@ reorder_parts(void)
2630 break; 2632 break;
2631 } 2633 }
2632 else if (ep->reorder.insert_after && 2634 else if (ep->reorder.insert_after &&
2633 !strcmp(ep->reorder.insert_after, pc->parts[j]->name)) 2635 !strcmp(ep->reorder.insert_after, pc->parts[j]->name))
2634 { 2636 {
2637 needed_part_exists(pc, ep->reorder.insert_after);
2638
2635 ep2 = (Edje_Part_Parser *)pc->parts[j]; 2639 ep2 = (Edje_Part_Parser *)pc->parts[j];
2636 if (ep2->reorder.before) 2640 if (ep2->reorder.before)
2637 ERR("The part \"%s\" is ambiguous ordered part.", pc->parts[i]->name); 2641 ERR("The part \"%s\" is ambiguous ordered part.", pc->parts[i]->name);
2638 if (ep2->reorder.linked_next) 2642 if (ep2->reorder.linked_next)
2639 ERR("Unable to insert two or more parts in same part \"%s\".", pc->parts[j]->name); 2643 ERR("Unable to insert two or more parts in same part \"%s\".", pc->parts[j]->name);
2640 k = j; 2644 k = j;
2641 found = EINA_TRUE; 2645 found = EINA_TRUE;
2642 ep2->reorder.linked_next += ep->reorder.linked_next + 1; 2646 ep2->reorder.linked_next += ep->reorder.linked_next + 1;
2643 ep->reorder.after = (Edje_Part_Parser *)pc->parts[j]; 2647 ep->reorder.after = (Edje_Part_Parser *)pc->parts[j];
2644 while (ep2->reorder.after) 2648 while (ep2->reorder.after)
@@ -4109,3 +4113,29 @@ using_file(const char *filename, const char type)
4109 fclose(f); 4113 fclose(f);
4110 } 4114 }
4111} 4115}
4116
4117Eina_Bool
4118needed_part_exists(Edje_Part_Collection *pc, const char *name)
4119{
4120 Eina_Bool found;
4121 unsigned int i;
4122
4123 found = EINA_FALSE;
4124
4125 for (i = 0; i < pc->parts_count; i++)
4126 {
4127 if (!strcmp(pc->parts[i]->name, name))
4128 {
4129 found = EINA_TRUE;
4130 break;
4131 }
4132 }
4133
4134 if (!found)
4135 {
4136 ERR("Unable to find part name \"%s\" needed in group \"%s\".",
4137 name, pc->part);
4138 exit(-1);
4139 }
4140 return found;
4141}