restrict debug methods

This commit is contained in:
Michael Kirk 2018-08-21 18:40:55 -06:00
parent 1295a09ab3
commit 2fc3a211f1
9 changed files with 840 additions and 971 deletions

View file

@ -35,6 +35,34 @@ def lowerCamlCaseForUnderscoredText_wrapped(name):
result = result[:-2] + 'ID'
return result
# Provides conext for writing an indented block surrounded by braces.
#
# e.g.
#
# with BracedContext('class Foo', writer) as writer:
# with BracedContext('func bar() -> Bool', writer) as writer:
# return true
#
# Produces:
#
# class Foo {
# func bar() -> Bool {
# return true
# }
# }
#
class BracedContext:
def __init__(self, line, writer):
self.writer = writer
writer.add('%s {' % line)
def __enter__(self):
self.writer.push_indent()
return self.writer
def __exit__(self, *args):
self.writer.pop_indent()
self.writer.add('}')
class WriterContext:
def __init__(self, proto_name, swift_name, parent=None):
@ -43,7 +71,6 @@ class WriterContext:
self.parent = parent
self.name_map = {}
class LineWriter:
def __init__(self, args):
self.contexts = []
@ -51,6 +78,9 @@ class LineWriter:
self.lines = []
self.args = args
self.current_indent = 0
def braced(self, line):
return BracedContext(line, self)
def push_indent(self):
self.current_indent = self.current_indent + 1
@ -358,6 +388,7 @@ class MessageContext(BaseContext):
def prepare(self):
self.swift_name = self.derive_swift_name()
self.swift_builder_name = "%sBuilder" % self.swift_name
for child in self.children():
child.prepare()
@ -495,22 +526,7 @@ class MessageContext(BaseContext):
writer.pop_indent()
writer.add('}')
writer.newline()
# serializedDataIgnoringErrors() func
writer.add('// NOTE: This method is intended for debugging purposes only.')
writer.add('@objc public func serializedDataIgnoringErrors() -> Data? {')
writer.push_indent()
writer.add('guard _isDebugAssertConfiguration() else {')
writer.push_indent()
writer.add('return nil')
writer.pop_indent()
writer.add('}')
writer.newline()
writer.add('return try! self.serializedData()')
writer.pop_indent()
writer.add('}')
writer.newline()
# serializedData() func
writer.extend(('''
@objc
@ -628,15 +644,33 @@ public func serializedData() throws -> Data {
writer.rstrip()
writer.add('}')
writer.newline()
self.generate_debug_extension(writer)
def generate_debug_extension(self, writer):
writer.add('#if DEBUG')
writer.newline()
with writer.braced('extension %s' % self.swift_name) as writer:
with writer.braced('@objc public func serializedDataIgnoringErrors() -> Data?') as writer:
writer.add('return try! self.serializedData()')
writer.newline()
with writer.braced('extension %s.%s' % ( self.swift_name, self.swift_builder_name )) as writer:
with writer.braced('@objc public func buildIgnoringErrors() -> %s?' % self.swift_name) as writer:
writer.add('return try! self.build()')
writer.newline()
writer.add('#endif')
writer.newline()
def generate_builder(self, writer):
wrapped_swift_name = self.derive_wrapped_swift_name()
writer.add('// MARK: - %sBuilder' % self.swift_name)
writer.add('// MARK: - %s' % self.swift_builder_name)
writer.newline()
writer.add('@objc public class %sBuilder: NSObject {' % self.swift_name)
writer.add('@objc public class %s: NSObject {' % self.swift_builder_name)
writer.newline()
writer.push_context(self.proto_name, self.swift_name)
@ -750,22 +784,7 @@ public func serializedData() throws -> Data {
writer.pop_indent()
writer.add('}')
writer.newline()
# buildIgnoringErrors() func
writer.add('// NOTE: This method is intended for debugging purposes only.')
writer.add('@objc public func buildIgnoringErrors() -> %s? {' % self.swift_name)
writer.push_indent()
writer.add('guard _isDebugAssertConfiguration() else {')
writer.push_indent()
writer.add('return nil')
writer.pop_indent()
writer.add('}')
writer.newline()
writer.add('return try! self.build()')
writer.pop_indent()
writer.add('}')
writer.newline()
# build() func
writer.add('@objc public func build() throws -> %s {' % self.swift_name)
writer.push_indent()
@ -1197,4 +1216,4 @@ if __name__ == "__main__":
process_proto_file(args, proto_file_path, dst_file_path)
# print 'complete.'

View file

@ -33,15 +33,6 @@ public enum WebRTCProtoError: Error {
proto.id = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebRTCProtoConnected? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebRTCProtoConnected {
return try WebRTCProtoConnected.parseProto(proto)
}
@ -61,15 +52,6 @@ public enum WebRTCProtoError: Error {
self.id = id
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -96,6 +78,22 @@ public enum WebRTCProtoError: Error {
}
}
#if DEBUG
extension WebRTCProtoConnected {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebRTCProtoConnected.WebRTCProtoConnectedBuilder {
@objc public func buildIgnoringErrors() -> WebRTCProtoConnected? {
return try! self.build()
}
}
#endif
// MARK: - WebRTCProtoHangup
@objc public class WebRTCProtoHangup: NSObject {
@ -119,15 +117,6 @@ public enum WebRTCProtoError: Error {
proto.id = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebRTCProtoHangup? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebRTCProtoHangup {
return try WebRTCProtoHangup.parseProto(proto)
}
@ -147,15 +136,6 @@ public enum WebRTCProtoError: Error {
self.id = id
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -182,6 +162,22 @@ public enum WebRTCProtoError: Error {
}
}
#if DEBUG
extension WebRTCProtoHangup {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebRTCProtoHangup.WebRTCProtoHangupBuilder {
@objc public func buildIgnoringErrors() -> WebRTCProtoHangup? {
return try! self.build()
}
}
#endif
// MARK: - WebRTCProtoVideoStreamingStatus
@objc public class WebRTCProtoVideoStreamingStatus: NSObject {
@ -209,15 +205,6 @@ public enum WebRTCProtoError: Error {
proto.enabled = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebRTCProtoVideoStreamingStatus? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebRTCProtoVideoStreamingStatus {
return try WebRTCProtoVideoStreamingStatus.parseProto(proto)
}
@ -244,15 +231,6 @@ public enum WebRTCProtoError: Error {
self.id = id
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -279,6 +257,22 @@ public enum WebRTCProtoError: Error {
}
}
#if DEBUG
extension WebRTCProtoVideoStreamingStatus {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebRTCProtoVideoStreamingStatus.WebRTCProtoVideoStreamingStatusBuilder {
@objc public func buildIgnoringErrors() -> WebRTCProtoVideoStreamingStatus? {
return try! self.build()
}
}
#endif
// MARK: - WebRTCProtoData
@objc public class WebRTCProtoData: NSObject {
@ -303,15 +297,6 @@ public enum WebRTCProtoError: Error {
proto.videoStreamingStatus = valueParam.proto
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebRTCProtoData? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebRTCProtoData {
return try WebRTCProtoData.parseProto(proto)
}
@ -339,15 +324,6 @@ public enum WebRTCProtoError: Error {
self.videoStreamingStatus = videoStreamingStatus
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -359,17 +335,17 @@ public enum WebRTCProtoError: Error {
}
fileprivate class func parseProto(_ proto: WebRTCProtos_Data) throws -> WebRTCProtoData {
var connected: WebRTCProtoConnected?
var connected: WebRTCProtoConnected? = nil
if proto.hasConnected {
connected = try WebRTCProtoConnected.parseProto(proto.connected)
}
var hangup: WebRTCProtoHangup?
var hangup: WebRTCProtoHangup? = nil
if proto.hasHangup {
hangup = try WebRTCProtoHangup.parseProto(proto.hangup)
}
var videoStreamingStatus: WebRTCProtoVideoStreamingStatus?
var videoStreamingStatus: WebRTCProtoVideoStreamingStatus? = nil
if proto.hasVideoStreamingStatus {
videoStreamingStatus = try WebRTCProtoVideoStreamingStatus.parseProto(proto.videoStreamingStatus)
}
@ -385,3 +361,19 @@ public enum WebRTCProtoError: Error {
return result
}
}
#if DEBUG
extension WebRTCProtoData {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebRTCProtoData.WebRTCProtoDataBuilder {
@objc public func buildIgnoringErrors() -> WebRTCProtoData? {
return try! self.build()
}
}
#endif

View file

@ -33,15 +33,6 @@ public enum FingerprintProtoError: Error {
proto.identityData = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> FingerprintProtoLogicalFingerprint? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> FingerprintProtoLogicalFingerprint {
return try FingerprintProtoLogicalFingerprint.parseProto(proto)
}
@ -61,15 +52,6 @@ public enum FingerprintProtoError: Error {
self.identityData = identityData
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -96,6 +78,22 @@ public enum FingerprintProtoError: Error {
}
}
#if DEBUG
extension FingerprintProtoLogicalFingerprint {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension FingerprintProtoLogicalFingerprint.FingerprintProtoLogicalFingerprintBuilder {
@objc public func buildIgnoringErrors() -> FingerprintProtoLogicalFingerprint? {
return try! self.build()
}
}
#endif
// MARK: - FingerprintProtoLogicalFingerprints
@objc public class FingerprintProtoLogicalFingerprints: NSObject {
@ -129,15 +127,6 @@ public enum FingerprintProtoError: Error {
proto.remoteFingerprint = valueParam.proto
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> FingerprintProtoLogicalFingerprints? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> FingerprintProtoLogicalFingerprints {
return try FingerprintProtoLogicalFingerprints.parseProto(proto)
}
@ -165,15 +154,6 @@ public enum FingerprintProtoError: Error {
self.remoteFingerprint = remoteFingerprint
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -211,3 +191,19 @@ public enum FingerprintProtoError: Error {
return result
}
}
#if DEBUG
extension FingerprintProtoLogicalFingerprints {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension FingerprintProtoLogicalFingerprints.FingerprintProtoLogicalFingerprintsBuilder {
@objc public func buildIgnoringErrors() -> FingerprintProtoLogicalFingerprints? {
return try! self.build()
}
}
#endif

View file

@ -38,15 +38,6 @@ public enum ProvisioningProtoError: Error {
proto.body = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> ProvisioningProtoProvisionEnvelope? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> ProvisioningProtoProvisionEnvelope {
return try ProvisioningProtoProvisionEnvelope.parseProto(proto)
}
@ -70,15 +61,6 @@ public enum ProvisioningProtoError: Error {
self.body = body
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -111,6 +93,22 @@ public enum ProvisioningProtoError: Error {
}
}
#if DEBUG
extension ProvisioningProtoProvisionEnvelope {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension ProvisioningProtoProvisionEnvelope.ProvisioningProtoProvisionEnvelopeBuilder {
@objc public func buildIgnoringErrors() -> ProvisioningProtoProvisionEnvelope? {
return try! self.build()
}
}
#endif
// MARK: - ProvisioningProtoProvisionMessage
@objc public class ProvisioningProtoProvisionMessage: NSObject {
@ -164,15 +162,6 @@ public enum ProvisioningProtoError: Error {
proto.readReceipts = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> ProvisioningProtoProvisionMessage? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> ProvisioningProtoProvisionMessage {
return try ProvisioningProtoProvisionMessage.parseProto(proto)
}
@ -216,15 +205,6 @@ public enum ProvisioningProtoError: Error {
self.readReceipts = readReceipts
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -286,3 +266,19 @@ public enum ProvisioningProtoError: Error {
return result
}
}
#if DEBUG
extension ProvisioningProtoProvisionMessage {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension ProvisioningProtoProvisionMessage.ProvisioningProtoProvisionMessageBuilder {
@objc public func buildIgnoringErrors() -> ProvisioningProtoProvisionMessage? {
return try! self.build()
}
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -68,15 +68,6 @@ public enum SignalIOSProtoError: Error {
proto.entityData = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> SignalIOSProtoBackupSnapshotBackupEntity? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> SignalIOSProtoBackupSnapshotBackupEntity {
return try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(proto)
}
@ -100,15 +91,6 @@ public enum SignalIOSProtoError: Error {
self.entityData = entityData
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -141,6 +123,22 @@ public enum SignalIOSProtoError: Error {
}
}
#if DEBUG
extension SignalIOSProtoBackupSnapshotBackupEntity {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityBuilder {
@objc public func buildIgnoringErrors() -> SignalIOSProtoBackupSnapshotBackupEntity? {
return try! self.build()
}
}
#endif
// MARK: - SignalIOSProtoBackupSnapshot
@objc public class SignalIOSProtoBackupSnapshot: NSObject {
@ -163,15 +161,6 @@ public enum SignalIOSProtoError: Error {
proto.entity = wrappedItems.map { $0.proto }
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> SignalIOSProtoBackupSnapshot? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> SignalIOSProtoBackupSnapshot {
return try SignalIOSProtoBackupSnapshot.parseProto(proto)
}
@ -191,15 +180,6 @@ public enum SignalIOSProtoError: Error {
self.entity = entity
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -223,3 +203,19 @@ public enum SignalIOSProtoError: Error {
return result
}
}
#if DEBUG
extension SignalIOSProtoBackupSnapshot {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension SignalIOSProtoBackupSnapshot.SignalIOSProtoBackupSnapshotBuilder {
@objc public func buildIgnoringErrors() -> SignalIOSProtoBackupSnapshot? {
return try! self.build()
}
}
#endif

View file

@ -149,14 +149,6 @@ struct SignalServiceProtos_Envelope {
fileprivate var _content: Data? = nil
}
#if swift(>=4.2)
extension SignalServiceProtos_Envelope.TypeEnum: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
struct SignalServiceProtos_Content {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
@ -1108,14 +1100,6 @@ struct SignalServiceProtos_DataMessage {
fileprivate var _storage = _StorageClass.defaultInstance
}
#if swift(>=4.2)
extension SignalServiceProtos_DataMessage.Flags: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
struct SignalServiceProtos_NullMessage {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
@ -1187,14 +1171,6 @@ struct SignalServiceProtos_ReceiptMessage {
fileprivate var _type: SignalServiceProtos_ReceiptMessage.TypeEnum? = nil
}
#if swift(>=4.2)
extension SignalServiceProtos_ReceiptMessage.TypeEnum: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
struct SignalServiceProtos_Verified {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
@ -1276,14 +1252,6 @@ struct SignalServiceProtos_Verified {
fileprivate var _nullMessage: Data? = nil
}
#if swift(>=4.2)
extension SignalServiceProtos_Verified.State: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
struct SignalServiceProtos_SyncMessage {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
@ -1732,14 +1700,6 @@ struct SignalServiceProtos_AttachmentPointer {
fileprivate var _height: UInt32? = nil
}
#if swift(>=4.2)
extension SignalServiceProtos_AttachmentPointer.Flags: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
struct SignalServiceProtos_GroupContext {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
@ -1830,14 +1790,6 @@ struct SignalServiceProtos_GroupContext {
fileprivate var _storage = _StorageClass.defaultInstance
}
#if swift(>=4.2)
extension SignalServiceProtos_GroupContext.TypeEnum: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
struct SignalServiceProtos_ContactDetails {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for

View file

@ -57,15 +57,6 @@ public enum WebSocketProtoError: Error {
proto.requestID = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebSocketProtoWebSocketRequestMessage? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebSocketProtoWebSocketRequestMessage {
return try WebSocketProtoWebSocketRequestMessage.parseProto(proto)
}
@ -107,15 +98,6 @@ public enum WebSocketProtoError: Error {
self.requestID = requestID
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -154,6 +136,22 @@ public enum WebSocketProtoError: Error {
}
}
#if DEBUG
extension WebSocketProtoWebSocketRequestMessage {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebSocketProtoWebSocketRequestMessage.WebSocketProtoWebSocketRequestMessageBuilder {
@objc public func buildIgnoringErrors() -> WebSocketProtoWebSocketRequestMessage? {
return try! self.build()
}
}
#endif
// MARK: - WebSocketProtoWebSocketResponseMessage
@objc public class WebSocketProtoWebSocketResponseMessage: NSObject {
@ -200,15 +198,6 @@ public enum WebSocketProtoError: Error {
proto.body = valueParam
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebSocketProtoWebSocketResponseMessage? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebSocketProtoWebSocketResponseMessage {
return try WebSocketProtoWebSocketResponseMessage.parseProto(proto)
}
@ -256,15 +245,6 @@ public enum WebSocketProtoError: Error {
self.status = status
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -297,6 +277,22 @@ public enum WebSocketProtoError: Error {
}
}
#if DEBUG
extension WebSocketProtoWebSocketResponseMessage {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebSocketProtoWebSocketResponseMessage.WebSocketProtoWebSocketResponseMessageBuilder {
@objc public func buildIgnoringErrors() -> WebSocketProtoWebSocketResponseMessage? {
return try! self.build()
}
}
#endif
// MARK: - WebSocketProtoWebSocketMessage
@objc public class WebSocketProtoWebSocketMessage: NSObject {
@ -352,15 +348,6 @@ public enum WebSocketProtoError: Error {
proto.response = valueParam.proto
}
// NOTE: This method is intended for debugging purposes only.
@objc public func buildIgnoringErrors() -> WebSocketProtoWebSocketMessage? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.build()
}
@objc public func build() throws -> WebSocketProtoWebSocketMessage {
return try WebSocketProtoWebSocketMessage.parseProto(proto)
}
@ -388,15 +375,6 @@ public enum WebSocketProtoError: Error {
self.response = response
}
// NOTE: This method is intended for debugging purposes only.
@objc public func serializedDataIgnoringErrors() -> Data? {
guard _isDebugAssertConfiguration() else {
return nil
}
return try! self.serializedData()
}
@objc
public func serializedData() throws -> Data {
return try self.proto.serializedData()
@ -413,12 +391,12 @@ public enum WebSocketProtoError: Error {
}
let type = WebSocketProtoWebSocketMessageTypeWrap(proto.type)
var request: WebSocketProtoWebSocketRequestMessage?
var request: WebSocketProtoWebSocketRequestMessage? = nil
if proto.hasRequest {
request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request)
}
var response: WebSocketProtoWebSocketResponseMessage?
var response: WebSocketProtoWebSocketResponseMessage? = nil
if proto.hasResponse {
response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response)
}
@ -434,3 +412,19 @@ public enum WebSocketProtoError: Error {
return result
}
}
#if DEBUG
extension WebSocketProtoWebSocketMessage {
@objc public func serializedDataIgnoringErrors() -> Data? {
return try! self.serializedData()
}
}
extension WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageBuilder {
@objc public func buildIgnoringErrors() -> WebSocketProtoWebSocketMessage? {
return try! self.build()
}
}
#endif

View file

@ -207,14 +207,6 @@ struct WebSocketProtos_WebSocketMessage {
fileprivate var _storage = _StorageClass.defaultInstance
}
#if swift(>=4.2)
extension WebSocketProtos_WebSocketMessage.TypeEnum: CaseIterable {
// Support synthesized by the compiler.
}
#endif // swift(>=4.2)
// MARK: - Code below here is support for the SwiftProtobuf runtime.
fileprivate let _protobuf_package = "WebSocketProtos"