diff --git a/src/google/protobuf/compiler/objectivec/enum.cc b/src/google/protobuf/compiler/objectivec/enum.cc index fcd7706d17..3b81df8d63 100644 --- a/src/google/protobuf/compiler/objectivec/enum.cc +++ b/src/google/protobuf/compiler/objectivec/enum.cc @@ -130,13 +130,15 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { if (HasPreservingUnknownEnumSemantics(descriptor_->file())) { // Include the unknown value. printer->Print( - "/**\n" - " * Value used if any message's field encounters a value that is not defined\n" - " * by this enum. The message will also have C functions to get/set the rawValue\n" - " * of the field.\n" - " **/\n" - "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n", - "name", name_); + // clang-format off + "/**\n" + " * Value used if any message's field encounters a value that is not defined\n" + " * by this enum. The message will also have C functions to get/set the rawValue\n" + " * of the field.\n" + " **/\n" + "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n", + // clang-format on + "name", name_); } for (int i = 0; i < all_values_.size(); i++) { if (alias_values_to_skip_.find(all_values_[i]) != alias_values_to_skip_.end()) { @@ -160,6 +162,7 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { } printer->Outdent(); printer->Print( + // clang-format off "};\n" "\n" "GPBEnumDescriptor *$name$_EnumDescriptor(void);\n" @@ -169,6 +172,7 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { " * the time this source was generated.\n" " **/\n" "BOOL $name$_IsValidValue(int32_t value);\n" + // clang-format on "\n", "name", name_); } @@ -199,9 +203,11 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { } printer->Print( + // clang-format off "GPBEnumDescriptor *$name$_EnumDescriptor(void) {\n" " static _Atomic(GPBEnumDescriptor*) descriptor = nil;\n" " if (!descriptor) {\n", + // clang-format on "name", name_); static const int kBytesPerLine = 40; // allow for escaping @@ -222,15 +228,18 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { if (text_format_decode_data.num_entries() == 0) { printer->Print( + // clang-format off " GPBEnumDescriptor *worker =\n" " [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n" " valueNames:valueNames\n" " values:values\n" " count:(uint32_t)(sizeof(values) / sizeof(int32_t))\n" " enumVerifier:$name$_IsValidValue];\n", + // clang-format on "name", name_); - } else { - printer->Print( + } else { + printer->Print( + // clang-format off " static const char *extraTextFormatInfo = \"$extraTextFormatInfo$\";\n" " GPBEnumDescriptor *worker =\n" " [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n" @@ -239,21 +248,26 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { " count:(uint32_t)(sizeof(values) / sizeof(int32_t))\n" " enumVerifier:$name$_IsValidValue\n" " extraTextFormatInfo:extraTextFormatInfo];\n", + // clang-format on "name", name_, "extraTextFormatInfo", absl::CEscape(text_format_decode_data.Data())); - } - printer->Print( - " GPBEnumDescriptor *expected = nil;\n" - " if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {\n" - " [worker release];\n" - " }\n" - " }\n" - " return descriptor;\n" - "}\n\n"); + } + // clang-format off + printer->Print( + " GPBEnumDescriptor *expected = nil;\n" + " if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {\n" + " [worker release];\n" + " }\n" + " }\n" + " return descriptor;\n" + "}\n\n"); + // clang-format on printer->Print( + // clang-format off "BOOL $name$_IsValidValue(int32_t value__) {\n" " switch (value__) {\n", + // clang-format on "name", name_); for (int i = 0; i < base_values_.size(); i++) { @@ -262,12 +276,14 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { "name", EnumValueName(base_values_[i])); } + // clang-format off printer->Print( " return YES;\n" " default:\n" " return NO;\n" " }\n" "}\n\n"); + // clang-format on } } // namespace objectivec } // namespace compiler diff --git a/src/google/protobuf/compiler/objectivec/enum_field.cc b/src/google/protobuf/compiler/objectivec/enum_field.cc index 72d0b581f0..c779a5e0d4 100644 --- a/src/google/protobuf/compiler/objectivec/enum_field.cc +++ b/src/google/protobuf/compiler/objectivec/enum_field.cc @@ -78,6 +78,7 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations( return; } + // clang-format off printer->Print( variables_, "/**\n" @@ -92,12 +93,14 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations( " **/\n" "void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value);\n" "\n"); + // clang-format on } void EnumFieldGenerator::GenerateCFunctionImplementations( io::Printer* printer) const { if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) return; + // clang-format off printer->Print( variables_, "int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message) {\n" @@ -112,6 +115,7 @@ void EnumFieldGenerator::GenerateCFunctionImplementations( " GPBSetMessageRawEnumField(message, field, value);\n" "}\n" "\n"); + // clang-format on } void EnumFieldGenerator::DetermineForwardDeclarations( diff --git a/src/google/protobuf/compiler/objectivec/extension.cc b/src/google/protobuf/compiler/objectivec/extension.cc index f13bff0755..768b4f1063 100644 --- a/src/google/protobuf/compiler/objectivec/extension.cc +++ b/src/google/protobuf/compiler/objectivec/extension.cc @@ -77,9 +77,12 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { // Unlike normal message fields, check if the file for the extension was // deprecated. vars["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()); - printer->Print(vars, - "$comments$" - "+ (GPBExtensionDescriptor *)$method_name$$storage_attribute$$deprecated_attribute$;\n"); + // clang-format off + printer->Print( + vars, + "$comments$" + "+ (GPBExtensionDescriptor *)$method_name$$storage_attribute$$deprecated_attribute$;\n"); + // clang-format on } void ExtensionGenerator::GenerateStaticVariablesInitialization( @@ -122,17 +125,20 @@ void ExtensionGenerator::GenerateStaticVariablesInitialization( vars["enum_desc_func_name"] = "NULL"; } - printer->Print(vars, - "{\n" - " .defaultValue.$default_name$ = $default$,\n" - " .singletonName = GPBStringifySymbol($root_class_and_method_name$),\n" - " .extendedClass.clazz = $extended_type$,\n" - " .messageOrGroupClass.clazz = $type$,\n" - " .enumDescriptorFunc = $enum_desc_func_name$,\n" - " .fieldNumber = $number$,\n" - " .dataType = $extension_type$,\n" - " .options = $options$,\n" - "},\n"); + // clang-format off + printer->Print( + vars, + "{\n" + " .defaultValue.$default_name$ = $default$,\n" + " .singletonName = GPBStringifySymbol($root_class_and_method_name$),\n" + " .extendedClass.clazz = $extended_type$,\n" + " .messageOrGroupClass.clazz = $type$,\n" + " .enumDescriptorFunc = $enum_desc_func_name$,\n" + " .fieldNumber = $number$,\n" + " .dataType = $extension_type$,\n" + " .options = $options$,\n" + "},\n"); + // clang-format on } void ExtensionGenerator::DetermineObjectiveCClassDefinitions( @@ -147,9 +153,11 @@ void ExtensionGenerator::DetermineObjectiveCClassDefinitions( } void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) { + // clang-format off printer->Print( "[registry addExtension:$root_class_and_method_name$];\n", "root_class_and_method_name", root_class_and_method_name_); + // clang-format on } } // namespace objectivec diff --git a/src/google/protobuf/compiler/objectivec/field.cc b/src/google/protobuf/compiler/objectivec/field.cc index 0caab624f1..a5fe4e97c9 100644 --- a/src/google/protobuf/compiler/objectivec/field.cc +++ b/src/google/protobuf/compiler/objectivec/field.cc @@ -243,6 +243,7 @@ void FieldGenerator::GenerateFieldDescription( io::Printer* printer, bool include_default) const { // Printed in the same order as the structure decl. if (include_default) { + // clang-format off printer->Print( variables_, "{\n" @@ -255,7 +256,9 @@ void FieldGenerator::GenerateFieldDescription( " .core.flags = $fieldflags$,\n" " .core.dataType = GPBDataType$field_type$,\n" "},\n"); + // clang-format on } else { + // clang-format off printer->Print( variables_, "{\n" @@ -267,6 +270,7 @@ void FieldGenerator::GenerateFieldDescription( " .flags = $fieldflags$,\n" " .dataType = GPBDataType$field_type$,\n" "},\n"); + // clang-format on } } @@ -326,14 +330,18 @@ void SingleFieldGenerator::GenerateFieldStorageDeclaration( void SingleFieldGenerator::GeneratePropertyDeclaration( io::Printer* printer) const { printer->Print(variables_, "$comments$"); + // clang-format off printer->Print( variables_, "@property(nonatomic, readwrite) $property_type$ $name$$deprecated_attribute$;\n" "\n"); + // clang-format on if (WantsHasProperty()) { + // clang-format off printer->Print( variables_, "@property(nonatomic, readwrite) BOOL has$capitalized_name$$deprecated_attribute$;\n"); + // clang-format on } } @@ -377,14 +385,18 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration( // conventions (init*, new*, etc.) printer->Print(variables_, "$comments$"); + // clang-format off printer->Print( variables_, "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$$deprecated_attribute$;\n"); + // clang-format on if (WantsHasProperty()) { + // clang-format off printer->Print( variables_, "/** Test to see if @c $name$ has been set. */\n" "@property(nonatomic, readwrite) BOOL has$capitalized_name$$deprecated_attribute$;\n"); + // clang-format on } if (IsInitName(variables_.find("name")->second)) { // If property name starts with init we need to annotate it to get past ARC. @@ -430,6 +442,7 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration( // dealing with needing Objective C's rules around storage name conventions // (init*, new*, etc.) + // clang-format off printer->Print( variables_, "$comments$" @@ -437,11 +450,14 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration( "@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$$deprecated_attribute$;\n" "/** The number of items in @c $name$ without causing the container to be created. */\n" "@property(nonatomic, readonly) NSUInteger $name$_Count$deprecated_attribute$;\n"); + // clang-format on if (IsInitName(variables_.find("name")->second)) { // If property name starts with init we need to annotate it to get past ARC. // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227 + // clang-format off printer->Print(variables_, "- ($array_property_type$ *)$name$ GPB_METHOD_FAMILY_NONE$deprecated_attribute$;\n"); + // clang-format on } printer->Print("\n"); } diff --git a/src/google/protobuf/compiler/objectivec/file.cc b/src/google/protobuf/compiler/objectivec/file.cc index bf175f9a93..291696f7f9 100644 --- a/src/google/protobuf/compiler/objectivec/file.cc +++ b/src/google/protobuf/compiler/objectivec/file.cc @@ -261,6 +261,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { // compiled, since that will be the versions for the ObjC runtime at that // time. The constants in the generated code will then get their values at // at compile time (so checking against the headers being used to compile). + // clang-format off printer->Print( "#if GOOGLE_PROTOBUF_OBJC_VERSION < $google_protobuf_objc_version$\n" "#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.\n" @@ -270,6 +271,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { "#endif\n" "\n", "google_protobuf_objc_version", absl::StrCat(GOOGLE_PROTOBUF_OBJC_VERSION)); + // clang-format on // The bundled protos (WKTs) don't use of forward declarations. bool headers_use_forward_declarations = @@ -299,6 +301,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { // deprecated-declarations suppression is only needed if some place in this // proto file is something deprecated or if it references something from // another file that is deprecated. + // clang-format off printer->Print( "// @@protoc_insertion_point(imports)\n" "\n" @@ -307,6 +310,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { "\n" "CF_EXTERN_C_BEGIN\n" "\n"); + // clang-format on std::set fwd_decls; for (const auto& generator : message_generators_) { @@ -338,6 +342,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { // For extensions to chain together, the Root gets created even if there // are no extensions. printer->Print( + // clang-format off "#pragma mark - $root_class_name$\n" "\n" "/**\n" @@ -353,6 +358,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { "GPB_FINAL @interface $root_class_name$ : GPBRootObject\n" "@end\n" "\n", + // clang-format off "root_class_name", root_class_name_); if (!extension_generators_.empty()) { @@ -372,6 +378,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { generator->GenerateMessageHeader(printer); } + // clang-format off printer->Print( "NS_ASSUME_NONNULL_END\n" "\n" @@ -382,6 +389,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { "// @@protoc_insertion_point(global_scope)\n" "\n" "// clange-format on\n"); + // clang-format on } void FileGenerator::GenerateSource(io::Printer* printer) { @@ -471,11 +479,13 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // another file that is deprecated. // dollar-in-identifier-extension is needed because we use references to // objc class names that have $ in identifiers. + // clang-format off printer->Print( "// @@protoc_insertion_point(imports)\n" "\n" "#pragma clang diagnostic push\n" "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n"); + // clang-format on if (includes_oneof) { // The generated code for oneof's uses direct ivar access, suppress the // warning in case developer turn that on in the context they compile the @@ -484,17 +494,21 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "#pragma clang diagnostic ignored \"-Wdirect-ivar-access\"\n"); } if (!fwd_decls.empty()) { + // clang-format off printer->Print( - "#pragma clang diagnostic ignored \"-Wdollar-in-identifier-extension\"\n"); + "#pragma clang diagnostic ignored \"-Wdollar-in-identifier-extension\"\n"); + // clang-format on } printer->Print( "\n"); if (!fwd_decls.empty()) { + // clang-format off printer->Print( "#pragma mark - Objective C Class declarations\n" "// Forward declarations of Objective C classes that we can use as\n" "// static values in struct initializers.\n" "// We don't use [Foo class] because it is not a static value.\n"); + // clang-format on } for (const auto& i : fwd_decls) { printer->Print("$value$\n", "value", i); @@ -503,9 +517,11 @@ void FileGenerator::GenerateSource(io::Printer* printer) { printer->Print("\n"); } printer->Print( + // clang-format off "#pragma mark - $root_class_name$\n" "\n" "@implementation $root_class_name$\n\n", + // clang-format on "root_class_name", root_class_name_); const bool file_contains_extensions = FileContainsExtensions(file_); @@ -513,6 +529,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // If there were any extensions or this file has any dependencies, output // a registry to override to create the file specific registry. if (file_contains_extensions || !deps_with_extensions.empty()) { + // clang-format off printer->Print( "+ (GPBExtensionRegistry*)extensionRegistry {\n" " // This is called by +initialize so there is no need to worry\n" @@ -521,6 +538,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { " if (!registry) {\n" " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n" " registry = [[GPBExtensionRegistry alloc] init];\n"); + // clang-format on printer->Indent(); printer->Indent(); @@ -536,6 +554,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { generator->GenerateStaticVariablesInitialization(printer); } printer->Outdent(); + // clang-format off printer->Print( "};\n" "for (size_t i = 0; i < sizeof(descriptions) / sizeof(descriptions[0]); ++i) {\n" @@ -546,15 +565,20 @@ void FileGenerator::GenerateSource(io::Printer* printer) { " [self globallyRegisterExtension:extension];\n" " [extension release];\n" "}\n"); + // clang-format on } if (deps_with_extensions.empty()) { + // clang-format off printer->Print( "// None of the imports (direct or indirect) defined extensions, so no need to add\n" "// them to this registry.\n"); + // clang-format on } else { + // clang-format off printer->Print( "// Merge in the imports (direct or indirect) that defined extensions.\n"); + // clang-format on for (std::vector::iterator iter = deps_with_extensions.begin(); iter != deps_with_extensions.end(); ++iter) { @@ -568,19 +592,25 @@ void FileGenerator::GenerateSource(io::Printer* printer) { printer->Outdent(); printer->Outdent(); + // clang-format off printer->Print( " }\n" " return registry;\n" "}\n"); + // clang-format on } else { if (file_->dependency_count() > 0) { + // clang-format off printer->Print( "// No extensions in the file and none of the imports (direct or indirect)\n" "// defined extensions, so no need to generate +extensionRegistry.\n"); + // clang-format on } else { + // clang-format off printer->Print( "// No extensions in the file and no imports, so no need to generate\n" "// +extensionRegistry.\n"); + // clang-format on } } @@ -603,7 +633,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) { vars["syntax"] = "GPBFileSyntaxProto3"; break; } - printer->Print(vars, + // clang-format off + printer->Print( + vars, "#pragma mark - $root_class_name$_FileDescriptor\n" "\n" "static GPBFileDescriptor *$root_class_name$_FileDescriptor(void) {\n" @@ -612,23 +644,30 @@ void FileGenerator::GenerateSource(io::Printer* printer) { " static GPBFileDescriptor *descriptor = NULL;\n" " if (!descriptor) {\n" " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n"); + // clang-format on if (!vars["objc_prefix"].empty()) { + // clang-format off printer->Print( vars, " descriptor = [[GPBFileDescriptor alloc] initWithPackage:@\"$package$\"\n" " objcPrefix:@\"$objc_prefix$\"\n" " syntax:$syntax$];\n"); + // clang-format on } else { + // clang-format off printer->Print( vars, " descriptor = [[GPBFileDescriptor alloc] initWithPackage:@\"$package$\"\n" " syntax:$syntax$];\n"); + // clang-format on } + // clang-format off printer->Print( " }\n" " return descriptor;\n" "}\n" "\n"); + // clang-format on } for (const auto& generator : enum_generators_) { @@ -638,13 +677,15 @@ void FileGenerator::GenerateSource(io::Printer* printer) { generator->GenerateSource(printer); } + // clang-format off printer->Print( - "\n" - "#pragma clang diagnostic pop\n" - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n" - "// clang-format on\n"); + "\n" + "#pragma clang diagnostic pop\n" + "\n" + "// @@protoc_insertion_point(global_scope)\n" + "\n" + "// clang-format on\n"); + // clang-format on } // Helper to print the import of the runtime support at the top of generated diff --git a/src/google/protobuf/compiler/objectivec/import_writer.cc b/src/google/protobuf/compiler/objectivec/import_writer.cc index 3a058a916f..f36ef781ec 100644 --- a/src/google/protobuf/compiler/objectivec/import_writer.cc +++ b/src/google/protobuf/compiler/objectivec/import_writer.cc @@ -213,12 +213,14 @@ void ImportWriter::PrintRuntimeImports( if (default_cpp_symbol) { printer->Print( + // clang-format off "// This CPP symbol can be defined to use imports that match up to the framework\n" "// imports needed when using CocoaPods.\n" "#if !defined($cpp_symbol$)\n" " #define $cpp_symbol$ 0\n" "#endif\n" "\n", + // clang-format on "cpp_symbol", cpp_symbol); } diff --git a/src/google/protobuf/compiler/objectivec/message.cc b/src/google/protobuf/compiler/objectivec/message.cc index 9169ecddfc..05bc5b3199 100644 --- a/src/google/protobuf/compiler/objectivec/message.cc +++ b/src/google/protobuf/compiler/objectivec/message.cc @@ -305,8 +305,10 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { } printer->Print( + // clang-format off "#pragma mark - $classname$\n" "\n", + // clang-format on "classname", class_name_); if (descriptor_->field_count()) { @@ -339,7 +341,9 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { } printer->Print( + // clang-format off "$comments$$deprecated_attribute$GPB_FINAL @interface $classname$ : GPBMessage\n\n", + // clang-format on "classname", class_name_, "deprecated_attribute", deprecated_attribute_, "comments", message_comments); @@ -390,16 +394,20 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { void MessageGenerator::GenerateSource(io::Printer* printer) { if (!IsMapEntryMessage(descriptor_)) { printer->Print( + // clang-format off "#pragma mark - $classname$\n" "\n", + // clang-format on "classname", class_name_); if (!deprecated_attribute_.empty()) { // No warnings when compiling the impl of this deprecated class. + // clang-format off printer->Print( "#pragma clang diagnostic push\n" "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n" "\n"); + // clang-format on } printer->Print("@implementation $classname$\n\n", @@ -452,9 +460,11 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { sizeof_has_storage += oneof_generators_.size(); printer->Print( + // clang-format off "\n" "typedef struct $classname$__storage_ {\n" " uint32_t _has_storage_[$sizeof_has_storage$];\n", + // clang-format on "classname", class_name_, "sizeof_has_storage", absl::StrCat(sizeof_has_storage)); printer->Indent(); @@ -468,12 +478,14 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { printer->Print("} $classname$__storage_;\n\n", "classname", class_name_); + // clang-format off printer->Print( "// This method is threadsafe because it is initially called\n" "// in +initialize for each subclass.\n" "+ (GPBDescriptor *)descriptor {\n" " static GPBDescriptor *descriptor = nil;\n" " if (!descriptor) {\n"); + // clang-format on TextFormatDecodeData text_format_decode_data; bool has_fields = descriptor_->field_count() > 0; @@ -531,6 +543,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { vars["init_flags"] = BuildFlagsString(FLAGTYPE_DESCRIPTOR_INITIALIZATION, init_flags); + // clang-format off printer->Print( vars, " GPBDescriptor *localDescriptor =\n" @@ -541,6 +554,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " fieldCount:$fields_count$\n" " storageSize:sizeof($classname$__storage_)\n" " flags:$init_flags$];\n"); + // clang-format on if (!oneof_generators_.empty()) { printer->Print( " static const char *oneofs[] = {\n"); @@ -549,17 +563,21 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { generator->DescriptorName()); } printer->Print( + // clang-format off " };\n" " [localDescriptor setupOneofs:oneofs\n" " count:(uint32_t)(sizeof(oneofs) / sizeof(char*))\n" " firstHasIndex:$first_has_index$];\n", + // clang-format on "first_has_index", oneof_generators_[0]->HasIndexAsString()); } if (text_format_decode_data.num_entries() != 0) { const std::string text_format_data_str(text_format_decode_data.Data()); + // clang-format off printer->Print( "#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n" " static const char *extraTextFormatInfo ="); + // clang-format on static const int kBytesPerLine = 40; // allow for escaping for (int i = 0; i < text_format_data_str.size(); i += kBytesPerLine) { printer->Print( @@ -567,10 +585,12 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "data", EscapeTrigraphs( absl::CEscape(text_format_data_str.substr(i, kBytesPerLine)))); } + // clang-format off printer->Print( ";\n" " [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\n" "#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n"); + // clang-format on } if (!sorted_extensions.empty()) { printer->Print( @@ -580,16 +600,20 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "start", absl::StrCat(sorted_extensions[i]->start), "end", absl::StrCat(sorted_extensions[i]->end)); } + // clang-format off printer->Print( " };\n" " [localDescriptor setupExtensionRanges:ranges\n" " count:(uint32_t)(sizeof(ranges) / sizeof(GPBExtensionRange))];\n"); + // clang-format on } if (descriptor_->containing_type() != NULL) { std::string containing_class = ClassName(descriptor_->containing_type()); std::string parent_class_ref = ObjCClass(containing_class); printer->Print( + // clang-format off " [localDescriptor setupContainingMessageClass:$parent_class_ref$];\n", + // clang-format on "parent_class_ref", parent_class_ref); } std::string suffix_added; @@ -599,6 +623,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " [localDescriptor setupMessageClassNameSuffix:@\"$suffix$\"];\n", "suffix", suffix_added); } + // clang-format off printer->Print( " #if defined(DEBUG) && DEBUG\n" " NSAssert(descriptor == nil, @\"Startup recursed!\");\n" @@ -608,11 +633,14 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " return descriptor;\n" "}\n\n" "@end\n\n"); + // clang-format on if (!deprecated_attribute_.empty()) { + // clang-format off printer->Print( "#pragma clang diagnostic pop\n" "\n"); + // clang-format on } for (int i = 0; i < descriptor_->field_count(); i++) { diff --git a/src/google/protobuf/compiler/objectivec/oneof.cc b/src/google/protobuf/compiler/objectivec/oneof.cc index db4922f2d5..dd15932b7a 100644 --- a/src/google/protobuf/compiler/objectivec/oneof.cc +++ b/src/google/protobuf/compiler/objectivec/oneof.cc @@ -89,27 +89,33 @@ void OneofGenerator::GenerateCaseEnum(io::Printer* printer) { "field_number", absl::StrCat(field->number())); } printer->Outdent(); + // clang-format off printer->Print( "};\n" "\n"); + // clang-format on } void OneofGenerator::GeneratePublicCasePropertyDeclaration( io::Printer* printer) { + // clang-format off printer->Print( variables_, "$comments$" "@property(nonatomic, readonly) $enum_name$ $name$OneOfCase;\n" "\n"); + // clang-format on } void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) { + // clang-format off printer->Print( variables_, "/**\n" " * Clears whatever value was set for the oneof '$name$'.\n" " **/\n" "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message);\n"); + // clang-format on } void OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) { @@ -119,6 +125,7 @@ void OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) { } void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) { + // clang-format off printer->Print( variables_, "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message) {\n" @@ -126,6 +133,7 @@ void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) { " GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:$raw_index$];\n" " GPBClearOneof(message, oneof);\n" "}\n"); + // clang-format on } std::string OneofGenerator::DescriptorName(void) const {