Fix bugs for objectivec

This commit is contained in:
TeBoring 2015-08-26 14:02:44 -07:00
parent b1b98e4b79
commit aca5a60883
16 changed files with 457 additions and 29 deletions

View File

@ -68,6 +68,7 @@ fi
mkdir -p "${OUTPUT_DIR}/google/protobuf"
CORE_PROTO_FILES=( \
src/google/protobuf/unittest_arena.proto \
src/google/protobuf/unittest_custom_options.proto \
src/google/protobuf/unittest_enormous_descriptor.proto \
src/google/protobuf/unittest_embed_optimize_for.proto \
@ -76,6 +77,9 @@ CORE_PROTO_FILES=( \
src/google/protobuf/unittest_import_lite.proto \
src/google/protobuf/unittest_lite.proto \
src/google/protobuf/unittest_mset.proto \
src/google/protobuf/unittest_mset_wire_format.proto \
src/google/protobuf/unittest_no_arena.proto \
src/google/protobuf/unittest_no_arena_import.proto \
src/google/protobuf/unittest_no_generic_services.proto \
src/google/protobuf/unittest_optimize_for.proto \
src/google/protobuf/unittest.proto \

View File

@ -34,6 +34,7 @@
#import "google/protobuf/MapProto2Unittest.pbobjc.m"
#import "google/protobuf/MapUnittest.pbobjc.m"
#import "google/protobuf/Unittest.pbobjc.m"
#import "google/protobuf/UnittestArena.pbobjc.m"
#import "google/protobuf/UnittestCustomOptions.pbobjc.m"
#import "google/protobuf/UnittestCycle.pbobjc.m"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.m"
@ -46,6 +47,9 @@
#import "google/protobuf/UnittestImportPublicLite.pbobjc.m"
#import "google/protobuf/UnittestLite.pbobjc.m"
#import "google/protobuf/UnittestMset.pbobjc.m"
#import "google/protobuf/UnittestMsetWireFormat.pbobjc.m"
#import "google/protobuf/UnittestNoArena.pbobjc.m"
#import "google/protobuf/UnittestNoArenaImport.pbobjc.m"
#import "google/protobuf/UnittestNoGenericServices.pbobjc.m"
#import "google/protobuf/UnittestObjc.pbobjc.m"
#import "google/protobuf/UnittestObjcStartup.pbobjc.m"

View File

@ -35,6 +35,7 @@
#import "GPBUnknownField_PackagePrivate.h"
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestMset.pbobjc.h"
#import "google/protobuf/UnittestMsetWireFormat.pbobjc.h"
@interface WireFormatTests : GPBTestCase
@end

View File

@ -34,10 +34,8 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
// `Any` contains an arbitrary serialized message along with a URL
// that describes the type of the serialized message.
//
// The proto runtimes and/or compiler will eventually
// provide utilities to pack/unpack Any values (projected Q1/15).
//
// # JSON
// JSON
// ====
// The JSON representation of an `Any` value uses the regular
// representation of the deserialized, embedded message, with an
// additional field `@type` which contains the type URL. Example:
@ -84,11 +82,6 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
//
// Schemas other than `http`, `https` (or the empty schema) might be
// used with implementation specific semantics.
//
// Types originating from the `google.*` package
// namespace should use `type.googleapis.com/full.type.name` (without
// schema and path). A type service will eventually become available which
// serves those URLs (projected Q2/15).
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
// Must be valid serialized data of the above specified type.

View File

@ -12,6 +12,7 @@
CF_EXTERN_C_BEGIN
@class GPBSourceContext;
GPB_ENUM_FWD_DECLARE(GPBSyntax);
NS_ASSUME_NONNULL_BEGIN
@ -34,6 +35,8 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
GPBApi_FieldNumber_OptionsArray = 3,
GPBApi_FieldNumber_Version = 4,
GPBApi_FieldNumber_SourceContext = 5,
GPBApi_FieldNumber_MixinsArray = 6,
GPBApi_FieldNumber_Syntax = 7,
};
// Api is a light-weight descriptor for a protocol buffer service.
@ -73,8 +76,6 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
// `google.feature.v1`. For major versions 0 and 1, the suffix can
// be omitted. Zero major versions must only be used for
// experimental, none-GA apis.
//
// See also: [design doc](http://go/api-versioning).
@property(nonatomic, readwrite, copy, null_resettable) NSString *version;
// Source context for the protocol buffer service represented by this
@ -82,8 +83,19 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
@property(nonatomic, readwrite) BOOL hasSourceContext;
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
// Included APIs. See [Mixin][].
// |mixinsArray| contains |GPBMixin|
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *mixinsArray;
@property(nonatomic, readonly) NSUInteger mixinsArray_Count;
// The source syntax of the service.
@property(nonatomic, readwrite) enum GPBSyntax syntax;
@end
int32_t GPBApi_Syntax_RawValue(GPBApi *message);
void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value);
#pragma mark - GPBMethod
typedef GPB_ENUM(GPBMethod_FieldNumber) {
@ -93,6 +105,7 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) {
GPBMethod_FieldNumber_ResponseTypeURL = 4,
GPBMethod_FieldNumber_ResponseStreaming = 5,
GPBMethod_FieldNumber_OptionsArray = 6,
GPBMethod_FieldNumber_Syntax = 7,
};
// Method represents a method of an api.
@ -118,6 +131,108 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) {
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
// The source syntax of this method.
@property(nonatomic, readwrite) enum GPBSyntax syntax;
@end
int32_t GPBMethod_Syntax_RawValue(GPBMethod *message);
void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value);
#pragma mark - GPBMixin
typedef GPB_ENUM(GPBMixin_FieldNumber) {
GPBMixin_FieldNumber_Name = 1,
GPBMixin_FieldNumber_Root = 2,
};
// Declares an API to be included in this API. The including API must
// redeclare all the methods from the included API, but documentation
// and options are inherited as follows:
//
// - If after comment and whitespace stripping, the documentation
// string of the redeclared method is empty, it will be inherited
// from the original method.
//
// - Each annotation belonging to the service config (http,
// visibility) which is not set in the redeclared method will be
// inherited.
//
// - If an http annotation is inherited, the path pattern will be
// modified as follows. Any version prefix will be replaced by the
// version of the including API plus the [root][] path if specified.
//
// Example of a simple mixin:
//
// package google.acl.v1;
// service AccessControl {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v1/{resource=**}:getAcl";
// }
// }
//
// package google.storage.v2;
// service Storage {
// // (-- see AccessControl.GetAcl --)
// rpc GetAcl(GetAclRequest) returns (Acl);
//
// // Get a data record.
// rpc GetData(GetDataRequest) returns (Data) {
// option (google.api.http).get = "/v2/{resource=**}";
// }
// }
//
// Example of a mixin configuration:
//
// apis:
// - name: google.storage.v2.Storage
// mixins:
// - name: google.acl.v1.AccessControl
//
// The mixin construct implies that all methods in `AccessControl` are
// also declared with same name and request/response types in
// `Storage`. A documentation generator or annotation processor will
// see the effective `Storage.GetAcl` method after inherting
// documentation and annotations as follows:
//
// service Storage {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v2/{resource=**}:getAcl";
// }
// ...
// }
//
// Note how the version in the path pattern changed from `v1` to `v2`.
//
// If the `root` field in the mixin is specified, it should be a
// relative path under which inherited HTTP paths are placed. Example:
//
// apis:
// - name: google.storage.v2.Storage
// mixins:
// - name: google.acl.v1.AccessControl
// root: acls
//
// This implies the following inherited HTTP annotation:
//
// service Storage {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
// }
// ...
// }
@interface GPBMixin : GPBMessage
// The fully qualified name of the API which is included.
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
// If non-empty specifies a path under which inherited HTTP paths
// are rooted.
@property(nonatomic, readwrite, copy, null_resettable) NSString *root;
@end
NS_ASSUME_NONNULL_END

