From dcb6380ab5a0d2bbf29429676258c33d09b5b45c Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Fri, 11 Oct 2019 11:22:32 +0200 Subject: [PATCH] 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 --- src/bindings/mono/eina_mono/eina_slice.cs | 74 ++++++++++++++++++----- src/tests/efl_mono/Eina.cs | 2 +- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/src/bindings/mono/eina_mono/eina_slice.cs b/src/bindings/mono/eina_mono/eina_slice.cs index a0c8fd971c..20bd81f6f7 100644 --- a/src/bindings/mono/eina_mono/eina_slice.cs +++ b/src/bindings/mono/eina_mono/eina_slice.cs @@ -2,15 +2,33 @@ using System; using System.Runtime.InteropServices; +using System.ComponentModel; namespace Eina { +/// +/// Basic interface for both slice types. +/// Since EFL 1.23. +/// public interface ISliceBase { + /// + /// The length of this slice in bytes. + /// Since EFL 1.23. + /// UIntPtr Len {get;set;} + + /// + /// The contents of this slice. + /// Since EFL 1.23. + /// IntPtr Mem {get;set;} + /// + /// The length in bytes as an integer. + /// Since EFL 1.23. + /// int Length {get;set;} }; @@ -21,27 +39,39 @@ public interface ISliceBase [StructLayout(LayoutKind.Sequential)] public struct Slice : ISliceBase { + /// + /// The length of this slice. + /// Since EFL 1.23. + /// public UIntPtr Len {get;set;} + + /// + /// The contents of this slice. + /// Since EFL 1.23. + /// public IntPtr Mem {get;set;} + /// + /// The length as an integer. + /// Since EFL 1.23. + /// public int Length { get { return (int)Len; } set { Len = (UIntPtr)value; } } + /// + /// Creates a new slice from the given memory and length. + /// Since EFL 1.23. + /// + /// The memory slice. + /// The length. public Slice(IntPtr mem, UIntPtr len) { Mem = mem; Len = len; } - - public Slice PinnedDataSet(IntPtr mem, UIntPtr len) - { - Mem = mem; - Len = len; - return this; - } } /// Pointer to a slice of native memory. @@ -51,28 +81,44 @@ public struct Slice : ISliceBase [StructLayout(LayoutKind.Sequential)] public struct RwSlice : ISliceBase { + /// + /// The length of this slice. + /// Since EFL 1.23. + /// public UIntPtr Len {get;set;} + + /// + /// The contents of this slice. + /// Since EFL 1.23. + /// public IntPtr Mem {get;set;} + /// + /// The length as an integer. + /// Since EFL 1.23. + /// public int Length { get { return (int)Len; } set { Len = (UIntPtr)value; } } + /// + /// Creates a new slice from the given memory and length. + /// Since EFL 1.23. + /// + /// The memory slice. + /// The length. public RwSlice(IntPtr mem, UIntPtr len) { Mem = mem; Len = len; } - public RwSlice PinnedDataSet(IntPtr mem, UIntPtr len) - { - Mem = mem; - Len = len; - return this; - } - + /// + /// Returns a read-only slice from this writable memory. + /// Since EFL 1.23. + /// Slice ToSlice() { var r = new Slice(); diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs index cebe2ec2e6..5a9b94e9af 100644 --- a/src/tests/efl_mono/Eina.cs +++ b/src/tests/efl_mono/Eina.cs @@ -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