path: root/src/lib
diff options
authorVitor Sousa <>2019-06-28 10:40:52 -0300
committerVitor Sousa <>2019-06-28 10:44:52 -0300
commit4496022a3ca5223baceb11609d7659e1f34d6549 (patch)
tree2862533df5585cd75520032df9df7d60bdff10a9 /src/lib
parentb7fa7d48ac9eff4b360e83de4d974a92c84c0291 (diff)
csharp: fix Eina_Stringshare support in containers for manual and generated API
Summary: Both C strings and eina stringshares are bound as regular strings in EFL#, as working directly with these types would demand unnecessary hassle from the user viewpoint. But for eina containers this distinction is important, and since C# generics do not provide a convenient way of dealing with the same type requiring a different management based on some other condition (at least not without compromising the usability for other types), we added a simple `System.String` wrapper named `Eina.Stringshare` that works as a placeholder for signaling this distinction. Working with this class should be transparent in most use cases because it converts to and from `System.String` implicitly. It also implements equality/inequality methods for easier comparison with strings and other stringshare objects. Add new methods and a new container element trait for dealing specifically with `Eina_Stringshare` elements. Adapt eolian_mono to identify and generate the proper placeholder in methods that require stringshare containers. Remove some direct uses of DllImport-ed functions in favor of more flexible manual binding methods. Move `Eina.Stringshare` DllImport directives to a static class named `NativeMethods`, in accordance with the code design warning CA1060. Also add a TODO comment to move all other DllImport directives to this class. Change parameter of the method `Efl.Csharp.Application.OnInitialize` from `Eina.Array<System.String>` to `string[]`. This will make this API more similar with the default C# way of receiving command line arguments. Add tests for containers storing stringshare elements. Reviewers: felipealmeida, lauromoura, segfaultxavi, bu5hm4n Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
Diffstat (limited to 'src/lib')
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/efl_mono/efl_custom_exports_mono.c b/src/lib/efl_mono/efl_custom_exports_mono.c
index 8d57ad730f..aa2572f49d 100644
--- a/src/lib/efl_mono/efl_custom_exports_mono.c
+++ b/src/lib/efl_mono/efl_custom_exports_mono.c
@@ -125,6 +125,12 @@ EAPI void efl_mono_native_free_ref(void **ptr)
125 free(*ptr); 125 free(*ptr);
126} 126}
127 127
128EAPI void efl_mono_native_stringshare_del_ref(void **str)
130 if (!str) return;
131 eina_stringshare_del(*str);
128EAPI void *efl_mono_native_alloc_copy(const void *val, unsigned int size) 134EAPI void *efl_mono_native_alloc_copy(const void *val, unsigned int size)
129{ 135{
130 if (!val) return NULL; 136 if (!val) return NULL;
@@ -161,6 +167,11 @@ EAPI Eina_Free_Cb efl_mono_native_free_addr_get()
161 return (Eina_Free_Cb)free; 167 return (Eina_Free_Cb)free;
162} 168}
163 169
170EAPI Eina_Free_Cb efl_mono_native_stringshare_del_addr_get()
172 return (Eina_Free_Cb)eina_stringshare_del;
164EAPI Eina_Free_Cb efl_mono_native_efl_unref_addr_get() 175EAPI Eina_Free_Cb efl_mono_native_efl_unref_addr_get()
165{ 176{
166 return (Eina_Free_Cb)efl_mono_thread_safe_efl_unref; 177 return (Eina_Free_Cb)efl_mono_thread_safe_efl_unref;