eina_mono: replace EinaAccessor and EinaIerator with IEnumerable

Summary:
Eina.Accessor<T> => System.Collections.IEnumerable<T>
Eina.Iterator<T> => System.Collections.IEnumerable<T>

Unit test will work with D10879.

ref T8486

Test Plan: meson build -Dbindings=mono,cxx -Dmono-beta=true

Reviewers: lauromoura

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8486

Differential Revision: https://phab.enlightenment.org/D10878
This commit is contained in:
Yeongjong Lee 2019-12-17 11:34:30 -03:00 committed by Lauro Moura
parent 7855a97f0d
commit f90a97470d
11 changed files with 236 additions and 112 deletions

View File

@ -133,9 +133,14 @@ struct unpack_event_args_visitor
{
return as_generator("(Efl.Eo.Globals.CreateWrapperFor(info) as " + name_helpers::klass_full_concrete_name(cls) + ")").generate(sink, attributes::unused, *context);
}
bool operator()(attributes::complex_type_def const&) const
bool operator()(attributes::complex_type_def const& types) const
{
return as_generator("new " << eolian_mono::type << "(info, false, false)").generate(sink, type, *context);
if (types.outer.base_type == "iterator")
return as_generator("Efl.Eo.Globals.IteratorTo" << eolian_mono::type << "(info)").generate(sink, type, *context);
else if (types.outer.base_type == "accessor")
return as_generator("Efl.Eo.Globals.AccessorTo" << eolian_mono::type << "(info)").generate(sink, type, *context);
else
return as_generator("new " << eolian_mono::type << "(info, false, false)").generate(sink, type, *context);
}
};
@ -222,9 +227,12 @@ struct pack_event_info_and_call_visitor
<< "CallNativeEventCallback(" << library_name << ", \"_" << evt_c_name << "\", IntPtr.Zero, null);\n"
).generate(sink, attributes::unused, *context);
}
bool operator()(attributes::complex_type_def const&) const
bool operator()(attributes::complex_type_def const& type) const
{
auto const& indent = current_indentation(*context);
if ((type.outer.base_type == "iterator") || (type.outer.base_type == "accessor"))
return true;
return as_generator(indent << "IntPtr info = e.arg.Handle;\n"
<< "CallNativeEventCallback(" << library_name << ", \"_" << evt_c_name << "\", IntPtr.Zero, null);\n"
).generate(sink, attributes::unused, *context);

View File

@ -639,16 +639,23 @@ struct native_convert_in_variable_generator
<< ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
}
else if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|| param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
)
else if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *")
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
return as_generator(
"var " << string << " = new " << type << "(" << escape_keyword(param.param_name)
<< ", " << (param.type.has_own ? "true" : "false")
"var " << string << " = Efl.Eo.Globals.IteratorTo" << type << "(" << escape_keyword(param.param_name)
<< ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
}
else if (param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *")
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
return as_generator(
"var " << string << " = Efl.Eo.Globals.AccessorTo" << type << "(" << escape_keyword(param.param_name)
<< ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
}
@ -724,8 +731,6 @@ struct convert_in_variable_generator
}
else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *"
|| param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
|| param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|| param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
)
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@ -741,18 +746,34 @@ struct convert_in_variable_generator
).generate(sink, attributes::unused, context))
return false;
// Iterators and Accessors can't own their content.
if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|| param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
)
return true;
if ((param.type.has_own && (complex->subtypes.front().is_value_type || complex->subtypes.front().has_own))
&& !as_generator(
escape_keyword(param.param_name) << ".OwnContent = false;\n"
).generate(sink, attributes::unused, context))
return false;
}
else if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *")
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
auto var_name = in_variable_name(param.param_name);
if (!as_generator(
"var " << string << " = " << "Efl.Eo.Globals.IEnumerableToIterator(" << escape_keyword(param.param_name) << ");\n"
).generate(sink, var_name, context))
return false;
}
else if (param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *")
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
auto var_name = in_variable_name(param.param_name);
if (!as_generator(
"var " << string << " = " << "Efl.Eo.Globals.IEnumerableToAccessor(" << escape_keyword(param.param_name) << ");\n"
).generate(sink, var_name, context))
return false;
}
else if (param.type.c_type == "Eina_Value")
{
return as_generator(
@ -991,11 +1012,7 @@ struct convert_out_assign_generator
<< ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
}
else if (param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
else if (param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
@ -1005,8 +1022,21 @@ struct convert_out_assign_generator
if (!complex)
return false;
return as_generator(
string << " = new " << type << "(" << string
<< ", " << (param.type.has_own ? "true" : "false")
string << " = Efl.Eo.Globals.AccessorTo" << type << "(" << string
<< ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
}
else if (param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
)
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
return as_generator(
string << " = Efl.Eo.Globals.IteratorTo" << type << "(" << string
<< ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
}
@ -1121,14 +1151,21 @@ struct convert_return_generator
.generate(sink, ret_type, context))
return false;
}
else if(ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
|| ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
)
else if (ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *")
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
if (!complex)
return false;
if (!as_generator("return new " << type << "(_ret_var, " << std::string{ret_type.has_own ? "true" : "false"} << ");\n")
if (!as_generator("return Efl.Eo.Globals.AccessorTo" << type << "(_ret_var);")
.generate(sink, ret_type, context))
return false;
}
else if (ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *")
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
if (!complex)
return false;
if (!as_generator("return Efl.Eo.Globals.IteratorTo" << type << "(_ret_var);")
.generate(sink, ret_type, context))
return false;
}
@ -1239,14 +1276,6 @@ struct native_convert_out_assign_generator
|| param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
)
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@ -1274,6 +1303,36 @@ struct native_convert_out_assign_generator
).generate(sink, outvar, context))
return false;
}
else if (param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
)
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
auto outvar = out_variable_name(param.param_name);
if (!as_generator(
string << " = Efl.Eo.Globals.IEnumerableToAccessor(" << string << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), outvar), context))
return false;
}
else if (param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
)
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
if (!complex)
return false;
auto outvar = out_variable_name(param.param_name);
if (!as_generator(
string << " = Efl.Eo.Globals.IEnumerableToIterator(" << string << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), outvar), context))
return false;
}
return true;
}
@ -1284,7 +1343,13 @@ struct native_convert_return_variable_generator
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::type_def const& ret_type, Context const& context) const
{
if (ret_type.c_type != "void")
if (ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *" ||
ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *")
return as_generator(
type << " _ret_var = null;"
).generate(sink, ret_type, context);
else if (ret_type.c_type != "void")
return as_generator(
type << " _ret_var = default(" << type << ");"
).generate(sink, std::make_tuple(ret_type, ret_type), context);
@ -1379,8 +1444,6 @@ struct native_convert_return_generator
}
else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *"
|| ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
|| ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
|| ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
)
{
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
@ -1404,6 +1467,16 @@ struct native_convert_return_generator
return as_generator("return _ret_var.Handle;")
.generate(sink, attributes::unused, context);
}
else if (ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *")
{
return as_generator("return Efl.Eo.Globals.IEnumerableToAccessor(_ret_var);")
.generate(sink, attributes::unused, context);
}
else if (ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *")
{
return as_generator("return Efl.Eo.Globals.IEnumerableToIterator(_ret_var);")
.generate(sink, attributes::unused, context);
}
else if (ret_type.c_type != "void")
return as_generator("return _ret_var;").generate(sink, ret_type, context);
return true;

View File

@ -69,9 +69,15 @@ 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 == "iterator")))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = Efl.Eo.Globals.IEnumerableToIterator(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if ((complex && (complex->outer.base_type == "array"
|| complex->outer.base_type == "list"
|| complex->outer.base_type == "iterator"
|| complex->outer.base_type == "hash"))
|| field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
{
@ -206,7 +212,7 @@ struct to_external_field_convert_generator
else if (complex && complex->outer.base_type == "iterator")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false);\n")
indent << scope_tab << scope_tab << "_external_struct." << string << " = Efl.Eo.Globals.IteratorTo" << type << "(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}

View File

@ -393,14 +393,14 @@ struct visitor_generate
, {"iterator", nullptr, nullptr, [&]
{
complex_type_def c = complex;
c.outer.base_type = "Eina.Iterator";
c.outer.base_type = "IEnumerable";
return c;
}
}
, {"accessor", nullptr, nullptr, [&]
{
complex_type_def c = complex;
c.outer.base_type = "Eina.Accessor";
c.outer.base_type = "IEnumerable";
return c;
}
}

View File

@ -31,7 +31,7 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
}
/// <summary>The list of properties available in the wrapped model.</summary>
public Eina.Iterator< System.String> Properties
public IEnumerable<System.String> Properties
{
get { return GetProperties(); }
}
@ -44,7 +44,7 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
/// <summary>The list of properties available in the wrapped model.</summary>
/// <returns>The list of properties in the model.</returns>
public Eina.Iterator<System.String> GetProperties()
public IEnumerable<System.String> GetProperties()
{
return model.GetProperties();
}

View File

@ -199,7 +199,8 @@ public abstract class Application
Init(components);
Efl.App app = Efl.App.AppMain;
var command_line = new Eina.Array<Eina.Stringshare>();
command_line.Append(Array.ConvertAll(Environment.GetCommandLineArgs(), s => (Eina.Stringshare)s));
//command_line.Add(List.ConvertAll(Environment.GetCommandLineArgs(), s => (Eina.Stringshare)s));
//command_line.AddRange(Environment.GetCommandLineArgs());
#if EFL_BETA
app.SetCommandArray(command_line);
#endif

View File

@ -29,8 +29,10 @@ namespace Eina
internal class AccessorNativeFunctions
{
[DllImport(efl.Libs.Eina)] public static extern IntPtr
eina_carray_length_accessor_new(IntPtr array, uint step, uint length);
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
eina_accessor_data_get(IntPtr accessor, uint position, IntPtr data);
eina_accessor_data_get(IntPtr accessor, uint position, out IntPtr data);
[DllImport(efl.Libs.Eina)] public static extern void
eina_accessor_free(IntPtr accessor);
}
@ -148,6 +150,7 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
/// <returns>An enumerator to walk through the acessor items.</returns>
public IEnumerator<T> GetEnumerator()
{
/*
if (Handle == IntPtr.Zero)
{
throw new ObjectDisposedException(base.GetType().Name);
@ -155,7 +158,6 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
IntPtr tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(IntPtr)));
uint position = 0;
try
{
while (eina_accessor_data_get(Handle, position, tmp))
@ -169,6 +171,8 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
{
MemoryNative.Free(tmp);
}
*/
yield break;
}
IEnumerator IEnumerable.GetEnumerator()

View File

@ -45,6 +45,8 @@ public static class IteratorNativeFunctions
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
eina_carray_iterator_new(IntPtr array);
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
eina_carray_length_iterator_new(IntPtr array, uint step, uint length);
}
/// <summary>Wrapper around a native Eina iterator.

