Skip to content

Commit 93e0e81

Browse files
committed
move proto resources into separate directory, update SwiftProtobuf to v1.37 and update generated pb.swift files.
pb.swift files were generated via: cd Sources/App/ProtoResources protoc --swift_out=.. database.proto protoc --swift_out=.. api.proto
1 parent 5521d5f commit 93e0e81

6 files changed

Lines changed: 106 additions & 160 deletions

File tree

Package.resolved

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ let package = Package(
1919
.product(name: "Vapor", package: "vapor"),
2020
"SwiftProtobuf",
2121
],
22+
exclude: ["ProtoResources/"],
2223
swiftSettings: [
2324
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release)),
24-
.unsafeFlags(["-enable-testing"], .when(configuration: .release)),
2525
.unsafeFlags(["-Ounchecked"], .when(configuration: .release)),
26-
]
26+
],
2727
),
2828
.target(name: "Run", dependencies: [.target(name: "App")]),
2929
.testTarget(

Sources/App/api.pb.swift

Lines changed: 39 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// DO NOT EDIT.
22
// swift-format-ignore-file
3+
// swiftlint:disable all
34
//
45
// Generated by the Swift generator plugin for the protocol buffer compiler.
56
// Source: api.proto
67
//
78
// For information on using the generated types, please see the documentation:
89
// https://github.com/apple/swift-protobuf/
910

10-
import Foundation
1111
import SwiftProtobuf
1212

1313
// If the compiler emits an error on this type, it is because this file
@@ -20,14 +20,14 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
2020
typealias Version = _2
2121
}
2222

