summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-08-31 02:04:13 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-08-31 02:13:59 +0200
commit242bad209b23098027b94528d81ead63e10461f3 (patch)
tree64d7d1e79c00507b783f46ee2e3736e6caf4dadd
parent5e5bfc70e5d52a2779473127a0f1ccdc92588de9 (diff)
downloadefl-242bad209b23098027b94528d81ead63e10461f3.tar.gz
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.
-rw-r--r--src/lib/eolian/Eolian.h15
-rw-r--r--src/lib/eolian/database_type_api.c7
-rw-r--r--src/lib/eolian/eo_parser.c4
-rw-r--r--src/lib/eolian/eolian_database.h1
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
@@ -2916,6 +2916,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.
*
* @param[in] tp the type.
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
@@ -228,6 +228,13 @@ eolian_type_is_owned(const Eolian_Type *tp)
}
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)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE);
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;
};