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
This commit is contained in:
Lauro Moura 2019-11-14 16:27:14 -03:00
parent fd6e5081f9
commit 2c5ea739e7
7 changed files with 654 additions and 14 deletions

View File

@ -43,19 +43,111 @@ public enum ElementType
[EditorBrowsable(EditorBrowsableState.Never)]
[StructLayout(LayoutKind.Sequential)]
public struct InlistMem
public struct InlistMem : IEquatable<InlistMem>
{
public IntPtr next {get;set;}
public IntPtr prev {get;set;}
public IntPtr last {get;set;}
/// <summary>
/// Gets a hash for <see cref="InlistMem" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> next.GetHashCode() ^ prev.GetHashCode() ^ last.GetHashCode();
/// <summary>Returns whether this <see cref="InlistMem" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is InlistMem)) ? false : Equals((InlistMem)other);
/// <summary>Returns whether this <see cref="InlistMem" /> is equal
/// to the given <see cref="InlistMem" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="InlistMem" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(InlistMem other)
=> (next == other.next) && (prev == other.prev)
&& (last == other.last);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(InlistMem lhs, InlistMem rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(InlistMem lhs, InlistMem rhs) => !(lhs == rhs);
}
[EditorBrowsable(EditorBrowsableState.Never)]
[StructLayout(LayoutKind.Sequential)]
public struct InlistNode<T>
public struct InlistNode<T> : IEquatable<InlistNode<T>>
{
public InlistMem __in_list {get;set;}
public T Val {get;set;}
/// <summary>
/// Gets a hash for <see cref="InlistNode{T}" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> __in_list.GetHashCode() ^ Val.GetHashCode();
/// <summary>Returns whether this <see cref="InlistNode{T}" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is InlistNode<T>)) ? false : Equals((InlistNode<T>)other);
/// <summary>Returns whether this <see cref="InlistNode{T}" /> is equal
/// to the given <see cref="InlistNode{T}" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="InlistNode{T}" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(InlistNode<T> other)
=> (__in_list == other.__in_list) && (Val.Equals(other.Val));
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(InlistNode<T> lhs, InlistNode<T> rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(InlistNode<T> lhs, InlistNode<T> rhs)
=> !(lhs == rhs);
}
[EditorBrowsable(EditorBrowsableState.Never)]

View File

@ -30,11 +30,57 @@ namespace Eina
[StructLayout(LayoutKind.Sequential)]
[EditorBrowsable(EditorBrowsableState.Never)]
public struct HashTupleNative
public struct HashTupleNative : IEquatable<HashTupleNative>
{
public IntPtr key;
public IntPtr data;
public uint key_length;
/// <summary>
/// Gets a hash for <see cref="HashTupleNative" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> key.GetHashCode() ^ data.GetHashCode() ^ key_length.GetHashCode();
/// <summary>Returns whether this <see cref="HashTupleNative" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is HashTupleNative)) ? false : Equals((HashTupleNative)other);
/// <summary>Returns whether this <see cref="HashTupleNative" /> is equal
/// to the given <see cref="HashTupleNative" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="HashTupleNative" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(HashTupleNative other)
=> (key == other.key) && (data == other.data)
&& (key_length == other.key_length);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(HashTupleNative lhs, HashTupleNative rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(HashTupleNative lhs, HashTupleNative rhs) => !(lhs == rhs);
}
[EditorBrowsable(EditorBrowsableState.Never)]

View File

@ -52,7 +52,7 @@ public interface ISliceBase
/// Since EFL 1.23.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct Slice : ISliceBase
public struct Slice : ISliceBase, IEquatable<Slice>
{
/// <summary>
/// The length of this slice.
@ -87,6 +87,49 @@ public struct Slice : ISliceBase
Mem = mem;
Len = len;
}
/// <summary>
/// Gets a hash for <see cref="Slice" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => Length.GetHashCode() ^ Mem.GetHashCode();
/// <summary>Returns whether this <see cref="Slice" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is Slice)) ? false : Equals((Slice)other);
/// <summary>Returns whether this <see cref="Slice" /> is equal
/// to the given <see cref="Slice" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="Slice" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(Slice other)
=> (Length == other.Length) ^ (Mem == other.Mem);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(Slice lhs, Slice rhs) => lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(Slice lhs, Slice rhs) => !(lhs == rhs);
}
/// <summary>Pointer to a slice of native memory.
@ -94,7 +137,7 @@ public struct Slice : ISliceBase
/// Since EFL 1.23.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct RwSlice : ISliceBase
public struct RwSlice : ISliceBase, IEquatable<RwSlice>
{
/// <summary>
/// The length of this slice.
@ -141,6 +184,49 @@ public struct RwSlice : ISliceBase
r.Len = Len;
return r;
}
/// <summary>
/// Gets a hash for <see cref="RwSlice" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => Mem.GetHashCode() ^ Length.GetHashCode();
/// <summary>Returns whether this <see cref="RwSlice" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is RwSlice)) ? false : Equals((RwSlice)other);
/// <summary>Returns whether this <see cref="RwSlice" /> is equal
/// to the given <see cref="RwSlice" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="RwSlice" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(RwSlice other)
=> (Length == other.Length) && (Mem == other.Mem);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(RwSlice lhs, RwSlice rhs) => lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(RwSlice lhs, RwSlice rhs) => !(lhs == rhs);
}
}

