summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-14 16:27:14 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-19 01:34:15 -0300
commit2c5ea739e7f9536aec46f09500ef5e42fa1e2b1f (patch)
treef64ab894dd0a2a77130f0f027c9273b3e5477e70 /src/bindings/mono/eo_mono
parentfd6e5081f9b0de50c30f80ec99c0d3c21ea29cae (diff)
csharp: Add IEquatable on classes.
Summary: ref T8418 Reviewers: lauromoura, felipealmeida, segfaultxavi, YOhoho Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8418 Differential Revision: https://phab.enlightenment.org/D10647
Diffstat (limited to 'src/bindings/mono/eo_mono')
-rw-r--r--src/bindings/mono/eo_mono/EoWrapper.cs48
-rw-r--r--src/bindings/mono/eo_mono/workaround.cs209
2 files changed, 252 insertions, 5 deletions
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index 0ab80e5..554f4ec 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -404,7 +404,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
404 /// <para>Wraps the pointer handle to the native object instance.</para> 404 /// <para>Wraps the pointer handle to the native object instance.</para>
405 /// <para>Since EFL 1.23.</para> 405 /// <para>Since EFL 1.23.</para>
406 /// </summary> 406 /// </summary>
407 protected struct ConstructingHandle 407 protected struct ConstructingHandle : IEquatable<ConstructingHandle>
408 { 408 {
409 /// <summary>Constructor for wrapping the native handle. 409 /// <summary>Constructor for wrapping the native handle.
410 /// <para>Since EFL 1.23.</para> 410 /// <para>Since EFL 1.23.</para>
@@ -418,6 +418,52 @@ public abstract class EoWrapper : IWrapper, IDisposable
418 /// <para>Since EFL 1.23.</para> 418 /// <para>Since EFL 1.23.</para>
419 /// </summary> 419 /// </summary>
420 public IntPtr NativeHandle { get; private set; } 420 public IntPtr NativeHandle { get; private set; }
421
422 /// <summary>
423 /// Gets a hash for <see cref="ConstructingHandle" />.
424 /// <para>Since EFL 1.24.</para>
425 /// </summary>
426 /// <returns>A hash code.</returns>
427 public override int GetHashCode() => NativeHandle.GetHashCode();
428
429 /// <summary>Returns whether this <see cref="ConstructingHandle" />
430 /// is equal to the given <see cref="object" />.
431 /// <para>Since EFL 1.24.</para>
432 /// </summary>
433 /// <param name="other">The <see cref="object" /> to be compared to.</param>
434 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
435 public override bool Equals(object other)
436 => (!(other is ConstructingHandle))
437 ? false : Equals((ConstructingHandle)other);
438
439 /// <summary>Returns whether this <see cref="ConstructingHandle" /> is equal
440 /// to the given <see cref="ConstructingHandle" />.
441 /// <para>Since EFL 1.24.</para>
442 /// </summary>
443 /// <param name="other">The <see cref="ConstructingHandle" /> to be compared to.</param>
444 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
445 public bool Equals(ConstructingHandle other)
446 => NativeHandle == other.NativeHandle;
447
448 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
449 /// <para>Since EFL 1.24.</para>
450 /// </summary>
451 /// <param name="lhs">The left hand side of the operator.</param>
452 /// <param name="rhs">The right hand side of the operator.</param>
453 /// <returns><c>true</c> if <c>lhs</c> is equal
454 /// to <c>rhs</c>.</returns>
455 public static bool operator==(ConstructingHandle lhs, ConstructingHandle rhs)
456 => lhs.Equals(rhs);
457
458 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
459 /// <para>Since EFL 1.24.</para>
460 /// </summary>
461 /// <param name="lhs">The left hand side of the operator.</param>
462 /// <param name="rhs">The right hand side of the operator.</param>
463 /// <returns><c>true</c> if <c>lhs</c> is not equal
464 /// to <c>rhs</c>.</returns>
465 public static bool operator!=(ConstructingHandle lhs, ConstructingHandle rhs)
466 => !(lhs == rhs);
421 } 467 }
422 468
423 /// <summary> 469 /// <summary>
diff --git a/src/bindings/mono/eo_mono/workaround.cs b/src/bindings/mono/eo_mono/workaround.cs
index b946a06..107a7cd 100644
--- a/src/bindings/mono/eo_mono/workaround.cs
+++ b/src/bindings/mono/eo_mono/workaround.cs
@@ -21,7 +21,7 @@ using System.Collections.Generic;
21 21
22///<summary>Eo class description, passed to efl_class_new.</summary> 22///<summary>Eo class description, passed to efl_class_new.</summary>
23[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] 23[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
24internal struct ClassDescription 24internal struct ClassDescription : IEquatable<ClassDescription>
25{ 25{
26 ///<summary>Current Eo version.</summary> 26 ///<summary>Current Eo version.</summary>
27 internal uint version; 27 internal uint version;
@@ -37,6 +37,55 @@ internal struct ClassDescription
37 internal IntPtr class_constructor; 37 internal IntPtr class_constructor;
38 ///<summary>Destructor of the class.</summary> 38 ///<summary>Destructor of the class.</summary>
39 internal IntPtr class_destructor; 39 internal IntPtr class_destructor;
40
41 /// <summary>
42 /// Gets a hash for <see cref="ClassDescription" />.
43 /// <para>Since EFL 1.24.</para>
44 /// </summary>
45 /// <returns>A hash code.</returns>
46 public override int GetHashCode()
47 => version.GetHashCode() ^ name.GetHashCode()
48 ^ class_type ^ data_size.GetHashCode();
49
50 /// <summary>Returns whether this <see cref="ClassDescription" />
51 /// is equal to the given <see cref="object" />.
52 /// <para>Since EFL 1.24.</para>
53 /// </summary>
54 /// <param name="other">The <see cref="object" /> to be compared to.</param>
55 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
56 public override bool Equals(object other)
57 => (!(other is ClassDescription)) ? false
58 : Equals((ClassDescription)other);
59
60
61 /// <summary>Returns whether this <see cref="ClassDescription" /> is equal
62 /// to the given <see cref="ClassDescription" />.
63 /// <para>Since EFL 1.24.</para>
64 /// </summary>
65 /// <param name="other">The <see cref="ClassDescription" /> to be compared to.</param>
66 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
67 public bool Equals(ClassDescription other)
68 => (name == other.name) && (class_type == other.class_type);
69
70 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
71 /// <para>Since EFL 1.24.</para>
72 /// </summary>
73 /// <param name="lhs">The left hand side of the operator.</param>
74 /// <param name="rhs">The right hand side of the operator.</param>
75 /// <returns><c>true</c> if <c>lhs</c> is equal
76 /// to <c>rhs</c>.</returns>
77 public static bool operator==(ClassDescription lhs, ClassDescription rhs)
78 => lhs.Equals(rhs);
79
80 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
81 /// <para>Since EFL 1.24.</para>
82 /// </summary>
83 /// <param name="lhs">The left hand side of the operator.</param>
84 /// <param name="rhs">The right hand side of the operator.</param>
85 /// <returns><c>true</c> if <c>lhs</c> is not equal
86 /// to <c>rhs</c>.</returns>
87 public static bool operator!=(ClassDescription lhs, ClassDescription rhs)
88 => !(lhs == rhs);
40} 89}
41 90
42///<summary>Description of an Eo API operation.</summary> 91///<summary>Description of an Eo API operation.</summary>
@@ -198,33 +247,185 @@ internal delegate void EventCb(System.IntPtr data, ref Event.NativeStruct evt);
198internal delegate void FreeWrapperSupervisorCb(System.IntPtr obj); 247internal delegate void FreeWrapperSupervisorCb(System.IntPtr obj);
199 248
200[StructLayout(LayoutKind.Sequential)] 249[StructLayout(LayoutKind.Sequential)]
201public struct TextCursorCursor 250public struct TextCursorCursor : IEquatable<TextCursorCursor>
202{ 251{
203 IntPtr obj; 252 IntPtr obj;
204 UIntPtr pos; // UIntPtr to automatically change size_t between 32/64 253 UIntPtr pos; // UIntPtr to automatically change size_t between 32/64
205 IntPtr node; 254 IntPtr node;
206 [MarshalAsAttribute(UnmanagedType.U1)]bool changed; 255 [MarshalAsAttribute(UnmanagedType.U1)]bool changed;
256
257 /// <summary>
258 /// Gets a hash for <see cref="TextCursorCursor" />.
259 /// <para>Since EFL 1.24.</para>
260 /// </summary>
261 /// <returns>A hash code.</returns>
262 public override int GetHashCode()
263 => obj.GetHashCode() ^ pos.GetHashCode()
264 ^ node.GetHashCode() ^ changed.GetHashCode();
265
266 /// <summary>Returns whether this <see cref="TextCursorCursor" />
267 /// is equal to the given <see cref="object" />.
268 /// <para>Since EFL 1.24.</para>
269 /// </summary>
270 /// <param name="other">The <see cref="object" /> to be compared to.</param>
271 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
272 public override bool Equals(object other)
273 => (!(other is TextCursorCursor)) ? false
274 : Equals((TextAnnotateAnnotation)other);
275
276
277 /// <summary>Returns whether this <see cref="TextCursorCursor" /> is equal
278 /// to the given <see cref="TextCursorCursor" />.
279 /// <para>Since EFL 1.24.</para>
280 /// </summary>
281 /// <param name="other">The <see cref="TextCursorCursor" /> to be compared to.</param>
282 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
283 public bool Equals(TextCursorCursor other)
284 => (obj == other.obj) && (pos == other.pos)
285 && (node == other.node) && (changed == other.changed);
286
287 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
288 /// <para>Since EFL 1.24.</para>
289 /// </summary>
290 /// <param name="lhs">The left hand side of the operator.</param>
291 /// <param name="rhs">The right hand side of the operator.</param>
292 /// <returns><c>true</c> if <c>lhs</c> is equal
293 /// to <c>rhs</c>.</returns>
294 public static bool operator==(TextCursorCursor lhs, TextCursorCursor rhs)
295 => lhs.Equals(rhs);
296
297 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
298 /// <para>Since EFL 1.24.</para>
299 /// </summary>
300 /// <param name="lhs">The left hand side of the operator.</param>
301 /// <param name="rhs">The right hand side of the operator.</param>
302 /// <returns><c>true</c> if <c>lhs</c> is not equal
303 /// to <c>rhs</c>.</returns>
304 public static bool operator!=(TextCursorCursor lhs, TextCursorCursor rhs)
305 => !(lhs == rhs);
207} 306}
208 307
209[StructLayout(LayoutKind.Sequential)] 308[StructLayout(LayoutKind.Sequential)]
210public struct TextAnnotateAnnotation 309public struct TextAnnotateAnnotation : IEquatable<TextAnnotateAnnotation>
211{ 310{
212 IntPtr list; 311 IntPtr list;
213 IntPtr obj; 312 IntPtr obj;
214 IntPtr start_node; 313 IntPtr start_node;
215 IntPtr end_node; 314 IntPtr end_node;
216 [MarshalAsAttribute(UnmanagedType.U1)]bool is_item; 315 [MarshalAsAttribute(UnmanagedType.U1)]bool is_item;
316
317 /// <summary>
318 /// Gets a hash for <see cref="TextAnnotateAnnotation" />.
319 /// <para>Since EFL 1.24.</para>
320 /// </summary>
321 /// <returns>A hash code.</returns>
322 public override int GetHashCode()
323 => list.GetHashCode() ^ obj.GetHashCode()
324 ^ start_node.GetHashCode() ^ end_node.GetHashCode()
325 ^ is_item.GetHashCode();
326
327 /// <summary>Returns whether this <see cref="TextAnnotateAnnotation" />
328 /// is equal to the given <see cref="object" />.
329 /// <para>Since EFL 1.24.</para>
330 /// </summary>
331 /// <param name="other">The <see cref="object" /> to be compared to.</param>
332 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
333 public override bool Equals(object other)
334 => (!(other is TextAnnotateAnnotation)) ? false
335 : Equals((TextAnnotateAnnotation)other);
336
337
338 /// <summary>Returns whether this <see cref="TextAnnotateAnnotation" /> is equal
339 /// to the given <see cref="TextAnnotateAnnotation" />.
340 /// <para>Since EFL 1.24.</para>
341 /// </summary>
342 /// <param name="other">The <see cref="TextAnnotateAnnotation" /> to be compared to.</param>
343 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
344 public bool Equals(TextAnnotateAnnotation other)
345 => (list == other.list) && (obj == other.obj)
346 && (start_node == other.start_node) && (is_item == other.is_item);
347
348 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
349 /// <para>Since EFL 1.24.</para>
350 /// </summary>
351 /// <param name="lhs">The left hand side of the operator.</param>
352 /// <param name="rhs">The right hand side of the operator.</param>
353 /// <returns><c>true</c> if <c>lhs</c> is equal
354 /// to <c>rhs</c>.</returns>
355 public static bool operator==(TextAnnotateAnnotation lhs, TextAnnotateAnnotation rhs)
356 => lhs.Equals(rhs);
357
358 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
359 /// <para>Since EFL 1.24.</para>
360 /// </summary>
361 /// <param name="lhs">The left hand side of the operator.</param>
362 /// <param name="rhs">The right hand side of the operator.</param>
363 /// <returns><c>true</c> if <c>lhs</c> is not equal
364 /// to <c>rhs</c>.</returns>
365 public static bool operator!=(TextAnnotateAnnotation lhs, TextAnnotateAnnotation rhs)
366 => !(lhs == rhs);
217} 367}
218 368
219namespace Access 369namespace Access
220{ 370{
221 371
222public struct ActionData 372public struct ActionData : IEquatable<ActionData>
223{ 373{
224 public IntPtr name; 374 public IntPtr name;
225 public IntPtr action; 375 public IntPtr action;
226 public IntPtr param; 376 public IntPtr param;
227 public IntPtr func; 377 public IntPtr func;
378
379
380 /// <summary>
381 /// Gets a hash for <see cref="ActionData" />.
382 /// <para>Since EFL 1.24.</para>
383 /// </summary>
384 /// <returns>A hash code.</returns>
385 public override int GetHashCode()
386 => name.GetHashCode() ^ action.GetHashCode()
387 ^ param.GetHashCode() ^ func.GetHashCode();
388
389 /// <summary>Returns whether this <see cref="ActionData" />
390 /// is equal to the given <see cref="object" />.
391 /// <para>Since EFL 1.24.</para>
392 /// </summary>
393 /// <param name="other">The <see cref="object" /> to be compared to.</param>
394 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
395 public override bool Equals(object other)
396 => (!(other is ActionData)) ? false
397 : Equals((ActionData)other);
398
399
400 /// <summary>Returns whether this <see cref="ActionData" /> is equal
401 /// to the given <see cref="ActionData" />.
402 /// <para>Since EFL 1.24.</para>
403 /// </summary>
404 /// <param name="other">The <see cref="ActionData" /> to be compared to.</param>
405 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
406 public bool Equals(ActionData other)
407 => (name == other.name) && (action == other.action)
408 && (param == other.param) && (func == other.func);
409
410 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
411 /// <para>Since EFL 1.24.</para>
412 /// </summary>
413 /// <param name="lhs">The left hand side of the operator.</param>
414 /// <param name="rhs">The right hand side of the operator.</param>
415 /// <returns><c>true</c> if <c>lhs</c> is equal
416 /// to <c>rhs</c>.</returns>
417 public static bool operator==(ActionData lhs, ActionData rhs)
418 => lhs.Equals(rhs);
419
420 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
421 /// <para>Since EFL 1.24.</para>
422 /// </summary>
423 /// <param name="lhs">The left hand side of the operator.</param>
424 /// <param name="rhs">The right hand side of the operator.</param>
425 /// <returns><c>true</c> if <c>lhs</c> is not equal
426 /// to <c>rhs</c>.</returns>
427 public static bool operator!=(ActionData lhs, ActionData rhs)
428 => !(lhs == rhs);
228} 429}
229 430
230} // namespace Access 431} // namespace Access