edje_cc: fix detecting missing part for insert_before/after
Summary: Detecting missing part for insert_before/after is broken. This patch makes the feature work and clarifies error message, and removes redundant internal function. Reviewers: cedric, jpeg Subscribers: jpeg Maniphest Tasks: T2513 Differential Revision: https://phab.enlightenment.org/D3576
This commit is contained in:
parent
7f4f215cd0
commit
2ca99b8b68
|
@ -240,7 +240,6 @@ char *mem_strdup(const char *s);
|
||||||
#define SZ sizeof
|
#define SZ sizeof
|
||||||
|
|
||||||
void using_file(const char *filename, const char type);
|
void using_file(const char *filename, const char type);
|
||||||
Eina_Bool needed_part_exists(Edje_Part_Collection *pc, const char *name);
|
|
||||||
|
|
||||||
void error_and_abort(Eet_File *ef, const char *fmt, ...);
|
void error_and_abort(Eet_File *ef, const char *fmt, ...);
|
||||||
|
|
||||||
|
|
|
@ -5982,16 +5982,12 @@ st_collections_group_parts_part_physics_body(void)
|
||||||
static void
|
static void
|
||||||
st_collections_group_parts_part_insert_before(void)
|
st_collections_group_parts_part_insert_before(void)
|
||||||
{
|
{
|
||||||
/* Edje_Part_Collection *pc; */
|
|
||||||
Edje_Part_Parser *epp;
|
Edje_Part_Parser *epp;
|
||||||
char *name;
|
|
||||||
|
|
||||||
check_arg_count(1);
|
check_arg_count(1);
|
||||||
|
|
||||||
/* pc = eina_list_data_get(eina_list_last(edje_collections)); */
|
|
||||||
name = parse_str(0);
|
|
||||||
epp = (Edje_Part_Parser *)current_part;
|
epp = (Edje_Part_Parser *)current_part;
|
||||||
epp->reorder.insert_before = name;
|
epp->reorder.insert_before = parse_str(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6010,16 +6006,12 @@ st_collections_group_parts_part_insert_before(void)
|
||||||
static void
|
static void
|
||||||
st_collections_group_parts_part_insert_after(void)
|
st_collections_group_parts_part_insert_after(void)
|
||||||
{
|
{
|
||||||
/* Edje_Part_Collection *pc; */
|
|
||||||
Edje_Part_Parser *epp;
|
Edje_Part_Parser *epp;
|
||||||
char *name;
|
|
||||||
|
|
||||||
check_arg_count(1);
|
check_arg_count(1);
|
||||||
|
|
||||||
/* pc = eina_list_data_get(eina_list_last(edje_collections)); */
|
|
||||||
name = parse_str(0);
|
|
||||||
epp = (Edje_Part_Parser *)current_part;
|
epp = (Edje_Part_Parser *)current_part;
|
||||||
epp->reorder.insert_after = name;
|
epp->reorder.insert_after = parse_str(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2595,7 +2595,8 @@ reorder_parts(void)
|
||||||
{
|
{
|
||||||
ep = (Edje_Part_Parser *)pc->parts[i];
|
ep = (Edje_Part_Parser *)pc->parts[i];
|
||||||
if (ep->reorder.insert_before && ep->reorder.insert_after)
|
if (ep->reorder.insert_before && ep->reorder.insert_after)
|
||||||
ERR("Unable to use together insert_before and insert_after in part \"%s\".", pc->parts[i]->name);
|
error_and_abort(NULL, "In group \"%s\": Unable to use together insert_before and insert_after in part \"%s\".",
|
||||||
|
pc->part, pc->parts[i]->name);
|
||||||
|
|
||||||
if (ep->reorder.done)
|
if (ep->reorder.done)
|
||||||
{
|
{
|
||||||
|
@ -2609,15 +2610,13 @@ reorder_parts(void)
|
||||||
if (ep->reorder.insert_before &&
|
if (ep->reorder.insert_before &&
|
||||||
!strcmp(ep->reorder.insert_before, pc->parts[j]->name))
|
!strcmp(ep->reorder.insert_before, pc->parts[j]->name))
|
||||||
{
|
{
|
||||||
needed_part_exists(pc, ep->reorder.insert_before);
|
|
||||||
|
|
||||||
ep2 = (Edje_Part_Parser *)pc->parts[j];
|
ep2 = (Edje_Part_Parser *)pc->parts[j];
|
||||||
if (ep2->reorder.after)
|
if (ep2->reorder.after)
|
||||||
ERR("The part \"%s\" is ambiguous ordered part.",
|
error_and_abort(NULL, "In group \"%s\": The part \"%s\" is ambiguous ordered part.",
|
||||||
pc->parts[i]->name);
|
pc->part, pc->parts[i]->name);
|
||||||
if (ep2->reorder.linked_prev)
|
if (ep2->reorder.linked_prev)
|
||||||
ERR("Unable to insert two or more parts in same part \"%s\".",
|
error_and_abort(NULL, "In group \"%s\": Unable to insert two or more parts in same part \"%s\".",
|
||||||
pc->parts[j]->name);
|
pc->part, pc->parts[j]->name);
|
||||||
/* Need it to be able to insert an element before the first */
|
/* Need it to be able to insert an element before the first */
|
||||||
if (j == 0) k = 0;
|
if (j == 0) k = 0;
|
||||||
else k = j - 1;
|
else k = j - 1;
|
||||||
|
@ -2634,13 +2633,13 @@ reorder_parts(void)
|
||||||
else if (ep->reorder.insert_after &&
|
else if (ep->reorder.insert_after &&
|
||||||
!strcmp(ep->reorder.insert_after, pc->parts[j]->name))
|
!strcmp(ep->reorder.insert_after, pc->parts[j]->name))
|
||||||
{
|
{
|
||||||
needed_part_exists(pc, ep->reorder.insert_after);
|
|
||||||
|
|
||||||
ep2 = (Edje_Part_Parser *)pc->parts[j];
|
ep2 = (Edje_Part_Parser *)pc->parts[j];
|
||||||
if (ep2->reorder.before)
|
if (ep2->reorder.before)
|
||||||
ERR("The part \"%s\" is ambiguous ordered part.", pc->parts[i]->name);
|
error_and_abort(NULL, "In group \"%s\": The part \"%s\" is ambiguous ordered part.",
|
||||||
|
pc->part, pc->parts[i]->name);
|
||||||
if (ep2->reorder.linked_next)
|
if (ep2->reorder.linked_next)
|
||||||
ERR("Unable to insert two or more parts in same part \"%s\".", pc->parts[j]->name);
|
error_and_abort(NULL, "In group \"%s\": Unable to insert two or more parts in same part \"%s\".",
|
||||||
|
pc->part, pc->parts[j]->name);
|
||||||
k = j;
|
k = j;
|
||||||
found = EINA_TRUE;
|
found = EINA_TRUE;
|
||||||
ep2->reorder.linked_next += ep->reorder.linked_next + 1;
|
ep2->reorder.linked_next += ep->reorder.linked_next + 1;
|
||||||
|
@ -2659,7 +2658,7 @@ reorder_parts(void)
|
||||||
|
|
||||||
if (((i > k) && ((i - ep->reorder.linked_prev) <= k))
|
if (((i > k) && ((i - ep->reorder.linked_prev) <= k))
|
||||||
|| ((i < k) && ((i + ep->reorder.linked_next) >= k)))
|
|| ((i < k) && ((i + ep->reorder.linked_next) >= k)))
|
||||||
ERR("The part order is wrong. It has circular dependency.");
|
error_and_abort(NULL, "In group \"%s\": The part order is wrong. It has circular dependency.", pc->part);
|
||||||
|
|
||||||
amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1;
|
amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1;
|
||||||
linked = i - ep->reorder.linked_prev;
|
linked = i - ep->reorder.linked_prev;
|
||||||
|
@ -2699,6 +2698,15 @@ reorder_parts(void)
|
||||||
ep->reorder.done = EINA_TRUE;
|
ep->reorder.done = EINA_TRUE;
|
||||||
free(parts);
|
free(parts);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ep->reorder.insert_before)
|
||||||
|
error_and_abort(NULL, "In group \"%s\": Unable to find part \"%s\" for insert_before in part \"%s\".",
|
||||||
|
pc->part, ep->reorder.insert_before, pc->parts[i]->name);
|
||||||
|
else
|
||||||
|
error_and_abort(NULL, "In group \"%s\": Unable to find part \"%s\" for insert_after in part \"%s\".",
|
||||||
|
pc->part, ep->reorder.insert_after, pc->parts[i]->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4113,29 +4121,3 @@ using_file(const char *filename, const char type)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
|
||||||
needed_part_exists(Edje_Part_Collection *pc, const char *name)
|
|
||||||
{
|
|
||||||
Eina_Bool found;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
found = EINA_FALSE;
|
|
||||||
|
|
||||||
for (i = 0; i < pc->parts_count; i++)
|
|
||||||
{
|
|
||||||
if (!strcmp(pc->parts[i]->name, name))
|
|
||||||
{
|
|
||||||
found = EINA_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
ERR("Unable to find part name \"%s\" needed in group \"%s\".",
|
|
||||||
name, pc->part);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue