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:
Lauro Moura 2018-09-11 11:31:51 -03:00 committed by Vitor Sousa
parent fb58e4a35e
commit 89a537b4d1
2 changed files with 27 additions and 0 deletions

View File

@ -766,6 +766,18 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
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>
public Value(Value_Native value)
{

View File

@ -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
/* public static void TestValueHash() { */