summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-24 23:19:22 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-24 23:21:24 +0200
commit05b395be47f49dfa9b3ded75ab1de95ef8ab07bf (patch)
tree0f691930fafa0b6cbb152eaa32326ca1c45390fa
parent903fd9065cce45820503ddb510fc56b3d2db26de (diff)
eolian: validate classes in a recursive manner
This allows for proper order of validation which will improve our performance when also validating for name duplicates.
-rw-r--r--src/lib/eolian/database_validate.c13
-rw-r--r--src/lib/eolian/eo_parser.c4
-rw-r--r--src/lib/eolian/eolian_database.h1
3 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 274c563dba..edd5d2c4c6 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -1,4 +1,5 @@
1#include <ctype.h> 1#include <ctype.h>
2#include <assert.h>
2 3
3#ifdef HAVE_CONFIG_H 4#ifdef HAVE_CONFIG_H
4# include "config.h" 5# include "config.h"
@@ -369,10 +370,20 @@ _validate_class(Eolian_Class *cl)
369 Eolian_Function *func; 370 Eolian_Function *func;
370 Eolian_Event *event; 371 Eolian_Event *event;
371 Eolian_Implement *impl; 372 Eolian_Implement *impl;
373 const char *iname;
374
375 if (!cl)
376 return EINA_FALSE; /* if this happens something is very wrong though */
372 377
373 if (cl->base.validated) 378 if (cl->base.validated)
374 return EINA_TRUE; 379 return EINA_TRUE;
375 380
381 EINA_LIST_FOREACH(cl->inherits, l, iname)
382 {
383 if (!_validate_class(eina_hash_find(_classes, iname)))
384 return EINA_FALSE;
385 }
386
376 EINA_LIST_FOREACH(cl->properties, l, func) 387 EINA_LIST_FOREACH(cl->properties, l, func)
377 if (!_validate_function(func)) 388 if (!_validate_function(func))
378 return EINA_FALSE; 389 return EINA_FALSE;
@@ -435,7 +446,7 @@ database_validate()
435 /* FIXME: pass unit properly */ 446 /* FIXME: pass unit properly */
436 Eina_Iterator *iter = eolian_all_classes_get(NULL); 447 Eina_Iterator *iter = eolian_all_classes_get(NULL);
437 EINA_ITERATOR_FOREACH(iter, cl) 448 EINA_ITERATOR_FOREACH(iter, cl)
438 if (!_validate_class(cl)) 449 if (cl->toplevel && !_validate_class(cl))
439 { 450 {
440 eina_iterator_free(iter); 451 eina_iterator_free(iter);
441 return EINA_FALSE; 452 return EINA_FALSE;
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index ef19fc3486..a7649e0a0b 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1985,7 +1985,7 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
1985 } 1985 }
1986 _parse_dep(ls, fname, iname); 1986 _parse_dep(ls, fname, iname);
1987 /* FIXME: pass unit properly */ 1987 /* FIXME: pass unit properly */
1988 const Eolian_Class *dep = eolian_class_get_by_name(NULL, iname); 1988 Eolian_Class *dep = (Eolian_Class *)eolian_class_get_by_name(NULL, iname);
1989 if (!dep) 1989 if (!dep)
1990 { 1990 {
1991 char ebuf[PATH_MAX]; 1991 char ebuf[PATH_MAX];
@@ -2023,6 +2023,7 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
2023 } 2023 }
2024 ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, 2024 ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits,
2025 eina_stringshare_add(iname)); 2025 eina_stringshare_add(iname));
2026 dep->toplevel = EINA_FALSE;
2026 eo_lexer_context_pop(ls); 2027 eo_lexer_context_pop(ls);
2027} 2028}
2028 2029
@@ -2036,6 +2037,7 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
2036 int line, col; 2037 int line, col;
2037 Eina_Strbuf *buf = push_strbuf(ls); 2038 Eina_Strbuf *buf = push_strbuf(ls);
2038 ls->tmp.kls = calloc(1, sizeof(Eolian_Class)); 2039 ls->tmp.kls = calloc(1, sizeof(Eolian_Class));
2040 ls->tmp.kls->toplevel = EINA_TRUE;
2039 FILL_BASE(ls->tmp.kls->base, ls, ls->line_number, ls->column); 2041 FILL_BASE(ls->tmp.kls->base, ls, ls->line_number, ls->column);
2040 eo_lexer_get(ls); 2042 eo_lexer_get(ls);
2041 ls->tmp.kls->type = type; 2043 ls->tmp.kls->type = type;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 301caf4294..5389267a7e 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -99,6 +99,7 @@ struct _Eolian_Class
99 Eina_List *events; /* List event_name -> Eolian_Event */ 99 Eina_List *events; /* List event_name -> Eolian_Event */
100 Eina_Bool class_ctor_enable:1; 100 Eina_Bool class_ctor_enable:1;
101 Eina_Bool class_dtor_enable:1; 101 Eina_Bool class_dtor_enable:1;
102 Eina_Bool toplevel:1;
102}; 103};
103 104
104struct _Eolian_Function 105struct _Eolian_Function