From 242bad209b23098027b94528d81ead63e10461f3 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Sat, 31 Aug 2019 02:04:13 +0200 Subject: [PATCH] eolian: add API to check if an inner type of complex type is @move This complements the equivalent APIs of parameters and so on. It is not the same as the older type_is_owned API, which applied to everything. --- src/lib/eolian/Eolian.h | 15 +++++++++++++++ src/lib/eolian/database_type_api.c | 7 +++++++ src/lib/eolian/eo_parser.c | 4 ++-- src/lib/eolian/eolian_database.h | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index f92830e64f..b054792e29 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -2915,6 +2915,21 @@ EAPI const Eolian_Error *eolian_type_error_get(const Eolian_Type *tp); */ EAPI Eina_Bool eolian_type_is_owned(const Eolian_Type *tp); +/* + * @brief Get whether the given type is moved with its parent type. + * + * This is only used for inner types of complex types, i.e. the types + * inside the brackets of lists, arrays, hashes and so on. You can use + * this to tell whether they belong to their parent type (i.e. whether + * they are marked @move). + * + * @param[in] tp the type. + * @return EINA_TRUE when the type is marked move, EINA_FALSE otherwise. + * + * @ingroup Eolian + */ +EAPI Eina_Bool eolian_type_is_move(const Eolian_Type *tp); + /* * @brief Get whether the given type is const. * diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 39ba042a2b..2bec505ca0 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -227,6 +227,13 @@ eolian_type_is_owned(const Eolian_Type *tp) return tp->owned; } +EAPI Eina_Bool +eolian_type_is_move(const Eolian_Type *tp) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE); + return tp->move; +} + EAPI Eina_Bool eolian_type_is_const(const Eolian_Type *tp) { diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index e69989aa8c..70ae08b1f8 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -774,14 +774,14 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ptr) def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE)); /* view-only types are not allowed to own the contents */ if (tpid == KW_array || tpid == KW_hash || tpid == KW_list || tpid == KW_future) - if ((def->base_type->owned = (ls->t.kw == KW_at_owned || ls->t.kw == KW_at_move))) + if ((def->base_type->owned = def->base_type->move = (ls->t.kw == KW_at_owned || ls->t.kw == KW_at_move))) eo_lexer_get(ls); if (tpid == KW_hash) { check_next(ls, ','); def->base_type->next_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE)); - if ((def->base_type->next_type->owned = (ls->t.kw == KW_at_owned || ls->t.kw == KW_at_move))) + if ((def->base_type->next_type->owned = def->base_type->move = (ls->t.kw == KW_at_owned || ls->t.kw == KW_at_move))) eo_lexer_get(ls); } check_match(ls, '>', '<', bline, bcol); diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index e66543f6bd..8f67ab5dc5 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -278,6 +278,7 @@ struct _Eolian_Type }; Eina_Bool is_const :1; Eina_Bool is_ptr :1; + Eina_Bool move :1; Eina_Bool owned :1; Eina_Bool ownable :1; };