View File

@ -49,14 +49,18 @@ static GPBFileDescriptor *GPBApiRoot_FileDescriptor(void) {
@dynamic optionsArray, optionsArray_Count;
@dynamic version;
@dynamic hasSourceContext, sourceContext;
@dynamic mixinsArray, mixinsArray_Count;
@dynamic syntax;
typedef struct GPBApi__storage_ {
uint32_t _has_storage_[1];
GPBSyntax syntax;
NSString *name;
NSMutableArray *methodsArray;
NSMutableArray *optionsArray;
NSString *version;
GPBSourceContext *sourceContext;
NSMutableArray *mixinsArray;
} GPBApi__storage_;
// This method is threadsafe because it is initially called
@ -120,6 +124,28 @@ typedef struct GPBApi__storage_ {
.dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
.fieldOptions = NULL,
},
{
.name = "mixinsArray",
.number = GPBApi_FieldNumber_MixinsArray,
.hasIndex = GPBNoHasBit,
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
.offset = offsetof(GPBApi__storage_, mixinsArray),
.defaultValue.valueMessage = nil,
.dataTypeSpecific.className = GPBStringifySymbol(GPBMixin),
.fieldOptions = NULL,
},
{
.name = "syntax",
.number = GPBApi_FieldNumber_Syntax,
.hasIndex = 6,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.dataType = GPBDataTypeEnum,
.offset = offsetof(GPBApi__storage_, syntax),
.defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBApi class]
@ -143,6 +169,18 @@ typedef struct GPBApi__storage_ {
@end
int32_t GPBApi_Syntax_RawValue(GPBApi *message) {
GPBDescriptor *descriptor = [GPBApi descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax];
return GPBGetMessageInt32Field(message, field);
}
void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value) {
GPBDescriptor *descriptor = [GPBApi descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - GPBMethod
@implementation GPBMethod
@ -153,11 +191,13 @@ typedef struct GPBApi__storage_ {
@dynamic responseTypeURL;
@dynamic responseStreaming;
@dynamic optionsArray, optionsArray_Count;
@dynamic syntax;
typedef struct GPBMethod__storage_ {
uint32_t _has_storage_[1];
BOOL requestStreaming;
BOOL responseStreaming;
GPBSyntax syntax;
NSString *name;
NSString *requestTypeURL;
NSString *responseTypeURL;
@ -236,6 +276,17 @@ typedef struct GPBMethod__storage_ {
.dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.fieldOptions = NULL,
},
{
.name = "syntax",
.number = GPBMethod_FieldNumber_Syntax,
.hasIndex = 6,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.dataType = GPBDataTypeEnum,
.offset = offsetof(GPBMethod__storage_, syntax),
.defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.fieldOptions = NULL,
},
};
#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS
const char *extraTextFormatInfo = NULL;
@ -265,5 +316,81 @@ typedef struct GPBMethod__storage_ {
@end
int32_t GPBMethod_Syntax_RawValue(GPBMethod *message) {
GPBDescriptor *descriptor = [GPBMethod descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax];
return GPBGetMessageInt32Field(message, field);
}
void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value) {
GPBDescriptor *descriptor = [GPBMethod descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - GPBMixin
@implementation GPBMixin
@dynamic name;
@dynamic root;
typedef struct GPBMixin__storage_ {
uint32_t _has_storage_[1];
NSString *name;
NSString *root;
} GPBMixin__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
.number = GPBMixin_FieldNumber_Name,
.hasIndex = 0,
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
.offset = offsetof(GPBMixin__storage_, name),
.defaultValue.valueString = nil,
.dataTypeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "root",
.number = GPBMixin_FieldNumber_Root,
.hasIndex = 1,
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
.offset = offsetof(GPBMixin__storage_, root),
.defaultValue.valueString = nil,
.dataTypeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBMixin class]
rootClass:[GPBApiRoot class]
file:GPBApiRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(GPBMixin__storage_)
wireFormat:NO];
NSAssert(descriptor == nil, @"Startup recursed!");
descriptor = localDescriptor;
}
return descriptor;
}
@end
// @@protoc_insertion_point(global_scope)

View File

@ -531,6 +531,7 @@ typedef GPB_ENUM(GPBFileOptions_FieldNumber) {
GPBFileOptions_FieldNumber_CcEnableArenas = 31,
GPBFileOptions_FieldNumber_ObjcClassPrefix = 36,
GPBFileOptions_FieldNumber_CsharpNamespace = 37,
GPBFileOptions_FieldNumber_JavananoUseDeprecatedPackage = 38,
GPBFileOptions_FieldNumber_UninterpretedOptionArray = 999,
};
@ -562,10 +563,12 @@ typedef GPB_ENUM(GPBFileOptions_FieldNumber) {
// If set true, then the Java code generator will generate equals() and
// hashCode() methods for all messages defined in the .proto file.
// - In the full runtime, this is purely a speed optimization, as the
// This increases generated code size, potentially substantially for large
// protos, which may harm a memory-constrained application.
// - In the full runtime this is a speed optimization, as the
// AbstractMessage base class includes reflection-based implementations of
// these methods.
//- In the lite runtime, setting this option changes the semantics of
// - In the lite runtime, setting this option changes the semantics of
// equals() and hashCode() to more closely match those of the full runtime;
// the generated methods compute their results based on field values rather
// than object identity. (Implementations should not assume that hashcodes
@ -633,6 +636,11 @@ typedef GPB_ENUM(GPBFileOptions_FieldNumber) {
@property(nonatomic, readwrite) BOOL hasCsharpNamespace;
@property(nonatomic, readwrite, copy, null_resettable) NSString *csharpNamespace;
// Whether the nano proto compiler should generate in the deprecated non-nano
// suffixed package.
@property(nonatomic, readwrite) BOOL hasJavananoUseDeprecatedPackage;
@property(nonatomic, readwrite) BOOL javananoUseDeprecatedPackage;
// The parser stores options it doesn't recognize here. See above.
// |uninterpretedOptionArray| contains |GPBUninterpretedOption|
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray;

View File

@ -1229,6 +1229,7 @@ typedef struct GPBMethodDescriptorProto__storage_ {
@dynamic hasCcEnableArenas, ccEnableArenas;
@dynamic hasObjcClassPrefix, objcClassPrefix;
@dynamic hasCsharpNamespace, csharpNamespace;
@dynamic hasJavananoUseDeprecatedPackage, javananoUseDeprecatedPackage;
@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count;
typedef struct GPBFileOptions__storage_ {
@ -1241,6 +1242,7 @@ typedef struct GPBFileOptions__storage_ {
BOOL deprecated;
BOOL javaStringCheckUtf8;
BOOL ccEnableArenas;
BOOL javananoUseDeprecatedPackage;
GPBFileOptions_OptimizeMode optimizeFor;
NSString *javaPackage;
NSString *javaOuterClassname;
@ -1410,6 +1412,17 @@ typedef struct GPBFileOptions__storage_ {
.dataTypeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "javananoUseDeprecatedPackage",
.number = GPBFileOptions_FieldNumber_JavananoUseDeprecatedPackage,
.hasIndex = 14,
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
.offset = offsetof(GPBFileOptions__storage_, javananoUseDeprecatedPackage),
.defaultValue.valueBool = NO,
.dataTypeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "uninterpretedOptionArray",
.number = GPBFileOptions_FieldNumber_UninterpretedOptionArray,

View File

@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
// service Foo {
// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
// }
//
// The JSON representation for `Empty` is empty JSON object `{}`.
@interface GPBEmpty : GPBMessage
@end

View File

@ -44,6 +44,7 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
// Field masks also have a custom JSON encoding (see below).
//
// # Field Masks in Projections
//
// When used in the context of a projection, a response message or
// sub-message is filtered by the API to only contain those fields as
// specified in the mask. For example, if the mask in the previous
@ -89,6 +90,7 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
// behavior for APIs.
//
// # Field Masks in Update Operations
//
// A field mask in update operations specifies which fields of the
// targeted resource are going to be updated. The API is required
// to only change the values of the fields as specified in the mask
@ -116,11 +118,13 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
// required to be honored by the API.
//
// ## Considerations for HTTP REST
//
// The HTTP kind of an update operation which uses a field mask must
// be set to PATCH instead of PUT in order to satisfy HTTP semantics
// (PUT must only be used for full updates).
//
// # JSON Encoding of Field Masks
//
// In JSON, a field mask is encoded as a single string where paths are
// separated by a comma. Fields name in each path are converted
// to/from lower-camel naming conventions.

View File

@ -18,8 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBNullValue
// `NullValue` is a singleton enumeration to represent the null
// value for the `Value` type union.
// `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
typedef GPB_ENUM(GPBNullValue) {
GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
// Null value.
@ -53,6 +55,8 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) {
// scripting languages like JS a struct is represented as an
// object. The details of that representation are described together
// with the proto support for the language.
//
// The JSON representation for `Struct` is JSON object.
@interface GPBStruct : GPBMessage
// Map of dynamically typed values.
@ -87,8 +91,11 @@ typedef GPB_ENUM(GPBValue_Kind_OneOfCase) {
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of that
// variants, absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
@interface GPBValue : GPBMessage
// The kind of value.
@property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase;
// Represents a null value.
@ -123,6 +130,8 @@ typedef GPB_ENUM(GPBListValue_FieldNumber) {
};
// `ListValue` is a wrapper around a repeated field of values.
//
// The JSON representation for `ListValue` is JSON array.
@interface GPBListValue : GPBMessage
// Repeated field of dynamically typed values.

View File

@ -77,11 +77,12 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
// Example 5: Compute Timestamp from Python `datetime.datetime`.
//
// now = datetime.datetime.utcnow()
// seconds = int(time.mktime(now.timetuple()))
// nanos = now.microsecond * 1000
// Example 5: Compute Timestamp from current time in Python.
//
// now = time.time()
// seconds = int(now)
// nanos = int((now - seconds) * 10**9)
// timestamp = Timestamp(seconds=seconds, nanos=nanos)
@interface GPBTimestamp : GPBMessage

View File

@ -16,6 +16,22 @@ CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum GPBSyntax
// Syntax specifies the syntax in which a service element was defined.
typedef GPB_ENUM(GPBSyntax) {
GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
// Syntax "proto2"
GPBSyntax_SyntaxProto2 = 0,
// Syntax "proto3"
GPBSyntax_SyntaxProto3 = 1,
};
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void);
BOOL GPBSyntax_IsValidValue(int32_t value);
#pragma mark - Enum GPBField_Kind
// Kind represents a basic field type.
@ -51,6 +67,9 @@ typedef GPB_ENUM(GPBField_Kind) {
// Field type string.
GPBField_Kind_TypeString = 9,
// Field type group (deprecated proto2 type)
GPBField_Kind_TypeGroup = 10,
// Field type message.
GPBField_Kind_TypeMessage = 11,
@ -122,6 +141,7 @@ typedef GPB_ENUM(GPBType_FieldNumber) {
GPBType_FieldNumber_OneofsArray = 3,
GPBType_FieldNumber_OptionsArray = 4,
GPBType_FieldNumber_SourceContext = 5,
GPBType_FieldNumber_Syntax = 6,
};
// A light-weight descriptor for a proto message type.
@ -136,7 +156,6 @@ typedef GPB_ENUM(GPBType_FieldNumber) {
@property(nonatomic, readonly) NSUInteger fieldsArray_Count;
// The list of oneof definitions.
// The list of oneofs declared in this Type
// |oneofsArray| contains |NSString|
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofsArray;
@property(nonatomic, readonly) NSUInteger oneofsArray_Count;
@ -150,8 +169,14 @@ typedef GPB_ENUM(GPBType_FieldNumber) {
@property(nonatomic, readwrite) BOOL hasSourceContext;
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
// The source syntax.
@property(nonatomic, readwrite) GPBSyntax syntax;
@end
int32_t GPBType_Syntax_RawValue(GPBType *message);
void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value);
#pragma mark - GPBField
typedef GPB_ENUM(GPBField_FieldNumber) {
@ -163,6 +188,7 @@ typedef GPB_ENUM(GPBField_FieldNumber) {
GPBField_FieldNumber_OneofIndex = 7,
GPBField_FieldNumber_Packed = 8,
GPBField_FieldNumber_OptionsArray = 9,
GPBField_FieldNumber_JsonName = 10,
};
// Field represents a single field of a message type.
@ -195,6 +221,9 @@ typedef GPB_ENUM(GPBField_FieldNumber) {
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray;
@property(nonatomic, readonly) NSUInteger optionsArray_Count;
// The JSON name for this field.
@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
@end
int32_t GPBField_Kind_RawValue(GPBField *message);
@ -210,6 +239,7 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) {
GPBEnum_FieldNumber_EnumvalueArray = 2,
GPBEnum_FieldNumber_OptionsArray = 3,
GPBEnum_FieldNumber_SourceContext = 4,
GPBEnum_FieldNumber_Syntax = 5,
};
// Enum type definition.
@ -232,8 +262,14 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) {
@property(nonatomic, readwrite) BOOL hasSourceContext;
@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
// The source syntax.
@property(nonatomic, readwrite) GPBSyntax syntax;
@end
int32_t GPBEnum_Syntax_RawValue(GPBEnum *message);
void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value);
#pragma mark - GPBEnumValue
typedef GPB_ENUM(GPBEnumValue_FieldNumber) {

View File

@ -40,6 +40,33 @@ static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) {
return descriptor;
}
#pragma mark - Enum GPBSyntax
GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void) {
static GPBEnumDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageEnumValueDescription values[] = {
{ .name = "SyntaxProto2", .number = GPBSyntax_SyntaxProto2 },
{ .name = "SyntaxProto3", .number = GPBSyntax_SyntaxProto3 },
};
descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBSyntax)
values:values
valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
enumVerifier:GPBSyntax_IsValidValue];
}
return descriptor;
}
BOOL GPBSyntax_IsValidValue(int32_t value__) {
switch (value__) {
case GPBSyntax_SyntaxProto2:
case GPBSyntax_SyntaxProto3:
return YES;
default:
return NO;
}
}
#pragma mark - GPBType
@implementation GPBType
@ -49,9 +76,11 @@ static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) {
@dynamic oneofsArray, oneofsArray_Count;
@dynamic optionsArray, optionsArray_Count;
@dynamic hasSourceContext, sourceContext;
@dynamic syntax;
typedef struct GPBType__storage_ {
uint32_t _has_storage_[1];
GPBSyntax syntax;
NSString *name;
NSMutableArray *fieldsArray;
NSMutableArray *oneofsArray;
@ -120,6 +149,17 @@ typedef struct GPBType__storage_ {
.dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
.fieldOptions = NULL,
},
{
.name = "syntax",
.number = GPBType_FieldNumber_Syntax,
.hasIndex = 5,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.dataType = GPBDataTypeEnum,
.offset = offsetof(GPBType__storage_, syntax),
.defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBType class]
@ -143,6 +183,18 @@ typedef struct GPBType__storage_ {
@end
int32_t GPBType_Syntax_RawValue(GPBType *message) {
GPBDescriptor *descriptor = [GPBType descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBType_FieldNumber_Syntax];
return GPBGetMessageInt32Field(message, field);
}
void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value) {
GPBDescriptor *descriptor = [GPBType descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBType_FieldNumber_Syntax];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - GPBField
@implementation GPBField
@ -155,6 +207,7 @@ typedef struct GPBType__storage_ {
@dynamic oneofIndex;
@dynamic packed;
@dynamic optionsArray, optionsArray_Count;
@dynamic jsonName;
typedef struct GPBField__storage_ {
uint32_t _has_storage_[1];
@ -166,6 +219,7 @@ typedef struct GPBField__storage_ {
NSString *name;
NSString *typeURL;
NSMutableArray *optionsArray;
NSString *jsonName;
} GPBField__storage_;
// This method is threadsafe because it is initially called
@ -262,6 +316,17 @@ typedef struct GPBField__storage_ {
.dataTypeSpecific.className = GPBStringifySymbol(GPBOption),
.fieldOptions = NULL,
},
{
.name = "jsonName",
.number = GPBField_FieldNumber_JsonName,
.hasIndex = 8,
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
.offset = offsetof(GPBField__storage_, jsonName),
.defaultValue.valueString = nil,
.dataTypeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
static GPBMessageEnumDescription enums[] = {
{ .enumDescriptorFunc = GPBField_Kind_EnumDescriptor },
@ -335,6 +400,7 @@ GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void) {
{ .name = "TypeFixed32", .number = GPBField_Kind_TypeFixed32 },
{ .name = "TypeBool", .number = GPBField_Kind_TypeBool },
{ .name = "TypeString", .number = GPBField_Kind_TypeString },
{ .name = "TypeGroup", .number = GPBField_Kind_TypeGroup },
{ .name = "TypeMessage", .number = GPBField_Kind_TypeMessage },
{ .name = "TypeBytes", .number = GPBField_Kind_TypeBytes },
{ .name = "TypeUint32", .number = GPBField_Kind_TypeUint32 },
@ -364,6 +430,7 @@ BOOL GPBField_Kind_IsValidValue(int32_t value__) {
case GPBField_Kind_TypeFixed32:
case GPBField_Kind_TypeBool:
case GPBField_Kind_TypeString:
case GPBField_Kind_TypeGroup:
case GPBField_Kind_TypeMessage:
case GPBField_Kind_TypeBytes:
case GPBField_Kind_TypeUint32:
@ -417,9 +484,11 @@ BOOL GPBField_Cardinality_IsValidValue(int32_t value__) {
@dynamic enumvalueArray, enumvalueArray_Count;
@dynamic optionsArray, optionsArray_Count;
@dynamic hasSourceContext, sourceContext;
@dynamic syntax;
typedef struct GPBEnum__storage_ {
uint32_t _has_storage_[1];
GPBSyntax syntax;
NSString *name;
NSMutableArray *enumvalueArray;
NSMutableArray *optionsArray;
@ -476,6 +545,17 @@ typedef struct GPBEnum__storage_ {
.dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext),
.fieldOptions = NULL,
},
{
.name = "syntax",
.number = GPBEnum_FieldNumber_Syntax,
.hasIndex = 4,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.dataType = GPBDataTypeEnum,
.offset = offsetof(GPBEnum__storage_, syntax),
.defaultValue.valueEnum = GPBSyntax_SyntaxProto2,
.dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor,
.fieldOptions = NULL,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBEnum class]
@ -499,6 +579,18 @@ typedef struct GPBEnum__storage_ {
@end
int32_t GPBEnum_Syntax_RawValue(GPBEnum *message) {
GPBDescriptor *descriptor = [GPBEnum descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBEnum_FieldNumber_Syntax];
return GPBGetMessageInt32Field(message, field);
}
void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value) {
GPBDescriptor *descriptor = [GPBEnum descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBEnum_FieldNumber_Syntax];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - GPBEnumValue
@implementation GPBEnumValue

View File

@ -30,7 +30,9 @@ typedef GPB_ENUM(GPBDoubleValue_FieldNumber) {
GPBDoubleValue_FieldNumber_Value = 1,
};
// Wrapper message for double.
// Wrapper message for `double`.
//
// The JSON representation for `DoubleValue` is JSON number.
@interface GPBDoubleValue : GPBMessage
// The double value.
@ -44,7 +46,9 @@ typedef GPB_ENUM(GPBFloatValue_FieldNumber) {
GPBFloatValue_FieldNumber_Value = 1,
};
// Wrapper message for float.
// Wrapper message for `float`.
//
// The JSON representation for `FloatValue` is JSON number.
@interface GPBFloatValue : GPBMessage
// The float value.
@ -58,7 +62,9 @@ typedef GPB_ENUM(GPBInt64Value_FieldNumber) {
GPBInt64Value_FieldNumber_Value = 1,
};
// Wrapper message for int64.
// Wrapper message for `int64`.
//
// The JSON representation for `Int64Value` is JSON string.
@interface GPBInt64Value : GPBMessage
// The int64 value.
@ -72,7 +78,9 @@ typedef GPB_ENUM(GPBUInt64Value_FieldNumber) {
GPBUInt64Value_FieldNumber_Value = 1,
};
// Wrapper message for uint64.
// Wrapper message for `uint64`.
//
// The JSON representation for `UInt64Value` is JSON string.
@interface GPBUInt64Value : GPBMessage
// The uint64 value.
@ -86,7 +94,9 @@ typedef GPB_ENUM(GPBInt32Value_FieldNumber) {
GPBInt32Value_FieldNumber_Value = 1,
};
// Wrapper message for int32.
// Wrapper message for `int32`.
//
// The JSON representation for `Int32Value` is JSON number.
@interface GPBInt32Value : GPBMessage
// The int32 value.
@ -100,7 +110,9 @@ typedef GPB_ENUM(GPBUInt32Value_FieldNumber) {
GPBUInt32Value_FieldNumber_Value = 1,
};
// Wrapper message for uint32.
// Wrapper message for `uint32`.
//
// The JSON representation for `UInt32Value` is JSON number.
@interface GPBUInt32Value : GPBMessage
// The uint32 value.
@ -114,7 +126,9 @@ typedef GPB_ENUM(GPBBoolValue_FieldNumber) {
GPBBoolValue_FieldNumber_Value = 1,
};
// Wrapper message for bool.
// Wrapper message for `bool`.
//
// The JSON representation for `BoolValue` is JSON `true` and `false`.
@interface GPBBoolValue : GPBMessage
// The bool value.
@ -128,7 +142,9 @@ typedef GPB_ENUM(GPBStringValue_FieldNumber) {
GPBStringValue_FieldNumber_Value = 1,
};
// Wrapper message for string.
// Wrapper message for `string`.
//
// The JSON representation for `StringValue` is JSON string.
@interface GPBStringValue : GPBMessage
// The string value.
@ -142,7 +158,9 @@ typedef GPB_ENUM(GPBBytesValue_FieldNumber) {
GPBBytesValue_FieldNumber_Value = 1,
};
// Wrapper message for bytes.
// Wrapper message for `bytes`.
//
// The JSON representation for `BytesValue` is JSON string.
@interface GPBBytesValue : GPBMessage
// The bytes value.

View File

@ -44,6 +44,7 @@ option cc_generic_services = true; // auto-added
option java_generic_services = true; // auto-added
option py_generic_services = true; // auto-added
option cc_enable_arenas = false;
option objc_class_prefix = "NOARN";
import "google/protobuf/unittest_import.proto";
import "google/protobuf/unittest_arena.proto";