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
This commit is contained in:
parent
595cb754b3
commit
eba07471a0
|
@ -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(
|
||||
|
|
|
@ -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 *")
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
// {
|
||||
// }
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue