eolian: add optional warning for regular classes in ext list

As per T7240, we intend to disallow multi-class inheritance in Eo
at some point. In order to achieve that, it is necessary to find
out which classes still use multi-class inheritance and change
them accordingly.

Eo multi-class inheritance is not actually multi-class, as doing
so will simply treat all the other classes as interfaces, which
is misleading and poor design on its own.

By setting EOLIAN_CLASS_REGULAR_AS_EXT_WARN environment variable,
Eolian will now warn about such classes, allowing them to be
fixed.

Closes T7365.
This commit is contained in:
Daniel Kolesa 2018-11-30 14:12:15 +01:00 committed by Christopher Michael
parent b4f9f1b263
commit 03001ceaca
1 changed files with 20 additions and 1 deletions

View File

@ -12,6 +12,7 @@ typedef struct _Validate_State
{
Eina_Bool warned;
Eina_Bool event_redef;
Eina_Bool ext_regular;
} Validate_State;
static Eina_Bool
@ -848,6 +849,23 @@ _validate_class(Validate_State *vals, Eolian_Class *cl,
EINA_LIST_FOREACH(cl->extends, l, icl)
{
if (!valid && vals->ext_regular) switch (icl->type)
{
case EOLIAN_CLASS_REGULAR:
case EOLIAN_CLASS_ABSTRACT:
/* regular class in extensions list, forbidden */
{
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "regular classes ('%s') cannot appear in extensions list of '%s'",
icl->base.name, cl->base.name);
_obj_error(&cl->base, buf);
vals->warned = EINA_TRUE;
break;
}
default:
/* it's ok, interfaces are allowed */
break;
}
if (!_validate_class(vals, icl, nhash, ehash, chash))
return EINA_FALSE;
}
@ -928,7 +946,8 @@ database_validate(const Eolian_Unit *src)
Validate_State vals = {
EINA_FALSE,
!!getenv("EOLIAN_EVENT_REDEF_WARN")
!!getenv("EOLIAN_EVENT_REDEF_WARN"),
!!getenv("EOLIAN_CLASS_REGULAR_AS_EXT_WARN")
};
/* do an initial pass to refill inherits */