Move E164/UUID handling in protobufs to callers

This commit is contained in:
Max Radermacher
2024-08-01 12:18:13 -05:00
committed by GitHub
parent 1528a4a969
commit 0ed1f04b8d
5 changed files with 12 additions and 81 deletions

View File

@@ -783,19 +783,7 @@ class MessageContext(BaseContext):
if proto_syntax == "proto3":
writer.add("return !proto.%s.isEmpty" % field.name_swift)
else:
is_uuid_or_e164 = field.name.endswith(
"Uuid"
) or field.name.endswith("E164")
if is_uuid_or_e164:
writer.add(
"return proto.%s && !proto.%s.isEmpty"
% (
field.has_accessor_name(),
field.name_swift,
)
)
else:
writer.add("return proto.%s" % field.has_accessor_name())
writer.add("return proto.%s" % field.has_accessor_name())
writer.pop_indent()
writer.add("}")
writer.newline()
@@ -1474,16 +1462,6 @@ public func serializedData() throws -> Data {
elif self.is_field_a_proto(field):
writer.add("proto.%s = valueParam.proto" % (field.name_swift,))
else:
if field.name.endswith("E164") and field.proto_type == "string":
writer.add("if let valueParam = valueParam.nilIfEmpty {")
writer.push_indent()
writer.add(
"owsAssertDebug(valueParam.isStructurallyValidE164)"
)
writer.pop_indent()
writer.add("}")
writer.newline()
writer.add("proto.%s = valueParam" % (field.name_swift,))
writer.pop_indent()
@@ -1526,13 +1504,6 @@ public func serializedData() throws -> Data {
elif self.is_field_a_proto(field):
writer.add("proto.%s = valueParam.proto" % (field.name_swift,))
else:
if field.name.endswith("E164") and field.proto_type == "string":
writer.add("if let valueParam = valueParam.nilIfEmpty {")
writer.push_indent()
writer.add("owsAssertDebug(valueParam.isStructurallyValidE164)")
writer.pop_indent()
writer.add("}")
writer.newline()
writer.add("proto.%s = valueParam" % (field.name_swift,))
writer.pop_indent()