csharp: Add missing docs to slice.
Summary: Also removed uneeded methods. Slice also may need some API love to be actually useful later. ref T8292 Reviewers: segfaultxavi, felipealmeida, brunobelo, woohyun Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8292 Differential Revision: https://phab.enlightenment.org/D10327
This commit is contained in:
parent
3c0e9b424d
commit
dcb6380ab5
|
@ -2,15 +2,33 @@
|
|||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Eina
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Basic interface for both slice types.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public interface ISliceBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The length of this slice in bytes.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
UIntPtr Len {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// The contents of this slice.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
IntPtr Mem {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// The length in bytes as an integer.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
int Length {get;set;}
|
||||
};
|
||||
|
||||
|
@ -21,27 +39,39 @@ public interface ISliceBase
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Slice : ISliceBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The length of this slice.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public UIntPtr Len {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// The contents of this slice.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public IntPtr Mem {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// The length as an integer.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get { return (int)Len; }
|
||||
set { Len = (UIntPtr)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new slice from the given memory and length.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
/// <param name="mem">The memory slice.</param>
|
||||
/// <param name="len">The length.</param>
|
||||
public Slice(IntPtr mem, UIntPtr len)
|
||||
{
|
||||
Mem = mem;
|
||||
Len = len;
|
||||
}
|
||||
|
||||
public Slice PinnedDataSet(IntPtr mem, UIntPtr len)
|
||||
{
|
||||
Mem = mem;
|
||||
Len = len;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Pointer to a slice of native memory.
|
||||
|
@ -51,28 +81,44 @@ public struct Slice : ISliceBase
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RwSlice : ISliceBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The length of this slice.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public UIntPtr Len {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// The contents of this slice.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public IntPtr Mem {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// The length as an integer.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get { return (int)Len; }
|
||||
set { Len = (UIntPtr)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new slice from the given memory and length.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
/// <param name="mem">The memory slice.</param>
|
||||
/// <param name="len">The length.</param>
|
||||
public RwSlice(IntPtr mem, UIntPtr len)
|
||||
{
|
||||
Mem = mem;
|
||||
Len = len;
|
||||
}
|
||||
|
||||
public RwSlice PinnedDataSet(IntPtr mem, UIntPtr len)
|
||||
{
|
||||
Mem = mem;
|
||||
Len = len;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a read-only slice from this writable memory.
|
||||
/// <para>Since EFL 1.23.</para>
|
||||
/// </summary>
|
||||
Slice ToSlice()
|
||||
{
|
||||
var r = new Slice();
|
||||
|
|
|
@ -340,7 +340,7 @@ class TestEinaSlice
|
|||
public static void pinned_data_set()
|
||||
{
|
||||
var binbuf = new Eina.Binbuf();
|
||||
binbuf.Append(new Eina.Slice().PinnedDataSet(pinnedPtr, (UIntPtr)3));
|
||||
binbuf.Append(new Eina.Slice(pinnedPtr, (UIntPtr)3));
|
||||
Test.Assert(binbuf.GetBytes().SequenceEqual(base_seq));
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue