forked from enlightenment/efl
efl-csharp: Add copy constructor for eina.Value.
Summary: This will allow deep copying the given value from C#. Reviewers: felipealmeida, vitor.sousa, segfaultxavi Reviewed By: vitor.sousa, segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7017
This commit is contained in:
parent
fb58e4a35e
commit
89a537b4d1
|
@ -766,6 +766,18 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
Setup(containerType, subtype, step);
|
Setup(containerType, subtype, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Deep copies the given eina Value</summary>
|
||||||
|
public Value(Value v)
|
||||||
|
{
|
||||||
|
Handle = Alloc();
|
||||||
|
if (!eina_value_copy(v.Handle, this.Handle))
|
||||||
|
throw new System.InvalidOperationException("Failed to copy value to managed memory.");
|
||||||
|
|
||||||
|
Disposed = false;
|
||||||
|
Flushed = false;
|
||||||
|
Ownership = Ownership.Managed;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Constructor to build value from Values_Natives passed by value from C.</summary>
|
/// <summary>Constructor to build value from Values_Natives passed by value from C.</summary>
|
||||||
public Value(Value_Native value)
|
public Value(Value_Native value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -836,6 +836,21 @@ public static class TestEinaValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void TestValueCopy() {
|
||||||
|
eina.Value v2 = null;
|
||||||
|
int raw_val = 42;
|
||||||
|
|
||||||
|
using (eina.Value v = new eina.Value(eina.ValueType.Int32)) {
|
||||||
|
Test.Assert(v.Set(raw_val));
|
||||||
|
|
||||||
|
v2 = new eina.Value(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rec_val;
|
||||||
|
Test.Assert(v2.Get(out rec_val));
|
||||||
|
Test.AssertEquals(raw_val, rec_val);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME Add remaining list tests
|
// FIXME Add remaining list tests
|
||||||
|
|
||||||
/* public static void TestValueHash() { */
|
/* public static void TestValueHash() { */
|
||||||
|
|
Loading…
Reference in New Issue