edje: check existence of group at compile time also.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 19 Dec 2011 17:25:00 +0000 (17:25 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 19 Dec 2011 17:25:00 +0000 (17:25 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@66336 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/bin/edje_cc.h
src/bin/edje_cc_handlers.c
src/bin/edje_cc_out.c

index 3fc1cc9..cc139d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * Fix wrong call to free() in edje_load.
        * Reduce parts walk to the strict minimum.
+
+2011-12-19  Cedric Bail
+
+       * Check existence of group at compile time also.
diff --git a/NEWS b/NEWS
index e238922..b2abed9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,11 @@
 Edje 1.1.0
 
 Changes since Edje 1.1.0:
+-------------------------
 
 Improvements:
     * speedup load time of Edje file.
+    * check existence of group at compile time also.
 
 Changes since Edje 1.0.0:
 -------------------------
index bcd31a1..d0c6d22 100644 (file)
@@ -138,6 +138,7 @@ struct _Edje_Part_Parser
 /* global fn calls */
 void    data_setup(void);
 void    data_write(void);
+void    data_queue_group_lookup(const char *name, Edje_Part *part);
 void    data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
 void    data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest);
 void    data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest);
index e0ab935..6a3e58c 100644 (file)
@@ -3212,6 +3212,7 @@ st_collections_group_parts_part_source(void)
 
    //FIXME: validate this somehow (need to decide on the format also)
    current_part->source = parse_str(0);
+   data_queue_group_lookup(current_part->source, current_part);
 }
 
 /**
@@ -3233,6 +3234,7 @@ st_collections_group_parts_part_source2(void)
 
    //FIXME: validate this somehow (need to decide on the format also)
    current_part->source2 = parse_str(0);
+   data_queue_group_lookup(current_part->source2, current_part);
 }
 
 /**
@@ -3254,6 +3256,7 @@ st_collections_group_parts_part_source3(void)
 
    //FIXME: validate this somehow (need to decide on the format also)
    current_part->source3 = parse_str(0);
+   data_queue_group_lookup(current_part->source3, current_part);
 }
 
 /**
@@ -3275,6 +3278,7 @@ st_collections_group_parts_part_source4(void)
 
    //FIXME: validate this somehow (need to decide on the format also)
    current_part->source4 = parse_str(0);
+   data_queue_group_lookup(current_part->source4, current_part);
 }
 
 /**
@@ -3296,6 +3300,7 @@ st_collections_group_parts_part_source5(void)
 
    //FIXME: validate this somehow (need to decide on the format also)
    current_part->source5 = parse_str(0);
+   data_queue_group_lookup(current_part->source5, current_part);
 }
 
 /**
@@ -3317,6 +3322,7 @@ st_collections_group_parts_part_source6(void)
 
    //FIXME: validate this somehow (need to decide on the format also)
    current_part->source6 = parse_str(0);
+   data_queue_group_lookup(current_part->source6, current_part);
 }
 
 /**
@@ -3804,6 +3810,7 @@ static void st_collections_group_parts_part_box_items_item_source(void)
    check_arg_count(1);
 
    current_item->source = parse_str(0);
+   data_queue_group_lookup(current_item->source, current_part);
 }
 
 /**
index 443a702..fc77d9d 100644 (file)
@@ -72,6 +72,7 @@ struct _Program_Lookup
 struct _Group_Lookup
 {
    char *name;
+   Edje_Part *part;
 };
 
 struct _String_Lookup
@@ -1371,13 +1372,16 @@ reorder_parts(void)
 }
 
 void
-data_queue_group_lookup(char *name)
+data_queue_group_lookup(const char *name, Edje_Part *part)
 {
    Group_Lookup *gl;
 
+   if (!name || strlen(name) == 0) return ;
+
    gl = mem_alloc(SZ(Group_Lookup));
    group_lookups = eina_list_append(group_lookups, gl);
    gl->name = mem_strdup(name);
+   gl->part = part;
 }
 
 void
@@ -1698,15 +1702,36 @@ data_process_lookups(void)
      {
        Edje_Part_Collection_Directory_Entry *de;
 
+        if (!group->part
+            || (group->part->type != EDJE_PART_TYPE_GROUP
+                && group->part->type != EDJE_PART_TYPE_TEXTBLOCK
+                && group->part->type != EDJE_PART_TYPE_BOX
+                && group->part->type != EDJE_PART_TYPE_TABLE))
+          goto free_group;
+
        de = eina_hash_find(edje_file->collection, group->name);
 
        if (!de)
+         {
+             Eina_Bool found = EINA_FALSE;
+
+             EINA_LIST_FOREACH(aliases, l, de)
+               if (strcmp(de->entry, group->name) == 0)
+                 {
+                    found = EINA_TRUE;
+                    break;
+                 }
+             if (!found) de = NULL;
+         }
+
+       if (!de)
           {
              ERR("%s: Error. Unable to find group name \"%s\".",
                 progname, group->name);
              exit(-1);
           }
 
+     free_group:
         free(group->name);
         free(group);
      }
@@ -1914,7 +1939,7 @@ _data_queue_program_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int
 static void
 _data_queue_group_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, char *ptr __UNUSED__, int len __UNUSED__)
 {
-   data_queue_group_lookup(name);
+   data_queue_group_lookup(name, NULL);
 }
 static void
 _data_queue_image_pc_lookup(Edje_Part_Collection *pc __UNUSED__, char *name, char *ptr, int len)