edje_cc: add 'skip_namespace_validation' keyword

this pairs with the newly-added -N option to denote groups in edc files
which should not be checked for correct namespacing

the option is useful for cases such as music_control.edc,
where a group has been shipping for years with API signals like
"btn,clicked" which cannot be changed since they are used in an external
application and compatibility must be maintained

the documentation for this option explicitly states that it must only be used
inside an #ifdef SKIP_NAMESPACE_VALIDATION block, allowing this keyword to
be easily removed at a later point

ref T7072

@feature

Differential Revision: https://phab.enlightenment.org/D6388
This commit is contained in:
Mike Blumenkrantz 2018-06-28 11:06:13 -04:00 committed by Marcel Hollerbach
parent 1b2408d5f7
commit 786210db6f
4 changed files with 52 additions and 16 deletions

View File

@ -167,6 +167,7 @@ struct _Edje_Part_Collection_Parser
Eina_Bool default_mouse_events;
Eina_Bool inherit_only;
Eina_Bool inherit_script : 1;
Eina_Bool skip_namespace_validation : 1;
};
typedef enum

View File

@ -257,6 +257,7 @@ static void st_collections_base_scale(void);
static void ob_collections_group(void);
static void st_collections_group_name(void);
static void st_collections_group_skip_namespace_validation(void);
static void st_collections_group_inherit_only(void);
static void st_collections_group_inherit(void);
static void st_collections_group_program_source(void);
@ -749,6 +750,7 @@ New_Statement_Handler statement_handlers[] =
}, /* dup */
{"collections.group.vibrations.sample.source", st_collections_group_vibration_sample_source}, /* dup */
{"collections.group.name", st_collections_group_name},
{"collections.group.skip_namespace_validation", st_collections_group_skip_namespace_validation},
{"collections.group.program_source", st_collections_group_program_source},
{"collections.group.inherit", st_collections_group_inherit},
{"collections.group.inherit_only", st_collections_group_inherit_only},
@ -4521,6 +4523,30 @@ st_collections_group_name(void)
_group_name(parse_str(0));
}
/**
@page edcref
@property
skip_namespace_validation
@parameters
[1 or 0]
@effect
This disables namespace validation for the current group if validation has
been enabled with edje_cc's -N option.
This property can be inherited.
Defaults: 0
@warning Your edc file should always wrap this keyword with #ifdef HAVE_SKIP_NAMESPACE_VALIDATION
@since 1.21
@endproperty
*/
static void
st_collections_group_skip_namespace_validation(void)
{
Edje_Part_Collection_Parser *pcp = eina_list_last_data_get(edje_collections);
check_arg_count(1);
pcp->skip_namespace_validation = parse_bool(0);
}
typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data;
struct _Edje_List_Foreach_Data
{
@ -5170,6 +5196,7 @@ st_collections_group_inherit(void)
pcp = (Edje_Part_Collection_Parser *)pc;
pcp2 = (Edje_Part_Collection_Parser *)pc2;
pcp->default_mouse_events = pcp2->default_mouse_events;
pcp->skip_namespace_validation = pcp2->skip_namespace_validation;
if (pcp2->inherit_script)
pcp->inherit_script = pcp2->inherit_script;

View File

@ -631,6 +631,7 @@ _part_namespace_verify(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef EIN
static void
check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
{
Edje_Part_Collection_Parser *pcp = (Edje_Part_Collection_Parser*)pc;
unsigned int i;
Eina_List *group_path = NULL;
/* FIXME: check image set and sort them. */
@ -662,19 +663,22 @@ check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
check_text_part_desc(pc, ep, (Edje_Part_Description_Text *)ep->other.desc[i], ef);
}
switch (ep->type)
if (!pcp->skip_namespace_validation)
{
case EDJE_PART_TYPE_BOX:
case EDJE_PART_TYPE_TABLE:
case EDJE_PART_TYPE_SWALLOW:
_part_namespace_verify(pc, ep, ef, 1);
break;
case EDJE_PART_TYPE_TEXT:
case EDJE_PART_TYPE_TEXTBLOCK:
case EDJE_PART_TYPE_SPACER:
_part_namespace_verify(pc, ep, ef, 0);
break;
default: break;
switch (ep->type)
{
case EDJE_PART_TYPE_BOX:
case EDJE_PART_TYPE_TABLE:
case EDJE_PART_TYPE_SWALLOW:
_part_namespace_verify(pc, ep, ef, 1);
break;
case EDJE_PART_TYPE_TEXT:
case EDJE_PART_TYPE_TEXTBLOCK:
case EDJE_PART_TYPE_SPACER:
_part_namespace_verify(pc, ep, ef, 0);
break;
default: break;
}
}
/* FIXME: When smart masks are supported, remove this check */
@ -716,6 +720,7 @@ _program_signal_namespace_verify(Edje_Part_Collection *pc, Eet_File *ef EINA_UNU
static void
check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef)
{
Edje_Part_Collection_Parser *pcp = (Edje_Part_Collection_Parser*)pc;
switch (ep->action)
{
case EDJE_ACTION_TYPE_STATE_SET:
@ -744,7 +749,8 @@ check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef)
if ((!ep->targets) && (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT))
{
_program_signal_namespace_verify(pc, ef, ep->state, ep->state2);
if (!pcp->skip_namespace_validation)
_program_signal_namespace_verify(pc, ef, ep->state, ep->state2);
}
EINA_LIST_FOREACH(ep->targets, l, et)

View File

@ -22,6 +22,8 @@
# define EPP_EXT
#endif
#define SKIP_NAMESPACE_VALIDATION_SUPPORTED " -DSKIP_NAMESPACE_VALIDATION=1 "
#define EDJE_1_18_SUPPORTED " -DEFL_VERSION_1_18=1 "
#define EDJE_1_19_SUPPORTED " -DEFL_VERSION_1_19=1 "
#define EDJE_1_20_SUPPORTED " -DEFL_VERSION_1_20=1 "
@ -1082,7 +1084,7 @@ compile(void)
inc = ecore_file_dir_get(file_in);
if (depfile)
snprintf(buf, sizeof(buf), "\"%s\" -MMD \"%s\" -MT \"%s\" \"%s\""
snprintf(buf, sizeof(buf), "\"%s\" "SKIP_NAMESPACE_VALIDATION_SUPPORTED" -MMD \"%s\" -MT \"%s\" \"%s\""
" -I\"%s\" %s -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
EDJE_CC_EFL_VERSION_SUPPORTED,
@ -1090,7 +1092,7 @@ compile(void)
inc ? inc : "./", def, clean_file,
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
else if (annotate)
snprintf(buf, sizeof(buf), "\"%s\" -annotate -a \"%s\" \"%s\""
snprintf(buf, sizeof(buf), "\"%s\" "SKIP_NAMESPACE_VALIDATION_SUPPORTED" -annotate -a \"%s\" \"%s\""
" -I\"%s\" %s -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
EDJE_CC_EFL_VERSION_SUPPORTED,
@ -1098,7 +1100,7 @@ compile(void)
inc ? inc : "./", def, clean_file,
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
else
snprintf(buf, sizeof(buf), "\"%s\" -a \"%s\" \"%s\" -I\"%s\" %s"
snprintf(buf, sizeof(buf), "\"%s\" "SKIP_NAMESPACE_VALIDATION_SUPPORTED" -a \"%s\" \"%s\" -I\"%s\" %s"
" -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
EDJE_CC_EFL_VERSION_SUPPORTED,