forked from enlightenment/efl
csharp: add move information to EnumerableToAccessor
Still need to fix the converted accessor ownership, maybe by creating a custom accessor class that released the pinned memory when is freed.
This commit is contained in:
parent
c9ca2833b8
commit
ed6679db19
|
@ -770,7 +770,7 @@ struct convert_in_variable_generator
|
||||||
return false;
|
return false;
|
||||||
auto var_name = in_variable_name(param.param_name);
|
auto var_name = in_variable_name(param.param_name);
|
||||||
if (!as_generator(
|
if (!as_generator(
|
||||||
"var " << string << " = " << "Efl.Eo.Globals.IEnumerableToAccessor(" << escape_keyword(param.param_name) << ");\n"
|
"var " << string << " = Efl.Eo.Globals.IEnumerableToAccessor(" << escape_keyword(param.param_name) << ", " << (param.type.has_own ? "true" : "false")<< ");\n"
|
||||||
).generate(sink, var_name, context))
|
).generate(sink, var_name, context))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1314,7 +1314,7 @@ struct native_convert_out_assign_generator
|
||||||
return false;
|
return false;
|
||||||
auto outvar = out_variable_name(param.param_name);
|
auto outvar = out_variable_name(param.param_name);
|
||||||
if (!as_generator(
|
if (!as_generator(
|
||||||
string << " = Efl.Eo.Globals.IEnumerableToAccessor(" << string << ");\n"
|
string << " = Efl.Eo.Globals.IEnumerableToAccessor(" << string << ", " << (param.type.has_own ? "true" : "false")<< ");\n"
|
||||||
).generate(sink, std::make_tuple(escape_keyword(param.param_name), outvar), context))
|
).generate(sink, std::make_tuple(escape_keyword(param.param_name), outvar), context))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1469,7 +1469,7 @@ struct native_convert_return_generator
|
||||||
}
|
}
|
||||||
else if (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 *")
|
||||||
{
|
{
|
||||||
return as_generator("return Efl.Eo.Globals.IEnumerableToAccessor(_ret_var);")
|
return as_generator(lit("return Efl.Eo.Globals.IEnumerableToAccessor(_ret_var, ") << (ret_type.has_own ? "true" : "false") << ");")
|
||||||
.generate(sink, attributes::unused, context);
|
.generate(sink, attributes::unused, context);
|
||||||
}
|
}
|
||||||
else if (ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *")
|
else if (ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *")
|
||||||
|
|
|
@ -774,10 +774,26 @@ public static class Globals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IntPtr IEnumerableToAccessor<T>(IEnumerable<T> enumerable)
|
internal static IntPtr IEnumerableToAccessor<T>(IEnumerable<T> enumerable, bool isMoved)
|
||||||
{
|
{
|
||||||
if (enumerable == null)
|
if (enumerable == null)
|
||||||
|
{
|
||||||
throw new ArgumentException("enumerable is null", nameof(enumerable));
|
throw new ArgumentException("enumerable is null", nameof(enumerable));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are a wrapper around an existing Eina.Accessor, we can just forward
|
||||||
|
// it and avoid unnecessary copying.
|
||||||
|
var wrappedAccessor = enumerable as Eina.Accessor<T>;
|
||||||
|
|
||||||
|
if (wrappedAccessor != null)
|
||||||
|
{
|
||||||
|
if (isMoved)
|
||||||
|
{
|
||||||
|
wrappedAccessor.Own = false;
|
||||||
|
}
|
||||||
|
return wrappedAccessor.Handle;
|
||||||
|
}
|
||||||
|
|
||||||
IntPtr[] intPtrs = new IntPtr[enumerable.Count()];
|
IntPtr[] intPtrs = new IntPtr[enumerable.Count()];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
Loading…
Reference in New Issue