@@ -23,6 +23,68 @@ private func nilOrValue<T>(_ value: Any?) -> T? {
2323 return value as! T ?
2424}
2525
26+ func deepEqualsEventChannelMessages( _ lhs: Any ? , _ rhs: Any ? ) -> Bool {
27+ let cleanLhs = nilOrValue ( lhs) as Any ?
28+ let cleanRhs = nilOrValue ( rhs) as Any ?
29+ switch ( cleanLhs, cleanRhs) {
30+ case ( nil , nil ) :
31+ return true
32+
33+ case ( nil , _) , ( _, nil ) :
34+ return false
35+
36+ case is ( Void , Void ) :
37+ return true
38+
39+ case let ( cleanLhsHashable, cleanRhsHashable) as ( AnyHashable , AnyHashable ) :
40+ return cleanLhsHashable == cleanRhsHashable
41+
42+ case let ( cleanLhsArray, cleanRhsArray) as ( [ Any ? ] , [ Any ? ] ) :
43+ guard cleanLhsArray. count == cleanRhsArray. count else { return false }
44+ for (index, element) in cleanLhsArray. enumerated ( ) {
45+ if !deepEqualsEventChannelMessages( element, cleanRhsArray [ index] ) {
46+ return false
47+ }
48+ }
49+ return true
50+
51+ case let ( cleanLhsDictionary, cleanRhsDictionary) as ( [ AnyHashable : Any ? ] , [ AnyHashable : Any ? ] ) :
52+ guard cleanLhsDictionary. count == cleanRhsDictionary. count else { return false }
53+ for (key, cleanLhsValue) in cleanLhsDictionary {
54+ guard cleanRhsDictionary. index ( forKey: key) != nil else { return false }
55+ if !deepEqualsEventChannelMessages( cleanLhsValue, cleanRhsDictionary [ key] !) {
56+ return false
57+ }
58+ }
59+ return true
60+
61+ default :
62+ // Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue.
63+ return false
64+ }
65+ }
66+
67+ func deepHashEventChannelMessages( value: Any ? , hasher: inout Hasher ) {
68+ if let valueList = value as? [ AnyHashable ] {
69+ for item in valueList { deepHashEventChannelMessages ( value: item, hasher: & hasher) }
70+ return
71+ }
72+
73+ if let valueDict = value as? [ AnyHashable : AnyHashable ] {
74+ for key in valueDict. keys {
75+ hasher. combine ( key)
76+ deepHashEventChannelMessages ( value: valueDict [ key] !, hasher: & hasher)
77+ }
78+ return
79+ }
80+
81+ if let hashableValue = value as? AnyHashable {
82+ hasher. combine ( hashableValue. hashValue)
83+ }
84+
85+ return hasher. combine ( String ( describing: value) )
86+ }
87+
2688/// Generated class from Pigeon that represents data sent in messages.
2789/// This protocol should not be extended by any user class outside of the generated file.
2890protocol PlatformEvent {
@@ -46,6 +108,12 @@ struct IntEvent: PlatformEvent {
46108 data
47109 ]
48110 }
111+ static func == ( lhs: IntEvent , rhs: IntEvent ) -> Bool {
112+ return deepEqualsEventChannelMessages ( lhs. toList ( ) , rhs. toList ( ) )
113+ }
114+ func hash( into hasher: inout Hasher ) {
115+ deepHashEventChannelMessages ( value: toList ( ) , hasher: & hasher)
116+ }
49117}
50118
51119/// Generated class from Pigeon that represents data sent in messages.
@@ -65,6 +133,12 @@ struct StringEvent: PlatformEvent {
65133 data
66134 ]
67135 }
136+ static func == ( lhs: StringEvent , rhs: StringEvent ) -> Bool {
137+ return deepEqualsEventChannelMessages ( lhs. toList ( ) , rhs. toList ( ) )
138+ }
139+ func hash( into hasher: inout Hasher ) {
140+ deepHashEventChannelMessages ( value: toList ( ) , hasher: & hasher)
141+ }
68142}
69143
70144private class EventChannelMessagesPigeonCodecReader : FlutterStandardReader {
0 commit comments