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.
This commit is contained in:
parent
5e5bfc70e5
commit
242bad209b
|
@ -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);
|
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.
|
* @brief Get whether the given type is const.
|
||||||
*
|
*
|
||||||
|
|
|
@ -227,6 +227,13 @@ eolian_type_is_owned(const Eolian_Type *tp)
|
||||||
return tp->owned;
|
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
|
EAPI Eina_Bool
|
||||||
eolian_type_is_const(const Eolian_Type *tp)
|
eolian_type_is_const(const Eolian_Type *tp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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));
|
def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
|
||||||
/* view-only types are not allowed to own the contents */
|
/* view-only types are not allowed to own the contents */
|
||||||
if (tpid == KW_array || tpid == KW_hash || tpid == KW_list || tpid == KW_future)
|
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);
|
eo_lexer_get(ls);
|
||||||
if (tpid == KW_hash)
|
if (tpid == KW_hash)
|
||||||
{
|
{
|
||||||
check_next(ls, ',');
|
check_next(ls, ',');
|
||||||
def->base_type->next_type =
|
def->base_type->next_type =
|
||||||
eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
|
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);
|
eo_lexer_get(ls);
|
||||||
}
|
}
|
||||||
check_match(ls, '>', '<', bline, bcol);
|
check_match(ls, '>', '<', bline, bcol);
|
||||||
|
|
|
@ -278,6 +278,7 @@ struct _Eolian_Type
|
||||||
};
|
};
|
||||||
Eina_Bool is_const :1;
|
Eina_Bool is_const :1;
|
||||||
Eina_Bool is_ptr :1;
|
Eina_Bool is_ptr :1;
|
||||||
|
Eina_Bool move :1;
|
||||||
Eina_Bool owned :1;
|
Eina_Bool owned :1;
|
||||||
Eina_Bool ownable :1;
|
Eina_Bool ownable :1;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue