diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-11-26 00:02:48 -0300 |
---|---|---|
committer | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-11-26 00:02:48 -0300 |
commit | 9b3a725e60f8213ad7df39762646a53397fd8870 (patch) | |
tree | 9b5dc39afe1446e1b483a6ac065d28885f3b7d6f | |
parent | ae76c7059dc9fc76565f6b6c8cb23b606792e3a1 (diff) |
csharp: Add code to update IList passed as @in variabledevs/lauromoura/remove_eina_mono
If the array was modified, we update the passed @in variable.
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/parameter.hh | 11 | ||||
-rw-r--r-- | src/bindings/mono/eo_mono/iwrapper.cs | 22 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh index a36c55775c..d284c63147 100644 --- a/src/bin/eolian_mono/eolian/mono/parameter.hh +++ b/src/bin/eolian_mono/eolian/mono/parameter.hh | |||
@@ -1095,6 +1095,17 @@ struct convert_in_ptr_assign_generator | |||
1095 | string << " = " << in_variable_name(param.param_name) << ";\n" | 1095 | string << " = " << in_variable_name(param.param_name) << ";\n" |
1096 | ).generate(sink, escape_keyword(param.param_name), context); | 1096 | ).generate(sink, escape_keyword(param.param_name), context); |
1097 | } | 1097 | } |
1098 | else if (param_is_acceptable(param, "Eina_Array *", WANT_OWN, !WANT_OUT) | ||
1099 | || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, !WANT_OUT) | ||
1100 | || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, !WANT_OUT) | ||
1101 | || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, !WANT_OUT) | ||
1102 | ) | ||
1103 | { | ||
1104 | return as_generator( | ||
1105 | lit("Efl.Eo.Globals.UpdateListFromNativeArray(") << escape_keyword(param.param_name) << ", " << in_variable_name(param.param_name) << ");\n" | ||
1106 | ).generate(sink, attributes::unused, context); | ||
1107 | } | ||
1108 | |||
1098 | 1109 | ||
1099 | return true; | 1110 | return true; |
1100 | } | 1111 | } |
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index 8305ba5e99..a6864cbb63 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs | |||
@@ -853,12 +853,9 @@ public static class Globals | |||
853 | if (nativeArray == IntPtr.Zero) | 853 | if (nativeArray == IntPtr.Zero) |
854 | throw new ArgumentException("nativeArray is null", nameof(nativeArray)); | 854 | throw new ArgumentException("nativeArray is null", nameof(nativeArray)); |
855 | 855 | ||
856 | uint count = Eina.ArrayNativeFunctions.eina_array_count_custom_export_mono(nativeArray); | ||
857 | List<T> list = new List<T>(); | 856 | List<T> list = new List<T>(); |
858 | for (uint i = 0; i < count; i++) | 857 | UpdateListFromNativeArray(list, nativeArray); |
859 | { | 858 | |
860 | list.Add(Eina.TraitFunctions.NativeToManaged<T>(Eina.ArrayNativeFunctions.eina_array_data_get_custom_export_mono(nativeArray, i))); | ||
861 | } | ||
862 | return list; | 859 | return list; |
863 | } | 860 | } |
864 | 861 | ||
@@ -875,6 +872,21 @@ public static class Globals | |||
875 | return nativeArray; | 872 | return nativeArray; |
876 | } | 873 | } |
877 | 874 | ||
875 | internal static void UpdateListFromNativeArray<T>(IList<T> list, IntPtr nativeArray) | ||
876 | { | ||
877 | list.Clear(); | ||
878 | if (nativeArray == IntPtr.Zero) | ||
879 | { | ||
880 | return; | ||
881 | } | ||
882 | |||
883 | uint count = Eina.ArrayNativeFunctions.eina_array_count_custom_export_mono(nativeArray); | ||
884 | for (uint i = 0; i < count; i++) | ||
885 | { | ||
886 | list.Add(Eina.TraitFunctions.NativeToManaged<T>(Eina.ArrayNativeFunctions.eina_array_data_get_custom_export_mono(nativeArray, i))); | ||
887 | } | ||
888 | } | ||
889 | |||
878 | } // Globals | 890 | } // Globals |
879 | 891 | ||
880 | /// <summary> | 892 | /// <summary> |