[ObjC] Generator changes for fullName and FileDescriptor improvements

PiperOrigin-RevId: 508063892
pull/11852/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent f4c7972ff4
commit 4ed02cc3a5
  1. 4
      objectivec/GPBAny.pbobjc.h
  2. 22
      objectivec/GPBAny.pbobjc.m
  3. 4
      objectivec/GPBApi.pbobjc.h
  4. 28
      objectivec/GPBApi.pbobjc.m
  5. 2
      objectivec/GPBBootstrap.h
  6. 4
      objectivec/GPBDuration.pbobjc.h
  7. 22
      objectivec/GPBDuration.pbobjc.m
  8. 4
      objectivec/GPBEmpty.pbobjc.h
  9. 22
      objectivec/GPBEmpty.pbobjc.m
  10. 4
      objectivec/GPBFieldMask.pbobjc.h
  11. 22
      objectivec/GPBFieldMask.pbobjc.m
  12. 4
      objectivec/GPBSourceContext.pbobjc.h
  13. 22
      objectivec/GPBSourceContext.pbobjc.m
  14. 4
      objectivec/GPBStruct.pbobjc.h
  15. 28
      objectivec/GPBStruct.pbobjc.m
  16. 4
      objectivec/GPBTimestamp.pbobjc.h
  17. 22
      objectivec/GPBTimestamp.pbobjc.m
  18. 4
      objectivec/GPBType.pbobjc.h
  19. 34
      objectivec/GPBType.pbobjc.m
  20. 4
      objectivec/GPBWrappers.pbobjc.h
  21. 46
      objectivec/GPBWrappers.pbobjc.m
  22. 99
      src/google/protobuf/compiler/objectivec/file.cc
  23. 4
      src/google/protobuf/compiler/objectivec/file.h
  24. 26
      src/google/protobuf/compiler/objectivec/message.cc
  25. 5
      src/google/protobuf/compiler/objectivec/message.h

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -26,20 +26,11 @@ GPBObjCClassDeclaration(GPBAny);
@end
#pragma mark - GPBAnyRoot_FileDescriptor
static GPBFileDescriptor *GPBAnyRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBAnyRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBAny
@ -82,7 +73,8 @@ typedef struct GPBAny__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBAny)
file:GPBAnyRoot_FileDescriptor()
messageName:@"Any"
fileDescription:&GPBAnyRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBAny__storage_)

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

