summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eina_mono/eina_slice.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/mono/eina_mono/eina_slice.cs')
-rw-r--r--src/bindings/mono/eina_mono/eina_slice.cs105
1 files changed, 103 insertions, 2 deletions
diff --git a/src/bindings/mono/eina_mono/eina_slice.cs b/src/bindings/mono/eina_mono/eina_slice.cs
index 20bd81f..c7a1fd9 100644
--- a/src/bindings/mono/eina_mono/eina_slice.cs
+++ b/src/bindings/mono/eina_mono/eina_slice.cs
@@ -1,3 +1,18 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1#pragma warning disable 1591 16#pragma warning disable 1591
2 17
3using System; 18using System;
@@ -37,7 +52,7 @@ public interface ISliceBase
37/// Since EFL 1.23. 52/// Since EFL 1.23.
38/// </summary> 53/// </summary>
39[StructLayout(LayoutKind.Sequential)] 54[StructLayout(LayoutKind.Sequential)]
40public struct Slice : ISliceBase 55public struct Slice : ISliceBase, IEquatable<Slice>
41{ 56{
42 /// <summary> 57 /// <summary>
43 /// The length of this slice. 58 /// The length of this slice.
@@ -72,6 +87,49 @@ public struct Slice : ISliceBase
72 Mem = mem; 87 Mem = mem;
73 Len = len; 88 Len = len;
74 } 89 }
90
91 /// <summary>
92 /// Gets a hash for <see cref="Slice" />.
93 /// <para>Since EFL 1.24.</para>
94 /// </summary>
95 /// <returns>A hash code.</returns>
96 public override int GetHashCode() => Length.GetHashCode() ^ Mem.GetHashCode();
97
98 /// <summary>Returns whether this <see cref="Slice" />
99 /// is equal to the given <see cref="object" />.
100 /// <para>Since EFL 1.24.</para>
101 /// </summary>
102 /// <param name="other">The <see cref="object" /> to be compared to.</param>
103 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
104 public override bool Equals(object other)
105 => (!(other is Slice)) ? false : Equals((Slice)other);
106
107 /// <summary>Returns whether this <see cref="Slice" /> is equal
108 /// to the given <see cref="Slice" />.
109 /// <para>Since EFL 1.24.</para>
110 /// </summary>
111 /// <param name="other">The <see cref="Slice" /> to be compared to.</param>
112 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
113 public bool Equals(Slice other)
114 => (Length == other.Length) ^ (Mem == other.Mem);
115
116 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
117 /// <para>Since EFL 1.24</para>
118 /// </summary>
119 /// <param name="lhs">The left hand side of the operator.</param>
120 /// <param name="rhs">The right hand side of the operator.</param>
121 /// <returns><c>true</c> if <c>lhs</c> is equal
122 /// to <c>rhs</c>.</returns>
123 public static bool operator==(Slice lhs, Slice rhs) => lhs.Equals(rhs);
124
125 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
126 /// <para>Since EFL 1.24.</para>
127 /// </summary>
128 /// <param name="lhs">The left hand side of the operator.</param>
129 /// <param name="rhs">The right hand side of the operator.</param>
130 /// <returns><c>true</c> if <c>lhs</c> is not equal
131 /// to <c>rhs</c>.</returns>
132 public static bool operator!=(Slice lhs, Slice rhs) => !(lhs == rhs);
75} 133}
76 134
77/// <summary>Pointer to a slice of native memory. 135/// <summary>Pointer to a slice of native memory.
@@ -79,7 +137,7 @@ public struct Slice : ISliceBase
79/// Since EFL 1.23. 137/// Since EFL 1.23.
80/// </summary> 138/// </summary>
81[StructLayout(LayoutKind.Sequential)] 139[StructLayout(LayoutKind.Sequential)]
82public struct RwSlice : ISliceBase 140public struct RwSlice : ISliceBase, IEquatable<RwSlice>
83{ 141{
84 /// <summary> 142 /// <summary>
85 /// The length of this slice. 143 /// The length of this slice.
@@ -126,6 +184,49 @@ public struct RwSlice : ISliceBase
126 r.Len = Len; 184 r.Len = Len;
127 return r; 185 return r;
128 } 186 }
187
188 /// <summary>
189 /// Gets a hash for <see cref="RwSlice" />.
190 /// <para>Since EFL 1.24.</para>
191 /// </summary>
192 /// <returns>A hash code.</returns>
193 public override int GetHashCode() => Mem.GetHashCode() ^ Length.GetHashCode();
194
195 /// <summary>Returns whether this <see cref="RwSlice" />
196 /// is equal to the given <see cref="object" />.
197 /// <para>Since EFL 1.24.</para>
198 /// </summary>
199 /// <param name="other">The <see cref="object" /> to be compared to.</param>
200 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
201 public override bool Equals(object other)
202 => (!(other is RwSlice)) ? false : Equals((RwSlice)other);
203
204 /// <summary>Returns whether this <see cref="RwSlice" /> is equal
205 /// to the given <see cref="RwSlice" />.
206 /// <para>Since EFL 1.24.</para>
207 /// </summary>
208 /// <param name="other">The <see cref="RwSlice" /> to be compared to.</param>
209 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
210 public bool Equals(RwSlice other)
211 => (Length == other.Length) && (Mem == other.Mem);
212
213 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
214 /// <para>Since EFL 1.24.</para>
215 /// </summary>
216 /// <param name="lhs">The left hand side of the operator.</param>
217 /// <param name="rhs">The right hand side of the operator.</param>
218 /// <returns><c>true</c> if <c>lhs</c> is equal
219 /// to <c>rhs</c>.</returns>
220 public static bool operator==(RwSlice lhs, RwSlice rhs) => lhs.Equals(rhs);
221
222 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
223 /// <para>Since EFL 1.24.</para>
224 /// </summary>
225 /// <param name="lhs">The left hand side of the operator.</param>
226 /// <param name="rhs">The right hand side of the operator.</param>
227 /// <returns><c>true</c> if <c>lhs</c> is not equal
228 /// to <c>rhs</c>.</returns>
229 public static bool operator!=(RwSlice lhs, RwSlice rhs) => !(lhs == rhs);
129} 230}
130 231
131} 232}