path: root/src/bin/eolian_mono/eolian/mono/struct_definition.hh
diff options
authorVitor Sousa <>2019-06-28 10:40:52 -0300
committerVitor Sousa <>2019-06-28 10:44:52 -0300
commit4496022a3ca5223baceb11609d7659e1f34d6549 (patch)
tree2862533df5585cd75520032df9df7d60bdff10a9 /src/bin/eolian_mono/eolian/mono/struct_definition.hh
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/bin/eolian_mono/eolian/mono/struct_definition.hh')
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 204484c2b0..851b9c4025 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -88,7 +88,7 @@ struct to_internal_field_convert_generator
88 else if (regular && regular->base_type == "stringshare") 88 else if (regular && regular->base_type == "stringshare")
89 { 89 {
90 if (!as_generator( 90 if (!as_generator(
91 indent << scope_tab << scope_tab << "_internal_struct." << string << " = Eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n") 91 indent << scope_tab << scope_tab << "_internal_struct." << string << " = Eina.MemoryNative.AddStringshare(_external_struct." << string << ");\n")
92 .generate(sink, std::make_tuple(field_name, field_name), context)) 92 .generate(sink, std::make_tuple(field_name, field_name), context))
93 return false; 93 return false;
94 } 94 }