@ -30,20 +30,11 @@ GPBObjCClassDeclaration(GPBSourceContext);
@end
#pragma mark - GPBApiRoot_FileDescriptor
static GPBFileDescriptor *GPBApiRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBApiRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBApi
@ -141,7 +132,8 @@ typedef struct GPBApi__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBApi)
file:GPBApiRoot_FileDescriptor()
messageName:@"Api"
fileDescription:&GPBApiRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBApi__storage_)
@ -262,7 +254,8 @@ typedef struct GPBMethod__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBMethod)
file:GPBApiRoot_FileDescriptor()
messageName:@"Method"
fileDescription:&GPBApiRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBMethod__storage_)
@ -335,7 +328,8 @@ typedef struct GPBMixin__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBMixin)
file:GPBApiRoot_FileDescriptor()
messageName:@"Mixin"
fileDescription:&GPBApiRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBMixin__storage_)

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

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -26,20 +26,11 @@ GPBObjCClassDeclaration(GPBDuration);
@end
#pragma mark - GPBDurationRoot_FileDescriptor
static GPBFileDescriptor *GPBDurationRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBDurationRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBDuration
@ -82,7 +73,8 @@ typedef struct GPBDuration__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBDuration)
file:GPBDurationRoot_FileDescriptor()
messageName:@"Duration"
fileDescription:&GPBDurationRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBDuration__storage_)

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -26,20 +26,11 @@ GPBObjCClassDeclaration(GPBEmpty);
@end
#pragma mark - GPBEmptyRoot_FileDescriptor
static GPBFileDescriptor *GPBEmptyRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBEmptyRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBEmpty
@ -58,7 +49,8 @@ typedef struct GPBEmpty__storage_ {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBEmpty)
file:GPBEmptyRoot_FileDescriptor()
messageName:@"Empty"
fileDescription:&GPBEmptyRoot_FileDescription
fields:NULL
fieldCount:0
storageSize:sizeof(GPBEmpty__storage_)

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -26,20 +26,11 @@ GPBObjCClassDeclaration(GPBFieldMask);
@end
#pragma mark - GPBFieldMaskRoot_FileDescriptor
static GPBFileDescriptor *GPBFieldMaskRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBFieldMaskRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBFieldMask
@ -71,7 +62,8 @@ typedef struct GPBFieldMask__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBFieldMask)
file:GPBFieldMaskRoot_FileDescriptor()
messageName:@"FieldMask"
fileDescription:&GPBFieldMaskRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBFieldMask__storage_)

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -26,20 +26,11 @@ GPBObjCClassDeclaration(GPBSourceContext);
@end
#pragma mark - GPBSourceContextRoot_FileDescriptor
static GPBFileDescriptor *GPBSourceContextRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBSourceContextRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBSourceContext
@ -71,7 +62,8 @@ typedef struct GPBSourceContext__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBSourceContext)
file:GPBSourceContextRoot_FileDescriptor()
messageName:@"SourceContext"
fileDescription:&GPBSourceContextRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBSourceContext__storage_)

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -31,20 +31,11 @@ GPBObjCClassDeclaration(GPBValue);
@end
#pragma mark - GPBStructRoot_FileDescriptor
static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBStructRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - Enum GPBNullValue
@ -111,7 +102,8 @@ typedef struct GPBStruct__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBStruct)
file:GPBStructRoot_FileDescriptor()
messageName:@"Struct"
fileDescription:&GPBStructRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBStruct__storage_)
@ -211,7 +203,8 @@ typedef struct GPBValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBValue)
file:GPBStructRoot_FileDescriptor()
messageName:@"Value"
fileDescription:&GPBStructRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBValue__storage_)
@ -279,7 +272,8 @@ typedef struct GPBListValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBListValue)
file:GPBStructRoot_FileDescriptor()
messageName:@"ListValue"
fileDescription:&GPBStructRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBListValue__storage_)

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -26,20 +26,11 @@ GPBObjCClassDeclaration(GPBTimestamp);
@end
#pragma mark - GPBTimestampRoot_FileDescriptor
static GPBFileDescriptor *GPBTimestampRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBTimestampRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBTimestamp
@ -82,7 +73,8 @@ typedef struct GPBTimestamp__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBTimestamp)
file:GPBTimestampRoot_FileDescriptor()
messageName:@"Timestamp"
fileDescription:&GPBTimestampRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBTimestamp__storage_)

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

@ -34,20 +34,11 @@ GPBObjCClassDeclaration(GPBType);
@end
#pragma mark - GPBTypeRoot_FileDescriptor
static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBTypeRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - Enum GPBSyntax
@ -289,7 +280,8 @@ typedef struct GPBType__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBType)
file:GPBTypeRoot_FileDescriptor()
messageName:@"Type"
fileDescription:&GPBTypeRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBType__storage_)
@ -444,7 +436,8 @@ typedef struct GPBField__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBField)
file:GPBTypeRoot_FileDescriptor()
messageName:@"Field"
fileDescription:&GPBTypeRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBField__storage_)
@ -562,7 +555,8 @@ typedef struct GPBEnum__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBEnum)
file:GPBTypeRoot_FileDescriptor()
messageName:@"Enum"
fileDescription:&GPBTypeRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBEnum__storage_)
@ -641,7 +635,8 @@ typedef struct GPBEnumValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBEnumValue)
file:GPBTypeRoot_FileDescriptor()
messageName:@"EnumValue"
fileDescription:&GPBTypeRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBEnumValue__storage_)
@ -697,7 +692,8 @@ typedef struct GPBOption__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBOption)
file:GPBTypeRoot_FileDescriptor()
messageName:@"Option"
fileDescription:&GPBTypeRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBOption__storage_)

@ -6,10 +6,10 @@
#import "GPBMessage.h"
#import "GPBRootObject.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#if 30007 < 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.
#endif

@ -34,20 +34,11 @@ GPBObjCClassDeclaration(GPBUInt64Value);
@end
#pragma mark - GPBWrappersRoot_FileDescriptor
static GPBFileDescriptor *GPBWrappersRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
static GPBFileDescription GPBWrappersRoot_FileDescription = {
.package = "google.protobuf",
.prefix = "GPB",
.syntax = GPBFileSyntaxProto3
};
#pragma mark - GPBDoubleValue
@ -79,7 +70,8 @@ typedef struct GPBDoubleValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBDoubleValue)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"DoubleValue"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBDoubleValue__storage_)
@ -124,7 +116,8 @@ typedef struct GPBFloatValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBFloatValue)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"FloatValue"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBFloatValue__storage_)
@ -169,7 +162,8 @@ typedef struct GPBInt64Value__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBInt64Value)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"Int64Value"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBInt64Value__storage_)
@ -214,7 +208,8 @@ typedef struct GPBUInt64Value__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBUInt64Value)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"UInt64Value"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBUInt64Value__storage_)
@ -259,7 +254,8 @@ typedef struct GPBInt32Value__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBInt32Value)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"Int32Value"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBInt32Value__storage_)
@ -304,7 +300,8 @@ typedef struct GPBUInt32Value__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBUInt32Value)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"UInt32Value"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBUInt32Value__storage_)
@ -348,7 +345,8 @@ typedef struct GPBBoolValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBBoolValue)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"BoolValue"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBBoolValue__storage_)
@ -393,7 +391,8 @@ typedef struct GPBStringValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBStringValue)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"StringValue"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBStringValue__storage_)
@ -438,7 +437,8 @@ typedef struct GPBBytesValue__storage_ {
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(GPBBytesValue)
file:GPBWrappersRoot_FileDescriptor()
messageName:@"BytesValue"
fileDescription:&GPBWrappersRoot_FileDescription
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBBytesValue__storage_)

