summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-04-11 14:31:03 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-04-11 14:31:03 +0200
commit710748c55103ba0415f46f5eb8d1ce503b3ea8ce (patch)
treed255e7812566e7054f17e92a6ea0dc1996dcdb18
parent97d777ee5d146a80d2c5d56b291ff42884c2a7b4 (diff)
eolian: better/more robust class inheritance list replacement
-rw-r--r--src/lib/eolian/database_validate.c31
-rw-r--r--src/lib/eolian/eolian_database.h1
2 files changed, 23 insertions, 9 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 787e8372af..4e309a52da 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -655,7 +655,6 @@ end:
655 return ret; 655 return ret;
656} 656}
657 657
658/* FIXME: need much better error handling here */
659static Eina_Bool 658static Eina_Bool
660_db_fill_inherits(Eolian_Class *cl, Eina_Hash *fhash) 659_db_fill_inherits(Eolian_Class *cl, Eina_Hash *fhash)
661{ 660{
@@ -685,13 +684,27 @@ _db_fill_inherits(Eolian_Class *cl, Eina_Hash *fhash)
685 else 684 else
686 { 685 {
687 cl->inherits = eina_list_append(cl->inherits, icl); 686 cl->inherits = eina_list_append(cl->inherits, icl);
688 /* recursively fill so the tree is valid */ 687 /* if the inherited class is already merged outside of staging,
689 if (!icl->valid_impls && !_db_fill_inherits(icl, fhash)) 688 * it's ok to skip it because it's already filled and validated
689 */
690 Eolian_Class *vcl = eina_hash_find(
691 cl->base.unit->state->main.unit.classes, inn);
692 /* fill if not found, but do not return right away because
693 * the rest of the list needs to be freed in order not to
694 * leak any memory
695 */
696 if (!vcl && !_db_fill_inherits(icl, fhash))
690 succ = EINA_FALSE; 697 succ = EINA_FALSE;
691 } 698 }
692 eina_stringshare_del(inn); 699 eina_stringshare_del(inn);
693 } 700 }
694 701
702 /* failed on the way, no point in filling further
703 * the failed stuff will get dropped so it's ok if it's inconsistent
704 */
705 if (!succ)
706 return EINA_FALSE;
707
695 eina_hash_add(fhash, cl->base.name, cl); 708 eina_hash_add(fhash, cl->base.name, cl);
696 709
697 /* make sure impls/ctors are filled first, but do it only once */ 710 /* make sure impls/ctors are filled first, but do it only once */
@@ -701,8 +714,7 @@ _db_fill_inherits(Eolian_Class *cl, Eina_Hash *fhash)
701 if (!_db_fill_ctors(cl)) 714 if (!_db_fill_ctors(cl))
702 return EINA_FALSE; 715 return EINA_FALSE;
703 716
704 cl->valid_impls = EINA_TRUE; 717 return EINA_TRUE;
705 return succ;
706} 718}
707 719
708static Eina_Bool 720static Eina_Bool
@@ -851,18 +863,21 @@ database_validate(const Eolian_Unit *src)
851 863
852 /* do an initial pass to refill inherits */ 864 /* do an initial pass to refill inherits */
853 Eina_Iterator *iter = eolian_unit_classes_get(src); 865 Eina_Iterator *iter = eolian_unit_classes_get(src);
866 Eina_Hash *fhash = eina_hash_stringshared_new(NULL);
854 EINA_ITERATOR_FOREACH(iter, cl) 867 EINA_ITERATOR_FOREACH(iter, cl)
855 { 868 {
856 if (cl->valid_impls) 869 /* can skip classes that have already been merged and validated */
870 Eolian_Class *vcl = eina_hash_find(
871 cl->base.unit->state->main.unit.classes, cl->base.name);
872 if (vcl)
857 continue; 873 continue;
858 Eina_Hash *fhash = eina_hash_stringshared_new(NULL);
859 if (!_db_fill_inherits(cl, fhash)) 874 if (!_db_fill_inherits(cl, fhash))
860 { 875 {
861 eina_hash_free(fhash); 876 eina_hash_free(fhash);
862 return EINA_FALSE; 877 return EINA_FALSE;
863 } 878 }
864 eina_hash_free(fhash);
865 } 879 }
880 eina_hash_free(fhash);
866 eina_iterator_free(iter); 881 eina_iterator_free(iter);
867 882
868 iter = eolian_unit_classes_get(src); 883 iter = eolian_unit_classes_get(src);
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 4df6b269d3..f4e310c9c1 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -188,7 +188,6 @@ struct _Eolian_Class
188 Eina_List *parts; /* Eolian_Part */ 188 Eina_List *parts; /* Eolian_Part */
189 Eina_Bool class_ctor_enable:1; 189 Eina_Bool class_ctor_enable:1;
190 Eina_Bool class_dtor_enable:1; 190 Eina_Bool class_dtor_enable:1;
191 Eina_Bool valid_impls:1;
192}; 191};
193 192
194struct _Eolian_Function 193struct _Eolian_Function