edje now has the group.script_recursion flag for permitting unsafe embryo recursion

this is enabled for all scripts within a group, and it should only be used if you:

1) know what you are doing

2) know why this is unsafe (T905)

@feature
This commit is contained in:
Mike Blumenkrantz 2014-04-21 10:29:53 -04:00
parent c5b1598e6e
commit 939f2eea7f
4 changed files with 32 additions and 1 deletions

View File

@ -209,6 +209,7 @@ static void st_collections_group_program_source(void);
static void st_collections_group_part_remove(void);
static void st_collections_group_program_remove(void);
static void st_collections_group_script_only(void);
static void st_collections_group_script_recursion(void);
static void st_collections_group_alias(void);
static void st_collections_group_min(void);
static void st_collections_group_max(void);
@ -532,6 +533,7 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.part_remove", st_collections_group_part_remove},
{"collections.group.program_remove", st_collections_group_program_remove},
{"collections.group.script_only", st_collections_group_script_only},
{"collections.group.script_recursion", st_collections_group_script_recursion},
{"collections.group.lua_script_only", st_collections_group_script_only},
{"collections.group.alias", st_collections_group_alias},
{"collections.group.min", st_collections_group_min},
@ -3474,6 +3476,32 @@ st_collections_group_script_only(void)
pc->lua_script_only = parse_bool(0);
}
/**
@page edcref
@property
script_recursion
@parameters
[1/0]
@effect
This flag (1/0) determines whether to error on unsafe calls when
recursively running Embryo programs.
For example, running an Embryo script which calls EDC which has a
script{} block is unsafe, and the outer-most (first) Embryo stack is GUARANTEED
to be corrupted. Only use this flag if you are sure that you know what you are doing.
@since 1.10
@endproperty
*/
static void
st_collections_group_script_recursion(void)
{
Edje_Part_Collection *pc;
check_arg_count(1);
pc = eina_list_data_get(eina_list_last(edje_collections));
pc->script_recursion = parse_bool(0);
}
/**
@page edcref
@property

View File

@ -1077,6 +1077,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.depth", physics.world.depth, EET_T_INT);
#endif
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_recursion", script_recursion, EET_T_UCHAR);
}
EAPI void

View File

@ -3871,7 +3871,7 @@ _edje_embryo_test_run(Edje *ed, const char *fname, const char *sig, const char *
/* will likely end up being much longer than 0.016 seconds - more */
/* like 0.03 - 0.05 seconds or even more */
embryo_program_max_cycle_run_set(ed->collection->script, 5000000);
if (embryo_program_recursion_get(ed->collection->script))
if (embryo_program_recursion_get(ed->collection->script) && (!ed->collection->script_recursion))
ERR("You are running Embryo->EDC->Embryo with script program '%s';\nBy the power of Grayskull, your previous Embryo stack is now broken!", fname);
ret = embryo_program_run(ed->collection->script, fn);
if (ret == EMBRYO_PROGRAM_FAIL)

View File

@ -967,6 +967,8 @@ struct _Edje_Part_Collection
unsigned char physics_enabled; /* will be 1 if a body is declared */
unsigned char script_recursion; /* permits unsafe Embryo->EDC->Embryo scripting */
unsigned char checked : 1;
};