From 2c5ea739e7f9536aec46f09500ef5e42fa1e2b1f Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Thu, 14 Nov 2019 16:27:14 -0300 Subject: [PATCH 01/12] 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 --- .../mono/eina_mono/eina_container_common.cs | 96 +++++++- src/bindings/mono/eina_mono/eina_hash.cs | 48 +++- src/bindings/mono/eina_mono/eina_slice.cs | 90 +++++++- src/bindings/mono/eina_mono/eina_value.cs | 45 +++- .../mono/eldbus_mono/eldbus_common.cs | 132 ++++++++++- src/bindings/mono/eo_mono/EoWrapper.cs | 48 +++- src/bindings/mono/eo_mono/workaround.cs | 209 +++++++++++++++++- 7 files changed, 654 insertions(+), 14 deletions(-) diff --git a/src/bindings/mono/eina_mono/eina_container_common.cs b/src/bindings/mono/eina_mono/eina_container_common.cs index 7b94ab7924..5366fab20c 100644 --- a/src/bindings/mono/eina_mono/eina_container_common.cs +++ b/src/bindings/mono/eina_mono/eina_container_common.cs @@ -43,19 +43,111 @@ public enum ElementType [EditorBrowsable(EditorBrowsableState.Never)] [StructLayout(LayoutKind.Sequential)] -public struct InlistMem +public struct InlistMem : IEquatable { public IntPtr next {get;set;} public IntPtr prev {get;set;} public IntPtr last {get;set;} + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => next.GetHashCode() ^ prev.GetHashCode() ^ last.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is InlistMem)) ? false : Equals((InlistMem)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(InlistMem other) + => (next == other.next) && (prev == other.prev) + && (last == other.last); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(InlistMem lhs, InlistMem rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(InlistMem lhs, InlistMem rhs) => !(lhs == rhs); } [EditorBrowsable(EditorBrowsableState.Never)] [StructLayout(LayoutKind.Sequential)] -public struct InlistNode +public struct InlistNode : IEquatable> { public InlistMem __in_list {get;set;} public T Val {get;set;} + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => __in_list.GetHashCode() ^ Val.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is InlistNode)) ? false : Equals((InlistNode)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(InlistNode other) + => (__in_list == other.__in_list) && (Val.Equals(other.Val)); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(InlistNode lhs, InlistNode rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(InlistNode lhs, InlistNode rhs) + => !(lhs == rhs); } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/bindings/mono/eina_mono/eina_hash.cs b/src/bindings/mono/eina_mono/eina_hash.cs index 29f0d0ddcd..c254d58ae5 100644 --- a/src/bindings/mono/eina_mono/eina_hash.cs +++ b/src/bindings/mono/eina_mono/eina_hash.cs @@ -30,11 +30,57 @@ namespace Eina [StructLayout(LayoutKind.Sequential)] [EditorBrowsable(EditorBrowsableState.Never)] -public struct HashTupleNative +public struct HashTupleNative : IEquatable { public IntPtr key; public IntPtr data; public uint key_length; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => key.GetHashCode() ^ data.GetHashCode() ^ key_length.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is HashTupleNative)) ? false : Equals((HashTupleNative)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(HashTupleNative other) + => (key == other.key) && (data == other.data) + && (key_length == other.key_length); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(HashTupleNative lhs, HashTupleNative rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(HashTupleNative lhs, HashTupleNative rhs) => !(lhs == rhs); } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/bindings/mono/eina_mono/eina_slice.cs b/src/bindings/mono/eina_mono/eina_slice.cs index 8bf056e37b..c7a1fd984f 100644 --- a/src/bindings/mono/eina_mono/eina_slice.cs +++ b/src/bindings/mono/eina_mono/eina_slice.cs @@ -52,7 +52,7 @@ public interface ISliceBase /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] -public struct Slice : ISliceBase +public struct Slice : ISliceBase, IEquatable { /// /// The length of this slice. @@ -87,6 +87,49 @@ public struct Slice : ISliceBase Mem = mem; Len = len; } + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => Length.GetHashCode() ^ Mem.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is Slice)) ? false : Equals((Slice)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(Slice other) + => (Length == other.Length) ^ (Mem == other.Mem); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24 + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(Slice lhs, Slice rhs) => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(Slice lhs, Slice rhs) => !(lhs == rhs); } /// Pointer to a slice of native memory. @@ -94,7 +137,7 @@ public struct Slice : ISliceBase /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] -public struct RwSlice : ISliceBase +public struct RwSlice : ISliceBase, IEquatable { /// /// The length of this slice. @@ -141,6 +184,49 @@ public struct RwSlice : ISliceBase r.Len = Len; return r; } + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => Mem.GetHashCode() ^ Length.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is RwSlice)) ? false : Equals((RwSlice)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(RwSlice other) + => (Length == other.Length) && (Mem == other.Mem); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(RwSlice lhs, RwSlice rhs) => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(RwSlice lhs, RwSlice rhs) => !(lhs == rhs); } } diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs index 12d43fd990..2a2508e08b 100644 --- a/src/bindings/mono/eina_mono/eina_value.cs +++ b/src/bindings/mono/eina_mono/eina_value.cs @@ -563,7 +563,7 @@ static internal class UnsafeNativeMethods /// [StructLayout(LayoutKind.Sequential)] [EditorBrowsable(EditorBrowsableState.Never)] -public struct ValueNative +public struct ValueNative : IEquatable { 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"; } + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => Type.GetHashCode() ^ Value.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is ValueNative)) ? false : Equals((ValueNative)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(ValueNative other) + => (Type == other.Type) ^ (Value == other.Value); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(ValueNative lhs, ValueNative rhs) => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(ValueNative lhs, ValueNative rhs) => !(lhs == rhs); } /// Exception for failures when setting an container item. diff --git a/src/bindings/mono/eldbus_mono/eldbus_common.cs b/src/bindings/mono/eldbus_mono/eldbus_common.cs index ed32cbbc5c..b6306953a1 100644 --- a/src/bindings/mono/eldbus_mono/eldbus_common.cs +++ b/src/bindings/mono/eldbus_mono/eldbus_common.cs @@ -41,7 +41,7 @@ public static class Timeout /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] -public struct ObjectPath +public struct ObjectPath : IEquatable { /// /// The string of the path. @@ -86,6 +86,48 @@ public struct ObjectPath /// /// The ObjectPath to be converted. public static string ToString(ObjectPath path) => path.value; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => value.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is ObjectPath)) ? false : Equals((ObjectPath)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(ObjectPath other) => value == other.value; + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(ObjectPath lhs, ObjectPath rhs) => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(ObjectPath lhs, ObjectPath rhs) => !(lhs == rhs); } @@ -94,7 +136,7 @@ public struct ObjectPath /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] -public struct SignatureString +public struct SignatureString : IEquatable { /// /// The string of the signature. @@ -137,6 +179,48 @@ public struct SignatureString => ToString(sig); public static string ToString(SignatureString sig) => sig.value; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => value.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is SignatureString)) ? false : Equals((SignatureString)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(SignatureString other) => value == other.value; + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(SignatureString lhs, SignatureString rhs) => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(SignatureString lhs, SignatureString rhs) => !(lhs == rhs); } /// @@ -144,7 +228,7 @@ public struct SignatureString /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] -public struct UnixFd +public struct UnixFd : IEquatable { /// /// The value of the file descriptor. @@ -189,6 +273,48 @@ public struct UnixFd /// /// The to be converted. public static Int32 ToInt32(UnixFd unix_fd) => unix_fd.value; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => value.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is UnixFd)) ? false : Equals((UnixFd)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(UnixFd other) => value == other.value; + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(UnixFd lhs, UnixFd rhs) => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(UnixFd lhs, UnixFd rhs) => !(lhs == rhs); } /// /// Arguments of EldBus. diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs index 0ab80e503a..554f4ec9bd 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 /// Wraps the pointer handle to the native object instance. /// Since EFL 1.23. /// - protected struct ConstructingHandle + protected struct ConstructingHandle : IEquatable { /// Constructor for wrapping the native handle. /// Since EFL 1.23. @@ -418,6 +418,52 @@ public abstract class EoWrapper : IWrapper, IDisposable /// Since EFL 1.23. /// public IntPtr NativeHandle { get; private set; } + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() => NativeHandle.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is ConstructingHandle)) + ? false : Equals((ConstructingHandle)other); + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(ConstructingHandle other) + => NativeHandle == other.NativeHandle; + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(ConstructingHandle lhs, ConstructingHandle rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(ConstructingHandle lhs, ConstructingHandle rhs) + => !(lhs == rhs); } /// diff --git a/src/bindings/mono/eo_mono/workaround.cs b/src/bindings/mono/eo_mono/workaround.cs index b946a06d44..107a7cd237 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; ///Eo class description, passed to efl_class_new. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] -internal struct ClassDescription +internal struct ClassDescription : IEquatable { ///Current Eo version. internal uint version; @@ -37,6 +37,55 @@ internal struct ClassDescription internal IntPtr class_constructor; ///Destructor of the class. internal IntPtr class_destructor; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => version.GetHashCode() ^ name.GetHashCode() + ^ class_type ^ data_size.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is ClassDescription)) ? false + : Equals((ClassDescription)other); + + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(ClassDescription other) + => (name == other.name) && (class_type == other.class_type); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(ClassDescription lhs, ClassDescription rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(ClassDescription lhs, ClassDescription rhs) + => !(lhs == rhs); } ///Description of an Eo API operation. @@ -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 { IntPtr obj; UIntPtr pos; // UIntPtr to automatically change size_t between 32/64 IntPtr node; [MarshalAsAttribute(UnmanagedType.U1)]bool changed; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => obj.GetHashCode() ^ pos.GetHashCode() + ^ node.GetHashCode() ^ changed.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is TextCursorCursor)) ? false + : Equals((TextAnnotateAnnotation)other); + + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(TextCursorCursor other) + => (obj == other.obj) && (pos == other.pos) + && (node == other.node) && (changed == other.changed); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(TextCursorCursor lhs, TextCursorCursor rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(TextCursorCursor lhs, TextCursorCursor rhs) + => !(lhs == rhs); } [StructLayout(LayoutKind.Sequential)] -public struct TextAnnotateAnnotation +public struct TextAnnotateAnnotation : IEquatable { IntPtr list; IntPtr obj; IntPtr start_node; IntPtr end_node; [MarshalAsAttribute(UnmanagedType.U1)]bool is_item; + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => list.GetHashCode() ^ obj.GetHashCode() + ^ start_node.GetHashCode() ^ end_node.GetHashCode() + ^ is_item.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is TextAnnotateAnnotation)) ? false + : Equals((TextAnnotateAnnotation)other); + + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(TextAnnotateAnnotation other) + => (list == other.list) && (obj == other.obj) + && (start_node == other.start_node) && (is_item == other.is_item); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(TextAnnotateAnnotation lhs, TextAnnotateAnnotation rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(TextAnnotateAnnotation lhs, TextAnnotateAnnotation rhs) + => !(lhs == rhs); } namespace Access { -public struct ActionData +public struct ActionData : IEquatable { public IntPtr name; public IntPtr action; public IntPtr param; public IntPtr func; + + + /// + /// Gets a hash for . + /// Since EFL 1.24. + /// + /// A hash code. + public override int GetHashCode() + => name.GetHashCode() ^ action.GetHashCode() + ^ param.GetHashCode() ^ func.GetHashCode(); + + /// Returns whether this + /// is equal to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public override bool Equals(object other) + => (!(other is ActionData)) ? false + : Equals((ActionData)other); + + + /// Returns whether this is equal + /// to the given . + /// Since EFL 1.24. + /// + /// The to be compared to. + /// true if is equal to other. + public bool Equals(ActionData other) + => (name == other.name) && (action == other.action) + && (param == other.param) && (func == other.func); + + /// Returns whether lhs is equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is equal + /// to rhs. + public static bool operator==(ActionData lhs, ActionData rhs) + => lhs.Equals(rhs); + + /// Returns whether lhs is not equal to rhs. + /// Since EFL 1.24. + /// + /// The left hand side of the operator. + /// The right hand side of the operator. + /// true if lhs is not equal + /// to rhs. + public static bool operator!=(ActionData lhs, ActionData rhs) + => !(lhs == rhs); } } // namespace Access From eb13df21d0e9f57e91d1c7cea862897bf06e3c20 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 19 Nov 2019 14:04:05 +0900 Subject: [PATCH 02/12] slider: fix behavior of slider when mirrored Summary: The vertical slider(!horizontal) should not be inverted when mirrored. This patch fixes and cleans up this. Test Plan: elementary_test -to slider elementary_test -to efl.ui.slider UI-Mirroring on/off and observe vertical slides. Reviewers: woohyun, cedric, bu5hm4n Reviewed By: woohyun Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10693 --- src/lib/elementary/efl_ui_slider.c | 29 ++++++++++++++++++++--------- src/lib/elementary/elm_slider.c | 21 ++++++++++++++++++--- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/lib/elementary/efl_ui_slider.c b/src/lib/elementary/efl_ui_slider.c index 219a15bc94..920dcfada2 100644 --- a/src/lib/elementary/efl_ui_slider.c +++ b/src/lib/elementary/efl_ui_slider.c @@ -48,6 +48,21 @@ _is_horizontal(Efl_Ui_Layout_Orientation dir) return efl_ui_layout_orientation_is_horizontal(dir, EINA_TRUE); } +static Eina_Bool +_is_inverted(Eo *obj, Efl_Ui_Slider_Data *sd) +{ + Eina_Bool mirrored, inverted; + + mirrored = efl_ui_mirrored_get(obj); + inverted = efl_ui_layout_orientation_is_inverted(sd->dir); + + if ((_is_horizontal(sd->dir) && (mirrored ^ inverted)) || + (!_is_horizontal(sd->dir) && inverted)) + return EINA_TRUE; + else + return EINA_FALSE; +} + static void _emit_events(Eo *obj, Efl_Ui_Slider_Data *sd) { @@ -84,7 +99,7 @@ _step_value_update(Evas_Object *obj, double step) EFL_UI_SLIDER_DATA_GET(obj, sd); - if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir)) + if (_is_inverted(obj, sd)) step *= -1.0; value = CLAMP(sd->val + step, sd->val_min, sd->val_max); @@ -105,10 +120,8 @@ _drag_value_fetch(Evas_Object *obj) if (_is_horizontal(sd->dir)) pos = posx; else pos = posy; - if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir)) - { - pos = 1.0 - pos; - } + if (_is_inverted(obj, sd)) + pos = 1.0 - pos; val = (pos * (sd->val_max - sd->val_min)) + sd->val_min; @@ -139,10 +152,8 @@ _drag_value_update(Evas_Object *obj) pos = (sd->val - sd->val_min) / (sd->val_max - sd->val_min); - if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir)) - { - pos = 1.0 - pos; - } + if (_is_inverted(obj, sd)) + pos = 1.0 - pos; efl_ui_drag_value_set(efl_part(wd->resize_obj, "efl.draggable.slider"), pos, pos); diff --git a/src/lib/elementary/elm_slider.c b/src/lib/elementary/elm_slider.c index c426a45aeb..2c6c26b84d 100644 --- a/src/lib/elementary/elm_slider.c +++ b/src/lib/elementary/elm_slider.c @@ -78,6 +78,21 @@ _is_horizontal(Efl_Ui_Layout_Orientation dir) return efl_ui_layout_orientation_is_horizontal(dir, EINA_TRUE); } +static Eina_Bool +_is_inverted(Eo *obj, Elm_Slider_Data *sd) +{ + Eina_Bool mirrored, inverted; + + mirrored = efl_ui_mirrored_get(obj); + inverted = efl_ui_layout_orientation_is_inverted(sd->dir); + + if ((_is_horizontal(sd->dir) && (mirrored ^ inverted)) || + (!_is_horizontal(sd->dir) && inverted)) + return EINA_TRUE; + else + return EINA_FALSE; +} + static void _units_set(Evas_Object *obj) { @@ -315,7 +330,7 @@ _val_set(Evas_Object *obj) else if (pos2 > 1.0) pos2 = 1.0; - if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir)) + if (_is_inverted(obj, sd)) { pos = 1.0 - pos; pos2 = 1.0 - pos2; @@ -360,7 +375,7 @@ _step_value_update(Evas_Object *obj, double step) ELM_SLIDER_DATA_GET(obj, sd); - if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir)) + if (_is_inverted(obj, sd)) step *= -1.0; absolute_step = step * (sd->val_max - sd->val_min); @@ -392,7 +407,7 @@ _val_fetch(Evas_Object *obj, Eina_Bool user_event) else pos2 = posy2; } - if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir)) + if (_is_inverted(obj, sd)) { pos = 1.0 - pos; pos2 = 1.0 - pos2; From 36c70ee93295d4b5040c0f8a20a2fdb70a0cd646 Mon Sep 17 00:00:00 2001 From: Xavi Artigas Date: Mon, 18 Nov 2019 15:20:38 +0100 Subject: [PATCH 03/12] docs: Copy all images to output folder Summary: Doxygen only copies to the output folder ("html") images included through the \image tag. However, we have several images included using \htmlonly blocks with tags inside, which also need copying. Old makefiles included code to manually copy all pngs, and this patch does the same for meson. I apologize for needing an external script just to run "cp -rf", it looks like meson does not allow wildcards passed to "cp". Files not in the output folder won't be included in the tarball and won't be distributed. Test Plan: Generated documentation now includes images for pages like: `group__Eina__List__Group.html#details` Reviewers: bu5hm4n, lauromoura Reviewed By: bu5hm4n Subscribers: cedric, #reviewers, #committers, myoungwoon Tags: #efl Differential Revision: https://phab.enlightenment.org/D10690 --- doc/efl_copy.sh | 1 + doc/meson.build | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 doc/efl_copy.sh diff --git a/doc/efl_copy.sh b/doc/efl_copy.sh new file mode 100755 index 0000000000..af975fbd8f --- /dev/null +++ b/doc/efl_copy.sh @@ -0,0 +1 @@ +cp $@ diff --git a/doc/meson.build b/doc/meson.build index 81c0e34910..18b9aeecf4 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -104,6 +104,7 @@ widget_preview_eps = custom_target('widget_preview_prefs_epc', shot_sh = find_program('shot.sh') tar = find_program('tar') +efl_copy = find_program('efl_copy.sh') foreach text_filter_property : text_filter_properties text = text_filter_property[0] @@ -181,10 +182,17 @@ doc_target += custom_target('doxygen', build_by_default: false ) +# This is not pretty but meson does not seem to allow wildcards in plain cp commands +copy_images = custom_target('documentation images', + command: [efl_copy, '-rf', join_paths(meson.current_source_dir(), 'img', '*.png'), 'html'], + output: ['empty_img_copy'], + build_by_default: false +) + compress_target = custom_target('package_doc_tar', command: [tar, '-C', meson.build_root(), '--xz', '-cf', 'efl-'+meson.project_version()+'-doc.tar.xz', 'html', 'man'], output: 'efl-'+meson.project_version()+'-doc.tar.xz', - depends: doc_target, + depends: [doc_target, copy_images], build_by_default: false ) From dd74c6ed35e281175aef666b672479608cb4dab6 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 08:37:29 -0500 Subject: [PATCH 04/12] tests/ecore_wl2: Add test for ecore_wl2_window_geometry functions ref T8016 --- src/tests/ecore_wl2/ecore_wl2_test_window.c | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tests/ecore_wl2/ecore_wl2_test_window.c b/src/tests/ecore_wl2/ecore_wl2_test_window.c index a3e1cbeb54..e68d8c1861 100644 --- a/src/tests/ecore_wl2/ecore_wl2_test_window.c +++ b/src/tests/ecore_wl2/ecore_wl2_test_window.c @@ -287,6 +287,29 @@ EFL_START_TEST(wl2_wm_window_rotation_app) } EFL_END_TEST +EFL_START_TEST(wl2_window_geometry) +{ + Ecore_Wl2_Display *disp; + Ecore_Wl2_Window *win; + int x, y, w, h; + + disp = _display_connect(); + ck_assert(disp != NULL); + + win = _window_create(disp); + ck_assert(win != NULL); + + ecore_wl2_window_geometry_set(win, 10, 10, 100, 100); + + ecore_wl2_window_geometry_get(win, &x, &y, &w, &h); + + fail_if(x != 10); + fail_if(y != 10); + fail_if(w != 100); + fail_if(h != 100); +} +EFL_END_TEST + void ecore_wl2_test_window(TCase *tc) { @@ -308,5 +331,6 @@ ecore_wl2_test_window(TCase *tc) tcase_add_test(tc, wl2_window_preferred_rot); tcase_add_test(tc, wl2_window_rotation_app); tcase_add_test(tc, wl2_wm_window_rotation_app); + tcase_add_test(tc, wl2_window_geometry); } } From a10a9ceccb9af0856ed653d1d821e36307b85872 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 09:01:53 -0500 Subject: [PATCH 05/12] ecore-wl2: Add API to find a window by surface This patch adds a convenience API that can be used to find a window based on wl_surface. @feature --- src/lib/ecore_wl2/Ecore_Wl2.h | 13 +++++++++++++ src/lib/ecore_wl2/ecore_wl2_display.c | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index eca4733710..38c81055f1 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -713,6 +713,19 @@ EAPI Eina_Bool ecore_wl2_display_sync_is_done(const Ecore_Wl2_Display *display); */ EAPI const char *ecore_wl2_display_name_get(const Ecore_Wl2_Display *display); +/** + * Finds an Ecore_Wl2_Window based on wl_surface + * + * @param display The display to search for the window + * @param surface The wl_surface of the window to find + * + * @return The Ecore_Wl2_Window if found, or NULL if no such window exists + * + * @ingroup Ecore_Wl2_Display_Group + * @since 1.24 + */ +EAPI Ecore_Wl2_Window *ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Display *display, struct wl_surface *surface); + /** * @defgroup Ecore_Wl2_Window_Group Wayland Library Window Functions * @ingroup Ecore_Wl2_Group diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index a1511c4711..85873fac69 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -1163,3 +1163,9 @@ ecore_wl2_display_flush(Ecore_Wl2_Display *display) _begin_recovery_maybe(display, code); } + +EAPI Ecore_Wl2_Window * +ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Display *display, struct wl_surface *surface) +{ + return _ecore_wl2_display_window_surface_find(display, surface); +} From 7fb23c2da13eb204b54e94bd18083d125e941b8f Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 09:16:31 -0500 Subject: [PATCH 06/12] ecore-wl2: Add API to find a connected display given a name This patch adds a convenience function to find a connected display given a name @feature --- src/lib/ecore_wl2/Ecore_Wl2.h | 16 ++++++++++++++ src/lib/ecore_wl2/ecore_wl2_display.c | 31 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 38c81055f1..ffb32e390d 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -726,6 +726,22 @@ EAPI const char *ecore_wl2_display_name_get(const Ecore_Wl2_Display *display); */ EAPI Ecore_Wl2_Window *ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Display *display, struct wl_surface *surface); +/** + * Gets the connected display object + * + * @brief This function is typically used by clients to get an + * ​existing Wayland display. + * + * ​@param name The display target name. If @c NULL, the default + * display is assumed. + * + * ​@return The Ecore_Wl2_Display which was connected to + * + * ​@ingroup Ecore_Wl2_Display_Group + * ​@since 1.24 + */ +EAPI Ecore_Wl2_Display *ecore_wl2_connected_display_get(const char *name); + /** * @defgroup Ecore_Wl2_Window_Group Wayland Library Window Functions * @ingroup Ecore_Wl2_Group diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index 85873fac69..267e62511d 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -1169,3 +1169,34 @@ ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Display *display, struct wl_s { return _ecore_wl2_display_window_surface_find(display, surface); } + +EAPI Ecore_Wl2_Display * +ecore_wl2_connected_display_get(const char *name) +{ + Ecore_Wl2_Display *ewd; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_client_displays, NULL); + + if (!name) + { + const char *n; + + /* client wants to connected to default display */ + n = getenv("WAYLAND_DISPLAY"); + if (!n) n = "wayland-0"; + + /* we have a default wayland display */ + + /* check hash of cached client displays for this name */ + ewd = eina_hash_find(_client_displays, n); + } + else + { + /* client wants to connect to specific display */ + + /* check hash of cached client displays for this name */ + ewd = eina_hash_find(_client_displays, name); + } + + return ewd; +} From ab51bbeeef36eb951d2b0327a0d2f9513847f3ca Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 09:23:18 -0500 Subject: [PATCH 07/12] ecore-wl2: Add API to return the compositor object from a given display This patch adds a convenience function to get the wl_compositor object from a given display @feature --- src/lib/ecore_wl2/Ecore_Wl2.h | 12 ++++++++++++ src/lib/ecore_wl2/ecore_wl2_display.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index ffb32e390d..b06f3b1375 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -742,6 +742,18 @@ EAPI Ecore_Wl2_Window *ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Displa */ EAPI Ecore_Wl2_Display *ecore_wl2_connected_display_get(const char *name); +/** + * Gets the wl_compositor which belongs to this display + * + * @param display The Ecore_Wl2_Display to get the compositor of + * + * @return The wl_compositor associated with this display + * + * @ingroup Ecore_Wl2_Display_Group + * @since 1.24 + */ +EAPI struct wl_compositor *ecore_wl2_display_compositor_get(Ecore_Wl2_Display *display); + /** * @defgroup Ecore_Wl2_Window_Group Wayland Library Window Functions * @ingroup Ecore_Wl2_Group diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index 267e62511d..cc92b8f871 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -1200,3 +1200,10 @@ ecore_wl2_connected_display_get(const char *name) return ewd; } + +EAPI struct wl_compositor * +ecore_wl2_display_compositor_get(Ecore_Wl2_Display *display) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(display, NULL); + return display->wl.compositor; +} From 68ea9f1a7178c1d6a8b6a1ef283f48f602b3d14b Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 09:28:27 -0500 Subject: [PATCH 08/12] ecore-wl2: Add API to return window type Small patch whichs adds a new API to return the type of a given window @feature --- src/lib/ecore_wl2/Ecore_Wl2.h | 10 ++++++++++ src/lib/ecore_wl2/ecore_wl2_window.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index b06f3b1375..04dd80a79f 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -1077,6 +1077,16 @@ EAPI void ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool ico */ EAPI void ecore_wl2_window_type_set(Ecore_Wl2_Window *window, Ecore_Wl2_Window_Type type); +/** + * Get the type of a given window + * + * @see Ecore_Wl2_Window_Type + * + * @ingroup Ecore_Wl2_Window_Group + * @since 1.24 + */ +EAPI Ecore_Wl2_Window_Type ecore_wl2_window_type_get(Ecore_Wl2_Window *window); + /** * Find the output that a given window is on * diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 97938339ce..6ba894b02f 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -1741,3 +1741,10 @@ ecore_wl2_window_surface_flush(Ecore_Wl2_Window *window, Eina_Bool purge) if (!window->wl2_surface) return; ecore_wl2_surface_flush(window->wl2_surface, purge); } + +EAPI Ecore_Wl2_Window_Type +ecore_wl2_window_type_get(Ecore_Wl2_Window *window) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(window, ECORE_WL2_WINDOW_TYPE_NONE); + return window->type; +} From 8195368929be462427e430455e66b9d7dc952622 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 09:31:46 -0500 Subject: [PATCH 09/12] tests/ecore_wl2: Add test for ecore_wl2_window_type functions ref T8016 --- src/tests/ecore_wl2/ecore_wl2_test_window.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tests/ecore_wl2/ecore_wl2_test_window.c b/src/tests/ecore_wl2/ecore_wl2_test_window.c index e68d8c1861..9c6462c5b9 100644 --- a/src/tests/ecore_wl2/ecore_wl2_test_window.c +++ b/src/tests/ecore_wl2/ecore_wl2_test_window.c @@ -310,6 +310,25 @@ EFL_START_TEST(wl2_window_geometry) } EFL_END_TEST +EFL_START_TEST(wl2_window_type) +{ + Ecore_Wl2_Display *disp; + Ecore_Wl2_Window *win; + Ecore_Wl2_Window_Type type = ECORE_WL2_WINDOW_TYPE_NONE; + + disp = _display_connect(); + ck_assert(disp != NULL); + + win = _window_create(disp); + ck_assert(win != NULL); + + ecore_wl2_window_type_set(win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL); + + type = ecore_wl2_window_type_get(win); + fail_if(type != ECORE_WL2_WINDOW_TYPE_TOPLEVEL); +} +EFL_END_TEST + void ecore_wl2_test_window(TCase *tc) { @@ -332,5 +351,6 @@ ecore_wl2_test_window(TCase *tc) tcase_add_test(tc, wl2_window_rotation_app); tcase_add_test(tc, wl2_wm_window_rotation_app); tcase_add_test(tc, wl2_window_geometry); + tcase_add_test(tc, wl2_window_type); } } From e36b1930bf04694fb67dd7e741dbcb5231bf5e58 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Tue, 19 Nov 2019 09:37:11 -0500 Subject: [PATCH 10/12] ecore-wl2: Add API to find a window by given surface This patch adds a convenience function to find a window by a given wl_surface. @feature --- src/lib/ecore_wl2/Ecore_Wl2.h | 10 ++++++++++ src/lib/ecore_wl2/ecore_wl2_window.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 04dd80a79f..6f8f9dcd54 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -1360,6 +1360,16 @@ EAPI void ecore_wl2_window_floating_mode_set(Ecore_Wl2_Window *window, Eina_Bool */ EAPI Eina_Bool ecore_wl2_window_floating_mode_get(Ecore_Wl2_Window *window); +/** + * Finds a window by surface + * + * @param surface The surface to find the window of + * + * @ingroup Ecore_Wl2_Window_Group + * @since 1.24 + */ +EAPI Ecore_Wl2_Window *ecore_wl2_window_surface_find(struct wl_surface *surface); + /** * @defgroup Ecore_Wl2_Input_Group Wayland Library Input Functions * @ingroup Ecore_Wl2_Group diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 6ba894b02f..d31dcafeb0 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -1748,3 +1748,18 @@ ecore_wl2_window_type_get(Ecore_Wl2_Window *window) EINA_SAFETY_ON_NULL_RETURN_VAL(window, ECORE_WL2_WINDOW_TYPE_NONE); return window->type; } + +EAPI Ecore_Wl2_Window * +ecore_wl2_window_surface_find(struct wl_surface *surface) +{ + Ecore_Wl2_Display *ewd; + Ecore_Wl2_Window *win; + + EINA_SAFETY_ON_NULL_RETURN_VAL(surface, NULL); + + ewd = ecore_wl2_connected_display_get(NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(ewd, NULL); + + win = ecore_wl2_display_window_find_by_surface(ewd, surface); + return win; +} From b1eb794a913e753929635aa80aeab8c2211db462 Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Tue, 19 Nov 2019 01:48:01 -0300 Subject: [PATCH 11/12] csharp: Fix CA1815 for generated structs and aliases Summary: Adds IEquatable and friends. Reviewers: felipealmeida, YOhoho, brunobelo Reviewed By: brunobelo Subscribers: cedric, #reviewers, segfaultxavi, #committers Tags: #efl Maniphest Tasks: T8418 Differential Revision: https://phab.enlightenment.org/D10694 --- .../eolian/mono/alias_definition.hh | 61 +++++++++- .../eolian_mono/eolian/mono/name_helpers.hh | 20 +++ .../eolian/mono/struct_definition.hh | 114 +++++++++++++++++- src/tests/efl_mono/Eo.cs | 36 ++++++ src/tests/efl_mono/Structs.cs | 44 +++++++ 5 files changed, 271 insertions(+), 4 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/alias_definition.hh b/src/bin/eolian_mono/eolian/mono/alias_definition.hh index 7f3f2588f3..31d86fe10d 100644 --- a/src/bin/eolian_mono/eolian/mono/alias_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/alias_definition.hh @@ -59,7 +59,7 @@ struct alias_definition_generator std::string const alias_name = utils::remove_all(alias.eolian_name, '_'); if (!as_generator( documentation - << "public struct " << alias_name << "\n" + << "public struct " << alias_name << " : IEquatable<" << alias_name << ">\n" << "{\n" << scope_tab << "private " << alias_type << " payload;\n\n" @@ -93,7 +93,64 @@ struct alias_definition_generator << scope_tab << "{\n" << scope_tab << scope_tab << "return this;\n" << scope_tab << "}\n" - << "}\n" + ).generate(sink, alias, context)) + return false; + + std::string since_line; + if (!alias.documentation.since.empty()) + if (!as_generator(scope_tab << "/// Since EFL " + alias.documentation.since + ".\n" + ).generate(std::back_inserter(since_line), attributes::unused, context)) + return false; + + // GetHashCode (needed by the equality comparisons) + if (!as_generator( + scope_tab << "/// Get a hash code for this item.\n" + << since_line + << scope_tab << "/// \n" + << scope_tab << "public override int GetHashCode() => payload.GetHashCode();\n" + ).generate(sink, attributes::unused, context)) + return false; + + // IEquatble Equals + if (!as_generator( + scope_tab << "/// Equality comparison.\n" + << since_line + << scope_tab << "/// \n" + << scope_tab << "public bool Equals(" << alias_name << " other) => payload == other.payload;\n" + ).generate(sink, attributes::unused, context)) + return false; + + // ValueType.Equals + if (!as_generator( + scope_tab << "/// Equality comparison.\n" + << since_line + << scope_tab << "/// \n" + << scope_tab << "public override bool Equals(object other)\n" + << scope_tab << scope_tab << "=> ((other is " << alias_name << ") ? Equals((" << alias_name << ")other) : false);\n" + ).generate(sink, attributes::unused, context)) + return false; + + // Equality operators + if (!as_generator( + scope_tab << "/// Equality comparison.\n" + << since_line + << scope_tab << "/// \n" + << scope_tab << "public static bool operator ==(" << alias_name << " lhs, " << alias_name << " rhs)\n" + << scope_tab << scope_tab << "=> lhs.payload == rhs.payload;\n" + ).generate(sink, attributes::unused, context)) + return false; + + if (!as_generator( + scope_tab << "/// Equality comparison.\n" + << since_line + << scope_tab << "/// \n" + << scope_tab << "public static bool operator !=(" << alias_name << " lhs, " << alias_name << " rhs)\n" + << scope_tab << scope_tab << "=> lhs.payload != rhs.payload;\n" + ).generate(sink, attributes::unused, context)) + return false; + + if (!as_generator( + "}\n" ).generate(sink, alias, context)) return false; diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh index 2f3026dfdc..a3ffe47a3b 100644 --- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh +++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh @@ -563,6 +563,17 @@ std::string translate_value_type(std::string const& name) return name; } + +// Field names // +struct struct_field_name_generator +{ + template + bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const + { + return as_generator(string).generate(sink, name_helpers::to_field_name(field.name), context); + } +} const struct_field_name {}; + } // namespace name_helpers } // namespace eolian_mono @@ -590,9 +601,18 @@ struct is_eager_generator struct is_generator : std::true_type {}; +template <> +struct is_eager_generator : std::true_type {}; +template <> +struct is_generator< ::eolian_mono::name_helpers::struct_field_name_generator> : std::true_type {}; + namespace type_traits { template <> struct attributes_needed : std::integral_constant {}; + +template <> +struct attributes_needed< ::eolian_mono::name_helpers::struct_field_name_generator> : std::integral_constant {}; + } } } } diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh index b3b8d717f6..7c0bc9e4e1 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh @@ -21,6 +21,7 @@ #include "grammar/indentation.hpp" #include "grammar/list.hpp" #include "grammar/alternative.hpp" +#include "grammar/attribute_reorder.hpp" #include "name_helpers.hh" #include "helpers.hh" #include "type.hh" @@ -408,14 +409,15 @@ struct struct_definition_generator auto const& indent = current_indentation(context); if(!as_generator(documentation).generate(sink, struct_, context)) return false; + auto struct_managed_name = binding_struct_name(struct_); if(!as_generator ( indent << "[StructLayout(LayoutKind.Sequential)]\n" << indent << "[Efl.Eo.BindingEntity]\n" - << indent << "public struct " << string << "\n" + << indent << "public struct " << struct_managed_name << " : IEquatable<" << struct_managed_name << ">\n" << indent << "{\n" ) - .generate(sink, binding_struct_name(struct_), context)) + .generate(sink, attributes::unused, context)) return false; // iterate struct fields @@ -472,6 +474,114 @@ struct struct_definition_generator return false; } + std::string since_line; + if (!struct_.documentation.since.empty()) + if (!as_generator(indent << scope_tab << "/// Since EFL " + struct_.documentation.since + ".\n" + ).generate(std::back_inserter(since_line), attributes::unused, context)) + return false; + + // GetHashCode (needed by the equality comparisons) + if (!as_generator( + indent << scope_tab << "/// Get a hash code for this item.\n" + << since_line + << indent << scope_tab << "/// \n" + << indent << scope_tab << "public override int GetHashCode()\n" + << indent << scope_tab << "{\n" + ).generate(sink, attributes::unused, context)) + return false; + + if (struct_.fields.size() != 0 ) + { + // int hash = 17; + // hash = 23 * fieldA.GetHashCode(); + // hash = 23 * fieldB.GetHashCode(); + // hash = 23 * fieldC.GetHashCode(); + // return hash + if (!as_generator( + indent << scope_tab << scope_tab << "int hash = 17;\n" + << *(indent << scope_tab << scope_tab << "hash = hash * 23 + " << name_helpers::struct_field_name << ".GetHashCode();\n") + << indent << scope_tab << scope_tab << "return hash;\n" + ).generate(sink, struct_.fields, context)) + return false; + } + else + { + // Just compare the place holder pointers + if (!as_generator( + "return field.GetHashCode();\n" + ).generate(sink, attributes::unused, context)) + return false; + } + + if (!as_generator( + indent << scope_tab << "}\n" + ).generate(sink, attributes::unused, context)) + return false; + + // IEquatable Equals + if (!as_generator( + indent << scope_tab << "/// Equality comparison.\n" + << since_line + << indent << scope_tab << "/// \n" + << indent << scope_tab << "public bool Equals(" << struct_managed_name << " other)\n" + << indent << scope_tab << "{\n" + << indent << scope_tab << scope_tab << "return " + ).generate(sink, attributes::unused, context)) + return false; + + if (struct_.fields.size() != 0 ) + { + if (!as_generator( + grammar::attribute_reorder<-1, -1>((name_helpers::struct_field_name << " == other." << name_helpers::struct_field_name)) % " && " + ).generate(sink, struct_.fields, context)) + return false; + } + else + { + // Just compare the place holder pointers + if (!as_generator( + "field.Equals(other.field)" + ).generate(sink, attributes::unused, context)) + return false; + } + + + if (!as_generator( + indent << scope_tab << scope_tab << ";\n" + << indent << scope_tab << "}\n" + ).generate(sink, attributes::unused, context)) + return false; + + // ValueType.Equals + if (!as_generator( + indent << scope_tab << "/// Equality comparison.\n" + << since_line + << indent << scope_tab << "/// \n" + << indent << scope_tab << "public override bool Equals(object other)\n" + << indent << scope_tab << scope_tab << "=> ((other is " << struct_managed_name << ") ? Equals((" << struct_managed_name << ")other) : false);\n" + ).generate(sink, attributes::unused, context)) + return false; + + // Equality operators + if (!as_generator( + indent << scope_tab << "/// Equality comparison.\n" + << since_line + << indent << scope_tab << "/// \n" + << indent << scope_tab << "public static bool operator ==(" << struct_managed_name << " lhs, " << struct_managed_name << " rhs)\n" + << indent << scope_tab << scope_tab << "=> lhs.Equals(rhs);" + ).generate(sink, attributes::unused, context)) + return false; + + if (!as_generator( + indent << scope_tab << "/// Equality comparison.\n" + << since_line + << indent << scope_tab << "/// \n" + << indent << scope_tab << "public static bool operator !=(" << struct_managed_name << " lhs, " << struct_managed_name << " rhs)\n" + << indent << scope_tab << scope_tab << "=> !lhs.Equals(rhs);" + ).generate(sink, attributes::unused, context)) + return false; + + // Conversions from/to internal struct and IntPtrs if(!as_generator( indent << scope_tab << "/// Implicit conversion to the managed representation from a native pointer.\n" ).generate(sink, attributes::unused, context)) diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs index 9a52085902..fc3c0d4c86 100644 --- a/src/tests/efl_mono/Eo.cs +++ b/src/tests/efl_mono/Eo.cs @@ -675,4 +675,40 @@ class TestHiddenClasses } } +class TestAliasEquality +{ + static Dummy.MyInt a = 4; + static Dummy.MyInt b = 4; + static Dummy.MyInt c = 5; + + public static void test_equals() + { + Test.AssertEquals(a, b); + Test.AssertNotEquals(a, c); + } + + public static void test_equals_different_types() + { + Test.Assert(!(a.Equals(new Object()))); + } + + public static void test_equatable() + { + Test.Assert(((IEquatable)a).Equals(b)); + Test.Assert(!((IEquatable)a).Equals(c)); + } + + public static void test_equality_operators() + { + Test.Assert(a == b); + Test.Assert(a != c); + } + + public static void test_hash_code() + { + Test.AssertEquals(a.GetHashCode(), b.GetHashCode()); + Test.AssertNotEquals(a.GetHashCode(), c.GetHashCode()); + } +} + } diff --git a/src/tests/efl_mono/Structs.cs b/src/tests/efl_mono/Structs.cs index 998610c785..60be42eea5 100644 --- a/src/tests/efl_mono/Structs.cs +++ b/src/tests/efl_mono/Structs.cs @@ -377,4 +377,48 @@ internal class TestStructs // } } +internal class TestStructEquality +{ + static Dummy.StructSimple a = new Dummy.StructSimple(1, 2, (char)3, 4, Fstring: "", Fmstring: "", Fstringshare: ""); + static Dummy.StructSimple b = new Dummy.StructSimple(1, 2, (char)3, 4, Fstring: "", Fmstring: "", Fstringshare: ""); + + static Dummy.StructSimple c = new Dummy.StructSimple(4, 3, (char)2, 1, Fstring: "", Fmstring: "", Fstringshare: ""); + + // to check if we differ on a single struct field + static Dummy.StructSimple singleDifferentField = new Dummy.StructSimple(1, 2, (char)3, 5, Fstring: "", Fmstring: "", Fstringshare: ""); + + public static void test_equals() + { + Test.AssertEquals(a, b); + Test.AssertNotEquals(a, c); + Test.AssertNotEquals(a, singleDifferentField); + } + + public static void test_equals_different_types() + { + Test.Assert(!(a.Equals(new Object()))); + } + + public static void test_equatable() + { + Test.Assert(((IEquatable)a).Equals(b)); + Test.Assert(!((IEquatable)a).Equals(c)); + Test.Assert(!((IEquatable)a).Equals(singleDifferentField)); + } + + public static void test_equality_operators() + { + Test.Assert(a == b); + Test.Assert(a != c); + Test.Assert(a != singleDifferentField); + } + + public static void test_hash_code() + { + Test.AssertEquals(a.GetHashCode(), b.GetHashCode()); + Test.AssertNotEquals(a.GetHashCode(), c.GetHashCode()); + Test.AssertNotEquals(a.GetHashCode(), singleDifferentField.GetHashCode()); + } +} + } From db68e45fede1fa9056ebfcac8ebd7ca320a28a54 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 20 Nov 2019 14:09:00 +0900 Subject: [PATCH 12/12] vector container: don't copy composite target duplicatedly. Container copied composite target in prior to duplicate children, the composite target is one of the children, it should skip to handle it again. --- src/lib/evas/canvas/efl_canvas_vg_container.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/efl_canvas_vg_container.c b/src/lib/evas/canvas/efl_canvas_vg_container.c index 471ea3dd6c..c6fe0c4af2 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_container.c +++ b/src/lib/evas/canvas/efl_canvas_vg_container.c @@ -390,7 +390,7 @@ _efl_canvas_vg_container_efl_object_parent_set(Eo *obj, EOLIAN static Efl_VG * _efl_canvas_vg_container_efl_duplicate_duplicate(const Eo *obj, - Efl_Canvas_Vg_Container_Data *pd) + Efl_Canvas_Vg_Container_Data *pd) { Eina_List *l; Efl_VG *child; @@ -410,6 +410,9 @@ _efl_canvas_vg_container_efl_duplicate_duplicate(const Eo *obj, //Copy Children EINA_LIST_FOREACH(pd->children, l, child) { + //Skip, We already copied composite target before. + if (child == pd->comp_target) continue; + Efl_VG *eo = efl_duplicate(child); efl_parent_set(eo, container); }