summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-11 11:22:32 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-10-11 11:23:22 +0200
commitdcb6380ab5a0d2bbf29429676258c33d09b5b45c (patch)
tree405c3543682c97f34b05ceb8d2b7db1842f7bb2b
parent3c0e9b424d5d6741effad8b79d365d9c8bba9dfb (diff)
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
-rw-r--r--src/bindings/mono/eina_mono/eina_slice.cs74
-rw-r--r--src/tests/efl_mono/Eina.cs2
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 a0c8fd9..20bd81f 100644
--- a/src/bindings/mono/eina_mono/eina_slice.cs
+++ b/src/bindings/mono/eina_mono/eina_slice.cs
@@ -2,15 +2,33 @@
2 2
3using System; 3using System;
4using System.Runtime.InteropServices; 4using System.Runtime.InteropServices;
5using System.ComponentModel;
5 6
6namespace Eina 7namespace Eina
7{ 8{
8 9
10/// <summary>
11/// Basic interface for both slice types.
12/// <para>Since EFL 1.23.</para>
13/// </summary>
9public interface ISliceBase 14public interface ISliceBase
10{ 15{
16 /// <summary>
17 /// The length of this slice in bytes.
18 /// <para>Since EFL 1.23.</para>
19 /// </summary>
11 UIntPtr Len {get;set;} 20 UIntPtr Len {get;set;}
21
22 /// <summary>
23 /// The contents of this slice.
24 /// <para>Since EFL 1.23.</para>
25 /// </summary>
12 IntPtr Mem {get;set;} 26 IntPtr Mem {get;set;}
13 27
28 /// <summary>
29 /// The length in bytes as an integer.
30 /// <para>Since EFL 1.23.</para>
31 /// </summary>
14 int Length {get;set;} 32 int Length {get;set;}
15}; 33};
16 34
@@ -21,27 +39,39 @@ public interface ISliceBase
21[StructLayout(LayoutKind.Sequential)] 39[StructLayout(LayoutKind.Sequential)]
22public struct Slice : ISliceBase 40public struct Slice : ISliceBase
23{ 41{
42 /// <summary>
43 /// The length of this slice.
44 /// <para>Since EFL 1.23.</para>
45 /// </summary>
24 public UIntPtr Len {get;set;} 46 public UIntPtr Len {get;set;}
47
48 /// <summary>
49 /// The contents of this slice.
50 /// <para>Since EFL 1.23.</para>
51 /// </summary>
25 public IntPtr Mem {get;set;} 52 public IntPtr Mem {get;set;}
26 53
54 /// <summary>
55 /// The length as an integer.
56 /// <para>Since EFL 1.23.</para>
57 /// </summary>
27 public int Length 58 public int Length
28 { 59 {
29 get { return (int)Len; } 60 get { return (int)Len; }
30 set { Len = (UIntPtr)value; } 61 set { Len = (UIntPtr)value; }
31 } 62 }
32 63
64 /// <summary>
65 /// Creates a new slice from the given memory and length.
66 /// <para>Since EFL 1.23.</para>
67 /// </summary>
68 /// <param name="mem">The memory slice.</param>
69 /// <param name="len">The length.</param>
33 public Slice(IntPtr mem, UIntPtr len) 70 public Slice(IntPtr mem, UIntPtr len)
34 { 71 {
35 Mem = mem; 72 Mem = mem;
36 Len = len; 73 Len = len;
37 } 74 }
38
39 public Slice PinnedDataSet(IntPtr mem, UIntPtr len)
40 {
41 Mem = mem;
42 Len = len;
43 return this;
44 }
45} 75}
46 76
47/// <summary>Pointer to a slice of native memory. 77/// <summary>Pointer to a slice of native memory.
@@ -51,28 +81,44 @@ public struct Slice : ISliceBase
51[StructLayout(LayoutKind.Sequential)] 81[StructLayout(LayoutKind.Sequential)]
52public struct RwSlice : ISliceBase 82public struct RwSlice : ISliceBase
53{ 83{
84 /// <summary>
85 /// The length of this slice.
86 /// <para>Since EFL 1.23.</para>
87 /// </summary>
54 public UIntPtr Len {get;set;} 88 public UIntPtr Len {get;set;}
89
90 /// <summary>
91 /// The contents of this slice.
92 /// <para>Since EFL 1.23.</para>
93 /// </summary>
55 public IntPtr Mem {get;set;} 94 public IntPtr Mem {get;set;}
56 95
96 /// <summary>
97 /// The length as an integer.
98 /// <para>Since EFL 1.23.</para>
99 /// </summary>
57 public int Length 100 public int Length
58 { 101 {
59 get { return (int)Len; } 102 get { return (int)Len; }
60 set { Len = (UIntPtr)value; } 103 set { Len = (UIntPtr)value; }
61 } 104 }
62 105
106 /// <summary>
107 /// Creates a new slice from the given memory and length.
108 /// <para>Since EFL 1.23.</para>
109 /// </summary>
110 /// <param name="mem">The memory slice.</param>
111 /// <param name="len">The length.</param>
63 public RwSlice(IntPtr mem, UIntPtr len) 112 public RwSlice(IntPtr mem, UIntPtr len)
64 { 113 {
65 Mem = mem; 114 Mem = mem;
66 Len = len; 115 Len = len;
67 } 116 }
68 117
69 public RwSlice PinnedDataSet(IntPtr mem, UIntPtr len) 118 /// <summary>
70 { 119 /// Returns a read-only slice from this writable memory.
71 Mem = mem; 120 /// <para>Since EFL 1.23.</para>
72 Len = len; 121 /// </summary>
73 return this;
74 }
75
76 Slice ToSlice() 122 Slice ToSlice()
77 { 123 {
78 var r = new Slice(); 124 var r = new Slice();
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index cebe2ec..5a9b94e 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -340,7 +340,7 @@ class TestEinaSlice
340 public static void pinned_data_set() 340 public static void pinned_data_set()
341 { 341 {
342 var binbuf = new Eina.Binbuf(); 342 var binbuf = new Eina.Binbuf();
343 binbuf.Append(new Eina.Slice().PinnedDataSet(pinnedPtr, (UIntPtr)3)); 343 binbuf.Append(new Eina.Slice(pinnedPtr, (UIntPtr)3));
344 Test.Assert(binbuf.GetBytes().SequenceEqual(base_seq)); 344 Test.Assert(binbuf.GetBytes().SequenceEqual(base_seq));
345 } 345 }
346#endif 346#endif