felipealmeida pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=eba07471a0cb9baed2204856078f44cc2d31f7d9

commit eba07471a0cb9baed2204856078f44cc2d31f7d9
Author: João Paulo Taylor Ienczak Zanette <joao....@expertisesolutions.com.br>
Date:   Tue Feb 18 19:17:56 2020 +0000

    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 <clean...@naver.com>
    Reviewed-by: Felipe Magno de Almeida <fel...@expertisesolutions.com.br>
    Differential Revision: https://phab.enlightenment.org/D11210
---
 .../eolian_mono/eolian/mono/struct_definition.hh   | 15 ++++++++
 src/bin/eolian_mono/eolian/mono/struct_fields.hh   |  7 ++++
 src/tests/efl_mono/StructHelpers.cs                | 16 ++++++--
 src/tests/efl_mono/Structs.cs                      | 44 ++++++++++++++++++++++
 src/tests/efl_mono/dummy_test_object.eo            |  1 +
 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
                .generate(sink, std::make_tuple(field_name, field_name), 
context))
              return false;
         }
+      else if ((complex && (complex->outer.base_type == "accessor")))
+        {
+           if (!as_generator(
+                 indent << scope_tab << scope_tab << "_internal_struct." << 
string << " = Efl.Eo.Globals.IEnumerableToAccessor(_external_struct." << string 
<< ", " << (field.type.has_own ? "true" : "false")  << ");\n")
+               .generate(sink, std::make_tuple(field_name, field_name), 
context))
+             return false;
+        }
       else if ((complex && (complex->outer.base_type == "hash"))
             || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == 
"const Eina_Binbuf *")
         {
@@ -172,6 +179,7 @@ struct to_internal_field_convert_generator
                .generate(sink, std::make_tuple(field_name, field_name), 
context))
              return false;
         }
+
       return true;
    }
 } const to_internal_field_convert {};
@@ -231,6 +239,13 @@ struct to_external_field_convert_generator
                .generate(sink, std::make_tuple(field.type, field_name), 
context))
              return false;
         }
+      else if (complex && complex->outer.base_type == "accessor")
+        {
+           if (!as_generator(
+                 "Efl.Eo.Globals.AccessorTo" << type << "(" << string << ");")
+               .generate(sink, std::make_tuple(field.type, field_name), 
context))
+             return false;
+        }
       else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) 
&& !helpers::need_struct_conversion(regular))
         {
            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
                .generate(sink, std::make_tuple(field_name, field_name), 
context))
              return false;
         }
+      else if ((complex && (complex->outer.base_type == "accessor")))
+        {
+           if (!as_generator(
+                 "this." << string << " = 
Efl.Eo.Globals.IEnumerableToAccessor(" << string << ", " << (field.type.has_own 
? "true" : "false")  << ");\n")
+               .generate(sink, std::make_tuple(field_name, field_name), 
context))
+             return false;
+        }
       else if ((complex && (complex->outer.base_type == "hash"))
             || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == 
"const Eina_Binbuf *")
         {
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
         Fhash["cc"] = "ccc";
 
         var Fiterator = ((Eina.Array<string>)Farray).GetIterator();
+        var Faccessor = ((Eina.Array<string>)Farray).GetAccessor();
 
         var Fany_value = new Eina.Value(Eina.ValueType.Double);
         Fany_value.Set(-9007199254740992.0);
@@ -167,9 +168,18 @@ internal class StructHelpers
         var Fobj = new Dummy.Numberwrapper();
         Fobj.Number = 42;
 
-        return new Dummy.StructComplex(farray: Farray, flist: Flist, fhash: 
Fhash,
-            fiterator: Fiterator, fanyValue:Fany_value, fanyValueRef: 
Fany_value_ref,
-            fbinbuf: Fbinbuf, fslice:Fslice, fobj: Fobj);
+        return new Dummy.StructComplex(
+            farray: Farray,
+            flist: Flist,
+            fhash: Fhash,
+            fiterator: Fiterator,
+            faccessor: Faccessor,
+            fanyValue:Fany_value,
+            fanyValueRef: Fany_value_ref,
+            fbinbuf: Fbinbuf,
+            fslice:Fslice,
+            fobj: Fobj
+        );
     }
 
     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
         t.Dispose();
     }
 
+    public static void complex_iterator_retrieves_list_correctly()
+    {
+        var complex = structComplexWithValues();
+
+        var i = 0;
+        foreach (var elm in complex.Fiterator) {
+            Test.AssertEquals(elm, complex.Flist[i]);
+            i++;
+        }
+    }
+
+    public static void complex_iterator_retrieves_array_correctly()
+    {
+        var complex = structComplexWithValues();
+
+        var i = 0;
+        foreach (var elm in complex.Fiterator) {
+            Test.AssertEquals(elm, complex.Farray[i]);
+            i++;
+        }
+    }
+
+    public static void complex_accessor_retrieves_list_correctly()
+    {
+        var complex = structComplexWithValues();
+
+        var i = 0;
+        foreach (var elm in complex.Faccessor) {
+            Test.AssertEquals(elm, complex.Flist[i]);
+            i++;
+        }
+    }
+
+    public static void complex_accessor_retrieves_array_correctly()
+    {
+        var complex = structComplexWithValues();
+
+        var i = 0;
+        foreach (var elm in complex.Faccessor) {
+            Test.AssertEquals(elm, complex.Farray[i]);
+            i++;
+        }
+    }
+
     // public static void complex_ptr_out()
     // {
     // }
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 {
    flist: list<string>;
    fhash: hash<string, string>;
    fiterator: iterator<string>;
+   faccessor: accessor<string>;
    fany_value: any_value;
    fany_value_ref: any_value_ref;
    fbinbuf: binbuf;

-- 


Reply via email to