summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-03 09:50:21 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-03 18:07:05 -0300
commit3cbe4d3e7ce01e0c56c8b7568300a95ab5a9c299 (patch)
tree1060dce5f7f7002812285a3afb67c8e0d737c34d
parent59698f0e227c54719dcb799da2c76d20847317aa (diff)
downloadefl-3cbe4d3e7ce01e0c56c8b7568300a95ab5a9c299.tar.gz
csharp: Add ownership info to AccessorToIEnumerable
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh8
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs9
2 files changed, 11 insertions, 6 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index b6e4f32aea..37cb0d7ed7 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -655,8 +655,7 @@ struct native_convert_in_variable_generator
if (!complex)
return false;
return as_generator(
- "var " << string << " = Efl.Eo.Globals.AccessorTo" << type << "(" << escape_keyword(param.param_name)
- << ");\n"
+ "var " << string << " = Efl.Eo.Globals.AccessorTo" << type << "(" << escape_keyword(param.param_name) << ", " << (param.type.has_own ? "true" : "false") << ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
}
else if (param.type.c_type == "Eina_Value")
@@ -1022,8 +1021,7 @@ struct convert_out_assign_generator
if (!complex)
return false;
return as_generator(
- string << " = Efl.Eo.Globals.AccessorTo" << type << "(" << string
- << ");\n"
+ string << " = Efl.Eo.Globals.AccessorTo" << type << "(" << string << ", " << (param.type.has_own ? "true" : "false") << ");\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)
@@ -1156,7 +1154,7 @@ struct convert_return_generator
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.AccessorTo" << type << "(_ret_var);")
+ if (!as_generator("return Efl.Eo.Globals.AccessorTo" << type << "(_ret_var, " << (ret_type.has_own ? "true" : "false") << ");")
.generate(sink, ret_type, context))
return false;
}
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index fce2549238..c9e5992506 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -759,10 +759,12 @@ public static class Globals
Monitor.Exit(Efl.All.InitLock);
}
- internal static IEnumerable<T> AccessorToIEnumerable<T>(IntPtr accessor)
+ internal static IEnumerable<T> AccessorToIEnumerable<T>(IntPtr accessor, bool isMoved)
{
if (accessor == IntPtr.Zero)
+ {
throw new ArgumentException("accessor is null", nameof(accessor));
+ }
IntPtr data = IntPtr.Zero;
uint position = 0;
@@ -772,6 +774,11 @@ public static class Globals
yield return Eina.TraitFunctions.NativeToManaged<T>(data);
position += 1;
}
+
+ if (isMoved)
+ {
+ Eina.AccessorNativeFunctions.eina_accessor_free(accessor);
+ }
}
internal static IntPtr IEnumerableToAccessor<T>(IEnumerable<T> enumerable, bool isMoved)