summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-22 15:26:36 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-22 15:36:31 +0100
commit7da6675c34b972a4700679f117c57a6aa520787d (patch)
tree53ed9dafcb6f5228a3c5e93edbe43e8ee1185a05
parent30c57531723be39778efcf5ceb151cceb79c4e2d (diff)
eolian: perform partial class validation every time
This makes sure that duplicate method/part/etc checks are done on every database update, removing the need for clunky toplevel checks and improving reliability. It also sacrifices some performance but it shouldn't be too bad (if a class is already validated, some checks are avoided to speed things up).
-rw-r--r--src/lib/eolian/database_validate.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index cf5f741f0b..9fd9e59379 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -337,6 +337,12 @@ _validate_function(const Eolian_Unit *src, Eolian_Function *func, Eina_Hash *nha
337 _obj_error(&func->base, buf); 337 _obj_error(&func->base, buf);
338 } 338 }
339 339
340 /* if already validated, no need to perform the other checks...
341 * but duplicate checks need to be performed every time
342 */
343 if (func->base.validated)
344 return EINA_TRUE;
345
340 if (func->get_ret_type && !_validate_type(src, func->get_ret_type)) 346 if (func->get_ret_type && !_validate_type(src, func->get_ret_type))
341 return EINA_FALSE; 347 return EINA_FALSE;
342 348
@@ -380,9 +386,6 @@ _validate_function(const Eolian_Unit *src, Eolian_Function *func, Eina_Hash *nha
380static Eina_Bool 386static Eina_Bool
381_validate_part(const Eolian_Unit *src, Eolian_Part *part, Eina_Hash *nhash) 387_validate_part(const Eolian_Unit *src, Eolian_Part *part, Eina_Hash *nhash)
382{ 388{
383 if (!_validate_doc(src, part->doc))
384 return EINA_FALSE;
385
386 const Eolian_Function *ofunc = eina_hash_find(nhash, part->name); 389 const Eolian_Function *ofunc = eina_hash_find(nhash, part->name);
387 if (ofunc) 390 if (ofunc)
388 { 391 {
@@ -394,12 +397,22 @@ _validate_part(const Eolian_Unit *src, Eolian_Part *part, Eina_Hash *nhash)
394 _obj_error(&part->base, buf); 397 _obj_error(&part->base, buf);
395 } 398 }
396 399
400 /* see _validate_function above */
401 if (part->base.validated)
402 return EINA_TRUE;
403
404 if (!_validate_doc(src, part->doc))
405 return EINA_FALSE;
406
397 return _validate(&part->base); 407 return _validate(&part->base);
398} 408}
399 409
400static Eina_Bool 410static Eina_Bool
401_validate_event(const Eolian_Unit *src, Eolian_Event *event) 411_validate_event(const Eolian_Unit *src, Eolian_Event *event)
402{ 412{
413 if (event->base.validated)
414 return EINA_TRUE;
415
403 if (event->type && !_validate_type(src, event->type)) 416 if (event->type && !_validate_type(src, event->type))
404 return EINA_FALSE; 417 return EINA_FALSE;
405 418
@@ -412,6 +425,9 @@ _validate_event(const Eolian_Unit *src, Eolian_Event *event)
412static Eina_Bool 425static Eina_Bool
413_validate_implement(const Eolian_Unit *src, Eolian_Implement *impl) 426_validate_implement(const Eolian_Unit *src, Eolian_Implement *impl)
414{ 427{
428 if (impl->base.validated)
429 return EINA_TRUE;
430
415 if (!_validate_doc(src, impl->common_doc)) 431 if (!_validate_doc(src, impl->common_doc))
416 return EINA_FALSE; 432 return EINA_FALSE;
417 if (!_validate_doc(src, impl->get_doc)) 433 if (!_validate_doc(src, impl->get_doc))
@@ -436,8 +452,7 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
436 if (!cl) 452 if (!cl)
437 return EINA_FALSE; /* if this happens something is very wrong though */ 453 return EINA_FALSE; /* if this happens something is very wrong though */
438 454
439 if (cl->base.validated) 455 Eina_Bool valid = cl->base.validated;
440 return EINA_TRUE;
441 456
442 Eina_Bool ahash = (nhash == NULL); 457 Eina_Bool ahash = (nhash == NULL);
443 if (ahash) 458 if (ahash)
@@ -446,7 +461,7 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
446 EINA_LIST_FOREACH(cl->inherits, l, icl) 461 EINA_LIST_FOREACH(cl->inherits, l, icl)
447 { 462 {
448 /* first inherit needs some checking done on it */ 463 /* first inherit needs some checking done on it */
449 if (l == cl->inherits) switch (cl->type) 464 if (!valid && (l == cl->inherits)) switch (cl->type)
450 { 465 {
451 case EOLIAN_CLASS_REGULAR: 466 case EOLIAN_CLASS_REGULAR:
452 case EOLIAN_CLASS_ABSTRACT: 467 case EOLIAN_CLASS_ABSTRACT:
@@ -495,6 +510,10 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
495 if (!(res = _validate_implement(src, impl))) 510 if (!(res = _validate_implement(src, impl)))
496 goto freehash; 511 goto freehash;
497 512
513 /* all the checks that need to be done every time are performed now */
514 if (valid)
515 goto freehash;
516
498 if (!(res = _validate_doc(src, cl->doc))) 517 if (!(res = _validate_doc(src, cl->doc)))
499 goto freehash; 518 goto freehash;
500 519
@@ -545,7 +564,7 @@ database_validate(Eolian *state, const Eolian_Unit *src)
545 564
546 Eina_Iterator *iter = eolian_all_classes_get(src); 565 Eina_Iterator *iter = eolian_all_classes_get(src);
547 EINA_ITERATOR_FOREACH(iter, cl) 566 EINA_ITERATOR_FOREACH(iter, cl)
548 if (cl->toplevel && !_validate_class(src, cl, NULL)) 567 if (!_validate_class(src, cl, NULL))
549 { 568 {
550 eina_iterator_free(iter); 569 eina_iterator_free(iter);
551 return EINA_FALSE; 570 return EINA_FALSE;