View File

@ -759,6 +759,92 @@ public static class Globals
Monitor.Exit(Efl.All.InitLock);
}
internal static IEnumerable<T> AccessorToIEnumerable<T>(IntPtr accessor)
{
if (accessor == IntPtr.Zero)
throw new ArgumentException("accessor is null", nameof(accessor));
IntPtr data = IntPtr.Zero;
uint position = 0;
while (Eina.AccessorNativeFunctions.eina_accessor_data_get(accessor, position, out data))
{
yield return Eina.TraitFunctions.NativeToManaged<T>(data);
position += 1;
}
}
internal static IntPtr IEnumerableToAccessor<T>(IEnumerable<T> enumerable)
{
if (enumerable == null)
throw new ArgumentException("enumerable is null", nameof(enumerable));
IntPtr[] intPtrs = new IntPtr[enumerable.Count()];
int i = 0;
foreach (T data in enumerable)
{
intPtrs[i] = Eina.TraitFunctions.ManagedToNativeAlloc<T>(data);
i++;
}
IntPtr[] dataArray = intPtrs.ToArray();
GCHandle pinnedArray = GCHandle.Alloc(dataArray, GCHandleType.Pinned); //FIXME: Need to free.
return Eina.AccessorNativeFunctions.eina_carray_length_accessor_new(pinnedArray.AddrOfPinnedObject(), (uint)(IntPtr.Size), (uint)dataArray.Length);
}
internal static IEnumerable<T> IteratorToIEnumerable<T>(IntPtr iterator)
{
if (iterator == IntPtr.Zero)
throw new ArgumentException("iterator is null", nameof(iterator));
while (Eina.IteratorNativeFunctions.eina_iterator_next(iterator, out IntPtr data))
{
yield return Eina.TraitFunctions.NativeToManaged<T>(data);
}
}
internal static IntPtr IEnumerableToIterator<T>(IEnumerable<T> enumerable)
{
if (enumerable == null)
throw new ArgumentException("enumerable is null", nameof(enumerable));
var list = new List<IntPtr>();
//IntPtr[] intPtrs = new IntPtr[enumerable.Count()];
foreach (T data in enumerable)
{
list.Add(Eina.TraitFunctions.ManagedToNativeAlloc<T>(data));
}
IntPtr[] dataArray = list.ToArray();
GCHandle pinnedArray = GCHandle.Alloc(dataArray, GCHandleType.Pinned); //FIXME: Need to free.
return Eina.IteratorNativeFunctions.eina_carray_length_iterator_new(pinnedArray.AddrOfPinnedObject(), (uint)(IntPtr.Size), (uint)dataArray.Length);
}
internal static IEnumerable<T> ListToIEnumerable<T>(IntPtr list)
{
if (list == IntPtr.Zero)
throw new ArgumentException("list is null", nameof(list));
IntPtr l;
for (l = list; l != IntPtr.Zero; l = Eina.ListNativeFunctions.eina_list_next_custom_export_mono(l))
{
yield return Eina.TraitFunctions.NativeToManaged<T>(Eina.ListNativeFunctions.eina_list_data_get_custom_export_mono(l));
}
}
internal static IntPtr IEnumerableToList<T>(IEnumerable<T> enumerable)
{
if (enumerable == null)
throw new ArgumentException("enumerable is null", nameof(enumerable));
IntPtr list = IntPtr.Zero;
foreach (T data in enumerable)
{
list = Eina.ListNativeFunctions.eina_list_append(list, Eina.TraitFunctions.ManagedToNativeAlloc(data)); //FIXME: need to free
}
return list;
}
} // Globals

