summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-06-28 10:40:52 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-06-28 10:44:52 -0300
commit4496022a3ca5223baceb11609d7659e1f34d6549 (patch)
tree2862533df5585cd75520032df9df7d60bdff10a9 /src/bindings/mono/eo_mono
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: https://phab.enlightenment.org/D9178
Diffstat (limited to 'src/bindings/mono/eo_mono')
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 966759b..caf28a7 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -494,7 +494,7 @@ public class Globals
494 { 494 {
495 foreach (IntPtr ptr in dict.Values) 495 foreach (IntPtr ptr in dict.Values)
496 { 496 {
497 Eina.Stringshare.eina_stringshare_del(ptr); 497 Eina.NativeMethods.eina_stringshare_del(ptr);
498 } 498 }
499 } 499 }
500 500
@@ -1148,13 +1148,13 @@ public class StringsharePassOwnershipMarshaler : ICustomMarshaler
1148 public object MarshalNativeToManaged(IntPtr pNativeData) 1148 public object MarshalNativeToManaged(IntPtr pNativeData)
1149 { 1149 {
1150 var ret = Eina.StringConversion.NativeUtf8ToManagedString(pNativeData); 1150 var ret = Eina.StringConversion.NativeUtf8ToManagedString(pNativeData);
1151 Eina.Stringshare.eina_stringshare_del(pNativeData); 1151 Eina.NativeMethods.eina_stringshare_del(pNativeData);
1152 return ret; 1152 return ret;
1153 } 1153 }
1154 1154
1155 public IntPtr MarshalManagedToNative(object managedObj) 1155 public IntPtr MarshalManagedToNative(object managedObj)
1156 { 1156 {
1157 return Eina.Stringshare.eina_stringshare_add((string)managedObj); 1157 return Eina.MemoryNative.AddStringshare((string)managedObj);
1158 } 1158 }
1159 1159
1160 public void CleanUpNativeData(IntPtr pNativeData) 1160 public void CleanUpNativeData(IntPtr pNativeData)
@@ -1193,7 +1193,7 @@ public class StringshareKeepOwnershipMarshaler : ICustomMarshaler
1193 1193
1194 public IntPtr MarshalManagedToNative(object managedObj) 1194 public IntPtr MarshalManagedToNative(object managedObj)
1195 { 1195 {
1196 return Eina.Stringshare.eina_stringshare_add((string)managedObj); 1196 return Eina.MemoryNative.AddStringshare((string)managedObj);
1197 } 1197 }
1198 1198
1199 public void CleanUpNativeData(IntPtr pNativeData) 1199 public void CleanUpNativeData(IntPtr pNativeData)