23-
struct GeocodingApi {
23+
struct GeocodingApi: Sendable {
2424
// SwiftProtobuf.Message conformance is added in an extension below. See the
2525
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
2626
// methods supported on all messages.
2727

2828
var unknownFields = SwiftProtobuf.UnknownStorage()
2929

30-
struct SearchResults {
30+
struct SearchResults: Sendable {
3131
// SwiftProtobuf.Message conformance is added in an extension below. See the
3232
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
3333
// methods supported on all messages.
@@ -41,114 +41,114 @@ struct GeocodingApi {
4141
init() {}
4242
}
4343

44-
struct Geoname {
44+
struct Geoname: @unchecked Sendable {
4545
// SwiftProtobuf.Message conformance is added in an extension below. See the
4646
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
4747
// methods supported on all messages.
4848

4949
var id: Int32 {
50-
get {return _storage._id}
50+
get {_storage._id}
5151
set {_uniqueStorage()._id = newValue}
5252
}
5353

5454
var name: String {
55-
get {return _storage._name}
55+
get {_storage._name}
5656
set {_uniqueStorage()._name = newValue}
5757
}
5858

5959
var latitude: Float {
60-
get {return _storage._latitude}
60+
get {_storage._latitude}
6161
set {_uniqueStorage()._latitude = newValue}
6262
}
6363

6464
var longitude: Float {
65-
get {return _storage._longitude}
65+
get {_storage._longitude}
6666
set {_uniqueStorage()._longitude = newValue}
6767
}
6868

6969
var ranking: Float {
70-
get {return _storage._ranking}
70+
get {_storage._ranking}
7171
set {_uniqueStorage()._ranking = newValue}
7272
}
7373

7474
var elevation: Float {
75-
get {return _storage._elevation}
75+
get {_storage._elevation}
7676
set {_uniqueStorage()._elevation = newValue}
7777
}
7878

7979
var featureCode: String {
80-
get {return _storage._featureCode}
80+
get {_storage._featureCode}
8181
set {_uniqueStorage()._featureCode = newValue}
8282
}
8383

8484
var countryCode: String {
85-
get {return _storage._countryCode}
85+
get {_storage._countryCode}
8686
set {_uniqueStorage()._countryCode = newValue}
8787
}
8888

8989
var countryID: Int32 {
90-
get {return _storage._countryID}
90+
get {_storage._countryID}
9191
set {_uniqueStorage()._countryID = newValue}
9292
}
9393

9494
var country: String {
95-
get {return _storage._country}
95+
get {_storage._country}
9696
set {_uniqueStorage()._country = newValue}
9797
}
9898

9999
var admin1ID: Int32 {
100-
get {return _storage._admin1ID}
100+
get {_storage._admin1ID}
101101
set {_uniqueStorage()._admin1ID = newValue}
102102
}
103103

104104
var admin2ID: Int32 {
105-
get {return _storage._admin2ID}
105+
get {_storage._admin2ID}
106106
set {_uniqueStorage()._admin2ID = newValue}
107107
}
108108

109109
var admin3ID: Int32 {
110-
get {return _storage._admin3ID}
110+
get {_storage._admin3ID}
111111
set {_uniqueStorage()._admin3ID = newValue}
112112
}
113113

114114
var admin4ID: Int32 {
115-
get {return _storage._admin4ID}
115+
get {_storage._admin4ID}
116116
set {_uniqueStorage()._admin4ID = newValue}
117117
}
118118

119119
var admin1: String {
120-
get {return _storage._admin1}
120+
get {_storage._admin1}
121121
set {_uniqueStorage()._admin1 = newValue}
122122
}
123123

124124
var admin2: String {
125-
get {return _storage._admin2}
125+
get {_storage._admin2}
126126
set {_uniqueStorage()._admin2 = newValue}
127127
}
128128

129129
var admin3: String {
130-
get {return _storage._admin3}
130+
get {_storage._admin3}
131131
set {_uniqueStorage()._admin3 = newValue}
132132
}
133133

134134
var admin4: String {
135-
get {return _storage._admin4}
135+
get {_storage._admin4}
136136
set {_uniqueStorage()._admin4 = newValue}
137137
}
138138

139139
var timezone: String {
140-
get {return _storage._timezone}
140+
get {_storage._timezone}
141141
set {_uniqueStorage()._timezone = newValue}
142142
}
143143

144144
var population: UInt32 {
145-
get {return _storage._population}
145+
get {_storage._population}
146146
set {_uniqueStorage()._population = newValue}
147147
}
148148

149149
///map<int32, string> alternativeNames = 16;
150150
var postcodes: [String] {
151-
get {return _storage._postcodes}
151+
get {_storage._postcodes}
152152
set {_uniqueStorage()._postcodes = newValue}
153153
}
154154

@@ -169,8 +169,8 @@ extension GeocodingApi: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat
169169
static let _protobuf_nameMap = SwiftProtobuf._NameMap()
170170

171171
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
172-
while let _ = try decoder.nextFieldNumber() {
173-
}
172+
// Load everything into unknown fields
173+
while try decoder.nextFieldNumber() != nil {}
174174
}
175175

176176
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
@@ -185,10 +185,7 @@ extension GeocodingApi: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat
185185

186186
extension GeocodingApi.SearchResults: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
187187
static let protoMessageName: String = GeocodingApi.protoMessageName + ".SearchResults"
188-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
189-
1: .same(proto: "results"),
190-
2: .standard(proto: "generationtime_ms"),
191-
]
188+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}results\0\u{3}generationtime_ms\0")
192189

193190
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
194191
while let fieldNumber = try decoder.nextFieldNumber() {
@@ -207,7 +204,7 @@ extension GeocodingApi.SearchResults: SwiftProtobuf.Message, SwiftProtobuf._Mess
207204
if !self.results.isEmpty {
208205
try visitor.visitRepeatedMessageField(value: self.results, fieldNumber: 1)
209206
}
210-
if self.generationtimeMs != 0 {
207+
if self.generationtimeMs.bitPattern != 0 {
211208
try visitor.visitSingularFloatField(value: self.generationtimeMs, fieldNumber: 2)
212209
}
213210
try unknownFields.traverse(visitor: &visitor)
@@ -223,29 +220,7 @@ extension GeocodingApi.SearchResults: SwiftProtobuf.Message, SwiftProtobuf._Mess
223220

224221
extension GeocodingApi.Geoname: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
225222
static let protoMessageName: String = GeocodingApi.protoMessageName + ".Geoname"
226-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
227-
1: .same(proto: "id"),
228-
2: .same(proto: "name"),
229-
4: .same(proto: "latitude"),
230-
5: .same(proto: "longitude"),
231-
6: .same(proto: "ranking"),
232-
7: .same(proto: "elevation"),
233-
8: .standard(proto: "feature_code"),
234-
9: .standard(proto: "country_code"),
235-
18: .standard(proto: "country_id"),
236-
19: .same(proto: "country"),
237-
10: .standard(proto: "admin1_id"),
238-
11: .standard(proto: "admin2_id"),
239-
12: .standard(proto: "admin3_id"),
240-
13: .standard(proto: "admin4_id"),
241-
20: .same(proto: "admin1"),
242-
21: .same(proto: "admin2"),
243-
22: .same(proto: "admin3"),
244-
23: .same(proto: "admin4"),
245-
14: .same(proto: "timezone"),
246-
15: .same(proto: "population"),
247-
17: .same(proto: "postcodes"),
248-
]
223+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}id\0\u{1}name\0\u{2}\u{2}latitude\0\u{1}longitude\0\u{1}ranking\0\u{1}elevation\0\u{3}feature_code\0\u{3}country_code\0\u{3}admin1_id\0\u{3}admin2_id\0\u{3}admin3_id\0\u{3}admin4_id\0\u{1}timezone\0\u{1}population\0\u{2}\u{2}postcodes\0\u{3}country_id\0\u{1}country\0\u{1}admin1\0\u{1}admin2\0\u{1}admin3\0\u{1}admin4\0")
249224

250225
fileprivate class _StorageClass {
251226
var _id: Int32 = 0
@@ -270,7 +245,11 @@ extension GeocodingApi.Geoname: SwiftProtobuf.Message, SwiftProtobuf._MessageImp
270245
var _population: UInt32 = 0
271246
var _postcodes: [String] = []
272247

273-
static let defaultInstance = _StorageClass()
248+
// This property is used as the initial default value for new instances of the type.
249+
// The type itself is protecting the reference to its storage via CoW semantics.
250+
// This will force a copy to be made of this reference when the first mutation occurs;
251+
// hence, it is safe to mark this as `nonisolated(unsafe)`.
252+
static nonisolated(unsafe) let defaultInstance = _StorageClass()
274253

275254
private init() {}
276255

@@ -349,16 +328,16 @@ extension GeocodingApi.Geoname: SwiftProtobuf.Message, SwiftProtobuf._MessageImp
349328
if !_storage._name.isEmpty {
350329
try visitor.visitSingularStringField(value: _storage._name, fieldNumber: 2)
351330
}
352-
if _storage._latitude != 0 {
331+
if _storage._latitude.bitPattern != 0 {
353332
try visitor.visitSingularFloatField(value: _storage._latitude, fieldNumber: 4)
354333
}
355-
if _storage._longitude != 0 {
334+
if _storage._longitude.bitPattern != 0 {
356335
try visitor.visitSingularFloatField(value: _storage._longitude, fieldNumber: 5)
357336
}
358-
if _storage._ranking != 0 {
337+
if _storage._ranking.bitPattern != 0 {
359338
try visitor.visitSingularFloatField(value: _storage._ranking, fieldNumber: 6)
360339
}
361-
if _storage._elevation != 0 {
340+
if _storage._elevation.bitPattern != 0 {
362341
try visitor.visitSingularFloatField(value: _storage._elevation, fieldNumber: 7)
363342
}
364343
if !_storage._featureCode.isEmpty {

0 commit comments

Comments
 (0)