summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno da Silva Belo <bruno.belo@expertisesolutions.com.br>2019-11-07 23:33:09 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-07 23:33:33 -0300
commit0a2c9f57ef9864f30a94abfd847870d3765f874c (patch)
treeb953d8d5bf4af6ea9a7ec15cc0124632b3c526fd
parent77207f9b5855189a4e818ed087f702080afc2068 (diff)
csharp: Localization strings with CultureInfo.
Summary: ref T8404 Reviewers: lauromoura, felipealmeida, YOhoho Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8404 Differential Revision: https://phab.enlightenment.org/D10608
-rw-r--r--src/bindings/mono/eina_mono/eina_container_common.cs5
-rw-r--r--src/bindings/mono/eina_mono/eina_value.cs55
-rw-r--r--src/tests/efl_mono/Strings.cs7
3 files changed, 41 insertions, 26 deletions
diff --git a/src/bindings/mono/eina_mono/eina_container_common.cs b/src/bindings/mono/eina_mono/eina_container_common.cs
index 5b3b2f4..7b94ab7 100644
--- a/src/bindings/mono/eina_mono/eina_container_common.cs
+++ b/src/bindings/mono/eina_mono/eina_container_common.cs
@@ -21,6 +21,7 @@ using System.Runtime.InteropServices;
21using System.Collections.Generic; 21using System.Collections.Generic;
22using System.Reflection; 22using System.Reflection;
23using System.ComponentModel; 23using System.ComponentModel;
24using System.Globalization;
24 25
25using Eina.Callbacks; 26using Eina.Callbacks;
26using static Eina.HashNativeFunctions; 27using static Eina.HashNativeFunctions;
@@ -642,7 +643,7 @@ abstract public class Primitive32ElementTraits<T> : PrimitiveElementTraits<T>, I
642 643
643 public IntPtr ManagedToNativeAllocRef(T man, bool refs) 644 public IntPtr ManagedToNativeAllocRef(T man, bool refs)
644 { 645 {
645 return int32Traits.ManagedToNativeAlloc(Convert.ToInt32((object)man)); 646 return int32Traits.ManagedToNativeAlloc(Convert.ToInt32((object)man, CultureInfo.CurrentCulture));
646 } 647 }
647 648
648 public void NativeFreeRef(IntPtr nat, bool unrefs) 649 public void NativeFreeRef(IntPtr nat, bool unrefs)
@@ -681,7 +682,7 @@ abstract public class Primitive64ElementTraits<T> : PrimitiveElementTraits<T>, I
681 682
682 public IntPtr ManagedToNativeAllocRef(T man, bool refs) 683 public IntPtr ManagedToNativeAllocRef(T man, bool refs)
683 { 684 {
684 return int64Traits.ManagedToNativeAlloc(Convert.ToInt64((object)man)); 685 return int64Traits.ManagedToNativeAlloc(Convert.ToInt64((object)man, CultureInfo.CurrentCulture));
685 } 686 }
686 687
687 public void NativeFreeRef(IntPtr nat, bool unrefs) 688 public void NativeFreeRef(IntPtr nat, bool unrefs)
diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs
index 8e0d836..365d60b 100644
--- a/src/bindings/mono/eina_mono/eina_value.cs
+++ b/src/bindings/mono/eina_mono/eina_value.cs
@@ -26,6 +26,7 @@ using System.Security.Permissions;
26using System.Security; 26using System.Security;
27using System.Diagnostics.CodeAnalysis; 27using System.Diagnostics.CodeAnalysis;
28using System.Runtime.Serialization; 28using System.Runtime.Serialization;
29using System.Globalization;
29 30
30using static Eina.EinaNative.UnsafeNativeMethods; 31using static Eina.EinaNative.UnsafeNativeMethods;
31using static Eina.TraitFunctions; 32using static Eina.TraitFunctions;
@@ -3111,69 +3112,69 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
3111 { 3112 {
3112 case ValueType.SByte: 3113 case ValueType.SByte:
3113 { 3114 {
3114 sbyte b = Convert.ToSByte(o); 3115 sbyte b = Convert.ToSByte(o, CultureInfo.CurrentCulture);
3115 return eina_value_container_append_wrapper_char(this.Handle, b); 3116 return eina_value_container_append_wrapper_char(this.Handle, b);
3116 } 3117 }
3117 3118
3118 case ValueType.Byte: 3119 case ValueType.Byte:
3119 { 3120 {
3120 byte b = Convert.ToByte(o); 3121 byte b = Convert.ToByte(o, CultureInfo.CurrentCulture);
3121 return eina_value_container_append_wrapper_uchar(this.Handle, b); 3122 return eina_value_container_append_wrapper_uchar(this.Handle, b);
3122 } 3123 }
3123 3124
3124 case ValueType.Short: 3125 case ValueType.Short:
3125 { 3126 {
3126 short b = Convert.ToInt16(o); 3127 short b = Convert.ToInt16(o, CultureInfo.CurrentCulture);
3127 return eina_value_container_append_wrapper_short(this.Handle, b); 3128 return eina_value_container_append_wrapper_short(this.Handle, b);
3128 } 3129 }
3129 3130
3130 case ValueType.UShort: 3131 case ValueType.UShort:
3131 { 3132 {
3132 ushort b = Convert.ToUInt16(o); 3133 ushort b = Convert.ToUInt16(o, CultureInfo.CurrentCulture);
3133 return eina_value_container_append_wrapper_ushort(this.Handle, b); 3134 return eina_value_container_append_wrapper_ushort(this.Handle, b);
3134 } 3135 }
3135 3136
3136 case ValueType.Int32: 3137 case ValueType.Int32:
3137 { 3138 {
3138 int x = Convert.ToInt32(o); 3139 int x = Convert.ToInt32(o, CultureInfo.CurrentCulture);
3139 return eina_value_container_append_wrapper_int(this.Handle, x); 3140 return eina_value_container_append_wrapper_int(this.Handle, x);
3140 } 3141 }
3141 3142
3142 case ValueType.UInt32: 3143 case ValueType.UInt32:
3143 { 3144 {
3144 uint x = Convert.ToUInt32(o); 3145 uint x = Convert.ToUInt32(o, CultureInfo.CurrentCulture);
3145 return eina_value_container_append_wrapper_uint(this.Handle, x); 3146 return eina_value_container_append_wrapper_uint(this.Handle, x);
3146 } 3147 }
3147 3148
3148 case ValueType.Long: 3149 case ValueType.Long:
3149 case ValueType.Int64: 3150 case ValueType.Int64:
3150 { 3151 {
3151 long x = Convert.ToInt64(o); 3152 long x = Convert.ToInt64(o, CultureInfo.CurrentCulture);
3152 return eina_value_container_append_wrapper_long(this.Handle, x); 3153 return eina_value_container_append_wrapper_long(this.Handle, x);
3153 } 3154 }
3154 3155
3155 case ValueType.ULong: 3156 case ValueType.ULong:
3156 case ValueType.UInt64: 3157 case ValueType.UInt64:
3157 { 3158 {
3158 ulong x = Convert.ToUInt64(o); 3159 ulong x = Convert.ToUInt64(o, CultureInfo.CurrentCulture);
3159 return eina_value_container_append_wrapper_ulong(this.Handle, x); 3160 return eina_value_container_append_wrapper_ulong(this.Handle, x);
3160 } 3161 }
3161 3162
3162 case ValueType.Float: 3163 case ValueType.Float:
3163 { 3164 {
3164 float x = Convert.ToSingle(o); 3165 float x = Convert.ToSingle(o, CultureInfo.CurrentCulture);
3165 return eina_value_container_append_wrapper_float(this.Handle, x); 3166 return eina_value_container_append_wrapper_float(this.Handle, x);
3166 } 3167 }
3167 3168
3168 case ValueType.Double: 3169 case ValueType.Double:
3169 { 3170 {
3170 double x = Convert.ToDouble(o); 3171 double x = Convert.ToDouble(o, CultureInfo.CurrentCulture);
3171 return eina_value_container_append_wrapper_double(this.Handle, x); 3172 return eina_value_container_append_wrapper_double(this.Handle, x);
3172 } 3173 }
3173 3174
3174 case ValueType.String: 3175 case ValueType.String:
3175 { 3176 {
3176 string x = Convert.ToString(o); 3177 string x = Convert.ToString(o, CultureInfo.CurrentCulture);
3177 return eina_value_container_append_wrapper_string(this.Handle, x); 3178 return eina_value_container_append_wrapper_string(this.Handle, x);
3178 } 3179 }
3179 case ValueType.Object: 3180 case ValueType.Object:
@@ -3298,42 +3299,48 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
3298 { 3299 {
3299 case ValueType.SByte: 3300 case ValueType.SByte:
3300 { 3301 {
3301 sbyte v = Convert.ToSByte(value); 3302 sbyte v = Convert.ToSByte(value,
3303 CultureInfo.CurrentCulture);
3302 eina_value_container_set_wrapper_char(this.Handle, i, v); 3304 eina_value_container_set_wrapper_char(this.Handle, i, v);
3303 break; 3305 break;
3304 } 3306 }
3305 3307
3306 case ValueType.Byte: 3308 case ValueType.Byte:
3307 { 3309 {
3308 byte v = Convert.ToByte(value); 3310 byte v = Convert.ToByte(value,
3311 CultureInfo.CurrentCulture);
3309 eina_value_container_set_wrapper_uchar(this.Handle, i, v); 3312 eina_value_container_set_wrapper_uchar(this.Handle, i, v);
3310 break; 3313 break;
3311 } 3314 }
3312 3315
3313 case ValueType.Short: 3316 case ValueType.Short:
3314 { 3317 {
3315 short x = Convert.ToInt16(value); 3318 short x = Convert.ToInt16(value,
3319 CultureInfo.CurrentCulture);
3316 eina_value_container_set_wrapper_short(this.Handle, i, x); 3320 eina_value_container_set_wrapper_short(this.Handle, i, x);
3317 break; 3321 break;
3318 } 3322 }
3319 3323
3320 case ValueType.UShort: 3324 case ValueType.UShort:
3321 { 3325 {
3322 ushort x = Convert.ToUInt16(value); 3326 ushort x = Convert.ToUInt16(value,
3327 CultureInfo.CurrentCulture);
3323 eina_value_container_set_wrapper_ushort(this.Handle, i, x); 3328 eina_value_container_set_wrapper_ushort(this.Handle, i, x);
3324 break; 3329 break;
3325 } 3330 }
3326 3331
3327 case ValueType.Int32: 3332 case ValueType.Int32:
3328 { 3333 {
3329 int x = Convert.ToInt32(value); 3334 int x = Convert.ToInt32(value,
3335 CultureInfo.CurrentCulture);
3330 eina_value_container_set_wrapper_int(this.Handle, i, x); 3336 eina_value_container_set_wrapper_int(this.Handle, i, x);
3331 break; 3337 break;
3332 } 3338 }
3333 3339
3334 case ValueType.UInt32: 3340 case ValueType.UInt32:
3335 { 3341 {
3336 uint x = Convert.ToUInt32(value); 3342 uint x = Convert.ToUInt32(value,
3343 CultureInfo.CurrentCulture);
3337 eina_value_container_set_wrapper_uint(this.Handle, i, x); 3344 eina_value_container_set_wrapper_uint(this.Handle, i, x);
3338 break; 3345 break;
3339 } 3346 }
@@ -3341,7 +3348,8 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
3341 case ValueType.Long: 3348 case ValueType.Long:
3342 case ValueType.Int64: 3349 case ValueType.Int64:
3343 { 3350 {
3344 long x = Convert.ToInt64(value); 3351 long x = Convert.ToInt64(value,
3352 CultureInfo.CurrentCulture);
3345 eina_value_container_set_wrapper_long(this.Handle, i, x); 3353 eina_value_container_set_wrapper_long(this.Handle, i, x);
3346 break; 3354 break;
3347 } 3355 }
@@ -3349,28 +3357,31 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
3349 case ValueType.ULong: 3357 case ValueType.ULong:
3350 case ValueType.UInt64: 3358 case ValueType.UInt64:
3351 { 3359 {
3352 ulong x = Convert.ToUInt64(value); 3360 ulong x = Convert.ToUInt64(value,
3361 CultureInfo.CurrentCulture);
3353 eina_value_container_set_wrapper_ulong(this.Handle, i, x); 3362 eina_value_container_set_wrapper_ulong(this.Handle, i, x);
3354 break; 3363 break;
3355 } 3364 }
3356 3365
3357 case ValueType.Float: 3366 case ValueType.Float:
3358 { 3367 {
3359 float x = Convert.ToSingle(value); 3368 float x = Convert.ToSingle(value,
3369 CultureInfo.CurrentCulture);
3360 eina_value_container_set_wrapper_float(this.Handle, i, x); 3370 eina_value_container_set_wrapper_float(this.Handle, i, x);
3361 break; 3371 break;
3362 } 3372 }
3363 3373
3364 case ValueType.Double: 3374 case ValueType.Double:
3365 { 3375 {
3366 double x = Convert.ToDouble(value); 3376 double x = Convert.ToDouble(value, CultureInfo.CurrentCulture);
3367 eina_value_container_set_wrapper_double(this.Handle, i, x); 3377 eina_value_container_set_wrapper_double(this.Handle, i, x);
3368 break; 3378 break;
3369 } 3379 }
3370 3380
3371 case ValueType.String: 3381 case ValueType.String:
3372 { 3382 {
3373 string x = Convert.ToString(value); 3383 string x = Convert.ToString(value,
3384 CultureInfo.CurrentCulture);
3374 eina_value_container_set_wrapper_string(this.Handle, i, x); 3385 eina_value_container_set_wrapper_string(this.Handle, i, x);
3375 break; 3386 break;
3376 } 3387 }
diff --git a/src/tests/efl_mono/Strings.cs b/src/tests/efl_mono/Strings.cs
index dc5bd08..43c6717 100644
--- a/src/tests/efl_mono/Strings.cs
+++ b/src/tests/efl_mono/Strings.cs
@@ -14,6 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16using System; 16using System;
17using System.Globalization;
17 18
18namespace TestSuite { 19namespace TestSuite {
19 20
@@ -83,7 +84,8 @@ class TestStrings
83 String str = String.Empty; 84 String str = String.Empty;
84 var obj = new Dummy.TestObject(); 85 var obj = new Dummy.TestObject();
85 obj.OutOwnString(out str); 86 obj.OutOwnString(out str);
86 Test.AssertEquals(str.ToString(), "out_own_string"); 87 Test.AssertEquals(str.ToString(CultureInfo.CurrentCulture),
88 "out_own_string");
87 } 89 }
88 System.GC.Collect(); 90 System.GC.Collect();
89 } 91 }
@@ -254,7 +256,8 @@ class TestStringshare
254 String str = String.Empty; 256 String str = String.Empty;
255 var obj = new Dummy.TestObject(); 257 var obj = new Dummy.TestObject();
256 obj.OutOwnStringshare(out str); 258 obj.OutOwnStringshare(out str);
257 Test.AssertEquals(str.ToString(), "out_own_stringshare"); 259 Test.AssertEquals(str.ToString(CultureInfo.CurrentCulture),
260 "out_own_stringshare");
258 } 261 }
259 System.GC.Collect(); 262 System.GC.Collect();
260 } 263 }