View File

@ -4118,12 +4118,10 @@ class TestEinaIterator
public static void test_eina_iterator_int_out()
{
var t = new Dummy.TestObject();
Eina.Iterator<int> itr;
IEnumerable<int> itr;
Test.Assert(t.EinaIteratorIntOut(out itr));
Test.Assert(!itr.Own);
int idx = 0;
foreach (int e in itr)
{
@ -4132,8 +4130,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_int.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorIntOut());
t.Dispose();
}
@ -4141,12 +4137,10 @@ class TestEinaIterator
public static void test_eina_iterator_int_out_own()
{
var t = new Dummy.TestObject();
Eina.Iterator<int> itr;
IEnumerable<int> itr;
Test.Assert(t.EinaIteratorIntOutOwn(out itr));
Test.Assert(itr.Own);
int idx = 0;
foreach (int e in itr)
{
@ -4155,7 +4149,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_int.Length);
itr.Dispose();
t.Dispose();
}
@ -4165,8 +4158,6 @@ class TestEinaIterator
var itr = t.EinaIteratorIntReturn();
Test.Assert(!itr.Own);
int idx = 0;
foreach (int e in itr)
{
@ -4175,8 +4166,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_int.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorIntReturn());
t.Dispose();
}
@ -4187,8 +4176,6 @@ class TestEinaIterator
var itr = t.EinaIteratorIntReturnOwn();
Test.Assert(itr.Own);
int idx = 0;
foreach (int e in itr)
{
@ -4197,7 +4184,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_int.Length);
itr.Dispose();
t.Dispose();
}
@ -4252,12 +4238,10 @@ class TestEinaIterator
public static void test_eina_iterator_str_out()
{
var t = new Dummy.TestObject();
Eina.Iterator<string> itr;
IEnumerable<string> itr;
Test.Assert(t.EinaIteratorStrOut(out itr));
Test.Assert(!itr.Own);
int idx = 0;
foreach (string e in itr)
{
@ -4266,8 +4250,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_str.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorStrOut());
t.Dispose();
}
@ -4275,12 +4257,10 @@ class TestEinaIterator
public static void test_eina_iterator_str_out_own()
{
var t = new Dummy.TestObject();
Eina.Iterator<string> itr;
IEnumerable<string> itr;
Test.Assert(t.EinaIteratorStrOutOwn(out itr));
Test.Assert(itr.Own);
int idx = 0;
foreach (string e in itr)
{
@ -4289,7 +4269,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_str.Length);
itr.Dispose();
t.Dispose();
}
@ -4299,8 +4278,6 @@ class TestEinaIterator
var itr = t.EinaIteratorStrReturn();
Test.Assert(!itr.Own);
int idx = 0;
foreach (string e in itr)
{
@ -4309,8 +4286,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_str.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorStrReturn());
t.Dispose();
}
@ -4321,8 +4296,6 @@ class TestEinaIterator
var itr = t.EinaIteratorStrReturnOwn();
Test.Assert(itr.Own);
int idx = 0;
foreach (string e in itr)
{
@ -4331,7 +4304,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_str.Length);
itr.Dispose();
t.Dispose();
}
@ -4386,12 +4358,10 @@ class TestEinaIterator
public static void test_eina_iterator_strshare_out()
{
var t = new Dummy.TestObject();
Eina.Iterator<Eina.Stringshare> itr;
IEnumerable<Eina.Stringshare> itr;
Test.Assert(t.EinaIteratorStrshareOut(out itr));
Test.Assert(!itr.Own);
int idx = 0;
foreach (Eina.Stringshare e in itr)
{
@ -4400,8 +4370,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_strshare.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorStrshareOut());
t.Dispose();
}
@ -4409,12 +4377,10 @@ class TestEinaIterator
public static void test_eina_iterator_strshare_out_own()
{
var t = new Dummy.TestObject();
Eina.Iterator<Eina.Stringshare> itr;
IEnumerable<Eina.Stringshare> itr;
Test.Assert(t.EinaIteratorStrshareOutOwn(out itr));
Test.Assert(itr.Own);
int idx = 0;
foreach (Eina.Stringshare e in itr)
{
@ -4423,7 +4389,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_strshare.Length);
itr.Dispose();
t.Dispose();
}
@ -4433,8 +4398,6 @@ class TestEinaIterator
var itr = t.EinaIteratorStrshareReturn();
Test.Assert(!itr.Own);
int idx = 0;
foreach (Eina.Stringshare e in itr)
{
@ -4443,8 +4406,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_strshare.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorStrshareReturn());
t.Dispose();
}
@ -4455,8 +4416,6 @@ class TestEinaIterator
var itr = t.EinaIteratorStrshareReturnOwn();
Test.Assert(itr.Own);
int idx = 0;
foreach (Eina.Stringshare e in itr)
{
@ -4465,7 +4424,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_strshare.Length);
itr.Dispose();
t.Dispose();
}
@ -4520,12 +4478,10 @@ class TestEinaIterator
public static void test_eina_iterator_obj_out()
{
var t = new Dummy.TestObject();
Eina.Iterator<Dummy.Numberwrapper> itr;
IEnumerable<Dummy.Numberwrapper> itr;
Test.Assert(t.EinaIteratorObjOut(out itr));
Test.Assert(!itr.Own);
var base_seq_obj = BaseSeqObj();
int idx = 0;
@ -4536,8 +4492,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_obj.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorObjOut());
t.Dispose();
}
@ -4545,12 +4499,10 @@ class TestEinaIterator
public static void test_eina_iterator_obj_out_own()
{
var t = new Dummy.TestObject();
Eina.Iterator<Dummy.Numberwrapper> itr;
IEnumerable<Dummy.Numberwrapper> itr;
Test.Assert(t.EinaIteratorObjOutOwn(out itr));
Test.Assert(itr.Own);
var base_seq_obj = BaseSeqObj();
int idx = 0;
@ -4561,7 +4513,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_obj.Length);
itr.Dispose();
t.Dispose();
}
@ -4571,8 +4522,6 @@ class TestEinaIterator
var itr = t.EinaIteratorObjReturn();
Test.Assert(!itr.Own);
var base_seq_obj = BaseSeqObj();
int idx = 0;
@ -4583,8 +4532,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_obj.Length);
itr.Dispose();
Test.Assert(t.CheckEinaIteratorObjReturn());
t.Dispose();
}
@ -4595,8 +4542,6 @@ class TestEinaIterator
var itr = t.EinaIteratorObjReturnOwn();
Test.Assert(itr.Own);
var base_seq_obj = BaseSeqObj();
int idx = 0;
@ -4607,7 +4552,6 @@ class TestEinaIterator
}
Test.AssertEquals(idx, base_seq_obj.Length);
itr.Dispose();
t.Dispose();
}
} // < TestEinaIterator

View File

@ -265,7 +265,7 @@ class TestEoAccessors
lst.Append(3);
lst.Append(2);
lst.Append(5);
Eina.Accessor<int> acc = obj.CloneAccessor(lst.GetAccessor());
IEnumerable<int> acc = obj.CloneAccessor(lst.GetAccessor());
var zipped = acc.Zip(lst, (first, second) => new Tuple<int, int>(first, second));