edje: Make state index optional
authoracidx <acidx>
Fri, 6 Jul 2012 18:34:50 +0000 (18:34 +0000)
committeracidx <acidx@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 6 Jul 2012 18:34:50 +0000 (18:34 +0000)
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.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@73424 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/bin/edje_cc_handlers.c
src/lib/edje_embryo.c
src/lib/edje_private.h

index 0fc7f73..07c9f11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/NEWS b/NEWS
index fb4e059..2f32496 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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.
index 0e2df50..b5e9bcc 100644 (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)
      {
index 1ad2377..c390d5e 100644 (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)
      {
index 78f017f..3defba1 100644 (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; \