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)
downloadefl-eba07471a0cb9baed2204856078f44cc2d31f7d9.tar.gz
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
.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;