summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-06-26 13:54:12 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-06-26 14:05:46 +0200
commit5b00dc344febd4004f268d8d76a05f7579d08288 (patch)
treedb6b2cb5cbf3f23c3af31eeb51abbbeb75d3c69c
parent4ff8c5f7b25ee539c930e5aaa6352cc0304d3908 (diff)
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.
-rw-r--r--src/lib/eolian/database_validate.c2
-rw-r--r--src/lib/eolian/eo_parser.c6
-rw-r--r--src/tests/eolian/data/owning.eo4
-rw-r--r--src/tests/eolian/data/owning_ref.c21
4 files changed, 11 insertions, 22 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 8deea6d595..c7254ed220 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -273,7 +273,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
273 { 273 {
274 if (!_validate_type(vals, itp)) 274 if (!_validate_type(vals, itp))
275 return EINA_FALSE; 275 return EINA_FALSE;
276 if ((kwid >= KW_accessor) && (kwid <= KW_list) && (kwid != KW_future)) 276 if (kwid == KW_array || kwid == KW_hash || kwid == KW_list)
277 { 277 {
278 if (!database_type_is_ownable(src, itp, EINA_TRUE)) 278 if (!database_type_is_ownable(src, itp, EINA_TRUE))
279 { 279 {
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index f33db75f67..6b5d920409 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -768,8 +768,10 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ptr)
768 def->base_type = eo_lexer_type_release(ls, parse_type_void(ls, EINA_TRUE)); 768 def->base_type = eo_lexer_type_release(ls, parse_type_void(ls, EINA_TRUE));
769 else 769 else
770 def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE)); 770 def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
771 if ((def->base_type->owned = (ls->t.kw == KW_at_owned))) 771 /* view-only types are not allowed to own the contents */
772 eo_lexer_get(ls); 772 if (tpid == KW_array || tpid == KW_hash || tpid == KW_list || tpid == KW_future)
773 if ((def->base_type->owned = (ls->t.kw == KW_at_owned)))
774 eo_lexer_get(ls);
773 if (tpid == KW_hash) 775 if (tpid == KW_hash)
774 { 776 {
775 check_next(ls, ','); 777 check_next(ls, ',');
diff --git a/src/tests/eolian/data/owning.eo b/src/tests/eolian/data/owning.eo
index f74d683b78..ae926a5e35 100644
--- a/src/tests/eolian/data/owning.eo
+++ b/src/tests/eolian/data/owning.eo
@@ -15,9 +15,7 @@ class Owning {
15 test2 { 15 test2 {
16 params { 16 params {
17 test1 : list<ptr(Test.A) @owned> @owned; 17 test1 : list<ptr(Test.A) @owned> @owned;
18 test2 : iterator<ptr(Test.A) @owned> @owned; 18 test2 : hash<string, ptr(Test.A) @owned> @owned;
19 test3 : hash<string, ptr(Test.A) @owned> @owned;
20 test4 : accessor<ptr(Test.A) @owned> @owned;
21 } 19 }
22 } 20 }
23 21
diff --git a/src/tests/eolian/data/owning_ref.c b/src/tests/eolian/data/owning_ref.c
index 3df14c9098..10a7f10a13 100644
--- a/src/tests/eolian/data/owning_ref.c
+++ b/src/tests/eolian/data/owning_ref.c
@@ -13,32 +13,21 @@ _owning_test1_ownership_fallback(Eina_List *test1, Eina_Iterator *test2, Eina_Ha
13 13
14EOAPI 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); 14EOAPI 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);
15 15
16void _owning_test2(Eo *obj, Owning_Data *pd, Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4); 16void _owning_test2(Eo *obj, Owning_Data *pd, Eina_List *test1, Eina_Hash *test2);
17 17
18static void 18static void
19_owning_test2_ownership_fallback(Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4) 19_owning_test2_ownership_fallback(Eina_List *test1, Eina_Hash *test2)
20{ 20{
21 Test_A *test1_iter; 21 Test_A *test1_iter;
22 EINA_LIST_FREE(test1,test1_iter) 22 EINA_LIST_FREE(test1,test1_iter)
23 { 23 {
24 free_a(test1_iter); 24 free_a(test1_iter);
25 } 25 }
26 Test_A *test2_iter; 26 eina_hash_free_cb_set(test2,NULL);
27 EINA_ITERATOR_FOREACH(test2,test2_iter) 27 eina_hash_free(test2);
28 {
29 free_a(test2_iter);
30 }
31 eina_hash_free_cb_set(test3,NULL);
32 eina_hash_free(test3);
33 Test_A *test4_iter;
34 unsigned int test4_i = 0;
35 EINA_ACCESSOR_FOREACH(test4,test4_i,test4_iter)
36 {
37 free_a(test4_iter);
38 }
39} 28}
40 29
41EOAPI 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); 30EOAPI EFL_VOID_FUNC_BODYV_FALLBACK(owning_test2, _owning_test2_ownership_fallback(test1, test2);, EFL_FUNC_CALL(test1, test2), Eina_List *test1, Eina_Hash *test2);
42 31
43static Eina_Bool 32static Eina_Bool
44_owning_class_initializer(Efl_Class *klass) 33_owning_class_initializer(Efl_Class *klass)