diff --git a/objectivec/DevTools/compile_testing_protos.sh b/objectivec/DevTools/compile_testing_protos.sh index 69c32f920b..613c63c6c4 100755 --- a/objectivec/DevTools/compile_testing_protos.sh +++ b/objectivec/DevTools/compile_testing_protos.sh @@ -1,8 +1,6 @@ #!/bin/bash -eu # Invoked by the Xcode projects to build the protos needed for the unittests. -readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/protos" - # ----------------------------------------------------------------------------- # Helper for bailing. die() { @@ -10,6 +8,27 @@ die() { exit 2 } +# ----------------------------------------------------------------------------- +# Parameters. +if (( $# > 1 )); then + die "Script takes only one parameter: $#" +fi + +if (( $# == 1 )); then + case "$1" in + "--elide_message_metadata") + readonly ELIDE_MESSAGE_METADATA_OPTION="--objc_opt=elide_message_metadata" + readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/elided/protos" + ;; + *) + die "Unknown option: $1" + ;; + esac +else + readonly ELIDE_MESSAGE_METADATA_OPTION="" + readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/normal/protos" +fi + # ----------------------------------------------------------------------------- # What to do. case "${ACTION}" in @@ -157,6 +176,7 @@ compile_protos() { --proto_path=src/google/protobuf/ \ --proto_path=src \ --experimental_allow_proto3_optional \ + ${ELIDE_MESSAGE_METADATA_OPTION} \ "$@" } diff --git a/objectivec/GPBMessage_PackagePrivate.h b/objectivec/GPBMessage_PackagePrivate.h index ca10983b3c..2aa984b138 100644 --- a/objectivec/GPBMessage_PackagePrivate.h +++ b/objectivec/GPBMessage_PackagePrivate.h @@ -34,6 +34,8 @@ #import "GPBMessage.h" +#import "GPBUtilities_PackagePrivate.h" + // TODO: Remove this import. Older generated code use the OSAtomic* apis, // so anyone that hasn't regenerated says building by having this. After // enough time has passed, this likely can be removed as folks should have @@ -42,6 +44,134 @@ #import "GPBBootstrap.h" +#if defined(__LP64__) && __LP64__ +#define GPB_ASM_PTR " .quad " +#define GPB_ASM_PTRSIZE " 8 " +#define GPB_ASM_ONLY_LP64(x) x +#define GPB_ALIGN_SIZE " 3 " +#define GPB_DESCRIPTOR_METHOD_TYPE "@16@0:8" +#else // __LP64__ +#define GPB_ASM_PTR " .long " +#define GPB_ASM_PTRSIZE " 4 " +#define GPB_ASM_ONLY_LP64(x) +#define GPB_ALIGN_SIZE " 2 " +#define GPB_DESCRIPTOR_METHOD_TYPE "@8@0:4" +#endif // __LP64__ + +#define GPB_MESSAGE_CLASS_NAME_RAW GPBMessage +#define GPB_MESSAGE_CLASS_NAME GPBStringifySymbol(GPB_MESSAGE_CLASS_NAME_RAW) + +#if !__has_feature(objc_arc) +#define GPB_CLASS_FLAGS " 0x00 " +#define GPB_METACLASS_FLAGS " 0x01 " +#else +// 0x80 denotes that the class supports ARC. +#define GPB_CLASS_FLAGS " 0x80 " +#define GPB_METACLASS_FLAGS " 0x81 " +#endif + +// This generates code equivalent to: +// ``` +// @implementation _name_ +// + (GPBDescriptor *)descriptor { +// return _descriptorFunc_(self, _cmd); +// } +// @end +// ``` +// We do this to avoid all of the @property metadata. +// If we use `@dynamic` the compiler generates a lot of property data including +// selectors and encoding strings. For large uses of protobufs, this can add +// up to several megabytes of unused Objective-C metadata. +// This inline class definition avoids the property data generation at the +// cost of being a little ugly. This has been tested with both 32 and 64 bits +// on intel and arm with Xcode 11.7 and Xcode 12.4. +// We make cstring_literals be local definitions by starting them with "L". +// https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_5.html#SEC48 +// This keeps our symbols tables smaller, and is what the linker expects. +// The linker in Xcode 12+ seems to be a bit more lenient about it, but the +// Xcode 11 linker requires it, and will give a cryptic "malformed method list" +// assertion if they are global. +#define GPB_MESSAGE_SUBCLASS_IMPL(name, descriptorFunc) \ + __asm__( \ + ".section __TEXT, __objc_classname, cstring_literals \n" \ + "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) ": " \ + " .asciz \"" GPBStringifySymbol(name) "\" \n" \ + \ + ".ifndef L_GBPDescriptorMethodName \n" \ + ".section __TEXT, __objc_methname, cstring_literals \n" \ + "L_GBPDescriptorMethodName: .asciz \"descriptor\" \n" \ + ".endif \n" \ + \ + ".ifndef L_GPBDescriptorMethodType \n" \ + ".section __TEXT, __objc_methtype, cstring_literals \n" \ + "L_GPBDescriptorMethodType: .asciz \"" GPB_DESCRIPTOR_METHOD_TYPE "\" \n" \ + ".endif \n" \ + \ + ".section __DATA,__objc_const, regular \n" \ + ".p2align" GPB_ALIGN_SIZE "\n" \ + "__OBJC_$_CLASS_METHODS_" GPBStringifySymbol(name) ": \n" \ + ".long 3 *" GPB_ASM_PTRSIZE "\n" \ + ".long 0x1 \n" \ + GPB_ASM_PTR "L_GBPDescriptorMethodName \n" \ + GPB_ASM_PTR "L_GPBDescriptorMethodType \n" \ + GPB_ASM_PTR "_" #descriptorFunc " \n" \ + \ + ".section __DATA,__objc_const, regular \n" \ + ".p2align" GPB_ALIGN_SIZE "\n" \ + "__OBJC_METACLASS_RO_$_" GPBStringifySymbol(name) ": \n" \ + ".long" GPB_METACLASS_FLAGS "\n" \ + ".long 5 *" GPB_ASM_PTRSIZE "\n" \ + ".long 5 *" GPB_ASM_PTRSIZE "\n" \ + GPB_ASM_ONLY_LP64(".space 4 \n") \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) " \n" \ + GPB_ASM_PTR "__OBJC_$_CLASS_METHODS_" GPBStringifySymbol(name) " \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + \ + ".section __DATA,__objc_const, regular \n" \ + ".p2align" GPB_ALIGN_SIZE "\n" \ + "__OBJC_CLASS_RO_$_" GPBStringifySymbol(name) ": \n" \ + ".long" GPB_CLASS_FLAGS "\n" \ + ".long" GPB_ASM_PTRSIZE "\n" \ + ".long" GPB_ASM_PTRSIZE "\n" \ + GPB_ASM_ONLY_LP64(".long 0 \n") \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) " \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "0 \n" \ + \ + ".globl _OBJC_METACLASS_$_" GPBStringifySymbol(name) "\n" \ + ".section __DATA,__objc_data, regular \n" \ + ".p2align" GPB_ALIGN_SIZE "\n" \ + "_OBJC_METACLASS_$_" GPBStringifySymbol(name) ": \n" \ + GPB_ASM_PTR "_OBJC_METACLASS_$_NSObject \n" \ + GPB_ASM_PTR "_OBJC_METACLASS_$_" GPB_MESSAGE_CLASS_NAME " \n" \ + GPB_ASM_PTR "__objc_empty_cache \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "__OBJC_METACLASS_RO_$_" GPBStringifySymbol(name) " \n" \ + \ + ".globl _OBJC_CLASS_$_" GPBStringifySymbol(name) "\n" \ + ".section __DATA,__objc_data, regular \n" \ + ".p2align" GPB_ALIGN_SIZE "\n" \ + "_OBJC_CLASS_$_" GPBStringifySymbol(name) ": \n" \ + GPB_ASM_PTR "_OBJC_METACLASS_$_" GPBStringifySymbol(name) " \n" \ + GPB_ASM_PTR "_OBJC_CLASS_$_" GPB_MESSAGE_CLASS_NAME " \n" \ + GPB_ASM_PTR "__objc_empty_cache \n" \ + GPB_ASM_PTR "0 \n" \ + GPB_ASM_PTR "__OBJC_CLASS_RO_$_" GPBStringifySymbol(name) " \n" \ + \ + ".section __DATA, __objc_classlist, regular, no_dead_strip \n" \ + ".p2align" GPB_ALIGN_SIZE "\n" \ + "_OBJC_LABEL_CLASS_$" GPBStringifySymbol(name) ": \n" \ + GPB_ASM_PTR "_OBJC_CLASS_$_" GPBStringifySymbol(name) " \n" \ + ) + typedef struct GPBMessage_Storage { uint32_t _has_storage_[0]; } GPBMessage_Storage; diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj index 365fdc30ca..45997ecc43 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj @@ -22,6 +22,67 @@ 8B4248BB1A8C256A00BC1EC6 /* GPBSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248BA1A8C256A00BC1EC6 /* GPBSwiftTests.swift */; }; 8B4248D21A927E1500BC1EC6 /* GPBWellKnownTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D01A927E1500BC1EC6 /* GPBWellKnownTypes.m */; }; 8B4248DC1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */; }; + 8B6C2AE62682952200026204 /* golden_message in Resources */ = {isa = PBXBuildFile; fileRef = 8B210CCD159383D60032D72D /* golden_message */; }; + 8B6C2AE72682952200026204 /* text_format_extensions_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F4F53F89219CC4F2001EABF4 /* text_format_extensions_unittest_data.txt */; }; + 8B6C2AE82682952200026204 /* text_format_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F43C88CF191D77FC009E917D /* text_format_unittest_data.txt */; }; + 8B6C2AE92682952200026204 /* golden_packed_fields_message in Resources */ = {isa = PBXBuildFile; fileRef = 8B210CCF159386920032D72D /* golden_packed_fields_message */; }; + 8B6C2AEA2682952200026204 /* text_format_map_unittest_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */; }; + 8B6C2AEC2682952200026204 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; }; + 8B6C2AED2682952200026204 /* GPBCompileTest24.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE508206C06440071091A /* GPBCompileTest24.m */; }; + 8B6C2AEE2682952200026204 /* GPBCompileTest20.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE485206BF8AF0071091A /* GPBCompileTest20.m */; }; + 8B6C2AEF2682952200026204 /* GPBArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F401DC321A8E5C0200FCC765 /* GPBArrayTests.m */; }; + 8B6C2AF02682952200026204 /* GPBCompileTest10.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48C206BF8B00071091A /* GPBCompileTest10.m */; }; + 8B6C2AF12682952200026204 /* GPBDictionaryTests+Int64.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D2F1AC06F10005A6198 /* GPBDictionaryTests+Int64.m */; }; + 8B6C2AF22682952200026204 /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48A206BF8B00071091A /* GPBCompileTest22.m */; }; + 8B6C2AF32682952200026204 /* GPBCompileTest08.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE47D206BF8AD0071091A /* GPBCompileTest08.m */; }; + 8B6C2AF42682952200026204 /* GPBCompileTest17.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48D206BF8B00071091A /* GPBCompileTest17.m */; }; + 8B6C2AF52682952200026204 /* GPBDictionaryTests+UInt64.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D321AC06F10005A6198 /* GPBDictionaryTests+UInt64.m */; }; + 8B6C2AF62682952200026204 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; }; + 8B6C2AF72682952200026204 /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE487206BF8B00071091A /* GPBCompileTest23.m */; }; + 8B6C2AF82682952200026204 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; }; + 8B6C2AF92682952200026204 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1D1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm */; }; + 8B6C2AFA2682952200026204 /* GPBCompileTest19.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE482206BF8AF0071091A /* GPBCompileTest19.m */; }; + 8B6C2AFB2682952200026204 /* GPBCompileTest06.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE492206BF8B10071091A /* GPBCompileTest06.m */; }; + 8B6C2AFC2682952200026204 /* GPBCompileTest12.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE490206BF8B10071091A /* GPBCompileTest12.m */; }; + 8B6C2AFD2682952200026204 /* GPBMessageTests+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */; }; + 8B6C2AFE2682952200026204 /* GPBCompileTest03.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE491206BF8B10071091A /* GPBCompileTest03.m */; }; + 8B6C2AFF2682952200026204 /* GPBCompileTest18.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48E206BF8B10071091A /* GPBCompileTest18.m */; }; + 8B6C2B002682952200026204 /* GPBCompileTest13.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE483206BF8AF0071091A /* GPBCompileTest13.m */; }; + 8B6C2B012682952200026204 /* GPBCompileTest15.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE489206BF8B00071091A /* GPBCompileTest15.m */; }; + 8B6C2B022682952200026204 /* GPBCompileTest07.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE480206BF8AE0071091A /* GPBCompileTest07.m */; }; + 8B6C2B032682952200026204 /* GPBWellKnownTypesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */; }; + 8B6C2B042682952200026204 /* GPBCompileTest21.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE486206BF8AF0071091A /* GPBCompileTest21.m */; }; + 8B6C2B052682952200026204 /* GPBCompileTest11.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE493206BF8B20071091A /* GPBCompileTest11.m */; }; + 8B6C2B062682952200026204 /* GPBUnittestProtos2.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F8D8811D789FCE002CE128 /* GPBUnittestProtos2.m */; }; + 8B6C2B072682952200026204 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */; }; + 8B6C2B082682952200026204 /* GPBSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248BA1A8C256A00BC1EC6 /* GPBSwiftTests.swift */; }; + 8B6C2B092682952200026204 /* GPBCompileTest25.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE507206C06440071091A /* GPBCompileTest25.m */; }; + 8B6C2B0A2682952200026204 /* GPBExtensionRegistryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4584D7E1ECCB38900803AB6 /* GPBExtensionRegistryTest.m */; }; + 8B6C2B0B2682952200026204 /* GPBMessageTests+ClassNames.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BFF9D1923AD582200E63E32 /* GPBMessageTests+ClassNames.m */; }; + 8B6C2B0C2682952200026204 /* GPBConcurrencyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */; }; + 8B6C2B0D2682952200026204 /* GPBMessageTests+Runtime.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */; }; + 8B6C2B0E2682952200026204 /* GPBCompileTest02.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE481206BF8AE0071091A /* GPBCompileTest02.m */; }; + 8B6C2B0F2682952200026204 /* GPBDictionaryTests+Int32.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D2E1AC06F10005A6198 /* GPBDictionaryTests+Int32.m */; }; + 8B6C2B102682952200026204 /* GPBCompileTest05.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE47F206BF8AE0071091A /* GPBCompileTest05.m */; }; + 8B6C2B112682952200026204 /* GPBCompileTest14.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48F206BF8B10071091A /* GPBCompileTest14.m */; }; + 8B6C2B122682952200026204 /* GPBTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6AC0F94FDF800A0C422 /* GPBTestUtilities.m */; }; + 8B6C2B132682952200026204 /* GPBCompileTest04.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE47E206BF8AE0071091A /* GPBCompileTest04.m */; }; + 8B6C2B142682952200026204 /* GPBCompileTest16.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48B206BF8B00071091A /* GPBCompileTest16.m */; }; + 8B6C2B152682952200026204 /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; }; + 8B6C2B162682952200026204 /* GPBDictionaryTests+Bool.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D2D1AC06F10005A6198 /* GPBDictionaryTests+Bool.m */; }; + 8B6C2B172682952200026204 /* GPBMessageTests+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */; }; + 8B6C2B182682952200026204 /* GPBCompileTest01.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE488206BF8B00071091A /* GPBCompileTest01.m */; }; + 8B6C2B192682952200026204 /* GPBUnknownFieldSetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6B80F94FDF900A0C422 /* GPBUnknownFieldSetTest.m */; }; + 8B6C2B1A2682952200026204 /* GPBDictionaryTests+String.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D301AC06F10005A6198 /* GPBDictionaryTests+String.m */; }; + 8B6C2B1B2682952200026204 /* GPBDictionaryTests+UInt32.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D311AC06F10005A6198 /* GPBDictionaryTests+UInt32.m */; }; + 8B6C2B1C2682952200026204 /* GPBCompileTest09.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE484206BF8AF0071091A /* GPBCompileTest09.m */; }; + 8B6C2B1D2682952200026204 /* GPBUtilitiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BA0F94FDF900A0C422 /* GPBUtilitiesTests.m */; }; + 8B6C2B1E2682952200026204 /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */; }; + 8B6C2B1F2682952200026204 /* GPBWireFormatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6BC0F94FDF900A0C422 /* GPBWireFormatTests.m */; }; + 8B6C2B202682952200026204 /* GPBUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */; }; + 8B6C2B212682952200026204 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; + 8B6C2B232682952200026204 /* libProtocolBuffers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */; }; + 8B6C2B242682952200026204 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 8B79657B14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; }; 8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; }; @@ -98,6 +159,20 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 8B6C2AE12682952200026204 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7461B52D0F94FAF800A0C422; + remoteInfo = ProtocolBuffers; + }; + 8B6C2B442682966800026204 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8B6C2B34268295BA00026204; + remoteInfo = "Compile Elided Unittest Protos"; + }; 8BBEA4BC147C729A00C4ADB7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; @@ -159,6 +234,8 @@ 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypesTest.m; sourceTree = ""; }; 8B42494C1A92A16600BC1EC6 /* duration.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = duration.proto; path = ../src/google/protobuf/duration.proto; sourceTree = ""; }; 8B42494D1A92A16600BC1EC6 /* timestamp.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = timestamp.proto; path = ../src/google/protobuf/timestamp.proto; sourceTree = ""; }; + 8B6C2B282682952200026204 /* UnitTestsElidedProperties.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTestsElidedProperties.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 8B6C2B322682956000026204 /* compile_testing_protos.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = compile_testing_protos.sh; sourceTree = ""; }; 8B79657814992E3E002FFBFC /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBRootObject.h; sourceTree = ""; }; 8B79657914992E3E002FFBFC /* GPBRootObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBRootObject.m; sourceTree = ""; }; 8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_custom_options.proto; path = ../../src/google/protobuf/unittest_custom_options.proto; sourceTree = ""; }; @@ -282,6 +359,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 8B6C2B222682952200026204 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8B6C2B232682952200026204 /* libProtocolBuffers.a in Frameworks */, + 8B6C2B242682952200026204 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8BBEA4A3147C727100C4ADB7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -324,6 +410,7 @@ 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */, 8BBEA4A6147C727100C4ADB7 /* UnitTests.xctest */, F4487C511A9F8E0200531423 /* libTestSingleSourceBuild.a */, + 8B6C2B282682952200026204 /* UnitTestsElidedProperties.xctest */, ); name = Products; sourceTree = ""; @@ -331,6 +418,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + 8B6C2B332682957100026204 /* DevTools */, 080E96DDFE201D6D7F000001 /* Core Source */, 7461B6940F94FDDD00A0C422 /* Tests */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -525,6 +613,14 @@ path = Tests; sourceTree = ""; }; + 8B6C2B332682957100026204 /* DevTools */ = { + isa = PBXGroup; + children = ( + 8B6C2B322682956000026204 /* compile_testing_protos.sh */, + ); + path = DevTools; + sourceTree = ""; + }; 8BCF334414ED727300BC5317 /* Support */ = { isa = PBXGroup; children = ( @@ -565,13 +661,28 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXLegacyTarget section */ + 8B6C2B34268295BA00026204 /* Compile Elided Unittest Protos */ = { + isa = PBXLegacyTarget; + buildArgumentsString = "--elide_message_metadata"; + buildConfigurationList = 8B6C2B35268295BA00026204 /* Build configuration list for PBXLegacyTarget "Compile Elided Unittest Protos" */; + buildPhases = ( + ); + buildToolPath = DevTools/compile_testing_protos.sh; + buildWorkingDirectory = ""; + dependencies = ( + ); + name = "Compile Elided Unittest Protos"; + passBuildSettingsInEnvironment = 1; + productName = "Compile Unittest Protos"; + }; F45BBC141B0CE3C6002D064D /* Compile Unittest Protos */ = { isa = PBXLegacyTarget; - buildArgumentsString = "$(ACTION)"; + buildArgumentsString = ""; buildConfigurationList = F45BBC171B0CE3C6002D064D /* Build configuration list for PBXLegacyTarget "Compile Unittest Protos" */; buildPhases = ( ); buildToolPath = DevTools/compile_testing_protos.sh; + buildWorkingDirectory = ""; dependencies = ( ); name = "Compile Unittest Protos"; @@ -598,6 +709,26 @@ productReference = 7461B52E0F94FAF800A0C422 /* libProtocolBuffers.a */; productType = "com.apple.product-type.library.static"; }; + 8B6C2ADF2682952200026204 /* UnitTestsElidedProperties */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8B6C2B252682952200026204 /* Build configuration list for PBXNativeTarget "UnitTestsElidedProperties" */; + buildPhases = ( + 8B6C2AE42682952200026204 /* Script: Check Runtime Stamps */, + 8B6C2AE52682952200026204 /* Resources */, + 8B6C2AEB2682952200026204 /* Sources */, + 8B6C2B222682952200026204 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 8B6C2AE02682952200026204 /* PBXTargetDependency */, + 8B6C2B452682966800026204 /* PBXTargetDependency */, + ); + name = UnitTestsElidedProperties; + productName = UnitTests; + productReference = 8B6C2B282682952200026204 /* UnitTestsElidedProperties.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 8BBEA4A5147C727100C4ADB7 /* UnitTests */ = { isa = PBXNativeTarget; buildConfigurationList = 8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */; @@ -670,11 +801,25 @@ 8BBEA4A5147C727100C4ADB7 /* UnitTests */, F4487C381A9F8E0200531423 /* TestSingleSourceBuild */, F45BBC141B0CE3C6002D064D /* Compile Unittest Protos */, + 8B6C2ADF2682952200026204 /* UnitTestsElidedProperties */, + 8B6C2B34268295BA00026204 /* Compile Elided Unittest Protos */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 8B6C2AE52682952200026204 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8B6C2AE62682952200026204 /* golden_message in Resources */, + 8B6C2AE72682952200026204 /* text_format_extensions_unittest_data.txt in Resources */, + 8B6C2AE82682952200026204 /* text_format_unittest_data.txt in Resources */, + 8B6C2AE92682952200026204 /* golden_packed_fields_message in Resources */, + 8B6C2AEA2682952200026204 /* text_format_map_unittest_data.txt in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8BBEA4A1147C727100C4ADB7 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -690,6 +835,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 8B6C2AE42682952200026204 /* Script: Check Runtime Stamps */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Script: Check Runtime Stamps"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -eu\nexec \"${SOURCE_ROOT}/DevTools/check_version_stamps.sh\"\n"; + showEnvVarsInLog = 0; + }; F4B62A781AF91F6000AFCEDC /* Script: Check Runtime Stamps */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -739,6 +899,67 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 8B6C2AEB2682952200026204 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8B6C2AEC2682952200026204 /* GPBCodedInputStreamTests.m in Sources */, + 8B6C2AED2682952200026204 /* GPBCompileTest24.m in Sources */, + 8B6C2AEE2682952200026204 /* GPBCompileTest20.m in Sources */, + 8B6C2AEF2682952200026204 /* GPBArrayTests.m in Sources */, + 8B6C2AF02682952200026204 /* GPBCompileTest10.m in Sources */, + 8B6C2AF12682952200026204 /* GPBDictionaryTests+Int64.m in Sources */, + 8B6C2AF22682952200026204 /* GPBCompileTest22.m in Sources */, + 8B6C2AF32682952200026204 /* GPBCompileTest08.m in Sources */, + 8B6C2AF42682952200026204 /* GPBCompileTest17.m in Sources */, + 8B6C2AF52682952200026204 /* GPBDictionaryTests+UInt64.m in Sources */, + 8B6C2AF62682952200026204 /* GPBCodedOuputStreamTests.m in Sources */, + 8B6C2AF72682952200026204 /* GPBCompileTest23.m in Sources */, + 8B6C2AF82682952200026204 /* GPBMessageTests.m in Sources */, + 8B6C2AF92682952200026204 /* GPBObjectiveCPlusPlusTest.mm in Sources */, + 8B6C2AFA2682952200026204 /* GPBCompileTest19.m in Sources */, + 8B6C2AFB2682952200026204 /* GPBCompileTest06.m in Sources */, + 8B6C2AFC2682952200026204 /* GPBCompileTest12.m in Sources */, + 8B6C2AFD2682952200026204 /* GPBMessageTests+Serialization.m in Sources */, + 8B6C2AFE2682952200026204 /* GPBCompileTest03.m in Sources */, + 8B6C2AFF2682952200026204 /* GPBCompileTest18.m in Sources */, + 8B6C2B002682952200026204 /* GPBCompileTest13.m in Sources */, + 8B6C2B012682952200026204 /* GPBCompileTest15.m in Sources */, + 8B6C2B022682952200026204 /* GPBCompileTest07.m in Sources */, + 8B6C2B032682952200026204 /* GPBWellKnownTypesTest.m in Sources */, + 8B6C2B042682952200026204 /* GPBCompileTest21.m in Sources */, + 8B6C2B052682952200026204 /* GPBCompileTest11.m in Sources */, + 8B6C2B062682952200026204 /* GPBUnittestProtos2.m in Sources */, + 8B6C2B072682952200026204 /* GPBDescriptorTests.m in Sources */, + 8B6C2B082682952200026204 /* GPBSwiftTests.swift in Sources */, + 8B6C2B092682952200026204 /* GPBCompileTest25.m in Sources */, + 8B6C2B0A2682952200026204 /* GPBExtensionRegistryTest.m in Sources */, + 8B6C2B0B2682952200026204 /* GPBMessageTests+ClassNames.m in Sources */, + 8B6C2B0C2682952200026204 /* GPBConcurrencyTests.m in Sources */, + 8B6C2B0D2682952200026204 /* GPBMessageTests+Runtime.m in Sources */, + 8B6C2B0E2682952200026204 /* GPBCompileTest02.m in Sources */, + 8B6C2B0F2682952200026204 /* GPBDictionaryTests+Int32.m in Sources */, + 8B6C2B102682952200026204 /* GPBCompileTest05.m in Sources */, + 8B6C2B112682952200026204 /* GPBCompileTest14.m in Sources */, + 8B6C2B122682952200026204 /* GPBTestUtilities.m in Sources */, + 8B6C2B132682952200026204 /* GPBCompileTest04.m in Sources */, + 8B6C2B142682952200026204 /* GPBCompileTest16.m in Sources */, + 8B6C2B152682952200026204 /* GPBPerfTests.m in Sources */, + 8B6C2B162682952200026204 /* GPBDictionaryTests+Bool.m in Sources */, + 8B6C2B172682952200026204 /* GPBMessageTests+Merge.m in Sources */, + 8B6C2B182682952200026204 /* GPBCompileTest01.m in Sources */, + 8B6C2B192682952200026204 /* GPBUnknownFieldSetTest.m in Sources */, + 8B6C2B1A2682952200026204 /* GPBDictionaryTests+String.m in Sources */, + 8B6C2B1B2682952200026204 /* GPBDictionaryTests+UInt32.m in Sources */, + 8B6C2B1C2682952200026204 /* GPBCompileTest09.m in Sources */, + 8B6C2B1D2682952200026204 /* GPBUtilitiesTests.m in Sources */, + 8B6C2B1E2682952200026204 /* GPBDictionaryTests.m in Sources */, + 8B6C2B1F2682952200026204 /* GPBWireFormatTests.m in Sources */, + 8B6C2B202682952200026204 /* GPBUnittestProtos.m in Sources */, + 8B6C2B212682952200026204 /* GPBARCUnittestProtos.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8BBEA4A2147C727100C4ADB7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -811,6 +1032,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 8B6C2AE02682952200026204 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 7461B52D0F94FAF800A0C422 /* ProtocolBuffers */; + targetProxy = 8B6C2AE12682952200026204 /* PBXContainerItemProxy */; + }; + 8B6C2B452682966800026204 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8B6C2B34268295BA00026204 /* Compile Elided Unittest Protos */; + targetProxy = 8B6C2B442682966800026204 /* PBXContainerItemProxy */; + }; 8BBEA4BD147C729A00C4ADB7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 7461B52D0F94FAF800A0C422 /* ProtocolBuffers */; @@ -844,6 +1075,65 @@ }; name = Release; }; + 8B6C2B262682952200026204 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = "Tests/UnitTests-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; + USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/elided/protos $(SRCROOT)"; + WARNING_CFLAGS = ( + "$(inherited)", + "-Wno-documentation-unknown-command", + "-Wno-reserved-id-macro", + "-Wno-direct-ivar-access", + ); + }; + name = Debug; + }; + 8B6C2B272682952200026204 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = "Tests/UnitTests-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; + SWIFT_VERSION = 4.0; + USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/elided/protos $(SRCROOT)"; + WARNING_CFLAGS = ( + "$(inherited)", + "-Wno-documentation-unknown-command", + "-Wno-reserved-id-macro", + "-Wno-direct-ivar-access", + ); + }; + name = Release; + }; + 8B6C2B36268295BA00026204 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Debug; + }; + 8B6C2B37268295BA00026204 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Release; + }; 8BBEA4A7147C727100C4ADB7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -858,7 +1148,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; - USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)"; + USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/normal/protos $(SRCROOT)"; WARNING_CFLAGS = ( "$(inherited)", "-Wno-documentation-unknown-command", @@ -881,7 +1171,7 @@ PRODUCT_NAME = UnitTests; SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; SWIFT_VERSION = 4.0; - USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/protos $(SRCROOT)"; + USER_HEADER_SEARCH_PATHS = "${PROJECT_DERIVED_FILE_DIR}/normal/protos $(SRCROOT)"; WARNING_CFLAGS = ( "$(inherited)", "-Wno-documentation-unknown-command", @@ -1054,14 +1344,12 @@ F45BBC151B0CE3C6002D064D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_OBJC_WEAK = YES; }; name = Debug; }; F45BBC161B0CE3C6002D064D /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_OBJC_WEAK = YES; }; name = Release; }; @@ -1077,6 +1365,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 8B6C2B252682952200026204 /* Build configuration list for PBXNativeTarget "UnitTestsElidedProperties" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8B6C2B262682952200026204 /* Debug */, + 8B6C2B272682952200026204 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8B6C2B35268295BA00026204 /* Build configuration list for PBXLegacyTarget "Compile Elided Unittest Protos" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8B6C2B36268295BA00026204 /* Debug */, + 8B6C2B37268295BA00026204 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme index 6653a1b02b..0a8ac1c614 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme @@ -266,6 +266,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -293,8 +563,6 @@ - - - - + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -72,18 +81,22 @@ + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -293,17 +560,6 @@ - - - - - - - - + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> @@ -72,18 +72,22 @@ + + + + + + + + - - - - - - - - file(), false, true)) { + descriptor, descriptor->file(), false, true)), + elide_message_metadata_(options.elide_message_metadata) { for (int i = 0; i < descriptor_->extension_count(); i++) { extension_generators_.emplace_back( new ExtensionGenerator(class_name_, descriptor_->extension(i))); @@ -390,26 +391,28 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "\n", "classname", class_name_); - if (!deprecated_attribute_.empty()) { - // No warnings when compiling the impl of this deprecated class. - printer->Print( - "#pragma clang diagnostic push\n" - "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n" - "\n"); - } + if (!elide_message_metadata_) { + if (!deprecated_attribute_.empty()) { + // No warnings when compiling the impl of this deprecated class. + printer->Print( + "#pragma clang diagnostic push\n" + "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n" + "\n"); + } - printer->Print("@implementation $classname$\n\n", - "classname", class_name_); + printer->Print("@implementation $classname$\n\n", + "classname", class_name_); - for (const auto& generator : oneof_generators_) { - generator->GeneratePropertyImplementation(printer); - } + for (const auto& generator : oneof_generators_) { + generator->GeneratePropertyImplementation(printer); + } - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GeneratePropertyImplementation(printer); + for (int i = 0; i < descriptor_->field_count(); i++) { + field_generators_.get(descriptor_->field(i)) + .GeneratePropertyImplementation(printer); + } + printer->Print("\n"); } - std::unique_ptr sorted_fields( SortFieldsByNumber(descriptor_)); std::unique_ptr size_order_fields( @@ -448,7 +451,6 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { sizeof_has_storage += oneof_generators_.size(); printer->Print( - "\n" "typedef struct $classname$__storage_ {\n" " uint32_t _has_storage_[$sizeof_has_storage$];\n", "classname", class_name_, @@ -464,13 +466,25 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { printer->Print("} $classname$__storage_;\n\n", "classname", class_name_); - 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"); - + if (elide_message_metadata_) { + printer->Print( + "// This function is threadsafe because it is initially called by +initialize\n" + "// for each subclass.\n" + "// It is marked as `used` because the reference to it is made from inside the\n" + "// `__asm__` block generated by the `GPB_MESSAGE_CLASS_IMPL` macro.\n" + "__attribute__((used)) static GPBDescriptor *$classname$_descriptor(id self, SEL _cmd) {\n" + " #pragma unused(self, _cmd)\n" + " static GPBDescriptor *descriptor = nil;\n" + " if (!descriptor) {\n", + "classname", class_name_); + } else { + 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"); + } TextFormatDecodeData text_format_decode_data; bool has_fields = descriptor_->field_count() > 0; bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault(); @@ -597,18 +611,25 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { } printer->Print( " #if defined(DEBUG) && DEBUG\n" - " NSAssert(descriptor == nil, @\"Startup recursed!\");\n" + " $assert$(descriptor == nil, @\"Startup recursed!\");\n" " #endif // DEBUG\n" " descriptor = localDescriptor;\n" " }\n" " return descriptor;\n" - "}\n\n" - "@end\n\n"); + "}\n\n", + "assert", elide_message_metadata_ ? "NSCAssert" : "NSAssert"); - if (!deprecated_attribute_.empty()) { + if (elide_message_metadata_) { printer->Print( - "#pragma clang diagnostic pop\n" - "\n"); + "GPB_MESSAGE_SUBCLASS_IMPL($classname$, $classname$_descriptor);\n\n", + "classname", class_name_); + } else { + printer->Print("@end\n\n"); + if (!deprecated_attribute_.empty()) { + printer->Print( + "#pragma clang diagnostic pop\n" + "\n"); + } } for (int i = 0; i < descriptor_->field_count(); i++) { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h index 01108d29e7..6ba25e0c9b 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h @@ -89,6 +89,7 @@ class MessageGenerator { std::vector> enum_generators_; std::vector> nested_message_generators_; std::vector> oneof_generators_; + bool elide_message_metadata_; }; } // namespace objectivec