Skip to content

Commit 3037b9b

Browse files
authored
Support blocking deprecated apis from the runtime. (#1814)
Tested with `swift test -Xswiftc -DREMOVE_DEPRECATED_APIS`.
1 parent dd5a9bc commit 3037b9b

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

Sources/SwiftProtobuf/Google_Protobuf_Duration+Extensions.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ extension Google_Protobuf_Duration: ExpressibleByFloatLiteral {
149149
}
150150

151151
extension Google_Protobuf_Duration {
152+
#if !REMOVE_DEPRECATED_APIS
152153
/// Creates a new `Google_Protobuf_Duration` that is equal to the given
153154
/// `TimeInterval` (measured in seconds), rounded to the nearest nanosecond.
154155
///
@@ -157,6 +158,7 @@ extension Google_Protobuf_Duration {
157158
public init(timeInterval: TimeInterval) {
158159
self.init(rounding: timeInterval, rule: .toNearestOrAwayFromZero)
159160
}
161+
#endif // !REMOVE_LEGACY_NAMEMAP_INITIALIZERS
160162

161163
/// Creates a new `Google_Protobuf_Duration` that is equal to the given
162164
/// `TimeInterval` (measured in seconds), rounded to the nearest nanosecond

Sources/SwiftProtobuf/Google_Protobuf_Timestamp+Extensions.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ extension Google_Protobuf_Timestamp: _CustomJSONCodable {
229229
}
230230

231231
extension Google_Protobuf_Timestamp {
232+
#if !REMOVE_DEPRECATED_APIS
232233
/// Creates a new `Google_Protobuf_Timestamp` initialized relative to 00:00:00
233234
/// UTC on 1 January 1970 by a given number of seconds.
234235
///
@@ -238,6 +239,7 @@ extension Google_Protobuf_Timestamp {
238239
public init(timeIntervalSince1970: TimeInterval) {
239240
self.init(roundingTimeIntervalSince1970: timeIntervalSince1970, rule: .toNearestOrAwayFromZero)
240241
}
242+
#endif // !REMOVE_DEPRECATED_APIS
241243

242244
/// Creates a new `Google_Protobuf_Timestamp` initialized relative to 00:00:00
243245
/// UTC on 1 January 1970 by a given number of seconds, rounded to the nearest
@@ -257,6 +259,7 @@ extension Google_Protobuf_Timestamp {
257259
self.init(seconds: s, nanos: n)
258260
}
259261

262+
#if !REMOVE_DEPRECATED_APIS
260263
/// Creates a new `Google_Protobuf_Timestamp` initialized relative to 00:00:00
261264
/// UTC on 1 January 2001 by a given number of seconds.
262265
///
@@ -269,6 +272,7 @@ extension Google_Protobuf_Timestamp {
269272
rule: .toNearestOrAwayFromZero
270273
)
271274
}
275+
#endif // !REMOVE_DEPRECATED_APIS
272276

273277
/// Creates a new `Google_Protobuf_Timestamp` initialized relative to 00:00:00
274278
/// UTC on 1 January 2001 by a given number of seconds, rounded to the nearest

Sources/SwiftProtobuf/Internal.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Foundation
2020
/// - Important: NOT INTENDED TO BE CALLED BY CLIENTS.
2121
public enum Internal {
2222

23+
#if !REMOVE_DEPRECATED_APIS
2324
/// A singleton instance of an empty data that is used by the generated code
2425
/// for default values. This is a performance enhancement to work around the
2526
/// fact that the `Data` type in Swift involves a new heap allocation every
@@ -33,6 +34,7 @@ public enum Internal {
3334
"Internal.emptyData isn't used any longer in newer versions of the generator. Generate code with a version later than 1.10.2 to get performance improvements. See https://github.com/apple/swift-protobuf/pull/1028 for more information."
3435
)
3536
public static let emptyData = Data()
37+
#endif // !REMOVE_DEPRECATED_APIS
3638

3739
/// Helper to loop over a list of Messages to see if they are all
3840
/// initialized (see Message.isInitialized for what that means).

Sources/SwiftProtobuf/Message+BinaryAdditions_Data.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Foundation
1616

1717
/// Binary encoding and decoding methods for messages.
1818
extension Message {
19+
#if !REMOVE_DEPRECATED_APIS
1920
/// Creates a new message by decoding the given `Data` value
2021
/// containing a serialized message in Protocol Buffer binary format.
2122
///
@@ -171,6 +172,7 @@ extension Message {
171172
try _merge(rawBuffer: body, extensions: extensions, partial: partial, options: options)
172173
}
173174
}
175+
#endif // !REMOVE_DEPRECATED_APIS
174176

175177
/// Updates the message by decoding the given `Data` value
176178
/// containing a serialized message in Protocol Buffer binary format into the

0 commit comments

Comments
 (0)