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 01:09:02 +0100
commitc2ccdec78749ceed7504eb9f1d3d4100184c1119 (patch)
tree50db238d04eb169e8160f9880f86ca47c0c7c7b4
parent57d8f24016f32961e97e3eac9c188da8da0c26a4 (diff)
eolian: add support for inlist structs
The inlist<T> syntax can now never refer to an ordinary type, T must be a new special type of struct called inlist struct. This inlist struct 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(). When used with inlist, the free function set on the inlist struct via @free() will be inherited onto the inlist<T> type, except when previously overridden. 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. @feature
-rw-r--r--src/lib/eolian/database_validate.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 4d3ae294c3..339f1baf08 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -277,7 +277,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
277 if (tp->base_type) 277 if (tp->base_type)
278 { 278 {
279 int kwid = eo_lexer_keyword_str_to_id(tp->base.name); 279 int kwid = eo_lexer_keyword_str_to_id(tp->base.name);
280 if (kwid == KW_inlist || kwid == KW_inarray) 280 if (kwid == KW_inarray)
281 { 281 {
282 if (database_type_is_ownable(src, tp->base_type, EINA_FALSE)) 282 if (database_type_is_ownable(src, tp->base_type, EINA_FALSE))
283 { 283 {
@@ -288,7 +288,28 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
288 } 288 }
289 if (!_validate_type(vals, tp->base_type)) 289 if (!_validate_type(vals, tp->base_type))
290 return EINA_FALSE; 290 return EINA_FALSE;
291 return _validate(&tp->base); 291 return _validate_ownable(tp);
292 }
293 else if (kwid == KW_inlist)
294 {
295 /* TODO: maybe check typedecl first to avoid potentially
296 * misleading error messages, but it should be harmless
297 */
298 if (!_validate_type(vals, tp->base_type))
299 return EINA_FALSE;
300 if (tp->base_type->tdecl->type != EOLIAN_TYPEDECL_STRUCT_INLIST)
301 {
302 _eo_parser_log(&tp->base_type->base,
303 "inlists can only point at inlist structs");
304 return EINA_FALSE;
305 }
306 /* potential @free() is inherited from the inlist struct
307 * onto the inlist itself, but the inlist struct type
308 * is never ownable in itself
309 */
310 if (tp->base_type->tdecl->freefunc && !tp->freefunc)
311 tp->freefunc = eina_stringshare_ref(tp->base_type->tdecl->freefunc);
312 return _validate_ownable(tp);
292 } 313 }
293 if (!tp->freefunc && kwid > KW_void) 314 if (!tp->freefunc && kwid > KW_void)
294 { 315 {