/src/swift-protobuf/Sources/SwiftProtobuf/SelectiveVisitor.swift
Line | Count | Source |
1 | | // Sources/SwiftProtobuf/SelectiveVisitor.swift - Base for custom Visitors |
2 | | // |
3 | | // Copyright (c) 2014 - 2017 Apple Inc. and the project authors |
4 | | // Licensed under Apache License v2.0 with Runtime Library Exception |
5 | | // |
6 | | // See LICENSE.txt for license information: |
7 | | // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt |
8 | | // |
9 | | // ----------------------------------------------------------------------------- |
10 | | /// |
11 | | /// A base for Visitors that only expect a subset of things to called. |
12 | | /// |
13 | | // ----------------------------------------------------------------------------- |
14 | | |
15 | | import Foundation |
16 | | |
17 | | /// A base for Visitors that only expects a subset of things to called. |
18 | | internal protocol SelectiveVisitor: Visitor { |
19 | | // Adds nothing. |
20 | | } |
21 | | |
22 | | /// Default impls for everything so things using this only have to write the |
23 | | /// methods they expect. Asserts to catch developer errors, but becomes |
24 | | /// nothing in release to keep code size small. |
25 | | /// |
26 | | /// NOTE: This is an impl for *everything*. This means the default impls |
27 | | /// provided by Visitor to bridge packed->repeated, repeated->singular, etc |
28 | | /// won't kick in. |
29 | | extension SelectiveVisitor { |
30 | 0 | internal mutating func visitSingularFloatField(value: Float, fieldNumber: Int) throws { |
31 | 0 | assert(false) |
32 | 0 | } |
33 | | |
34 | 0 | internal mutating func visitSingularDoubleField(value: Double, fieldNumber: Int) throws { |
35 | 0 | assert(false) |
36 | 0 | } |
37 | | |
38 | 0 | internal mutating func visitSingularInt32Field(value: Int32, fieldNumber: Int) throws { |
39 | 0 | assert(false) |
40 | 0 | } |
41 | | |
42 | 0 | internal mutating func visitSingularInt64Field(value: Int64, fieldNumber: Int) throws { |
43 | 0 | assert(false) |
44 | 0 | } |
45 | | |
46 | 0 | internal mutating func visitSingularUInt32Field(value: UInt32, fieldNumber: Int) throws { |
47 | 0 | assert(false) |
48 | 0 | } |
49 | | |
50 | 0 | internal mutating func visitSingularUInt64Field(value: UInt64, fieldNumber: Int) throws { |
51 | 0 | assert(false) |
52 | 0 | } |
53 | | |
54 | 0 | internal mutating func visitSingularSInt32Field(value: Int32, fieldNumber: Int) throws { |
55 | 0 | assert(false) |
56 | 0 | } |
57 | | |
58 | 0 | internal mutating func visitSingularSInt64Field(value: Int64, fieldNumber: Int) throws { |
59 | 0 | assert(false) |
60 | 0 | } |
61 | | |
62 | 0 | internal mutating func visitSingularFixed32Field(value: UInt32, fieldNumber: Int) throws { |
63 | 0 | assert(false) |
64 | 0 | } |
65 | | |
66 | 0 | internal mutating func visitSingularFixed64Field(value: UInt64, fieldNumber: Int) throws { |
67 | 0 | assert(false) |
68 | 0 | } |
69 | | |
70 | 0 | internal mutating func visitSingularSFixed32Field(value: Int32, fieldNumber: Int) throws { |
71 | 0 | assert(false) |
72 | 0 | } |
73 | | |
74 | 0 | internal mutating func visitSingularSFixed64Field(value: Int64, fieldNumber: Int) throws { |
75 | 0 | assert(false) |
76 | 0 | } |
77 | | |
78 | 0 | internal mutating func visitSingularBoolField(value: Bool, fieldNumber: Int) throws { |
79 | 0 | assert(false) |
80 | 0 | } |
81 | | |
82 | 0 | internal mutating func visitSingularStringField(value: String, fieldNumber: Int) throws { |
83 | 0 | assert(false) |
84 | 0 | } |
85 | | |
86 | 0 | internal mutating func visitSingularBytesField(value: Data, fieldNumber: Int) throws { |
87 | 0 | assert(false) |
88 | 0 | } |
89 | | |
90 | 0 | internal mutating func visitSingularEnumField<E: Enum>(value: E, fieldNumber: Int) throws { |
91 | 0 | assert(false) |
92 | 0 | } |
93 | | |
94 | 0 | internal mutating func visitSingularMessageField<M: Message>(value: M, fieldNumber: Int) throws { |
95 | 0 | assert(false) |
96 | 0 | } |
97 | | |
98 | 0 | internal mutating func visitSingularGroupField<G: Message>(value: G, fieldNumber: Int) throws { |
99 | 0 | assert(false) |
100 | 0 | } |
101 | | |
102 | 0 | internal mutating func visitRepeatedFloatField(value: [Float], fieldNumber: Int) throws { |
103 | 0 | assert(false) |
104 | 0 | } |
105 | | |
106 | 0 | internal mutating func visitRepeatedDoubleField(value: [Double], fieldNumber: Int) throws { |
107 | 0 | assert(false) |
108 | 0 | } |
109 | | |
110 | 0 | internal mutating func visitRepeatedInt32Field(value: [Int32], fieldNumber: Int) throws { |
111 | 0 | assert(false) |
112 | 0 | } |
113 | | |
114 | 0 | internal mutating func visitRepeatedInt64Field(value: [Int64], fieldNumber: Int) throws { |
115 | 0 | assert(false) |
116 | 0 | } |
117 | | |
118 | 0 | internal mutating func visitRepeatedUInt32Field(value: [UInt32], fieldNumber: Int) throws { |
119 | 0 | assert(false) |
120 | 0 | } |
121 | | |
122 | 0 | internal mutating func visitRepeatedUInt64Field(value: [UInt64], fieldNumber: Int) throws { |
123 | 0 | assert(false) |
124 | 0 | } |
125 | | |
126 | 0 | internal mutating func visitRepeatedSInt32Field(value: [Int32], fieldNumber: Int) throws { |
127 | 0 | assert(false) |
128 | 0 | } |
129 | | |
130 | 0 | internal mutating func visitRepeatedSInt64Field(value: [Int64], fieldNumber: Int) throws { |
131 | 0 | assert(false) |
132 | 0 | } |
133 | | |
134 | 0 | internal mutating func visitRepeatedFixed32Field(value: [UInt32], fieldNumber: Int) throws { |
135 | 0 | assert(false) |
136 | 0 | } |
137 | | |
138 | 0 | internal mutating func visitRepeatedFixed64Field(value: [UInt64], fieldNumber: Int) throws { |
139 | 0 | assert(false) |
140 | 0 | } |
141 | | |
142 | 0 | internal mutating func visitRepeatedSFixed32Field(value: [Int32], fieldNumber: Int) throws { |
143 | 0 | assert(false) |
144 | 0 | } |
145 | | |
146 | 0 | internal mutating func visitRepeatedSFixed64Field(value: [Int64], fieldNumber: Int) throws { |
147 | 0 | assert(false) |
148 | 0 | } |
149 | | |
150 | 0 | internal mutating func visitRepeatedBoolField(value: [Bool], fieldNumber: Int) throws { |
151 | 0 | assert(false) |
152 | 0 | } |
153 | | |
154 | 0 | internal mutating func visitRepeatedStringField(value: [String], fieldNumber: Int) throws { |
155 | 0 | assert(false) |
156 | 0 | } |
157 | | |
158 | 0 | internal mutating func visitRepeatedBytesField(value: [Data], fieldNumber: Int) throws { |
159 | 0 | assert(false) |
160 | 0 | } |
161 | | |
162 | 0 | internal mutating func visitRepeatedEnumField<E: Enum>(value: [E], fieldNumber: Int) throws { |
163 | 0 | assert(false) |
164 | 0 | } |
165 | | |
166 | 0 | internal mutating func visitRepeatedMessageField<M: Message>(value: [M], fieldNumber: Int) throws { |
167 | 0 | assert(false) |
168 | 0 | } |
169 | | |
170 | 0 | internal mutating func visitRepeatedGroupField<G: Message>(value: [G], fieldNumber: Int) throws { |
171 | 0 | assert(false) |
172 | 0 | } |
173 | | |
174 | 0 | internal mutating func visitPackedFloatField(value: [Float], fieldNumber: Int) throws { |
175 | 0 | assert(false) |
176 | 0 | } |
177 | | |
178 | 0 | internal mutating func visitPackedDoubleField(value: [Double], fieldNumber: Int) throws { |
179 | 0 | assert(false) |
180 | 0 | } |
181 | | |
182 | 0 | internal mutating func visitPackedInt32Field(value: [Int32], fieldNumber: Int) throws { |
183 | 0 | assert(false) |
184 | 0 | } |
185 | | |
186 | 0 | internal mutating func visitPackedInt64Field(value: [Int64], fieldNumber: Int) throws { |
187 | 0 | assert(false) |
188 | 0 | } |
189 | | |
190 | 0 | internal mutating func visitPackedUInt32Field(value: [UInt32], fieldNumber: Int) throws { |
191 | 0 | assert(false) |
192 | 0 | } |
193 | | |
194 | 0 | internal mutating func visitPackedUInt64Field(value: [UInt64], fieldNumber: Int) throws { |
195 | 0 | assert(false) |
196 | 0 | } |
197 | | |
198 | 0 | internal mutating func visitPackedSInt32Field(value: [Int32], fieldNumber: Int) throws { |
199 | 0 | assert(false) |
200 | 0 | } |
201 | | |
202 | 0 | internal mutating func visitPackedSInt64Field(value: [Int64], fieldNumber: Int) throws { |
203 | 0 | assert(false) |
204 | 0 | } |
205 | | |
206 | 0 | internal mutating func visitPackedFixed32Field(value: [UInt32], fieldNumber: Int) throws { |
207 | 0 | assert(false) |
208 | 0 | } |
209 | | |
210 | 0 | internal mutating func visitPackedFixed64Field(value: [UInt64], fieldNumber: Int) throws { |
211 | 0 | assert(false) |
212 | 0 | } |
213 | | |
214 | 0 | internal mutating func visitPackedSFixed32Field(value: [Int32], fieldNumber: Int) throws { |
215 | 0 | assert(false) |
216 | 0 | } |
217 | | |
218 | 0 | internal mutating func visitPackedSFixed64Field(value: [Int64], fieldNumber: Int) throws { |
219 | 0 | assert(false) |
220 | 0 | } |
221 | | |
222 | 0 | internal mutating func visitPackedBoolField(value: [Bool], fieldNumber: Int) throws { |
223 | 0 | assert(false) |
224 | 0 | } |
225 | | |
226 | 0 | internal mutating func visitPackedEnumField<E: Enum>(value: [E], fieldNumber: Int) throws { |
227 | 0 | assert(false) |
228 | 0 | } |
229 | | |
230 | | internal mutating func visitMapField<KeyType, ValueType: MapValueType>( |
231 | | fieldType: _ProtobufMap<KeyType, ValueType>.Type, |
232 | | value: _ProtobufMap<KeyType, ValueType>.BaseType, |
233 | | fieldNumber: Int |
234 | 0 | ) throws { |
235 | 0 | assert(false) |
236 | 0 | } |
237 | | |
238 | | internal mutating func visitMapField<KeyType, ValueType>( |
239 | | fieldType: _ProtobufEnumMap<KeyType, ValueType>.Type, |
240 | | value: _ProtobufEnumMap<KeyType, ValueType>.BaseType, |
241 | | fieldNumber: Int |
242 | 0 | ) throws where ValueType.RawValue == Int { |
243 | 0 | assert(false) |
244 | 0 | } |
245 | | |
246 | | internal mutating func visitMapField<KeyType, ValueType>( |
247 | | fieldType: _ProtobufMessageMap<KeyType, ValueType>.Type, |
248 | | value: _ProtobufMessageMap<KeyType, ValueType>.BaseType, |
249 | | fieldNumber: Int |
250 | 0 | ) throws { |
251 | 0 | assert(false) |
252 | 0 | } |
253 | | |
254 | 0 | internal mutating func visitExtensionFields(fields: ExtensionFieldValueSet, start: Int, end: Int) throws { |
255 | 0 | assert(false) |
256 | 0 | } |
257 | | |
258 | | internal mutating func visitExtensionFieldsAsMessageSet( |
259 | | fields: ExtensionFieldValueSet, |
260 | | start: Int, |
261 | | end: Int |
262 | 0 | ) throws { |
263 | 0 | assert(false) |
264 | 0 | } |
265 | | |
266 | 0 | internal mutating func visitUnknown(bytes: Data) throws { |
267 | 0 | assert(false) |
268 | 0 | } |
269 | | } |