summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-01-29 15:46:05 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2019-02-28 00:52:14 +0100
commita9360222b053f38c8fd0f2ee21fc2f3ea94430d7 (patch)
treeb41d6444a59455449c59e29ae3bc994ccf816576
parent0e027980f6c275f1a56ae550679010d689c91b23 (diff)
eolian: add support for inlist structs
This adds support for inlist structs, a special type of struct that can only be used with inlists. This differs from regular structs in a couple ways: 1) They are stored separately. Just like structs, enums, aliases have their own storage, so do inlist structs. 2) They can't be @extern, nor they can be opaque. 3) They are their own type of typedecl. 4) When they contain only one field, this field must be a value type always, cannot be a pointer. Like regular structs, they can have arbitrary fields, and they can have a pre-set free function via @free(). In C, the inlist structs will be generated exactly like ordinary ones, except they will have EINA_INLIST before the first field. Other binding generators can deal with them as they wish, for example to provide high level interfaces to them. This does not yet do the plumbing necessary to hook these into the type system, nor it adds generator support. @feature
-rw-r--r--src/lib/eolian/Eolian.h62
-rw-r--r--src/lib/eolian/database_check.c1
-rw-r--r--src/lib/eolian/database_type.c20
-rw-r--r--src/lib/eolian/database_type_api.c4
-rw-r--r--src/lib/eolian/database_validate.c23
-rw-r--r--src/lib/eolian/eo_parser.c20
-rw-r--r--src/lib/eolian/eolian_database.c36
-rw-r--r--src/lib/eolian/eolian_database.h4
8 files changed, 155 insertions, 15 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index a61f1086b9..321a1ff5af 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -264,7 +264,8 @@ typedef enum
264 EOLIAN_TYPEDECL_STRUCT_OPAQUE, 264 EOLIAN_TYPEDECL_STRUCT_OPAQUE,
265 EOLIAN_TYPEDECL_ENUM, 265 EOLIAN_TYPEDECL_ENUM,
266 EOLIAN_TYPEDECL_ALIAS, 266 EOLIAN_TYPEDECL_ALIAS,
267 EOLIAN_TYPEDECL_FUNCTION_POINTER 267 EOLIAN_TYPEDECL_FUNCTION_POINTER,
268 EOLIAN_TYPEDECL_STRUCT_INLIST
268} Eolian_Typedecl_Type; 269} Eolian_Typedecl_Type;
269 270
270typedef enum 271typedef enum
@@ -1051,6 +1052,16 @@ EAPI const Eolian_Typedecl *eolian_unit_struct_by_name_get(const Eolian_Unit *un
1051EAPI const Eolian_Typedecl *eolian_unit_enum_by_name_get(const Eolian_Unit *unit, const char *name); 1052EAPI const Eolian_Typedecl *eolian_unit_enum_by_name_get(const Eolian_Unit *unit, const char *name);
1052 1053
1053/* 1054/*
1055 * @brief Get an inlist struct declaration within a unit by name.
1056 *
1057 * @param[in] unit The unit.
1058 * @param[in] name The name of the alias.
1059 *
1060 * @ingroup Eolian
1061 */
1062EAPI const Eolian_Typedecl *eolian_unit_inlist_struct_by_name_get(const Eolian_Unit *unit, const char *name);
1063
1064/*
1054 * @brief Get an iterator to all aliases in the Eolian database. 1065 * @brief Get an iterator to all aliases in the Eolian database.
1055 * 1066 *
1056 * @param[in] unit The unit. 1067 * @param[in] unit The unit.
@@ -1084,6 +1095,17 @@ EAPI Eina_Iterator *eolian_unit_structs_get(const Eolian_Unit *unit);
1084EAPI Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit); 1095EAPI Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit);
1085 1096
1086/* 1097/*
1098 * @brief Get an iterator to all inlist structs in the Eolian database.
1099 *
1100 * @param[in] unit The unit.
1101 *
1102 * Thanks to internal caching, this is an O(1) operation.
1103 *
1104 * @ingroup Eolian
1105 */
1106EAPI Eina_Iterator *eolian_unit_inlist_structs_get(const Eolian_Unit *unit);
1107
1108/*
1087 * @brief A helper function to get an object in a state by name. 1109 * @brief A helper function to get an object in a state by name.
1088 * 1110 *
1089 * @see eolian_unit_object_by_name_get 1111 * @see eolian_unit_object_by_name_get
@@ -1276,6 +1298,19 @@ eolian_state_enum_by_name_get(const Eolian_State *state, const char *name)
1276} 1298}
1277 1299
1278/* 1300/*
1301 * @brief A helper function to get an inlist struct in a state by name.
1302 *
1303 * @see eolian_unit_inlist_struct_by_name_get
1304 *
1305 * @ingroup Eolian
1306 */
1307static inline const Eolian_Typedecl *
1308eolian_state_inlist_struct_by_name_get(const Eolian_State *state, const char *name)
1309{
1310 return eolian_unit_inlist_struct_by_name_get(EOLIAN_UNIT(state), name);
1311}
1312
1313/*
1279 * @brief Get an iterator to all aliases contained in a file. 1314 * @brief Get an iterator to all aliases contained in a file.
1280 * 1315 *
1281 * @param[in] state The state. 1316 * @param[in] state The state.
@@ -1312,6 +1347,18 @@ EAPI Eina_Iterator *eolian_state_structs_by_file_get(const Eolian_State *state,
1312EAPI Eina_Iterator *eolian_state_enums_by_file_get(const Eolian_State *state, const char *file_name); 1347EAPI Eina_Iterator *eolian_state_enums_by_file_get(const Eolian_State *state, const char *file_name);
1313 1348
1314/* 1349/*
1350 * @brief Get an iterator to all inlist structs contained in a file.
1351 *
1352 * @param[in] state The state.
1353 * @param[in] file_name The file name.
1354 *
1355 * Thanks to internal caching, this is an O(1) operation.
1356 *
1357 * @ingroup Eolian
1358 */
1359EAPI Eina_Iterator *eolian_state_inlist_structs_by_file_get(const Eolian_State *state, const char *file_name);
1360
1361/*
1315 * @brief A helper function to get all aliases in a state. 1362 * @brief A helper function to get all aliases in a state.
1316 * 1363 *
1317 * @see eolian_unit_aliases_get 1364 * @see eolian_unit_aliases_get
@@ -1351,6 +1398,19 @@ eolian_state_enums_get(const Eolian_State *state)
1351} 1398}
1352 1399
1353/* 1400/*
1401 * @brief A helper function to get all inlist structs in a state.
1402 *
1403 * @see eolian_unit_inlist_structs_get
1404 *
1405 * @ingroup Eolian
1406 */
1407static inline Eina_Iterator *
1408eolian_state_inlist_structs_get(const Eolian_State *state)
1409{
1410 return eolian_unit_inlist_structs_get(EOLIAN_UNIT(state));
1411}
1412
1413/*
1354 * @brief A helper function to get the full name of a class. 1414 * @brief A helper function to get the full name of a class.
1355 * 1415 *
1356 * @see eolian_object_name_get 1416 * @see eolian_object_name_get
diff --git a/src/lib/eolian/database_check.c b/src/lib/eolian/database_check.c
index 61afa6e281..cc5a697d31 100644
--- a/src/lib/eolian/database_check.c
+++ b/src/lib/eolian/database_check.c
@@ -172,6 +172,7 @@ _check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, Eina_Hash *chash)
172 switch (tp->type) 172 switch (tp->type)
173 { 173 {
174 case EOLIAN_TYPEDECL_STRUCT: 174 case EOLIAN_TYPEDECL_STRUCT:
175 case EOLIAN_TYPEDECL_STRUCT_INLIST:
175 _check_type(((const Eolian_Struct_Type_Field *)data)->type, 176 _check_type(((const Eolian_Struct_Type_Field *)data)->type,
176 depset, chash); 177 depset, chash);
177 break; 178 break;
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 31517d6487..d629a44395 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -43,11 +43,20 @@ database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp)
43} 43}
44 44
45void 45void
46database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp) 46database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp, Eina_Bool is_inlist)
47{ 47{
48 EOLIAN_OBJECT_ADD(unit, tp->base.name, tp, structs); 48 if (is_inlist)
49 eina_hash_set(unit->state->staging.structs_f, tp->base.file, eina_list_append 49 {
50 ((Eina_List*)eina_hash_find(unit->state->staging.structs_f, tp->base.file), tp)); 50 EOLIAN_OBJECT_ADD(unit, tp->base.name, tp, inlists);
51 }
52 else
53 {
54 EOLIAN_OBJECT_ADD(unit, tp->base.name, tp, structs);
55 }
56 Eina_Hash *sh = is_inlist ? unit->state->staging.structs_f
57 : unit->state->staging.inlists_f;
58 eina_hash_set(sh, tp->base.file, eina_list_append
59 ((Eina_List*)eina_hash_find(sh, tp->base.file), tp));
51 database_object_add(unit, &tp->base); 60 database_object_add(unit, &tp->base);
52} 61}
53 62
@@ -160,6 +169,8 @@ _stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
160 if (tp->type == EOLIAN_TYPEDECL_STRUCT_OPAQUE) 169 if (tp->type == EOLIAN_TYPEDECL_STRUCT_OPAQUE)
161 return; 170 return;
162 eina_strbuf_append(buf, " { "); 171 eina_strbuf_append(buf, " { ");
172 if (tp->type == EOLIAN_TYPEDECL_STRUCT_INLIST)
173 eina_strbuf_append(buf, "EINA_INLIST; ");
163 Eina_List *l; 174 Eina_List *l;
164 Eolian_Struct_Type_Field *sf; 175 Eolian_Struct_Type_Field *sf;
165 EINA_LIST_FOREACH(tp->field_list, l, sf) 176 EINA_LIST_FOREACH(tp->field_list, l, sf)
@@ -234,6 +245,7 @@ database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
234 break; 245 break;
235 case EOLIAN_TYPEDECL_STRUCT: 246 case EOLIAN_TYPEDECL_STRUCT:
236 case EOLIAN_TYPEDECL_STRUCT_OPAQUE: 247 case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
248 case EOLIAN_TYPEDECL_STRUCT_INLIST:
237 _stype_to_str(tp, buf); 249 _stype_to_str(tp, buf);
238 break; 250 break;
239 default: 251 default:
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 7d471c7ee4..a0887943f1 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -31,7 +31,7 @@ EAPI Eina_Iterator *
31eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp) 31eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp)
32{ 32{
33 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 33 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
34 if (tp->type != EOLIAN_TYPEDECL_STRUCT) 34 if (tp->type != EOLIAN_TYPEDECL_STRUCT && tp->type != EOLIAN_TYPEDECL_STRUCT_INLIST)
35 return NULL; 35 return NULL;
36 return eina_list_iterator_new(tp->field_list); 36 return eina_list_iterator_new(tp->field_list);
37} 37}
@@ -42,7 +42,7 @@ eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field)
42 Eolian_Struct_Type_Field *sf = NULL; 42 Eolian_Struct_Type_Field *sf = NULL;
43 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 43 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
44 EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL); 44 EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
45 if (tp->type != EOLIAN_TYPEDECL_STRUCT) 45 if (tp->type != EOLIAN_TYPEDECL_STRUCT && tp->type != EOLIAN_TYPEDECL_STRUCT_INLIST)
46 return NULL; 46 return NULL;
47 sf = eina_hash_find(tp->fields, field); 47 sf = eina_hash_find(tp->fields, field);
48 if (!sf) return NULL; 48 if (!sf) return NULL;
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 319b45a802..09ca6e5de3 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -171,6 +171,25 @@ _validate_typedecl(Validate_State *vals, Eolian_Typedecl *tp)
171 if (!tp->freefunc && tp->base_type->freefunc) 171 if (!tp->freefunc && tp->base_type->freefunc)
172 tp->freefunc = eina_stringshare_ref(tp->base_type->freefunc); 172 tp->freefunc = eina_stringshare_ref(tp->base_type->freefunc);
173 return _validate(&tp->base); 173 return _validate(&tp->base);
174 case EOLIAN_TYPEDECL_STRUCT_INLIST:
175 if (eina_hash_population(tp->fields) == 1)
176 {
177 Eina_Iterator *itr = eina_hash_iterator_data_new(tp->fields);
178 const Eolian_Struct_Type_Field *sf;
179 if (!eina_iterator_next(itr, (void **)&sf))
180 {
181 _eo_parser_log(&tp->base, "internal error: failed fetching field");
182 eina_iterator_free(itr);
183 return EINA_FALSE;
184 }
185 eina_iterator_free(itr);
186 if (database_type_is_ownable(tp->base.unit, sf->type, EINA_FALSE))
187 {
188 _eo_parser_log(&sf->base, "single-field inlist struct must contain a value type");
189 return EINA_FALSE;
190 }
191 }
192 /* fallthrough */
174 case EOLIAN_TYPEDECL_STRUCT: 193 case EOLIAN_TYPEDECL_STRUCT:
175 { 194 {
176 Cb_Ret rt = { vals, EINA_TRUE }; 195 Cb_Ret rt = { vals, EINA_TRUE };
@@ -1388,6 +1407,10 @@ database_validate(const Eolian_Unit *src)
1388 if (!rt.succ) 1407 if (!rt.succ)
1389 return EINA_FALSE; 1408 return EINA_FALSE;
1390 1409
1410 eina_hash_foreach(src->inlists, (Eina_Hash_Foreach)_typedecl_map_cb, &rt);
1411 if (!rt.succ)
1412 return EINA_FALSE;
1413
1391 eina_hash_foreach(src->globals, (Eina_Hash_Foreach)_var_map_cb, &rt); 1414 eina_hash_foreach(src->globals, (Eina_Hash_Foreach)_var_map_cb, &rt);
1392 if (!rt.succ) 1415 if (!rt.succ)
1393 return EINA_FALSE; 1416 return EINA_FALSE;
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index cc3ea7aabb..57b5e117c0 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -133,6 +133,7 @@ _eolian_decl_name_get(Eolian_Object *obj)
133 return "type alias"; 133 return "type alias";
134 case EOLIAN_TYPEDECL_STRUCT: 134 case EOLIAN_TYPEDECL_STRUCT:
135 case EOLIAN_TYPEDECL_STRUCT_OPAQUE: 135 case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
136 case EOLIAN_TYPEDECL_STRUCT_INLIST:
136 return "struct"; 137 return "struct";
137 case EOLIAN_TYPEDECL_ENUM: 138 case EOLIAN_TYPEDECL_ENUM:
138 return "enum"; 139 return "enum";
@@ -433,13 +434,13 @@ _struct_field_free(Eolian_Struct_Type_Field *def)
433 434
434static Eolian_Typedecl * 435static Eolian_Typedecl *
435parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern, 436parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
436 int line, int column, const char *freefunc) 437 int line, int column, const char *freefunc, Eina_Bool is_inlist)
437{ 438{
438 int bline = ls->line_number, bcolumn = ls->column; 439 int bline = ls->line_number, bcolumn = ls->column;
439 Eolian_Typedecl *def = eo_lexer_typedecl_new(ls); 440 Eolian_Typedecl *def = eo_lexer_typedecl_new(ls);
440 def->is_extern = is_extern; 441 def->is_extern = is_extern;
441 def->base.name = name; 442 def->base.name = name;
442 def->type = EOLIAN_TYPEDECL_STRUCT; 443 def->type = is_inlist ? EOLIAN_TYPEDECL_STRUCT_INLIST : EOLIAN_TYPEDECL_STRUCT;
443 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free)); 444 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free));
444 if (freefunc) 445 if (freefunc)
445 { 446 {
@@ -475,7 +476,7 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
475 } 476 }
476 check_match(ls, '}', '{', bline, bcolumn); 477 check_match(ls, '}', '{', bline, bcolumn);
477 FILL_BASE(def->base, ls, line, column, TYPEDECL); 478 FILL_BASE(def->base, ls, line, column, TYPEDECL);
478 database_struct_add(ls->unit, eo_lexer_typedecl_release(ls, def)); 479 database_struct_add(ls->unit, eo_lexer_typedecl_release(ls, def), is_inlist);
479 return def; 480 return def;
480} 481}
481 482
@@ -2205,8 +2206,10 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2205 } 2206 }
2206 case KW_struct: 2207 case KW_struct:
2207 case KW_enum: 2208 case KW_enum:
2209 case KW_inlist:
2208 { 2210 {
2209 Eina_Bool is_enum = (ls->t.kw == KW_enum); 2211 Eina_Bool is_enum = (ls->t.kw == KW_enum);
2212 Eina_Bool is_inlist = (ls->t.kw == KW_inlist);
2210 const char *name; 2213 const char *name;
2211 int line, col; 2214 int line, col;
2212 const char *freefunc = NULL; 2215 const char *freefunc = NULL;
@@ -2217,6 +2220,8 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
2217 { 2220 {
2218 case KW_at_extern: 2221 case KW_at_extern:
2219 CASE_LOCK(ls, extern, "@extern qualifier") 2222 CASE_LOCK(ls, extern, "@extern qualifier")
2223 if (is_inlist)
2224 eo_lexer_syntax_error(ls, "inlist structs cannot be @extern");
2220 eo_lexer_get(ls); 2225 eo_lexer_get(ls);
2221 break; 2226 break;
2222 case KW_at_free: 2227 case KW_at_free:
@@ -2254,12 +2259,13 @@ postparams:
2254 eo_lexer_context_restore(ls); 2259 eo_lexer_context_restore(ls);
2255 Eolian_Typedecl tdecl; 2260 Eolian_Typedecl tdecl;
2256 tdecl.base.type = EOLIAN_OBJECT_TYPEDECL; 2261 tdecl.base.type = EOLIAN_OBJECT_TYPEDECL;
2257 tdecl.type = is_enum ? EOLIAN_TYPEDECL_ENUM : EOLIAN_TYPEDECL_STRUCT; 2262 tdecl.type = is_inlist ? EOLIAN_TYPEDECL_STRUCT_INLIST :
2263 (is_enum ? EOLIAN_TYPEDECL_ENUM : EOLIAN_TYPEDECL_STRUCT);
2258 redef_error(ls, decl, &tdecl.base); 2264 redef_error(ls, decl, &tdecl.base);
2259 } 2265 }
2260 eo_lexer_context_pop(ls); 2266 eo_lexer_context_pop(ls);
2261 eo_lexer_dtor_pop(ls); 2267 eo_lexer_dtor_pop(ls);
2262 if (!is_enum && ls->t.token == ';') 2268 if (!is_enum && !is_inlist && ls->t.token == ';')
2263 { 2269 {
2264 Eolian_Typedecl *def = eo_lexer_typedecl_new(ls); 2270 Eolian_Typedecl *def = eo_lexer_typedecl_new(ls);
2265 def->is_extern = has_extern; 2271 def->is_extern = has_extern;
@@ -2273,13 +2279,13 @@ postparams:
2273 eo_lexer_get(ls); 2279 eo_lexer_get(ls);
2274 FILL_DOC(ls, def, doc); 2280 FILL_DOC(ls, def, doc);
2275 FILL_BASE(def->base, ls, line, col, TYPEDECL); 2281 FILL_BASE(def->base, ls, line, col, TYPEDECL);
2276 database_struct_add(ls->unit, eo_lexer_typedecl_release(ls, def)); 2282 database_struct_add(ls->unit, eo_lexer_typedecl_release(ls, def), EINA_FALSE);
2277 break; 2283 break;
2278 } 2284 }
2279 if (is_enum) 2285 if (is_enum)
2280 parse_enum(ls, name, has_extern, line, col); 2286 parse_enum(ls, name, has_extern, line, col);
2281 else 2287 else
2282 parse_struct(ls, name, has_extern, line, col, freefunc); 2288 parse_struct(ls, name, has_extern, line, col, freefunc, is_inlist);
2283 break; 2289 break;
2284 } 2290 }
2285 def: 2291 def:
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index eb6e896bab..a97c53f526 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -557,6 +557,7 @@ database_unit_init(Eolian_State *state, Eolian_Unit *unit, const char *file)
557 unit->aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); 557 unit->aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
558 unit->structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); 558 unit->structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
559 unit->enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); 559 unit->enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
560 unit->inlists = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
560 unit->objects = eina_hash_stringshared_new(NULL); 561 unit->objects = eina_hash_stringshared_new(NULL);
561} 562}
562 563
@@ -571,6 +572,7 @@ _unit_contents_del(Eolian_Unit *unit)
571 eina_hash_free(unit->aliases); 572 eina_hash_free(unit->aliases);
572 eina_hash_free(unit->structs); 573 eina_hash_free(unit->structs);
573 eina_hash_free(unit->enums); 574 eina_hash_free(unit->enums);
575 eina_hash_free(unit->inlists);
574 eina_hash_free(unit->objects); 576 eina_hash_free(unit->objects);
575} 577}
576 578
@@ -618,6 +620,7 @@ _state_area_init(Eolian_State *state, Eolian_State_Area *a)
618 a->aliases_f = eina_hash_stringshared_new(NULL); 620 a->aliases_f = eina_hash_stringshared_new(NULL);
619 a->structs_f = eina_hash_stringshared_new(NULL); 621 a->structs_f = eina_hash_stringshared_new(NULL);
620 a->enums_f = eina_hash_stringshared_new(NULL); 622 a->enums_f = eina_hash_stringshared_new(NULL);
623 a->inlists_f = eina_hash_stringshared_new(NULL);
621 a->globals_f = eina_hash_stringshared_new(NULL); 624 a->globals_f = eina_hash_stringshared_new(NULL);
622 a->constants_f = eina_hash_stringshared_new(NULL); 625 a->constants_f = eina_hash_stringshared_new(NULL);
623 a->objects_f = eina_hash_stringshared_new(NULL); 626 a->objects_f = eina_hash_stringshared_new(NULL);
@@ -644,6 +647,7 @@ _state_area_contents_del(Eolian_State_Area *a)
644 _hashlist_free(a->aliases_f); 647 _hashlist_free(a->aliases_f);
645 _hashlist_free(a->structs_f); 648 _hashlist_free(a->structs_f);
646 _hashlist_free(a->enums_f); 649 _hashlist_free(a->enums_f);
650 _hashlist_free(a->inlists_f);
647 _hashlist_free(a->globals_f); 651 _hashlist_free(a->globals_f);
648 _hashlist_free(a->constants_f); 652 _hashlist_free(a->constants_f);
649 _hashlist_free(a->objects_f); 653 _hashlist_free(a->objects_f);
@@ -848,6 +852,7 @@ _state_clean(Eolian_State *state)
848 eina_hash_free_buckets(stu->aliases); 852 eina_hash_free_buckets(stu->aliases);
849 eina_hash_free_buckets(stu->structs); 853 eina_hash_free_buckets(stu->structs);
850 eina_hash_free_buckets(stu->enums); 854 eina_hash_free_buckets(stu->enums);
855 eina_hash_free_buckets(stu->inlists);
851 eina_hash_free_buckets(stu->objects); 856 eina_hash_free_buckets(stu->objects);
852 857
853 eina_hash_foreach(st->units, _ulist_free_cb, NULL); 858 eina_hash_foreach(st->units, _ulist_free_cb, NULL);
@@ -858,6 +863,7 @@ _state_clean(Eolian_State *state)
858 _hashlist_free_buckets(st->aliases_f); 863 _hashlist_free_buckets(st->aliases_f);
859 _hashlist_free_buckets(st->structs_f); 864 _hashlist_free_buckets(st->structs_f);
860 _hashlist_free_buckets(st->enums_f); 865 _hashlist_free_buckets(st->enums_f);
866 _hashlist_free_buckets(st->inlists_f);
861 _hashlist_free_buckets(st->globals_f); 867 _hashlist_free_buckets(st->globals_f);
862 _hashlist_free_buckets(st->constants_f); 868 _hashlist_free_buckets(st->constants_f);
863 _hashlist_free_buckets(st->objects_f); 869 _hashlist_free_buckets(st->objects_f);
@@ -952,6 +958,7 @@ _merge_unit(Eolian_Unit *dest, Eolian_Unit *src)
952 eina_hash_foreach(src->aliases, _merge_unit_cb, dest->aliases); 958 eina_hash_foreach(src->aliases, _merge_unit_cb, dest->aliases);
953 eina_hash_foreach(src->structs, _merge_unit_cb, dest->structs); 959 eina_hash_foreach(src->structs, _merge_unit_cb, dest->structs);
954 eina_hash_foreach(src->enums, _merge_unit_cb, dest->enums); 960 eina_hash_foreach(src->enums, _merge_unit_cb, dest->enums);
961 eina_hash_foreach(src->inlists, _merge_unit_cb, dest->inlists);
955 eina_hash_foreach(src->objects, _merge_unit_cb_noref, dest->objects); 962 eina_hash_foreach(src->objects, _merge_unit_cb_noref, dest->objects);
956} 963}
957 964
@@ -1010,6 +1017,7 @@ _merge_staging(Eolian_State *state)
1010 EOLIAN_STAGING_MERGE_LIST(aliases); 1017 EOLIAN_STAGING_MERGE_LIST(aliases);
1011 EOLIAN_STAGING_MERGE_LIST(structs); 1018 EOLIAN_STAGING_MERGE_LIST(structs);
1012 EOLIAN_STAGING_MERGE_LIST(enums); 1019 EOLIAN_STAGING_MERGE_LIST(enums);
1020 EOLIAN_STAGING_MERGE_LIST(inlists);
1013 EOLIAN_STAGING_MERGE_LIST(globals); 1021 EOLIAN_STAGING_MERGE_LIST(globals);
1014 EOLIAN_STAGING_MERGE_LIST(constants); 1022 EOLIAN_STAGING_MERGE_LIST(constants);
1015 EOLIAN_STAGING_MERGE_LIST(objects); 1023 EOLIAN_STAGING_MERGE_LIST(objects);
@@ -1205,6 +1213,17 @@ eolian_state_enums_by_file_get(const Eolian_State *state, const char *file_name)
1205 return eina_list_iterator_new(l); 1213 return eina_list_iterator_new(l);
1206} 1214}
1207 1215
1216EAPI Eina_Iterator *
1217eolian_state_inlist_structs_by_file_get(const Eolian_State *state, const char *file_name)
1218{
1219 if (!state) return NULL;
1220 Eina_Stringshare *shr = eina_stringshare_add(file_name);
1221 Eina_List *l = eina_hash_find(state->main.inlists_f, shr);
1222 eina_stringshare_del(shr);
1223 if (!l) return NULL;
1224 return eina_list_iterator_new(l);
1225}
1226
1208EAPI const Eolian_State * 1227EAPI const Eolian_State *
1209eolian_unit_state_get(const Eolian_Unit *unit) 1228eolian_unit_state_get(const Eolian_Unit *unit)
1210{ 1229{
@@ -1332,6 +1351,17 @@ eolian_unit_enum_by_name_get(const Eolian_Unit *unit, const char *name)
1332 return tp; 1351 return tp;
1333} 1352}
1334 1353
1354EAPI const Eolian_Typedecl *
1355eolian_unit_inlist_struct_by_name_get(const Eolian_Unit *unit, const char *name)
1356{
1357 if (!unit) return NULL;
1358 Eina_Stringshare *shr = eina_stringshare_add(name);
1359 Eolian_Typedecl *tp = eina_hash_find(unit->inlists, shr);
1360 eina_stringshare_del(shr);
1361 if (!tp) return NULL;
1362 return tp;
1363}
1364
1335EAPI Eina_Iterator * 1365EAPI Eina_Iterator *
1336eolian_unit_aliases_get(const Eolian_Unit *unit) 1366eolian_unit_aliases_get(const Eolian_Unit *unit)
1337{ 1367{
@@ -1350,6 +1380,12 @@ eolian_unit_enums_get(const Eolian_Unit *unit)
1350 return (unit ? eina_hash_iterator_data_new(unit->enums) : NULL); 1380 return (unit ? eina_hash_iterator_data_new(unit->enums) : NULL);
1351} 1381}
1352 1382
1383EAPI Eina_Iterator *
1384eolian_unit_inlist_structs_get(const Eolian_Unit *unit)
1385{
1386 return (unit ? eina_hash_iterator_data_new(unit->inlists) : NULL);
1387}
1388
1353char * 1389char *
1354database_class_to_filename(const char *cname) 1390database_class_to_filename(const char *cname)
1355{ 1391{
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index b70f2b4f1e..fd15d6401a 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -44,6 +44,7 @@ struct _Eolian_Unit
44 Eina_Hash *aliases; 44 Eina_Hash *aliases;
45 Eina_Hash *structs; 45 Eina_Hash *structs;
46 Eina_Hash *enums; 46 Eina_Hash *enums;
47 Eina_Hash *inlists;
47 Eina_Hash *objects; 48 Eina_Hash *objects;
48}; 49};
49 50
@@ -57,6 +58,7 @@ typedef struct _Eolian_State_Area
57 Eina_Hash *aliases_f; 58 Eina_Hash *aliases_f;
58 Eina_Hash *structs_f; 59 Eina_Hash *structs_f;
59 Eina_Hash *enums_f; 60 Eina_Hash *enums_f;
61 Eina_Hash *inlists_f;
60 Eina_Hash *globals_f; 62 Eina_Hash *globals_f;
61 Eina_Hash *constants_f; 63 Eina_Hash *constants_f;
62 Eina_Hash *objects_f; 64 Eina_Hash *objects_f;
@@ -407,7 +409,7 @@ Eolian_Object_Type database_doc_token_ref_resolve(const Eolian_Doc_Token *tok,
407/* types */ 409/* types */
408 410
409void database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp); 411void database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp);
410void database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp); 412void database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp, Eina_Bool is_inlist);
411void database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp); 413void database_enum_add(Eolian_Unit *unit, Eolian_Typedecl *tp);
412void database_type_del(Eolian_Type *tp); 414void database_type_del(Eolian_Type *tp);
413void database_typedecl_del(Eolian_Typedecl *tp); 415void database_typedecl_del(Eolian_Typedecl *tp);