summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Paulo Taylor Ienczak Zanette <joao.tiz@expertisesolutions.com.br>2020-02-18 19:17:56 +0000
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2020-02-18 16:52:59 -0300
commiteba07471a0cb9baed2204856078f44cc2d31f7d9 (patch)
tree345b85d0e62a8e079592a76df14b9a6554e0c35e
parent595cb754b3aa280cdbebcb5fa0c51f287099b713 (diff)
csharp: Add IntPtr to/from IEnumerable conversion for "accessor" types
Adds a special case for "accessor" complex types in `implicit operator` for structs and `IntPtr`s, in which an IEnumerator must be converted to/from an IntPtr. Reviewed-by: YeongJong Lee <cleanlyj@naver.com> Reviewed-by: Felipe Magno de Almeida <felipe@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D11210
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh15
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_fields.hh7
-rw-r--r--src/tests/efl_mono/StructHelpers.cs16
-rw-r--r--src/tests/efl_mono/Structs.cs44
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo1
5 files changed, 80 insertions, 3 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 6f19088d52..038ab1d0fd 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -90,6 +90,13 @@ struct to_internal_field_convert_generator
90 .generate(sink, std::make_tuple(field_name, field_name), context)) 90 .generate(sink, std::make_tuple(field_name, field_name), context))
91 return false; 91 return false;
92 } 92 }
93 else if ((complex && (complex->outer.base_type == "accessor")))
94 {
95 if (!as_generator(
96 indent << scope_tab << scope_tab << "_internal_struct." << string << " = Efl.Eo.Globals.IEnumerableToAccessor(_external_struct." << string << ", " << (field.type.has_own ? "true" : "false") << ");\n")
97 .generate(sink, std::make_tuple(field_name, field_name), context))
98 return false;
99 }
93 else if ((complex && (complex->outer.base_type == "hash")) 100 else if ((complex && (complex->outer.base_type == "hash"))
94 || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *") 101 || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
95 { 102 {
@@ -172,6 +179,7 @@ struct to_internal_field_convert_generator
172 .generate(sink, std::make_tuple(field_name, field_name), context)) 179 .generate(sink, std::make_tuple(field_name, field_name), context))
173 return false; 180 return false;
174 } 181 }
182
175 return true; 183 return true;
176 } 184 }
177} const to_internal_field_convert {}; 185} const to_internal_field_convert {};
@@ -231,6 +239,13 @@ struct to_external_field_convert_generator
231 .generate(sink, std::make_tuple(field.type, field_name), context)) 239 .generate(sink, std::make_tuple(field.type, field_name), context))
232 return false; 240 return false;
233 } 241 }
242 else if (complex && complex->outer.base_type == "accessor")
243 {
244 if (!as_generator(
245 "Efl.Eo.Globals.AccessorTo" << type << "(" << string << ");")
246 .generate(sink, std::make_tuple(field.type, field_name), context))
247 return false;
248 }
234 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) 249 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
235 { 250 {
236 if (!as_generator( 251 if (!as_generator(
diff --git a/src/bin/eolian_mono/eolian/mono/struct_fields.hh b/src/bin/eolian_mono/eolian/mono/struct_fields.hh
index a9f400bbc5..9d861a0b65 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_fields.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_fields.hh
@@ -103,6 +103,13 @@ struct field_argument_assignment_generator
103 .generate(sink, std::make_tuple(field_name, field_name), context)) 103 .generate(sink, std::make_tuple(field_name, field_name), context))
104 return false; 104 return false;
105 } 105 }
106 else if ((complex && (complex->outer.base_type == "accessor")))
107 {
108 if (!as_generator(
109 "this." << string << " = Efl.Eo.Globals.IEnumerableToAccessor(" << string << ", " << (field.type.has_own ? "true" : "false") << ");\n")
110 .generate(sink, std::make_tuple(field_name, field_name), context))
111 return false;
112 }
106 else if ((complex && (complex->outer.base_type == "hash")) 113 else if ((complex && (complex->outer.base_type == "hash"))
107 || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *") 114 || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
108 { 115 {
diff --git a/src/tests/efl_mono/StructHelpers.cs b/src/tests/efl_mono/StructHelpers.cs
index 0ce836a332..b6ceac4bd8 100644
--- a/src/tests/efl_mono/StructHelpers.cs
+++ b/src/tests/efl_mono/StructHelpers.cs
@@ -151,6 +151,7 @@ internal class StructHelpers
151 Fhash["cc"] = "ccc"; 151 Fhash["cc"] = "ccc";
152 152
153 var Fiterator = ((Eina.Array<string>)Farray).GetIterator(); 153 var Fiterator = ((Eina.Array<string>)Farray).GetIterator();
154 var Faccessor = ((Eina.Array<string>)Farray).GetAccessor();
154 155
155 var Fany_value = new Eina.Value(Eina.ValueType.Double); 156 var Fany_value = new Eina.Value(Eina.ValueType.Double);
156 Fany_value.Set(-9007199254740992.0); 157 Fany_value.Set(-9007199254740992.0);
@@ -167,9 +168,18 @@ internal class StructHelpers
167 var Fobj = new Dummy.Numberwrapper(); 168 var Fobj = new Dummy.Numberwrapper();
168 Fobj.Number = 42; 169 Fobj.Number = 42;
169 170
170 return new Dummy.StructComplex(farray: Farray, flist: Flist, fhash: Fhash, 171 return new Dummy.StructComplex(
171 fiterator: Fiterator, fanyValue:Fany_value, fanyValueRef: Fany_value_ref, 172 farray: Farray,
172 fbinbuf: Fbinbuf, fslice:Fslice, fobj: Fobj); 173 flist: Flist,
174 fhash: Fhash,
175 fiterator: Fiterator,
176 faccessor: Faccessor,
177 fanyValue:Fany_value,
178 fanyValueRef: Fany_value_ref,
179 fbinbuf: Fbinbuf,
180 fslice:Fslice,
181 fobj: Fobj
182 );
173 } 183 }
174 184
175 internal static void checkStructComplex(Dummy.StructComplex complex) 185 internal static void checkStructComplex(Dummy.StructComplex complex)
diff --git a/src/tests/efl_mono/Structs.cs b/src/tests/efl_mono/Structs.cs
index e110f2f15a..151bc8388d 100644
--- a/src/tests/efl_mono/Structs.cs
+++ b/src/tests/efl_mono/Structs.cs
@@ -349,6 +349,50 @@ internal class TestStructs
349 t.Dispose(); 349 t.Dispose();
350 } 350 }
351 351
352 public static void complex_iterator_retrieves_list_correctly()
353 {
354 var complex = structComplexWithValues();
355
356 var i = 0;
357 foreach (var elm in complex.Fiterator) {
358 Test.AssertEquals(elm, complex.Flist[i]);
359 i++;
360 }
361 }
362
363 public static void complex_iterator_retrieves_array_correctly()
364 {
365 var complex = structComplexWithValues();
366
367 var i = 0;
368 foreach (var elm in complex.Fiterator) {
369 Test.AssertEquals(elm, complex.Farray[i]);
370 i++;
371 }
372 }
373
374 public static void complex_accessor_retrieves_list_correctly()
375 {
376 var complex = structComplexWithValues();
377
378 var i = 0;
379 foreach (var elm in complex.Faccessor) {
380 Test.AssertEquals(elm, complex.Flist[i]);
381 i++;
382 }
383 }
384
385 public static void complex_accessor_retrieves_array_correctly()
386 {
387 var complex = structComplexWithValues();
388
389 var i = 0;
390 foreach (var elm in complex.Faccessor) {
391 Test.AssertEquals(elm, complex.Farray[i]);
392 i++;
393 }
394 }
395
352 // public static void complex_ptr_out() 396 // public static void complex_ptr_out()
353 // { 397 // {
354 // } 398 // }
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index 39cc258a14..fa3b52cace 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -79,6 +79,7 @@ struct @beta @free(free) Dummy.StructComplex {
79 flist: list<string>; 79 flist: list<string>;
80 fhash: hash<string, string>; 80 fhash: hash<string, string>;
81 fiterator: iterator<string>; 81 fiterator: iterator<string>;
82 faccessor: accessor<string>;
82 fany_value: any_value; 83 fany_value: any_value;
83 fany_value_ref: any_value_ref; 84 fany_value_ref: any_value_ref;
84 fbinbuf: binbuf; 85 fbinbuf: binbuf;