summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-12-28 18:13:51 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2018-12-28 18:22:43 +0100
commitc6509aee0fc4871524690411f3a9dde8ac447c0c (patch)
tree12fa1502adb3c76410c46792e50f0b433545ff87
parent9b1cc1d80ac380ff5c02d8626c3fc7bc682d0d27 (diff)
efl-mono: Remove Flush from C# Value API.
Summary: Fixes T7387 Test Plan: run tests Reviewers: segfaultxavi, felipealmeida Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7387 Differential Revision: https://phab.enlightenment.org/D7521
-rw-r--r--src/bindings/mono/eina_mono/eina_value.cs40
-rw-r--r--src/tests/efl_mono/Value.cs35
2 files changed, 1 insertions, 74 deletions
diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs
index 4deeb1ad63..9ff4de5b13 100644
--- a/src/bindings/mono/eina_mono/eina_value.cs
+++ b/src/bindings/mono/eina_mono/eina_value.cs
@@ -405,21 +405,6 @@ public struct ValueNative
405 } 405 }
406} 406}
407 407
408
409/// <summary>Exception for trying to access flushed values.</summary>
410[Serializable]
411public class ValueFlushedException : Exception
412{
413 /// <summary> Default constructor.</summary>
414 public ValueFlushedException() : base () { }
415 /// <summary> Most commonly used contructor.</summary>
416 public ValueFlushedException(string msg) : base(msg) { }
417 /// <summary> Wraps an inner exception.</summary>
418 public ValueFlushedException(string msg, Exception inner) : base(msg, inner) { }
419 /// <summary> Serializable constructor.</summary>
420 protected ValueFlushedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
421}
422
423/// <summary>Exception for failures when setting an container item.</summary> 408/// <summary>Exception for failures when setting an container item.</summary>
424[Serializable] 409[Serializable]
425public class SetItemFailedException : Exception 410public class SetItemFailedException : Exception
@@ -681,8 +666,6 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
681 /// <summary> Whether this wrapper owns (can free) the native value. </summary> 666 /// <summary> Whether this wrapper owns (can free) the native value. </summary>
682 public Ownership Ownership { get; protected set;} 667 public Ownership Ownership { get; protected set;}
683 private bool Disposed; 668 private bool Disposed;
684 /// <summary> Whether this wrapper has already freed the native value. </summary>
685 public bool Flushed { get; protected set;}
686 /// <summary> Whether this is an Optional value (meaning it can have a value or not). </summary> 669 /// <summary> Whether this is an Optional value (meaning it can have a value or not). </summary>
687 public bool Optional { 670 public bool Optional {
688 get { 671 get {
@@ -774,7 +757,6 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
774 throw new System.InvalidOperationException("Failed to copy value to managed memory."); 757 throw new System.InvalidOperationException("Failed to copy value to managed memory.");
775 758
776 Disposed = false; 759 Disposed = false;
777 Flushed = false;
778 Ownership = Ownership.Managed; 760 Ownership = Ownership.Managed;
779 } 761 }
780 762
@@ -912,10 +894,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
912 if (type.IsContainer()) 894 if (type.IsContainer())
913 throw new ArgumentException("To setup a container you must provide a subtype."); 895 throw new ArgumentException("To setup a container you must provide a subtype.");
914 896
915 bool ret = eina_value_setup_wrapper(this.Handle, ValueTypeBridge.GetNative(type)); 897 return eina_value_setup_wrapper(this.Handle, ValueTypeBridge.GetNative(type));
916 if (ret)
917 Flushed = false;
918 return ret;
919 } 898 }
920 899
921 public bool Setup(ValueType containerType, ValueType subtype, uint step=0) { 900 public bool Setup(ValueType containerType, ValueType subtype, uint step=0) {
@@ -930,9 +909,6 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
930 break; 909 break;
931 } 910 }
932 911
933 if (ret)
934 Flushed = false;
935
936 return ret; 912 return ret;
937 } 913 }
938 914
@@ -940,8 +916,6 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
940 { 916 {
941 if (Disposed) 917 if (Disposed)
942 throw new ObjectDisposedException(GetType().Name); 918 throw new ObjectDisposedException(GetType().Name);
943 if (Flushed)
944 throw new ValueFlushedException("Trying to use value that has been flushed. Setup it again.");
945 } 919 }
946 920
947 private void ContainerSanityChecks(int targetIndex=-1) 921 private void ContainerSanityChecks(int targetIndex=-1)
@@ -979,16 +953,6 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
979 throw new InvalidValueTypeException("Value is not an Optional one"); 953 throw new InvalidValueTypeException("Value is not an Optional one");
980 } 954 }
981 955
982 /// <summary>Releases the memory stored by this value. It can be reused by calling setup again.
983 /// </summary>
984 public void Flush()
985 {
986 if (Disposed)
987 throw new ObjectDisposedException(GetType().Name);
988 eina_value_flush_wrapper(this.Handle);
989 Flushed = true;
990 }
991
992 /// <summary>Get a ValueNative struct with the *value* pointed by this Eina.Value.</summary> 956 /// <summary>Get a ValueNative struct with the *value* pointed by this Eina.Value.</summary>
993 public ValueNative GetNative() 957 public ValueNative GetNative()
994 { 958 {
@@ -1440,8 +1404,6 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
1440 return this.CompareTo(other) == 0; 1404 return this.CompareTo(other) == 0;
1441 } catch (ObjectDisposedException) { 1405 } catch (ObjectDisposedException) {
1442 return false; 1406 return false;
1443 } catch (ValueFlushedException) {
1444 return false;
1445 } 1407 }
1446 } 1408 }
1447 1409
diff --git a/src/tests/efl_mono/Value.cs b/src/tests/efl_mono/Value.cs
index 63b1d1f4be..6f2c5799b5 100644
--- a/src/tests/efl_mono/Value.cs
+++ b/src/tests/efl_mono/Value.cs
@@ -176,45 +176,10 @@ public static class TestEinaValue {
176 { 176 {
177 Eina.Value v = new Eina.Value(Eina.ValueType.Int32); 177 Eina.Value v = new Eina.Value(Eina.ValueType.Int32);
178 v.Dispose(); 178 v.Dispose();
179 Test.AssertRaises<ObjectDisposedException>(v.Flush);
180 Test.AssertRaises<ObjectDisposedException>(() => v.ToString()); 179 Test.AssertRaises<ObjectDisposedException>(() => v.ToString());
181 Test.AssertRaises<ObjectDisposedException>(() => v.Set(24)); 180 Test.AssertRaises<ObjectDisposedException>(() => v.Set(24));
182 } 181 }
183 182
184 public static void TestValueFlush()
185 {
186 using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
187 Test.Assert(v.Set(44));
188 Test.Assert(!v.Flushed);
189 v.Flush();
190 Test.Assert(v.Flushed);
191
192 int x;
193 Test.AssertRaises<Eina.ValueFlushedException>(() => v.Get(out x));
194 x = 42;
195 Test.AssertRaises<Eina.ValueFlushedException>(() => v.Set(x));
196
197 v.Setup(Eina.ValueType.String);
198 Test.AssertNotRaises<Eina.ValueFlushedException>(() => v.Set("Hello, EFL"));
199
200 string y = String.Empty;
201 Test.AssertNotRaises<Eina.ValueFlushedException>(() => v.Get(out y));
202 v.Flush();
203 Test.AssertRaises<Eina.ValueFlushedException>(() => v.Get(out y));
204
205 v.Setup(Eina.ValueType.Array, Eina.ValueType.UInt32);
206
207 Test.AssertNotRaises<Eina.ValueFlushedException>(() =>
208 v.Append(42));
209 v.Flush();
210 Test.AssertRaises<Eina.ValueFlushedException>(() =>
211 v.Append(42));
212
213 Test.AssertRaises<Eina.ValueFlushedException>(() => v.GetValueSubType());
214
215 }
216 }
217
218 private delegate bool BoolRet(); 183 private delegate bool BoolRet();
219 public static void TestValueOptionalInt() 184 public static void TestValueOptionalInt()
220 { 185 {