View File

@ -563,7 +563,7 @@ static internal class UnsafeNativeMethods
/// </summary>
[StructLayout(LayoutKind.Sequential)]
[EditorBrowsable(EditorBrowsableState.Never)]
public struct ValueNative
public struct ValueNative : IEquatable<ValueNative>
{
public IntPtr Type;
public IntPtr Value; // Actually an Eina_Value_Union, but it is padded to 8 bytes.
@ -572,6 +572,49 @@ public struct ValueNative
{
return $"ValueNative<Type:0x{Type.ToInt64():x}, Value:0x{Value.ToInt64():x}>";
}
/// <summary>
/// Gets a hash for <see cref="ValueNative" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => Type.GetHashCode() ^ Value.GetHashCode();
/// <summary>Returns whether this <see cref="ValueNative" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is ValueNative)) ? false : Equals((ValueNative)other);
/// <summary>Returns whether this <see cref="ValueNative" /> is equal
/// to the given <see cref="ValueNative" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="ValueNative" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(ValueNative other)
=> (Type == other.Type) ^ (Value == other.Value);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(ValueNative lhs, ValueNative rhs) => lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(ValueNative lhs, ValueNative rhs) => !(lhs == rhs);
}
/// <summary>Exception for failures when setting an container item.

View File

@ -41,7 +41,7 @@ public static class Timeout
/// <para>Since EFL 1.23.</para>
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct ObjectPath
public struct ObjectPath : IEquatable<ObjectPath>
{
/// <summary>
/// The string of the path.
@ -86,6 +86,48 @@ public struct ObjectPath
/// </summary>
/// <param name="path">The ObjectPath to be converted.</param>
public static string ToString(ObjectPath path) => path.value;
/// <summary>
/// Gets a hash for <see cref="ObjectPath" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => value.GetHashCode();
/// <summary>Returns whether this <see cref="ObjectPath" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is ObjectPath)) ? false : Equals((ObjectPath)other);
/// <summary>Returns whether this <see cref="ObjectPath" /> is equal
/// to the given <see cref="ObjectPath" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="ObjectPath" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(ObjectPath other) => value == other.value;
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(ObjectPath lhs, ObjectPath rhs) => lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(ObjectPath lhs, ObjectPath rhs) => !(lhs == rhs);
}
@ -94,7 +136,7 @@ public struct ObjectPath
/// <para>Since EFL 1.23.</para>
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct SignatureString
public struct SignatureString : IEquatable<SignatureString>
{
/// <summary>
/// The string of the signature.
@ -137,6 +179,48 @@ public struct SignatureString
=> ToString(sig);
public static string ToString(SignatureString sig) => sig.value;
/// <summary>
/// Gets a hash for <see cref="SignatureString" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => value.GetHashCode();
/// <summary>Returns whether this <see cref="SignatureString" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is SignatureString)) ? false : Equals((SignatureString)other);
/// <summary>Returns whether this <see cref="SignatureString" /> is equal
/// to the given <see cref="SignatureString" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="SignatureString" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(SignatureString other) => value == other.value;
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(SignatureString lhs, SignatureString rhs) => lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(SignatureString lhs, SignatureString rhs) => !(lhs == rhs);
}
/// <summary>
@ -144,7 +228,7 @@ public struct SignatureString
/// <para>Since EFL 1.23.</para>
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct UnixFd
public struct UnixFd : IEquatable<UnixFd>
{
/// <summary>
/// The value of the file descriptor.
@ -189,6 +273,48 @@ public struct UnixFd
/// </summary>
/// <param name="unix_fd">The <see cref="UnixFd" /> to be converted.</param>
public static Int32 ToInt32(UnixFd unix_fd) => unix_fd.value;
/// <summary>
/// Gets a hash for <see cref="UnixFd" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => value.GetHashCode();
/// <summary>Returns whether this <see cref="UnixFd" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is UnixFd)) ? false : Equals((UnixFd)other);
/// <summary>Returns whether this <see cref="UnixFd" /> is equal
/// to the given <see cref="UnixFd" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="UnixFd" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(UnixFd other) => value == other.value;
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(UnixFd lhs, UnixFd rhs) => lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(UnixFd lhs, UnixFd rhs) => !(lhs == rhs);
}
/// <summary>
/// Arguments of EldBus.

