eolian: allow value types in view containers (iterators etc.)

This restricts disallowing value types to containers that can own
them.

It also disallows usage of @owned on those view-only containers,
as that makes no sense.
This commit is contained in:
Daniel Kolesa 2019-06-26 13:54:12 +02:00
parent 4ff8c5f7b2
commit 5b00dc344f
4 changed files with 11 additions and 22 deletions

View File

@ -273,7 +273,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
{
if (!_validate_type(vals, itp))
return EINA_FALSE;
if ((kwid >= KW_accessor) && (kwid <= KW_list) && (kwid != KW_future))
if (kwid == KW_array || kwid == KW_hash || kwid == KW_list)
{
if (!database_type_is_ownable(src, itp, EINA_TRUE))
{

View File

@ -768,8 +768,10 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ptr)
def->base_type = eo_lexer_type_release(ls, parse_type_void(ls, EINA_TRUE));
else
def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
if ((def->base_type->owned = (ls->t.kw == KW_at_owned)))
eo_lexer_get(ls);
/* 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)))
eo_lexer_get(ls);
if (tpid == KW_hash)
{
check_next(ls, ',');

View File

@ -15,9 +15,7 @@ class Owning {
test2 {
params {
test1 : list<ptr(Test.A) @owned> @owned;
test2 : iterator<ptr(Test.A) @owned> @owned;
test3 : hash<string, ptr(Test.A) @owned> @owned;
test4 : accessor<ptr(Test.A) @owned> @owned;
test2 : hash<string, ptr(Test.A) @owned> @owned;
}
}

View File

@ -13,32 +13,21 @@ _owning_test1_ownership_fallback(Eina_List *test1, Eina_Iterator *test2, Eina_Ha
EOAPI EFL_VOID_FUNC_BODYV_FALLBACK(owning_test1, _owning_test1_ownership_fallback(test1, test2, test3, test4);, EFL_FUNC_CALL(test1, test2, test3, test4), Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4);
void _owning_test2(Eo *obj, Owning_Data *pd, Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4);
void _owning_test2(Eo *obj, Owning_Data *pd, Eina_List *test1, Eina_Hash *test2);
static void
_owning_test2_ownership_fallback(Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4)
_owning_test2_ownership_fallback(Eina_List *test1, Eina_Hash *test2)
{
Test_A *test1_iter;
EINA_LIST_FREE(test1,test1_iter)
{
free_a(test1_iter);
}
Test_A *test2_iter;
EINA_ITERATOR_FOREACH(test2,test2_iter)
{
free_a(test2_iter);
}
eina_hash_free_cb_set(test3,NULL);
eina_hash_free(test3);
Test_A *test4_iter;
unsigned int test4_i = 0;
EINA_ACCESSOR_FOREACH(test4,test4_i,test4_iter)
{
free_a(test4_iter);
}
eina_hash_free_cb_set(test2,NULL);
eina_hash_free(test2);
}
EOAPI EFL_VOID_FUNC_BODYV_FALLBACK(owning_test2, _owning_test2_ownership_fallback(test1, test2, test3, test4);, EFL_FUNC_CALL(test1, test2, test3, test4), Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4);
EOAPI EFL_VOID_FUNC_BODYV_FALLBACK(owning_test2, _owning_test2_ownership_fallback(test1, test2);, EFL_FUNC_CALL(test1, test2), Eina_List *test1, Eina_Hash *test2);
static Eina_Bool
_owning_class_initializer(Efl_Class *klass)