From c6509aee0fc4871524690411f3a9dde8ac447c0c Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Fri, 28 Dec 2018 18:13:51 +0100 Subject: [PATCH] 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 --- src/bindings/mono/eina_mono/eina_value.cs | 40 +---------------------- src/tests/efl_mono/Value.cs | 35 -------------------- 2 files changed, 1 insertion(+), 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 } } - -/// Exception for trying to access flushed values. -[Serializable] -public class ValueFlushedException : Exception -{ - /// Default constructor. - public ValueFlushedException() : base () { } - /// Most commonly used contructor. - public ValueFlushedException(string msg) : base(msg) { } - /// Wraps an inner exception. - public ValueFlushedException(string msg, Exception inner) : base(msg, inner) { } - /// Serializable constructor. - protected ValueFlushedException(SerializationInfo info, StreamingContext context) : base(info, context) { } -} - /// Exception for failures when setting an container item. [Serializable] public class SetItemFailedException : Exception @@ -681,8 +666,6 @@ public class Value : IDisposable, IComparable, IEquatable /// Whether this wrapper owns (can free) the native value. public Ownership Ownership { get; protected set;} private bool Disposed; - /// Whether this wrapper has already freed the native value. - public bool Flushed { get; protected set;} /// Whether this is an Optional value (meaning it can have a value or not). public bool Optional { get { @@ -774,7 +757,6 @@ public class Value : IDisposable, IComparable, IEquatable throw new System.InvalidOperationException("Failed to copy value to managed memory."); Disposed = false; - Flushed = false; Ownership = Ownership.Managed; } @@ -912,10 +894,7 @@ public class Value : IDisposable, IComparable, IEquatable if (type.IsContainer()) throw new ArgumentException("To setup a container you must provide a subtype."); - bool ret = eina_value_setup_wrapper(this.Handle, ValueTypeBridge.GetNative(type)); - if (ret) - Flushed = false; - return ret; + return eina_value_setup_wrapper(this.Handle, ValueTypeBridge.GetNative(type)); } public bool Setup(ValueType containerType, ValueType subtype, uint step=0) { @@ -930,9 +909,6 @@ public class Value : IDisposable, IComparable, IEquatable break; } - if (ret) - Flushed = false; - return ret; } @@ -940,8 +916,6 @@ public class Value : IDisposable, IComparable, IEquatable { if (Disposed) throw new ObjectDisposedException(GetType().Name); - if (Flushed) - throw new ValueFlushedException("Trying to use value that has been flushed. Setup it again."); } private void ContainerSanityChecks(int targetIndex=-1) @@ -979,16 +953,6 @@ public class Value : IDisposable, IComparable, IEquatable throw new InvalidValueTypeException("Value is not an Optional one"); } - /// Releases the memory stored by this value. It can be reused by calling setup again. - /// - public void Flush() - { - if (Disposed) - throw new ObjectDisposedException(GetType().Name); - eina_value_flush_wrapper(this.Handle); - Flushed = true; - } - /// Get a ValueNative struct with the *value* pointed by this Eina.Value. public ValueNative GetNative() { @@ -1440,8 +1404,6 @@ public class Value : IDisposable, IComparable, IEquatable return this.CompareTo(other) == 0; } catch (ObjectDisposedException) { return false; - } catch (ValueFlushedException) { - return false; } } 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 { { Eina.Value v = new Eina.Value(Eina.ValueType.Int32); v.Dispose(); - Test.AssertRaises(v.Flush); Test.AssertRaises(() => v.ToString()); Test.AssertRaises(() => v.Set(24)); } - public static void TestValueFlush() - { - using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) { - Test.Assert(v.Set(44)); - Test.Assert(!v.Flushed); - v.Flush(); - Test.Assert(v.Flushed); - - int x; - Test.AssertRaises(() => v.Get(out x)); - x = 42; - Test.AssertRaises(() => v.Set(x)); - - v.Setup(Eina.ValueType.String); - Test.AssertNotRaises(() => v.Set("Hello, EFL")); - - string y = String.Empty; - Test.AssertNotRaises(() => v.Get(out y)); - v.Flush(); - Test.AssertRaises(() => v.Get(out y)); - - v.Setup(Eina.ValueType.Array, Eina.ValueType.UInt32); - - Test.AssertNotRaises(() => - v.Append(42)); - v.Flush(); - Test.AssertRaises(() => - v.Append(42)); - - Test.AssertRaises(() => v.GetValueSubType()); - - } - } - private delegate bool BoolRet(); public static void TestValueOptionalInt() {