-
Notifications
You must be signed in to change notification settings - Fork 581
/
Copy pathFooBar.swift
387 lines (303 loc) · 10.3 KB
/
FooBar.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.protos.custom_options.FooBar in custom_options.proto
import Wire
public struct FooBar {
@ProtoDefaulted
public var foo: Int32?
@ProtoDefaulted
public var bar: String?
@ProtoDefaulted
public var baz: FooBar.Nested?
@ProtoDefaulted
public var qux: UInt64?
public var fred: [Float] = []
@ProtoDefaulted
public var daisy: Double?
public var nested: [FooBar] = []
public var unknownFields: ExtensibleUnknownFields = .init()
public init(configure: (inout Self) -> Swift.Void = { _ in }) {
configure(&self)
}
}
extension FooBar : ProtoExtensible {
}
/**
* Extensions of FooBar
*/
extension FooBar {
/**
*
* Source: custom_options.proto
*/
public var ext: FooBar.FooBarBazEnum? {
get {
self.parseUnknownField(fieldNumber: 101, type: FooBar.FooBarBazEnum.self)
}
set {
self.setUnknownField(fieldNumber: 101, newValue: newValue)
}
}
/**
*
* Source: custom_options.proto
*/
public var rep: [FooBar.FooBarBazEnum] {
get {
self.parseUnknownField(fieldNumber: 102)
}
set {
self.setUnknownField(fieldNumber: 102, newValue: newValue)
}
}
/**
*
* Source: custom_options.proto
*/
public var more_string: String? {
get {
self.parseUnknownField(fieldNumber: 150, type: String.self)
}
set {
self.setUnknownField(fieldNumber: 150, newValue: newValue)
}
}
/**
* Default value for more_string extension field.
*/
public static let default_more_string: String = .defaultedValue
}
#if !WIRE_REMOVE_EQUATABLE
extension FooBar : Equatable {
}
#endif
#if !WIRE_REMOVE_HASHABLE
extension FooBar : Hashable {
}
#endif
extension FooBar : Sendable {
}
extension FooBar : ProtoDefaultedValue {
public static var defaultedValue: Self {
.init()
}
}
#if !WIRE_REMOVE_REDACTABLE
extension FooBar : Redactable {
public enum RedactedKeys : String, RedactedKey {
case nested
}
}
#endif
extension FooBar : ProtoMessage {
public static func protoMessageTypeURL() -> String {
return "type.googleapis.com/squareup.protos.custom_options.FooBar"
}
}
extension FooBar : Proto2Codable {
public init(from protoReader: ProtoReader) throws {
var foo: Int32? = nil
var bar: String? = nil
var baz: FooBar.Nested? = nil
var qux: UInt64? = nil
var fred: [Float] = []
var daisy: Double? = nil
var nested: [FooBar] = []
let token = try protoReader.beginMessage()
while let tag = try protoReader.nextTag(token: token) {
switch tag {
case 1: foo = try protoReader.decode(Int32.self, encoding: .variable)
case 2: bar = try protoReader.decode(String.self)
case 3: baz = try protoReader.decode(FooBar.Nested.self)
case 4: qux = try protoReader.decode(UInt64.self, encoding: .variable)
case 5: try protoReader.decode(into: &fred)
case 6: daisy = try protoReader.decode(Double.self)
case 7: try protoReader.decode(into: &nested)
default: try protoReader.readUnknownField(tag: tag)
}
}
self.unknownFields = try protoReader.endMessage(token: token)
self._foo.wrappedValue = foo
self._bar.wrappedValue = bar
self._baz.wrappedValue = baz
self._qux.wrappedValue = qux
self.fred = fred
self._daisy.wrappedValue = daisy
self.nested = nested
}
public func encode(to protoWriter: ProtoWriter) throws {
try protoWriter.encode(tag: 1, value: self.foo, encoding: .variable)
try protoWriter.encode(tag: 2, value: self.bar)
try protoWriter.encode(tag: 3, value: self.baz)
try protoWriter.encode(tag: 4, value: self.qux, encoding: .variable)
try protoWriter.encode(tag: 5, value: self.fred)
try protoWriter.encode(tag: 6, value: self.daisy)
try protoWriter.encode(tag: 7, value: self.nested)
try protoWriter.writeUnknownFields(unknownFields)
}
}
#if !WIRE_REMOVE_CODABLE
extension FooBar : Codable {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringLiteralCodingKeys.self)
self._foo.wrappedValue = try container.decodeIfPresent(Int32.self, forKey: "foo")
self._bar.wrappedValue = try container.decodeIfPresent(String.self, forKey: "bar")
self._baz.wrappedValue = try container.decodeIfPresent(FooBar.Nested.self, forKey: "baz")
self._qux.wrappedValue = try container.decodeIfPresent(stringEncoded: UInt64.self, forKey: "qux")
self.fred = try container.decodeProtoArray(Float.self, forKey: "fred")
self._daisy.wrappedValue = try container.decodeIfPresent(Double.self, forKey: "daisy")
self.nested = try container.decodeProtoArray(FooBar.self, forKey: "nested")
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringLiteralCodingKeys.self)
let includeDefaults = encoder.protoDefaultValuesEncodingStrategy == .include
try container.encodeIfPresent(self.foo, forKey: "foo")
try container.encodeIfPresent(self.bar, forKey: "bar")
try container.encodeIfPresent(self.baz, forKey: "baz")
try container.encodeIfPresent(stringEncoded: self.qux, forKey: "qux")
if includeDefaults || !self.fred.isEmpty {
try container.encodeProtoArray(self.fred, forKey: "fred")
}
try container.encodeIfPresent(self.daisy, forKey: "daisy")
if includeDefaults || !self.nested.isEmpty {
try container.encodeProtoArray(self.nested, forKey: "nested")
}
}
}
#endif
/**
* Subtypes within FooBar
*/
extension FooBar {
public struct Nested {
public var value: FooBar.FooBarBazEnum?
public var unknownFields: UnknownFields = .init()
public init(configure: (inout Self) -> Swift.Void = { _ in }) {
configure(&self)
}
}
public struct More {
public var serial: [Int32] = []
public var unknownFields: UnknownFields = .init()
public init(configure: (inout Self) -> Swift.Void = { _ in }) {
configure(&self)
}
}
@objc
public enum FooBarBazEnum : Int32, CaseIterable, Proto2Enum {
case FOO = 1
case BAR = 2
case BAZ = 3
public var description: String {
switch self {
case .FOO: return "FOO"
case .BAR: return "BAR"
case .BAZ: return "BAZ"
}
}
}
}
#if !WIRE_REMOVE_EQUATABLE
extension FooBar.Nested : Equatable {
}
#endif
#if !WIRE_REMOVE_HASHABLE
extension FooBar.Nested : Hashable {
}
#endif
extension FooBar.Nested : Sendable {
}
extension FooBar.Nested : ProtoDefaultedValue {
public static var defaultedValue: Self {
.init()
}
}
extension FooBar.Nested : ProtoMessage {
public static func protoMessageTypeURL() -> String {
return "type.googleapis.com/squareup.protos.custom_options.FooBar.Nested"
}
}
extension FooBar.Nested : Proto2Codable {
public init(from protoReader: ProtoReader) throws {
var value: FooBar.FooBarBazEnum? = nil
let token = try protoReader.beginMessage()
while let tag = try protoReader.nextTag(token: token) {
switch tag {
case 1: value = try protoReader.decode(FooBar.FooBarBazEnum.self)
default: try protoReader.readUnknownField(tag: tag)
}
}
self.unknownFields = try protoReader.endMessage(token: token)
self.value = value
}
public func encode(to protoWriter: ProtoWriter) throws {
try protoWriter.encode(tag: 1, value: self.value)
try protoWriter.writeUnknownFields(unknownFields)
}
}
#if !WIRE_REMOVE_CODABLE
extension FooBar.Nested : Codable {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringLiteralCodingKeys.self)
self.value = try container.decodeIfPresent(FooBar.FooBarBazEnum.self, forKey: "value")
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringLiteralCodingKeys.self)
try container.encodeIfPresent(self.value, forKey: "value")
}
}
#endif
#if !WIRE_REMOVE_EQUATABLE
extension FooBar.More : Equatable {
}
#endif
#if !WIRE_REMOVE_HASHABLE
extension FooBar.More : Hashable {
}
#endif
extension FooBar.More : Sendable {
}
extension FooBar.More : ProtoDefaultedValue {
public static var defaultedValue: Self {
.init()
}
}
extension FooBar.More : ProtoMessage {
public static func protoMessageTypeURL() -> String {
return "type.googleapis.com/squareup.protos.custom_options.FooBar.More"
}
}
extension FooBar.More : Proto2Codable {
public init(from protoReader: ProtoReader) throws {
var serial: [Int32] = []
let token = try protoReader.beginMessage()
while let tag = try protoReader.nextTag(token: token) {
switch tag {
case 1: try protoReader.decode(into: &serial, encoding: .variable)
default: try protoReader.readUnknownField(tag: tag)
}
}
self.unknownFields = try protoReader.endMessage(token: token)
self.serial = serial
}
public func encode(to protoWriter: ProtoWriter) throws {
try protoWriter.encode(tag: 1, value: self.serial, encoding: .variable)
try protoWriter.writeUnknownFields(unknownFields)
}
}
#if !WIRE_REMOVE_CODABLE
extension FooBar.More : Codable {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringLiteralCodingKeys.self)
self.serial = try container.decodeProtoArray(Int32.self, forKey: "serial")
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringLiteralCodingKeys.self)
let includeDefaults = encoder.protoDefaultValuesEncodingStrategy == .include
if includeDefaults || !self.serial.isEmpty {
try container.encodeProtoArray(self.serial, forKey: "serial")
}
}
}
#endif
extension FooBar.FooBarBazEnum : Sendable {
}