@ -42,7 +42,6 @@
#include "absl/container/btree_set.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "google/protobuf/compiler/objectivec/enum.h"
@ -64,7 +63,7 @@ namespace objectivec {
namespace {
// This is also found in GPBBootstrap.h, and needs to be kept in sync.
const int32_t GOOGLE_PROTOBUF_OBJC_VERSION = 30006;
const int32_t GOOGLE_PROTOBUF_OBJC_VERSION = 30007;
const char* kHeaderExtension = ".pbobjc.h";
@ -113,8 +112,7 @@ struct FileDescriptorsOrderedByName {
};
void MakeDescriptors(
const Descriptor* descriptor, const std::string& root_class_name,
const std::string& file_descriptor_function_name,
const Descriptor* descriptor, const std::string& file_description_name,
std::vector<std::unique_ptr<EnumGenerator>>* enum_generators,
std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators,
std::vector<std::unique_ptr<MessageGenerator>>* message_generators) {
@ -124,39 +122,13 @@ void MakeDescriptors(
}
for (int i = 0; i < descriptor->nested_type_count(); i++) {
message_generators->emplace_back(std::make_unique<MessageGenerator>(
root_class_name, file_descriptor_function_name,
descriptor->nested_type(i)));
file_description_name, descriptor->nested_type(i)));
message_generators->back()->AddExtensionGenerators(extension_generators);
MakeDescriptors(descriptor->nested_type(i), root_class_name,
file_descriptor_function_name, enum_generators,
extension_generators, message_generators);
MakeDescriptors(descriptor->nested_type(i), file_description_name,
enum_generators, extension_generators, message_generators);
}
}
std::string FilenameIdentifier(const std::string& filename) {
std::string result;
for (const auto ch : filename) {
if (absl::ascii_isalnum(ch)) {
result.push_back(ch);
} else if (ch == '/') {
result.push_back('_');
} else {
absl::StrAppend(&result, "_", absl::Hex(static_cast<uint8_t>(ch)));
}
}
return result;
}
std::string FileDescriptorFunctionName(
const FileDescriptor* file, const GenerationOptions& generation_options) {
// If multi source generation, then it won't be static and so make a longer
// name to hopefully ensure it is unique.
if (generation_options.experimental_multi_source_generation) {
return absl::StrCat("FileDescriptor_", FilenameIdentifier(file->name()));
}
return FileClassName(file) + "_FileDescriptor";
}
} // namespace
const FileGenerator::CommonState::MinDepsEntry&
@ -248,8 +220,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file,
generation_options_(generation_options),
common_state_(&common_state),
root_class_name_(FileClassName(file)),
file_descriptor_function_name_(
FileDescriptorFunctionName(file, generation_options)),
file_description_name_(FileClassName(file) + "_FileDescription"),
is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)) {
for (int i = 0; i < file_->enum_type_count(); i++) {
enum_generators_.emplace_back(
@ -261,12 +232,11 @@ FileGenerator::FileGenerator(const FileDescriptor* file,
}
for (int i = 0; i < file_->message_type_count(); i++) {
message_generators_.emplace_back(std::make_unique<MessageGenerator>(
root_class_name_, file_descriptor_function_name_,
file_->message_type(i)));
file_description_name_, file_->message_type(i)));
message_generators_.back()->AddExtensionGenerators(&extension_generators_);
MakeDescriptors(file_->message_type(i), root_class_name_,
file_descriptor_function_name_, &enum_generators_,
&extension_generators_, &message_generators_);
MakeDescriptors(file_->message_type(i), file_description_name_,
&enum_generators_, &extension_generators_,
&message_generators_);
}
}
@ -393,7 +363,7 @@ void FileGenerator::GenerateSource(io::Printer* p) const {
}
PrintRootImplementation(p, deps_with_extensions);
PrintFileDescriptorImplementation(p);
PrintFileDescription(p);
for (const auto& generator : enum_generators_) {
generator->GenerateSource(p);
@ -445,7 +415,6 @@ void FileGenerator::GenerateGlobalSource(io::Printer* p) const {
}
PrintRootImplementation(p, deps_with_extensions);
PrintFileDescriptorImplementation(p);
});
}
@ -472,10 +441,6 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* p) const {
}
GenerateFile(p, GeneratedFileType::kSource, ignored_warnings, {}, [&] {
p->Print(
"extern GPBFileDescriptor *$file_descriptor_function_name$(void);\n\n",
"file_descriptor_function_name", file_descriptor_function_name_);
if (!fwd_decls.empty()) {
p->Print(
// clang-format off
@ -489,6 +454,7 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* p) const {
"fwd_decls", absl::StrJoin(fwd_decls, "\n"));
}
PrintFileDescription(p);
generator->GenerateSource(p);
});
}
@ -720,7 +686,7 @@ void FileGenerator::PrintRootExtensionRegistryImplementation(
// clang-format on
}
void FileGenerator::PrintFileDescriptorImplementation(io::Printer* p) const {
void FileGenerator::PrintFileDescription(io::Printer* p) const {
// File descriptor only needed if there are messages to use it.
if (message_generators_.empty()) {
return;
@ -728,8 +694,10 @@ void FileGenerator::PrintFileDescriptorImplementation(io::Printer* p) const {
const std::string objc_prefix(FileClassPrefix(file_));
absl::flat_hash_map<absl::string_view, std::string> vars;
vars["file_descriptor_function_name"] = file_descriptor_function_name_;
vars["package"] = file_->package();
vars["file_description_name"] = file_description_name_;
vars["package_value"] = file_->package().empty()
? "NULL"
: absl::StrCat("\"", file_->package(), "\"");
switch (file_->syntax()) {
case FileDescriptor::SYNTAX_UNKNOWN:
vars["syntax"] = "GPBFileSyntaxUnknown";
@ -741,37 +709,20 @@ void FileGenerator::PrintFileDescriptorImplementation(io::Printer* p) const {
vars["syntax"] = "GPBFileSyntaxProto3";
break;
}
if (objc_prefix.empty()) {
vars["prefix_arg"] = "";
} else {
vars["prefix_arg"] = absl::StrCat(
" objcPrefix:@\"",
objc_prefix, "\"\n");
}
if (generation_options_.experimental_multi_source_generation) {
vars["file_desc_scope"] = "";
if (objc_prefix.empty() && !file_->options().has_objc_class_prefix()) {
vars["prefix_value"] = "NULL";
} else {
vars["file_desc_scope"] = "static ";
vars["prefix_value"] = absl::StrCat("\"", objc_prefix, "\"");
}
// clang-format off
p->Print(
vars,
"#pragma mark - $file_descriptor_function_name$\n"
"\n"
"$file_desc_scope$GPBFileDescriptor *$file_descriptor_function_name$(void) {\n"
" // This is called by +initialize so there is no need to worry\n"
" // about thread safety of the singleton.\n"
" static GPBFileDescriptor *descriptor = NULL;\n"
" if (!descriptor) {\n"
" GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n"
" descriptor = [[GPBFileDescriptor alloc] initWithPackage:@\"$package$\"\n"
"$prefix_arg$"
" syntax:$syntax$];\n"
" }\n"
" return descriptor;\n"
"}\n"
"static GPBFileDescription $file_description_name$ = {\n"
" .package = $package_value$,\n"
" .prefix = $prefix_value$,\n"
" .syntax = $syntax$\n"
"};\n"
"\n");
// clang-format on
}

@ -110,7 +110,7 @@ class FileGenerator {
void PrintRootExtensionRegistryImplementation(
io::Printer* p,
const std::vector<const FileDescriptor*>& deps_with_extensions) const;
void PrintFileDescriptorImplementation(io::Printer* p) const;
void PrintFileDescription(io::Printer* p) const;
bool HeadersUseForwardDeclarations() const {
// The bundled protos (WKTs) don't make use of forward declarations.
@ -122,7 +122,7 @@ class FileGenerator {
const GenerationOptions& generation_options_;
mutable CommonState* common_state_;
const std::string root_class_name_;
const std::string file_descriptor_function_name_;
const std::string file_description_name_;
const bool is_bundled_proto_;
std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;

@ -215,12 +215,9 @@ const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {
} // namespace
MessageGenerator::MessageGenerator(
const std::string& root_classname,
const std::string& file_descriptor_function_name,
const Descriptor* descriptor)
: root_classname_(root_classname),
file_descriptor_function_name_(file_descriptor_function_name),
MessageGenerator::MessageGenerator(const std::string& file_description_name,
const Descriptor* descriptor)
: file_description_name_(file_description_name),
descriptor_(descriptor),
field_generators_(descriptor),
class_name_(ClassName(descriptor_)),
@ -461,8 +458,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
// 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_);
" __unused Class rootStartup = [$root_class_name$ class];\n",
"root_class_name", FileClassName(descriptor_->file()));
// clang-format on
} else {
// The Root class has a debug runtime check, so if not starting that
@ -503,8 +500,9 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
absl::flat_hash_map<absl::string_view, std::string> vars;
vars["classname"] = class_name_;
vars["message_name"] = descriptor_->name();
vars["class_reference"] = ObjCClass(class_name_);
vars["file_descriptor_function_name"] = file_descriptor_function_name_;
vars["file_description_name"] = file_description_name_;
vars["fields"] = has_fields ? "fields" : "NULL";
if (has_fields) {
vars["fields_count"] = absl::StrCat("(uint32_t)(sizeof(fields) / sizeof(",
@ -532,7 +530,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
vars,
" GPBDescriptor *localDescriptor =\n"
" [GPBDescriptor allocDescriptorForClass:$class_reference$\n"
" file:$file_descriptor_function_name$()\n"
" messageName:@\"$message_name$\"\n"
" fileDescription:&$file_description_name$\n"
" fields:$fields$\n"
" fieldCount:$fields_count$\n"
" storageSize:sizeof($classname$__storage_)\n"
@ -596,13 +595,6 @@ void MessageGenerator::GenerateSource(io::Printer* printer) const {
// clang-format on
"parent_class_ref", parent_class_ref);
}
std::string suffix_added;
ClassName(descriptor_, &suffix_added);
if (!suffix_added.empty()) {
printer->Print(
" [localDescriptor setupMessageClassNameSuffix:@\"$suffix$\"];\n",
"suffix", suffix_added);
}
// clang-format off
printer->Print(
" #if defined(DEBUG) && DEBUG\n"

@ -51,8 +51,7 @@ class ExtensionGenerator;
class MessageGenerator {
public:
MessageGenerator(const std::string& root_classname,
const std::string& file_descriptor_function_name,
MessageGenerator(const std::string& file_description_name,
const Descriptor* descriptor);
~MessageGenerator() = default;
@ -74,7 +73,7 @@ class MessageGenerator {
private:
const std::string root_classname_;
const std::string file_descriptor_function_name_;
const std::string file_description_name_;
const Descriptor* descriptor_;
FieldGeneratorMap field_generators_;
const std::string class_name_;

Loading…
Cancel
Save