edje: Make state index optional

This shouldn't break stuff, just make things easier.  Think of all that lost
time " 0.0".  Not anymore.  Not even in Embryo scripts.  Indexes should only
be provided when you need them (which is quite rare).

Note that if you use ``set_state("new state")'' in your Embryo scripts, the
produced .edj files will be incompatible with older versions of Edje.  This
backwards incompatibility only applies to Embryo scripts; edje_cc will
generate a ``0.0'' value if the index is omitted from state declarations and
programs.

Sachiel said this patch was OK; our benevolent release manager acked as
well. Blame them if this breaks stuff.

SVN revision: 73424
This commit is contained in:
Leandro Pereira 2012-07-06 18:34:50 +00:00
parent 99621b948a
commit 7ee848bc33
5 changed files with 28 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2012-06-06 Leandro Pereira
* Made state index optional (defaulting to 0.0).
2011-01-29 Carsten Haitzler (The Rasterman)
1.0.0 release

View File

@ -15,6 +15,7 @@ Additions:
Improvements:
* Allocate once and reuse Evas_Map.
* Make edje_cc faster by improving the parser, mapping file in memory and using threads.
* Made state index optional in EDC files and Embryo scripts.
Fixes:
* Add missing files in the tarballs.

View File

@ -4348,7 +4348,7 @@ st_collections_group_parts_part_description_inherit(void)
parent = parent_desc;
if (!parent)
{
check_arg_count(2);
check_min_arg_count(1);
/* inherit may not be used in the default description */
if (!ep->other.desc_count)
@ -4361,7 +4361,10 @@ st_collections_group_parts_part_description_inherit(void)
/* find the description that we inherit from */
parent_name = parse_str(0);
parent_val = parse_float_range(1, 0.0, 1.0);
if (get_arg_count() == 2)
parent_val = parse_float_range(1, 0.0, 1.0);
else
parent_val = 0.0;
if (!strcmp (parent_name, "default") && parent_val == 0.0)
parent = ep->default_desc;
@ -4594,7 +4597,7 @@ st_collections_group_parts_part_description_state(void)
Edje_Part_Description_Common *ed;
char *s;
check_arg_count(2);
check_min_arg_count(1);
ep = current_part;
@ -4611,7 +4614,10 @@ st_collections_group_parts_part_description_state(void)
}
ed->state.name = s;
ed->state.value = parse_float_range(1, 0.0, 1.0);
if (get_arg_count() == 1)
ed->state.value = 0.0;
else
ed->state.value = parse_float_range(1, 0.0, 1.0);
if (ed != ep->default_desc)
{
@ -7597,7 +7603,10 @@ st_collections_group_programs_program_action(void)
if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
{
ep->state = parse_str(1);
ep->value = parse_float_range(2, 0.0, 1.0);
if (get_arg_count() == 1)
ep->value = 0.0;
else
ep->value = parse_float_range(2, 0.0, 1.0);
}
else if (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT)
{

View File

@ -871,14 +871,19 @@ _edje_embryo_fn_set_state(Embryo_Program *ep, Embryo_Cell *params)
double value = 0.0;
Edje_Real_Part *rp;
CHKPARAM(3);
if (!HASNPARAMS(2) || !HASNPARAMS(3)) return -1;
ed = embryo_program_data_get(ep);
GETSTR(state, params[2]);
if ((!state)) return 0;
part_id = params[1];
if (part_id < 0) return 0;
f = EMBRYO_CELL_TO_FLOAT(params[3]);
value = (double)f;
if (HASNPARAMS(3))
{
f = EMBRYO_CELL_TO_FLOAT(params[3]);
value = (double)f;
}
else
value = 0.0;
rp = ed->table_parts[part_id % ed->table_parts_size];
if (rp)
{

View File

@ -1893,6 +1893,7 @@ void _edje_cache_file_unref(Edje_File *edf);
void _edje_embryo_globals_init(Edje *ed);
#define CHKPARAM(n) if (params[0] != (sizeof(Embryo_Cell) * (n))) return -1;
#define HASNPARAMS(n) (params[0] == (sizeof(Embryo_Cell) * (n)))
#define GETSTR(str, par) { \
Embryo_Cell *___cptr; \
int ___l; \