summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-05-18 23:43:09 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-05-23 18:59:26 -0300
commit54f1e56b34e5b8b67161b70b582e54be1fbf5c74 (patch)
treee2873270d4ef751bb5bd07932fcb6f898ef4c121 /src
parentcfafd01bbe27bab90117e1a8d97fdace55b47944 (diff)
efl_mono: Generate support for accessors in .eos
Summary: Depends on D6190 Reviewers: felipealmeida, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6191
Diffstat (limited to 'src')
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh5
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh28
-rw-r--r--src/bin/eolian_mono/eolian/mono/type_impl.hh9
-rw-r--r--src/bindings/mono/eina_mono/eina_accessor.cs18
-rw-r--r--src/tests/efl_mono/Eo.cs22
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c15
-rw-r--r--src/tests/efl_mono/test_testing.eo8
7 files changed, 99 insertions, 6 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
index 38dbbcb48c..95970dedd6 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
@@ -237,6 +237,11 @@ struct marshall_type_visitor_generate
237 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}}; 237 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
238 } 238 }
239 } 239 }
240 ,{"accessor", nullptr, nullptr, [&]
241 {
242 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
243 }
244 }
240 }; 245 };
241 246
242 auto default_match = [&] (attributes::complex_type_def const& complex) 247 auto default_match = [&] (attributes::complex_type_def const& complex)
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index f7c97b723f..55ea6f4115 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -275,6 +275,10 @@ inline bool param_should_use_out_var(attributes::parameter_def const& param, boo
275 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT) 275 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
276 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT) 276 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
277 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT) 277 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
278 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
279 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
280 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
281 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
278 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT) 282 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
279 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT) 283 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
280 || param_is_acceptable(param, "const Eina_Hash *", !WANT_OWN, WANT_OUT) 284 || param_is_acceptable(param, "const Eina_Hash *", !WANT_OWN, WANT_OUT)
@@ -321,6 +325,10 @@ inline bool param_should_use_in_var(attributes::parameter_def const& param, bool
321 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, !WANT_OUT) 325 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, !WANT_OUT)
322 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, !WANT_OUT) 326 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, !WANT_OUT)
323 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, !WANT_OUT) 327 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, !WANT_OUT)
328 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, !WANT_OUT)
329 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, !WANT_OUT)
330 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, !WANT_OUT)
331 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, !WANT_OUT)
324 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, !WANT_OUT) 332 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, !WANT_OUT)
325 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, !WANT_OUT) 333 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, !WANT_OUT)
326 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, !WANT_OUT) 334 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, !WANT_OUT)
@@ -578,6 +586,7 @@ struct native_convert_in_variable_generator
578 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 586 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
579 || param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *" 587 || param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
580 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *" 588 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
589 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
581 ) 590 )
582 { 591 {
583 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type); 592 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@@ -665,6 +674,7 @@ struct convert_in_variable_generator
665 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 674 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
666 || param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *" 675 || param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
667 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *" 676 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
677 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
668 ) 678 )
669 { 679 {
670 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type); 680 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@@ -743,6 +753,10 @@ struct convert_out_variable_generator
743 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT) 753 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
744 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT) 754 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
745 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT) 755 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
756 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
757 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
758 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
759 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
746 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT) 760 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
747 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT) 761 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
748 || param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT) 762 || param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT)
@@ -818,6 +832,10 @@ struct native_convert_out_variable_generator
818 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT) 832 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
819 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT) 833 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
820 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT) 834 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
835 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
836 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
837 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
838 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
821 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT) 839 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
822 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT) 840 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
823 || param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT) 841 || param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT)
@@ -926,6 +944,10 @@ struct convert_out_assign_generator
926 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT) 944 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
927 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT) 945 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
928 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT) 946 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
947 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
948 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
949 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
950 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
929 || param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT) 951 || param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
930 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT) 952 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
931 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT) 953 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
@@ -1045,6 +1067,7 @@ struct convert_return_generator
1045 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 1067 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
1046 || ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *" 1068 || ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
1047 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *" 1069 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
1070 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
1048 ) 1071 )
1049 { 1072 {
1050 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type); 1073 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
@@ -1175,6 +1198,10 @@ struct native_convert_out_assign_generator
1175 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT) 1198 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
1176 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT) 1199 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
1177 || param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT) 1200 || param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
1201 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
1202 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
1203 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
1204 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
1178 ) 1205 )
1179 { 1206 {
1180 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type); 1207 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@@ -1302,6 +1329,7 @@ struct native_convert_return_generator
1302 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 1329 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
1303 || ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *" 1330 || ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
1304 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *" 1331 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
1332 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
1305 ) 1333 )
1306 { 1334 {
1307 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type); 1335 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
diff --git a/src/bin/eolian_mono/eolian/mono/type_impl.hh b/src/bin/eolian_mono/eolian/mono/type_impl.hh
index 1028a76ad9..09c4bc198d 100644
--- a/src/bin/eolian_mono/eolian/mono/type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/type_impl.hh
@@ -287,8 +287,6 @@ struct visitor_generate
287 { 287 {
288 (*this)(regular_type_def{" eina.Future", complex.outer.base_qualifier, {}}); 288 (*this)(regular_type_def{" eina.Future", complex.outer.base_qualifier, {}});
289 return attributes::type_def::variant_type(); 289 return attributes::type_def::variant_type();
290 // return replace_outer
291 // (complex, regular_type_def{" ::efl::shared_future", complex.outer.base_qualifier, {}});
292 } 290 }
293 } 291 }
294 , {"iterator", nullptr, nullptr, [&] 292 , {"iterator", nullptr, nullptr, [&]
@@ -300,10 +298,9 @@ struct visitor_generate
300 } 298 }
301 , {"accessor", nullptr, nullptr, [&] 299 , {"accessor", nullptr, nullptr, [&]
302 { 300 {
303 (*this)(regular_type_def{" int", complex.outer.base_qualifier, {}}); 301 complex_type_def c = complex;
304 return attributes::type_def::variant_type(); 302 c.outer.base_type = "eina.Accessor";
305 // return replace_outer 303 return c;
306 // (complex, regular_type_def{" ::efl::eina::accessor", complex.outer.base_qualifier, {}});
307 } 304 }
308 } 305 }
309 }; 306 };
diff --git a/src/bindings/mono/eina_mono/eina_accessor.cs b/src/bindings/mono/eina_mono/eina_accessor.cs
index eab0aebc8c..b3af7cccde 100644
--- a/src/bindings/mono/eina_mono/eina_accessor.cs
+++ b/src/bindings/mono/eina_mono/eina_accessor.cs
@@ -26,6 +26,19 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
26 /// <summary>Who is in charge of releasing the resources wrapped by this instance.</summary> 26 /// <summary>Who is in charge of releasing the resources wrapped by this instance.</summary>
27 private Ownership Ownership { get; set; } 27 private Ownership Ownership { get; set; }
28 28
29 // FIXME Part of the implicit EFL Container interface. Need to make it explicit.
30 public bool Own
31 {
32 get
33 {
34 return Ownership == Ownership.Managed;
35 }
36 set
37 {
38 Ownership = value ? Ownership.Managed : Ownership.Unmanaged;
39 }
40 }
41
29 /// <summary>Create a new accessor wrapping the given pointer.</summary> 42 /// <summary>Create a new accessor wrapping the given pointer.</summary>
30 public Accessor(IntPtr handle, Ownership owner=Ownership.Managed) 43 public Accessor(IntPtr handle, Ownership owner=Ownership.Managed)
31 { 44 {
@@ -33,6 +46,11 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
33 Ownership = owner; 46 Ownership = owner;
34 } 47 }
35 48
49 public Accessor(IntPtr handle, bool own, bool ownContent=false)
50 : this(handle, own ? Ownership.Managed : Ownership.Unmanaged)
51 {
52 }
53
36 /// <summary>Release the native resources held by this instance.</summary> 54 /// <summary>Release the native resources held by this instance.</summary>
37 public void Dispose() 55 public void Dispose()
38 { 56 {
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index db89fb8c4f..997876b52f 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -1,4 +1,5 @@
1using System; 1using System;
2using System.Linq;
2 3
3namespace TestSuite 4namespace TestSuite
4{ 5{
@@ -224,4 +225,25 @@ class TestTypedefs
224 } 225 }
225} 226}
226 227
228class TestEoAccessors
229{
230 public static void basic_eo_accessors()
231 {
232 test.ITesting obj = new test.Testing();
233 eina.List<int> lst = new eina.List<int>();
234 lst.Append(4);
235 lst.Append(3);
236 lst.Append(2);
237 lst.Append(5);
238 eina.Accessor<int> acc = obj.CloneAccessor(lst.GetAccessor());
239
240 var zipped = acc.Zip(lst, (first, second) => new Tuple<int, int>(first, second));
241
242 foreach(Tuple<int, int> pair in zipped)
243 {
244 Test.AssertEquals(pair.Item1, pair.Item2);
245 }
246 }
247}
248
227} 249}
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 085188bcde..346ef2cb2c 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -52,6 +52,7 @@ typedef struct Test_Testing_Data
52 Eo *part1; 52 Eo *part1;
53 Eo *part2; 53 Eo *part2;
54 Eina_Promise *promise; 54 Eina_Promise *promise;
55 Eina_List *list_for_accessor;
55} Test_Testing_Data; 56} Test_Testing_Data;
56 57
57typedef struct Test_Numberwrapper_Data 58typedef struct Test_Numberwrapper_Data
@@ -3841,6 +3842,20 @@ void _test_testing_reject_promise(Eo *obj, Test_Testing_Data *pd, Eina_Error err
3841 eina_promise_reject(pd->promise, err); 3842 eina_promise_reject(pd->promise, err);
3842} 3843}
3843 3844
3845Eina_Accessor *_test_testing_clone_accessor(Eo *obj, Test_Testing_Data *pd, Eina_Accessor *acc)
3846{
3847 if (pd->list_for_accessor)
3848 eina_list_free(pd->list_for_accessor);
3849
3850 unsigned int i;
3851 int *data;
3852 EINA_ACCESSOR_FOREACH(acc, i, data)
3853 {
3854 pd->list_for_accessor = eina_list_append(pd->list_for_accessor, data);
3855 }
3856
3857 return eina_list_accessor_new(pd->list_for_accessor);
3858}
3844 3859
3845#include "test_testing.eo.c" 3860#include "test_testing.eo.c"
3846#include "test_numberwrapper.eo.c" 3861#include "test_numberwrapper.eo.c"
diff --git a/src/tests/efl_mono/test_testing.eo b/src/tests/efl_mono/test_testing.eo
index d19024f435..3b43168c43 100644
--- a/src/tests/efl_mono/test_testing.eo
+++ b/src/tests/efl_mono/test_testing.eo
@@ -1633,6 +1633,14 @@ class Test.Testing (Efl.Object, Efl.Part) {
1633 @in error: Eina.Error; 1633 @in error: Eina.Error;
1634 } 1634 }
1635 } 1635 }
1636
1637 /* Accessors */
1638 clone_accessor {
1639 params {
1640 @in acc: accessor<ptr(int)>;
1641 }
1642 return: accessor<ptr(int)> @owned;
1643 }
1636 } 1644 }
1637 implements { 1645 implements {
1638 class.constructor; 1646 class.constructor;