View File

@ -404,7 +404,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
/// <para>Wraps the pointer handle to the native object instance.</para>
/// <para>Since EFL 1.23.</para>
/// </summary>
protected struct ConstructingHandle
protected struct ConstructingHandle : IEquatable<ConstructingHandle>
{
/// <summary>Constructor for wrapping the native handle.
/// <para>Since EFL 1.23.</para>
@ -418,6 +418,52 @@ public abstract class EoWrapper : IWrapper, IDisposable
/// <para>Since EFL 1.23.</para>
/// </summary>
public IntPtr NativeHandle { get; private set; }
/// <summary>
/// Gets a hash for <see cref="ConstructingHandle" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode() => NativeHandle.GetHashCode();
/// <summary>Returns whether this <see cref="ConstructingHandle" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is ConstructingHandle))
? false : Equals((ConstructingHandle)other);
/// <summary>Returns whether this <see cref="ConstructingHandle" /> is equal
/// to the given <see cref="ConstructingHandle" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="ConstructingHandle" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(ConstructingHandle other)
=> NativeHandle == other.NativeHandle;
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(ConstructingHandle lhs, ConstructingHandle rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(ConstructingHandle lhs, ConstructingHandle rhs)
=> !(lhs == rhs);
}
/// <summary>

View File

@ -21,7 +21,7 @@ using System.Collections.Generic;
///<summary>Eo class description, passed to efl_class_new.</summary>
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
internal struct ClassDescription
internal struct ClassDescription : IEquatable<ClassDescription>
{
///<summary>Current Eo version.</summary>
internal uint version;
@ -37,6 +37,55 @@ internal struct ClassDescription
internal IntPtr class_constructor;
///<summary>Destructor of the class.</summary>
internal IntPtr class_destructor;
/// <summary>
/// Gets a hash for <see cref="ClassDescription" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> version.GetHashCode() ^ name.GetHashCode()
^ class_type ^ data_size.GetHashCode();
/// <summary>Returns whether this <see cref="ClassDescription" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is ClassDescription)) ? false
: Equals((ClassDescription)other);
/// <summary>Returns whether this <see cref="ClassDescription" /> is equal
/// to the given <see cref="ClassDescription" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="ClassDescription" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(ClassDescription other)
=> (name == other.name) && (class_type == other.class_type);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(ClassDescription lhs, ClassDescription rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(ClassDescription lhs, ClassDescription rhs)
=> !(lhs == rhs);
}
///<summary>Description of an Eo API operation.</summary>
@ -198,33 +247,185 @@ internal delegate void EventCb(System.IntPtr data, ref Event.NativeStruct evt);
internal delegate void FreeWrapperSupervisorCb(System.IntPtr obj);
[StructLayout(LayoutKind.Sequential)]
public struct TextCursorCursor
public struct TextCursorCursor : IEquatable<TextCursorCursor>
{
IntPtr obj;
UIntPtr pos; // UIntPtr to automatically change size_t between 32/64
IntPtr node;
[MarshalAsAttribute(UnmanagedType.U1)]bool changed;
/// <summary>
/// Gets a hash for <see cref="TextCursorCursor" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> obj.GetHashCode() ^ pos.GetHashCode()
^ node.GetHashCode() ^ changed.GetHashCode();
/// <summary>Returns whether this <see cref="TextCursorCursor" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is TextCursorCursor)) ? false
: Equals((TextAnnotateAnnotation)other);
/// <summary>Returns whether this <see cref="TextCursorCursor" /> is equal
/// to the given <see cref="TextCursorCursor" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="TextCursorCursor" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(TextCursorCursor other)
=> (obj == other.obj) && (pos == other.pos)
&& (node == other.node) && (changed == other.changed);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(TextCursorCursor lhs, TextCursorCursor rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(TextCursorCursor lhs, TextCursorCursor rhs)
=> !(lhs == rhs);
}
[StructLayout(LayoutKind.Sequential)]
public struct TextAnnotateAnnotation
public struct TextAnnotateAnnotation : IEquatable<TextAnnotateAnnotation>
{
IntPtr list;
IntPtr obj;
IntPtr start_node;
IntPtr end_node;
[MarshalAsAttribute(UnmanagedType.U1)]bool is_item;
/// <summary>
/// Gets a hash for <see cref="TextAnnotateAnnotation" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> list.GetHashCode() ^ obj.GetHashCode()
^ start_node.GetHashCode() ^ end_node.GetHashCode()
^ is_item.GetHashCode();
/// <summary>Returns whether this <see cref="TextAnnotateAnnotation" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is TextAnnotateAnnotation)) ? false
: Equals((TextAnnotateAnnotation)other);
/// <summary>Returns whether this <see cref="TextAnnotateAnnotation" /> is equal
/// to the given <see cref="TextAnnotateAnnotation" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="TextAnnotateAnnotation" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(TextAnnotateAnnotation other)
=> (list == other.list) && (obj == other.obj)
&& (start_node == other.start_node) && (is_item == other.is_item);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(TextAnnotateAnnotation lhs, TextAnnotateAnnotation rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(TextAnnotateAnnotation lhs, TextAnnotateAnnotation rhs)
=> !(lhs == rhs);
}
namespace Access
{
public struct ActionData
public struct ActionData : IEquatable<ActionData>
{
public IntPtr name;
public IntPtr action;
public IntPtr param;
public IntPtr func;
/// <summary>
/// Gets a hash for <see cref="ActionData" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <returns>A hash code.</returns>
public override int GetHashCode()
=> name.GetHashCode() ^ action.GetHashCode()
^ param.GetHashCode() ^ func.GetHashCode();
/// <summary>Returns whether this <see cref="ActionData" />
/// is equal to the given <see cref="object" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="object" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public override bool Equals(object other)
=> (!(other is ActionData)) ? false
: Equals((ActionData)other);
/// <summary>Returns whether this <see cref="ActionData" /> is equal
/// to the given <see cref="ActionData" />.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="other">The <see cref="ActionData" /> to be compared to.</param>
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
public bool Equals(ActionData other)
=> (name == other.name) && (action == other.action)
&& (param == other.param) && (func == other.func);
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is equal
/// to <c>rhs</c>.</returns>
public static bool operator==(ActionData lhs, ActionData rhs)
=> lhs.Equals(rhs);
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
/// <para>Since EFL 1.24.</para>
/// </summary>
/// <param name="lhs">The left hand side of the operator.</param>
/// <param name="rhs">The right hand side of the operator.</param>
/// <returns><c>true</c> if <c>lhs</c> is not equal
/// to <c>rhs</c>.</returns>
public static bool operator!=(ActionData lhs, ActionData rhs)
=> !(lhs == rhs);
}
} // namespace Access