aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-30 17:03:37 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-30 17:08:44 +0100
commit5651b2e586e9a9836ebe4f50f9223e237099cf86 (patch)
treee6c8bafbdf6950410b32f8fcbc201dc608a12871
parenteolian: move impl/ctor fill to validation stage (diff)
downloadefl-5651b2e586e9a9836ebe4f50f9223e237099cf86.tar.gz
eolian: deferred parsing of inherits + better static checks
This change finally introduces deferred parsing of inherits to Eolian, after a long time and many iterations. That means instead of parsing inherits directly as part of the main file's parse pass, they're pushed into a queue and parsed later. The validation engine was modified to properly fill in the remaining info afterwards. This may introduce breakages but I haven't noticed any. It also properly unlocks cyclic dependency support in Eolian. Additionally, this also introduces checks for duplicates in class inherits (class Foo(Bar, Bar) is no longer possible) and it adds stricter name checks, so you can no longer have a class Foo.Bar and refer to it as Foo_Bar in implements. This was actually never meant to be supported, but the check was previously broken. @feature
-rw-r--r--src/lib/elementary/efl_ui_legacy.eo2
-rw-r--r--src/lib/elementary/efl_ui_list.eo2
-rw-r--r--src/lib/elementary/elm_genlist.eo2
-rw-r--r--src/lib/eolian/database_validate.c72
-rw-r--r--src/lib/eolian/eo_parser.c29
-rw-r--r--src/lib/evas/canvas/efl_input_key.eo2
6 files changed, 87 insertions, 22 deletions
diff --git a/src/lib/elementary/efl_ui_legacy.eo b/src/lib/elementary/efl_ui_legacy.eo
index e077691310..301bcdc837 100644
--- a/src/lib/elementary/efl_ui_legacy.eo
+++ b/src/lib/elementary/efl_ui_legacy.eo
@@ -1,4 +1,4 @@
-interface EFl.Ui.Legacy (Efl.Interface)
+interface Efl.Ui.Legacy (Efl.Interface)
{
[[The bg (background) widget is used for setting (solid) background decorations
diff --git a/src/lib/elementary/efl_ui_list.eo b/src/lib/elementary/efl_ui_list.eo
index 2ca88bdf74..64148ee5ff 100644
--- a/src/lib/elementary/efl_ui_list.eo
+++ b/src/lib/elementary/efl_ui_list.eo
@@ -99,7 +99,7 @@ class Efl.Ui.List (Efl.Ui.Layout, Efl.Ui.View, Efl.Ui.Scrollable.Interactive, Ef
Efl.Layout.Signal.signal_callback_add;
Efl.Layout.Signal.signal_callback_del;
// Elm.Interface.Atspi_Accessible.children { get; }
-// Elm.Interface.Atspi_Widget_Action.elm_actions { get; }
+// Elm.Interface.Atspi_Widget.Action.elm_actions { get; }
// Efl.Access.Widget.Action.elm_actions { get; }
Efl.Access.Selection.selected_children_count { get; }
Efl.Access.Selection.selected_child { get; }
diff --git a/src/lib/elementary/elm_genlist.eo b/src/lib/elementary/elm_genlist.eo
index 2d9a4e2536..45ee52bdd5 100644
--- a/src/lib/elementary/elm_genlist.eo
+++ b/src/lib/elementary/elm_genlist.eo
@@ -3,7 +3,7 @@ import elm_list;
import elm_genlist_item;
class Elm.Genlist (Efl.Ui.Layout, Efl.Ui.Focus.Composition, Elm.Interface_Scrollable, Efl.Ui.Clickable,
- Efl.Access.Widget_Action, Efl.Access.Selection,
+ Efl.Access.Widget.Action, Efl.Access.Selection,
Efl.Ui.Selectable, Efl.Ui.Legacy)
{
[[Elementary genlist class]]
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 2f316fc653..66cf97fb66 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -645,6 +645,54 @@ end:
}
static Eina_Bool
+_db_fill_inherits(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *fhash)
+{
+ if (eina_hash_find(fhash, cl->full_name))
+ return EINA_TRUE;
+
+ Eina_List *il = cl->inherits;
+ Eina_Stringshare *inn = NULL;
+ cl->inherits = NULL;
+ Eina_Bool succ = EINA_TRUE;
+
+ EINA_LIST_FREE(il, inn)
+ {
+ if (!succ)
+ {
+ eina_stringshare_del(inn);
+ continue;
+ }
+ Eolian_Class *icl = eina_hash_find(src->state->unit.classes, inn);
+ if (!icl)
+ {
+ succ = EINA_FALSE;
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf), "unknown inherit '%s' (incorrect case?)", inn);
+ _obj_error(&cl->base, buf);
+ }
+ else
+ {
+ cl->inherits = eina_list_append(cl->inherits, icl);
+ /* recursively fill so the tree is valid */
+ if (!icl->base.validated && !_db_fill_inherits(src, icl, fhash))
+ succ = EINA_FALSE;
+ }
+ eina_stringshare_del(inn);
+ }
+
+ eina_hash_add(fhash, cl->full_name, cl);
+
+ /* make sure impls/ctors are filled first, but do it only once */
+ if (!_db_fill_implements(cl))
+ return EINA_FALSE;
+
+ if (!_db_fill_ctors(cl))
+ return EINA_FALSE;
+
+ return succ;
+}
+
+static Eina_Bool
_validate_implement(const Eolian_Unit *src, Eolian_Implement *impl)
{
if (impl->base.validated)
@@ -661,7 +709,8 @@ _validate_implement(const Eolian_Unit *src, Eolian_Implement *impl)
}
static Eina_Bool
-_validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
+_validate_class(const Eolian_Unit *src, Eolian_Class *cl,
+ Eina_Hash *nhash, Eina_Bool ipass)
{
Eina_List *l;
Eolian_Function *func;
@@ -675,12 +724,17 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
Eina_Bool valid = cl->base.validated;
- /* make sure impls/ctors are filled first, but do it only once */
- if (!valid && !_db_fill_implements(cl))
- return EINA_FALSE;
-
- if (!valid && !_db_fill_ctors(cl))
- return EINA_FALSE;
+ /* refill inherits in the current inheritance tree first */
+ if (!valid && !ipass)
+ {
+ Eina_Hash *fhash = eina_hash_stringshared_new(NULL);
+ if (!_db_fill_inherits(src, cl, fhash))
+ {
+ eina_hash_free(fhash);
+ return EINA_FALSE;
+ }
+ eina_hash_free(fhash);
+ }
EINA_LIST_FOREACH(cl->inherits, l, icl)
{
@@ -710,7 +764,7 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
default:
break;
}
- if (!_validate_class(src, icl, nhash))
+ if (!_validate_class(src, icl, nhash, EINA_TRUE))
return EINA_FALSE;
}
@@ -786,7 +840,7 @@ database_validate(Eolian *state, const Eolian_Unit *src)
EINA_ITERATOR_FOREACH(iter, cl)
{
eina_hash_free_buckets(nhash);
- if (!_validate_class(src, cl, nhash))
+ if (!_validate_class(src, cl, nhash, EINA_FALSE))
{
eina_iterator_free(iter);
eina_hash_free(nhash);
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 309b2df39d..f7445bf9bf 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2038,24 +2038,35 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf)
return; /* unreachable (longjmp above), make static analysis shut up */
}
fname = eina_hash_find(ls->state->filenames_eo, fnm);
- free(fnm);
if (!fname)
{
char ebuf[PATH_MAX];
+ free(fnm);
eo_lexer_context_restore(ls);
snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'", iname);
eo_lexer_syntax_error(ls, ebuf);
+ return;
}
- Eolian_Class *dep = _parse_dep(ls, fname, iname);
- if (!dep)
+
+ Eina_Stringshare *inames = eina_stringshare_add(iname), *oiname = NULL;
+ Eina_List *l;
+ /* never allow duplicate inherits */
+ EINA_LIST_FOREACH(ls->tmp.kls->inherits, l, oiname)
{
- char ebuf[PATH_MAX];
- eo_lexer_context_restore(ls);
- snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'. Incorrect case?", iname);
- eo_lexer_syntax_error(ls, ebuf);
- return;
+ if (inames == oiname)
+ {
+ char ebuf[PATH_MAX];
+ free(fnm);
+ eina_stringshare_del(inames);
+ eo_lexer_context_restore(ls);
+ snprintf(ebuf, sizeof(ebuf), "duplicate inherit '%s'", iname);
+ eo_lexer_syntax_error(ls, ebuf);
+ return;
+ }
}
- ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, dep);
+ eina_hash_set(ls->state->defer, fnm, fname);
+ ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, inames);
+ free(fnm);
eo_lexer_context_pop(ls);
}
diff --git a/src/lib/evas/canvas/efl_input_key.eo b/src/lib/evas/canvas/efl_input_key.eo
index 45fe094d6f..501a188a3e 100644
--- a/src/lib/evas/canvas/efl_input_key.eo
+++ b/src/lib/evas/canvas/efl_input_key.eo
@@ -1,4 +1,4 @@
-class Efl.Input.Key (Efl.Object, Efl.Input.Event, Efl.Input.State, Efl.Input.Event)
+class Efl.Input.Key (Efl.Object, Efl.Input.Event, Efl.Input.State)
{
[[Represents a single key event from a keyboard or similar device.