summaryrefslogtreecommitdiff
path: root/src/lib/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-09-19 16:49:31 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-09-19 18:20:56 +0200
commit46a6949b2e29bddacd523d96564492957faecc34 (patch)
treee166ded7050c55fb3a117f6a21171b38b70b7b99 /src/lib/eolian
parentf8926697ff430e025d782fbdbb588db8ee154852 (diff)
eolian: auto-add composited interfaces into implements if needed
The condition here is that the composited interface does not already appear in the inheritance tree of the given class. If it does, don't add. If it doesn't, add it to the class that specifies the composited block.
Diffstat (limited to 'src/lib/eolian')
-rw-r--r--src/lib/eolian/database_validate.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index cdbd699293..f13e0e82b7 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -865,6 +865,22 @@ _extend_impl(Eina_Hash *fs, Eolian_Implement *impl, Eina_Bool as_iface)
865 return !st; 865 return !st;
866} 866}
867 867
868/* fills a complete set of stuff implemented or inherited on a class
869 * this is used to check whether to auto-add composited interfaces into
870 * implemented/extended list
871 */
872static void
873_db_fill_ihash(Eolian_Class *icl, Eina_Hash *icls)
874{
875 if (icl->parent)
876 _db_fill_ihash(icl->parent, icls);
877 Eina_List *l;
878 Eolian_Class *sicl;
879 EINA_LIST_FOREACH(icl->extends, l, sicl)
880 _db_fill_ihash(sicl, icls);
881 eina_hash_set(icls, &icl, icl);
882}
883
868static void 884static void
869_db_fill_callables(Eolian_Class *cl, Eolian_Class *icl, Eina_Hash *fs, Eina_Bool parent) 885_db_fill_callables(Eolian_Class *cl, Eolian_Class *icl, Eina_Hash *fs, Eina_Bool parent)
870{ 886{
@@ -1084,13 +1100,6 @@ _db_swap_inherit(Eolian_Class *cl, Eina_Bool succ, Eina_Stringshare *in_cl,
1084 succ = EINA_FALSE; 1100 succ = EINA_FALSE;
1085 _eo_parser_log(&cl->base, "non-interface class '%s' in composite list", icl->base.name); 1101 _eo_parser_log(&cl->base, "non-interface class '%s' in composite list", icl->base.name);
1086 } 1102 }
1087 else if (iface_only && !_get_impl_class(cl, icl->base.name))
1088 {
1089 /* TODO: optimize check using a lookup hash later */
1090 succ = EINA_FALSE;
1091 _eo_parser_log(&cl->base, "interface '%s' not found within the inheritance tree of '%s'",
1092 icl->base.name, cl->base.name);
1093 }
1094 else 1103 else
1095 *out_cl = icl; 1104 *out_cl = icl;
1096 eina_stringshare_del(in_cl); 1105 eina_stringshare_del(in_cl);
@@ -1183,6 +1192,7 @@ _db_fill_inherits(Validate_State *vals, Eolian_Class *cl, Eina_Hash *fhash,
1183 /* replace the composite list with real instances and initial-fill the hash */ 1192 /* replace the composite list with real instances and initial-fill the hash */
1184 il = cl->composite; 1193 il = cl->composite;
1185 cl->composite = NULL; 1194 cl->composite = NULL;
1195 int ncomp = 0;
1186 EINA_LIST_FREE(il, inn) 1196 EINA_LIST_FREE(il, inn)
1187 { 1197 {
1188 Eolian_Class *out_cl = NULL; 1198 Eolian_Class *out_cl = NULL;
@@ -1190,6 +1200,8 @@ _db_fill_inherits(Validate_State *vals, Eolian_Class *cl, Eina_Hash *fhash,
1190 if (!succ) 1200 if (!succ)
1191 continue; 1201 continue;
1192 cl->composite = eina_list_append(cl->composite, out_cl); 1202 cl->composite = eina_list_append(cl->composite, out_cl);
1203 succ = _db_fill_inherits(vals, out_cl, fhash, errh);
1204 ++ncomp;
1193 eina_hash_set(ch, &out_cl, out_cl); 1205 eina_hash_set(ch, &out_cl, out_cl);
1194 } 1206 }
1195 1207
@@ -1216,6 +1228,37 @@ _db_fill_inherits(Validate_State *vals, Eolian_Class *cl, Eina_Hash *fhash,
1216 1228
1217 eina_hash_add(fhash, &cl->base.name, cl); 1229 eina_hash_add(fhash, &cl->base.name, cl);
1218 1230
1231 /* there are more than zero of composites of its own */
1232 if (ncomp > 0)
1233 {
1234 /* this one stores what is already in inheritance tree */
1235 Eina_Hash *ih = eina_hash_pointer_new(NULL);
1236
1237 /* fill a complete inheritance tree set */
1238 if (cl->parent)
1239 _db_fill_ihash(cl->parent, ih);
1240
1241 EINA_LIST_FOREACH(cl->extends, il, icl)
1242 _db_fill_ihash(icl, ih);
1243
1244 /* go through only the explicitly specified composite list part, as the
1245 * rest was to be handled in parents already... add what hasn't been
1246 * explicitly implemented so far into implements/extends
1247 */
1248 EINA_LIST_FOREACH(cl->composite, il, icl)
1249 {
1250 /* ran out of classes */
1251 if (!ncomp--)
1252 break;
1253 /* found in inheritance tree, skip */
1254 if (eina_hash_find(ih, &icl))
1255 continue;
1256 cl->extends = eina_list_append(cl->extends, icl);
1257 }
1258
1259 eina_hash_free(ih);
1260 }
1261
1219 /* stores mappings from function to Impl_Status */ 1262 /* stores mappings from function to Impl_Status */
1220 Eina_Hash *fh = eina_hash_pointer_new(NULL); 1263 Eina_Hash *fh = eina_hash_pointer_new(NULL);
1221 1264