Respond to CR.
This commit is contained in:
parent
1ab0842403
commit
21523ac522
|
@ -613,15 +613,16 @@ public func serializedData() throws -> Data {
|
||||||
writer.newline()
|
writer.newline()
|
||||||
|
|
||||||
# description
|
# description
|
||||||
writer.add('@objc public override var description: String {')
|
if self.args.add_description:
|
||||||
writer.push_indent()
|
writer.add('@objc public override var description: String {')
|
||||||
writer.add('var fields = [String]()')
|
writer.push_indent()
|
||||||
for field in self.fields():
|
writer.add('var fields = [String]()')
|
||||||
writer.add('fields.append("%s: \(proto.%s)")' % ( field.name_swift, field.name_swift, ) )
|
for field in self.fields():
|
||||||
writer.add('return "[" + fields.joined(separator: ", ") + "]"')
|
writer.add('fields.append("%s: \(proto.%s)")' % ( field.name_swift, field.name_swift, ) )
|
||||||
writer.pop_indent()
|
writer.add('return "[" + fields.joined(separator: ", ") + "]"')
|
||||||
writer.add('}')
|
writer.pop_indent()
|
||||||
writer.newline()
|
writer.add('}')
|
||||||
|
writer.newline()
|
||||||
|
|
||||||
writer.pop_context()
|
writer.pop_context()
|
||||||
|
|
||||||
|
@ -735,15 +736,16 @@ public func serializedData() throws -> Data {
|
||||||
writer.newline()
|
writer.newline()
|
||||||
|
|
||||||
# description
|
# description
|
||||||
writer.add('@objc public override var description: String {')
|
if self.args.add_description:
|
||||||
writer.push_indent()
|
writer.add('@objc public override var description: String {')
|
||||||
writer.add('var fields = [String]()')
|
writer.push_indent()
|
||||||
for field in self.fields():
|
writer.add('var fields = [String]()')
|
||||||
writer.add('fields.append("%s: \(proto.%s)")' % ( field.name_swift, field.name_swift, ) )
|
for field in self.fields():
|
||||||
writer.add('return "[" + fields.joined(separator: ", ") + "]"')
|
writer.add('fields.append("%s: \(proto.%s)")' % ( field.name_swift, field.name_swift, ) )
|
||||||
writer.pop_indent()
|
writer.add('return "[" + fields.joined(separator: ", ") + "]"')
|
||||||
writer.add('}')
|
writer.pop_indent()
|
||||||
writer.newline()
|
writer.add('}')
|
||||||
|
writer.newline()
|
||||||
|
|
||||||
writer.pop_context()
|
writer.pop_context()
|
||||||
|
|
||||||
|
@ -1124,6 +1126,7 @@ if __name__ == "__main__":
|
||||||
parser.add_argument('--proto-prefix', help='name prefix for proto bufs.')
|
parser.add_argument('--proto-prefix', help='name prefix for proto bufs.')
|
||||||
parser.add_argument('--dst-dir', help='path to the destination directory.')
|
parser.add_argument('--dst-dir', help='path to the destination directory.')
|
||||||
parser.add_argument('--add-log-tag', action='store_true', help='add log tag properties.')
|
parser.add_argument('--add-log-tag', action='store_true', help='add log tag properties.')
|
||||||
|
parser.add_argument('--add-description', action='store_true', help='add log tag properties.')
|
||||||
parser.add_argument('--verbose', action='store_true', help='enables verbose logging')
|
parser.add_argument('--verbose', action='store_true', help='enables verbose logging')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ import SignalMessaging
|
||||||
owsFail("\(self.logTag) could not serialize sync contacts data")
|
owsFail("\(self.logTag) could not serialize sync contacts data")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
|
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let attachmentDataSource = dataSource else {
|
guard let attachmentDataSource = dataSource else {
|
||||||
|
|
|
@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
// Returns NO on error.
|
// Returns NO on error.
|
||||||
- (BOOL)writeData:(NSData *)data;
|
- (BOOL)writeData:(NSData *)data;
|
||||||
- (BOOL)writeUInt32:(UInt32)value;
|
- (BOOL)writeVariableLengthUInt32:(UInt32)value;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,28 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
- (BOOL)writeData:(NSData *)data
|
- (BOOL)writeData:(NSData *)data
|
||||||
{
|
{
|
||||||
OWSAssert(data);
|
OWSAssert(data);
|
||||||
NSInteger written = [self.outputStream write:data.bytes maxLength:data.length];
|
|
||||||
if (written != data.length) {
|
if (data.length < 1) {
|
||||||
OWSFail(@"%@ could not write to output stream.", self.logTag);
|
return YES;
|
||||||
self.hasError = YES;
|
}
|
||||||
return NO;
|
|
||||||
|
while (YES) {
|
||||||
|
NSInteger written = [self.outputStream write:data.bytes maxLength:data.length];
|
||||||
|
if (written < 1) {
|
||||||
|
OWSFail(@"%@ could not write to output stream.", self.logTag);
|
||||||
|
self.hasError = YES;
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (written < data.length) {
|
||||||
|
data = [data subdataWithRange:NSMakeRange(written, data.length - written)];
|
||||||
|
} else {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)writeUInt32:(UInt32)value
|
- (BOOL)writeVariableLengthUInt32:(UInt32)value
|
||||||
{
|
{
|
||||||
while (YES) {
|
while (YES) {
|
||||||
if (value <= 0x7F) {
|
if (value <= 0x7F) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ disappearingMessagesConfiguration:(nullable OWSDisappearingMessagesConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t contactDataLength = (uint32_t)contactData.length;
|
uint32_t contactDataLength = (uint32_t)contactData.length;
|
||||||
[self writeUInt32:contactDataLength];
|
[self writeVariableLengthUInt32:contactDataLength];
|
||||||
[self writeData:contactData];
|
[self writeData:contactData];
|
||||||
|
|
||||||
if (avatarPng) {
|
if (avatarPng) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
uint32_t groupDataLength = (uint32_t)groupData.length;
|
uint32_t groupDataLength = (uint32_t)groupData.length;
|
||||||
|
|
||||||
[self writeUInt32:groupDataLength];
|
[self writeVariableLengthUInt32:groupDataLength];
|
||||||
[self writeData:groupData];
|
[self writeData:groupData];
|
||||||
|
|
||||||
if (avatarPng) {
|
if (avatarPng) {
|
||||||
|
|
|
@ -43,12 +43,6 @@ public enum FingerprintProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try FingerprintProtoLogicalFingerprint.parseProto(proto).serializedData()
|
return try FingerprintProtoLogicalFingerprint.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("identityData: \(proto.identityData)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: FingerprintProtos_LogicalFingerprint
|
fileprivate let proto: FingerprintProtos_LogicalFingerprint
|
||||||
|
@ -94,12 +88,6 @@ public enum FingerprintProtoError: Error {
|
||||||
identityData: identityData)
|
identityData: identityData)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("identityData: \(proto.identityData)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - FingerprintProtoLogicalFingerprints
|
// MARK: - FingerprintProtoLogicalFingerprints
|
||||||
|
@ -142,14 +130,6 @@ public enum FingerprintProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try FingerprintProtoLogicalFingerprints.parseProto(proto).serializedData()
|
return try FingerprintProtoLogicalFingerprints.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("version: \(proto.version)")
|
|
||||||
fields.append("localFingerprint: \(proto.localFingerprint)")
|
|
||||||
fields.append("remoteFingerprint: \(proto.remoteFingerprint)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: FingerprintProtos_LogicalFingerprints
|
fileprivate let proto: FingerprintProtos_LogicalFingerprints
|
||||||
|
@ -215,12 +195,4 @@ public enum FingerprintProtoError: Error {
|
||||||
remoteFingerprint: remoteFingerprint)
|
remoteFingerprint: remoteFingerprint)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("version: \(proto.version)")
|
|
||||||
fields.append("localFingerprint: \(proto.localFingerprint)")
|
|
||||||
fields.append("remoteFingerprint: \(proto.remoteFingerprint)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,6 @@ public enum ProvisioningProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try ProvisioningProtoProvisionEnvelope.parseProto(proto).serializedData()
|
return try ProvisioningProtoProvisionEnvelope.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("publicKey: \(proto.publicKey)")
|
|
||||||
fields.append("body: \(proto.body)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: ProvisioningProtos_ProvisionEnvelope
|
fileprivate let proto: ProvisioningProtos_ProvisionEnvelope
|
||||||
|
@ -109,13 +102,6 @@ public enum ProvisioningProtoError: Error {
|
||||||
body: body)
|
body: body)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("publicKey: \(proto.publicKey)")
|
|
||||||
fields.append("body: \(proto.body)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - ProvisioningProtoProvisionMessage
|
// MARK: - ProvisioningProtoProvisionMessage
|
||||||
|
@ -174,18 +160,6 @@ public enum ProvisioningProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try ProvisioningProtoProvisionMessage.parseProto(proto).serializedData()
|
return try ProvisioningProtoProvisionMessage.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("identityKeyPublic: \(proto.identityKeyPublic)")
|
|
||||||
fields.append("identityKeyPrivate: \(proto.identityKeyPrivate)")
|
|
||||||
fields.append("number: \(proto.number)")
|
|
||||||
fields.append("provisioningCode: \(proto.provisioningCode)")
|
|
||||||
fields.append("userAgent: \(proto.userAgent)")
|
|
||||||
fields.append("profileKey: \(proto.profileKey)")
|
|
||||||
fields.append("readReceipts: \(proto.readReceipts)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: ProvisioningProtos_ProvisionMessage
|
fileprivate let proto: ProvisioningProtos_ProvisionMessage
|
||||||
|
@ -291,16 +265,4 @@ public enum ProvisioningProtoError: Error {
|
||||||
readReceipts: readReceipts)
|
readReceipts: readReceipts)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("identityKeyPublic: \(proto.identityKeyPublic)")
|
|
||||||
fields.append("identityKeyPrivate: \(proto.identityKeyPrivate)")
|
|
||||||
fields.append("number: \(proto.number)")
|
|
||||||
fields.append("provisioningCode: \(proto.provisioningCode)")
|
|
||||||
fields.append("userAgent: \(proto.userAgent)")
|
|
||||||
fields.append("profileKey: \(proto.profileKey)")
|
|
||||||
fields.append("readReceipts: \(proto.readReceipts)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -77,13 +77,6 @@ public enum SignalIOSProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(proto).serializedData()
|
return try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("type: \(proto.type)")
|
|
||||||
fields.append("entityData: \(proto.entityData)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: IOSProtos_BackupSnapshot.BackupEntity
|
fileprivate let proto: IOSProtos_BackupSnapshot.BackupEntity
|
||||||
|
@ -139,13 +132,6 @@ public enum SignalIOSProtoError: Error {
|
||||||
entityData: entityData)
|
entityData: entityData)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("type: \(proto.type)")
|
|
||||||
fields.append("entityData: \(proto.entityData)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - SignalIOSProtoBackupSnapshot
|
// MARK: - SignalIOSProtoBackupSnapshot
|
||||||
|
@ -186,12 +172,6 @@ public enum SignalIOSProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try SignalIOSProtoBackupSnapshot.parseProto(proto).serializedData()
|
return try SignalIOSProtoBackupSnapshot.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("entity: \(proto.entity)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: IOSProtos_BackupSnapshot
|
fileprivate let proto: IOSProtos_BackupSnapshot
|
||||||
|
@ -235,10 +215,4 @@ public enum SignalIOSProtoError: Error {
|
||||||
entity: entity)
|
entity: entity)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("entity: \(proto.entity)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,16 +65,6 @@ public enum WebSocketProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try WebSocketProtoWebSocketRequestMessage.parseProto(proto).serializedData()
|
return try WebSocketProtoWebSocketRequestMessage.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("verb: \(proto.verb)")
|
|
||||||
fields.append("path: \(proto.path)")
|
|
||||||
fields.append("body: \(proto.body)")
|
|
||||||
fields.append("headers: \(proto.headers)")
|
|
||||||
fields.append("requestID: \(proto.requestID)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: WebSocketProtos_WebSocketRequestMessage
|
fileprivate let proto: WebSocketProtos_WebSocketRequestMessage
|
||||||
|
@ -154,16 +144,6 @@ public enum WebSocketProtoError: Error {
|
||||||
requestID: requestID)
|
requestID: requestID)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("verb: \(proto.verb)")
|
|
||||||
fields.append("path: \(proto.path)")
|
|
||||||
fields.append("body: \(proto.body)")
|
|
||||||
fields.append("headers: \(proto.headers)")
|
|
||||||
fields.append("requestID: \(proto.requestID)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - WebSocketProtoWebSocketResponseMessage
|
// MARK: - WebSocketProtoWebSocketResponseMessage
|
||||||
|
@ -220,16 +200,6 @@ public enum WebSocketProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try WebSocketProtoWebSocketResponseMessage.parseProto(proto).serializedData()
|
return try WebSocketProtoWebSocketResponseMessage.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("requestID: \(proto.requestID)")
|
|
||||||
fields.append("status: \(proto.status)")
|
|
||||||
fields.append("message: \(proto.message)")
|
|
||||||
fields.append("headers: \(proto.headers)")
|
|
||||||
fields.append("body: \(proto.body)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: WebSocketProtos_WebSocketResponseMessage
|
fileprivate let proto: WebSocketProtos_WebSocketResponseMessage
|
||||||
|
@ -309,16 +279,6 @@ public enum WebSocketProtoError: Error {
|
||||||
status: status)
|
status: status)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("requestID: \(proto.requestID)")
|
|
||||||
fields.append("status: \(proto.status)")
|
|
||||||
fields.append("message: \(proto.message)")
|
|
||||||
fields.append("headers: \(proto.headers)")
|
|
||||||
fields.append("body: \(proto.body)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - WebSocketProtoWebSocketMessage
|
// MARK: - WebSocketProtoWebSocketMessage
|
||||||
|
@ -385,14 +345,6 @@ public enum WebSocketProtoError: Error {
|
||||||
@objc public func buildSerializedData() throws -> Data {
|
@objc public func buildSerializedData() throws -> Data {
|
||||||
return try WebSocketProtoWebSocketMessage.parseProto(proto).serializedData()
|
return try WebSocketProtoWebSocketMessage.parseProto(proto).serializedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("type: \(proto.type)")
|
|
||||||
fields.append("request: \(proto.request)")
|
|
||||||
fields.append("response: \(proto.response)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let proto: WebSocketProtos_WebSocketMessage
|
fileprivate let proto: WebSocketProtos_WebSocketMessage
|
||||||
|
@ -464,12 +416,4 @@ public enum WebSocketProtoError: Error {
|
||||||
response: response)
|
response: response)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override var description: String {
|
|
||||||
var fields = [String]()
|
|
||||||
fields.append("type: \(proto.type)")
|
|
||||||
fields.append("request: \(proto.request)")
|
|
||||||
fields.append("response: \(proto.response)")
|
|
||||||
return "[" + fields.joined(separator: ", ") + "]"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue