aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-09-22 22:56:31 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-09-29 11:28:15 +0200
commit79e21e90e0595d250394a0443cc81af20a85c79a (patch)
tree185b53facb375441f1d20d1c94ee03b44e069262 /src/tests
parenteolian: generate free function for owned parameters (diff)
downloadefl-79e21e90e0595d250394a0443cc81af20a85c79a.tar.gz
eolian: add tests for the new owning functions
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/eolian/data/owning.eo25
-rw-r--r--src/tests/eolian/data/owning.eo.c77
-rw-r--r--src/tests/eolian/eolian_generation.c13
3 files changed, 115 insertions, 0 deletions
diff --git a/src/tests/eolian/data/owning.eo b/src/tests/eolian/data/owning.eo
new file mode 100644
index 0000000000..7330375405
--- /dev/null
+++ b/src/tests/eolian/data/owning.eo
@@ -0,0 +1,25 @@
+struct @free(free_a) Test.A {
+ t : int;
+}
+
+class Owning {
+ methods {
+ test1 {
+ params {
+ test1 : list<int> @owned;
+ test2 : iterator<int> @owned;
+ test3 : hash<int, int> @owned;
+ test4 : accessor<int> @owned;
+ }
+ }
+ test2 {
+ params {
+ test1 : list<ptr(Test.A) @owned> @owned;
+ test2 : iterator<ptr(Test.A) @owned> @owned;
+ test3 : hash<int, ptr(Test.A) @owned> @owned;
+ test4 : accessor<ptr(Test.A) @owned> @owned;
+ }
+ }
+
+ }
+}
diff --git a/src/tests/eolian/data/owning.eo.c b/src/tests/eolian/data/owning.eo.c
new file mode 100644
index 0000000000..0c0d03a9ef
--- /dev/null
+++ b/src/tests/eolian/data/owning.eo.c
@@ -0,0 +1,77 @@
+
+void _owning_test1(Eo *obj, Owning_Data *pd, Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4);
+
+static void
+_owning_test1_ownership_fallback(Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4)
+{
+ eina_list_free(test1);
+ eina_iterator_free(test2);
+ eina_hash_free_cb_set(test3,NULL);
+ eina_hash_free(test3);
+ eina_accessor_free(test4);
+}
+
+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);
+
+static void
+_owning_test2_ownership_fallback(Eina_List *test1, Eina_Iterator *test2, Eina_Hash *test3, Eina_Accessor *test4)
+{
+ 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);
+ }
+}
+
+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);
+
+static Eina_Bool
+_owning_class_initializer(Efl_Class *klass)
+{
+ const Efl_Object_Ops *opsp = NULL, *copsp = NULL;
+
+#ifndef OWNING_EXTRA_OPS
+#define OWNING_EXTRA_OPS
+#endif
+
+ EFL_OPS_DEFINE(ops,
+ EFL_OBJECT_OP_FUNC(owning_test1, _owning_test1),
+ EFL_OBJECT_OP_FUNC(owning_test2, _owning_test2),
+ OWNING_EXTRA_OPS
+ );
+ opsp = &ops;
+
+#ifdef OWNING_EXTRA_CLASS_OPS
+ EFL_OPS_DEFINE(cops, OWNING_EXTRA_CLASS_OPS);
+ copsp = &cops;
+#endif
+
+ return efl_class_functions_set(klass, opsp, copsp);
+}
+
+static const Efl_Class_Description _owning_class_desc = {
+ EO_VERSION,
+ "Owning",
+ EFL_CLASS_TYPE_REGULAR,
+ sizeof(Owning_Data),
+ _owning_class_initializer,
+ NULL,
+ NULL
+};
+
+EFL_DEFINE_CLASS(owning_class_get, &_owning_class_desc, NULL, NULL);
diff --git a/src/tests/eolian/eolian_generation.c b/src/tests/eolian/eolian_generation.c
index ee19d22163..d1d06169e4 100644
--- a/src/tests/eolian/eolian_generation.c
+++ b/src/tests/eolian/eolian_generation.c
@@ -217,6 +217,18 @@ START_TEST(eolian_function_pointers)
}
END_TEST
+START_TEST(owning)
+{
+ char output_filepath[PATH_MAX] = "";
+ snprintf(output_filepath, PATH_MAX, "%s/eolian_owning",
+ eina_environment_tmp_get());
+ _remove_ref(output_filepath, "c");
+ fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/owning.eo", "-gc", output_filepath));
+ fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/owning.eo.c", output_filepath, "c"));
+
+}
+END_TEST
+
void eolian_generation_test(TCase *tc)
{
tcase_add_test(tc, eolian_types_generation);
@@ -227,4 +239,5 @@ void eolian_generation_test(TCase *tc)
tcase_add_test(tc, eolian_import);
tcase_add_test(tc, eolian_docs);
tcase_add_test(tc, eolian_function_pointers);
+ tcase_add_test(tc, owning);
}