[ObjC] Loosen the link between generate messages and roots.

The root class only needs to be started up if the message scopes extensions.
This updates the startup flows so the root is only started when the message
scopes extensions and thus the runtime requires that startup.

Bump the generated source version to account for the new initializer that
doesn't take the rootClass argument.

Fix typo while at it.

PiperOrigin-RevId: 504899046
pull/11676/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 8e022f8158
commit 48ff4f6219
  1. 4
      objectivec/GPBAny.pbobjc.h
  2. 1
      objectivec/GPBAny.pbobjc.m
  3. 4
      objectivec/GPBApi.pbobjc.h
  4. 3
      objectivec/GPBApi.pbobjc.m
  5. 2
      objectivec/GPBBootstrap.h
  6. 36
      objectivec/GPBDescriptor.m
  7. 8
      objectivec/GPBDescriptor_PackagePrivate.h
  8. 4
      objectivec/GPBDuration.pbobjc.h
  9. 1
      objectivec/GPBDuration.pbobjc.m
  10. 4
      objectivec/GPBEmpty.pbobjc.h
  11. 1
      objectivec/GPBEmpty.pbobjc.m
  12. 4
      objectivec/GPBFieldMask.pbobjc.h
  13. 1
      objectivec/GPBFieldMask.pbobjc.m
  14. 4
      objectivec/GPBSourceContext.pbobjc.h
  15. 1
      objectivec/GPBSourceContext.pbobjc.m
  16. 4
      objectivec/GPBStruct.pbobjc.h
  17. 3
      objectivec/GPBStruct.pbobjc.m
  18. 4
      objectivec/GPBTimestamp.pbobjc.h
  19. 1
      objectivec/GPBTimestamp.pbobjc.m
  20. 4
      objectivec/GPBType.pbobjc.h
  21. 5
      objectivec/GPBType.pbobjc.m
  22. 4
      objectivec/GPBWrappers.pbobjc.h
  23. 9
      objectivec/GPBWrappers.pbobjc.m
  24. 2
      src/google/protobuf/compiler/objectivec/file.cc
  25. 14
      src/google/protobuf/compiler/objectivec/message.cc

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -74,7 +74,6 @@ typedef struct GPBAny__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBAny class] [GPBDescriptor allocDescriptorForClass:[GPBAny class]
rootClass:[GPBAnyRoot class]
file:GPBAnyRoot_FileDescriptor() file:GPBAnyRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -8,10 +8,10 @@
#import "GPBSourceContext.pbobjc.h" #import "GPBSourceContext.pbobjc.h"
#import "GPBType.pbobjc.h" #import "GPBType.pbobjc.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -139,7 +139,6 @@ typedef struct GPBApi__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBApi class] [GPBDescriptor allocDescriptorForClass:[GPBApi class]
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor() file:GPBApiRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -260,7 +259,6 @@ typedef struct GPBMethod__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBMethod class] [GPBDescriptor allocDescriptorForClass:[GPBMethod class]
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor() file:GPBApiRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -333,7 +331,6 @@ typedef struct GPBMixin__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBMixin class] [GPBDescriptor allocDescriptorForClass:[GPBMixin class]
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor() file:GPBApiRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -134,7 +134,7 @@
// Current library runtime version. // Current library runtime version.
// - Gets bumped when the runtime makes changes to the interfaces between the // - Gets bumped when the runtime makes changes to the interfaces between the
// generated code and runtime (things added/removed, etc). // generated code and runtime (things added/removed, etc).
#define GOOGLE_PROTOBUF_OBJC_VERSION 30005 #define GOOGLE_PROTOBUF_OBJC_VERSION 30006
// Minimum runtime version supported for compiling/running against. // Minimum runtime version supported for compiling/running against.
// - Gets changed when support for the older generated code is dropped. // - Gets changed when support for the older generated code is dropped.

@ -49,7 +49,7 @@
// description has to be long lived, it is held as a raw pointer. // description has to be long lived, it is held as a raw pointer.
- (instancetype)initWithFieldDescription:(void *)description - (instancetype)initWithFieldDescription:(void *)description
file:(GPBFileDescriptor *)file file:(GPBFileDescriptor *)file
decriptorFlags:(GPBDescriptorInitializationFlags)decriptorFlags; descriptorFlags:(GPBDescriptorInitializationFlags)descriptorFlags;
@end @end
@ -135,15 +135,11 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
@synthesize wireFormat = wireFormat_; @synthesize wireFormat = wireFormat_;
+ (instancetype)allocDescriptorForClass:(Class)messageClass + (instancetype)allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags { flags:(GPBDescriptorInitializationFlags)flags {
// The rootClass is no longer used, but it is passed in to ensure it
// was started up during initialization also.
(void)rootClass;
NSMutableArray *fields = NSMutableArray *fields =
(fieldCount ? [[NSMutableArray alloc] initWithCapacity:fieldCount] : nil); (fieldCount ? [[NSMutableArray alloc] initWithCapacity:fieldCount] : nil);
BOOL fieldsIncludeDefault = (flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0; BOOL fieldsIncludeDefault = (flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0;
@ -157,7 +153,7 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
desc = &(((GPBMessageFieldDescription *)fieldDescriptions)[i]); desc = &(((GPBMessageFieldDescription *)fieldDescriptions)[i]);
} }
GPBFieldDescriptor *fieldDescriptor = GPBFieldDescriptor *fieldDescriptor =
[[GPBFieldDescriptor alloc] initWithFieldDescription:desc file:file decriptorFlags:flags]; [[GPBFieldDescriptor alloc] initWithFieldDescription:desc file:file descriptorFlags:flags];
[fields addObject:fieldDescriptor]; [fields addObject:fieldDescriptor];
[fieldDescriptor release]; [fieldDescriptor release];
} }
@ -172,6 +168,24 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, NSArray *allMessageField
return descriptor; return descriptor;
} }
+ (instancetype)allocDescriptorForClass:(Class)messageClass
rootClass:(__unused Class)rootClass
file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags {
// The rootClass is no longer used, but it is passed as [ROOT class] to
// ensure it was started up during initialization also when the message
// scopes extensions.
return [self allocDescriptorForClass:messageClass
file:file
fields:fieldDescriptions
fieldCount:fieldCount
storageSize:storageSize
flags:flags];
}
- (instancetype)initWithClass:(Class)messageClass - (instancetype)initWithClass:(Class)messageClass
file:(GPBFileDescriptor *)file file:(GPBFileDescriptor *)file
fields:(NSArray *)fields fields:(NSArray *)fields
@ -466,10 +480,10 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
- (instancetype)initWithFieldDescription:(void *)description - (instancetype)initWithFieldDescription:(void *)description
file:(GPBFileDescriptor *)file file:(GPBFileDescriptor *)file
decriptorFlags:(GPBDescriptorInitializationFlags)decriptorFlags { descriptorFlags:(GPBDescriptorInitializationFlags)descriptorFlags {
if ((self = [super init])) { if ((self = [super init])) {
BOOL includesDefault = BOOL includesDefault =
(decriptorFlags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0; (descriptorFlags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0;
GPBMessageFieldDescription *coreDesc; GPBMessageFieldDescription *coreDesc;
if (includesDefault) { if (includesDefault) {
coreDesc = &(((GPBMessageFieldDescriptionWithDefault *)description)->core); coreDesc = &(((GPBMessageFieldDescriptionWithDefault *)description)->core);
@ -486,7 +500,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// If proto3 optionals weren't known (i.e. generated code from an // If proto3 optionals weren't known (i.e. generated code from an
// older version), compute the flag for the rest of the runtime. // older version), compute the flag for the rest of the runtime.
if ((decriptorFlags & GPBDescriptorInitializationFlag_Proto3OptionalKnown) == 0) { if ((descriptorFlags & GPBDescriptorInitializationFlag_Proto3OptionalKnown) == 0) {
// If it was... // If it was...
// - proto3 syntax // - proto3 syntax
// - not repeated/map // - not repeated/map
@ -504,7 +518,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// If the ClosedEnum flag wasn't known (i.e. generated code from an older // If the ClosedEnum flag wasn't known (i.e. generated code from an older
// version), compute the flag for the rest of the runtime. // version), compute the flag for the rest of the runtime.
if ((decriptorFlags & GPBDescriptorInitializationFlag_ClosedEnumSupportKnown) == 0) { if ((descriptorFlags & GPBDescriptorInitializationFlag_ClosedEnumSupportKnown) == 0) {
// NOTE: This isn't correct, it is using the syntax of the file that // NOTE: This isn't correct, it is using the syntax of the file that
// declared the field, not the syntax of the file that declared the // declared the field, not the syntax of the file that declared the
// enum; but for older generated code, that's all we have and that happens // enum; but for older generated code, that's all we have and that happens
@ -540,7 +554,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
// Note: Only fetch the class here, can't send messages to it because // Note: Only fetch the class here, can't send messages to it because
// that could cause cycles back to this class within +initialize if // that could cause cycles back to this class within +initialize if
// two messages have each other in fields (i.e. - they build a graph). // two messages have each other in fields (i.e. - they build a graph).
if ((decriptorFlags & GPBDescriptorInitializationFlag_UsesClassRefs) != 0) { if ((descriptorFlags & GPBDescriptorInitializationFlag_UsesClassRefs) != 0) {
msgClass_ = coreDesc->dataTypeSpecific.clazz; msgClass_ = coreDesc->dataTypeSpecific.clazz;
} else { } else {
// Backwards compatibility for sources generated with older protoc. // Backwards compatibility for sources generated with older protoc.

@ -201,6 +201,14 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
} }
// fieldDescriptions have to be long lived, they are held as raw pointers. // fieldDescriptions have to be long lived, they are held as raw pointers.
+ (instancetype)allocDescriptorForClass:(Class)messageClass
file:(GPBFileDescriptor *)file
fields:(void *)fieldDescriptions
fieldCount:(uint32_t)fieldCount
storageSize:(uint32_t)storageSize
flags:(GPBDescriptorInitializationFlags)flags;
// Old interface that took the rootClass.
+ (instancetype)allocDescriptorForClass:(Class)messageClass + (instancetype)allocDescriptorForClass:(Class)messageClass
rootClass:(Class)rootClass rootClass:(Class)rootClass
file:(GPBFileDescriptor *)file file:(GPBFileDescriptor *)file

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -74,7 +74,6 @@ typedef struct GPBDuration__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBDuration class] [GPBDescriptor allocDescriptorForClass:[GPBDuration class]
rootClass:[GPBDurationRoot class]
file:GPBDurationRoot_FileDescriptor() file:GPBDurationRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -50,7 +50,6 @@ typedef struct GPBEmpty__storage_ {
if (!descriptor) { if (!descriptor) {
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBEmpty class] [GPBDescriptor allocDescriptorForClass:[GPBEmpty class]
rootClass:[GPBEmptyRoot class]
file:GPBEmptyRoot_FileDescriptor() file:GPBEmptyRoot_FileDescriptor()
fields:NULL fields:NULL
fieldCount:0 fieldCount:0

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -63,7 +63,6 @@ typedef struct GPBFieldMask__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBFieldMask class] [GPBDescriptor allocDescriptorForClass:[GPBFieldMask class]
rootClass:[GPBFieldMaskRoot class]
file:GPBFieldMaskRoot_FileDescriptor() file:GPBFieldMaskRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -63,7 +63,6 @@ typedef struct GPBSourceContext__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBSourceContext class] [GPBDescriptor allocDescriptorForClass:[GPBSourceContext class]
rootClass:[GPBSourceContextRoot class]
file:GPBSourceContextRoot_FileDescriptor() file:GPBSourceContextRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -109,7 +109,6 @@ typedef struct GPBStruct__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBStruct class] [GPBDescriptor allocDescriptorForClass:[GPBStruct class]
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor() file:GPBStructRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -209,7 +208,6 @@ typedef struct GPBValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBValue class] [GPBDescriptor allocDescriptorForClass:[GPBValue class]
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor() file:GPBStructRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -277,7 +275,6 @@ typedef struct GPBListValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBListValue class] [GPBDescriptor allocDescriptorForClass:[GPBListValue class]
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor() file:GPBStructRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -74,7 +74,6 @@ typedef struct GPBTimestamp__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBTimestamp class] [GPBDescriptor allocDescriptorForClass:[GPBTimestamp class]
rootClass:[GPBTimestampRoot class]
file:GPBTimestampRoot_FileDescriptor() file:GPBTimestampRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -8,10 +8,10 @@
#import "GPBAny.pbobjc.h" #import "GPBAny.pbobjc.h"
#import "GPBSourceContext.pbobjc.h" #import "GPBSourceContext.pbobjc.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -283,7 +283,6 @@ typedef struct GPBType__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBType class] [GPBDescriptor allocDescriptorForClass:[GPBType class]
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor() file:GPBTypeRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -438,7 +437,6 @@ typedef struct GPBField__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBField class] [GPBDescriptor allocDescriptorForClass:[GPBField class]
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor() file:GPBTypeRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -556,7 +554,6 @@ typedef struct GPBEnum__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBEnum class] [GPBDescriptor allocDescriptorForClass:[GPBEnum class]
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor() file:GPBTypeRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -635,7 +632,6 @@ typedef struct GPBEnumValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBEnumValue class] [GPBDescriptor allocDescriptorForClass:[GPBEnumValue class]
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor() file:GPBTypeRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -691,7 +687,6 @@ typedef struct GPBOption__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBOption class] [GPBDescriptor allocDescriptorForClass:[GPBOption class]
rootClass:[GPBTypeRoot class]
file:GPBTypeRoot_FileDescriptor() file:GPBTypeRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -6,10 +6,10 @@
#import "GPBMessage.h" #import "GPBMessage.h"
#import "GPBRootObject.h" #import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30005 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif
#if 30005 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION #if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif #endif

@ -63,7 +63,6 @@ typedef struct GPBDoubleValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBDoubleValue class] [GPBDescriptor allocDescriptorForClass:[GPBDoubleValue class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -108,7 +107,6 @@ typedef struct GPBFloatValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBFloatValue class] [GPBDescriptor allocDescriptorForClass:[GPBFloatValue class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -153,7 +151,6 @@ typedef struct GPBInt64Value__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBInt64Value class] [GPBDescriptor allocDescriptorForClass:[GPBInt64Value class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -198,7 +195,6 @@ typedef struct GPBUInt64Value__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBUInt64Value class] [GPBDescriptor allocDescriptorForClass:[GPBUInt64Value class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -243,7 +239,6 @@ typedef struct GPBInt32Value__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBInt32Value class] [GPBDescriptor allocDescriptorForClass:[GPBInt32Value class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -288,7 +283,6 @@ typedef struct GPBUInt32Value__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBUInt32Value class] [GPBDescriptor allocDescriptorForClass:[GPBUInt32Value class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -332,7 +326,6 @@ typedef struct GPBBoolValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBBoolValue class] [GPBDescriptor allocDescriptorForClass:[GPBBoolValue class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -377,7 +370,6 @@ typedef struct GPBStringValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBStringValue class] [GPBDescriptor allocDescriptorForClass:[GPBStringValue class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
@ -422,7 +414,6 @@ typedef struct GPBBytesValue__storage_ {
}; };
GPBDescriptor *localDescriptor = GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBBytesValue class] [GPBDescriptor allocDescriptorForClass:[GPBBytesValue class]
rootClass:[GPBWrappersRoot class]
file:GPBWrappersRoot_FileDescriptor() file:GPBWrappersRoot_FileDescriptor()
fields:fields fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))

@ -64,7 +64,7 @@ namespace objectivec {
namespace { namespace {
// This is also found in GPBBootstrap.h, and needs to be kept in sync. // This is also found in GPBBootstrap.h, and needs to be kept in sync.
const int32_t GOOGLE_PROTOBUF_OBJC_VERSION = 30005; const int32_t GOOGLE_PROTOBUF_OBJC_VERSION = 30006;
const char* kHeaderExtension = ".pbobjc.h"; const char* kHeaderExtension = ".pbobjc.h";

@ -450,6 +450,18 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
" if (!descriptor) {\n"); " if (!descriptor) {\n");
// clang-format on // clang-format on
// If the message scopes extensions, trigger the root class
// +initialize/+extensionRegistry as that is where the runtime support for
// extensions lives.
if (descriptor_->extension_count() > 0) {
// clang-format off
printer->Print(
" // Start up the root class to support the scoped extensions.\n"
" __unused Class rootStartup = [$rootclass_name$ class];\n",
"rootclass_name", root_classname_);
// clang-format on
}
TextFormatDecodeData text_format_decode_data; TextFormatDecodeData text_format_decode_data;
bool has_fields = descriptor_->field_count() > 0; bool has_fields = descriptor_->field_count() > 0;
bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault(); bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault();
@ -483,7 +495,6 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
absl::flat_hash_map<absl::string_view, std::string> vars; absl::flat_hash_map<absl::string_view, std::string> vars;
vars["classname"] = class_name_; vars["classname"] = class_name_;
vars["rootclassname"] = root_classname_;
vars["file_descriptor_function_name"] = file_descriptor_function_name_; vars["file_descriptor_function_name"] = file_descriptor_function_name_;
vars["fields"] = has_fields ? "fields" : "NULL"; vars["fields"] = has_fields ? "fields" : "NULL";
if (has_fields) { if (has_fields) {
@ -512,7 +523,6 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
vars, vars,
" GPBDescriptor *localDescriptor =\n" " GPBDescriptor *localDescriptor =\n"
" [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n" " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n"
" rootClass:[$rootclassname$ class]\n"
" file:$file_descriptor_function_name$()\n" " file:$file_descriptor_function_name$()\n"
" fields:$fields$\n" " fields:$fields$\n"
" fieldCount:$fields_count$\n" " fieldCount:$fields_count$\n"

Loading…
Cancel
Save