eolian: add optional warnings about events missing a type

Set the EOLIAN_EVENT_NO_TYPE_WARN environment variable to enable
those warnings during Eolian usage. They will be considered a part
of the validation then.

Use the void type for events to suppress the warning.
This commit is contained in:
Daniel Kolesa 2018-05-09 15:44:36 +02:00
parent 6c252fc16c
commit 3685bcd61d
3 changed files with 18 additions and 3 deletions

View File

@ -9,6 +9,8 @@ EAPI const Eolian_Type *
eolian_event_type_get(const Eolian_Event *event)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(event, NULL);
if (event->type && (event->type->type == EOLIAN_TYPE_VOID))
return NULL;
return event->type;
}

View File

@ -12,6 +12,7 @@ typedef struct _Validate_State
{
Eina_Bool warned;
Eina_Bool event_redef;
Eina_Bool event_notype;
} Validate_State;
static Eina_Bool
@ -456,13 +457,14 @@ _validate_part(Eolian_Part *part, Eina_Hash *nhash)
static Eina_Bool
_validate_event(Validate_State *vals, Eolian_Event *event, Eina_Hash *nhash)
{
char buf[512];
const Eolian_Object *oobj = NULL;
if (vals->event_redef)
{
oobj = eina_hash_find(nhash, &event->base.name);
if (EINA_UNLIKELY(!!oobj))
{
char buf[512];
snprintf(buf, sizeof(buf),
"event '%s' conflicts with another symbol (at %s:%d:%d)",
event->base.name, oobj->file, oobj->line, oobj->column);
@ -478,6 +480,13 @@ _validate_event(Validate_State *vals, Eolian_Event *event, Eina_Hash *nhash)
return EINA_TRUE;
}
if (vals->event_notype && !event->type)
{
snprintf(buf, sizeof(buf), "event '%s' has no type", event->base.name);
_obj_error(&event->base, buf);
vals->warned = EINA_TRUE;
}
if (event->type && !_validate_type(vals, event->type))
return EINA_FALSE;
@ -904,7 +913,11 @@ database_validate(const Eolian_Unit *src)
{
Eolian_Class *cl;
Validate_State vals = { EINA_FALSE, !!getenv("EOLIAN_EVENT_REDEF_WARN") };
Validate_State vals = {
EINA_FALSE,
!!getenv("EOLIAN_EVENT_REDEF_WARN"),
!!getenv("EOLIAN_EVENT_NO_TYPE_WARN")
};
/* do an initial pass to refill inherits */
Eina_Iterator *iter = eolian_unit_classes_get(src);

View File

@ -1751,7 +1751,7 @@ end:
if (ls->t.token == ':')
{
eo_lexer_get(ls);
ev->type = eo_lexer_type_release(ls, parse_type(ls));
ev->type = eo_lexer_type_release(ls, parse_type_void(ls));
ev->type->owned = has_owned;
}
check(ls, ';');