From b5a35b441107c40e53584cf655dd558a05f40e79 Mon Sep 17 00:00:00 2001 From: Sergio Campama Date: Thu, 3 Mar 2016 16:45:15 -0300 Subject: Adds more information to Objective C error when the expected objc_class_prefix option is missing. --- src/google/protobuf/compiler/objectivec/objectivec_helpers.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index 77a378c8..3e7ccb43 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -968,7 +968,8 @@ bool ValidateObjCClassPrefix(const FileDescriptor* file, } else { // ...it didn't match! *out_error = "error: Expected 'option objc_class_prefix = \"" + - package_match->second + "\";' in '" + file->name() + "'"; + package_match->second + "\";' for package '" + package + + "' in '" + file->name() + "'"; if (prefix.length()) { *out_error += "; but found '" + prefix + "' instead"; } -- cgit v1.2.3 From 513875da7770f4190fe7b1938638ded96c396c48 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 3 Mar 2016 14:08:54 -0800 Subject: Generate well-known types in Ruby extension and prune unneeded proto2 dependencies. --- ruby/Rakefile | 45 +++++++++++- ruby/tests/generated_code.rb | 74 ------------------- .../protobuf/compiler/ruby/ruby_generator.cc | 84 +++++++++++++++++++--- 3 files changed, 117 insertions(+), 86 deletions(-) delete mode 100644 ruby/tests/generated_code.rb (limited to 'src') diff --git a/ruby/Rakefile b/ruby/Rakefile index 81c3119e..8eb7a2df 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -34,6 +34,49 @@ else end end +well_known_protos = %w[ + google/protobuf/any.proto + google/protobuf/api.proto + google/protobuf/duration.proto + google/protobuf/empty.proto + google/protobuf/field_mask.proto + google/protobuf/source_context.proto + google/protobuf/struct.proto + google/protobuf/timestamp.proto + google/protobuf/type.proto + google/protobuf/wrappers.proto +] + +# These are omitted for now because we don't support proto2. +proto2_protos = %w[ + google/protobuf/descriptor.proto + google/protobuf/compiler/plugin.proto +] + +genproto_output = [] + +well_known_protos.each do |proto_file| + input_file = "../src/" + proto_file + output_file = "lib/" + proto_file.sub(/\.proto$/, ".rb") + genproto_output << output_file + file output_file => input_file do |file_task| + sh "../src/protoc -I../src --ruby_out=lib #{input_file}" + end +end + + +# Proto for tests. +genproto_output << "tests/generated_code.rb" +file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task| + sh "../src/protoc --ruby_out=. tests/generated_code.proto" +end + +task :genproto => genproto_output + +task :clean do + sh "rm -f #{genproto_output.join(' ')}" +end + Gem::PackageTask.new(spec) do |pkg| end @@ -41,7 +84,7 @@ Rake::TestTask.new(:test => :build) do |t| t.test_files = FileList["tests/*.rb"] end -task :build => [:clean, :compile] +task :build => [:clean, :compile, :genproto] task :default => [:build] # vim:sw=2:et diff --git a/ruby/tests/generated_code.rb b/ruby/tests/generated_code.rb deleted file mode 100644 index 5a685433..00000000 --- a/ruby/tests/generated_code.rb +++ /dev/null @@ -1,74 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: generated_code.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_message "A.B.C.TestMessage" do - optional :optional_int32, :int32, 1 - optional :optional_int64, :int64, 2 - optional :optional_uint32, :uint32, 3 - optional :optional_uint64, :uint64, 4 - optional :optional_bool, :bool, 5 - optional :optional_double, :double, 6 - optional :optional_float, :float, 7 - optional :optional_string, :string, 8 - optional :optional_bytes, :string, 9 - optional :optional_enum, :enum, 10, "A.B.C.TestEnum" - optional :optional_msg, :message, 11, "A.B.C.TestMessage" - repeated :repeated_int32, :int32, 21 - repeated :repeated_int64, :int64, 22 - repeated :repeated_uint32, :uint32, 23 - repeated :repeated_uint64, :uint64, 24 - repeated :repeated_bool, :bool, 25 - repeated :repeated_double, :double, 26 - repeated :repeated_float, :float, 27 - repeated :repeated_string, :string, 28 - repeated :repeated_bytes, :string, 29 - repeated :repeated_enum, :enum, 30, "A.B.C.TestEnum" - repeated :repeated_msg, :message, 31, "A.B.C.TestMessage" - map :map_int32_string, :int32, :string, 61 - map :map_int64_string, :int64, :string, 62 - map :map_uint32_string, :uint32, :string, 63 - map :map_uint64_string, :uint64, :string, 64 - map :map_bool_string, :bool, :string, 65 - map :map_string_string, :string, :string, 66 - map :map_string_msg, :string, :message, 67, "A.B.C.TestMessage" - map :map_string_enum, :string, :enum, 68, "A.B.C.TestEnum" - map :map_string_int32, :string, :int32, 69 - map :map_string_bool, :string, :bool, 70 - optional :nested_message, :message, 80, "A.B.C.TestMessage.NestedMessage" - oneof :my_oneof do - optional :oneof_int32, :int32, 41 - optional :oneof_int64, :int64, 42 - optional :oneof_uint32, :uint32, 43 - optional :oneof_uint64, :uint64, 44 - optional :oneof_bool, :bool, 45 - optional :oneof_double, :double, 46 - optional :oneof_float, :float, 47 - optional :oneof_string, :string, 48 - optional :oneof_bytes, :string, 49 - optional :oneof_enum, :enum, 50, "A.B.C.TestEnum" - optional :oneof_msg, :message, 51, "A.B.C.TestMessage" - end - end - add_message "A.B.C.TestMessage.NestedMessage" do - optional :foo, :int32, 1 - end - add_enum "A.B.C.TestEnum" do - value :Default, 0 - value :A, 1 - value :B, 2 - value :C, 3 - end -end - -module A - module B - module C - TestMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("A.B.C.TestMessage").msgclass - TestMessage::NestedMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("A.B.C.TestMessage.NestedMessage").msgclass - TestEnum = Google::Protobuf::DescriptorPool.generated_pool.lookup("A.B.C.TestEnum").enummodule - end - end -end diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index 9692f1bf..92c76fb0 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -75,6 +75,10 @@ std::string StripDotProto(const std::string& proto_file) { return proto_file.substr(0, lastindex); } +std::string GetOutputFilename(const std::string& proto_file) { + return StripDotProto(proto_file) + ".rb"; +} + std::string LabelForField(const google::protobuf::FieldDescriptor* field) { switch (field->label()) { case FieldDescriptor::LABEL_OPTIONAL: return "optional"; @@ -331,8 +335,69 @@ void EndPackageModules( } } -void GenerateFile(const google::protobuf::FileDescriptor* file, - google::protobuf::io::Printer* printer) { +bool UsesTypeFromFile(const Descriptor* message, const FileDescriptor* file, + string* error) { + for (int i = 0; i < message->field_count(); i++) { + const FieldDescriptor* field = message->field(i); + if ((field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + field->message_type()->file() == file) || + (field->type() == FieldDescriptor::TYPE_ENUM && + field->enum_type()->file() == file)) { + *error = "proto3 message field " + field->full_name() + " in file " + + file->name() + " has a dependency on a type from proto2 file " + + file->name() + + ". Ruby doesn't support proto2 yet, so we must fail."; + return true; + } + } + + for (int i = 0; i < message->nested_type_count(); i++) { + if (UsesTypeFromFile(message->nested_type(i), file, error)) { + return true; + } + } + + return false; +} + +// Ruby doesn't currently support proto2. This causes a failure even for proto3 +// files that import proto2. But in some cases, the proto2 file is only being +// imported to extend another proto2 message. The prime example is declaring +// custom options by extending FileOptions/FieldOptions/etc. +// +// If the proto3 messages don't have any proto2 submessages, it is safe to omit +// the dependency completely. Users won't be able to use any proto2 extensions, +// but they already couldn't because proto2 messages aren't supported. +// +// If/when we add proto2 support, we should remove this. +bool MaybeEmitDependency(const FileDescriptor* import, + const FileDescriptor* from, + io::Printer* printer, + string* error) { + if (import->syntax() == FileDescriptor::SYNTAX_PROTO2) { + for (int i = 0; i < from->message_type_count(); i++) { + if (UsesTypeFromFile(from->message_type(i), import, error)) { + // Error text was already set by UsesTypeFromFile(). + return false; + } + } + + // Ok to omit this proto2 dependency -- so we won't print anything. + GOOGLE_LOG(WARNING) << "Omitting proto2 dependency '" << import->name() + << "' from proto3 output file '" + << GetOutputFilename(from->name()) + << "' because we don't support proto2 and no proto2 " + "types from that file are being used."; + return true; + } else { + printer->Print( + "require '$name$'\n", "name", StripDotProto(import->name())); + return true; + } +} + +bool GenerateFile(const FileDescriptor* file, io::Printer* printer, + string* error) { printer->Print( "# Generated by the protocol buffer compiler. DO NOT EDIT!\n" "# source: $filename$\n" @@ -343,9 +408,9 @@ void GenerateFile(const google::protobuf::FileDescriptor* file, "require 'google/protobuf'\n\n"); for (int i = 0; i < file->dependency_count(); i++) { - const std::string& name = file->dependency(i)->name(); - printer->Print( - "require '$name$'\n", "name", StripDotProto(name)); + if (!MaybeEmitDependency(file->dependency(i), file, printer, error)) { + return false; + } } printer->Print( @@ -369,6 +434,7 @@ void GenerateFile(const google::protobuf::FileDescriptor* file, GenerateEnumAssignment("", file->enum_type(i), printer); } EndPackageModules(levels, printer); + return true; } bool Generator::Generate( @@ -384,15 +450,11 @@ bool Generator::Generate( return false; } - std::string filename = - StripDotProto(file->name()) + ".rb"; scoped_ptr output( - generator_context->Open(filename)); + generator_context->Open(GetOutputFilename(file->name()))); io::Printer printer(output.get(), '$'); - GenerateFile(file, &printer); - - return true; + return GenerateFile(file, &printer, error); } } // namespace ruby -- cgit v1.2.3 From 3cc35adb6dca9057a790d253b9f5e2b9b000a106 Mon Sep 17 00:00:00 2001 From: Antal Tátrai Date: Sat, 5 Mar 2016 09:32:59 +0100 Subject: Fix compiling clang/libc++ builds. (Issue: #1266) --- src/google/protobuf/map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index dfc62420..9dd42572 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -548,7 +548,7 @@ class Map { !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) template void construct(NodeType* p, Args&&... args) { - new (static_cast(p)) NodeType(std::forward(args)...); + new (const_cast(static_cast(p))) NodeType(std::forward(args)...); } template -- cgit v1.2.3 From 36650a07cf98ee4e734e07f2403fe5d20e300fc8 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Mon, 7 Mar 2016 12:07:03 -0500 Subject: HeaderDoc support in the library and generated sources - Convert most of the core library headers over to HeaderDoc format. - Switch the generated comments over to HeaderDoc. - Create GPBCodedOutputStream_PackagePrivate and move some things into there that should be more internal. --- objectivec/GPBCodedInputStream.h | 66 +- objectivec/GPBCodedOutputStream.h | 206 ++-- objectivec/GPBCodedOutputStream.m | 17 +- objectivec/GPBCodedOutputStream_PackagePrivate.h | 126 +++ objectivec/GPBDictionary.m | 2 +- objectivec/GPBExtensionInternals.m | 2 +- objectivec/GPBExtensionRegistry.h | 53 +- objectivec/GPBMessage.h | 227 ++++- objectivec/GPBMessage.m | 2 +- objectivec/GPBRootObject.h | 7 +- objectivec/GPBUnknownField.h | 33 +- objectivec/GPBUnknownField.m | 2 +- objectivec/GPBUnknownFieldSet.h | 17 +- objectivec/GPBUtilities.h | 150 ++- .../ProtocolBuffers_OSX.xcodeproj/project.pbxproj | 4 +- .../ProtocolBuffers_iOS.xcodeproj/project.pbxproj | 4 +- objectivec/Tests/GPBCodedOuputStreamTests.m | 21 +- objectivec/google/protobuf/Any.pbobjc.h | 116 +-- objectivec/google/protobuf/Api.pbobjc.h | 265 ++--- objectivec/google/protobuf/Descriptor.pbobjc.h | 1052 +++++++++++--------- objectivec/google/protobuf/Duration.pbobjc.h | 110 +- objectivec/google/protobuf/Empty.pbobjc.h | 32 +- objectivec/google/protobuf/FieldMask.pbobjc.h | 261 ++--- objectivec/google/protobuf/SourceContext.pbobjc.h | 22 +- objectivec/google/protobuf/Struct.pbobjc.h | 89 +- objectivec/google/protobuf/Timestamp.pbobjc.h | 134 +-- objectivec/google/protobuf/Type.pbobjc.h | 189 ++-- objectivec/google/protobuf/Wrappers.pbobjc.h | 86 +- .../compiler/objectivec/objectivec_enum.cc | 6 +- .../compiler/objectivec/objectivec_enum_field.cc | 5 + .../compiler/objectivec/objectivec_field.cc | 16 +- .../compiler/objectivec/objectivec_file.cc | 14 +- .../compiler/objectivec/objectivec_helpers.cc | 10 +- .../compiler/objectivec/objectivec_helpers.h | 1 + .../compiler/objectivec/objectivec_oneof.cc | 1 + 35 files changed, 1985 insertions(+), 1363 deletions(-) create mode 100644 objectivec/GPBCodedOutputStream_PackagePrivate.h (limited to 'src') diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h index 42a04941..06198883 100644 --- a/objectivec/GPBCodedInputStream.h +++ b/objectivec/GPBCodedInputStream.h @@ -35,52 +35,86 @@ NS_ASSUME_NONNULL_BEGIN -// Reads and decodes protocol message fields. -// Subclassing of GPBCodedInputStream is NOT supported. +/// Reads and decodes protocol message fields. +/// +/// The common uses of protocol buffers shouldn't need to use this class. +/// @c GPBMessage's provide a @c +parseFromData:error: and @c +/// +parseFromData:extensionRegistry:error: method that will decode a +/// message for you. +/// +/// @note Subclassing of GPBCodedInputStream is NOT supported. @interface GPBCodedInputStream : NSObject +/// Creates a new stream wrapping some data. + (instancetype)streamWithData:(NSData *)data; + +/// Initializes a stream wrapping some data. - (instancetype)initWithData:(NSData *)data; -// Attempt to read a field tag, returning zero if we have reached EOF. -// Protocol message parsers use this to read tags, since a protocol message -// may legally end wherever a tag occurs, and zero is not a valid tag number. +/// Attempt to read a field tag, returning zero if we have reached EOF. +/// Protocol message parsers use this to read tags, since a protocol message +/// may legally end wherever a tag occurs, and zero is not a valid tag number. - (int32_t)readTag; +/// Read and return a double. - (double)readDouble; +/// Read and return a float. - (float)readFloat; +/// Read and return a uint64. - (uint64_t)readUInt64; +/// Read and return a uint32. - (uint32_t)readUInt32; +/// Read and return an int64. - (int64_t)readInt64; +/// Read and return an int32. - (int32_t)readInt32; +/// Read and return a fixed64. - (uint64_t)readFixed64; +/// Read and return a fixed32. - (uint32_t)readFixed32; +/// Read and return an enum (int). - (int32_t)readEnum; +/// Read and return a sfixed32. - (int32_t)readSFixed32; +/// Read and return a sfixed64. - (int64_t)readSFixed64; +/// Read and return a sint32. - (int32_t)readSInt32; +/// Read and return a sint64. - (int64_t)readSInt64; +/// Read and return a boolean. - (BOOL)readBool; +/// Read and return a string. - (NSString *)readString; +/// Read and return length delimited data. - (NSData *)readBytes; -// Read an embedded message field value from the stream. +/// Read an embedded message field value from the stream. +/// +/// @param message The message to set fields on as they are read. +/// @param extensionRegistry An optional extension registry to use to lookup +/// extensions for @message. - (void)readMessage:(GPBMessage *)message - extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; + extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; -// Reads and discards a single field, given its tag value. Returns NO if the -// tag is an endgroup tag, in which case nothing is skipped. Otherwise, -// returns YES. +/// Reads and discards a single field, given its tag value. +/// +/// @param tag The tag number of the field to skip. +/// +/// @return NO if the tag is an endgroup tag (in which case nothing is skipped), +/// YES in all other cases. - (BOOL)skipField:(int32_t)tag; -// Reads and discards an entire message. This will read either until EOF -// or until an endgroup tag, whichever comes first. +/// Reads and discards an entire message. This will read either until EOF +/// or until an endgroup tag, whichever comes first. - (void)skipMessage; -// Verifies that the last call to readTag() returned the given tag value. -// This is used to verify that a nested group ended with the correct end tag. -// Throws NSParseErrorException if value does not match the last tag. -- (void)checkLastTagWas:(int32_t)value; +/// Verifies that the last call to @c -readTag returned the given tag value. +/// This is used to verify that a nested group ended with the correct end tag. +/// Throws @c NSParseErrorException if value does not match the last tag. +/// +/// @param expected The tag that was expected. +- (void)checkLastTagWas:(int32_t)expected; @end diff --git a/objectivec/GPBCodedOutputStream.h b/objectivec/GPBCodedOutputStream.h index 0a47f1c9..e67efd2d 100644 --- a/objectivec/GPBCodedOutputStream.h +++ b/objectivec/GPBCodedOutputStream.h @@ -46,36 +46,63 @@ NS_ASSUME_NONNULL_BEGIN +/// Writes out protocol message fields. +/// +/// The common uses of protocol buffers shouldn't need to use this class. +/// @c GPBMessage's provide a @c -data method that will serialize the message +/// for you. +/// +/// @note Subclassing of GPBCodedOutputStream is NOT supported. @interface GPBCodedOutputStream : NSObject -// Creates a new stream to write into data. Data must be sized to fit or it -// will error when it runs out of space. +/// Creates a stream to fill in the given data. Data must be sized to fit or +/// an error will be raised when out of space. + (instancetype)streamWithData:(NSMutableData *)data; + +/// Creates a stream to write into the given @c NSOutputStream. + (instancetype)streamWithOutputStream:(NSOutputStream *)output; -+ (instancetype)streamWithOutputStream:(NSOutputStream *)output - bufferSize:(size_t)bufferSize; +/// Initializes a stream to fill in the given data. Data must be sized to fit +/// or an error will be raised when out of space. - (instancetype)initWithData:(NSMutableData *)data; + +/// Initializes a stream to write into the given @c NSOutputStream. - (instancetype)initWithOutputStream:(NSOutputStream *)output; -- (instancetype)initWithOutputStream:(NSOutputStream *)output - bufferSize:(size_t)bufferSize; +/// Flush any buffered data out. - (void)flush; +/// Write the raw byte out. - (void)writeRawByte:(uint8_t)value; +/// Write the tag for the given field number and wire format. +/// +/// @param fieldNumber The field number. +/// @param format The wire format the data for the field will be in. - (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format; +/// Write a 32bit value out in little endian format. - (void)writeRawLittleEndian32:(int32_t)value; +/// Write a 64bit value out in little endian format. - (void)writeRawLittleEndian64:(int64_t)value; +/// Write a 32bit value out in varint format. - (void)writeRawVarint32:(int32_t)value; +/// Write a 64bit value out in varint format. - (void)writeRawVarint64:(int64_t)value; -// Note that this will truncate 64 bit values to 32. +/// Write a size_t out as a 32bit varint value. +/// +/// @note This will truncate 64 bit values to 32. - (void)writeRawVarintSizeTAs32:(size_t)value; +/// Writes the contents of an @c NSData out. - (void)writeRawData:(NSData *)data; +/// Writes out the given data. +/// +/// @param data The data blob to write out. +/// @param offset The offset into the blob to start writing out. +/// @param length The number of bytes from the blob to write out. - (void)writeRawPtr:(const void *)data offset:(size_t)offset length:(size_t)length; @@ -83,238 +110,213 @@ NS_ASSUME_NONNULL_BEGIN //%PDDM-EXPAND _WRITE_DECLS() // This block of code is generated, do not edit it directly. +/// Write a double for the given field number. - (void)writeDouble:(int32_t)fieldNumber value:(double)value; +/// Write a packaged array of double for the given field number. - (void)writeDoubleArray:(int32_t)fieldNumber values:(GPBDoubleArray *)values tag:(uint32_t)tag; +/// Write a double without any tag. - (void)writeDoubleNoTag:(double)value; +/// Write a float for the given field number. - (void)writeFloat:(int32_t)fieldNumber value:(float)value; +/// Write a packaged array of float for the given field number. - (void)writeFloatArray:(int32_t)fieldNumber values:(GPBFloatArray *)values tag:(uint32_t)tag; +/// Write a float without any tag. - (void)writeFloatNoTag:(float)value; +/// Write a uint64_t for the given field number. - (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value; +/// Write a packaged array of uint64_t for the given field number. - (void)writeUInt64Array:(int32_t)fieldNumber values:(GPBUInt64Array *)values tag:(uint32_t)tag; +/// Write a uint64_t without any tag. - (void)writeUInt64NoTag:(uint64_t)value; +/// Write a int64_t for the given field number. - (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value; +/// Write a packaged array of int64_t for the given field number. - (void)writeInt64Array:(int32_t)fieldNumber values:(GPBInt64Array *)values tag:(uint32_t)tag; +/// Write a int64_t without any tag. - (void)writeInt64NoTag:(int64_t)value; +/// Write a int32_t for the given field number. - (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value; +/// Write a packaged array of int32_t for the given field number. - (void)writeInt32Array:(int32_t)fieldNumber values:(GPBInt32Array *)values tag:(uint32_t)tag; +/// Write a int32_t without any tag. - (void)writeInt32NoTag:(int32_t)value; +/// Write a uint32_t for the given field number. - (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value; +/// Write a packaged array of uint32_t for the given field number. - (void)writeUInt32Array:(int32_t)fieldNumber values:(GPBUInt32Array *)values tag:(uint32_t)tag; +/// Write a uint32_t without any tag. - (void)writeUInt32NoTag:(uint32_t)value; +/// Write a uint64_t for the given field number. - (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value; +/// Write a packaged array of uint64_t for the given field number. - (void)writeFixed64Array:(int32_t)fieldNumber values:(GPBUInt64Array *)values tag:(uint32_t)tag; +/// Write a uint64_t without any tag. - (void)writeFixed64NoTag:(uint64_t)value; +/// Write a uint32_t for the given field number. - (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value; +/// Write a packaged array of uint32_t for the given field number. - (void)writeFixed32Array:(int32_t)fieldNumber values:(GPBUInt32Array *)values tag:(uint32_t)tag; +/// Write a uint32_t without any tag. - (void)writeFixed32NoTag:(uint32_t)value; +/// Write a int32_t for the given field number. - (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value; +/// Write a packaged array of int32_t for the given field number. - (void)writeSInt32Array:(int32_t)fieldNumber values:(GPBInt32Array *)values tag:(uint32_t)tag; +/// Write a int32_t without any tag. - (void)writeSInt32NoTag:(int32_t)value; +/// Write a int64_t for the given field number. - (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value; +/// Write a packaged array of int64_t for the given field number. - (void)writeSInt64Array:(int32_t)fieldNumber values:(GPBInt64Array *)values tag:(uint32_t)tag; +/// Write a int64_t without any tag. - (void)writeSInt64NoTag:(int64_t)value; +/// Write a int64_t for the given field number. - (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value; +/// Write a packaged array of int64_t for the given field number. - (void)writeSFixed64Array:(int32_t)fieldNumber values:(GPBInt64Array *)values tag:(uint32_t)tag; +/// Write a int64_t without any tag. - (void)writeSFixed64NoTag:(int64_t)value; +/// Write a int32_t for the given field number. - (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value; +/// Write a packaged array of int32_t for the given field number. - (void)writeSFixed32Array:(int32_t)fieldNumber values:(GPBInt32Array *)values tag:(uint32_t)tag; +/// Write a int32_t without any tag. - (void)writeSFixed32NoTag:(int32_t)value; +/// Write a BOOL for the given field number. - (void)writeBool:(int32_t)fieldNumber value:(BOOL)value; +/// Write a packaged array of BOOL for the given field number. - (void)writeBoolArray:(int32_t)fieldNumber values:(GPBBoolArray *)values tag:(uint32_t)tag; +/// Write a BOOL without any tag. - (void)writeBoolNoTag:(BOOL)value; +/// Write a int32_t for the given field number. - (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value; +/// Write a packaged array of int32_t for the given field number. - (void)writeEnumArray:(int32_t)fieldNumber values:(GPBEnumArray *)values tag:(uint32_t)tag; +/// Write a int32_t without any tag. - (void)writeEnumNoTag:(int32_t)value; +/// Write a NSString for the given field number. - (void)writeString:(int32_t)fieldNumber value:(NSString *)value; +/// Write an array of NSString for the given field number. - (void)writeStringArray:(int32_t)fieldNumber values:(NSArray *)values; +/// Write a NSString without any tag. - (void)writeStringNoTag:(NSString *)value; +/// Write a GPBMessage for the given field number. - (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value; +/// Write an array of GPBMessage for the given field number. - (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray *)values; +/// Write a GPBMessage without any tag. - (void)writeMessageNoTag:(GPBMessage *)value; +/// Write a NSData for the given field number. - (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value; +/// Write an array of NSData for the given field number. - (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray *)values; +/// Write a NSData without any tag. - (void)writeBytesNoTag:(NSData *)value; +/// Write a GPBMessage for the given field number. - (void)writeGroup:(int32_t)fieldNumber value:(GPBMessage *)value; +/// Write an array of GPBMessage for the given field number. - (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray *)values; +/// Write a GPBMessage without any tag (but does write the endGroup tag). - (void)writeGroupNoTag:(int32_t)fieldNumber value:(GPBMessage *)value; +/// Write a GPBUnknownFieldSet for the given field number. - (void)writeUnknownGroup:(int32_t)fieldNumber value:(GPBUnknownFieldSet *)value; +/// Write an array of GPBUnknownFieldSet for the given field number. - (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray *)values; +/// Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag). - (void)writeUnknownGroupNoTag:(int32_t)fieldNumber value:(GPBUnknownFieldSet *)value; //%PDDM-EXPAND-END _WRITE_DECLS() -// Write a MessageSet extension field to the stream. For historical reasons, -// the wire format differs from normal fields. +/// Write a MessageSet extension field to the stream. For historical reasons, +/// the wire format differs from normal fields. - (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value; -// Write an unparsed MessageSet extension field to the stream. For -// historical reasons, the wire format differs from normal fields. +/// Write an unparsed MessageSet extension field to the stream. For +/// historical reasons, the wire format differs from normal fields. - (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value; @end -CF_EXTERN_C_BEGIN - -size_t GPBComputeDoubleSize(int32_t fieldNumber, double value) - __attribute__((const)); -size_t GPBComputeFloatSize(int32_t fieldNumber, float value) - __attribute__((const)); -size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value) - __attribute__((const)); -size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value) - __attribute__((const)); -size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value) - __attribute__((const)); -size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value) - __attribute__((const)); -size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) - __attribute__((const)); -size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) - __attribute__((const)); -size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) - __attribute__((const)); -size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) - __attribute__((const)); -size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, - GPBUnknownFieldSet *value) - __attribute__((const)); -size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) - __attribute__((const)); -size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) - __attribute__((const)); -size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) - __attribute__((const)); -size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value) - __attribute__((const)); -size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value) - __attribute__((const)); -size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) - __attribute__((const)); -size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) - __attribute__((const)); -size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const)); -size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) - __attribute__((const)); - -size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const)); -size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const)); -size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const)); -size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const)); -size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const)); -size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const)); -size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const)); -size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const)); -size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const)); -size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const)); -size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) - __attribute__((const)); -size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const)); -size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const)); -size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const)); -size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const)); -size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const)); -size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const)); -size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const)); -size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const)); - -// Note that this will calculate the size of 64 bit values truncated to 32. -size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const)); - -size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const)); -size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const)); - -// Note that this will calculate the size of 64 bit values truncated to 32. -size_t GPBComputeRawVarint32SizeForInteger(NSInteger value) - __attribute__((const)); - -// Compute the number of bytes that would be needed to encode a -// MessageSet extension to the stream. For historical reasons, -// the wire format differs from normal fields. -size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value) - __attribute__((const)); - -// Compute the number of bytes that would be needed to encode an -// unparsed MessageSet extension field to the stream. For -// historical reasons, the wire format differs from normal fields. -size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value) - __attribute__((const)); - -size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) - __attribute__((const)); - -CF_EXTERN_C_END - NS_ASSUME_NONNULL_END // Write methods for types that can be in packed arrays. //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE) +//%/// Write a TYPE for the given field number. //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value; +//%/// Write a packaged array of TYPE for the given field number. //%- (void)write##NAME##Array:(int32_t)fieldNumber //% NAME$S values:(GPB##ARRAY_TYPE##Array *)values //% NAME$S tag:(uint32_t)tag; +//%/// Write a TYPE without any tag. //%- (void)write##NAME##NoTag:(TYPE)value; //% // Write methods for types that aren't in packed arrays. //%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE) +//%/// Write a TYPE for the given field number. //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value; +//%/// Write an array of TYPE for the given field number. //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values; +//%/// Write a TYPE without any tag. //%- (void)write##NAME##NoTag:(TYPE *)value; //% // Special write methods for Groups. //%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE) +//%/// Write a TYPE for the given field number. //%- (void)write##NAME:(int32_t)fieldNumber //% NAME$S value:(TYPE *)value; +//%/// Write an array of TYPE for the given field number. //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values; +//%/// Write a TYPE without any tag (but does write the endGroup tag). //%- (void)write##NAME##NoTag:(int32_t)fieldNumber //% NAME$S value:(TYPE *)value; //% diff --git a/objectivec/GPBCodedOutputStream.m b/objectivec/GPBCodedOutputStream.m index 70142e6f..fd9ed66c 100644 --- a/objectivec/GPBCodedOutputStream.m +++ b/objectivec/GPBCodedOutputStream.m @@ -28,7 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" #import @@ -178,12 +178,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, return [self initWithOutputStream:nil data:data]; } -- (instancetype)initWithOutputStream:(NSOutputStream *)output - bufferSize:(size_t)bufferSize { - NSMutableData *data = [NSMutableData dataWithLength:bufferSize]; - return [self initWithOutputStream:output data:data]; -} - // This initializer isn't exposed, but it is the designated initializer. // Setting OutputStream and NSData is to control the buffering behavior/size // of the work, but that is more obvious via the bufferSize: version. @@ -199,15 +193,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, return self; } -+ (instancetype)streamWithOutputStream:(NSOutputStream *)output - bufferSize:(size_t)bufferSize { - return [[[self alloc] initWithOutputStream:output - bufferSize:bufferSize] autorelease]; -} - + (instancetype)streamWithOutputStream:(NSOutputStream *)output { + NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE]; return [[[self alloc] initWithOutputStream:output - bufferSize:PAGE_SIZE] autorelease]; + data:data] autorelease]; } + (instancetype)streamWithData:(NSMutableData *)data { diff --git a/objectivec/GPBCodedOutputStream_PackagePrivate.h b/objectivec/GPBCodedOutputStream_PackagePrivate.h new file mode 100644 index 00000000..2e7bb4c4 --- /dev/null +++ b/objectivec/GPBCodedOutputStream_PackagePrivate.h @@ -0,0 +1,126 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2016 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBCodedOutputStream.h" + +NS_ASSUME_NONNULL_BEGIN + +CF_EXTERN_C_BEGIN + +size_t GPBComputeDoubleSize(int32_t fieldNumber, double value) + __attribute__((const)); +size_t GPBComputeFloatSize(int32_t fieldNumber, float value) + __attribute__((const)); +size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value) + __attribute__((const)); +size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value) + __attribute__((const)); +size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value) + __attribute__((const)); +size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value) + __attribute__((const)); +size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) + __attribute__((const)); +size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) + __attribute__((const)); +size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) + __attribute__((const)); +size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) + __attribute__((const)); +size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, + GPBUnknownFieldSet *value) + __attribute__((const)); +size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) + __attribute__((const)); +size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) + __attribute__((const)); +size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) + __attribute__((const)); +size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value) + __attribute__((const)); +size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value) + __attribute__((const)); +size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) + __attribute__((const)); +size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) + __attribute__((const)); +size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const)); +size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) + __attribute__((const)); + +size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const)); +size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const)); +size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const)); +size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const)); +size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const)); +size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const)); +size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const)); +size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const)); +size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const)); +size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) + __attribute__((const)); +size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const)); +size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const)); +size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const)); +size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const)); + +// Note that this will calculate the size of 64 bit values truncated to 32. +size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const)); + +size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const)); +size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const)); + +// Note that this will calculate the size of 64 bit values truncated to 32. +size_t GPBComputeRawVarint32SizeForInteger(NSInteger value) + __attribute__((const)); + +// Compute the number of bytes that would be needed to encode a +// MessageSet extension to the stream. For historical reasons, +// the wire format differs from normal fields. +size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value) + __attribute__((const)); + +// Compute the number of bytes that would be needed to encode an +// unparsed MessageSet extension field to the stream. For +// historical reasons, the wire format differs from normal fields. +size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value) + __attribute__((const)); + +size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) + __attribute__((const)); + +CF_EXTERN_C_END + +NS_ASSUME_NONNULL_END diff --git a/objectivec/GPBDictionary.m b/objectivec/GPBDictionary.m index 6baa2a18..3bd146e0 100644 --- a/objectivec/GPBDictionary.m +++ b/objectivec/GPBDictionary.m @@ -31,7 +31,7 @@ #import "GPBDictionary_PackagePrivate.h" #import "GPBCodedInputStream_PackagePrivate.h" -#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" #import "GPBDescriptor_PackagePrivate.h" #import "GPBMessage_PackagePrivate.h" #import "GPBUtilities_PackagePrivate.h" diff --git a/objectivec/GPBExtensionInternals.m b/objectivec/GPBExtensionInternals.m index 634c3369..7d0dcb2e 100644 --- a/objectivec/GPBExtensionInternals.m +++ b/objectivec/GPBExtensionInternals.m @@ -33,7 +33,7 @@ #import #import "GPBCodedInputStream_PackagePrivate.h" -#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" #import "GPBDescriptor_PackagePrivate.h" #import "GPBMessage_PackagePrivate.h" #import "GPBUtilities_PackagePrivate.h" diff --git a/objectivec/GPBExtensionRegistry.h b/objectivec/GPBExtensionRegistry.h index 0363c70a..08a6472a 100644 --- a/objectivec/GPBExtensionRegistry.h +++ b/objectivec/GPBExtensionRegistry.h @@ -35,30 +35,45 @@ NS_ASSUME_NONNULL_BEGIN -// A table of known extensions, searchable by name or field number. When -// parsing a protocol message that might have extensions, you must provide an -// ExtensionRegistry in which you have registered any extensions that you want -// to be able to parse. Otherwise, those extensions will just be treated like -// unknown fields. -// -// The *Root classes provide +extensionRegistry for the extensions defined in a -// given file *and* all files it imports. You can also create a -// GPBExtensionRegistry, and merge those registries to handle parsing extensions -// defined from non overlapping files. -// -// GPBExtensionRegistry *registry = -// [[[MyProtoFileRoot extensionRegistry] copy] autorelease]; -// [registry addExtension:[OtherMessage neededExtension]; // Not in MyProtoFile -// NSError *parseError = nil; -// MyMessage *msg = [MyMessage parseData:data -// extensionRegistry:registry -// error:&parseError]; -// +/// A table of known extensions, searchable by name or field number. When +/// parsing a protocol message that might have extensions, you must provide a +/// @c GPBExtensionRegistry in which you have registered any extensions that you +/// want to be able to parse. Otherwise, those extensions will just be treated +/// like unknown fields. +/// +/// The @c *Root classes provide @c +extensionRegistry for the extensions defined +/// in a given file *and* all files it imports. You can also create a +/// @c GPBExtensionRegistry, and merge those registries to handle parsing +/// extensions defined from non overlapping files. +/// +/// @code +/// GPBExtensionRegistry *registry = +/// [[[MyProtoFileRoot extensionRegistry] copy] autorelease]; +/// [registry addExtension:[OtherMessage neededExtension]; // Not in MyProtoFile +/// NSError *parseError = nil; +/// MyMessage *msg = [MyMessage parseData:data +/// extensionRegistry:registry +/// error:&parseError]; +/// @endcode @interface GPBExtensionRegistry : NSObject +/// Add the given @c GPBExtensionDescriptor to this registry. +/// +/// @param extension The extension description to add. - (void)addExtension:(GPBExtensionDescriptor *)extension; + +/// Adds all the extensions from another registry to this registry. +/// +/// @param registry The registry to merge into this registry. - (void)addExtensions:(GPBExtensionRegistry *)registry; +/// Looks for the extension registered for the given field number on a given +/// @c GPBDescriptor. +/// +/// @param descriptor The descriptor to look for a registered extension on. +/// @param fieldNumber The field number of an extension to look for. +/// +/// @return The registered @c GPBExtensionDescripto or nil if none was found. - (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor fieldNumber:(NSInteger)fieldNumber; diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h index 332393ed..58c42d02 100644 --- a/objectivec/GPBMessage.h +++ b/objectivec/GPBMessage.h @@ -44,23 +44,27 @@ NS_ASSUME_NONNULL_BEGIN CF_EXTERN_C_BEGIN -// NSError domain used for errors. +/// NSError domain used for errors. extern NSString *const GPBMessageErrorDomain; +/// Error code for NSError with GPBMessageErrorDomain. typedef NS_ENUM(NSInteger, GPBMessageErrorCode) { + /// The data being parsed is bad and a message can not be created from it. GPBMessageErrorCodeMalformedData = -100, + /// A message can't be serialized because it is missing required fields. GPBMessageErrorCodeMissingRequiredField = -101, }; -// In DEBUG ONLY, an NSException is thrown when a parsed message doesn't -// contain required fields. This key allows you to retrieve the parsed message -// from the exception's |userInfo| dictionary. #ifdef DEBUG +/// In DEBUG ONLY, an NSException is thrown when a parsed message doesn't +/// contain required fields. This key allows you to retrieve the parsed message +/// from the exception's @c userInfo dictionary. extern NSString *const GPBExceptionMessageKey; #endif // DEBUG CF_EXTERN_C_END +/// Base class for all of the generated message classes. @interface GPBMessage : NSObject // NOTE: If you add a instance method/property to this class that may conflict @@ -68,108 +72,235 @@ CF_EXTERN_C_END // The main cases are methods that take no arguments, or setFoo:/hasFoo: type // methods. +/// The unknown fields for this message. +/// +/// Only messages from proto files declared with "proto2" syntax support unknown +/// fields. For "proto3" syntax, any unknown fields found while parsing are +/// dropped. @property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields; -// Are all required fields in the message and all embedded messages set. +/// Are all required fields set in the message and all embedded messages. @property(nonatomic, readonly, getter=isInitialized) BOOL initialized; -// Returns an autoreleased instance. +/// Returns an autoreleased instance. + (instancetype)message; -// Create a message based on a variety of inputs. If there is a data parse -// error, nil is returned and if not NULL, errorPtr is filled in. -// NOTE: In DEBUG ONLY, the message is also checked for all required field, -// if one is missing, the parse will fail (returning nil, filling in errorPtr). +/// Creates a new instance by parsing the data. This method should be sent to +/// the generated message class that the data should be interpreted as. If +/// there is an error the method returns nil and the error is returned in +/// errorPtr (when provided). +/// +/// @note In DEBUG builds, the parsed message is checked to be sure all required +/// fields were provided, and the parse will fail if some are missing. +/// +/// @param data The data to parse. +/// @param errorPtr An optional error pointer to fill in with a failure reason if +/// the data can not be parsed. +/// +/// @return A new instance of the class messaged. + (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr; + +/// Creates a new instance by parsing the data. This method should be sent to +/// the generated message class that the data should be interpreted as. If +/// there is an error the method returns nil and the error is returned in +/// errorPtr (when provided). +/// +/// @note In DEBUG builds, the parsed message is checked to be sure all required +/// fields were provided, and the parse will fail if some are missing. +/// +/// @param data The data to parse. +/// @param extensionRegistry The extension registry to use to look up extensions. +/// @param errorPtr An optional error pointer to fill in with a failure +/// reason if the data can not be parsed. +/// +/// @return A new instance of the class messaged. + (instancetype)parseFromData:(NSData *)data extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry error:(NSError **)errorPtr; + +/// Creates a new instance by parsing the data from the given input stream. This +/// method should be sent to the generated message class that the data should +/// be interpreted as. If there is an error the method returns nil and the error +/// is returned in errorPtr (when provided). +/// +/// @note In DEBUG builds, the parsed message is checked to be sure all required +/// fields were provided, and the parse will fail if some are missing. +/// +/// @param input The stream to read data from. +/// @param extensionRegistry The extension registry to use to look up extensions. +/// @param errorPtr An optional error pointer to fill in with a failure +/// reason if the data can not be parsed. +/// +/// @return A new instance of the class messaged. + (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: (nullable GPBExtensionRegistry *)extensionRegistry error:(NSError **)errorPtr; -// Create a message based on delimited input. If there is a data parse -// error, nil is returned and if not NULL, errorPtr is filled in. +/// Creates a new instance by parsing the data from the given input stream. This +/// method should be sent to the generated message class that the data should +/// be interpreted as. If there is an error the method returns nil and the error +/// is returned in errorPtr (when provided). +/// +/// @note Unlike the parseFrom... methods, this never checks to see if all of +/// the required fields are set. So this method can be used to reload +/// messages that may not be complete. +/// +/// @param input The stream to read data from. +/// @param extensionRegistry The extension registry to use to look up extensions. +/// @param errorPtr An optional error pointer to fill in with a failure +/// reason if the data can not be parsed. +/// +/// @return A new instance of the class messaged. + (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: (nullable GPBExtensionRegistry *)extensionRegistry error:(NSError **)errorPtr; -// If there is a data parse error, nil is returned and if not NULL, errorPtr is -// filled in. -// NOTE: In DEBUG ONLY, the message is also checked for all required field, -// if one is missing, the parse will fail (returning nil, filling in errorPtr). +/// Initializes an instance by parsing the data. This method should be sent to +/// the generated message class that the data should be interpreted as. If +/// there is an error the method returns nil and the error is returned in +/// errorPtr (when provided). +/// +/// @note In DEBUG builds, the parsed message is checked to be sure all required +/// fields were provided, and the parse will fail if some are missing. +/// +/// @param data The data to parse. +/// @param errorPtr An optional error pointer to fill in with a failure reason if +/// the data can not be parsed. - (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr; + +/// Initializes an instance by parsing the data. This method should be sent to +/// the generated message class that the data should be interpreted as. If +/// there is an error the method returns nil and the error is returned in +/// errorPtr (when provided). +/// +/// @note In DEBUG builds, the parsed message is checked to be sure all required +/// fields were provided, and the parse will fail if some are missing. +/// +/// @param data The data to parse. +/// @param extensionRegistry The extension registry to use to look up extensions. +/// @param errorPtr An optional error pointer to fill in with a failure +/// reason if the data can not be parsed. - (instancetype)initWithData:(NSData *)data extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry error:(NSError **)errorPtr; + +/// Initializes an instance by parsing the data from the given input stream. This +/// method should be sent to the generated message class that the data should +/// be interpreted as. If there is an error the method returns nil and the error +/// is returned in errorPtr (when provided). +/// +/// @note Unlike the parseFrom... methods, this never checks to see if all of +/// the required fields are set. So this method can be used to reload +/// messages that may not be complete. +/// +/// @param input The stream to read data from. +/// @param extensionRegistry The extension registry to use to look up extensions. +/// @param errorPtr An optional error pointer to fill in with a failure +/// reason if the data can not be parsed. - (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: (nullable GPBExtensionRegistry *)extensionRegistry error:(NSError **)errorPtr; -// Serializes the message and writes it to output. +/// Writes out the message to the given output stream. - (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output; +/// Writes out the message to the given output stream. - (void)writeToOutputStream:(NSOutputStream *)output; -// Serializes the message and writes it to output, but writes the size of the -// message as a variant before writing the message. +/// Writes out a varint for the message size followed by the the message to +/// the given output stream. - (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output; +/// Writes out a varint for the message size followed by the the message to +/// the given output stream. - (void)writeDelimitedToOutputStream:(NSOutputStream *)output; -// Serializes the message to an NSData. Note that this value is not cached, so -// if you are using it repeatedly, cache it yourself. If there is an error -// while generating the data, nil is returned. -// NOTE: In DEBUG ONLY, the message is also checked for all required field, -// if one is missing, nil will be returned. +/// Serializes the message to a @c NSData. +/// +/// If there is an error while generating the data, nil is returned. +/// +/// @note This value is not cached, so if you are using it repeatedly, cache +/// it yourself. +/// +/// @note In DEBUG ONLY, the message is also checked for all required field, +/// if one is missing, nil will be returned. - (nullable NSData *)data; -// Same as -[data], except a delimiter is added to the start of the data -// indicating the size of the message data that follows. +/// Serializes a varint with the message size followed by the message data, +/// returning that as a @c NSData. +/// +/// @note This value is not cached, so if you are using it repeatedly, cache +/// it yourself. - (NSData *)delimitedData; -// Returns the size of the object if it were serialized. -// This is not a cached value. If you are following a pattern like this: -// size_t size = [aMsg serializedSize]; -// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; -// [foo writeSize:size]; -// [foo appendData:[aMsg data]]; -// you would be better doing: -// NSData *data = [aMsg data]; -// NSUInteger size = [aMsg length]; -// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; -// [foo writeSize:size]; -// [foo appendData:data]; +/// Calculates the size of the object if it were serialized. +/// +/// This is not a cached value. If you are following a pattern like this: +/// @code +/// size_t size = [aMsg serializedSize]; +/// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; +/// [foo writeSize:size]; +/// [foo appendData:[aMsg data]]; +/// @endcode +/// you would be better doing: +/// @code +/// NSData *data = [aMsg data]; +/// NSUInteger size = [aMsg length]; +/// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; +/// [foo writeSize:size]; +/// [foo appendData:data]; +/// @endcode - (size_t)serializedSize; -// Return the descriptor for the message +/// Return the descriptor for the message class. + (GPBDescriptor *)descriptor; +/// Return the descriptor for the message. - (GPBDescriptor *)descriptor; -// Extensions use boxed values (NSNumbers) for PODs, NSMutableArrays for -// repeated. If the extension is a Message one will be auto created for you -// and returned similar to fields. +/// Test to see if the given extension is set on the message. - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension; + +/// Fetches the given extension's value for this message. +/// +/// Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for +/// repeated fields. If the extension is a Message one will be auto created for you +/// and returned similar to fields. - (nullable id)getExtension:(GPBExtensionDescriptor *)extension; + +/// Sets the given extension's value for this message. This is only for single +/// field extensions (i.e. - not repeated fields). +/// +/// Extensions use boxed values (@c NSNumbers). - (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value; + +/// Adds the given value to the extension for this message. This is only for +/// repeated field extensions. If the field is a repeated POD type the @c value +/// is a @c NSNumber. - (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value; + +/// Replaces the given value at an index for the extension on this message. This +/// is only for repeated field extensions. If the field is a repeated POD type +/// the @c value is a @c NSNumber. - (void)setExtension:(GPBExtensionDescriptor *)extension index:(NSUInteger)index value:(id)value; + +/// Clears the given extension for this message. - (void)clearExtension:(GPBExtensionDescriptor *)extension; -// Resets all fields to their default values. +/// Resets all of the fields of this message to their default values. - (void)clear; -// Parses a message of this type from the input and merges it with this -// message. -// NOTE: This will throw if there is an error parsing the data. +/// Parses a message of this type from the input and merges it with this +/// message. +/// +/// @note This will throw if there is an error parsing the data. - (void)mergeFromData:(NSData *)data extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; -// Merges the fields from another message (of the same type) into this -// message. +/// Merges the fields from another message (of the same type) into this +/// message. - (void)mergeFrom:(GPBMessage *)other; @end diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index fdb695ec..d5e8d37b 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -35,7 +35,7 @@ #import "GPBArray_PackagePrivate.h" #import "GPBCodedInputStream_PackagePrivate.h" -#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" #import "GPBDescriptor_PackagePrivate.h" #import "GPBDictionary_PackagePrivate.h" #import "GPBExtensionInternals.h" diff --git a/objectivec/GPBRootObject.h b/objectivec/GPBRootObject.h index e2af5d97..c05b5c62 100644 --- a/objectivec/GPBRootObject.h +++ b/objectivec/GPBRootObject.h @@ -34,11 +34,12 @@ NS_ASSUME_NONNULL_BEGIN -// All Root Objects derive from GPBRootObject. It supplies a registry -// for derived classes to register their extensions to. +/// Every generated proto file defines a local "Root" class that exposes a +/// @c GPBExtensionRegistry for all the extensions defined by that file and +/// the files it depends on. @interface GPBRootObject : NSObject -// Per class registry. +/// An extension registry for the given file and all the files it depends on. + (GPBExtensionRegistry *)extensionRegistry; @end diff --git a/objectivec/GPBUnknownField.h b/objectivec/GPBUnknownField.h index 43709ee5..0f301e47 100644 --- a/objectivec/GPBUnknownField.h +++ b/objectivec/GPBUnknownField.h @@ -37,22 +37,51 @@ NS_ASSUME_NONNULL_BEGIN +/// Store an unknown field. These are used in conjunction with @c GPBUnknownFieldSet @interface GPBUnknownField : NSObject +/// The field number the data is stored under. @property(nonatomic, readonly, assign) int32_t number; -// Only one of these will be set. +/// An array of varint values for this field. @property(nonatomic, readonly, strong) GPBUInt64Array *varintList; + +/// An array of fixed32 values for this field. @property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List; + +/// An array of fixed64 values for this field. @property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List; + +/// An array of data values for this field. @property(nonatomic, readonly, strong) NSArray *lengthDelimitedList; + +/// An array of groups of values for this field. @property(nonatomic, readonly, strong) NSArray *groupList; -// Only one of these should be used per Field. + +/// Add a value to the varintList. +/// +/// @param value The value to add. - (void)addVarint:(uint64_t)value; + +/// Add a value to the fixed32List. +/// +/// @param value The value to add. - (void)addFixed32:(uint32_t)value; + +/// Add a value to the fixed64List. +/// +/// @param value The value to add. - (void)addFixed64:(uint64_t)value; + +/// Add a value to the lengthDelimitedList. +/// +/// @param value The value to add. - (void)addLengthDelimited:(NSData *)value; + +/// Add a value to the groupList. +/// +/// @param value The value to add. - (void)addGroup:(GPBUnknownFieldSet *)value; @end diff --git a/objectivec/GPBUnknownField.m b/objectivec/GPBUnknownField.m index 22ed66a4..0e29bde5 100644 --- a/objectivec/GPBUnknownField.m +++ b/objectivec/GPBUnknownField.m @@ -31,7 +31,7 @@ #import "GPBUnknownField_PackagePrivate.h" #import "GPBArray.h" -#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" @implementation GPBUnknownField { @protected diff --git a/objectivec/GPBUnknownFieldSet.h b/objectivec/GPBUnknownFieldSet.h index 8db0132a..cf612993 100644 --- a/objectivec/GPBUnknownFieldSet.h +++ b/objectivec/GPBUnknownFieldSet.h @@ -34,15 +34,30 @@ NS_ASSUME_NONNULL_BEGIN +/// A collection of unknown fields. @interface GPBUnknownFieldSet : NSObject +/// Tests to see if the given field number has a value. +/// +/// @param number The field number to check. +/// +/// @return YES if there is an unknown field for the given field number. - (BOOL)hasField:(int32_t)number; + +/// Fetches the @c GPBUnknownField for the given field number. +/// +/// @param number The field number to look up. +/// +/// @return The @c GPBUnknownField or nil. - (nullable GPBUnknownField *)getField:(int32_t)number; + +/// Returns the number of fields in this set. - (NSUInteger)countOfFields; +/// Adds the given field to the set. - (void)addField:(GPBUnknownField *)field; -// Returns an NSArray of the GPBUnknownFields sorted by the field numbers. +/// Returns an NSArray of the @c GPBUnknownFields sorted by the field numbers. - (NSArray *)sortedFields; @end diff --git a/objectivec/GPBUtilities.h b/objectivec/GPBUtilities.h index 5b55104b..b7209324 100644 --- a/objectivec/GPBUtilities.h +++ b/objectivec/GPBUtilities.h @@ -38,24 +38,34 @@ CF_EXTERN_C_BEGIN NS_ASSUME_NONNULL_BEGIN -// Generates a string that should be a valid "Text Format" for the C++ version -// of Protocol Buffers. lineIndent can be nil if no additional line indent is -// needed. The comments provide the names according to the ObjC library, they -// most likely won't exactly match the original .proto file. +/// Generates a string that should be a valid "Text Format" for the C++ version +/// of Protocol Buffers. +/// +/// @param message The message to generate from. +/// @param lineIndent A string to use as the prefix for all lines generated. Can +/// be nil if no extra indent is needed. +/// +/// @return A @c NSString with the Text Format of the message. NSString *GPBTextFormatForMessage(GPBMessage *message, NSString * __nullable lineIndent); + +/// Generates a string that should be a valid "Text Format" for the C++ version +/// of Protocol Buffers. +/// +/// @param unknownSet The unknown field set to generate from. +/// @param lineIndent A string to use as the prefix for all lines generated. Can +/// be nil if no extra indent is needed. +/// +/// @return A @c NSString with the Text Format of the unknown field set. NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet, NSString * __nullable lineIndent); -// -// Test if the given field is set on a message. -// +/// Test if the given field is set on a message. BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber); +/// Test if the given field is set on a message. BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field); -// -// Clear the given field of a message. -// +/// Clear the given field of a message. void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field); //%PDDM-EXPAND GPB_ACCESSORS() @@ -68,60 +78,100 @@ void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field); // Single Fields +/// Gets the value of a bytes field. NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a bytes field. void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value); +/// Gets the value of a string field. NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a string field. void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value); +/// Gets the value of a message field. GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a message field. void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value); +/// Gets the value of a group field. GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a group field. void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value); +/// Gets the value of a bool field. BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a bool field. void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value); +/// Gets the value of an int32 field. int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of an int32 field. void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); +/// Gets the value of an uint32 field. uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of an uint32 field. void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value); +/// Gets the value of an int64 field. int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of an int64 field. void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value); +/// Gets the value of an uint64 field. uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of an uint64 field. void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value); +/// Gets the value of a float field. float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a float field. void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value); +/// Gets the value of a double field. double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a double field. void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value); -// Get/Set the given enum field of a message. You can only Set values that are -// members of the enum. For proto3, when doing a Get, if the value isn't a -// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The -// the functions with "Raw" in the will bypass all checks. +/// Get the given enum field of a message. For proto3, if the value isn't a +/// member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned. +/// GPBGetMessageRawEnumField will bypass the check and return whatever value +/// was set. int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field); +/// Set the given enum field of a message. You can only set values that are +/// members of the enum. void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); +/// Get the given enum field of a message. No check is done to ensure the value +/// was defined in the enum. int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field); +/// Set the given enum field of a message. You can set the value to anything, +/// even a value that is not a member of the enum. void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); // Repeated Fields -// The object will/should be GPB*Array or NSMutableArray based on the field's -// type. +/// Gets the value of a repeated field. +/// +/// The result will be @c GPB*Array or @c NSMutableArray based on the +/// field's type. id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a repeated field. +/// +/// The value should be @c GPB*Array or @c NSMutableArray based on the +/// field's type. void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array); // Map Fields -// The object will/should be GPB*Dictionary or NSMutableDictionary based on the -// field's type. +/// Gets the value of a map<> field. +/// +/// The result will be @c GPB*Dictionary or @c NSMutableDictionary based on +/// the field's type. id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field); +/// Sets the value of a map<> field. +/// +/// The object should be @c GPB*Dictionary or @c NSMutableDictionary based +/// on the field's type. void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary); //%PDDM-EXPAND-END GPB_ACCESSORS() @@ -144,44 +194,64 @@ CF_EXTERN_C_END //% //%// Single Fields //% -//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, *) -//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, *) -//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, *) -//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, *) -//%GPB_ACCESSOR_SINGLE(Bool, BOOL) -//%GPB_ACCESSOR_SINGLE(Int32, int32_t) -//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t) -//%GPB_ACCESSOR_SINGLE(Int64, int64_t) -//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t) -//%GPB_ACCESSOR_SINGLE(Float, float) -//%GPB_ACCESSOR_SINGLE(Double, double) -//%// Get/Set the given enum field of a message. You can only Set values that are -//%// members of the enum. For proto3, when doing a Get, if the value isn't a -//%// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The -//%// the functions with "Raw" in the will bypass all checks. +//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *) +//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *) +//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *) +//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *) +//%GPB_ACCESSOR_SINGLE(Bool, BOOL, ) +//%GPB_ACCESSOR_SINGLE(Int32, int32_t, n) +//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n) +//%GPB_ACCESSOR_SINGLE(Int64, int64_t, n) +//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n) +//%GPB_ACCESSOR_SINGLE(Float, float, ) +//%GPB_ACCESSOR_SINGLE(Double, double, ) +//%/// Get the given enum field of a message. For proto3, if the value isn't a +//%/// member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned. +//%/// GPBGetMessageRawEnumField will bypass the check and return whatever value +//%/// was set. //%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field); +//%/// Set the given enum field of a message. You can only set values that are +//%/// members of the enum. //%void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); +//%/// Get the given enum field of a message. No check is done to ensure the value +//%/// was defined in the enum. //%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field); +//%/// Set the given enum field of a message. You can set the value to anything, +//%/// even a value that is not a member of the enum. //%void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); //% //%// Repeated Fields //% -//%// The object will/should be GPB*Array or NSMutableArray based on the field's -//%// type. +//%/// Gets the value of a repeated field. +//%/// +//%/// The result will be @c GPB*Array or @c NSMutableArray based on the +//%/// field's type. //%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field); +//%/// Sets the value of a repeated field. +//%/// +//%/// The value should be @c GPB*Array or @c NSMutableArray based on the +//%/// field's type. //%void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array); //% //%// Map Fields //% -//%// The object will/should be GPB*Dictionary or NSMutableDictionary based on the -//%// field's type. +//%/// Gets the value of a map<> field. +//%/// +//%/// The result will be @c GPB*Dictionary or @c NSMutableDictionary based on +//%/// the field's type. //%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field); +//%/// Sets the value of a map<> field. +//%/// +//%/// The object should be @c GPB*Dictionary or @c NSMutableDictionary based +//%/// on the field's type. //%void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary); //% -//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE) -//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, ) -//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, TisP) +//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN) +//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, ) +//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP) +//%/// Gets the value of a##AN NAME$L field. //%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field); +//%/// Sets the value of a##AN NAME$L field. //%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value); //% diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj index 6b34b9bf..78c3f9ba 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj @@ -188,6 +188,7 @@ F4487C7C1AAE06AC00531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = ""; }; F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = ""; }; F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = ""; }; + F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = ""; }; F451D3F51A8AAE8700B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = ""; }; F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = ""; }; F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = ""; }; @@ -368,9 +369,10 @@ 7461B4860F94F96B00A0C422 /* IO */ = { isa = PBXGroup; children = ( - 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */, 51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */, + 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */, 7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */, + F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */, 7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */, 7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */, 7461B4E70F94F99000A0C422 /* GPBWireFormat.h */, diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj index e9d3fc95..5d96c05f 100644 --- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj @@ -209,6 +209,7 @@ F4487C7D1AAE06C500531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = ""; }; F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = ""; }; F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = ""; }; + F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = ""; }; F451D3F61A8AAEA600B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = ""; }; F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = ""; }; F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = ""; }; @@ -405,9 +406,10 @@ 7461B4860F94F96B00A0C422 /* IO */ = { isa = PBXGroup; children = ( - 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */, 51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */, + 7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */, 7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */, + F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */, 7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */, 7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */, 7461B4E70F94F99000A0C422 /* GPBWireFormat.h */, diff --git a/objectivec/Tests/GPBCodedOuputStreamTests.m b/objectivec/Tests/GPBCodedOuputStreamTests.m index 77d88033..0723b645 100644 --- a/objectivec/Tests/GPBCodedOuputStreamTests.m +++ b/objectivec/Tests/GPBCodedOuputStreamTests.m @@ -30,11 +30,30 @@ #import "GPBTestUtilities.h" -#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" #import "GPBCodedInputStream.h" #import "GPBUtilities_PackagePrivate.h" #import "google/protobuf/Unittest.pbobjc.h" +@interface GPBCodedOutputStream (InternalMethods) +// Declared in the .m file, expose for testing. +- (instancetype)initWithOutputStream:(NSOutputStream *)output + data:(NSMutableData *)data; +@end + +@interface GPBCodedOutputStream (Helper) ++ (instancetype)streamWithOutputStream:(NSOutputStream *)output + bufferSize:(size_t)bufferSize; +@end + +@implementation GPBCodedOutputStream (Helper) ++ (instancetype)streamWithOutputStream:(NSOutputStream *)output + bufferSize:(size_t)bufferSize { + NSMutableData *data = [NSMutableData dataWithLength:bufferSize]; + return [[[self alloc] initWithOutputStream:output data:data] autorelease]; +} +@end + @interface CodedOutputStreamTests : GPBTestCase @end diff --git a/objectivec/google/protobuf/Any.pbobjc.h b/objectivec/google/protobuf/Any.pbobjc.h index 9866b5b1..a204ae9a 100644 --- a/objectivec/google/protobuf/Any.pbobjc.h +++ b/objectivec/google/protobuf/Any.pbobjc.h @@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBAnyRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBAnyRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBAny @@ -31,61 +33,61 @@ typedef GPB_ENUM(GPBAny_FieldNumber) { GPBAny_FieldNumber_Value = 2, }; -// `Any` contains an arbitrary serialized message along with a URL -// that describes the type of the serialized message. -// -// -// 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: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } +/// `Any` contains an arbitrary serialized message along with a URL +/// that describes the type of the serialized message. +/// +/// +/// 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: +/// +/// package google.profile; +/// message Person { +/// string first_name = 1; +/// string last_name = 2; +/// } +/// +/// { +/// "\@type": "type.googleapis.com/google.profile.Person", +/// "firstName": , +/// "lastName": +/// } +/// +/// If the embedded message type is well-known and has a custom JSON +/// representation, that representation will be embedded adding a field +/// `value` which holds the custom JSON in addition to the `\@type` +/// field. Example (for message [google.protobuf.Duration][]): +/// +/// { +/// "\@type": "type.googleapis.com/google.protobuf.Duration", +/// "value": "1.212s" +/// } @interface GPBAny : GPBMessage -// A URL/resource name whose content describes the type of the -// serialized message. -// -// For URLs which use the schema `http`, `https`, or no schema, the -// following restrictions and interpretations apply: -// -// * If no schema is provided, `https` is assumed. -// * The last segment of the URL's path must represent the fully -// qualified name of the type (as in `path/google.protobuf.Duration`). -// * An HTTP GET on the URL must yield a [google.protobuf.Type][] -// value in binary format, or produce an error. -// * Applications are allowed to cache lookup results based on the -// URL, or have them precompiled into a binary to avoid any -// lookup. Therefore, binary compatibility needs to be preserved -// on changes to types. (Use versioned type names to manage -// breaking changes.) -// -// Schemas other than `http`, `https` (or the empty schema) might be -// used with implementation specific semantics. +/// A URL/resource name whose content describes the type of the +/// serialized message. +/// +/// For URLs which use the schema `http`, `https`, or no schema, the +/// following restrictions and interpretations apply: +/// +/// * If no schema is provided, `https` is assumed. +/// * The last segment of the URL's path must represent the fully +/// qualified name of the type (as in `path/google.protobuf.Duration`). +/// * An HTTP GET on the URL must yield a [google.protobuf.Type][] +/// value in binary format, or produce an error. +/// * Applications are allowed to cache lookup results based on the +/// URL, or have them precompiled into a binary to avoid any +/// lookup. Therefore, binary compatibility needs to be preserved +/// on changes to types. (Use versioned type names to manage +/// breaking changes.) +/// +/// Schemas other than `http`, `https` (or the empty schema) might be +/// used with implementation specific semantics. @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL; -// Must be valid serialized data of the above specified type. +/// Must be valid serialized data of the above specified type. @property(nonatomic, readwrite, copy, null_resettable) NSData *value; @end diff --git a/objectivec/google/protobuf/Api.pbobjc.h b/objectivec/google/protobuf/Api.pbobjc.h index 8d82b15f..271a166f 100644 --- a/objectivec/google/protobuf/Api.pbobjc.h +++ b/objectivec/google/protobuf/Api.pbobjc.h @@ -21,13 +21,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBApiRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBApiRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBApi @@ -42,58 +44,67 @@ typedef GPB_ENUM(GPBApi_FieldNumber) { GPBApi_FieldNumber_Syntax = 7, }; -// Api is a light-weight descriptor for a protocol buffer service. +/// Api is a light-weight descriptor for a protocol buffer service. @interface GPBApi : GPBMessage -// The fully qualified name of this api, including package name -// followed by the api's simple name. +/// The fully qualified name of this api, including package name +/// followed by the api's simple name. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// The methods of this api, in unspecified order. +/// The methods of this api, in unspecified order. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodsArray; +/// The number of items in @c methodsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger methodsArray_Count; -// Any metadata attached to the API. +/// Any metadata attached to the API. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/// The number of items in @c optionsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger optionsArray_Count; -// A version string for this api. If specified, must have the form -// `major-version.minor-version`, as in `1.10`. If the minor version -// is omitted, it defaults to zero. If the entire version field is -// empty, the major version is derived from the package name, as -// outlined below. If the field is not empty, the version in the -// package name will be verified to be consistent with what is -// provided here. -// -// The versioning schema uses [semantic -// versioning](http://semver.org) where the major version number -// indicates a breaking change and the minor version an additive, -// non-breaking change. Both version numbers are signals to users -// what to expect from different versions, and should be carefully -// chosen based on the product plan. -// -// The major version is also reflected in the package name of the -// API, which must end in `v`, as in -// `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. +/// A version string for this api. If specified, must have the form +/// `major-version.minor-version`, as in `1.10`. If the minor version +/// is omitted, it defaults to zero. If the entire version field is +/// empty, the major version is derived from the package name, as +/// outlined below. If the field is not empty, the version in the +/// package name will be verified to be consistent with what is +/// provided here. +/// +/// The versioning schema uses [semantic +/// versioning](http://semver.org) where the major version number +/// indicates a breaking change and the minor version an additive, +/// non-breaking change. Both version numbers are signals to users +/// what to expect from different versions, and should be carefully +/// chosen based on the product plan. +/// +/// The major version is also reflected in the package name of the +/// API, which must end in `v`, as in +/// `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. @property(nonatomic, readwrite, copy, null_resettable) NSString *version; -// Source context for the protocol buffer service represented by this -// message. -@property(nonatomic, readwrite) BOOL hasSourceContext; +/// Source context for the protocol buffer service represented by this +/// message. @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext; +/// Test to see if @c sourceContext has been set. +@property(nonatomic, readwrite) BOOL hasSourceContext; -// Included APIs. See [Mixin][]. +/// Included APIs. See [Mixin][]. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *mixinsArray; +/// The number of items in @c mixinsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger mixinsArray_Count; -// The source syntax of the service. +/// The source syntax of the service. @property(nonatomic, readwrite) enum GPBSyntax syntax; @end +/// Fetches the raw value of a @c GPBApi's @c syntax property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBApi_Syntax_RawValue(GPBApi *message); +/// Sets the raw value of an @c GPBApi's @c syntax property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value); #pragma mark - GPBMethod @@ -108,34 +119,40 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) { GPBMethod_FieldNumber_Syntax = 7, }; -// Method represents a method of an api. +/// Method represents a method of an api. @interface GPBMethod : GPBMessage -// The simple name of this method. +/// The simple name of this method. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// A URL of the input message type. +/// A URL of the input message type. @property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL; -// If true, the request is streamed. +/// If true, the request is streamed. @property(nonatomic, readwrite) BOOL requestStreaming; -// The URL of the output message type. +/// The URL of the output message type. @property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL; -// If true, the response is streamed. +/// If true, the response is streamed. @property(nonatomic, readwrite) BOOL responseStreaming; -// Any metadata attached to the method. +/// Any metadata attached to the method. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/// The number of items in @c optionsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger optionsArray_Count; -// The source syntax of this method. +/// The source syntax of this method. @property(nonatomic, readwrite) enum GPBSyntax syntax; @end +/// Fetches the raw value of a @c GPBMethod's @c syntax property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBMethod_Syntax_RawValue(GPBMethod *message); +/// Sets the raw value of an @c GPBMethod's @c syntax property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value); #pragma mark - GPBMixin @@ -145,90 +162,90 @@ typedef GPB_ENUM(GPBMixin_FieldNumber) { 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 { -// 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"; -// } -// ... -// } +/// 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 { +/// 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. +/// 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. +/// If non-empty specifies a path under which inherited HTTP paths +/// are rooted. @property(nonatomic, readwrite, copy, null_resettable) NSString *root; @end diff --git a/objectivec/google/protobuf/Descriptor.pbobjc.h b/objectivec/google/protobuf/Descriptor.pbobjc.h index 2ab20243..109711c7 100644 --- a/objectivec/google/protobuf/Descriptor.pbobjc.h +++ b/objectivec/google/protobuf/Descriptor.pbobjc.h @@ -39,85 +39,91 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Enum GPBFieldDescriptorProto_Type typedef GPB_ENUM(GPBFieldDescriptorProto_Type) { - // 0 is reserved for errors. - // Order is weird for historical reasons. + /// 0 is reserved for errors. + /// Order is weird for historical reasons. GPBFieldDescriptorProto_Type_TypeDouble = 1, GPBFieldDescriptorProto_Type_TypeFloat = 2, - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if - // negative values are likely. + /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + /// negative values are likely. GPBFieldDescriptorProto_Type_TypeInt64 = 3, GPBFieldDescriptorProto_Type_TypeUint64 = 4, - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if - // negative values are likely. + /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + /// negative values are likely. GPBFieldDescriptorProto_Type_TypeInt32 = 5, GPBFieldDescriptorProto_Type_TypeFixed64 = 6, GPBFieldDescriptorProto_Type_TypeFixed32 = 7, GPBFieldDescriptorProto_Type_TypeBool = 8, GPBFieldDescriptorProto_Type_TypeString = 9, - // Tag-delimited aggregate. + /// Tag-delimited aggregate. GPBFieldDescriptorProto_Type_TypeGroup = 10, - // Length-delimited aggregate. + /// Length-delimited aggregate. GPBFieldDescriptorProto_Type_TypeMessage = 11, - // New in version 2. + /// New in version 2. GPBFieldDescriptorProto_Type_TypeBytes = 12, GPBFieldDescriptorProto_Type_TypeUint32 = 13, GPBFieldDescriptorProto_Type_TypeEnum = 14, GPBFieldDescriptorProto_Type_TypeSfixed32 = 15, GPBFieldDescriptorProto_Type_TypeSfixed64 = 16, - // Uses ZigZag encoding. + /// Uses ZigZag encoding. GPBFieldDescriptorProto_Type_TypeSint32 = 17, - // Uses ZigZag encoding. + /// Uses ZigZag encoding. GPBFieldDescriptorProto_Type_TypeSint64 = 18, }; GPBEnumDescriptor *GPBFieldDescriptorProto_Type_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBFieldDescriptorProto_Type_IsValidValue(int32_t value); #pragma mark - Enum GPBFieldDescriptorProto_Label typedef GPB_ENUM(GPBFieldDescriptorProto_Label) { - // 0 is reserved for errors + /// 0 is reserved for errors GPBFieldDescriptorProto_Label_LabelOptional = 1, GPBFieldDescriptorProto_Label_LabelRequired = 2, - // TODO(sanjay): Should we add LABEL_MAP? + /// TODO(sanjay): Should we add LABEL_MAP? GPBFieldDescriptorProto_Label_LabelRepeated = 3, }; GPBEnumDescriptor *GPBFieldDescriptorProto_Label_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBFieldDescriptorProto_Label_IsValidValue(int32_t value); #pragma mark - Enum GPBFileOptions_OptimizeMode -// Generated classes can be optimized for speed or code size. +/// Generated classes can be optimized for speed or code size. typedef GPB_ENUM(GPBFileOptions_OptimizeMode) { - // Generate complete code for parsing, serialization, + /// Generate complete code for parsing, serialization, GPBFileOptions_OptimizeMode_Speed = 1, - // etc. + /// etc. GPBFileOptions_OptimizeMode_CodeSize = 2, - // Generate code using MessageLite and the lite runtime. + /// Generate code using MessageLite and the lite runtime. GPBFileOptions_OptimizeMode_LiteRuntime = 3, }; GPBEnumDescriptor *GPBFileOptions_OptimizeMode_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBFileOptions_OptimizeMode_IsValidValue(int32_t value); #pragma mark - Enum GPBFieldOptions_CType typedef GPB_ENUM(GPBFieldOptions_CType) { - // Default mode. + /// Default mode. GPBFieldOptions_CType_String = 0, GPBFieldOptions_CType_Cord = 1, GPBFieldOptions_CType_StringPiece = 2, @@ -125,34 +131,40 @@ typedef GPB_ENUM(GPBFieldOptions_CType) { GPBEnumDescriptor *GPBFieldOptions_CType_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBFieldOptions_CType_IsValidValue(int32_t value); #pragma mark - Enum GPBFieldOptions_JSType typedef GPB_ENUM(GPBFieldOptions_JSType) { - // Use the default type. + /// Use the default type. GPBFieldOptions_JSType_JsNormal = 0, - // Use JavaScript strings. + /// Use JavaScript strings. GPBFieldOptions_JSType_JsString = 1, - // Use JavaScript numbers. + /// Use JavaScript numbers. GPBFieldOptions_JSType_JsNumber = 2, }; GPBEnumDescriptor *GPBFieldOptions_JSType_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBFieldOptions_JSType_IsValidValue(int32_t value); #pragma mark - GPBDescriptorRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBDescriptorRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBFileDescriptorSet @@ -161,11 +173,12 @@ typedef GPB_ENUM(GPBFileDescriptorSet_FieldNumber) { GPBFileDescriptorSet_FieldNumber_FileArray = 1, }; -// The protocol compiler can output a FileDescriptorSet containing the .proto -// files it parses. +/// The protocol compiler can output a FileDescriptorSet containing the .proto +/// files it parses. @interface GPBFileDescriptorSet : GPBMessage @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fileArray; +/// The number of items in @c fileArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger fileArray_Count; @end @@ -187,57 +200,69 @@ typedef GPB_ENUM(GPBFileDescriptorProto_FieldNumber) { GPBFileDescriptorProto_FieldNumber_Syntax = 12, }; -// Describes a complete .proto file. +/// Describes a complete .proto file. @interface GPBFileDescriptorProto : GPBMessage -// file name, relative to root of source tree -@property(nonatomic, readwrite) BOOL hasName; +/// file name, relative to root of source tree @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; -// e.g. "foo", "foo.bar", etc. -@property(nonatomic, readwrite) BOOL hasPackage; +/// e.g. "foo", "foo.bar", etc. @property(nonatomic, readwrite, copy, null_resettable) NSString *package; +/// Test to see if @c package has been set. +@property(nonatomic, readwrite) BOOL hasPackage; -// Names of files imported by this file. +/// Names of files imported by this file. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *dependencyArray; +/// The number of items in @c dependencyArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger dependencyArray_Count; -// Indexes of the public imported files in the dependency list above. +/// Indexes of the public imported files in the dependency list above. @property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *publicDependencyArray; +/// The number of items in @c publicDependencyArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger publicDependencyArray_Count; -// Indexes of the weak imported files in the dependency list. -// For Google-internal migration only. Do not use. +/// Indexes of the weak imported files in the dependency list. +/// For Google-internal migration only. Do not use. @property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *weakDependencyArray; +/// The number of items in @c weakDependencyArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger weakDependencyArray_Count; -// All top-level definitions in this file. +/// All top-level definitions in this file. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *messageTypeArray; +/// The number of items in @c messageTypeArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger messageTypeArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumTypeArray; +/// The number of items in @c enumTypeArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger enumTypeArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *serviceArray; +/// The number of items in @c serviceArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger serviceArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionArray; +/// The number of items in @c extensionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger extensionArray_Count; -@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) GPBFileOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; -// This field contains optional information about the original source code. -// You may safely remove this entire field without harming runtime -// functionality of the descriptors -- the information is needed only by -// development tools. -@property(nonatomic, readwrite) BOOL hasSourceCodeInfo; +/// This field contains optional information about the original source code. +/// You may safely remove this entire field without harming runtime +/// functionality of the descriptors -- the information is needed only by +/// development tools. @property(nonatomic, readwrite, strong, null_resettable) GPBSourceCodeInfo *sourceCodeInfo; +/// Test to see if @c sourceCodeInfo has been set. +@property(nonatomic, readwrite) BOOL hasSourceCodeInfo; -// The syntax of the proto file. -// The supported values are "proto2" and "proto3". -@property(nonatomic, readwrite) BOOL hasSyntax; +/// The syntax of the proto file. +/// The supported values are "proto2" and "proto3". @property(nonatomic, readwrite, copy, null_resettable) NSString *syntax; +/// Test to see if @c syntax has been set. +@property(nonatomic, readwrite) BOOL hasSyntax; @end @@ -256,39 +281,49 @@ typedef GPB_ENUM(GPBDescriptorProto_FieldNumber) { GPBDescriptorProto_FieldNumber_ReservedNameArray = 10, }; -// Describes a message type. +/// Describes a message type. @interface GPBDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldArray; +/// The number of items in @c fieldArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger fieldArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionArray; +/// The number of items in @c extensionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger extensionArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *nestedTypeArray; +/// The number of items in @c nestedTypeArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger nestedTypeArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumTypeArray; +/// The number of items in @c enumTypeArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger enumTypeArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionRangeArray; +/// The number of items in @c extensionRangeArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger extensionRangeArray_Count; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofDeclArray; +/// The number of items in @c oneofDeclArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger oneofDeclArray_Count; -@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) GPBMessageOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *reservedRangeArray; +/// The number of items in @c reservedRangeArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger reservedRangeArray_Count; -// Reserved field names, which may not be used by fields in the same message. -// A given name may only be reserved once. +/// Reserved field names, which may not be used by fields in the same message. +/// A given name may only be reserved once. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *reservedNameArray; +/// The number of items in @c reservedNameArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger reservedNameArray_Count; @end @@ -302,12 +337,12 @@ typedef GPB_ENUM(GPBDescriptorProto_ExtensionRange_FieldNumber) { @interface GPBDescriptorProto_ExtensionRange : GPBMessage -@property(nonatomic, readwrite) BOOL hasStart; @property(nonatomic, readwrite) int32_t start; -@property(nonatomic, readwrite) BOOL hasEnd; +@property(nonatomic, readwrite) BOOL hasStart; @property(nonatomic, readwrite) int32_t end; +@property(nonatomic, readwrite) BOOL hasEnd; @end #pragma mark - GPBDescriptorProto_ReservedRange @@ -317,19 +352,19 @@ typedef GPB_ENUM(GPBDescriptorProto_ReservedRange_FieldNumber) { GPBDescriptorProto_ReservedRange_FieldNumber_End = 2, }; -// Range of reserved tag numbers. Reserved tag numbers may not be used by -// fields or extension ranges in the same message. Reserved ranges may -// not overlap. +/// Range of reserved tag numbers. Reserved tag numbers may not be used by +/// fields or extension ranges in the same message. Reserved ranges may +/// not overlap. @interface GPBDescriptorProto_ReservedRange : GPBMessage -// Inclusive. -@property(nonatomic, readwrite) BOOL hasStart; +/// Inclusive. @property(nonatomic, readwrite) int32_t start; -// Exclusive. -@property(nonatomic, readwrite) BOOL hasEnd; +@property(nonatomic, readwrite) BOOL hasStart; +/// Exclusive. @property(nonatomic, readwrite) int32_t end; +@property(nonatomic, readwrite) BOOL hasEnd; @end #pragma mark - GPBFieldDescriptorProto @@ -347,58 +382,64 @@ typedef GPB_ENUM(GPBFieldDescriptorProto_FieldNumber) { GPBFieldDescriptorProto_FieldNumber_JsonName = 10, }; -// Describes a field within a message. +/// Describes a field within a message. @interface GPBFieldDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; -@property(nonatomic, readwrite) BOOL hasNumber; @property(nonatomic, readwrite) int32_t number; -@property(nonatomic, readwrite) BOOL hasLabel; +@property(nonatomic, readwrite) BOOL hasNumber; @property(nonatomic, readwrite) GPBFieldDescriptorProto_Label label; -// If type_name is set, this need not be set. If both this and type_name -// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. -@property(nonatomic, readwrite) BOOL hasType; +@property(nonatomic, readwrite) BOOL hasLabel; +/// If type_name is set, this need not be set. If both this and type_name +/// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. @property(nonatomic, readwrite) GPBFieldDescriptorProto_Type type; -// For message and enum types, this is the name of the type. If the name -// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping -// rules are used to find the type (i.e. first the nested types within this -// message are searched, then within the parent, on up to the root -// namespace). -@property(nonatomic, readwrite) BOOL hasTypeName; +@property(nonatomic, readwrite) BOOL hasType; +/// For message and enum types, this is the name of the type. If the name +/// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping +/// rules are used to find the type (i.e. first the nested types within this +/// message are searched, then within the parent, on up to the root +/// namespace). @property(nonatomic, readwrite, copy, null_resettable) NSString *typeName; +/// Test to see if @c typeName has been set. +@property(nonatomic, readwrite) BOOL hasTypeName; -// For extensions, this is the name of the type being extended. It is -// resolved in the same manner as type_name. -@property(nonatomic, readwrite) BOOL hasExtendee; +/// For extensions, this is the name of the type being extended. It is +/// resolved in the same manner as type_name. @property(nonatomic, readwrite, copy, null_resettable) NSString *extendee; +/// Test to see if @c extendee has been set. +@property(nonatomic, readwrite) BOOL hasExtendee; -// For numeric types, contains the original text representation of the value. -// For booleans, "true" or "false". -// For strings, contains the default text contents (not escaped in any way). -// For bytes, contains the C escaped value. All bytes >= 128 are escaped. -// TODO(kenton): Base-64 encode? -@property(nonatomic, readwrite) BOOL hasDefaultValue; +/// For numeric types, contains the original text representation of the value. +/// For booleans, "true" or "false". +/// For strings, contains the default text contents (not escaped in any way). +/// For bytes, contains the C escaped value. All bytes >= 128 are escaped. +/// TODO(kenton): Base-64 encode? @property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue; +/// Test to see if @c defaultValue has been set. +@property(nonatomic, readwrite) BOOL hasDefaultValue; -// If set, gives the index of a oneof in the containing type's oneof_decl -// list. This field is a member of that oneof. -@property(nonatomic, readwrite) BOOL hasOneofIndex; +/// If set, gives the index of a oneof in the containing type's oneof_decl +/// list. This field is a member of that oneof. @property(nonatomic, readwrite) int32_t oneofIndex; -// JSON name of this field. The value is set by protocol compiler. If the -// user has set a "json_name" option on this field, that option's value -// will be used. Otherwise, it's deduced from the field's name by converting -// it to camelCase. -@property(nonatomic, readwrite) BOOL hasJsonName; +@property(nonatomic, readwrite) BOOL hasOneofIndex; +/// JSON name of this field. The value is set by protocol compiler. If the +/// user has set a "json_name" option on this field, that option's value +/// will be used. Otherwise, it's deduced from the field's name by converting +/// it to camelCase. @property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName; +/// Test to see if @c jsonName has been set. +@property(nonatomic, readwrite) BOOL hasJsonName; -@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) GPBFieldOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; @end @@ -408,11 +449,12 @@ typedef GPB_ENUM(GPBOneofDescriptorProto_FieldNumber) { GPBOneofDescriptorProto_FieldNumber_Name = 1, }; -// Describes a oneof. +/// Describes a oneof. @interface GPBOneofDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; @end @@ -424,17 +466,20 @@ typedef GPB_ENUM(GPBEnumDescriptorProto_FieldNumber) { GPBEnumDescriptorProto_FieldNumber_Options = 3, }; -// Describes an enum type. +/// Describes an enum type. @interface GPBEnumDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valueArray; +/// The number of items in @c valueArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger valueArray_Count; -@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) GPBEnumOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; @end @@ -446,17 +491,19 @@ typedef GPB_ENUM(GPBEnumValueDescriptorProto_FieldNumber) { GPBEnumValueDescriptorProto_FieldNumber_Options = 3, }; -// Describes a value within an enum. +/// Describes a value within an enum. @interface GPBEnumValueDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; -@property(nonatomic, readwrite) BOOL hasNumber; @property(nonatomic, readwrite) int32_t number; -@property(nonatomic, readwrite) BOOL hasOptions; +@property(nonatomic, readwrite) BOOL hasNumber; @property(nonatomic, readwrite, strong, null_resettable) GPBEnumValueOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; @end @@ -468,17 +515,20 @@ typedef GPB_ENUM(GPBServiceDescriptorProto_FieldNumber) { GPBServiceDescriptorProto_FieldNumber_Options = 3, }; -// Describes a service. +/// Describes a service. @interface GPBServiceDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodArray; +/// The number of items in @c methodArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger methodArray_Count; -@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) GPBServiceOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; @end @@ -493,31 +543,35 @@ typedef GPB_ENUM(GPBMethodDescriptorProto_FieldNumber) { GPBMethodDescriptorProto_FieldNumber_ServerStreaming = 6, }; -// Describes a method of a service. +/// Describes a method of a service. @interface GPBMethodDescriptorProto : GPBMessage -@property(nonatomic, readwrite) BOOL hasName; @property(nonatomic, readwrite, copy, null_resettable) NSString *name; +/// Test to see if @c name has been set. +@property(nonatomic, readwrite) BOOL hasName; -// Input and output type names. These are resolved in the same way as -// FieldDescriptorProto.type_name, but must refer to a message type. -@property(nonatomic, readwrite) BOOL hasInputType; +/// Input and output type names. These are resolved in the same way as +/// FieldDescriptorProto.type_name, but must refer to a message type. @property(nonatomic, readwrite, copy, null_resettable) NSString *inputType; +/// Test to see if @c inputType has been set. +@property(nonatomic, readwrite) BOOL hasInputType; -@property(nonatomic, readwrite) BOOL hasOutputType; @property(nonatomic, readwrite, copy, null_resettable) NSString *outputType; +/// Test to see if @c outputType has been set. +@property(nonatomic, readwrite) BOOL hasOutputType; -@property(nonatomic, readwrite) BOOL hasOptions; @property(nonatomic, readwrite, strong, null_resettable) GPBMethodOptions *options; +/// Test to see if @c options has been set. +@property(nonatomic, readwrite) BOOL hasOptions; -// Identifies if client streams multiple client messages -@property(nonatomic, readwrite) BOOL hasClientStreaming; +/// Identifies if client streams multiple client messages @property(nonatomic, readwrite) BOOL clientStreaming; -// Identifies if server streams multiple server messages -@property(nonatomic, readwrite) BOOL hasServerStreaming; +@property(nonatomic, readwrite) BOOL hasClientStreaming; +/// Identifies if server streams multiple server messages @property(nonatomic, readwrite) BOOL serverStreaming; +@property(nonatomic, readwrite) BOOL hasServerStreaming; @end #pragma mark - GPBFileOptions @@ -543,112 +597,118 @@ typedef GPB_ENUM(GPBFileOptions_FieldNumber) { @interface GPBFileOptions : GPBMessage -// Sets the Java package where classes generated from this .proto will be -// placed. By default, the proto package is used, but this is often -// inappropriate because proto packages do not normally start with backwards -// domain names. -@property(nonatomic, readwrite) BOOL hasJavaPackage; +/// Sets the Java package where classes generated from this .proto will be +/// placed. By default, the proto package is used, but this is often +/// inappropriate because proto packages do not normally start with backwards +/// domain names. @property(nonatomic, readwrite, copy, null_resettable) NSString *javaPackage; +/// Test to see if @c javaPackage has been set. +@property(nonatomic, readwrite) BOOL hasJavaPackage; -// If set, all the classes from the .proto file are wrapped in a single -// outer class with the given name. This applies to both Proto1 -// (equivalent to the old "--one_java_file" option) and Proto2 (where -// a .proto always translates to a single class, but you may want to -// explicitly choose the class name). -@property(nonatomic, readwrite) BOOL hasJavaOuterClassname; +/// If set, all the classes from the .proto file are wrapped in a single +/// outer class with the given name. This applies to both Proto1 +/// (equivalent to the old "--one_java_file" option) and Proto2 (where +/// a .proto always translates to a single class, but you may want to +/// explicitly choose the class name). @property(nonatomic, readwrite, copy, null_resettable) NSString *javaOuterClassname; +/// Test to see if @c javaOuterClassname has been set. +@property(nonatomic, readwrite) BOOL hasJavaOuterClassname; -// If set true, then the Java code generator will generate a separate .java -// file for each top-level message, enum, and service defined in the .proto -// file. Thus, these types will *not* be nested inside the outer class -// named by java_outer_classname. However, the outer class will still be -// generated to contain the file's getDescriptor() method as well as any -// top-level extensions defined in the file. -@property(nonatomic, readwrite) BOOL hasJavaMultipleFiles; +/// If set true, then the Java code generator will generate a separate .java +/// file for each top-level message, enum, and service defined in the .proto +/// file. Thus, these types will *not* be nested inside the outer class +/// named by java_outer_classname. However, the outer class will still be +/// generated to contain the file's getDescriptor() method as well as any +/// top-level extensions defined in the file. @property(nonatomic, readwrite) BOOL javaMultipleFiles; -// If set true, then the Java code generator will generate equals() and -// hashCode() methods for all messages defined in the .proto file. -// 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 -// 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 -// will be consistent across runtimes or versions of the protocol compiler.) -@property(nonatomic, readwrite) BOOL hasJavaGenerateEqualsAndHash; +@property(nonatomic, readwrite) BOOL hasJavaMultipleFiles; +/// If set true, then the Java code generator will generate equals() and +/// hashCode() methods for all messages defined in the .proto file. +/// 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 +/// 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 +/// will be consistent across runtimes or versions of the protocol compiler.) @property(nonatomic, readwrite) BOOL javaGenerateEqualsAndHash; -// If set true, then the Java2 code generator will generate code that -// throws an exception whenever an attempt is made to assign a non-UTF-8 -// byte sequence to a string field. -// Message reflection will do the same. -// However, an extension field still accepts non-UTF-8 byte sequences. -// This option has no effect on when used with the lite runtime. -@property(nonatomic, readwrite) BOOL hasJavaStringCheckUtf8; +@property(nonatomic, readwrite) BOOL hasJavaGenerateEqualsAndHash; +/// If set true, then the Java2 code generator will generate code that +/// throws an exception whenever an attempt is made to assign a non-UTF-8 +/// byte sequence to a string field. +/// Message reflection will do the same. +/// However, an extension field still accepts non-UTF-8 byte sequences. +/// This option has no effect on when used with the lite runtime. @property(nonatomic, readwrite) BOOL javaStringCheckUtf8; -@property(nonatomic, readwrite) BOOL hasOptimizeFor; +@property(nonatomic, readwrite) BOOL hasJavaStringCheckUtf8; @property(nonatomic, readwrite) GPBFileOptions_OptimizeMode optimizeFor; -// Sets the Go package where structs generated from this .proto will be -// placed. If omitted, the Go package will be derived from the following: -// - The basename of the package import path, if provided. -// - Otherwise, the package statement in the .proto file, if present. -// - Otherwise, the basename of the .proto file, without extension. -@property(nonatomic, readwrite) BOOL hasGoPackage; +@property(nonatomic, readwrite) BOOL hasOptimizeFor; +/// Sets the Go package where structs generated from this .proto will be +/// placed. If omitted, the Go package will be derived from the following: +/// - The basename of the package import path, if provided. +/// - Otherwise, the package statement in the .proto file, if present. +/// - Otherwise, the basename of the .proto file, without extension. @property(nonatomic, readwrite, copy, null_resettable) NSString *goPackage; +/// Test to see if @c goPackage has been set. +@property(nonatomic, readwrite) BOOL hasGoPackage; -// Should generic services be generated in each language? "Generic" services -// are not specific to any particular RPC system. They are generated by the -// main code generators in each language (without additional plugins). -// Generic services were the only kind of service generation supported by -// early versions of google.protobuf. -// -// Generic services are now considered deprecated in favor of using plugins -// that generate code specific to your particular RPC system. Therefore, -// these default to false. Old code which depends on generic services should -// explicitly set them to true. -@property(nonatomic, readwrite) BOOL hasCcGenericServices; +/// Should generic services be generated in each language? "Generic" services +/// are not specific to any particular RPC system. They are generated by the +/// main code generators in each language (without additional plugins). +/// Generic services were the only kind of service generation supported by +/// early versions of google.protobuf. +/// +/// Generic services are now considered deprecated in favor of using plugins +/// that generate code specific to your particular RPC system. Therefore, +/// these default to false. Old code which depends on generic services should +/// explicitly set them to true. @property(nonatomic, readwrite) BOOL ccGenericServices; -@property(nonatomic, readwrite) BOOL hasJavaGenericServices; +@property(nonatomic, readwrite) BOOL hasCcGenericServices; @property(nonatomic, readwrite) BOOL javaGenericServices; -@property(nonatomic, readwrite) BOOL hasPyGenericServices; +@property(nonatomic, readwrite) BOOL hasJavaGenericServices; @property(nonatomic, readwrite) BOOL pyGenericServices; -// Is this file deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for everything in the file, or it will be completely ignored; in the very -// least, this is a formalization for deprecating files. -@property(nonatomic, readwrite) BOOL hasDeprecated; +@property(nonatomic, readwrite) BOOL hasPyGenericServices; +/// Is this file deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for everything in the file, or it will be completely ignored; in the very +/// least, this is a formalization for deprecating files. @property(nonatomic, readwrite) BOOL deprecated; -// Enables the use of arenas for the proto messages in this file. This applies -// only to generated classes for C++. -@property(nonatomic, readwrite) BOOL hasCcEnableArenas; +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// Enables the use of arenas for the proto messages in this file. This applies +/// only to generated classes for C++. @property(nonatomic, readwrite) BOOL ccEnableArenas; -// Sets the objective c class prefix which is prepended to all objective c -// generated classes from this .proto. There is no default. -@property(nonatomic, readwrite) BOOL hasObjcClassPrefix; +@property(nonatomic, readwrite) BOOL hasCcEnableArenas; +/// Sets the objective c class prefix which is prepended to all objective c +/// generated classes from this .proto. There is no default. @property(nonatomic, readwrite, copy, null_resettable) NSString *objcClassPrefix; +/// Test to see if @c objcClassPrefix has been set. +@property(nonatomic, readwrite) BOOL hasObjcClassPrefix; -// Namespace for generated classes; defaults to the package. -@property(nonatomic, readwrite) BOOL hasCsharpNamespace; +/// Namespace for generated classes; defaults to the package. @property(nonatomic, readwrite, copy, null_resettable) NSString *csharpNamespace; +/// Test to see if @c csharpNamespace has been set. +@property(nonatomic, readwrite) BOOL hasCsharpNamespace; -// Whether the nano proto compiler should generate in the deprecated non-nano -// suffixed package. -@property(nonatomic, readwrite) BOOL hasJavananoUseDeprecatedPackage; +/// Whether the nano proto compiler should generate in the deprecated non-nano +/// suffixed package. @property(nonatomic, readwrite) BOOL javananoUseDeprecatedPackage; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasJavananoUseDeprecatedPackage; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -665,66 +725,67 @@ typedef GPB_ENUM(GPBMessageOptions_FieldNumber) { @interface GPBMessageOptions : GPBMessage -// Set true to use the old proto1 MessageSet wire format for extensions. -// This is provided for backwards-compatibility with the MessageSet wire -// format. You should not use this for any other reason: It's less -// efficient, has fewer features, and is more complicated. -// -// The message must be defined exactly as follows: -// message Foo { -// option message_set_wire_format = true; -// extensions 4 to max; -// } -// Note that the message cannot have any defined fields; MessageSets only -// have extensions. -// -// All extensions of your type must be singular messages; e.g. they cannot -// be int32s, enums, or repeated messages. -// -// Because this is an option, the above two restrictions are not enforced by -// the protocol compiler. -@property(nonatomic, readwrite) BOOL hasMessageSetWireFormat; +/// Set true to use the old proto1 MessageSet wire format for extensions. +/// This is provided for backwards-compatibility with the MessageSet wire +/// format. You should not use this for any other reason: It's less +/// efficient, has fewer features, and is more complicated. +/// +/// The message must be defined exactly as follows: +/// message Foo { +/// option message_set_wire_format = true; +/// extensions 4 to max; +/// } +/// Note that the message cannot have any defined fields; MessageSets only +/// have extensions. +/// +/// All extensions of your type must be singular messages; e.g. they cannot +/// be int32s, enums, or repeated messages. +/// +/// Because this is an option, the above two restrictions are not enforced by +/// the protocol compiler. @property(nonatomic, readwrite) BOOL messageSetWireFormat; -// Disables the generation of the standard "descriptor()" accessor, which can -// conflict with a field of the same name. This is meant to make migration -// from proto1 easier; new code should avoid fields named "descriptor". -@property(nonatomic, readwrite) BOOL hasNoStandardDescriptorAccessor; +@property(nonatomic, readwrite) BOOL hasMessageSetWireFormat; +/// Disables the generation of the standard "descriptor()" accessor, which can +/// conflict with a field of the same name. This is meant to make migration +/// from proto1 easier; new code should avoid fields named "descriptor". @property(nonatomic, readwrite) BOOL noStandardDescriptorAccessor; -// Is this message deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for the message, or it will be completely ignored; in the very least, -// this is a formalization for deprecating messages. -@property(nonatomic, readwrite) BOOL hasDeprecated; +@property(nonatomic, readwrite) BOOL hasNoStandardDescriptorAccessor; +/// Is this message deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for the message, or it will be completely ignored; in the very least, +/// this is a formalization for deprecating messages. @property(nonatomic, readwrite) BOOL deprecated; -// Whether the message is an automatically generated map entry type for the -// maps field. -// -// For maps fields: -// map map_field = 1; -// The parsed descriptor looks like: -// message MapFieldEntry { -// option map_entry = true; -// optional KeyType key = 1; -// optional ValueType value = 2; -// } -// repeated MapFieldEntry map_field = 1; -// -// Implementations may choose not to generate the map_entry=true message, but -// use a native map in the target language to hold the keys and values. -// The reflection APIs in such implementions still need to work as -// if the field is a repeated message field. -// -// NOTE: Do not set the option in .proto files. Always use the maps syntax -// instead. The option should only be implicitly set by the proto compiler -// parser. -@property(nonatomic, readwrite) BOOL hasMapEntry; +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// Whether the message is an automatically generated map entry type for the +/// maps field. +/// +/// For maps fields: +/// map map_field = 1; +/// The parsed descriptor looks like: +/// message MapFieldEntry { +/// option map_entry = true; +/// optional KeyType key = 1; +/// optional ValueType value = 2; +/// } +/// repeated MapFieldEntry map_field = 1; +/// +/// Implementations may choose not to generate the map_entry=true message, but +/// use a native map in the target language to hold the keys and values. +/// The reflection APIs in such implementions still need to work as +/// if the field is a repeated message field. +/// +/// NOTE: Do not set the option in .proto files. Always use the maps syntax +/// instead. The option should only be implicitly set by the proto compiler +/// parser. @property(nonatomic, readwrite) BOOL mapEntry; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasMapEntry; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -743,77 +804,78 @@ typedef GPB_ENUM(GPBFieldOptions_FieldNumber) { @interface GPBFieldOptions : GPBMessage -// The ctype option instructs the C++ code generator to use a different -// representation of the field than it normally would. See the specific -// options below. This option is not yet implemented in the open source -// release -- sorry, we'll try to include it in a future version! -@property(nonatomic, readwrite) BOOL hasCtype; +/// The ctype option instructs the C++ code generator to use a different +/// representation of the field than it normally would. See the specific +/// options below. This option is not yet implemented in the open source +/// release -- sorry, we'll try to include it in a future version! @property(nonatomic, readwrite) GPBFieldOptions_CType ctype; -// The packed option can be enabled for repeated primitive fields to enable -// a more efficient representation on the wire. Rather than repeatedly -// writing the tag and type for each element, the entire array is encoded as -// a single length-delimited blob. In proto3, only explicit setting it to -// false will avoid using packed encoding. -@property(nonatomic, readwrite) BOOL hasPacked; +@property(nonatomic, readwrite) BOOL hasCtype; +/// The packed option can be enabled for repeated primitive fields to enable +/// a more efficient representation on the wire. Rather than repeatedly +/// writing the tag and type for each element, the entire array is encoded as +/// a single length-delimited blob. In proto3, only explicit setting it to +/// false will avoid using packed encoding. @property(nonatomic, readwrite) BOOL packed; -// The jstype option determines the JavaScript type used for values of the -// field. The option is permitted only for 64 bit integral and fixed types -// (int64, uint64, sint64, fixed64, sfixed64). By default these types are -// represented as JavaScript strings. This avoids loss of precision that can -// happen when a large value is converted to a floating point JavaScript -// numbers. Specifying JS_NUMBER for the jstype causes the generated -// JavaScript code to use the JavaScript "number" type instead of strings. -// This option is an enum to permit additional types to be added, -// e.g. goog.math.Integer. -@property(nonatomic, readwrite) BOOL hasJstype; +@property(nonatomic, readwrite) BOOL hasPacked; +/// The jstype option determines the JavaScript type used for values of the +/// field. The option is permitted only for 64 bit integral and fixed types +/// (int64, uint64, sint64, fixed64, sfixed64). By default these types are +/// represented as JavaScript strings. This avoids loss of precision that can +/// happen when a large value is converted to a floating point JavaScript +/// numbers. Specifying JS_NUMBER for the jstype causes the generated +/// JavaScript code to use the JavaScript "number" type instead of strings. +/// This option is an enum to permit additional types to be added, +/// e.g. goog.math.Integer. @property(nonatomic, readwrite) GPBFieldOptions_JSType jstype; -// Should this field be parsed lazily? Lazy applies only to message-type -// fields. It means that when the outer message is initially parsed, the -// inner message's contents will not be parsed but instead stored in encoded -// form. The inner message will actually be parsed when it is first accessed. -// -// This is only a hint. Implementations are free to choose whether to use -// eager or lazy parsing regardless of the value of this option. However, -// setting this option true suggests that the protocol author believes that -// using lazy parsing on this field is worth the additional bookkeeping -// overhead typically needed to implement it. -// -// This option does not affect the public interface of any generated code; -// all method signatures remain the same. Furthermore, thread-safety of the -// interface is not affected by this option; const methods remain safe to -// call from multiple threads concurrently, while non-const methods continue -// to require exclusive access. -// -// -// Note that implementations may choose not to check required fields within -// a lazy sub-message. That is, calling IsInitialized() on the outher message -// may return true even if the inner message has missing required fields. -// This is necessary because otherwise the inner message would have to be -// parsed in order to perform the check, defeating the purpose of lazy -// parsing. An implementation which chooses not to check required fields -// must be consistent about it. That is, for any particular sub-message, the -// implementation must either *always* check its required fields, or *never* -// check its required fields, regardless of whether or not the message has -// been parsed. -@property(nonatomic, readwrite) BOOL hasLazy; +@property(nonatomic, readwrite) BOOL hasJstype; +/// Should this field be parsed lazily? Lazy applies only to message-type +/// fields. It means that when the outer message is initially parsed, the +/// inner message's contents will not be parsed but instead stored in encoded +/// form. The inner message will actually be parsed when it is first accessed. +/// +/// This is only a hint. Implementations are free to choose whether to use +/// eager or lazy parsing regardless of the value of this option. However, +/// setting this option true suggests that the protocol author believes that +/// using lazy parsing on this field is worth the additional bookkeeping +/// overhead typically needed to implement it. +/// +/// This option does not affect the public interface of any generated code; +/// all method signatures remain the same. Furthermore, thread-safety of the +/// interface is not affected by this option; const methods remain safe to +/// call from multiple threads concurrently, while non-const methods continue +/// to require exclusive access. +/// +/// +/// Note that implementations may choose not to check required fields within +/// a lazy sub-message. That is, calling IsInitialized() on the outher message +/// may return true even if the inner message has missing required fields. +/// This is necessary because otherwise the inner message would have to be +/// parsed in order to perform the check, defeating the purpose of lazy +/// parsing. An implementation which chooses not to check required fields +/// must be consistent about it. That is, for any particular sub-message, the +/// implementation must either *always* check its required fields, or *never* +/// check its required fields, regardless of whether or not the message has +/// been parsed. @property(nonatomic, readwrite) BOOL lazy; -// Is this field deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for accessors, or it will be completely ignored; in the very least, this -// is a formalization for deprecating fields. -@property(nonatomic, readwrite) BOOL hasDeprecated; +@property(nonatomic, readwrite) BOOL hasLazy; +/// Is this field deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for accessors, or it will be completely ignored; in the very least, this +/// is a formalization for deprecating fields. @property(nonatomic, readwrite) BOOL deprecated; -// For Google-internal migration only. Do not use. -@property(nonatomic, readwrite) BOOL hasWeak; +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// For Google-internal migration only. Do not use. @property(nonatomic, readwrite) BOOL weak; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasWeak; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -828,20 +890,21 @@ typedef GPB_ENUM(GPBEnumOptions_FieldNumber) { @interface GPBEnumOptions : GPBMessage -// Set this option to true to allow mapping different tag names to the same -// value. -@property(nonatomic, readwrite) BOOL hasAllowAlias; +/// Set this option to true to allow mapping different tag names to the same +/// value. @property(nonatomic, readwrite) BOOL allowAlias; -// Is this enum deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for the enum, or it will be completely ignored; in the very least, this -// is a formalization for deprecating enums. -@property(nonatomic, readwrite) BOOL hasDeprecated; +@property(nonatomic, readwrite) BOOL hasAllowAlias; +/// Is this enum deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for the enum, or it will be completely ignored; in the very least, this +/// is a formalization for deprecating enums. @property(nonatomic, readwrite) BOOL deprecated; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -855,15 +918,16 @@ typedef GPB_ENUM(GPBEnumValueOptions_FieldNumber) { @interface GPBEnumValueOptions : GPBMessage -// Is this enum value deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for the enum value, or it will be completely ignored; in the very least, -// this is a formalization for deprecating enum values. -@property(nonatomic, readwrite) BOOL hasDeprecated; +/// Is this enum value deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for the enum value, or it will be completely ignored; in the very least, +/// this is a formalization for deprecating enum values. @property(nonatomic, readwrite) BOOL deprecated; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -877,15 +941,16 @@ typedef GPB_ENUM(GPBServiceOptions_FieldNumber) { @interface GPBServiceOptions : GPBMessage -// Is this service deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for the service, or it will be completely ignored; in the very least, -// this is a formalization for deprecating services. -@property(nonatomic, readwrite) BOOL hasDeprecated; +/// Is this service deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for the service, or it will be completely ignored; in the very least, +/// this is a formalization for deprecating services. @property(nonatomic, readwrite) BOOL deprecated; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -899,15 +964,16 @@ typedef GPB_ENUM(GPBMethodOptions_FieldNumber) { @interface GPBMethodOptions : GPBMessage -// Is this method deprecated? -// Depending on the target platform, this can emit Deprecated annotations -// for the method, or it will be completely ignored; in the very least, -// this is a formalization for deprecating methods. -@property(nonatomic, readwrite) BOOL hasDeprecated; +/// Is this method deprecated? +/// Depending on the target platform, this can emit Deprecated annotations +/// for the method, or it will be completely ignored; in the very least, +/// this is a formalization for deprecating methods. @property(nonatomic, readwrite) BOOL deprecated; -// The parser stores options it doesn't recognize here. See above. +@property(nonatomic, readwrite) BOOL hasDeprecated; +/// The parser stores options it doesn't recognize here. See above. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; +/// The number of items in @c uninterpretedOptionArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; @end @@ -924,36 +990,40 @@ typedef GPB_ENUM(GPBUninterpretedOption_FieldNumber) { GPBUninterpretedOption_FieldNumber_AggregateValue = 8, }; -// A message representing a option the parser does not recognize. This only -// appears in options protos created by the compiler::Parser class. -// DescriptorPool resolves these when building Descriptor objects. Therefore, -// options protos in descriptor objects (e.g. returned by Descriptor::options(), -// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions -// in them. +/// A message representing a option the parser does not recognize. This only +/// appears in options protos created by the compiler::Parser class. +/// DescriptorPool resolves these when building Descriptor objects. Therefore, +/// options protos in descriptor objects (e.g. returned by Descriptor::options(), +/// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions +/// in them. @interface GPBUninterpretedOption : GPBMessage @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *nameArray; +/// The number of items in @c nameArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger nameArray_Count; -// The value of the uninterpreted option, in whatever type the tokenizer -// identified it as during parsing. Exactly one of these should be set. -@property(nonatomic, readwrite) BOOL hasIdentifierValue; +/// The value of the uninterpreted option, in whatever type the tokenizer +/// identified it as during parsing. Exactly one of these should be set. @property(nonatomic, readwrite, copy, null_resettable) NSString *identifierValue; +/// Test to see if @c identifierValue has been set. +@property(nonatomic, readwrite) BOOL hasIdentifierValue; -@property(nonatomic, readwrite) BOOL hasPositiveIntValue; @property(nonatomic, readwrite) uint64_t positiveIntValue; -@property(nonatomic, readwrite) BOOL hasNegativeIntValue; +@property(nonatomic, readwrite) BOOL hasPositiveIntValue; @property(nonatomic, readwrite) int64_t negativeIntValue; -@property(nonatomic, readwrite) BOOL hasDoubleValue; +@property(nonatomic, readwrite) BOOL hasNegativeIntValue; @property(nonatomic, readwrite) double doubleValue; -@property(nonatomic, readwrite) BOOL hasStringValue; +@property(nonatomic, readwrite) BOOL hasDoubleValue; @property(nonatomic, readwrite, copy, null_resettable) NSData *stringValue; +/// Test to see if @c stringValue has been set. +@property(nonatomic, readwrite) BOOL hasStringValue; -@property(nonatomic, readwrite) BOOL hasAggregateValue; @property(nonatomic, readwrite, copy, null_resettable) NSString *aggregateValue; +/// Test to see if @c aggregateValue has been set. +@property(nonatomic, readwrite) BOOL hasAggregateValue; @end @@ -964,19 +1034,20 @@ typedef GPB_ENUM(GPBUninterpretedOption_NamePart_FieldNumber) { GPBUninterpretedOption_NamePart_FieldNumber_IsExtension = 2, }; -// The name of the uninterpreted option. Each string represents a segment in -// a dot-separated name. is_extension is true iff a segment represents an -// extension (denoted with parentheses in options specs in .proto files). -// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents -// "foo.(bar.baz).qux". +/// The name of the uninterpreted option. Each string represents a segment in +/// a dot-separated name. is_extension is true iff a segment represents an +/// extension (denoted with parentheses in options specs in .proto files). +/// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents +/// "foo.(bar.baz).qux". @interface GPBUninterpretedOption_NamePart : GPBMessage -@property(nonatomic, readwrite) BOOL hasNamePart; @property(nonatomic, readwrite, copy, null_resettable) NSString *namePart; +/// Test to see if @c namePart has been set. +@property(nonatomic, readwrite) BOOL hasNamePart; -@property(nonatomic, readwrite) BOOL hasIsExtension; @property(nonatomic, readwrite) BOOL isExtension; +@property(nonatomic, readwrite) BOOL hasIsExtension; @end #pragma mark - GPBSourceCodeInfo @@ -985,54 +1056,55 @@ typedef GPB_ENUM(GPBSourceCodeInfo_FieldNumber) { GPBSourceCodeInfo_FieldNumber_LocationArray = 1, }; -// Encapsulates information about the original source file from which a -// FileDescriptorProto was generated. +/// Encapsulates information about the original source file from which a +/// FileDescriptorProto was generated. @interface GPBSourceCodeInfo : GPBMessage -// A Location identifies a piece of source code in a .proto file which -// corresponds to a particular definition. This information is intended -// to be useful to IDEs, code indexers, documentation generators, and similar -// tools. -// -// For example, say we have a file like: -// message Foo { -// optional string foo = 1; -// } -// Let's look at just the field definition: -// optional string foo = 1; -// ^ ^^ ^^ ^ ^^^ -// a bc de f ghi -// We have the following locations: -// span path represents -// [a,i) [ 4, 0, 2, 0 ] The whole field definition. -// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). -// [c,d) [ 4, 0, 2, 0, 5 ] The type (string). -// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). -// [g,h) [ 4, 0, 2, 0, 3 ] The number (1). -// -// Notes: -// - A location may refer to a repeated field itself (i.e. not to any -// particular index within it). This is used whenever a set of elements are -// logically enclosed in a single code segment. For example, an entire -// extend block (possibly containing multiple extension definitions) will -// have an outer location whose path refers to the "extensions" repeated -// field without an index. -// - Multiple locations may have the same path. This happens when a single -// logical declaration is spread out across multiple places. The most -// obvious example is the "extend" block again -- there may be multiple -// extend blocks in the same scope, each of which will have the same path. -// - A location's span is not always a subset of its parent's span. For -// example, the "extendee" of an extension declaration appears at the -// beginning of the "extend" block and is shared by all extensions within -// the block. -// - Just because a location's span is a subset of some other location's span -// does not mean that it is a descendent. For example, a "group" defines -// both a type and a field in a single declaration. Thus, the locations -// corresponding to the type and field and their components will overlap. -// - Code which tries to interpret locations should probably be designed to -// ignore those that it doesn't understand, as more types of locations could -// be recorded in the future. +/// A Location identifies a piece of source code in a .proto file which +/// corresponds to a particular definition. This information is intended +/// to be useful to IDEs, code indexers, documentation generators, and similar +/// tools. +/// +/// For example, say we have a file like: +/// message Foo { +/// optional string foo = 1; +/// } +/// Let's look at just the field definition: +/// optional string foo = 1; +/// ^ ^^ ^^ ^ ^^^ +/// a bc de f ghi +/// We have the following locations: +/// span path represents +/// [a,i) [ 4, 0, 2, 0 ] The whole field definition. +/// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). +/// [c,d) [ 4, 0, 2, 0, 5 ] The type (string). +/// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). +/// [g,h) [ 4, 0, 2, 0, 3 ] The number (1). +/// +/// Notes: +/// - A location may refer to a repeated field itself (i.e. not to any +/// particular index within it). This is used whenever a set of elements are +/// logically enclosed in a single code segment. For example, an entire +/// extend block (possibly containing multiple extension definitions) will +/// have an outer location whose path refers to the "extensions" repeated +/// field without an index. +/// - Multiple locations may have the same path. This happens when a single +/// logical declaration is spread out across multiple places. The most +/// obvious example is the "extend" block again -- there may be multiple +/// extend blocks in the same scope, each of which will have the same path. +/// - A location's span is not always a subset of its parent's span. For +/// example, the "extendee" of an extension declaration appears at the +/// beginning of the "extend" block and is shared by all extensions within +/// the block. +/// - Just because a location's span is a subset of some other location's span +/// does not mean that it is a descendent. For example, a "group" defines +/// both a type and a field in a single declaration. Thus, the locations +/// corresponding to the type and field and their components will overlap. +/// - Code which tries to interpret locations should probably be designed to +/// ignore those that it doesn't understand, as more types of locations could +/// be recorded in the future. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *locationArray; +/// The number of items in @c locationArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger locationArray_Count; @end @@ -1049,94 +1121,99 @@ typedef GPB_ENUM(GPBSourceCodeInfo_Location_FieldNumber) { @interface GPBSourceCodeInfo_Location : GPBMessage -// Identifies which part of the FileDescriptorProto was defined at this -// location. -// -// Each element is a field number or an index. They form a path from -// the root FileDescriptorProto to the place where the definition. For -// example, this path: -// [ 4, 3, 2, 7, 1 ] -// refers to: -// file.message_type(3) // 4, 3 -// .field(7) // 2, 7 -// .name() // 1 -// This is because FileDescriptorProto.message_type has field number 4: -// repeated DescriptorProto message_type = 4; -// and DescriptorProto.field has field number 2: -// repeated FieldDescriptorProto field = 2; -// and FieldDescriptorProto.name has field number 1: -// optional string name = 1; -// -// Thus, the above path gives the location of a field name. If we removed -// the last element: -// [ 4, 3, 2, 7 ] -// this path refers to the whole field declaration (from the beginning -// of the label to the terminating semicolon). +/// Identifies which part of the FileDescriptorProto was defined at this +/// location. +/// +/// Each element is a field number or an index. They form a path from +/// the root FileDescriptorProto to the place where the definition. For +/// example, this path: +/// [ 4, 3, 2, 7, 1 ] +/// refers to: +/// file.message_type(3) // 4, 3 +/// .field(7) // 2, 7 +/// .name() // 1 +/// This is because FileDescriptorProto.message_type has field number 4: +/// repeated DescriptorProto message_type = 4; +/// and DescriptorProto.field has field number 2: +/// repeated FieldDescriptorProto field = 2; +/// and FieldDescriptorProto.name has field number 1: +/// optional string name = 1; +/// +/// Thus, the above path gives the location of a field name. If we removed +/// the last element: +/// [ 4, 3, 2, 7 ] +/// this path refers to the whole field declaration (from the beginning +/// of the label to the terminating semicolon). @property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *pathArray; +/// The number of items in @c pathArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger pathArray_Count; -// Always has exactly three or four elements: start line, start column, -// end line (optional, otherwise assumed same as start line), end column. -// These are packed into a single field for efficiency. Note that line -// and column numbers are zero-based -- typically you will want to add -// 1 to each before displaying to a user. +/// Always has exactly three or four elements: start line, start column, +/// end line (optional, otherwise assumed same as start line), end column. +/// These are packed into a single field for efficiency. Note that line +/// and column numbers are zero-based -- typically you will want to add +/// 1 to each before displaying to a user. @property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *spanArray; +/// The number of items in @c spanArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger spanArray_Count; -// If this SourceCodeInfo represents a complete declaration, these are any -// comments appearing before and after the declaration which appear to be -// attached to the declaration. -// -// A series of line comments appearing on consecutive lines, with no other -// tokens appearing on those lines, will be treated as a single comment. -// -// leading_detached_comments will keep paragraphs of comments that appear -// before (but not connected to) the current element. Each paragraph, -// separated by empty lines, will be one comment element in the repeated -// field. -// -// Only the comment content is provided; comment markers (e.g. //) are -// stripped out. For block comments, leading whitespace and an asterisk -// will be stripped from the beginning of each line other than the first. -// Newlines are included in the output. -// -// Examples: -// -// optional int32 foo = 1; // Comment attached to foo. -// // Comment attached to bar. -// optional int32 bar = 2; -// -// optional string baz = 3; -// // Comment attached to baz. -// // Another line attached to baz. -// -// // Comment attached to qux. -// // -// // Another line attached to qux. -// optional double qux = 4; -// -// // Detached comment for corge. This is not leading or trailing comments -// // to qux or corge because there are blank lines separating it from -// // both. -// -// // Detached comment for corge paragraph 2. -// -// optional string corge = 5; -// /* Block comment attached -// * to corge. Leading asterisks -// * will be removed. */ -// /* Block comment attached to -// * grault. */ -// optional int32 grault = 6; -// -// // ignored detached comments. -@property(nonatomic, readwrite) BOOL hasLeadingComments; +/// If this SourceCodeInfo represents a complete declaration, these are any +/// comments appearing before and after the declaration which appear to be +/// attached to the declaration. +/// +/// A series of line comments appearing on consecutive lines, with no other +/// tokens appearing on those lines, will be treated as a single comment. +/// +/// leading_detached_comments will keep paragraphs of comments that appear +/// before (but not connected to) the current element. Each paragraph, +/// separated by empty lines, will be one comment element in the repeated +/// field. +/// +/// Only the comment content is provided; comment markers (e.g. //) are +/// stripped out. For block comments, leading whitespace and an asterisk +/// will be stripped from the beginning of each line other than the first. +/// Newlines are included in the output. +/// +/// Examples: +/// +/// optional int32 foo = 1; // Comment attached to foo. +/// // Comment attached to bar. +/// optional int32 bar = 2; +/// +/// optional string baz = 3; +/// // Comment attached to baz. +/// // Another line attached to baz. +/// +/// // Comment attached to qux. +/// // +/// // Another line attached to qux. +/// optional double qux = 4; +/// +/// // Detached comment for corge. This is not leading or trailing comments +/// // to qux or corge because there are blank lines separating it from +/// // both. +/// +/// // Detached comment for corge paragraph 2. +/// +/// optional string corge = 5; +/// /* Block comment attached +/// * to corge. Leading asterisks +/// * will be removed. */ +/// /* Block comment attached to +/// * grault. */ +/// optional int32 grault = 6; +/// +/// // ignored detached comments. @property(nonatomic, readwrite, copy, null_resettable) NSString *leadingComments; +/// Test to see if @c leadingComments has been set. +@property(nonatomic, readwrite) BOOL hasLeadingComments; -@property(nonatomic, readwrite) BOOL hasTrailingComments; @property(nonatomic, readwrite, copy, null_resettable) NSString *trailingComments; +/// Test to see if @c trailingComments has been set. +@property(nonatomic, readwrite) BOOL hasTrailingComments; @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *leadingDetachedCommentsArray; +/// The number of items in @c leadingDetachedCommentsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger leadingDetachedCommentsArray_Count; @end @@ -1147,14 +1224,15 @@ typedef GPB_ENUM(GPBGeneratedCodeInfo_FieldNumber) { GPBGeneratedCodeInfo_FieldNumber_AnnotationArray = 1, }; -// Describes the relationship between generated code and its original source -// file. A GeneratedCodeInfo message is associated with only one generated -// source file, but may contain references to different source .proto files. +/// Describes the relationship between generated code and its original source +/// file. A GeneratedCodeInfo message is associated with only one generated +/// source file, but may contain references to different source .proto files. @interface GPBGeneratedCodeInfo : GPBMessage -// An Annotation connects some span of text in generated code to an element -// of its generating .proto file. +/// An Annotation connects some span of text in generated code to an element +/// of its generating .proto file. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *annotationArray; +/// The number of items in @c annotationArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger annotationArray_Count; @end @@ -1170,26 +1248,28 @@ typedef GPB_ENUM(GPBGeneratedCodeInfo_Annotation_FieldNumber) { @interface GPBGeneratedCodeInfo_Annotation : GPBMessage -// Identifies the element in the original source .proto file. This field -// is formatted the same as SourceCodeInfo.Location.path. +/// Identifies the element in the original source .proto file. This field +/// is formatted the same as SourceCodeInfo.Location.path. @property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *pathArray; +/// The number of items in @c pathArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger pathArray_Count; -// Identifies the filesystem path to the original source .proto. -@property(nonatomic, readwrite) BOOL hasSourceFile; +/// Identifies the filesystem path to the original source .proto. @property(nonatomic, readwrite, copy, null_resettable) NSString *sourceFile; +/// Test to see if @c sourceFile has been set. +@property(nonatomic, readwrite) BOOL hasSourceFile; -// Identifies the starting offset in bytes in the generated code -// that relates to the identified object. -@property(nonatomic, readwrite) BOOL hasBegin; +/// Identifies the starting offset in bytes in the generated code +/// that relates to the identified object. @property(nonatomic, readwrite) int32_t begin; -// Identifies the ending offset in bytes in the generated code that -// relates to the identified offset. The end offset should be one past -// the last relevant byte (so the length of the text = end - begin). -@property(nonatomic, readwrite) BOOL hasEnd; +@property(nonatomic, readwrite) BOOL hasBegin; +/// Identifies the ending offset in bytes in the generated code that +/// relates to the identified offset. The end offset should be one past +/// the last relevant byte (so the length of the text = end - begin). @property(nonatomic, readwrite) int32_t end; +@property(nonatomic, readwrite) BOOL hasEnd; @end NS_ASSUME_NONNULL_END diff --git a/objectivec/google/protobuf/Duration.pbobjc.h b/objectivec/google/protobuf/Duration.pbobjc.h index b592640b..ebf9119e 100644 --- a/objectivec/google/protobuf/Duration.pbobjc.h +++ b/objectivec/google/protobuf/Duration.pbobjc.h @@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBDurationRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBDurationRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBDuration @@ -31,58 +33,58 @@ typedef GPB_ENUM(GPBDuration_FieldNumber) { GPBDuration_FieldNumber_Nanos = 2, }; -// A Duration represents a signed, fixed-length span of time represented -// as a count of seconds and fractions of seconds at nanosecond -// resolution. It is independent of any calendar and concepts like "day" -// or "month". It is related to Timestamp in that the difference between -// two Timestamp values is a Duration and it can be added or subtracted -// from a Timestamp. Range is approximately +-10,000 years. -// -// Example 1: Compute Duration from two Timestamps in pseudo code. -// -// Timestamp start = ...; -// Timestamp end = ...; -// Duration duration = ...; -// -// duration.seconds = end.seconds - start.seconds; -// duration.nanos = end.nanos - start.nanos; -// -// if (duration.seconds < 0 && duration.nanos > 0) { -// duration.seconds += 1; -// duration.nanos -= 1000000000; -// } else if (durations.seconds > 0 && duration.nanos < 0) { -// duration.seconds -= 1; -// duration.nanos += 1000000000; -// } -// -// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. -// -// Timestamp start = ...; -// Duration duration = ...; -// Timestamp end = ...; -// -// end.seconds = start.seconds + duration.seconds; -// end.nanos = start.nanos + duration.nanos; -// -// if (end.nanos < 0) { -// end.seconds -= 1; -// end.nanos += 1000000000; -// } else if (end.nanos >= 1000000000) { -// end.seconds += 1; -// end.nanos -= 1000000000; -// } +/// A Duration represents a signed, fixed-length span of time represented +/// as a count of seconds and fractions of seconds at nanosecond +/// resolution. It is independent of any calendar and concepts like "day" +/// or "month". It is related to Timestamp in that the difference between +/// two Timestamp values is a Duration and it can be added or subtracted +/// from a Timestamp. Range is approximately +-10,000 years. +/// +/// Example 1: Compute Duration from two Timestamps in pseudo code. +/// +/// Timestamp start = ...; +/// Timestamp end = ...; +/// Duration duration = ...; +/// +/// duration.seconds = end.seconds - start.seconds; +/// duration.nanos = end.nanos - start.nanos; +/// +/// if (duration.seconds < 0 && duration.nanos > 0) { +/// duration.seconds += 1; +/// duration.nanos -= 1000000000; +/// } else if (durations.seconds > 0 && duration.nanos < 0) { +/// duration.seconds -= 1; +/// duration.nanos += 1000000000; +/// } +/// +/// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. +/// +/// Timestamp start = ...; +/// Duration duration = ...; +/// Timestamp end = ...; +/// +/// end.seconds = start.seconds + duration.seconds; +/// end.nanos = start.nanos + duration.nanos; +/// +/// if (end.nanos < 0) { +/// end.seconds -= 1; +/// end.nanos += 1000000000; +/// } else if (end.nanos >= 1000000000) { +/// end.seconds += 1; +/// end.nanos -= 1000000000; +/// } @interface GPBDuration : GPBMessage -// Signed seconds of the span of time. Must be from -315,576,000,000 -// to +315,576,000,000 inclusive. +/// Signed seconds of the span of time. Must be from -315,576,000,000 +/// to +315,576,000,000 inclusive. @property(nonatomic, readwrite) int64_t seconds; -// Signed fractions of a second at nanosecond resolution of the span -// of time. Durations less than one second are represented with a 0 -// `seconds` field and a positive or negative `nanos` field. For durations -// of one second or more, a non-zero value for the `nanos` field must be -// of the same sign as the `seconds` field. Must be from -999,999,999 -// to +999,999,999 inclusive. +/// Signed fractions of a second at nanosecond resolution of the span +/// of time. Durations less than one second are represented with a 0 +/// `seconds` field and a positive or negative `nanos` field. For durations +/// of one second or more, a non-zero value for the `nanos` field must be +/// of the same sign as the `seconds` field. Must be from -999,999,999 +/// to +999,999,999 inclusive. @property(nonatomic, readwrite) int32_t nanos; @end diff --git a/objectivec/google/protobuf/Empty.pbobjc.h b/objectivec/google/protobuf/Empty.pbobjc.h index bace614d..ca09f71d 100644 --- a/objectivec/google/protobuf/Empty.pbobjc.h +++ b/objectivec/google/protobuf/Empty.pbobjc.h @@ -15,26 +15,28 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBEmptyRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBEmptyRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBEmpty -// A generic empty message that you can re-use to avoid defining duplicated -// empty messages in your APIs. A typical example is to use it as the request -// or the response type of an API method. For instance: -// -// service Foo { -// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); -// } -// -// The JSON representation for `Empty` is empty JSON object `{}`. +/// A generic empty message that you can re-use to avoid defining duplicated +/// empty messages in your APIs. A typical example is to use it as the request +/// or the response type of an API method. For instance: +/// +/// service Foo { +/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); +/// } +/// +/// The JSON representation for `Empty` is empty JSON object `{}`. @interface GPBEmpty : GPBMessage @end diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.h b/objectivec/google/protobuf/FieldMask.pbobjc.h index f4bc2653..f861a986 100644 --- a/objectivec/google/protobuf/FieldMask.pbobjc.h +++ b/objectivec/google/protobuf/FieldMask.pbobjc.h @@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBFieldMaskRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBFieldMaskRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBFieldMask @@ -30,132 +32,133 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) { GPBFieldMask_FieldNumber_PathsArray = 1, }; -// `FieldMask` represents a set of symbolic field paths, for example: -// -// paths: "f.a" -// paths: "f.b.d" -// -// Here `f` represents a field in some root message, `a` and `b` -// fields in the message found in `f`, and `d` a field found in the -// message in `f.b`. -// -// Field masks are used to specify a subset of fields that should be -// returned by a get operation or modified by an update operation. -// 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 -// example is applied to a response message as follows: -// -// f { -// a : 22 -// b { -// d : 1 -// x : 2 -// } -// y : 13 -// } -// z: 8 -// -// The result will not contain specific values for fields x,y and z -// (their value will be set to the default, and omitted in proto text -// output): -// -// -// f { -// a : 22 -// b { -// d : 1 -// } -// } -// -// A repeated field is not allowed except at the last position of a -// field mask. -// -// If a FieldMask object is not present in a get operation, the -// operation applies to all fields (as if a FieldMask of all fields -// had been specified). -// -// Note that a field mask does not necessarily applies to the -// top-level response message. In case of a REST get operation, the -// field mask applies directly to the response, but in case of a REST -// list operation, the mask instead applies to each individual message -// in the returned resource list. In case of a REST custom method, -// other definitions may be used. Where the mask applies will be -// clearly documented together with its declaration in the API. In -// any case, the effect on the returned resource/resources is required -// 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 -// and leave the others untouched. If a resource is passed in to -// describe the updated values, the API ignores the values of all -// fields not covered by the mask. -// -// In order to reset a field's value to the default, the field must -// be in the mask and set to the default value in the provided resource. -// Hence, in order to reset all fields of a resource, provide a default -// instance of the resource and set all fields in the mask, or do -// not provide a mask as described below. -// -// If a field mask is not present on update, the operation applies to -// all fields (as if a field mask of all fields has been specified). -// Note that in the presence of schema evolution, this may mean that -// fields the client does not know and has therefore not filled into -// the request will be reset to their default. If this is unwanted -// behavior, a specific service may require a client to always specify -// a field mask, producing an error if not. -// -// As with get operations, the location of the resource which -// describes the updated values in the request message depends on the -// operation kind. In any case, the effect of the field mask is -// 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. -// -// As an example, consider the following message declarations: -// -// message Profile { -// User user = 1; -// Photo photo = 2; -// } -// message User { -// string display_name = 1; -// string address = 2; -// } -// -// In proto a field mask for `Profile` may look as such: -// -// mask { -// paths: "user.display_name" -// paths: "photo" -// } -// -// In JSON, the same mask is represented as below: -// -// { -// mask: "user.displayName,photo" -// } +/// `FieldMask` represents a set of symbolic field paths, for example: +/// +/// paths: "f.a" +/// paths: "f.b.d" +/// +/// Here `f` represents a field in some root message, `a` and `b` +/// fields in the message found in `f`, and `d` a field found in the +/// message in `f.b`. +/// +/// Field masks are used to specify a subset of fields that should be +/// returned by a get operation or modified by an update operation. +/// 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 +/// example is applied to a response message as follows: +/// +/// f { +/// a : 22 +/// b { +/// d : 1 +/// x : 2 +/// } +/// y : 13 +/// } +/// z: 8 +/// +/// The result will not contain specific values for fields x,y and z +/// (their value will be set to the default, and omitted in proto text +/// output): +/// +/// +/// f { +/// a : 22 +/// b { +/// d : 1 +/// } +/// } +/// +/// A repeated field is not allowed except at the last position of a +/// field mask. +/// +/// If a FieldMask object is not present in a get operation, the +/// operation applies to all fields (as if a FieldMask of all fields +/// had been specified). +/// +/// Note that a field mask does not necessarily applies to the +/// top-level response message. In case of a REST get operation, the +/// field mask applies directly to the response, but in case of a REST +/// list operation, the mask instead applies to each individual message +/// in the returned resource list. In case of a REST custom method, +/// other definitions may be used. Where the mask applies will be +/// clearly documented together with its declaration in the API. In +/// any case, the effect on the returned resource/resources is required +/// 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 +/// and leave the others untouched. If a resource is passed in to +/// describe the updated values, the API ignores the values of all +/// fields not covered by the mask. +/// +/// In order to reset a field's value to the default, the field must +/// be in the mask and set to the default value in the provided resource. +/// Hence, in order to reset all fields of a resource, provide a default +/// instance of the resource and set all fields in the mask, or do +/// not provide a mask as described below. +/// +/// If a field mask is not present on update, the operation applies to +/// all fields (as if a field mask of all fields has been specified). +/// Note that in the presence of schema evolution, this may mean that +/// fields the client does not know and has therefore not filled into +/// the request will be reset to their default. If this is unwanted +/// behavior, a specific service may require a client to always specify +/// a field mask, producing an error if not. +/// +/// As with get operations, the location of the resource which +/// describes the updated values in the request message depends on the +/// operation kind. In any case, the effect of the field mask is +/// 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. +/// +/// As an example, consider the following message declarations: +/// +/// message Profile { +/// User user = 1; +/// Photo photo = 2; +/// } +/// message User { +/// string display_name = 1; +/// string address = 2; +/// } +/// +/// In proto a field mask for `Profile` may look as such: +/// +/// mask { +/// paths: "user.display_name" +/// paths: "photo" +/// } +/// +/// In JSON, the same mask is represented as below: +/// +/// { +/// mask: "user.displayName,photo" +/// } @interface GPBFieldMask : GPBMessage -// The set of field mask paths. +/// The set of field mask paths. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *pathsArray; +/// The number of items in @c pathsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger pathsArray_Count; @end diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.h b/objectivec/google/protobuf/SourceContext.pbobjc.h index 8480db1d..546db674 100644 --- a/objectivec/google/protobuf/SourceContext.pbobjc.h +++ b/objectivec/google/protobuf/SourceContext.pbobjc.h @@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBSourceContextRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBSourceContextRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBSourceContext @@ -30,12 +32,12 @@ typedef GPB_ENUM(GPBSourceContext_FieldNumber) { GPBSourceContext_FieldNumber_FileName = 1, }; -// `SourceContext` represents information about the source of a -// protobuf element, like the file in which it is defined. +/// `SourceContext` represents information about the source of a +/// protobuf element, like the file in which it is defined. @interface GPBSourceContext : GPBMessage -// The path-qualified name of the .proto file that contained the associated -// protobuf element. For example: `"google/protobuf/source.proto"`. +/// The path-qualified name of the .proto file that contained the associated +/// protobuf element. For example: `"google/protobuf/source.proto"`. @property(nonatomic, readwrite, copy, null_resettable) NSString *fileName; @end diff --git a/objectivec/google/protobuf/Struct.pbobjc.h b/objectivec/google/protobuf/Struct.pbobjc.h index 293dea40..7b9c45a0 100644 --- a/objectivec/google/protobuf/Struct.pbobjc.h +++ b/objectivec/google/protobuf/Struct.pbobjc.h @@ -19,29 +19,36 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Enum GPBNullValue -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. +/// `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) { + /// Value used if any message's field encounters a value that is not defined + /// by this enum. The message will also have C functions to get/set the rawValue + /// of the field. GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, - // Null value. + /// Null value. GPBNullValue_NullValue = 0, }; GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBNullValue_IsValidValue(int32_t value); #pragma mark - GPBStructRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBStructRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBStruct @@ -50,18 +57,19 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) { GPBStruct_FieldNumber_Fields = 1, }; -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// 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. +/// `Struct` represents a structured data value, consisting of fields +/// which map to dynamically typed values. In some languages, `Struct` +/// might be supported by a native representation. For example, in +/// 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. +/// Map of dynamically typed values. @property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary *fields; +/// The number of items in @c fields without causing the array to be created. @property(nonatomic, readonly) NSUInteger fields_Count; @end @@ -87,40 +95,46 @@ typedef GPB_ENUM(GPBValue_Kind_OneOfCase) { GPBValue_Kind_OneOfCase_ListValue = 6, }; -// `Value` represents a dynamically typed value which can be either -// 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. +/// `Value` represents a dynamically typed value which can be either +/// 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. +/// The kind of value. @property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase; -// Represents a null value. +/// Represents a null value. @property(nonatomic, readwrite) GPBNullValue nullValue; -// Represents a double value. +/// Represents a double value. @property(nonatomic, readwrite) double numberValue; -// Represents a string value. +/// Represents a string value. @property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue; -// Represents a boolean value. +/// Represents a boolean value. @property(nonatomic, readwrite) BOOL boolValue; -// Represents a structured value. +/// Represents a structured value. @property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue; -// Represents a repeated `Value`. +/// Represents a repeated `Value`. @property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue; @end +/// Fetches the raw value of a @c GPBValue's @c nullValue property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBValue_NullValue_RawValue(GPBValue *message); +/// Sets the raw value of an @c GPBValue's @c nullValue property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value); +/// Clears whatever value was set for the oneof 'kind'. void GPBValue_ClearKindOneOfCase(GPBValue *message); #pragma mark - GPBListValue @@ -129,13 +143,14 @@ typedef GPB_ENUM(GPBListValue_FieldNumber) { GPBListValue_FieldNumber_ValuesArray = 1, }; -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. +/// `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. +/// Repeated field of dynamically typed values. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valuesArray; +/// The number of items in @c valuesArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger valuesArray_Count; @end diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.h b/objectivec/google/protobuf/Timestamp.pbobjc.h index 79b24ec6..d17c2860 100644 --- a/objectivec/google/protobuf/Timestamp.pbobjc.h +++ b/objectivec/google/protobuf/Timestamp.pbobjc.h @@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBTimestampRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBTimestampRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBTimestamp @@ -31,70 +33,70 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) { GPBTimestamp_FieldNumber_Nanos = 2, }; -// A Timestamp represents a point in time independent of any time zone -// or calendar, represented as seconds and fractions of seconds at -// nanosecond resolution in UTC Epoch time. It is encoded using the -// Proleptic Gregorian Calendar which extends the Gregorian calendar -// backwards to year one. It is encoded assuming all minutes are 60 -// seconds long, i.e. leap seconds are "smeared" so that no leap second -// table is needed for interpretation. Range is from -// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. -// By restricting to that range, we ensure that we can convert to -// and from RFC 3339 date strings. -// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). -// -// Example 1: Compute Timestamp from POSIX `time()`. -// -// Timestamp timestamp; -// timestamp.set_seconds(time(NULL)); -// timestamp.set_nanos(0); -// -// Example 2: Compute Timestamp from POSIX `gettimeofday()`. -// -// struct timeval tv; -// gettimeofday(&tv, NULL); -// -// Timestamp timestamp; -// timestamp.set_seconds(tv.tv_sec); -// timestamp.set_nanos(tv.tv_usec * 1000); -// -// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. -// -// FILETIME ft; -// GetSystemTimeAsFileTime(&ft); -// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; -// -// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z -// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. -// Timestamp timestamp; -// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); -// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); -// -// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. -// -// long millis = System.currentTimeMillis(); -// -// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) -// .setNanos((int) ((millis % 1000) * 1000000)).build(); -// -// -// 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) +/// A Timestamp represents a point in time independent of any time zone +/// or calendar, represented as seconds and fractions of seconds at +/// nanosecond resolution in UTC Epoch time. It is encoded using the +/// Proleptic Gregorian Calendar which extends the Gregorian calendar +/// backwards to year one. It is encoded assuming all minutes are 60 +/// seconds long, i.e. leap seconds are "smeared" so that no leap second +/// table is needed for interpretation. Range is from +/// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. +/// By restricting to that range, we ensure that we can convert to +/// and from RFC 3339 date strings. +/// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). +/// +/// Example 1: Compute Timestamp from POSIX `time()`. +/// +/// Timestamp timestamp; +/// timestamp.set_seconds(time(NULL)); +/// timestamp.set_nanos(0); +/// +/// Example 2: Compute Timestamp from POSIX `gettimeofday()`. +/// +/// struct timeval tv; +/// gettimeofday(&tv, NULL); +/// +/// Timestamp timestamp; +/// timestamp.set_seconds(tv.tv_sec); +/// timestamp.set_nanos(tv.tv_usec * 1000); +/// +/// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. +/// +/// FILETIME ft; +/// GetSystemTimeAsFileTime(&ft); +/// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; +/// +/// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z +/// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. +/// Timestamp timestamp; +/// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); +/// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); +/// +/// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. +/// +/// long millis = System.currentTimeMillis(); +/// +/// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) +/// .setNanos((int) ((millis % 1000) * 1000000)).build(); +/// +/// +/// 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 -// Represents seconds of UTC time since Unix epoch -// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to -// 9999-12-31T23:59:59Z inclusive. +/// Represents seconds of UTC time since Unix epoch +/// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to +/// 9999-12-31T23:59:59Z inclusive. @property(nonatomic, readwrite) int64_t seconds; -// Non-negative fractions of a second at nanosecond resolution. Negative -// second values with fractions must still have non-negative nanos values -// that count forward in time. Must be from 0 to 999,999,999 -// inclusive. +/// Non-negative fractions of a second at nanosecond resolution. Negative +/// second values with fractions must still have non-negative nanos values +/// that count forward in time. Must be from 0 to 999,999,999 +/// inclusive. @property(nonatomic, readwrite) int32_t nanos; @end diff --git a/objectivec/google/protobuf/Type.pbobjc.h b/objectivec/google/protobuf/Type.pbobjc.h index a7d03a2a..9301e4f4 100644 --- a/objectivec/google/protobuf/Type.pbobjc.h +++ b/objectivec/google/protobuf/Type.pbobjc.h @@ -21,118 +21,135 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Enum GPBSyntax -// The syntax in which a protocol buffer element is defined. +/// The syntax in which a protocol buffer element is defined. typedef GPB_ENUM(GPBSyntax) { + /// Value used if any message's field encounters a value that is not defined + /// by this enum. The message will also have C functions to get/set the rawValue + /// of the field. GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, - // Syntax `proto2`. + /// Syntax `proto2`. GPBSyntax_SyntaxProto2 = 0, - // Syntax `proto3`. + /// Syntax `proto3`. GPBSyntax_SyntaxProto3 = 1, }; GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBSyntax_IsValidValue(int32_t value); #pragma mark - Enum GPBField_Kind -// Basic field types. +/// Basic field types. typedef GPB_ENUM(GPBField_Kind) { + /// Value used if any message's field encounters a value that is not defined + /// by this enum. The message will also have C functions to get/set the rawValue + /// of the field. GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, - // Field type unknown. + /// Field type unknown. GPBField_Kind_TypeUnknown = 0, - // Field type double. + /// Field type double. GPBField_Kind_TypeDouble = 1, - // Field type float. + /// Field type float. GPBField_Kind_TypeFloat = 2, - // Field type int64. + /// Field type int64. GPBField_Kind_TypeInt64 = 3, - // Field type uint64. + /// Field type uint64. GPBField_Kind_TypeUint64 = 4, - // Field type int32. + /// Field type int32. GPBField_Kind_TypeInt32 = 5, - // Field type fixed64. + /// Field type fixed64. GPBField_Kind_TypeFixed64 = 6, - // Field type fixed32. + /// Field type fixed32. GPBField_Kind_TypeFixed32 = 7, - // Field type bool. + /// Field type bool. GPBField_Kind_TypeBool = 8, - // Field type string. + /// Field type string. GPBField_Kind_TypeString = 9, - // Field type group. Proto2 syntax only, and deprecated. + /// Field type group. Proto2 syntax only, and deprecated. GPBField_Kind_TypeGroup = 10, - // Field type message. + /// Field type message. GPBField_Kind_TypeMessage = 11, - // Field type bytes. + /// Field type bytes. GPBField_Kind_TypeBytes = 12, - // Field type uint32. + /// Field type uint32. GPBField_Kind_TypeUint32 = 13, - // Field type enum. + /// Field type enum. GPBField_Kind_TypeEnum = 14, - // Field type sfixed32. + /// Field type sfixed32. GPBField_Kind_TypeSfixed32 = 15, - // Field type sfixed64. + /// Field type sfixed64. GPBField_Kind_TypeSfixed64 = 16, - // Field type sint32. + /// Field type sint32. GPBField_Kind_TypeSint32 = 17, - // Field type sint64. + /// Field type sint64. GPBField_Kind_TypeSint64 = 18, }; GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBField_Kind_IsValidValue(int32_t value); #pragma mark - Enum GPBField_Cardinality -// Whether a field is optional, required, or repeated. +/// Whether a field is optional, required, or repeated. typedef GPB_ENUM(GPBField_Cardinality) { + /// Value used if any message's field encounters a value that is not defined + /// by this enum. The message will also have C functions to get/set the rawValue + /// of the field. GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, - // For fields with unknown cardinality. + /// For fields with unknown cardinality. GPBField_Cardinality_CardinalityUnknown = 0, - // For optional fields. + /// For optional fields. GPBField_Cardinality_CardinalityOptional = 1, - // For required fields. Proto2 syntax only. + /// For required fields. Proto2 syntax only. GPBField_Cardinality_CardinalityRequired = 2, - // For repeated fields. + /// For repeated fields. GPBField_Cardinality_CardinalityRepeated = 3, }; GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void); +/// Checks to see if the given value is defined by the enum or was not known at +/// the time this source was generated. BOOL GPBField_Cardinality_IsValidValue(int32_t value); #pragma mark - GPBTypeRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBTypeRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBType @@ -146,34 +163,43 @@ typedef GPB_ENUM(GPBType_FieldNumber) { GPBType_FieldNumber_Syntax = 6, }; -// A protocol buffer message type. +/// A protocol buffer message type. @interface GPBType : GPBMessage -// The fully qualified message name. +/// The fully qualified message name. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// The list of fields. +/// The list of fields. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldsArray; +/// The number of items in @c fieldsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger fieldsArray_Count; -// The list of types appearing in `oneof` definitions in this type. +/// The list of types appearing in `oneof` definitions in this type. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofsArray; +/// The number of items in @c oneofsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger oneofsArray_Count; -// The protocol buffer options. +/// The protocol buffer options. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/// The number of items in @c optionsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger optionsArray_Count; -// The source context. -@property(nonatomic, readwrite) BOOL hasSourceContext; +/// The source context. @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext; +/// Test to see if @c sourceContext has been set. +@property(nonatomic, readwrite) BOOL hasSourceContext; -// The source syntax. +/// The source syntax. @property(nonatomic, readwrite) GPBSyntax syntax; @end +/// Fetches the raw value of a @c GPBType's @c syntax property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBType_Syntax_RawValue(GPBType *message); +/// Sets the raw value of an @c GPBType's @c syntax property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value); #pragma mark - GPBField @@ -191,48 +217,59 @@ typedef GPB_ENUM(GPBField_FieldNumber) { GPBField_FieldNumber_DefaultValue = 11, }; -// A single field of a message type. +/// A single field of a message type. @interface GPBField : GPBMessage -// The field type. +/// The field type. @property(nonatomic, readwrite) GPBField_Kind kind; -// The field cardinality. +/// The field cardinality. @property(nonatomic, readwrite) GPBField_Cardinality cardinality; -// The field number. +/// The field number. @property(nonatomic, readwrite) int32_t number; -// The field name. +/// The field name. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// The field type URL, without the scheme, for message or enumeration -// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. +/// The field type URL, without the scheme, for message or enumeration +/// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL; -// The index of the field type in `Type.oneofs`, for message or enumeration -// types. The first type has index 1; zero means the type is not in the list. +/// The index of the field type in `Type.oneofs`, for message or enumeration +/// types. The first type has index 1; zero means the type is not in the list. @property(nonatomic, readwrite) int32_t oneofIndex; -// Whether to use alternative packed wire representation. +/// Whether to use alternative packed wire representation. @property(nonatomic, readwrite) BOOL packed; -// The protocol buffer options. +/// The protocol buffer options. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/// The number of items in @c optionsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger optionsArray_Count; -// The field JSON name. +/// The field JSON name. @property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName; -// The string value of the default value of this field. Proto2 syntax only. +/// The string value of the default value of this field. Proto2 syntax only. @property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue; @end +/// Fetches the raw value of a @c GPBField's @c kind property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBField_Kind_RawValue(GPBField *message); +/// Sets the raw value of an @c GPBField's @c kind property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBField_Kind_RawValue(GPBField *message, int32_t value); +/// Fetches the raw value of a @c GPBField's @c cardinality property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBField_Cardinality_RawValue(GPBField *message); +/// Sets the raw value of an @c GPBField's @c cardinality property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value); #pragma mark - GPBEnum @@ -245,30 +282,38 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) { GPBEnum_FieldNumber_Syntax = 5, }; -// Enum type definition. +/// Enum type definition. @interface GPBEnum : GPBMessage -// Enum type name. +/// Enum type name. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// Enum value definitions. +/// Enum value definitions. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumvalueArray; +/// The number of items in @c enumvalueArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger enumvalueArray_Count; -// Protocol buffer options. +/// Protocol buffer options. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/// The number of items in @c optionsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger optionsArray_Count; -// The source context. -@property(nonatomic, readwrite) BOOL hasSourceContext; +/// The source context. @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext; +/// Test to see if @c sourceContext has been set. +@property(nonatomic, readwrite) BOOL hasSourceContext; -// The source syntax. +/// The source syntax. @property(nonatomic, readwrite) GPBSyntax syntax; @end +/// Fetches the raw value of a @c GPBEnum's @c syntax property, even +/// if the value was not defined by the enum at the time the code was generated. int32_t GPBEnum_Syntax_RawValue(GPBEnum *message); +/// Sets the raw value of an @c GPBEnum's @c syntax property, allowing +/// it to be set to a value that was not defined by the enum at the time the code +/// was generated. void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value); #pragma mark - GPBEnumValue @@ -279,17 +324,18 @@ typedef GPB_ENUM(GPBEnumValue_FieldNumber) { GPBEnumValue_FieldNumber_OptionsArray = 3, }; -// Enum value definition. +/// Enum value definition. @interface GPBEnumValue : GPBMessage -// Enum value name. +/// Enum value name. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// Enum value number. +/// Enum value number. @property(nonatomic, readwrite) int32_t number; -// Protocol buffer options. +/// Protocol buffer options. @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/// The number of items in @c optionsArray without causing the array to be created. @property(nonatomic, readonly) NSUInteger optionsArray_Count; @end @@ -301,16 +347,17 @@ typedef GPB_ENUM(GPBOption_FieldNumber) { GPBOption_FieldNumber_Value = 2, }; -// A protocol buffer option, which can be attached to a message, field, -// enumeration, etc. +/// A protocol buffer option, which can be attached to a message, field, +/// enumeration, etc. @interface GPBOption : GPBMessage -// The option's name. For example, `"java_package"`. +/// The option's name. For example, `"java_package"`. @property(nonatomic, readwrite, copy, null_resettable) NSString *name; -// The option's value. For example, `"com.google.protobuf"`. -@property(nonatomic, readwrite) BOOL hasValue; +/// The option's value. For example, `"com.google.protobuf"`. @property(nonatomic, readwrite, strong, null_resettable) GPBAny *value; +/// Test to see if @c value has been set. +@property(nonatomic, readwrite) BOOL hasValue; @end diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.h b/objectivec/google/protobuf/Wrappers.pbobjc.h index 580945c4..38b99622 100644 --- a/objectivec/google/protobuf/Wrappers.pbobjc.h +++ b/objectivec/google/protobuf/Wrappers.pbobjc.h @@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - GPBWrappersRoot +/// Exposes the extension registry for this file. +/// +/// The base class provides: +/// @code +/// + (GPBExtensionRegistry *)extensionRegistry; +/// @endcode +/// which is a @c GPBExtensionRegistry that includes all the extensions defined by +/// this file and all files that it depends on. @interface GPBWrappersRoot : GPBRootObject - -// The base class provides: -// + (GPBExtensionRegistry *)extensionRegistry; -// which is an GPBExtensionRegistry that includes all the extensions defined by -// this file and all files that it depends on. - @end #pragma mark - GPBDoubleValue @@ -30,12 +32,12 @@ typedef GPB_ENUM(GPBDoubleValue_FieldNumber) { GPBDoubleValue_FieldNumber_Value = 1, }; -// Wrapper message for `double`. -// -// The JSON representation for `DoubleValue` is JSON number. +/// Wrapper message for `double`. +/// +/// The JSON representation for `DoubleValue` is JSON number. @interface GPBDoubleValue : GPBMessage -// The double value. +/// The double value. @property(nonatomic, readwrite) double value; @end @@ -46,12 +48,12 @@ typedef GPB_ENUM(GPBFloatValue_FieldNumber) { GPBFloatValue_FieldNumber_Value = 1, }; -// Wrapper message for `float`. -// -// The JSON representation for `FloatValue` is JSON number. +/// Wrapper message for `float`. +/// +/// The JSON representation for `FloatValue` is JSON number. @interface GPBFloatValue : GPBMessage -// The float value. +/// The float value. @property(nonatomic, readwrite) float value; @end @@ -62,12 +64,12 @@ typedef GPB_ENUM(GPBInt64Value_FieldNumber) { GPBInt64Value_FieldNumber_Value = 1, }; -// Wrapper message for `int64`. -// -// The JSON representation for `Int64Value` is JSON string. +/// Wrapper message for `int64`. +/// +/// The JSON representation for `Int64Value` is JSON string. @interface GPBInt64Value : GPBMessage -// The int64 value. +/// The int64 value. @property(nonatomic, readwrite) int64_t value; @end @@ -78,12 +80,12 @@ typedef GPB_ENUM(GPBUInt64Value_FieldNumber) { GPBUInt64Value_FieldNumber_Value = 1, }; -// Wrapper message for `uint64`. -// -// The JSON representation for `UInt64Value` is JSON string. +/// Wrapper message for `uint64`. +/// +/// The JSON representation for `UInt64Value` is JSON string. @interface GPBUInt64Value : GPBMessage -// The uint64 value. +/// The uint64 value. @property(nonatomic, readwrite) uint64_t value; @end @@ -94,12 +96,12 @@ typedef GPB_ENUM(GPBInt32Value_FieldNumber) { GPBInt32Value_FieldNumber_Value = 1, }; -// Wrapper message for `int32`. -// -// The JSON representation for `Int32Value` is JSON number. +/// Wrapper message for `int32`. +/// +/// The JSON representation for `Int32Value` is JSON number. @interface GPBInt32Value : GPBMessage -// The int32 value. +/// The int32 value. @property(nonatomic, readwrite) int32_t value; @end @@ -110,12 +112,12 @@ typedef GPB_ENUM(GPBUInt32Value_FieldNumber) { GPBUInt32Value_FieldNumber_Value = 1, }; -// Wrapper message for `uint32`. -// -// The JSON representation for `UInt32Value` is JSON number. +/// Wrapper message for `uint32`. +/// +/// The JSON representation for `UInt32Value` is JSON number. @interface GPBUInt32Value : GPBMessage -// The uint32 value. +/// The uint32 value. @property(nonatomic, readwrite) uint32_t value; @end @@ -126,12 +128,12 @@ typedef GPB_ENUM(GPBBoolValue_FieldNumber) { GPBBoolValue_FieldNumber_Value = 1, }; -// Wrapper message for `bool`. -// -// The JSON representation for `BoolValue` is JSON `true` and `false`. +/// Wrapper message for `bool`. +/// +/// The JSON representation for `BoolValue` is JSON `true` and `false`. @interface GPBBoolValue : GPBMessage -// The bool value. +/// The bool value. @property(nonatomic, readwrite) BOOL value; @end @@ -142,12 +144,12 @@ typedef GPB_ENUM(GPBStringValue_FieldNumber) { GPBStringValue_FieldNumber_Value = 1, }; -// Wrapper message for `string`. -// -// The JSON representation for `StringValue` is JSON string. +/// Wrapper message for `string`. +/// +/// The JSON representation for `StringValue` is JSON string. @interface GPBStringValue : GPBMessage -// The string value. +/// The string value. @property(nonatomic, readwrite, copy, null_resettable) NSString *value; @end @@ -158,12 +160,12 @@ typedef GPB_ENUM(GPBBytesValue_FieldNumber) { GPBBytesValue_FieldNumber_Value = 1, }; -// Wrapper message for `bytes`. -// -// The JSON representation for `BytesValue` is JSON string. +/// Wrapper message for `bytes`. +/// +/// The JSON representation for `BytesValue` is JSON string. @interface GPBBytesValue : GPBMessage -// The bytes value. +/// The bytes value. @property(nonatomic, readwrite, copy, null_resettable) NSData *value; @end diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index d6f01c60..857d24a4 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -80,10 +80,12 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { if (HasPreservingUnknownEnumSemantics(descriptor_->file())) { // Include the unknown value. printer->Print( + "/// Value used if any message's field encounters a value that is not defined\n" + "/// by this enum. The message will also have C functions to get/set the rawValue\n" + "/// of the field.\n" "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n", "name", name_); } - for (int i = 0; i < all_values_.size(); i++) { SourceLocation location; if (all_values_[i]->GetSourceLocation(&location)) { @@ -107,6 +109,8 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { "\n" "GPBEnumDescriptor *$name$_EnumDescriptor(void);\n" "\n" + "/// Checks to see if the given value is defined by the enum or was not known at\n" + "/// the time this source was generated.\n" "BOOL $name$_IsValidValue(int32_t value);\n" "\n", "name", name_); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc index ecc77f6b..cfbb8c52 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc @@ -87,7 +87,12 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations( printer->Print( variables_, + "/// Fetches the raw value of a @c $owning_message_class$'s @c $name$ property, even\n" + "/// if the value was not defined by the enum at the time the code was generated.\n" "int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message);\n" + "/// Sets the raw value of an @c $owning_message_class$'s @c $name$ property, allowing\n" + "/// it to be set to a value that was not defined by the enum at the time the code\n" + "/// was generated.\n" "void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value);\n" "\n"); } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 09341820..8697e225 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -270,15 +270,15 @@ void SingleFieldGenerator::GenerateFieldStorageDeclaration( void SingleFieldGenerator::GeneratePropertyDeclaration( io::Printer* printer) const { printer->Print(variables_, "$comments$"); + printer->Print( + variables_, + "@property(nonatomic, readwrite) $property_type$ $name$;\n" + "\n"); if (WantsHasProperty()) { printer->Print( variables_, "@property(nonatomic, readwrite) BOOL has$capitalized_name$;\n"); } - printer->Print( - variables_, - "@property(nonatomic, readwrite) $property_type$ $name$;\n" - "\n"); } void SingleFieldGenerator::GeneratePropertyImplementation( @@ -326,14 +326,15 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration( // conventions (init*, new*, etc.) printer->Print(variables_, "$comments$"); + printer->Print( + variables_, + "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;\n"); if (WantsHasProperty()) { printer->Print( variables_, + "/// Test to see if @c $name$ has been set.\n" "@property(nonatomic, readwrite) BOOL has$capitalized_name$;\n"); } - printer->Print( - variables_, - "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;\n"); if (IsInitName(variables_.find("name")->second)) { // If property name starts with init we need to annotate it to get past ARC. // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227 @@ -385,6 +386,7 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration( "$comments$" "$array_comment$" "@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$;\n" + "/// The number of items in @c $name$ without causing the array to be created.\n" "@property(nonatomic, readonly) NSUInteger $name$_Count;\n"); if (IsInitName(variables_.find("name")->second)) { // If property name starts with init we need to annotate it to get past ARC. diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index cdf9ebbc..16199884 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -151,13 +151,15 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { printer->Print( "#pragma mark - $root_class_name$\n" "\n" + "/// Exposes the extension registry for this file.\n" + "///\n" + "/// The base class provides:\n" + "/// @code\n" + "/// + (GPBExtensionRegistry *)extensionRegistry;\n" + "/// @endcode\n" + "/// which is a @c GPBExtensionRegistry that includes all the extensions defined by\n" + "/// this file and all files that it depends on.\n" "@interface $root_class_name$ : GPBRootObject\n" - "\n" - "// The base class provides:\n" - "// + (GPBExtensionRegistry *)extensionRegistry;\n" - "// which is an GPBExtensionRegistry that includes all the extensions defined by\n" - "// this file and all files that it depends on.\n" - "\n" "@end\n" "\n", "root_class_name", root_class_name_); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index 77a378c8..24ff2b56 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -771,16 +771,14 @@ string BuildCommentsString(const SourceLocation& location) { while (!lines.empty() && lines.back().empty()) { lines.pop_back(); } - string prefix("//"); + string prefix("///"); string suffix("\n"); string final_comments; for (int i = 0; i < lines.size(); i++) { - // We use $ for delimiters, so replace comments with dollars with - // html escaped version. - // None of the other compilers handle this (as of this writing) but we - // ran into it once, so just to be safe. + // HeaderDoc uses '\' and '@' for markers; escape them. + const string line = StringReplace(lines[i], "\\", "\\\\", true); final_comments += - prefix + StringReplace(lines[i], "$", "$", true) + suffix; + prefix + StringReplace(line, "@", "\\@", true) + suffix; } return final_comments; } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index 5b2dd190..a301493e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -146,6 +146,7 @@ string DefaultValue(const FieldDescriptor* field); string BuildFlagsString(const vector& strings); +// Builds a HeaderDoc style comment out of the comments in the .proto file. string BuildCommentsString(const SourceLocation& location); // Checks the prefix for a given file and outputs any warnings needed, if diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc index 3cb87482..24e6df07 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc @@ -104,6 +104,7 @@ void OneofGenerator::GeneratePublicCasePropertyDeclaration( void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) { printer->Print( variables_, + "/// Clears whatever value was set for the oneof '$name$'.\n" "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message);\n"); } -- cgit v1.2.3 From 1bf4b38f29d6cc3f24ad1e0b6c3339420bd719be Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 8 Mar 2016 09:29:49 -0500 Subject: Fix up handing of fields with leading names that should be all caps. Add a compile test to confirm things are working as expected. --- Makefile.am | 1 + objectivec/Tests/GPBMessageTests.m | 18 ++++++++++++++++++ objectivec/Tests/unittest_objc.proto | 12 ++++++++++++ .../protobuf/compiler/objectivec/objectivec_helpers.cc | 15 +++++++++------ 4 files changed, 40 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/Makefile.am b/Makefile.am index 3e21db89..064efdfb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -413,6 +413,7 @@ objectivec_EXTRA_DIST= \ objectivec/GPBCodedInputStream_PackagePrivate.h \ objectivec/GPBCodedOutputStream.h \ objectivec/GPBCodedOutputStream.m \ + objectivec/GPBCodedOutputStream_PackagePrivate.h \ objectivec/GPBDescriptor.h \ objectivec/GPBDescriptor.m \ objectivec/GPBDescriptor_PackagePrivate.h \ diff --git a/objectivec/Tests/GPBMessageTests.m b/objectivec/Tests/GPBMessageTests.m index 7b37ca95..43546156 100644 --- a/objectivec/Tests/GPBMessageTests.m +++ b/objectivec/Tests/GPBMessageTests.m @@ -1820,6 +1820,24 @@ XCTAssertEqualObjects(enumDescriptor, expectedDescriptor); } +- (void)testPropertyNaming { + // objectivec_helpers.cc has some special handing to get proper all caps + // for a few cases to meet objc developer expectations. + // + // This "test" confirms that the expected names are generated, otherwise the + // test itself will fail to compile. + ObjCPropertyNaming *msg = [ObjCPropertyNaming message]; + // On their own, at the end, in the middle. + msg.URL = @"good"; + msg.thumbnailURL = @"good"; + msg.URLFoo = @"good"; + msg.someURLBlah = @"good"; + msg.HTTP = @"good"; + msg.HTTPS = @"good"; + // No caps since it was "urls". + [msg.urlsArray addObject:@"good"]; +} + - (void)testEnumNaming { // objectivec_helpers.cc has some interesting cases to deal with in // EnumValueName/EnumValueShortName. Confirm that things generated as diff --git a/objectivec/Tests/unittest_objc.proto b/objectivec/Tests/unittest_objc.proto index 3bb92761..9483cb1d 100644 --- a/objectivec/Tests/unittest_objc.proto +++ b/objectivec/Tests/unittest_objc.proto @@ -112,6 +112,18 @@ enum retain { serializedSize = 6; } +message ObjCPropertyNaming { + // Test that the properties properly get things all caps. + optional string url = 1; + optional string thumbnail_url = 2; + optional string url_foo = 3; + optional string some_url_blah = 4; + optional string http = 5; + optional string https = 6; + // This one doesn't. + repeated string urls = 7; +} + // EnumValueShortName: The short names shouldn't get suffixes/prefixes. enum Foo { SERIALIZED_SIZE = 1; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index 24ff2b56..613a511c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -124,9 +124,14 @@ string UnderscoresToCamelCase(const string& input, bool first_capitalized) { } values.push_back(current); + string result; + bool first_segment_forces_upper = false; for (vector::iterator i = values.begin(); i != values.end(); ++i) { string value = *i; bool all_upper = (kUpperSegments.count(value) > 0); + if (all_upper && (result.length() == 0)) { + first_segment_forces_upper = true; + } for (int j = 0; j < value.length(); j++) { if (j == 0 || all_upper) { value[j] = ascii_toupper(value[j]); @@ -134,13 +139,11 @@ string UnderscoresToCamelCase(const string& input, bool first_capitalized) { // Nothing, already in lower. } } - *i = value; - } - string result; - for (vector::iterator i = values.begin(); i != values.end(); ++i) { - result += *i; + result += value; } - if ((result.length() != 0) && !first_capitalized) { + if ((result.length() != 0) && + !first_capitalized && + !first_segment_forces_upper) { result[0] = ascii_tolower(result[0]); } return result; -- cgit v1.2.3 From e2fb1d982291bfc87693d8a0744213ef22a75c14 Mon Sep 17 00:00:00 2001 From: Antal Tátrai Date: Tue, 8 Mar 2016 20:01:42 +0100 Subject: Comment has been added to fix (issue #1266) --- src/google/protobuf/map.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 9dd42572..37e19b0a 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -548,6 +548,10 @@ class Map { !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) template void construct(NodeType* p, Args&&... args) { + // Clang 3.6 doesn't compile static casting to void* directly. (Issue #1266) + // According C++ standard 5.2.9/1: "The static_cast operator shall not cast + // away constness". So first the maybe const pointer is casted to const void* and + // after the const void* is const casted. new (const_cast(static_cast(p))) NodeType(std::forward(args)...); } -- cgit v1.2.3 From 58f07644eab25f68973ecab4bdc43fc318c26131 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 11 Mar 2016 09:19:58 -0800 Subject: Fixing compilation error when building with emscripten. This change was previously done in //third_party in CL 108656107 but never made it to the open source project and was overwritten in an update. --- src/google/protobuf/map.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 37e19b0a..83199380 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -545,7 +545,9 @@ class Map { } #if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \ - !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID) + !defined(GOOGLE_PROTOBUF_OS_NACL) && \ + !defined(GOOGLE_PROTOBUF_OS_ANDROID) && \ + !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN) template void construct(NodeType* p, Args&&... args) { // Clang 3.6 doesn't compile static casting to void* directly. (Issue #1266) -- cgit v1.2.3 From 79a23c435c4862d0c7af3c2740662104c77171dc Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 17 Mar 2016 10:04:21 -0400 Subject: Shrink ObjC overhead (generated size and some runtime sizes) NOTE: This is a binary breaking change as structure sizes have changed size and/or order. - Drop capturing field options, no other options were captured and other mobile targeted languages don't try to capture this sort information (saved 8 bytes for every field defined (in static data and again in field descriptor instance size data). - No longer generate/compile in the messages/enums in descriptor.proto. If developers need it, they should generate it and compile it in. Reduced the overhead of the core library. - Compute the number of has_bits actually needs to avoid over reserving. - Let the boolean single fields store via a has_bit to avoid storage, makes the common cases of the instance size smaller. - Reorder some flags and down size the enums to contain the bits needed. - Reorder the items in the structures to manually ensure they are are packed better (especially when generating 64bit code - 8 bytes for every field, 16 bytes for every extension, instance sizes 8 bytes also). - Split off the structure initialization so when the default is zero, the generated static storage doesn't need to reserve the space. This is batched at the message level, so all the fields for the message have to have zero defaults to get the saves. By definition all proto3 syntax files fall into this case but it also saves space for the proto2 that use the standard defaults. (saves 8 bytes of static data for every field that had a zero default) - Don't track the enums defined by a message. Nothing in the runtime needs it and it was just generation and runtime overhead. (saves 8 bytes per enum) - Ensure EnumDescriptors are started up threadsafe in all cases. - Split some of the Descriptor initialization into multiple methods so the generated code isn't padded with lots of zero/nil args. - Change how oneof info is feed to the runtime enabling us to generate less static data (8 bytes saved per oneof for 64bit). - Change how enum value informat is capture to pack the data and only decode it if it ends up being needed. Avoids padding issues causing bloat of 64bit, and removes the needs for extra pointers in addition to the data (just the data and one pointer now). --- Makefile.am | 4 +- Protobuf.podspec | 1 - generate_descriptor_proto.sh | 4 +- objectivec/DevTools/compile_testing_protos.sh | 65 +- objectivec/DevTools/full_mac_build.sh | 4 +- objectivec/GPBBootstrap.h | 9 +- objectivec/GPBDescriptor.h | 11 +- objectivec/GPBDescriptor.m | 360 ++- objectivec/GPBDescriptor_PackagePrivate.h | 183 +- objectivec/GPBMessage.m | 22 +- objectivec/GPBProtocolBuffers.m | 2 - objectivec/GPBRuntimeTypes.h | 4 +- objectivec/GPBUtilities.m | 64 +- objectivec/GPBUtilities_PackagePrivate.h | 2 +- .../ProtocolBuffers_OSX.xcodeproj/project.pbxproj | 10 - .../ProtocolBuffers_iOS.xcodeproj/project.pbxproj | 10 - objectivec/Tests/GPBARCUnittestProtos.m | 5 + objectivec/Tests/GPBDescriptorTests.m | 13 - objectivec/Tests/GPBUnittestProtos.m | 5 + objectivec/generate_descriptors_proto.sh | 50 - objectivec/generate_well_known_types.sh | 49 + objectivec/google/protobuf/Any.pbobjc.h | 2 +- objectivec/google/protobuf/Any.pbobjc.m | 33 +- objectivec/google/protobuf/Api.pbobjc.h | 2 +- objectivec/google/protobuf/Api.pbobjc.m | 151 +- objectivec/google/protobuf/Descriptor.pbobjc.h | 1279 ---------- objectivec/google/protobuf/Descriptor.pbobjc.m | 2594 -------------------- objectivec/google/protobuf/Duration.pbobjc.h | 2 +- objectivec/google/protobuf/Duration.pbobjc.m | 22 +- objectivec/google/protobuf/Empty.pbobjc.h | 2 +- objectivec/google/protobuf/Empty.pbobjc.m | 10 +- objectivec/google/protobuf/FieldMask.pbobjc.h | 2 +- objectivec/google/protobuf/FieldMask.pbobjc.m | 16 +- objectivec/google/protobuf/SourceContext.pbobjc.h | 2 +- objectivec/google/protobuf/SourceContext.pbobjc.m | 16 +- objectivec/google/protobuf/Struct.pbobjc.h | 2 +- objectivec/google/protobuf/Struct.pbobjc.m | 112 +- objectivec/google/protobuf/Timestamp.pbobjc.h | 2 +- objectivec/google/protobuf/Timestamp.pbobjc.m | 22 +- objectivec/google/protobuf/Type.pbobjc.h | 2 +- objectivec/google/protobuf/Type.pbobjc.m | 337 ++- objectivec/google/protobuf/Wrappers.pbobjc.h | 2 +- objectivec/google/protobuf/Wrappers.pbobjc.m | 145 +- .../compiler/objectivec/objectivec_enum.cc | 65 +- .../compiler/objectivec/objectivec_enum_field.cc | 17 +- .../compiler/objectivec/objectivec_enum_field.h | 2 - .../compiler/objectivec/objectivec_extension.cc | 8 +- .../compiler/objectivec/objectivec_field.cc | 140 +- .../compiler/objectivec/objectivec_field.h | 20 +- .../compiler/objectivec/objectivec_file.cc | 2 +- .../compiler/objectivec/objectivec_helpers.cc | 56 +- .../compiler/objectivec/objectivec_helpers.h | 4 + .../compiler/objectivec/objectivec_map_field.cc | 14 +- .../compiler/objectivec/objectivec_map_field.h | 1 - .../compiler/objectivec/objectivec_message.cc | 254 +- .../compiler/objectivec/objectivec_oneof.cc | 15 +- .../compiler/objectivec/objectivec_oneof.h | 4 +- .../objectivec/objectivec_primitive_field.cc | 26 + .../objectivec/objectivec_primitive_field.h | 5 + 59 files changed, 1061 insertions(+), 5206 deletions(-) delete mode 100755 objectivec/generate_descriptors_proto.sh create mode 100755 objectivec/generate_well_known_types.sh delete mode 100644 objectivec/google/protobuf/Descriptor.pbobjc.h delete mode 100644 objectivec/google/protobuf/Descriptor.pbobjc.m (limited to 'src') diff --git a/Makefile.am b/Makefile.am index 064efdfb..4b5a44ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -381,13 +381,11 @@ objectivec_EXTRA_DIST= \ objectivec/DevTools/full_mac_build.sh \ objectivec/DevTools/pddm.py \ objectivec/DevTools/pddm_tests.py \ - objectivec/generate_descriptors_proto.sh \ + objectivec/generate_well_known_types.sh \ objectivec/google/protobuf/Any.pbobjc.h \ objectivec/google/protobuf/Any.pbobjc.m \ objectivec/google/protobuf/Api.pbobjc.h \ objectivec/google/protobuf/Api.pbobjc.m \ - objectivec/google/protobuf/Descriptor.pbobjc.h \ - objectivec/google/protobuf/Descriptor.pbobjc.m \ objectivec/google/protobuf/Duration.pbobjc.h \ objectivec/google/protobuf/Duration.pbobjc.m \ objectivec/google/protobuf/Empty.pbobjc.h \ diff --git a/Protobuf.podspec b/Protobuf.podspec index 02c83723..0bbd06df 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -17,7 +17,6 @@ Pod::Spec.new do |s| s.source_files = 'objectivec/*.{h,m}', 'objectivec/google/protobuf/Any.pbobjc.{h,m}', 'objectivec/google/protobuf/Api.pbobjc.{h,m}', - 'objectivec/google/protobuf/Descriptor.pbobjc.{h,m}', 'objectivec/google/protobuf/Duration.pbobjc.h', 'objectivec/google/protobuf/Empty.pbobjc.{h,m}', 'objectivec/google/protobuf/FieldMask.pbobjc.{h,m}', diff --git a/generate_descriptor_proto.sh b/generate_descriptor_proto.sh index 81b8a0d6..1690d0da 100755 --- a/generate_descriptor_proto.sh +++ b/generate_descriptor_proto.sh @@ -92,9 +92,9 @@ do done cd .. -if test -x objectivec/generate_descriptors_proto.sh; then +if test -x objectivec/generate_well_known_types.sh; then echo "Generating messages for objc." - objectivec/generate_descriptors_proto.sh $@ + objectivec/generate_well_known_types.sh $@ fi if test -x csharp/generate_protos.sh; then diff --git a/objectivec/DevTools/compile_testing_protos.sh b/objectivec/DevTools/compile_testing_protos.sh index e9c5fe61..82953130 100755 --- a/objectivec/DevTools/compile_testing_protos.sh +++ b/objectivec/DevTools/compile_testing_protos.sh @@ -67,29 +67,36 @@ fi # Ensure the output dir exists 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 \ - src/google/protobuf/unittest_empty.proto \ - src/google/protobuf/unittest_import.proto \ - 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 \ - src/google/protobuf/unittest_import_public.proto \ - src/google/protobuf/unittest_import_public_lite.proto \ - src/google/protobuf/unittest_drop_unknown_fields.proto \ - src/google/protobuf/unittest_preserve_unknown_enum.proto \ - src/google/protobuf/map_lite_unittest.proto \ - src/google/protobuf/map_proto2_unittest.proto \ - src/google/protobuf/map_unittest.proto \ +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 + src/google/protobuf/unittest_empty.proto + src/google/protobuf/unittest_import.proto + 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 + src/google/protobuf/unittest_import_public.proto + src/google/protobuf/unittest_import_public_lite.proto + src/google/protobuf/unittest_drop_unknown_fields.proto + src/google/protobuf/unittest_preserve_unknown_enum.proto + src/google/protobuf/map_lite_unittest.proto + src/google/protobuf/map_proto2_unittest.proto + src/google/protobuf/map_unittest.proto +) + +# The unittest_custom_options.proto extends the messages in descriptor.proto +# so we build it in to test extending in general. The library doesn't provide +# a descriptor as it doesn't use the classes/enums. +CORE_PROTO_FILES+=( + src/google/protobuf/descriptor.proto ) compile_proto() { @@ -104,12 +111,12 @@ for a_proto in "${CORE_PROTO_FILES[@]}" ; do compile_proto "${a_proto}" done -OBJC_PROTO_FILES=( \ - objectivec/Tests/unittest_cycle.proto \ - objectivec/Tests/unittest_runtime_proto2.proto \ - objectivec/Tests/unittest_runtime_proto3.proto \ - objectivec/Tests/unittest_objc.proto \ - objectivec/Tests/unittest_objc_startup.proto \ +OBJC_PROTO_FILES=( + objectivec/Tests/unittest_cycle.proto + objectivec/Tests/unittest_runtime_proto2.proto + objectivec/Tests/unittest_runtime_proto3.proto + objectivec/Tests/unittest_objc.proto + objectivec/Tests/unittest_objc_startup.proto ) for a_proto in "${OBJC_PROTO_FILES[@]}" ; do diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh index c8681e26..b382779e 100755 --- a/objectivec/DevTools/full_mac_build.sh +++ b/objectivec/DevTools/full_mac_build.sh @@ -190,7 +190,7 @@ header "Ensuring the ObjC descriptors are current." readonly NewestInput=$(find \ src/google/protobuf/*.proto \ src/.libs src/*.la src/protoc \ - objectivec/generate_descriptors_proto.sh \ + objectivec/generate_well_known_types.sh \ -type f -print0 \ | xargs -0 stat -f "%m %N" \ | sort -n | tail -n1 | cut -f2- -d" ") @@ -203,7 +203,7 @@ readonly OldestOutput=$(find \ # If the newest input is newer than the oldest output, regenerate. if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then echo ">> Newest input is newer than oldest output, regenerating." - objectivec/generate_descriptors_proto.sh -j "${NUM_MAKE_JOBS}" + objectivec/generate_well_known_types.sh -j "${NUM_MAKE_JOBS}" else echo ">> Newest input is older than oldest output, no need to regenerating." fi diff --git a/objectivec/GPBBootstrap.h b/objectivec/GPBBootstrap.h index c49c7e20..ffefa770 100644 --- a/objectivec/GPBBootstrap.h +++ b/objectivec/GPBBootstrap.h @@ -37,13 +37,6 @@ #define GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS 0 #endif -// Most uses of protocol buffers don't need field options, by default the -// static data will be compiled out, define this to 1 to include it. The only -// time you need this is if you are doing introspection of the protocol buffers. -#ifndef GPBOBJC_INCLUDE_FIELD_OPTIONS -#define GPBOBJC_INCLUDE_FIELD_OPTIONS 0 -#endif - // Used in the generated code to give sizes to enums. int32_t was chosen based // on the fact that Protocol Buffers enums are limited to this range. #if !__has_feature(objc_fixed_enum) @@ -89,4 +82,4 @@ // generated Objective C sources. In general we don't want to change the // runtime interfaces (or this version) as it means everything has to be // regenerated. -#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30000 +#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30001 diff --git a/objectivec/GPBDescriptor.h b/objectivec/GPBDescriptor.h index 8d8e9754..a6eff0fb 100644 --- a/objectivec/GPBDescriptor.h +++ b/objectivec/GPBDescriptor.h @@ -34,19 +34,18 @@ @class GPBEnumDescriptor; @class GPBFieldDescriptor; -@class GPBFieldOptions; @class GPBFileDescriptor; @class GPBOneofDescriptor; NS_ASSUME_NONNULL_BEGIN -typedef NS_ENUM(NSInteger, GPBFileSyntax) { +typedef NS_ENUM(uint8_t, GPBFileSyntax) { GPBFileSyntaxUnknown = 0, GPBFileSyntaxProto2 = 2, GPBFileSyntaxProto3 = 3, }; -typedef NS_ENUM(NSInteger, GPBFieldType) { +typedef NS_ENUM(uint8_t, GPBFieldType) { GPBFieldTypeSingle, // optional/required GPBFieldTypeRepeated, // repeated GPBFieldTypeMap, // map @@ -57,9 +56,8 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { @property(nonatomic, readonly, copy) NSString *name; @property(nonatomic, readonly, strong, nullable) NSArray *fields; @property(nonatomic, readonly, strong, nullable) NSArray *oneofs; -@property(nonatomic, readonly, strong, nullable) NSArray *enums; @property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges; -@property(nonatomic, readonly) NSUInteger extensionRangesCount; +@property(nonatomic, readonly) uint32_t extensionRangesCount; @property(nonatomic, readonly, assign) GPBFileDescriptor *file; @property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat; @@ -68,7 +66,6 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; - (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name; -- (nullable GPBEnumDescriptor *)enumWithName:(NSString *)name; @end @@ -103,8 +100,6 @@ typedef NS_ENUM(NSInteger, GPBFieldType) { @property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof; -@property(nonatomic, readonly, nullable) GPBFieldOptions *fieldOptions; - // Message properties @property(nonatomic, readonly, assign, nullable) Class msgClass; diff --git a/objectivec/GPBDescriptor.m b/objectivec/GPBDescriptor.m index bae9187e..2709737c 100644 --- a/objectivec/GPBDescriptor.m +++ b/objectivec/GPBDescriptor.m @@ -35,7 +35,6 @@ #import "GPBUtilities_PackagePrivate.h" #import "GPBWireFormat.h" #import "GPBMessage_PackagePrivate.h" -#import "google/protobuf/Descriptor.pbobjc.h" // The address of this variable is used as a key for obj_getAssociatedObject. static const char kTextFormatExtraValueKey = 0; @@ -92,7 +91,6 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, @implementation GPBDescriptor { Class messageClass_; - NSArray *enums_; GPBFileDescriptor *file_; BOOL wireFormat_; } @@ -100,7 +98,6 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, @synthesize messageClass = messageClass_; @synthesize fields = fields_; @synthesize oneofs = oneofs_; -@synthesize enums = enums_; @synthesize extensionRanges = extensionRanges_; @synthesize extensionRangesCount = extensionRangesCount_; @synthesize file = file_; @@ -110,130 +107,58 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, allocDescriptorForClass:(Class)messageClass rootClass:(Class)rootClass file:(GPBFileDescriptor *)file - fields:(GPBMessageFieldDescription *)fieldDescriptions - fieldCount:(NSUInteger)fieldCount - oneofs:(GPBMessageOneofDescription *)oneofDescriptions - oneofCount:(NSUInteger)oneofCount - enums:(GPBMessageEnumDescription *)enumDescriptions - enumCount:(NSUInteger)enumCount - ranges:(const GPBExtensionRange *)ranges - rangeCount:(NSUInteger)rangeCount - storageSize:(size_t)storageSize - wireFormat:(BOOL)wireFormat { + fields:(void *)fieldDescriptions + fieldCount:(uint32_t)fieldCount + storageSize:(uint32_t)storageSize + 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 = nil; - NSMutableArray *oneofs = nil; - NSMutableArray *enums = nil; - NSMutableArray *extensionRanges = nil; GPBFileSyntax syntax = file.syntax; - for (NSUInteger i = 0; i < fieldCount; ++i) { + BOOL fieldsIncludeDefault = + (flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0; + + void *desc; + for (uint32_t i = 0; i < fieldCount; ++i) { if (fields == nil) { fields = [[NSMutableArray alloc] initWithCapacity:fieldCount]; } - GPBFieldDescriptor *fieldDescriptor = [[GPBFieldDescriptor alloc] - initWithFieldDescription:&fieldDescriptions[i] - rootClass:rootClass - syntax:syntax]; + // Need correctly typed pointer for array indexing below to work. + if (fieldsIncludeDefault) { + GPBMessageFieldDescriptionWithDefault *fieldDescWithDefault = fieldDescriptions; + desc = &(fieldDescWithDefault[i]); + } else { + GPBMessageFieldDescription *fieldDesc = fieldDescriptions; + desc = &(fieldDesc[i]); + } + GPBFieldDescriptor *fieldDescriptor = + [[GPBFieldDescriptor alloc] initWithFieldDescription:desc + includesDefault:fieldsIncludeDefault + syntax:syntax]; [fields addObject:fieldDescriptor]; [fieldDescriptor release]; } - for (NSUInteger i = 0; i < oneofCount; ++i) { - if (oneofs == nil) { - oneofs = [[NSMutableArray alloc] initWithCapacity:oneofCount]; - } - GPBMessageOneofDescription *oneofDescription = &oneofDescriptions[i]; - NSArray *fieldsForOneof = - NewFieldsArrayForHasIndex(oneofDescription->index, fields); - GPBOneofDescriptor *oneofDescriptor = - [[GPBOneofDescriptor alloc] initWithOneofDescription:oneofDescription - fields:fieldsForOneof]; - [oneofs addObject:oneofDescriptor]; - [oneofDescriptor release]; - [fieldsForOneof release]; - } - for (NSUInteger i = 0; i < enumCount; ++i) { - if (enums == nil) { - enums = [[NSMutableArray alloc] initWithCapacity:enumCount]; - } - GPBEnumDescriptor *enumDescriptor = - enumDescriptions[i].enumDescriptorFunc(); - [enums addObject:enumDescriptor]; - } + BOOL wireFormat = (flags & GPBDescriptorInitializationFlag_WireFormat) != 0; GPBDescriptor *descriptor = [[self alloc] initWithClass:messageClass file:file fields:fields - oneofs:oneofs - enums:enums - extensionRanges:ranges - extensionRangesCount:rangeCount storageSize:storageSize wireFormat:wireFormat]; [fields release]; - [oneofs release]; - [enums release]; - [extensionRanges release]; - return descriptor; -} - -+ (instancetype) - allocDescriptorForClass:(Class)messageClass - rootClass:(Class)rootClass - file:(GPBFileDescriptor *)file - fields:(GPBMessageFieldDescription *)fieldDescriptions - fieldCount:(NSUInteger)fieldCount - oneofs:(GPBMessageOneofDescription *)oneofDescriptions - oneofCount:(NSUInteger)oneofCount - enums:(GPBMessageEnumDescription *)enumDescriptions - enumCount:(NSUInteger)enumCount - ranges:(const GPBExtensionRange *)ranges - rangeCount:(NSUInteger)rangeCount - storageSize:(size_t)storageSize - wireFormat:(BOOL)wireFormat - extraTextFormatInfo:(const char *)extraTextFormatInfo { - GPBDescriptor *descriptor = [self allocDescriptorForClass:messageClass - rootClass:rootClass - file:file - fields:fieldDescriptions - fieldCount:fieldCount - oneofs:oneofDescriptions - oneofCount:oneofCount - enums:enumDescriptions - enumCount:enumCount - ranges:ranges - rangeCount:rangeCount - storageSize:storageSize - wireFormat:wireFormat]; - // Extra info is a compile time option, so skip the work if not needed. - if (extraTextFormatInfo) { - NSValue *extraInfoValue = [NSValue valueWithPointer:extraTextFormatInfo]; - for (GPBFieldDescriptor *fieldDescriptor in descriptor->fields_) { - if (fieldDescriptor->description_->flags & GPBFieldTextFormatNameCustom) { - objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey, - extraInfoValue, - OBJC_ASSOCIATION_RETAIN_NONATOMIC); - } - } - } return descriptor; } - (instancetype)initWithClass:(Class)messageClass file:(GPBFileDescriptor *)file fields:(NSArray *)fields - oneofs:(NSArray *)oneofs - enums:(NSArray *)enums - extensionRanges:(const GPBExtensionRange *)extensionRanges - extensionRangesCount:(NSUInteger)extensionRangesCount - storageSize:(size_t)storageSize + storageSize:(uint32_t)storageSize wireFormat:(BOOL)wireFormat { if ((self = [super init])) { messageClass_ = messageClass; file_ = file; fields_ = [fields retain]; - oneofs_ = [oneofs retain]; - enums_ = [enums retain]; - extensionRanges_ = extensionRanges; - extensionRangesCount_ = extensionRangesCount; storageSize_ = storageSize; wireFormat_ = wireFormat; } @@ -243,10 +168,47 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, - (void)dealloc { [fields_ release]; [oneofs_ release]; - [enums_ release]; [super dealloc]; } +- (void)setupOneofs:(const char **)oneofNames + count:(uint32_t)count + firstHasIndex:(int32_t)firstHasIndex { + NSCAssert(firstHasIndex < 0, @"Should always be <0"); + NSMutableArray *oneofs = [[NSMutableArray alloc] initWithCapacity:count]; + for (uint32_t i = 0, hasIndex = firstHasIndex; i < count; ++i, --hasIndex) { + const char *name = oneofNames[i]; + NSArray *fieldsForOneof = NewFieldsArrayForHasIndex(hasIndex, fields_); + NSCAssert(fieldsForOneof.count > 0, + @"No fields for this oneof? (%s:%d)", name, hasIndex); + GPBOneofDescriptor *oneofDescriptor = + [[GPBOneofDescriptor alloc] initWithName:name fields:fieldsForOneof]; + [oneofs addObject:oneofDescriptor]; + [oneofDescriptor release]; + [fieldsForOneof release]; + } + oneofs_ = oneofs; +} + +- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo { + // Extra info is a compile time option, so skip the work if not needed. + if (extraTextFormatInfo) { + NSValue *extraInfoValue = [NSValue valueWithPointer:extraTextFormatInfo]; + for (GPBFieldDescriptor *fieldDescriptor in fields_) { + if (fieldDescriptor->description_->flags & GPBFieldTextFormatNameCustom) { + objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey, + extraInfoValue, + OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + } + } +} + +- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count { + extensionRanges_ = ranges; + extensionRangesCount_ = count; +} + - (NSString *)name { return NSStringFromClass(messageClass_); } @@ -283,15 +245,6 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, return nil; } -- (GPBEnumDescriptor *)enumWithName:(NSString *)name { - for (GPBEnumDescriptor *descriptor in enums_) { - if ([descriptor.name isEqual:name]) { - return descriptor; - } - } - return nil; -} - @end @implementation GPBFileDescriptor { @@ -318,19 +271,16 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, @synthesize fields = fields_; -- (instancetype)initWithOneofDescription: - (GPBMessageOneofDescription *)oneofDescription - fields:(NSArray *)fields { +- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields { self = [super init]; if (self) { - NSAssert(oneofDescription->index < 0, @"Should always be <0"); - oneofDescription_ = oneofDescription; + name_ = name; fields_ = [fields retain]; for (GPBFieldDescriptor *fieldDesc in fields) { fieldDesc->containingOneof_ = self; } - caseSel_ = SelFromStrings(NULL, oneofDescription->name, "OneOfCase", NO); + caseSel_ = SelFromStrings(NULL, name, "OneOfCase", NO); } return self; } @@ -341,7 +291,7 @@ static NSArray *NewFieldsArrayForHasIndex(int hasIndex, } - (NSString *)name { - return @(oneofDescription_->name); + return @(name_); } - (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber { @@ -389,7 +339,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { @implementation GPBFieldDescriptor { GPBGenericValue defaultValue_; - GPBFieldOptions *fieldOptions_; // Message ivars Class msgClass_; @@ -403,7 +352,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { } enumHandling_; } -@synthesize fieldOptions = fieldOptions_; @synthesize msgClass = msgClass_; @synthesize containingOneof = containingOneof_; @@ -417,16 +365,21 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { return self; } -- (instancetype)initWithFieldDescription: - (GPBMessageFieldDescription *)description - rootClass:(Class)rootClass +- (instancetype)initWithFieldDescription:(void *)description + includesDefault:(BOOL)includesDefault syntax:(GPBFileSyntax)syntax { if ((self = [super init])) { - description_ = description; - getSel_ = sel_getUid(description->name); - setSel_ = SelFromStrings("set", description->name, NULL, YES); + GPBMessageFieldDescription *coreDesc; + if (includesDefault) { + coreDesc = &(((GPBMessageFieldDescriptionWithDefault *)description)->core); + } else { + coreDesc = description; + } + description_ = coreDesc; + getSel_ = sel_getUid(coreDesc->name); + setSel_ = SelFromStrings("set", coreDesc->name, NULL, YES); - GPBDataType dataType = description->dataType; + GPBDataType dataType = coreDesc->dataType; BOOL isMessage = GPBDataTypeIsMessage(dataType); BOOL isMapOrArray = GPBFieldIsMapOrArray(self); @@ -434,39 +387,39 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { // map<>/repeated fields get a *Count property (inplace of a has*) to // support checking if there are any entries without triggering // autocreation. - hasOrCountSel_ = SelFromStrings(NULL, description->name, "_Count", NO); + hasOrCountSel_ = SelFromStrings(NULL, coreDesc->name, "_Count", NO); } else { // If there is a positive hasIndex, then: // - All fields types for proto2 messages get has* selectors. // - Only message fields for proto3 messages get has* selectors. // Note: the positive check is to handle oneOfs, we can't check // containingOneof_ because it isn't set until after initialization. - if ((description->hasIndex >= 0) && - (description->hasIndex != GPBNoHasBit) && + if ((coreDesc->hasIndex >= 0) && + (coreDesc->hasIndex != GPBNoHasBit) && ((syntax != GPBFileSyntaxProto3) || isMessage)) { - hasOrCountSel_ = SelFromStrings("has", description->name, NULL, NO); - setHasSel_ = SelFromStrings("setHas", description->name, NULL, YES); + hasOrCountSel_ = SelFromStrings("has", coreDesc->name, NULL, NO); + setHasSel_ = SelFromStrings("setHas", coreDesc->name, NULL, YES); } } // Extra type specific data. if (isMessage) { - const char *className = description->dataTypeSpecific.className; + const char *className = coreDesc->dataTypeSpecific.className; msgClass_ = objc_getClass(className); NSAssert(msgClass_, @"Class %s not defined", className); } else if (dataType == GPBDataTypeEnum) { - if ((description_->flags & GPBFieldHasEnumDescriptor) != 0) { + if ((coreDesc->flags & GPBFieldHasEnumDescriptor) != 0) { enumHandling_.enumDescriptor_ = - description->dataTypeSpecific.enumDescFunc(); + coreDesc->dataTypeSpecific.enumDescFunc(); } else { enumHandling_.enumVerifier_ = - description->dataTypeSpecific.enumVerifier; + coreDesc->dataTypeSpecific.enumVerifier; } } - // Non map<>/repeated fields can have defaults. - if (!isMapOrArray) { - defaultValue_ = description->defaultValue; + // Non map<>/repeated fields can have defaults in proto2 syntax. + if (!isMapOrArray && includesDefault) { + defaultValue_ = ((GPBMessageFieldDescriptionWithDefault *)description)->defaultValue; if (dataType == GPBDataTypeBytes) { // Data stored as a length prefixed (network byte order) c-string in // descriptor structure. @@ -480,24 +433,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { } } } - - // FieldOptions stored as a length prefixed (network byte order) c-escaped - // string in descriptor records. - if (description->fieldOptions) { - uint8_t *optionsBytes = (uint8_t *)description->fieldOptions; - uint32_t optionsLength = *((uint32_t *)optionsBytes); - optionsLength = ntohl(optionsLength); - if (optionsLength > 0) { - optionsBytes += sizeof(optionsLength); - NSData *optionsData = [NSData dataWithBytesNoCopy:optionsBytes - length:optionsLength - freeWhenDone:NO]; - GPBExtensionRegistry *registry = [rootClass extensionRegistry]; - fieldOptions_ = [[GPBFieldOptions parseFromData:optionsData - extensionRegistry:registry - error:NULL] retain]; - } - } } return self; } @@ -666,7 +601,7 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { } else { // Undo the CamelCase. NSMutableString *result = [NSMutableString stringWithCapacity:len]; - for (NSUInteger i = 0; i < len; i++) { + for (uint32_t i = 0; i < len; i++) { unichar c = [name characterAtIndex:i]; if (c >= 'A' && c <= 'Z') { if (i > 0) { @@ -686,10 +621,16 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { @implementation GPBEnumDescriptor { NSString *name_; - GPBMessageEnumValueDescription *valueDescriptions_; - NSUInteger valueDescriptionsCount_; + // valueNames_ is a single c string with all of the value names appended + // together, each null terminated. -calcValueNameOffsets fills in + // nameOffsets_ with the offsets to allow quicker access to the individual + // names. + const char *valueNames_; + const int32_t *values_; GPBEnumValidationFunc enumVerifier_; const uint8_t *extraTextFormatInfo_; + uint32_t *nameOffsets_; + uint32_t valueCount_; } @synthesize name = name_; @@ -697,26 +638,30 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { + (instancetype) allocDescriptorForName:(NSString *)name - values:(GPBMessageEnumValueDescription *)valueDescriptions - valueCount:(NSUInteger)valueCount + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount enumVerifier:(GPBEnumValidationFunc)enumVerifier { GPBEnumDescriptor *descriptor = [[self alloc] initWithName:name - values:valueDescriptions - valueCount:valueCount + valueNames:valueNames + values:values + count:valueCount enumVerifier:enumVerifier]; return descriptor; } + (instancetype) allocDescriptorForName:(NSString *)name - values:(GPBMessageEnumValueDescription *)valueDescriptions - valueCount:(NSUInteger)valueCount + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount enumVerifier:(GPBEnumValidationFunc)enumVerifier extraTextFormatInfo:(const char *)extraTextFormatInfo { // Call the common case. GPBEnumDescriptor *descriptor = [self allocDescriptorForName:name - values:valueDescriptions - valueCount:valueCount + valueNames:valueNames + values:values + count:valueCount enumVerifier:enumVerifier]; // Set the extra info. descriptor->extraTextFormatInfo_ = (const uint8_t *)extraTextFormatInfo; @@ -724,24 +669,49 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { } - (instancetype)initWithName:(NSString *)name - values:(GPBMessageEnumValueDescription *)valueDescriptions - valueCount:(NSUInteger)valueCount + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount enumVerifier:(GPBEnumValidationFunc)enumVerifier { if ((self = [super init])) { name_ = [name copy]; - valueDescriptions_ = valueDescriptions; - valueDescriptionsCount_ = valueCount; + valueNames_ = valueNames; + values_ = values; + valueCount_ = valueCount; enumVerifier_ = enumVerifier; } return self; } +- (void)dealloc { + [name_ release]; + if (nameOffsets_) free(nameOffsets_); + [super dealloc]; +} + +- (void)calcValueNameOffsets { + @synchronized(self) { + if (nameOffsets_ != NULL) { + return; + } + uint32_t *offsets = malloc(valueCount_ * sizeof(uint32_t)); + const char *scan = valueNames_; + for (uint32_t i = 0; i < valueCount_; ++i) { + offsets[i] = (uint32_t)(scan - valueNames_); + while (*scan != '\0') ++scan; + ++scan; // Step over the null. + } + nameOffsets_ = offsets; + } +} + - (NSString *)enumNameForValue:(int32_t)number { - for (NSUInteger i = 0; i < valueDescriptionsCount_; ++i) { - GPBMessageEnumValueDescription *scan = &valueDescriptions_[i]; - if ((scan->number == number) && (scan->name != NULL)) { - NSString *fullName = - [NSString stringWithFormat:@"%@_%s", name_, scan->name]; + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + + for (uint32_t i = 0; i < valueCount_; ++i) { + if (values_[i] == number) { + const char *valueName = valueNames_ + nameOffsets_[i]; + NSString *fullName = [NSString stringWithFormat:@"%@_%s", name_, valueName]; return fullName; } } @@ -760,12 +730,14 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { const char *nameAsCStr = [name UTF8String]; nameAsCStr += prefixLen; + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + // Find it. - for (NSUInteger i = 0; i < valueDescriptionsCount_; ++i) { - GPBMessageEnumValueDescription *scan = &valueDescriptions_[i]; - if ((scan->name != NULL) && (strcmp(nameAsCStr, scan->name) == 0)) { + for (uint32_t i = 0; i < valueCount_; ++i) { + const char *valueName = valueNames_ + nameOffsets_[i]; + if (strcmp(nameAsCStr, valueName) == 0) { if (outValue) { - *outValue = scan->number; + *outValue = values_[i]; } return YES; } @@ -773,34 +745,28 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { return NO; } -- (void)dealloc { - [name_ release]; - [super dealloc]; -} - - (NSString *)textFormatNameForValue:(int32_t)number { + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + // Find the EnumValue descriptor and its index. - GPBMessageEnumValueDescription *valueDescriptor = NULL; - NSUInteger valueDescriptorIndex; - for (valueDescriptorIndex = 0; valueDescriptorIndex < valueDescriptionsCount_; + BOOL foundIt = NO; + uint32_t valueDescriptorIndex; + for (valueDescriptorIndex = 0; valueDescriptorIndex < valueCount_; ++valueDescriptorIndex) { - GPBMessageEnumValueDescription *scan = - &valueDescriptions_[valueDescriptorIndex]; - if (scan->number == number) { - valueDescriptor = scan; + if (values_[valueDescriptorIndex] == number) { + foundIt = YES; break; } } - // If we didn't find it, or names were disable at proto compile time, nothing - // we can do. - if (!valueDescriptor || !valueDescriptor->name) { + if (!foundIt) { return nil; } NSString *result = nil; // Naming adds an underscore between enum name and value name, skip that also. - NSString *shortName = @(valueDescriptor->name); + const char *valueName = valueNames_ + nameOffsets_[valueDescriptorIndex]; + NSString *shortName = @(valueName); // See if it is in the map of special format handling. if (extraTextFormatInfo_) { diff --git a/objectivec/GPBDescriptor_PackagePrivate.h b/objectivec/GPBDescriptor_PackagePrivate.h index 7987d928..e3d0a80f 100644 --- a/objectivec/GPBDescriptor_PackagePrivate.h +++ b/objectivec/GPBDescriptor_PackagePrivate.h @@ -36,7 +36,7 @@ #import "GPBWireFormat.h" // Describes attributes of the field. -typedef NS_OPTIONS(uint32_t, GPBFieldFlags) { +typedef NS_OPTIONS(uint16_t, GPBFieldFlags) { // These map to standard protobuf concepts. GPBFieldRequired = 1 << 0, GPBFieldRepeated = 1 << 1, @@ -44,6 +44,12 @@ typedef NS_OPTIONS(uint32_t, GPBFieldFlags) { GPBFieldOptional = 1 << 3, GPBFieldHasDefaultValue = 1 << 4, + // Indicates the field needs custom handling for the TextFormat name, if not + // set, the name can be derived from the ObjC name. + GPBFieldTextFormatNameCustom = 1 << 6, + // Indicates the field has an enum descriptor. + GPBFieldHasEnumDescriptor = 1 << 7, + // These are not standard protobuf concepts, they are specific to the // Objective C runtime. @@ -62,67 +68,49 @@ typedef NS_OPTIONS(uint32_t, GPBFieldFlags) { GPBFieldMapKeySFixed64 = 10 << 8, GPBFieldMapKeyBool = 11 << 8, GPBFieldMapKeyString = 12 << 8, - - // Indicates the field needs custom handling for the TextFormat name, if not - // set, the name can be derived from the ObjC name. - GPBFieldTextFormatNameCustom = 1 << 16, - // Indicates the field has an enum descriptor. - GPBFieldHasEnumDescriptor = 1 << 17, }; +// NOTE: The structures defined here have their members ordered to minimize +// their size. This directly impacts the size of apps since these exist per +// field/extension. + // Describes a single field in a protobuf as it is represented as an ivar. typedef struct GPBMessageFieldDescription { // Name of ivar. const char *name; + union { + const char *className; // Name for message class. + // For enums only: If EnumDescriptors are compiled in, it will be that, + // otherwise it will be the verifier. + GPBEnumDescriptorFunc enumDescFunc; + GPBEnumValidationFunc enumVerifier; + } dataTypeSpecific; // The field number for the ivar. uint32_t number; // The index (in bits) into _has_storage_. - // > 0: the bit to use for a value being set. - // = 0: no storage used. + // >= 0: the bit to use for a value being set. + // = GPBNoHasBit(INT32_MAX): no storage used. // < 0: in a oneOf, use a full int32 to record the field active. int32_t hasIndex; + // Offset of the variable into it's structure struct. + uint32_t offset; // Field flags. Use accessor functions below. GPBFieldFlags flags; // Data type of the ivar. GPBDataType dataType; - // Offset of the variable into it's structure struct. - size_t offset; - // FieldOptions protobuf, serialized as string. - const char *fieldOptions; - - GPBGenericValue defaultValue; // Default value for the ivar. - union { - const char *className; // Name for message class. - // For enums only: If EnumDescriptors are compiled in, it will be that, - // otherwise it will be the verifier. - GPBEnumDescriptorFunc enumDescFunc; - GPBEnumValidationFunc enumVerifier; - } dataTypeSpecific; } GPBMessageFieldDescription; -// Describes a oneof. -typedef struct GPBMessageOneofDescription { - // Name of this enum oneof. - const char *name; - // The index of this oneof in the has_storage. - int32_t index; -} GPBMessageOneofDescription; - -// Describes an enum type defined in a .proto file. -typedef struct GPBMessageEnumDescription { - GPBEnumDescriptorFunc enumDescriptorFunc; -} GPBMessageEnumDescription; +// Fields in messages defined in a 'proto2' syntax file can provide a default +// value. This struct provides the default along with the field info. +typedef struct GPBMessageFieldDescriptionWithDefault { + // Default value for the ivar. + GPBGenericValue defaultValue; -// Describes an individual enum constant of a particular type. -typedef struct GPBMessageEnumValueDescription { - // Name of this enum constant. - const char *name; - // Numeric value of this enum constant. - int32_t number; -} GPBMessageEnumValueDescription; + GPBMessageFieldDescription core; +} GPBMessageFieldDescriptionWithDefault; // Describes attributes of the extension. -typedef NS_OPTIONS(uint32_t, GPBExtensionOptions) { +typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) { // These map to standard protobuf concepts. GPBExtensionRepeated = 1 << 0, GPBExtensionPacked = 1 << 1, @@ -131,65 +119,53 @@ typedef NS_OPTIONS(uint32_t, GPBExtensionOptions) { // An extension typedef struct GPBExtensionDescription { + GPBGenericValue defaultValue; const char *singletonName; - GPBDataType dataType; const char *extendedClass; - int32_t fieldNumber; - GPBGenericValue defaultValue; const char *messageOrGroupClassName; - GPBExtensionOptions options; GPBEnumDescriptorFunc enumDescriptorFunc; + int32_t fieldNumber; + GPBDataType dataType; + GPBExtensionOptions options; } GPBExtensionDescription; +typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) { + GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0, + GPBDescriptorInitializationFlag_WireFormat = 1 << 1, +}; + @interface GPBDescriptor () { @package NSArray *fields_; NSArray *oneofs_; - size_t storageSize_; + uint32_t storageSize_; } -// fieldDescriptions, enumDescriptions, rangeDescriptions, and -// extraTextFormatInfo 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 rootClass:(Class)rootClass file:(GPBFileDescriptor *)file - fields:(GPBMessageFieldDescription *)fieldDescriptions - fieldCount:(NSUInteger)fieldCount - oneofs:(GPBMessageOneofDescription *)oneofDescriptions - oneofCount:(NSUInteger)oneofCount - enums:(GPBMessageEnumDescription *)enumDescriptions - enumCount:(NSUInteger)enumCount - ranges:(const GPBExtensionRange *)ranges - rangeCount:(NSUInteger)rangeCount - storageSize:(size_t)storageSize - wireFormat:(BOOL)wireFormat; -+ (instancetype) - allocDescriptorForClass:(Class)messageClass - rootClass:(Class)rootClass - file:(GPBFileDescriptor *)file - fields:(GPBMessageFieldDescription *)fieldDescriptions - fieldCount:(NSUInteger)fieldCount - oneofs:(GPBMessageOneofDescription *)oneofDescriptions - oneofCount:(NSUInteger)oneofCount - enums:(GPBMessageEnumDescription *)enumDescriptions - enumCount:(NSUInteger)enumCount - ranges:(const GPBExtensionRange *)ranges - rangeCount:(NSUInteger)rangeCount - storageSize:(size_t)storageSize - wireFormat:(BOOL)wireFormat - extraTextFormatInfo:(const char *)extraTextFormatInfo; + fields:(void *)fieldDescriptions + fieldCount:(uint32_t)fieldCount + storageSize:(uint32_t)storageSize + flags:(GPBDescriptorInitializationFlags)flags; - (instancetype)initWithClass:(Class)messageClass file:(GPBFileDescriptor *)file fields:(NSArray *)fields - oneofs:(NSArray *)oneofs - enums:(NSArray *)enums - extensionRanges:(const GPBExtensionRange *)ranges - extensionRangesCount:(NSUInteger)rangeCount - storageSize:(size_t)storage + storageSize:(uint32_t)storage wireFormat:(BOOL)wireFormat; +// Called right after init to provide extra information to avoid init having +// an explosion of args. These pointers are recorded, so they are expected +// to live for the lifetime of the app. +- (void)setupOneofs:(const char **)oneofNames + count:(uint32_t)count + firstHasIndex:(int32_t)firstHasIndex; +- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo; +- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count; + @end @interface GPBFileDescriptor () @@ -199,14 +175,12 @@ typedef struct GPBExtensionDescription { @interface GPBOneofDescriptor () { @package - GPBMessageOneofDescription *oneofDescription_; + const char *name_; NSArray *fields_; - SEL caseSel_; } -- (instancetype)initWithOneofDescription: - (GPBMessageOneofDescription *)oneofDescription - fields:(NSArray *)fields; +// name must be long lived. +- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields; @end @interface GPBFieldDescriptor () { @@ -222,30 +196,32 @@ typedef struct GPBExtensionDescription { // Single initializer // description has to be long lived, it is held as a raw pointer. -- (instancetype)initWithFieldDescription: - (GPBMessageFieldDescription *)description - rootClass:(Class)rootClass +- (instancetype)initWithFieldDescription:(void *)description + includesDefault:(BOOL)includesDefault syntax:(GPBFileSyntax)syntax; @end @interface GPBEnumDescriptor () -// valueDescriptions and extraTextFormatInfo have to be long lived, they are +// valueNames, values and extraTextFormatInfo have to be long lived, they are // held as raw pointers. + (instancetype) allocDescriptorForName:(NSString *)name - values:(GPBMessageEnumValueDescription *)valueDescriptions - valueCount:(NSUInteger)valueCount + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount enumVerifier:(GPBEnumValidationFunc)enumVerifier; + (instancetype) allocDescriptorForName:(NSString *)name - values:(GPBMessageEnumValueDescription *)valueDescriptions - valueCount:(NSUInteger)valueCount + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount enumVerifier:(GPBEnumValidationFunc)enumVerifier extraTextFormatInfo:(const char *)extraTextFormatInfo; - (instancetype)initWithName:(NSString *)name - values:(GPBMessageEnumValueDescription *)valueDescriptions - valueCount:(NSUInteger)valueCount + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount enumVerifier:(GPBEnumValidationFunc)enumVerifier; @end @@ -314,5 +290,24 @@ GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) { return (description->options & GPBExtensionSetWireFormat) != 0; } +// Helper for compile time assets. +#ifndef _GPBCompileAssert + #if __has_feature(c_static_assert) || __has_extension(c_static_assert) + #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg) + #else + // Pre-Xcode 7 support. + #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg + #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg) + #define _GPBCompileAssert(test, msg) \ + typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) +#endif // _GPBCompileAssert + +// Sanity check that there isn't padding between the field description +// structures with and without a default. +_GPBCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) == + (sizeof(GPBGenericValue) + + sizeof(GPBMessageFieldDescription)), + DescriptionsWithDefault_different_size_than_expected); CF_EXTERN_C_END diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index d5e8d37b..94d179be 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -54,18 +54,6 @@ NSString *const GPBExceptionMessageKey = static NSString *const kGPBDataCoderKey = @"GPBData"; -#ifndef _GPBCompileAssert - #if __has_feature(c_static_assert) || __has_extension(c_static_assert) - #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg) - #else - // Pre-Xcode 7 support. - #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg - #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg) - #define _GPBCompileAssert(test, msg) \ - typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] - #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) -#endif // _GPBCompileAssert - // // PLEASE REMEMBER: // @@ -789,14 +777,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { file:fileDescriptor fields:NULL fieldCount:0 - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 storageSize:0 - wireFormat:NO]; + flags:0]; } return descriptor; } @@ -3096,7 +3078,7 @@ static void ResolveIvarSet(GPBFieldDescriptor *field, } else { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof && (sel == oneof->caseSel_)) { - int32_t index = oneof->oneofDescription_->index; + int32_t index = GPBFieldHasIndex(field); result.impToAdd = imp_implementationWithBlock(^(id obj) { return GPBGetHasOneof(obj, index); }); diff --git a/objectivec/GPBProtocolBuffers.m b/objectivec/GPBProtocolBuffers.m index e9cbfb42..8512af7e 100644 --- a/objectivec/GPBProtocolBuffers.m +++ b/objectivec/GPBProtocolBuffers.m @@ -46,8 +46,6 @@ #import "GPBWellKnownTypes.m" #import "GPBWireFormat.m" -#import "google/protobuf/Descriptor.pbobjc.m" - // Duration and Timestamp are #imported into GPBWellKnownTypes.m to the // Objective C categories added will always be linked in with the classes. #import "google/protobuf/Any.pbobjc.m" diff --git a/objectivec/GPBRuntimeTypes.h b/objectivec/GPBRuntimeTypes.h index e91d86a6..0a38b110 100644 --- a/objectivec/GPBRuntimeTypes.h +++ b/objectivec/GPBRuntimeTypes.h @@ -67,7 +67,7 @@ typedef union { // Do not change the order of this enum (or add things to it) without thinking // about it very carefully. There are several things that depend on the order. -typedef enum { +typedef NS_ENUM(uint8_t, GPBDataType) { GPBDataTypeBool = 0, GPBDataTypeFixed32, GPBDataTypeSFixed32, @@ -86,7 +86,7 @@ typedef enum { GPBDataTypeMessage, GPBDataTypeGroup, GPBDataTypeEnum, -} GPBDataType; +}; enum { // A count of the number of types in GPBDataType. Separated out from the diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m index d4d6471f..3e9d11c0 100644 --- a/objectivec/GPBUtilities.m +++ b/objectivec/GPBUtilities.m @@ -145,9 +145,8 @@ void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, } void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, - uint32_t fieldNumberNotToClear) { - int32_t hasIndex = oneof->oneofDescription_->index; - uint32_t fieldNumberSet = GPBGetHasOneof(self, hasIndex); + int32_t oneofHasIndex, uint32_t fieldNumberNotToClear) { + uint32_t fieldNumberSet = GPBGetHasOneof(self, oneofHasIndex); if ((fieldNumberSet == fieldNumberNotToClear) || (fieldNumberSet == 0)) { // Do nothing/nothing set in the oneof. return; @@ -168,7 +167,7 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, // Set to nothing stored in the oneof. // (field number doesn't matter since setting to nothing). - GPBSetHasIvar(self, hasIndex, 1, NO); + GPBSetHasIvar(self, oneofHasIndex, 1, NO); } #pragma mark - IVar accessors @@ -200,7 +199,8 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, //% NAME$S GPBFileSyntax syntax) { //% GPBOneofDescriptor *oneof = field->containingOneof_; //% if (oneof) { -//% GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); +//% GPBMessageFieldDescription *fieldDesc = field->description_; +//% GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); //% } //% NSCAssert(self->messageStorage_ != NULL, //% @"%@: All messages should have storage (from init)", @@ -321,7 +321,8 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self, // oneof. GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } // Clear "has" if they are being set to nil. BOOL setHasValue = (value != nil); @@ -476,15 +477,15 @@ void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); } -//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Bool, BOOL) -// This block of code is generated, do not edit it directly. - BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field) { if (GPBGetHasIvarField(self, field)) { - uint8_t *storage = (uint8_t *)self->messageStorage_; - BOOL *typePtr = (BOOL *)&storage[field->description_->offset]; - return *typePtr; + // Bools are stored in the has bits to avoid needing explicit space in the + // storage structure. + // (the field number passed to the HasIvar helper doesn't really matter + // since the offset is never negative) + GPBMessageFieldDescription *fieldDesc = field->description_; + return GPBGetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number); } else { return field.defaultValue.valueBool; } @@ -503,19 +504,18 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, GPBFieldDescriptor *field, BOOL value, GPBFileSyntax syntax) { + GPBMessageFieldDescription *fieldDesc = field->description_; GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } - NSCAssert(self->messageStorage_ != NULL, - @"%@: All messages should have storage (from init)", - [self class]); -#if defined(__clang_analyzer__) - if (self->messageStorage_ == NULL) return; -#endif - uint8_t *storage = (uint8_t *)self->messageStorage_; - BOOL *typePtr = (BOOL *)&storage[field->description_->offset]; - *typePtr = value; + + // Bools are stored in the has bits to avoid needing explicit space in the + // storage structure. + // (the field number passed to the HasIvar helper doesn't really matter since + // the offset is never negative) + GPBSetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number, value); + // proto2: any value counts as having been set; proto3, it // has to be a non zero value. BOOL hasValue = @@ -553,7 +553,8 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, GPBFileSyntax syntax) { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } NSCAssert(self->messageStorage_ != NULL, @"%@: All messages should have storage (from init)", @@ -601,7 +602,8 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, GPBFileSyntax syntax) { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } NSCAssert(self->messageStorage_ != NULL, @"%@: All messages should have storage (from init)", @@ -649,7 +651,8 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, GPBFileSyntax syntax) { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } NSCAssert(self->messageStorage_ != NULL, @"%@: All messages should have storage (from init)", @@ -697,7 +700,8 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, GPBFileSyntax syntax) { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } NSCAssert(self->messageStorage_ != NULL, @"%@: All messages should have storage (from init)", @@ -745,7 +749,8 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, GPBFileSyntax syntax) { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } NSCAssert(self->messageStorage_ != NULL, @"%@: All messages should have storage (from init)", @@ -793,7 +798,8 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, GPBFileSyntax syntax) { GPBOneofDescriptor *oneof = field->containingOneof_; if (oneof) { - GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); } NSCAssert(self->messageStorage_ != NULL, @"%@: All messages should have storage (from init)", @@ -812,7 +818,7 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, GPBBecomeVisibleToAutocreator(self); } -//%PDDM-EXPAND-END (7 expansions) +//%PDDM-EXPAND-END (6 expansions) // Aliases are function calls that are virtually the same. diff --git a/objectivec/GPBUtilities_PackagePrivate.h b/objectivec/GPBUtilities_PackagePrivate.h index cac551f6..a6b6c84d 100644 --- a/objectivec/GPBUtilities_PackagePrivate.h +++ b/objectivec/GPBUtilities_PackagePrivate.h @@ -185,7 +185,7 @@ GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field, } void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, - uint32_t fieldNumberNotToClear); + int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); //%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE) //%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj index 78c3f9ba..30934254 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; }; 5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */; }; 7461B5360F94FB4600A0C422 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */; }; @@ -27,7 +26,6 @@ 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; }; 8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; }; - 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; }; 8BBEA4A9147C727D00C4ADB7 /* GPBCodedInputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69B0F94FDF800A0C422 /* GPBCodedInputStreamTests.m */; }; 8BBEA4AA147C727D00C4ADB7 /* GPBCodedOuputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */; }; 8BBEA4AC147C727D00C4ADB7 /* GPBMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B6A30F94FDF800A0C422 /* GPBMessageTests.m */; }; @@ -140,10 +138,8 @@ 8B4248D51A92826400BC1EC6 /* Timestamp.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timestamp.pbobjc.h; path = google/protobuf/Timestamp.pbobjc.h; sourceTree = ""; }; 8B4248D61A92826400BC1EC6 /* Timestamp.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Timestamp.pbobjc.m; path = google/protobuf/Timestamp.pbobjc.m; sourceTree = ""; }; 8B4248DB1A92933A00BC1EC6 /* GPBWellKnownTypesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypesTest.m; sourceTree = ""; }; - 8B42494B1A92A16600BC1EC6 /* descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = descriptor.proto; path = ../src/google/protobuf/descriptor.proto; sourceTree = ""; }; 8B42494C1A92A16600BC1EC6 /* duration.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = duration.proto; path = ../src/google/protobuf/duration.proto; sourceTree = ""; }; 8B42494D1A92A16600BC1EC6 /* timestamp.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = timestamp.proto; path = ../src/google/protobuf/timestamp.proto; sourceTree = ""; }; - 8B54585814DCC34E003D7338 /* Descriptor.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Descriptor.pbobjc.h; path = google/protobuf/Descriptor.pbobjc.h; sourceTree = SOURCE_ROOT; }; 8B79657814992E3E002FFBFC /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBRootObject.h; sourceTree = ""; }; 8B79657914992E3E002FFBFC /* GPBRootObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBRootObject.m; sourceTree = ""; }; 8B7E6A7414893DBA00F8884A /* unittest_custom_options.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_custom_options.proto; path = ../../src/google/protobuf/unittest_custom_options.proto; sourceTree = ""; }; @@ -162,7 +158,6 @@ 8BCF338814ED799900BC5317 /* GPBProtocolBuffers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBProtocolBuffers.m; sourceTree = ""; }; 8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_enormous_descriptor.proto; path = ../../src/google/protobuf/unittest_enormous_descriptor.proto; sourceTree = ""; }; 8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos.m; sourceTree = ""; }; - 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Descriptor.pbobjc.m; path = google/protobuf/Descriptor.pbobjc.m; sourceTree = SOURCE_ROOT; }; 8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = ""; }; F401DC2A1A8D444600FCC765 /* GPBArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBArray.h; sourceTree = ""; }; F401DC2B1A8D444600FCC765 /* GPBArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBArray.m; sourceTree = ""; }; @@ -300,9 +295,6 @@ F4E675881B21D0000054530B /* Api.pbobjc.h */, F4E675891B21D0000054530B /* Api.pbobjc.m */, F4E675A71B21D05C0054530B /* api.proto */, - 8B54585814DCC34E003D7338 /* Descriptor.pbobjc.h */, - 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */, - 8B42494B1A92A16600BC1EC6 /* descriptor.proto */, 8B4248D31A92826400BC1EC6 /* Duration.pbobjc.h */, 8B4248D41A92826400BC1EC6 /* Duration.pbobjc.m */, 8B42494C1A92A16600BC1EC6 /* duration.proto */, @@ -634,7 +626,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */, 7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */, F4E6759B1B21D0000054530B /* Empty.pbobjc.m in Sources */, 7461B53D0F94FB4E00A0C422 /* GPBCodedOutputStream.m in Sources */, @@ -696,7 +687,6 @@ 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */, 8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */, F4E675B11B21D0A70054530B /* FieldMask.pbobjc.m in Sources */, - 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */, 8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */, F4E675AF1B21D0A70054530B /* Api.pbobjc.m in Sources */, ); diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj index 5d96c05f..b6221819 100644 --- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; }; 5102DABC1891A073002037B6 /* GPBConcurrencyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */; }; 7461B5360F94FB4600A0C422 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */; }; @@ -27,7 +26,6 @@ 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B79657914992E3E002FFBFC /* GPBRootObject.m */; }; 8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8B615C17DF7056002EE618 /* GPBARCUnittestProtos.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 8B96157414C8C38C00A2AC0B /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B96157314C8C38C00A2AC0B /* GPBDescriptor.m */; }; - 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */; }; 8B9742331A89D19F00DCE92C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8B9742321A89D19F00DCE92C /* LaunchScreen.xib */; }; 8B9742431A8AAA7800DCE92C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B9742421A8AAA7800DCE92C /* CoreGraphics.framework */; }; 8B9A5EA61831993600A9D33B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; @@ -155,7 +153,6 @@ 8B4248E21A929C8900BC1EC6 /* GPBWellKnownTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypes.m; sourceTree = ""; }; 8B4248E51A929C9900BC1EC6 /* GPBWellKnownTypesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBWellKnownTypesTest.m; sourceTree = ""; }; 8B4249481A92A02300BC1EC6 /* timestamp.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = timestamp.proto; path = ../src/google/protobuf/timestamp.proto; sourceTree = ""; }; - 8B4249491A92A0BA00BC1EC6 /* descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = descriptor.proto; path = ../src/google/protobuf/descriptor.proto; sourceTree = ""; }; 8B42494A1A92A0BA00BC1EC6 /* duration.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = duration.proto; path = ../src/google/protobuf/duration.proto; sourceTree = ""; }; 8B79657814992E3E002FFBFC /* GPBRootObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBRootObject.h; sourceTree = ""; }; 8B79657914992E3E002FFBFC /* GPBRootObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBRootObject.m; sourceTree = ""; }; @@ -183,7 +180,6 @@ 8BCF338814ED799900BC5317 /* GPBProtocolBuffers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBProtocolBuffers.m; sourceTree = ""; }; 8BD3981D14BE54220081D629 /* unittest_enormous_descriptor.proto */ = {isa = PBXFileReference; lastKnownFileType = text; name = unittest_enormous_descriptor.proto; path = ../../src/google/protobuf/unittest_enormous_descriptor.proto; sourceTree = ""; }; 8BD3981E14BE59D70081D629 /* GPBUnittestProtos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBUnittestProtos.m; sourceTree = ""; }; - 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Descriptor.pbobjc.m; path = google/protobuf/Descriptor.pbobjc.m; sourceTree = SOURCE_ROOT; }; 8BEB5AE01498033E0078BF9D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRuntimeTypes.h; sourceTree = ""; }; F401DC341A8E5C6F00FCC765 /* GPBArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBArrayTests.m; sourceTree = ""; }; F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = ""; }; @@ -224,7 +220,6 @@ F4E675B71B21D1440054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = ""; }; F4E675B81B21D1440054530B /* Api.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Api.pbobjc.h; path = google/protobuf/Api.pbobjc.h; sourceTree = ""; }; F4E675B91B21D1440054530B /* Api.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Api.pbobjc.m; path = google/protobuf/Api.pbobjc.m; sourceTree = ""; }; - F4E675BA1B21D1440054530B /* Descriptor.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Descriptor.pbobjc.h; path = google/protobuf/Descriptor.pbobjc.h; sourceTree = ""; }; F4E675BB1B21D1440054530B /* Empty.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Empty.pbobjc.h; path = google/protobuf/Empty.pbobjc.h; sourceTree = ""; }; F4E675BC1B21D1440054530B /* Empty.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Empty.pbobjc.m; path = google/protobuf/Empty.pbobjc.m; sourceTree = ""; }; F4E675BD1B21D1440054530B /* FieldMask.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FieldMask.pbobjc.h; path = google/protobuf/FieldMask.pbobjc.h; sourceTree = ""; }; @@ -335,9 +330,6 @@ F4E675B81B21D1440054530B /* Api.pbobjc.h */, F4E675B91B21D1440054530B /* Api.pbobjc.m */, F4E675D91B21D1DE0054530B /* api.proto */, - F4E675BA1B21D1440054530B /* Descriptor.pbobjc.h */, - 8BD3982214BE5B0C0081D629 /* Descriptor.pbobjc.m */, - 8B4249491A92A0BA00BC1EC6 /* descriptor.proto */, 8B4248DD1A929C7D00BC1EC6 /* Duration.pbobjc.h */, 8B4248DE1A929C7D00BC1EC6 /* Duration.pbobjc.m */, 8B42494A1A92A0BA00BC1EC6 /* duration.proto */, @@ -722,7 +714,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2CFB390415C718CE00CBF84D /* Descriptor.pbobjc.m in Sources */, 7461B53C0F94FB4E00A0C422 /* GPBCodedInputStream.m in Sources */, F4E675D21B21D1620054530B /* Empty.pbobjc.m in Sources */, F4487C731A9F906200531423 /* GPBArray.m in Sources */, @@ -792,7 +783,6 @@ 8B79657D14992E3F002FFBFC /* GPBRootObject.m in Sources */, 8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */, F4E675CB1B21D1610054530B /* FieldMask.pbobjc.m in Sources */, - 8B96157514CA019D00A2AC0B /* Descriptor.pbobjc.m in Sources */, 8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */, F4E675C91B21D1610054530B /* Api.pbobjc.m in Sources */, ); diff --git a/objectivec/Tests/GPBARCUnittestProtos.m b/objectivec/Tests/GPBARCUnittestProtos.m index d0408869..28d2396c 100644 --- a/objectivec/Tests/GPBARCUnittestProtos.m +++ b/objectivec/Tests/GPBARCUnittestProtos.m @@ -34,6 +34,11 @@ // Makes sure all the generated headers compile with ARC on. +// The unittest_custom_options.proto extends the messages in descriptor.proto +// so we build it in to test extending in general. The library doesn't provide +// a descriptor as it doesn't use the classes/enums. +#import "google/protobuf/Descriptor.pbobjc.h" + #import "google/protobuf/Unittest.pbobjc.h" #import "google/protobuf/UnittestCustomOptions.pbobjc.h" #import "google/protobuf/UnittestCycle.pbobjc.h" diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m index ccdbb645..a1923c9c 100644 --- a/objectivec/Tests/GPBDescriptorTests.m +++ b/objectivec/Tests/GPBDescriptorTests.m @@ -153,19 +153,6 @@ XCTAssertFalse([fieldDescriptor isValidEnumValue:-2]); } -- (void)testEnumDescriptorLookup { - GPBDescriptor *descriptor = [TestAllTypes descriptor]; - GPBEnumDescriptor *enumDescriptor = - [descriptor enumWithName:@"TestAllTypes_NestedEnum"]; - XCTAssertNotNil(enumDescriptor); - - // Descriptor cannot find foreign or imported enums. - enumDescriptor = [descriptor enumWithName:@"ForeignEnumEnum"]; - XCTAssertNil(enumDescriptor); - enumDescriptor = [descriptor enumWithName:@"ImportEnumEnum"]; - XCTAssertNil(enumDescriptor); -} - - (void)testOneofDescriptor { GPBDescriptor *descriptor = [TestOneof2 descriptor]; diff --git a/objectivec/Tests/GPBUnittestProtos.m b/objectivec/Tests/GPBUnittestProtos.m index 50c4dfa9..d19beee9 100644 --- a/objectivec/Tests/GPBUnittestProtos.m +++ b/objectivec/Tests/GPBUnittestProtos.m @@ -31,6 +31,11 @@ // Collects all the compiled protos into one file and compiles them to make sure // the compiler is generating valid code. +// The unittest_custom_options.proto extends the messages in descriptor.proto +// so we build it in to test extending in general. The library doesn't provide +// a descriptor as it doesn't use the classes/enums. +#import "google/protobuf/Descriptor.pbobjc.m" + #import "google/protobuf/MapProto2Unittest.pbobjc.m" #import "google/protobuf/MapUnittest.pbobjc.m" #import "google/protobuf/Unittest.pbobjc.m" diff --git a/objectivec/generate_descriptors_proto.sh b/objectivec/generate_descriptors_proto.sh deleted file mode 100755 index 84ba0738..00000000 --- a/objectivec/generate_descriptors_proto.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -# Run this script to regenerate descriptor.pbobjc.{h,m} after the protocol -# compiler changes. - -# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly -# to make when building protoc. This is particularly useful for passing -# -j4 to run 4 jobs simultaneously. - -set -eu - -readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")") -readonly ProtoRootDir="${ScriptDir}/.." - -pushd "${ProtoRootDir}" > /dev/null - -if test ! -e src/google/protobuf/stubs/common.h; then - cat >&2 << __EOF__ -Could not find source code. Make sure you are running this script from the -root of the distribution tree. -__EOF__ - exit 1 -fi - -if test ! -e src/Makefile; then - cat >&2 << __EOF__ -Could not find src/Makefile. You must run ./configure (and perhaps -./autogen.sh) first. -__EOF__ - exit 1 -fi - -# Make sure the compiler is current. -cd src -make $@ protoc - -declare -a RUNTIME_PROTO_FILES=( \ - google/protobuf/any.proto \ - google/protobuf/api.proto \ - google/protobuf/descriptor.proto \ - google/protobuf/duration.proto \ - google/protobuf/empty.proto \ - google/protobuf/field_mask.proto \ - google/protobuf/source_context.proto \ - google/protobuf/struct.proto \ - google/protobuf/timestamp.proto \ - google/protobuf/type.proto \ - google/protobuf/wrappers.proto) - -./protoc --objc_out="${ProtoRootDir}/objectivec" ${RUNTIME_PROTO_FILES[@]} diff --git a/objectivec/generate_well_known_types.sh b/objectivec/generate_well_known_types.sh new file mode 100755 index 00000000..be9b38a5 --- /dev/null +++ b/objectivec/generate_well_known_types.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Run this script to regenerate *.pbobjc.{h,m} for the well known types after +# the protocol compiler changes. + +# HINT: Flags passed to generate_well_known_types.sh will be passed directly +# to make when building protoc. This is particularly useful for passing +# -j4 to run 4 jobs simultaneously. + +set -eu + +readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")") +readonly ProtoRootDir="${ScriptDir}/.." + +pushd "${ProtoRootDir}" > /dev/null + +if test ! -e src/google/protobuf/stubs/common.h; then + cat >&2 << __EOF__ +Could not find source code. Make sure you are running this script from the +root of the distribution tree. +__EOF__ + exit 1 +fi + +if test ! -e src/Makefile; then + cat >&2 << __EOF__ +Could not find src/Makefile. You must run ./configure (and perhaps +./autogen.sh) first. +__EOF__ + exit 1 +fi + +# Make sure the compiler is current. +cd src +make $@ protoc + +declare -a RUNTIME_PROTO_FILES=( \ + google/protobuf/any.proto \ + google/protobuf/api.proto \ + google/protobuf/duration.proto \ + google/protobuf/empty.proto \ + google/protobuf/field_mask.proto \ + google/protobuf/source_context.proto \ + google/protobuf/struct.proto \ + google/protobuf/timestamp.proto \ + google/protobuf/type.proto \ + google/protobuf/wrappers.proto) + +./protoc --objc_out="${ProtoRootDir}/objectivec" ${RUNTIME_PROTO_FILES[@]} diff --git a/objectivec/google/protobuf/Any.pbobjc.h b/objectivec/google/protobuf/Any.pbobjc.h index a204ae9a..79ec0fb7 100644 --- a/objectivec/google/protobuf/Any.pbobjc.h +++ b/objectivec/google/protobuf/Any.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Any.pbobjc.m b/objectivec/google/protobuf/Any.pbobjc.m index b41102a4..7cbf0def 100644 --- a/objectivec/google/protobuf/Any.pbobjc.m +++ b/objectivec/google/protobuf/Any.pbobjc.m @@ -46,47 +46,36 @@ typedef struct GPBAny__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "typeURL", + .dataTypeSpecific.className = NULL, .number = GPBAny_FieldNumber_TypeURL, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBAny__storage_, typeURL), .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom, .dataType = GPBDataTypeString, - .offset = offsetof(GPBAny__storage_, typeURL), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBAny_FieldNumber_Value, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBAny__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeBytes, - .offset = offsetof(GPBAny__storage_, value), - .defaultValue.valueData = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; -#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - const char *extraTextFormatInfo = NULL; -#else - static const char *extraTextFormatInfo = "\001\001\004\241!!\000"; -#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS GPBDescriptor *localDescriptor = [GPBDescriptor allocDescriptorForClass:[GPBAny class] rootClass:[GPBAnyRoot class] file:GPBAnyRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBAny__storage_) - wireFormat:NO - extraTextFormatInfo:extraTextFormatInfo]; + flags:0]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\004\241!!\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Api.pbobjc.h b/objectivec/google/protobuf/Api.pbobjc.h index 271a166f..3f7e99c6 100644 --- a/objectivec/google/protobuf/Api.pbobjc.h +++ b/objectivec/google/protobuf/Api.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Api.pbobjc.m b/objectivec/google/protobuf/Api.pbobjc.m index d964ff41..2b2f62ea 100644 --- a/objectivec/google/protobuf/Api.pbobjc.m +++ b/objectivec/google/protobuf/Api.pbobjc.m @@ -71,80 +71,66 @@ typedef struct GPBApi__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBApi_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBApi__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBApi__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "methodsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBMethod), .number = GPBApi_FieldNumber_MethodsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBApi__storage_, methodsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBApi__storage_, methodsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBMethod), - .fieldOptions = NULL, }, { .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), .number = GPBApi_FieldNumber_OptionsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBApi__storage_, optionsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBApi__storage_, optionsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), - .fieldOptions = NULL, }, { .name = "version", + .dataTypeSpecific.className = NULL, .number = GPBApi_FieldNumber_Version, - .hasIndex = 3, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBApi__storage_, version), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBApi__storage_, version), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "sourceContext", + .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), .number = GPBApi_FieldNumber_SourceContext, - .hasIndex = 4, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBApi__storage_, sourceContext), .flags = GPBFieldOptional, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBApi__storage_, sourceContext), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), - .fieldOptions = NULL, }, { .name = "mixinsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBMixin), .number = GPBApi_FieldNumber_MixinsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBApi__storage_, mixinsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBApi__storage_, mixinsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBMixin), - .fieldOptions = NULL, }, { .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, .number = GPBApi_FieldNumber_Syntax, - .hasIndex = 6, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GPBApi__storage_, syntax), .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBApi__storage_, syntax), - .defaultValue.valueEnum = GPBSyntax_SyntaxProto2, - .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -152,15 +138,9 @@ typedef struct GPBApi__storage_ { 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 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBApi__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -195,8 +175,6 @@ void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value) { typedef struct GPBMethod__storage_ { uint32_t _has_storage_[1]; - BOOL requestStreaming; - BOOL responseStreaming; GPBSyntax syntax; NSString *name; NSString *requestTypeURL; @@ -212,102 +190,81 @@ typedef struct GPBMethod__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBMethod_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBMethod__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBMethod__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "requestTypeURL", + .dataTypeSpecific.className = NULL, .number = GPBMethod_FieldNumber_RequestTypeURL, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBMethod__storage_, requestTypeURL), .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom, .dataType = GPBDataTypeString, - .offset = offsetof(GPBMethod__storage_, requestTypeURL), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "requestStreaming", + .dataTypeSpecific.className = NULL, .number = GPBMethod_FieldNumber_RequestStreaming, .hasIndex = 2, + .offset = 3, // Stored in _has_storage_ to save space. .flags = GPBFieldOptional, .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMethod__storage_, requestStreaming), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "responseTypeURL", + .dataTypeSpecific.className = NULL, .number = GPBMethod_FieldNumber_ResponseTypeURL, - .hasIndex = 3, + .hasIndex = 4, + .offset = (uint32_t)offsetof(GPBMethod__storage_, responseTypeURL), .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom, .dataType = GPBDataTypeString, - .offset = offsetof(GPBMethod__storage_, responseTypeURL), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "responseStreaming", + .dataTypeSpecific.className = NULL, .number = GPBMethod_FieldNumber_ResponseStreaming, - .hasIndex = 4, + .hasIndex = 5, + .offset = 6, // Stored in _has_storage_ to save space. .flags = GPBFieldOptional, .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMethod__storage_, responseStreaming), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), .number = GPBMethod_FieldNumber_OptionsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBMethod__storage_, optionsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBMethod__storage_, optionsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), - .fieldOptions = NULL, }, { .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, .number = GPBMethod_FieldNumber_Syntax, - .hasIndex = 6, + .hasIndex = 7, + .offset = (uint32_t)offsetof(GPBMethod__storage_, syntax), .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; -#else - static const char *extraTextFormatInfo = "\002\002\007\244\241!!\000\004\010\244\241!!\000"; -#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS GPBDescriptor *localDescriptor = [GPBDescriptor allocDescriptorForClass:[GPBMethod 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 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBMethod__storage_) - wireFormat:NO - extraTextFormatInfo:extraTextFormatInfo]; + flags:0]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\002\007\244\241!!\000\004\010\244\241!!\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -349,25 +306,21 @@ typedef struct GPBMixin__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBMixin_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBMixin__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBMixin__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "root", + .dataTypeSpecific.className = NULL, .number = GPBMixin_FieldNumber_Root, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBMixin__storage_, root), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBMixin__storage_, root), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -375,15 +328,9 @@ typedef struct GPBMixin__storage_ { 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 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBMixin__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Descriptor.pbobjc.h b/objectivec/google/protobuf/Descriptor.pbobjc.h deleted file mode 100644 index 109711c7..00000000 --- a/objectivec/google/protobuf/Descriptor.pbobjc.h +++ /dev/null @@ -1,1279 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/descriptor.proto - -#import "GPBProtocolBuffers.h" - -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 -#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -CF_EXTERN_C_BEGIN - -@class GPBDescriptorProto; -@class GPBDescriptorProto_ExtensionRange; -@class GPBDescriptorProto_ReservedRange; -@class GPBEnumDescriptorProto; -@class GPBEnumOptions; -@class GPBEnumValueDescriptorProto; -@class GPBEnumValueOptions; -@class GPBFieldDescriptorProto; -@class GPBFieldOptions; -@class GPBFileDescriptorProto; -@class GPBFileOptions; -@class GPBGeneratedCodeInfo_Annotation; -@class GPBMessageOptions; -@class GPBMethodDescriptorProto; -@class GPBMethodOptions; -@class GPBOneofDescriptorProto; -@class GPBServiceDescriptorProto; -@class GPBServiceOptions; -@class GPBSourceCodeInfo; -@class GPBSourceCodeInfo_Location; -@class GPBUninterpretedOption; -@class GPBUninterpretedOption_NamePart; - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - Enum GPBFieldDescriptorProto_Type - -typedef GPB_ENUM(GPBFieldDescriptorProto_Type) { - /// 0 is reserved for errors. - /// Order is weird for historical reasons. - GPBFieldDescriptorProto_Type_TypeDouble = 1, - GPBFieldDescriptorProto_Type_TypeFloat = 2, - - /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if - /// negative values are likely. - GPBFieldDescriptorProto_Type_TypeInt64 = 3, - GPBFieldDescriptorProto_Type_TypeUint64 = 4, - - /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if - /// negative values are likely. - GPBFieldDescriptorProto_Type_TypeInt32 = 5, - GPBFieldDescriptorProto_Type_TypeFixed64 = 6, - GPBFieldDescriptorProto_Type_TypeFixed32 = 7, - GPBFieldDescriptorProto_Type_TypeBool = 8, - GPBFieldDescriptorProto_Type_TypeString = 9, - - /// Tag-delimited aggregate. - GPBFieldDescriptorProto_Type_TypeGroup = 10, - - /// Length-delimited aggregate. - GPBFieldDescriptorProto_Type_TypeMessage = 11, - - /// New in version 2. - GPBFieldDescriptorProto_Type_TypeBytes = 12, - GPBFieldDescriptorProto_Type_TypeUint32 = 13, - GPBFieldDescriptorProto_Type_TypeEnum = 14, - GPBFieldDescriptorProto_Type_TypeSfixed32 = 15, - GPBFieldDescriptorProto_Type_TypeSfixed64 = 16, - - /// Uses ZigZag encoding. - GPBFieldDescriptorProto_Type_TypeSint32 = 17, - - /// Uses ZigZag encoding. - GPBFieldDescriptorProto_Type_TypeSint64 = 18, -}; - -GPBEnumDescriptor *GPBFieldDescriptorProto_Type_EnumDescriptor(void); - -/// Checks to see if the given value is defined by the enum or was not known at -/// the time this source was generated. -BOOL GPBFieldDescriptorProto_Type_IsValidValue(int32_t value); - -#pragma mark - Enum GPBFieldDescriptorProto_Label - -typedef GPB_ENUM(GPBFieldDescriptorProto_Label) { - /// 0 is reserved for errors - GPBFieldDescriptorProto_Label_LabelOptional = 1, - GPBFieldDescriptorProto_Label_LabelRequired = 2, - - /// TODO(sanjay): Should we add LABEL_MAP? - GPBFieldDescriptorProto_Label_LabelRepeated = 3, -}; - -GPBEnumDescriptor *GPBFieldDescriptorProto_Label_EnumDescriptor(void); - -/// Checks to see if the given value is defined by the enum or was not known at -/// the time this source was generated. -BOOL GPBFieldDescriptorProto_Label_IsValidValue(int32_t value); - -#pragma mark - Enum GPBFileOptions_OptimizeMode - -/// Generated classes can be optimized for speed or code size. -typedef GPB_ENUM(GPBFileOptions_OptimizeMode) { - /// Generate complete code for parsing, serialization, - GPBFileOptions_OptimizeMode_Speed = 1, - - /// etc. - GPBFileOptions_OptimizeMode_CodeSize = 2, - - /// Generate code using MessageLite and the lite runtime. - GPBFileOptions_OptimizeMode_LiteRuntime = 3, -}; - -GPBEnumDescriptor *GPBFileOptions_OptimizeMode_EnumDescriptor(void); - -/// Checks to see if the given value is defined by the enum or was not known at -/// the time this source was generated. -BOOL GPBFileOptions_OptimizeMode_IsValidValue(int32_t value); - -#pragma mark - Enum GPBFieldOptions_CType - -typedef GPB_ENUM(GPBFieldOptions_CType) { - /// Default mode. - GPBFieldOptions_CType_String = 0, - GPBFieldOptions_CType_Cord = 1, - GPBFieldOptions_CType_StringPiece = 2, -}; - -GPBEnumDescriptor *GPBFieldOptions_CType_EnumDescriptor(void); - -/// Checks to see if the given value is defined by the enum or was not known at -/// the time this source was generated. -BOOL GPBFieldOptions_CType_IsValidValue(int32_t value); - -#pragma mark - Enum GPBFieldOptions_JSType - -typedef GPB_ENUM(GPBFieldOptions_JSType) { - /// Use the default type. - GPBFieldOptions_JSType_JsNormal = 0, - - /// Use JavaScript strings. - GPBFieldOptions_JSType_JsString = 1, - - /// Use JavaScript numbers. - GPBFieldOptions_JSType_JsNumber = 2, -}; - -GPBEnumDescriptor *GPBFieldOptions_JSType_EnumDescriptor(void); - -/// Checks to see if the given value is defined by the enum or was not known at -/// the time this source was generated. -BOOL GPBFieldOptions_JSType_IsValidValue(int32_t value); - -#pragma mark - GPBDescriptorRoot - -/// Exposes the extension registry for this file. -/// -/// The base class provides: -/// @code -/// + (GPBExtensionRegistry *)extensionRegistry; -/// @endcode -/// which is a @c GPBExtensionRegistry that includes all the extensions defined by -/// this file and all files that it depends on. -@interface GPBDescriptorRoot : GPBRootObject -@end - -#pragma mark - GPBFileDescriptorSet - -typedef GPB_ENUM(GPBFileDescriptorSet_FieldNumber) { - GPBFileDescriptorSet_FieldNumber_FileArray = 1, -}; - -/// The protocol compiler can output a FileDescriptorSet containing the .proto -/// files it parses. -@interface GPBFileDescriptorSet : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fileArray; -/// The number of items in @c fileArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger fileArray_Count; - -@end - -#pragma mark - GPBFileDescriptorProto - -typedef GPB_ENUM(GPBFileDescriptorProto_FieldNumber) { - GPBFileDescriptorProto_FieldNumber_Name = 1, - GPBFileDescriptorProto_FieldNumber_Package = 2, - GPBFileDescriptorProto_FieldNumber_DependencyArray = 3, - GPBFileDescriptorProto_FieldNumber_MessageTypeArray = 4, - GPBFileDescriptorProto_FieldNumber_EnumTypeArray = 5, - GPBFileDescriptorProto_FieldNumber_ServiceArray = 6, - GPBFileDescriptorProto_FieldNumber_ExtensionArray = 7, - GPBFileDescriptorProto_FieldNumber_Options = 8, - GPBFileDescriptorProto_FieldNumber_SourceCodeInfo = 9, - GPBFileDescriptorProto_FieldNumber_PublicDependencyArray = 10, - GPBFileDescriptorProto_FieldNumber_WeakDependencyArray = 11, - GPBFileDescriptorProto_FieldNumber_Syntax = 12, -}; - -/// Describes a complete .proto file. -@interface GPBFileDescriptorProto : GPBMessage - -/// file name, relative to root of source tree -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -/// e.g. "foo", "foo.bar", etc. -@property(nonatomic, readwrite, copy, null_resettable) NSString *package; -/// Test to see if @c package has been set. -@property(nonatomic, readwrite) BOOL hasPackage; - -/// Names of files imported by this file. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *dependencyArray; -/// The number of items in @c dependencyArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger dependencyArray_Count; - -/// Indexes of the public imported files in the dependency list above. -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *publicDependencyArray; -/// The number of items in @c publicDependencyArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger publicDependencyArray_Count; - -/// Indexes of the weak imported files in the dependency list. -/// For Google-internal migration only. Do not use. -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *weakDependencyArray; -/// The number of items in @c weakDependencyArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger weakDependencyArray_Count; - -/// All top-level definitions in this file. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *messageTypeArray; -/// The number of items in @c messageTypeArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger messageTypeArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumTypeArray; -/// The number of items in @c enumTypeArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger enumTypeArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *serviceArray; -/// The number of items in @c serviceArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger serviceArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionArray; -/// The number of items in @c extensionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger extensionArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) GPBFileOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -/// This field contains optional information about the original source code. -/// You may safely remove this entire field without harming runtime -/// functionality of the descriptors -- the information is needed only by -/// development tools. -@property(nonatomic, readwrite, strong, null_resettable) GPBSourceCodeInfo *sourceCodeInfo; -/// Test to see if @c sourceCodeInfo has been set. -@property(nonatomic, readwrite) BOOL hasSourceCodeInfo; - -/// The syntax of the proto file. -/// The supported values are "proto2" and "proto3". -@property(nonatomic, readwrite, copy, null_resettable) NSString *syntax; -/// Test to see if @c syntax has been set. -@property(nonatomic, readwrite) BOOL hasSyntax; - -@end - -#pragma mark - GPBDescriptorProto - -typedef GPB_ENUM(GPBDescriptorProto_FieldNumber) { - GPBDescriptorProto_FieldNumber_Name = 1, - GPBDescriptorProto_FieldNumber_FieldArray = 2, - GPBDescriptorProto_FieldNumber_NestedTypeArray = 3, - GPBDescriptorProto_FieldNumber_EnumTypeArray = 4, - GPBDescriptorProto_FieldNumber_ExtensionRangeArray = 5, - GPBDescriptorProto_FieldNumber_ExtensionArray = 6, - GPBDescriptorProto_FieldNumber_Options = 7, - GPBDescriptorProto_FieldNumber_OneofDeclArray = 8, - GPBDescriptorProto_FieldNumber_ReservedRangeArray = 9, - GPBDescriptorProto_FieldNumber_ReservedNameArray = 10, -}; - -/// Describes a message type. -@interface GPBDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldArray; -/// The number of items in @c fieldArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger fieldArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionArray; -/// The number of items in @c extensionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger extensionArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *nestedTypeArray; -/// The number of items in @c nestedTypeArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger nestedTypeArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumTypeArray; -/// The number of items in @c enumTypeArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger enumTypeArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *extensionRangeArray; -/// The number of items in @c extensionRangeArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger extensionRangeArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofDeclArray; -/// The number of items in @c oneofDeclArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger oneofDeclArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) GPBMessageOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *reservedRangeArray; -/// The number of items in @c reservedRangeArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger reservedRangeArray_Count; - -/// Reserved field names, which may not be used by fields in the same message. -/// A given name may only be reserved once. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *reservedNameArray; -/// The number of items in @c reservedNameArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger reservedNameArray_Count; - -@end - -#pragma mark - GPBDescriptorProto_ExtensionRange - -typedef GPB_ENUM(GPBDescriptorProto_ExtensionRange_FieldNumber) { - GPBDescriptorProto_ExtensionRange_FieldNumber_Start = 1, - GPBDescriptorProto_ExtensionRange_FieldNumber_End = 2, -}; - -@interface GPBDescriptorProto_ExtensionRange : GPBMessage - -@property(nonatomic, readwrite) int32_t start; - -@property(nonatomic, readwrite) BOOL hasStart; -@property(nonatomic, readwrite) int32_t end; - -@property(nonatomic, readwrite) BOOL hasEnd; -@end - -#pragma mark - GPBDescriptorProto_ReservedRange - -typedef GPB_ENUM(GPBDescriptorProto_ReservedRange_FieldNumber) { - GPBDescriptorProto_ReservedRange_FieldNumber_Start = 1, - GPBDescriptorProto_ReservedRange_FieldNumber_End = 2, -}; - -/// Range of reserved tag numbers. Reserved tag numbers may not be used by -/// fields or extension ranges in the same message. Reserved ranges may -/// not overlap. -@interface GPBDescriptorProto_ReservedRange : GPBMessage - -/// Inclusive. -@property(nonatomic, readwrite) int32_t start; - -@property(nonatomic, readwrite) BOOL hasStart; -/// Exclusive. -@property(nonatomic, readwrite) int32_t end; - -@property(nonatomic, readwrite) BOOL hasEnd; -@end - -#pragma mark - GPBFieldDescriptorProto - -typedef GPB_ENUM(GPBFieldDescriptorProto_FieldNumber) { - GPBFieldDescriptorProto_FieldNumber_Name = 1, - GPBFieldDescriptorProto_FieldNumber_Extendee = 2, - GPBFieldDescriptorProto_FieldNumber_Number = 3, - GPBFieldDescriptorProto_FieldNumber_Label = 4, - GPBFieldDescriptorProto_FieldNumber_Type = 5, - GPBFieldDescriptorProto_FieldNumber_TypeName = 6, - GPBFieldDescriptorProto_FieldNumber_DefaultValue = 7, - GPBFieldDescriptorProto_FieldNumber_Options = 8, - GPBFieldDescriptorProto_FieldNumber_OneofIndex = 9, - GPBFieldDescriptorProto_FieldNumber_JsonName = 10, -}; - -/// Describes a field within a message. -@interface GPBFieldDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -@property(nonatomic, readwrite) int32_t number; - -@property(nonatomic, readwrite) BOOL hasNumber; -@property(nonatomic, readwrite) GPBFieldDescriptorProto_Label label; - -@property(nonatomic, readwrite) BOOL hasLabel; -/// If type_name is set, this need not be set. If both this and type_name -/// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. -@property(nonatomic, readwrite) GPBFieldDescriptorProto_Type type; - -@property(nonatomic, readwrite) BOOL hasType; -/// For message and enum types, this is the name of the type. If the name -/// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping -/// rules are used to find the type (i.e. first the nested types within this -/// message are searched, then within the parent, on up to the root -/// namespace). -@property(nonatomic, readwrite, copy, null_resettable) NSString *typeName; -/// Test to see if @c typeName has been set. -@property(nonatomic, readwrite) BOOL hasTypeName; - -/// For extensions, this is the name of the type being extended. It is -/// resolved in the same manner as type_name. -@property(nonatomic, readwrite, copy, null_resettable) NSString *extendee; -/// Test to see if @c extendee has been set. -@property(nonatomic, readwrite) BOOL hasExtendee; - -/// For numeric types, contains the original text representation of the value. -/// For booleans, "true" or "false". -/// For strings, contains the default text contents (not escaped in any way). -/// For bytes, contains the C escaped value. All bytes >= 128 are escaped. -/// TODO(kenton): Base-64 encode? -@property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue; -/// Test to see if @c defaultValue has been set. -@property(nonatomic, readwrite) BOOL hasDefaultValue; - -/// If set, gives the index of a oneof in the containing type's oneof_decl -/// list. This field is a member of that oneof. -@property(nonatomic, readwrite) int32_t oneofIndex; - -@property(nonatomic, readwrite) BOOL hasOneofIndex; -/// JSON name of this field. The value is set by protocol compiler. If the -/// user has set a "json_name" option on this field, that option's value -/// will be used. Otherwise, it's deduced from the field's name by converting -/// it to camelCase. -@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName; -/// Test to see if @c jsonName has been set. -@property(nonatomic, readwrite) BOOL hasJsonName; - -@property(nonatomic, readwrite, strong, null_resettable) GPBFieldOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -@end - -#pragma mark - GPBOneofDescriptorProto - -typedef GPB_ENUM(GPBOneofDescriptorProto_FieldNumber) { - GPBOneofDescriptorProto_FieldNumber_Name = 1, -}; - -/// Describes a oneof. -@interface GPBOneofDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -@end - -#pragma mark - GPBEnumDescriptorProto - -typedef GPB_ENUM(GPBEnumDescriptorProto_FieldNumber) { - GPBEnumDescriptorProto_FieldNumber_Name = 1, - GPBEnumDescriptorProto_FieldNumber_ValueArray = 2, - GPBEnumDescriptorProto_FieldNumber_Options = 3, -}; - -/// Describes an enum type. -@interface GPBEnumDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valueArray; -/// The number of items in @c valueArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger valueArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) GPBEnumOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -@end - -#pragma mark - GPBEnumValueDescriptorProto - -typedef GPB_ENUM(GPBEnumValueDescriptorProto_FieldNumber) { - GPBEnumValueDescriptorProto_FieldNumber_Name = 1, - GPBEnumValueDescriptorProto_FieldNumber_Number = 2, - GPBEnumValueDescriptorProto_FieldNumber_Options = 3, -}; - -/// Describes a value within an enum. -@interface GPBEnumValueDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -@property(nonatomic, readwrite) int32_t number; - -@property(nonatomic, readwrite) BOOL hasNumber; -@property(nonatomic, readwrite, strong, null_resettable) GPBEnumValueOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -@end - -#pragma mark - GPBServiceDescriptorProto - -typedef GPB_ENUM(GPBServiceDescriptorProto_FieldNumber) { - GPBServiceDescriptorProto_FieldNumber_Name = 1, - GPBServiceDescriptorProto_FieldNumber_MethodArray = 2, - GPBServiceDescriptorProto_FieldNumber_Options = 3, -}; - -/// Describes a service. -@interface GPBServiceDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodArray; -/// The number of items in @c methodArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger methodArray_Count; - -@property(nonatomic, readwrite, strong, null_resettable) GPBServiceOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -@end - -#pragma mark - GPBMethodDescriptorProto - -typedef GPB_ENUM(GPBMethodDescriptorProto_FieldNumber) { - GPBMethodDescriptorProto_FieldNumber_Name = 1, - GPBMethodDescriptorProto_FieldNumber_InputType = 2, - GPBMethodDescriptorProto_FieldNumber_OutputType = 3, - GPBMethodDescriptorProto_FieldNumber_Options = 4, - GPBMethodDescriptorProto_FieldNumber_ClientStreaming = 5, - GPBMethodDescriptorProto_FieldNumber_ServerStreaming = 6, -}; - -/// Describes a method of a service. -@interface GPBMethodDescriptorProto : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *name; -/// Test to see if @c name has been set. -@property(nonatomic, readwrite) BOOL hasName; - -/// Input and output type names. These are resolved in the same way as -/// FieldDescriptorProto.type_name, but must refer to a message type. -@property(nonatomic, readwrite, copy, null_resettable) NSString *inputType; -/// Test to see if @c inputType has been set. -@property(nonatomic, readwrite) BOOL hasInputType; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *outputType; -/// Test to see if @c outputType has been set. -@property(nonatomic, readwrite) BOOL hasOutputType; - -@property(nonatomic, readwrite, strong, null_resettable) GPBMethodOptions *options; -/// Test to see if @c options has been set. -@property(nonatomic, readwrite) BOOL hasOptions; - -/// Identifies if client streams multiple client messages -@property(nonatomic, readwrite) BOOL clientStreaming; - -@property(nonatomic, readwrite) BOOL hasClientStreaming; -/// Identifies if server streams multiple server messages -@property(nonatomic, readwrite) BOOL serverStreaming; - -@property(nonatomic, readwrite) BOOL hasServerStreaming; -@end - -#pragma mark - GPBFileOptions - -typedef GPB_ENUM(GPBFileOptions_FieldNumber) { - GPBFileOptions_FieldNumber_JavaPackage = 1, - GPBFileOptions_FieldNumber_JavaOuterClassname = 8, - GPBFileOptions_FieldNumber_OptimizeFor = 9, - GPBFileOptions_FieldNumber_JavaMultipleFiles = 10, - GPBFileOptions_FieldNumber_GoPackage = 11, - GPBFileOptions_FieldNumber_CcGenericServices = 16, - GPBFileOptions_FieldNumber_JavaGenericServices = 17, - GPBFileOptions_FieldNumber_PyGenericServices = 18, - GPBFileOptions_FieldNumber_JavaGenerateEqualsAndHash = 20, - GPBFileOptions_FieldNumber_Deprecated = 23, - GPBFileOptions_FieldNumber_JavaStringCheckUtf8 = 27, - GPBFileOptions_FieldNumber_CcEnableArenas = 31, - GPBFileOptions_FieldNumber_ObjcClassPrefix = 36, - GPBFileOptions_FieldNumber_CsharpNamespace = 37, - GPBFileOptions_FieldNumber_JavananoUseDeprecatedPackage = 38, - GPBFileOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBFileOptions : GPBMessage - -/// Sets the Java package where classes generated from this .proto will be -/// placed. By default, the proto package is used, but this is often -/// inappropriate because proto packages do not normally start with backwards -/// domain names. -@property(nonatomic, readwrite, copy, null_resettable) NSString *javaPackage; -/// Test to see if @c javaPackage has been set. -@property(nonatomic, readwrite) BOOL hasJavaPackage; - -/// If set, all the classes from the .proto file are wrapped in a single -/// outer class with the given name. This applies to both Proto1 -/// (equivalent to the old "--one_java_file" option) and Proto2 (where -/// a .proto always translates to a single class, but you may want to -/// explicitly choose the class name). -@property(nonatomic, readwrite, copy, null_resettable) NSString *javaOuterClassname; -/// Test to see if @c javaOuterClassname has been set. -@property(nonatomic, readwrite) BOOL hasJavaOuterClassname; - -/// If set true, then the Java code generator will generate a separate .java -/// file for each top-level message, enum, and service defined in the .proto -/// file. Thus, these types will *not* be nested inside the outer class -/// named by java_outer_classname. However, the outer class will still be -/// generated to contain the file's getDescriptor() method as well as any -/// top-level extensions defined in the file. -@property(nonatomic, readwrite) BOOL javaMultipleFiles; - -@property(nonatomic, readwrite) BOOL hasJavaMultipleFiles; -/// If set true, then the Java code generator will generate equals() and -/// hashCode() methods for all messages defined in the .proto file. -/// 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 -/// 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 -/// will be consistent across runtimes or versions of the protocol compiler.) -@property(nonatomic, readwrite) BOOL javaGenerateEqualsAndHash; - -@property(nonatomic, readwrite) BOOL hasJavaGenerateEqualsAndHash; -/// If set true, then the Java2 code generator will generate code that -/// throws an exception whenever an attempt is made to assign a non-UTF-8 -/// byte sequence to a string field. -/// Message reflection will do the same. -/// However, an extension field still accepts non-UTF-8 byte sequences. -/// This option has no effect on when used with the lite runtime. -@property(nonatomic, readwrite) BOOL javaStringCheckUtf8; - -@property(nonatomic, readwrite) BOOL hasJavaStringCheckUtf8; -@property(nonatomic, readwrite) GPBFileOptions_OptimizeMode optimizeFor; - -@property(nonatomic, readwrite) BOOL hasOptimizeFor; -/// Sets the Go package where structs generated from this .proto will be -/// placed. If omitted, the Go package will be derived from the following: -/// - The basename of the package import path, if provided. -/// - Otherwise, the package statement in the .proto file, if present. -/// - Otherwise, the basename of the .proto file, without extension. -@property(nonatomic, readwrite, copy, null_resettable) NSString *goPackage; -/// Test to see if @c goPackage has been set. -@property(nonatomic, readwrite) BOOL hasGoPackage; - -/// Should generic services be generated in each language? "Generic" services -/// are not specific to any particular RPC system. They are generated by the -/// main code generators in each language (without additional plugins). -/// Generic services were the only kind of service generation supported by -/// early versions of google.protobuf. -/// -/// Generic services are now considered deprecated in favor of using plugins -/// that generate code specific to your particular RPC system. Therefore, -/// these default to false. Old code which depends on generic services should -/// explicitly set them to true. -@property(nonatomic, readwrite) BOOL ccGenericServices; - -@property(nonatomic, readwrite) BOOL hasCcGenericServices; -@property(nonatomic, readwrite) BOOL javaGenericServices; - -@property(nonatomic, readwrite) BOOL hasJavaGenericServices; -@property(nonatomic, readwrite) BOOL pyGenericServices; - -@property(nonatomic, readwrite) BOOL hasPyGenericServices; -/// Is this file deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for everything in the file, or it will be completely ignored; in the very -/// least, this is a formalization for deprecating files. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// Enables the use of arenas for the proto messages in this file. This applies -/// only to generated classes for C++. -@property(nonatomic, readwrite) BOOL ccEnableArenas; - -@property(nonatomic, readwrite) BOOL hasCcEnableArenas; -/// Sets the objective c class prefix which is prepended to all objective c -/// generated classes from this .proto. There is no default. -@property(nonatomic, readwrite, copy, null_resettable) NSString *objcClassPrefix; -/// Test to see if @c objcClassPrefix has been set. -@property(nonatomic, readwrite) BOOL hasObjcClassPrefix; - -/// Namespace for generated classes; defaults to the package. -@property(nonatomic, readwrite, copy, null_resettable) NSString *csharpNamespace; -/// Test to see if @c csharpNamespace has been set. -@property(nonatomic, readwrite) BOOL hasCsharpNamespace; - -/// Whether the nano proto compiler should generate in the deprecated non-nano -/// suffixed package. -@property(nonatomic, readwrite) BOOL javananoUseDeprecatedPackage; - -@property(nonatomic, readwrite) BOOL hasJavananoUseDeprecatedPackage; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBMessageOptions - -typedef GPB_ENUM(GPBMessageOptions_FieldNumber) { - GPBMessageOptions_FieldNumber_MessageSetWireFormat = 1, - GPBMessageOptions_FieldNumber_NoStandardDescriptorAccessor = 2, - GPBMessageOptions_FieldNumber_Deprecated = 3, - GPBMessageOptions_FieldNumber_MapEntry = 7, - GPBMessageOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBMessageOptions : GPBMessage - -/// Set true to use the old proto1 MessageSet wire format for extensions. -/// This is provided for backwards-compatibility with the MessageSet wire -/// format. You should not use this for any other reason: It's less -/// efficient, has fewer features, and is more complicated. -/// -/// The message must be defined exactly as follows: -/// message Foo { -/// option message_set_wire_format = true; -/// extensions 4 to max; -/// } -/// Note that the message cannot have any defined fields; MessageSets only -/// have extensions. -/// -/// All extensions of your type must be singular messages; e.g. they cannot -/// be int32s, enums, or repeated messages. -/// -/// Because this is an option, the above two restrictions are not enforced by -/// the protocol compiler. -@property(nonatomic, readwrite) BOOL messageSetWireFormat; - -@property(nonatomic, readwrite) BOOL hasMessageSetWireFormat; -/// Disables the generation of the standard "descriptor()" accessor, which can -/// conflict with a field of the same name. This is meant to make migration -/// from proto1 easier; new code should avoid fields named "descriptor". -@property(nonatomic, readwrite) BOOL noStandardDescriptorAccessor; - -@property(nonatomic, readwrite) BOOL hasNoStandardDescriptorAccessor; -/// Is this message deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for the message, or it will be completely ignored; in the very least, -/// this is a formalization for deprecating messages. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// Whether the message is an automatically generated map entry type for the -/// maps field. -/// -/// For maps fields: -/// map map_field = 1; -/// The parsed descriptor looks like: -/// message MapFieldEntry { -/// option map_entry = true; -/// optional KeyType key = 1; -/// optional ValueType value = 2; -/// } -/// repeated MapFieldEntry map_field = 1; -/// -/// Implementations may choose not to generate the map_entry=true message, but -/// use a native map in the target language to hold the keys and values. -/// The reflection APIs in such implementions still need to work as -/// if the field is a repeated message field. -/// -/// NOTE: Do not set the option in .proto files. Always use the maps syntax -/// instead. The option should only be implicitly set by the proto compiler -/// parser. -@property(nonatomic, readwrite) BOOL mapEntry; - -@property(nonatomic, readwrite) BOOL hasMapEntry; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBFieldOptions - -typedef GPB_ENUM(GPBFieldOptions_FieldNumber) { - GPBFieldOptions_FieldNumber_Ctype = 1, - GPBFieldOptions_FieldNumber_Packed = 2, - GPBFieldOptions_FieldNumber_Deprecated = 3, - GPBFieldOptions_FieldNumber_Lazy = 5, - GPBFieldOptions_FieldNumber_Jstype = 6, - GPBFieldOptions_FieldNumber_Weak = 10, - GPBFieldOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBFieldOptions : GPBMessage - -/// The ctype option instructs the C++ code generator to use a different -/// representation of the field than it normally would. See the specific -/// options below. This option is not yet implemented in the open source -/// release -- sorry, we'll try to include it in a future version! -@property(nonatomic, readwrite) GPBFieldOptions_CType ctype; - -@property(nonatomic, readwrite) BOOL hasCtype; -/// The packed option can be enabled for repeated primitive fields to enable -/// a more efficient representation on the wire. Rather than repeatedly -/// writing the tag and type for each element, the entire array is encoded as -/// a single length-delimited blob. In proto3, only explicit setting it to -/// false will avoid using packed encoding. -@property(nonatomic, readwrite) BOOL packed; - -@property(nonatomic, readwrite) BOOL hasPacked; -/// The jstype option determines the JavaScript type used for values of the -/// field. The option is permitted only for 64 bit integral and fixed types -/// (int64, uint64, sint64, fixed64, sfixed64). By default these types are -/// represented as JavaScript strings. This avoids loss of precision that can -/// happen when a large value is converted to a floating point JavaScript -/// numbers. Specifying JS_NUMBER for the jstype causes the generated -/// JavaScript code to use the JavaScript "number" type instead of strings. -/// This option is an enum to permit additional types to be added, -/// e.g. goog.math.Integer. -@property(nonatomic, readwrite) GPBFieldOptions_JSType jstype; - -@property(nonatomic, readwrite) BOOL hasJstype; -/// Should this field be parsed lazily? Lazy applies only to message-type -/// fields. It means that when the outer message is initially parsed, the -/// inner message's contents will not be parsed but instead stored in encoded -/// form. The inner message will actually be parsed when it is first accessed. -/// -/// This is only a hint. Implementations are free to choose whether to use -/// eager or lazy parsing regardless of the value of this option. However, -/// setting this option true suggests that the protocol author believes that -/// using lazy parsing on this field is worth the additional bookkeeping -/// overhead typically needed to implement it. -/// -/// This option does not affect the public interface of any generated code; -/// all method signatures remain the same. Furthermore, thread-safety of the -/// interface is not affected by this option; const methods remain safe to -/// call from multiple threads concurrently, while non-const methods continue -/// to require exclusive access. -/// -/// -/// Note that implementations may choose not to check required fields within -/// a lazy sub-message. That is, calling IsInitialized() on the outher message -/// may return true even if the inner message has missing required fields. -/// This is necessary because otherwise the inner message would have to be -/// parsed in order to perform the check, defeating the purpose of lazy -/// parsing. An implementation which chooses not to check required fields -/// must be consistent about it. That is, for any particular sub-message, the -/// implementation must either *always* check its required fields, or *never* -/// check its required fields, regardless of whether or not the message has -/// been parsed. -@property(nonatomic, readwrite) BOOL lazy; - -@property(nonatomic, readwrite) BOOL hasLazy; -/// Is this field deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for accessors, or it will be completely ignored; in the very least, this -/// is a formalization for deprecating fields. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// For Google-internal migration only. Do not use. -@property(nonatomic, readwrite) BOOL weak; - -@property(nonatomic, readwrite) BOOL hasWeak; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBEnumOptions - -typedef GPB_ENUM(GPBEnumOptions_FieldNumber) { - GPBEnumOptions_FieldNumber_AllowAlias = 2, - GPBEnumOptions_FieldNumber_Deprecated = 3, - GPBEnumOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBEnumOptions : GPBMessage - -/// Set this option to true to allow mapping different tag names to the same -/// value. -@property(nonatomic, readwrite) BOOL allowAlias; - -@property(nonatomic, readwrite) BOOL hasAllowAlias; -/// Is this enum deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for the enum, or it will be completely ignored; in the very least, this -/// is a formalization for deprecating enums. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBEnumValueOptions - -typedef GPB_ENUM(GPBEnumValueOptions_FieldNumber) { - GPBEnumValueOptions_FieldNumber_Deprecated = 1, - GPBEnumValueOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBEnumValueOptions : GPBMessage - -/// Is this enum value deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for the enum value, or it will be completely ignored; in the very least, -/// this is a formalization for deprecating enum values. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBServiceOptions - -typedef GPB_ENUM(GPBServiceOptions_FieldNumber) { - GPBServiceOptions_FieldNumber_Deprecated = 33, - GPBServiceOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBServiceOptions : GPBMessage - -/// Is this service deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for the service, or it will be completely ignored; in the very least, -/// this is a formalization for deprecating services. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBMethodOptions - -typedef GPB_ENUM(GPBMethodOptions_FieldNumber) { - GPBMethodOptions_FieldNumber_Deprecated = 33, - GPBMethodOptions_FieldNumber_UninterpretedOptionArray = 999, -}; - -@interface GPBMethodOptions : GPBMessage - -/// Is this method deprecated? -/// Depending on the target platform, this can emit Deprecated annotations -/// for the method, or it will be completely ignored; in the very least, -/// this is a formalization for deprecating methods. -@property(nonatomic, readwrite) BOOL deprecated; - -@property(nonatomic, readwrite) BOOL hasDeprecated; -/// The parser stores options it doesn't recognize here. See above. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *uninterpretedOptionArray; -/// The number of items in @c uninterpretedOptionArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger uninterpretedOptionArray_Count; - -@end - -#pragma mark - GPBUninterpretedOption - -typedef GPB_ENUM(GPBUninterpretedOption_FieldNumber) { - GPBUninterpretedOption_FieldNumber_NameArray = 2, - GPBUninterpretedOption_FieldNumber_IdentifierValue = 3, - GPBUninterpretedOption_FieldNumber_PositiveIntValue = 4, - GPBUninterpretedOption_FieldNumber_NegativeIntValue = 5, - GPBUninterpretedOption_FieldNumber_DoubleValue = 6, - GPBUninterpretedOption_FieldNumber_StringValue = 7, - GPBUninterpretedOption_FieldNumber_AggregateValue = 8, -}; - -/// A message representing a option the parser does not recognize. This only -/// appears in options protos created by the compiler::Parser class. -/// DescriptorPool resolves these when building Descriptor objects. Therefore, -/// options protos in descriptor objects (e.g. returned by Descriptor::options(), -/// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions -/// in them. -@interface GPBUninterpretedOption : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *nameArray; -/// The number of items in @c nameArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger nameArray_Count; - -/// The value of the uninterpreted option, in whatever type the tokenizer -/// identified it as during parsing. Exactly one of these should be set. -@property(nonatomic, readwrite, copy, null_resettable) NSString *identifierValue; -/// Test to see if @c identifierValue has been set. -@property(nonatomic, readwrite) BOOL hasIdentifierValue; - -@property(nonatomic, readwrite) uint64_t positiveIntValue; - -@property(nonatomic, readwrite) BOOL hasPositiveIntValue; -@property(nonatomic, readwrite) int64_t negativeIntValue; - -@property(nonatomic, readwrite) BOOL hasNegativeIntValue; -@property(nonatomic, readwrite) double doubleValue; - -@property(nonatomic, readwrite) BOOL hasDoubleValue; -@property(nonatomic, readwrite, copy, null_resettable) NSData *stringValue; -/// Test to see if @c stringValue has been set. -@property(nonatomic, readwrite) BOOL hasStringValue; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *aggregateValue; -/// Test to see if @c aggregateValue has been set. -@property(nonatomic, readwrite) BOOL hasAggregateValue; - -@end - -#pragma mark - GPBUninterpretedOption_NamePart - -typedef GPB_ENUM(GPBUninterpretedOption_NamePart_FieldNumber) { - GPBUninterpretedOption_NamePart_FieldNumber_NamePart = 1, - GPBUninterpretedOption_NamePart_FieldNumber_IsExtension = 2, -}; - -/// The name of the uninterpreted option. Each string represents a segment in -/// a dot-separated name. is_extension is true iff a segment represents an -/// extension (denoted with parentheses in options specs in .proto files). -/// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents -/// "foo.(bar.baz).qux". -@interface GPBUninterpretedOption_NamePart : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *namePart; -/// Test to see if @c namePart has been set. -@property(nonatomic, readwrite) BOOL hasNamePart; - -@property(nonatomic, readwrite) BOOL isExtension; - -@property(nonatomic, readwrite) BOOL hasIsExtension; -@end - -#pragma mark - GPBSourceCodeInfo - -typedef GPB_ENUM(GPBSourceCodeInfo_FieldNumber) { - GPBSourceCodeInfo_FieldNumber_LocationArray = 1, -}; - -/// Encapsulates information about the original source file from which a -/// FileDescriptorProto was generated. -@interface GPBSourceCodeInfo : GPBMessage - -/// A Location identifies a piece of source code in a .proto file which -/// corresponds to a particular definition. This information is intended -/// to be useful to IDEs, code indexers, documentation generators, and similar -/// tools. -/// -/// For example, say we have a file like: -/// message Foo { -/// optional string foo = 1; -/// } -/// Let's look at just the field definition: -/// optional string foo = 1; -/// ^ ^^ ^^ ^ ^^^ -/// a bc de f ghi -/// We have the following locations: -/// span path represents -/// [a,i) [ 4, 0, 2, 0 ] The whole field definition. -/// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). -/// [c,d) [ 4, 0, 2, 0, 5 ] The type (string). -/// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). -/// [g,h) [ 4, 0, 2, 0, 3 ] The number (1). -/// -/// Notes: -/// - A location may refer to a repeated field itself (i.e. not to any -/// particular index within it). This is used whenever a set of elements are -/// logically enclosed in a single code segment. For example, an entire -/// extend block (possibly containing multiple extension definitions) will -/// have an outer location whose path refers to the "extensions" repeated -/// field without an index. -/// - Multiple locations may have the same path. This happens when a single -/// logical declaration is spread out across multiple places. The most -/// obvious example is the "extend" block again -- there may be multiple -/// extend blocks in the same scope, each of which will have the same path. -/// - A location's span is not always a subset of its parent's span. For -/// example, the "extendee" of an extension declaration appears at the -/// beginning of the "extend" block and is shared by all extensions within -/// the block. -/// - Just because a location's span is a subset of some other location's span -/// does not mean that it is a descendent. For example, a "group" defines -/// both a type and a field in a single declaration. Thus, the locations -/// corresponding to the type and field and their components will overlap. -/// - Code which tries to interpret locations should probably be designed to -/// ignore those that it doesn't understand, as more types of locations could -/// be recorded in the future. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *locationArray; -/// The number of items in @c locationArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger locationArray_Count; - -@end - -#pragma mark - GPBSourceCodeInfo_Location - -typedef GPB_ENUM(GPBSourceCodeInfo_Location_FieldNumber) { - GPBSourceCodeInfo_Location_FieldNumber_PathArray = 1, - GPBSourceCodeInfo_Location_FieldNumber_SpanArray = 2, - GPBSourceCodeInfo_Location_FieldNumber_LeadingComments = 3, - GPBSourceCodeInfo_Location_FieldNumber_TrailingComments = 4, - GPBSourceCodeInfo_Location_FieldNumber_LeadingDetachedCommentsArray = 6, -}; - -@interface GPBSourceCodeInfo_Location : GPBMessage - -/// Identifies which part of the FileDescriptorProto was defined at this -/// location. -/// -/// Each element is a field number or an index. They form a path from -/// the root FileDescriptorProto to the place where the definition. For -/// example, this path: -/// [ 4, 3, 2, 7, 1 ] -/// refers to: -/// file.message_type(3) // 4, 3 -/// .field(7) // 2, 7 -/// .name() // 1 -/// This is because FileDescriptorProto.message_type has field number 4: -/// repeated DescriptorProto message_type = 4; -/// and DescriptorProto.field has field number 2: -/// repeated FieldDescriptorProto field = 2; -/// and FieldDescriptorProto.name has field number 1: -/// optional string name = 1; -/// -/// Thus, the above path gives the location of a field name. If we removed -/// the last element: -/// [ 4, 3, 2, 7 ] -/// this path refers to the whole field declaration (from the beginning -/// of the label to the terminating semicolon). -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *pathArray; -/// The number of items in @c pathArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger pathArray_Count; - -/// Always has exactly three or four elements: start line, start column, -/// end line (optional, otherwise assumed same as start line), end column. -/// These are packed into a single field for efficiency. Note that line -/// and column numbers are zero-based -- typically you will want to add -/// 1 to each before displaying to a user. -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *spanArray; -/// The number of items in @c spanArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger spanArray_Count; - -/// If this SourceCodeInfo represents a complete declaration, these are any -/// comments appearing before and after the declaration which appear to be -/// attached to the declaration. -/// -/// A series of line comments appearing on consecutive lines, with no other -/// tokens appearing on those lines, will be treated as a single comment. -/// -/// leading_detached_comments will keep paragraphs of comments that appear -/// before (but not connected to) the current element. Each paragraph, -/// separated by empty lines, will be one comment element in the repeated -/// field. -/// -/// Only the comment content is provided; comment markers (e.g. //) are -/// stripped out. For block comments, leading whitespace and an asterisk -/// will be stripped from the beginning of each line other than the first. -/// Newlines are included in the output. -/// -/// Examples: -/// -/// optional int32 foo = 1; // Comment attached to foo. -/// // Comment attached to bar. -/// optional int32 bar = 2; -/// -/// optional string baz = 3; -/// // Comment attached to baz. -/// // Another line attached to baz. -/// -/// // Comment attached to qux. -/// // -/// // Another line attached to qux. -/// optional double qux = 4; -/// -/// // Detached comment for corge. This is not leading or trailing comments -/// // to qux or corge because there are blank lines separating it from -/// // both. -/// -/// // Detached comment for corge paragraph 2. -/// -/// optional string corge = 5; -/// /* Block comment attached -/// * to corge. Leading asterisks -/// * will be removed. */ -/// /* Block comment attached to -/// * grault. */ -/// optional int32 grault = 6; -/// -/// // ignored detached comments. -@property(nonatomic, readwrite, copy, null_resettable) NSString *leadingComments; -/// Test to see if @c leadingComments has been set. -@property(nonatomic, readwrite) BOOL hasLeadingComments; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *trailingComments; -/// Test to see if @c trailingComments has been set. -@property(nonatomic, readwrite) BOOL hasTrailingComments; - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *leadingDetachedCommentsArray; -/// The number of items in @c leadingDetachedCommentsArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger leadingDetachedCommentsArray_Count; - -@end - -#pragma mark - GPBGeneratedCodeInfo - -typedef GPB_ENUM(GPBGeneratedCodeInfo_FieldNumber) { - GPBGeneratedCodeInfo_FieldNumber_AnnotationArray = 1, -}; - -/// Describes the relationship between generated code and its original source -/// file. A GeneratedCodeInfo message is associated with only one generated -/// source file, but may contain references to different source .proto files. -@interface GPBGeneratedCodeInfo : GPBMessage - -/// An Annotation connects some span of text in generated code to an element -/// of its generating .proto file. -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *annotationArray; -/// The number of items in @c annotationArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger annotationArray_Count; - -@end - -#pragma mark - GPBGeneratedCodeInfo_Annotation - -typedef GPB_ENUM(GPBGeneratedCodeInfo_Annotation_FieldNumber) { - GPBGeneratedCodeInfo_Annotation_FieldNumber_PathArray = 1, - GPBGeneratedCodeInfo_Annotation_FieldNumber_SourceFile = 2, - GPBGeneratedCodeInfo_Annotation_FieldNumber_Begin = 3, - GPBGeneratedCodeInfo_Annotation_FieldNumber_End = 4, -}; - -@interface GPBGeneratedCodeInfo_Annotation : GPBMessage - -/// Identifies the element in the original source .proto file. This field -/// is formatted the same as SourceCodeInfo.Location.path. -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *pathArray; -/// The number of items in @c pathArray without causing the array to be created. -@property(nonatomic, readonly) NSUInteger pathArray_Count; - -/// Identifies the filesystem path to the original source .proto. -@property(nonatomic, readwrite, copy, null_resettable) NSString *sourceFile; -/// Test to see if @c sourceFile has been set. -@property(nonatomic, readwrite) BOOL hasSourceFile; - -/// Identifies the starting offset in bytes in the generated code -/// that relates to the identified object. -@property(nonatomic, readwrite) int32_t begin; - -@property(nonatomic, readwrite) BOOL hasBegin; -/// Identifies the ending offset in bytes in the generated code that -/// relates to the identified offset. The end offset should be one past -/// the last relevant byte (so the length of the text = end - begin). -@property(nonatomic, readwrite) int32_t end; - -@property(nonatomic, readwrite) BOOL hasEnd; -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -// @@protoc_insertion_point(global_scope) diff --git a/objectivec/google/protobuf/Descriptor.pbobjc.m b/objectivec/google/protobuf/Descriptor.pbobjc.m deleted file mode 100644 index 40309893..00000000 --- a/objectivec/google/protobuf/Descriptor.pbobjc.m +++ /dev/null @@ -1,2594 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/descriptor.proto - -#import "GPBProtocolBuffers_RuntimeSupport.h" -#import "google/protobuf/Descriptor.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma mark - GPBDescriptorRoot - -@implementation GPBDescriptorRoot - -@end - -#pragma mark - GPBDescriptorRoot_FileDescriptor - -static GPBFileDescriptor *GPBDescriptorRoot_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) { - GPBDebugCheckRuntimeVersion(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" - syntax:GPBFileSyntaxProto2]; - } - return descriptor; -} - -#pragma mark - GPBFileDescriptorSet - -@implementation GPBFileDescriptorSet - -@dynamic fileArray, fileArray_Count; - -typedef struct GPBFileDescriptorSet__storage_ { - uint32_t _has_storage_[1]; - NSMutableArray *fileArray; -} GPBFileDescriptorSet__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 = "fileArray", - .number = GPBFileDescriptorSet_FieldNumber_FileArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorSet__storage_, fileArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBFileDescriptorProto), - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBFileDescriptorSet class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBFileDescriptorSet__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBFileDescriptorProto - -@implementation GPBFileDescriptorProto - -@dynamic hasName, name; -@dynamic hasPackage, package; -@dynamic dependencyArray, dependencyArray_Count; -@dynamic publicDependencyArray, publicDependencyArray_Count; -@dynamic weakDependencyArray, weakDependencyArray_Count; -@dynamic messageTypeArray, messageTypeArray_Count; -@dynamic enumTypeArray, enumTypeArray_Count; -@dynamic serviceArray, serviceArray_Count; -@dynamic extensionArray, extensionArray_Count; -@dynamic hasOptions, options; -@dynamic hasSourceCodeInfo, sourceCodeInfo; -@dynamic hasSyntax, syntax; - -typedef struct GPBFileDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - NSString *name; - NSString *package; - NSMutableArray *dependencyArray; - NSMutableArray *messageTypeArray; - NSMutableArray *enumTypeArray; - NSMutableArray *serviceArray; - NSMutableArray *extensionArray; - GPBFileOptions *options; - GPBSourceCodeInfo *sourceCodeInfo; - GPBInt32Array *publicDependencyArray; - GPBInt32Array *weakDependencyArray; - NSString *syntax; -} GPBFileDescriptorProto__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 = GPBFileDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "package", - .number = GPBFileDescriptorProto_FieldNumber_Package, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileDescriptorProto__storage_, package), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "dependencyArray", - .number = GPBFileDescriptorProto_FieldNumber_DependencyArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileDescriptorProto__storage_, dependencyArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "messageTypeArray", - .number = GPBFileDescriptorProto_FieldNumber_MessageTypeArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorProto__storage_, messageTypeArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "enumTypeArray", - .number = GPBFileDescriptorProto_FieldNumber_EnumTypeArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorProto__storage_, enumTypeArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "serviceArray", - .number = GPBFileDescriptorProto_FieldNumber_ServiceArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorProto__storage_, serviceArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBServiceDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "extensionArray", - .number = GPBFileDescriptorProto_FieldNumber_ExtensionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorProto__storage_, extensionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBFileDescriptorProto_FieldNumber_Options, - .hasIndex = 9, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBFileOptions), - .fieldOptions = NULL, - }, - { - .name = "sourceCodeInfo", - .number = GPBFileDescriptorProto_FieldNumber_SourceCodeInfo, - .hasIndex = 10, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileDescriptorProto__storage_, sourceCodeInfo), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceCodeInfo), - .fieldOptions = NULL, - }, - { - .name = "publicDependencyArray", - .number = GPBFileDescriptorProto_FieldNumber_PublicDependencyArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBFileDescriptorProto__storage_, publicDependencyArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "weakDependencyArray", - .number = GPBFileDescriptorProto_FieldNumber_WeakDependencyArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBFileDescriptorProto__storage_, weakDependencyArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "syntax", - .number = GPBFileDescriptorProto_FieldNumber_Syntax, - .hasIndex = 11, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileDescriptorProto__storage_, syntax), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBFileDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBFileDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBDescriptorProto - -@implementation GPBDescriptorProto - -@dynamic hasName, name; -@dynamic fieldArray, fieldArray_Count; -@dynamic extensionArray, extensionArray_Count; -@dynamic nestedTypeArray, nestedTypeArray_Count; -@dynamic enumTypeArray, enumTypeArray_Count; -@dynamic extensionRangeArray, extensionRangeArray_Count; -@dynamic oneofDeclArray, oneofDeclArray_Count; -@dynamic hasOptions, options; -@dynamic reservedRangeArray, reservedRangeArray_Count; -@dynamic reservedNameArray, reservedNameArray_Count; - -typedef struct GPBDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - NSString *name; - NSMutableArray *fieldArray; - NSMutableArray *nestedTypeArray; - NSMutableArray *enumTypeArray; - NSMutableArray *extensionRangeArray; - NSMutableArray *extensionArray; - GPBMessageOptions *options; - NSMutableArray *oneofDeclArray; - NSMutableArray *reservedRangeArray; - NSMutableArray *reservedNameArray; -} GPBDescriptorProto__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 = GPBDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "fieldArray", - .number = GPBDescriptorProto_FieldNumber_FieldArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, fieldArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "nestedTypeArray", - .number = GPBDescriptorProto_FieldNumber_NestedTypeArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, nestedTypeArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "enumTypeArray", - .number = GPBDescriptorProto_FieldNumber_EnumTypeArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, enumTypeArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "extensionRangeArray", - .number = GPBDescriptorProto_FieldNumber_ExtensionRangeArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, extensionRangeArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto_ExtensionRange), - .fieldOptions = NULL, - }, - { - .name = "extensionArray", - .number = GPBDescriptorProto_FieldNumber_ExtensionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, extensionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBDescriptorProto_FieldNumber_Options, - .hasIndex = 7, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBMessageOptions), - .fieldOptions = NULL, - }, - { - .name = "oneofDeclArray", - .number = GPBDescriptorProto_FieldNumber_OneofDeclArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, oneofDeclArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOneofDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "reservedRangeArray", - .number = GPBDescriptorProto_FieldNumber_ReservedRangeArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBDescriptorProto__storage_, reservedRangeArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBDescriptorProto_ReservedRange), - .fieldOptions = NULL, - }, - { - .name = "reservedNameArray", - .number = GPBDescriptorProto_FieldNumber_ReservedNameArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBDescriptorProto__storage_, reservedNameArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBDescriptorProto_ExtensionRange - -@implementation GPBDescriptorProto_ExtensionRange - -@dynamic hasStart, start; -@dynamic hasEnd, end; - -typedef struct GPBDescriptorProto_ExtensionRange__storage_ { - uint32_t _has_storage_[1]; - int32_t start; - int32_t end; -} GPBDescriptorProto_ExtensionRange__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 = "start", - .number = GPBDescriptorProto_ExtensionRange_FieldNumber_Start, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBDescriptorProto_ExtensionRange__storage_, start), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "end", - .number = GPBDescriptorProto_ExtensionRange_FieldNumber_End, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBDescriptorProto_ExtensionRange__storage_, end), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBDescriptorProto_ExtensionRange class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBDescriptorProto_ExtensionRange__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBDescriptorProto_ReservedRange - -@implementation GPBDescriptorProto_ReservedRange - -@dynamic hasStart, start; -@dynamic hasEnd, end; - -typedef struct GPBDescriptorProto_ReservedRange__storage_ { - uint32_t _has_storage_[1]; - int32_t start; - int32_t end; -} GPBDescriptorProto_ReservedRange__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 = "start", - .number = GPBDescriptorProto_ReservedRange_FieldNumber_Start, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBDescriptorProto_ReservedRange__storage_, start), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "end", - .number = GPBDescriptorProto_ReservedRange_FieldNumber_End, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBDescriptorProto_ReservedRange__storage_, end), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBDescriptorProto_ReservedRange class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBDescriptorProto_ReservedRange__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBFieldDescriptorProto - -@implementation GPBFieldDescriptorProto - -@dynamic hasName, name; -@dynamic hasNumber, number; -@dynamic hasLabel, label; -@dynamic hasType, type; -@dynamic hasTypeName, typeName; -@dynamic hasExtendee, extendee; -@dynamic hasDefaultValue, defaultValue; -@dynamic hasOneofIndex, oneofIndex; -@dynamic hasJsonName, jsonName; -@dynamic hasOptions, options; - -typedef struct GPBFieldDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - int32_t number; - GPBFieldDescriptorProto_Label label; - GPBFieldDescriptorProto_Type type; - int32_t oneofIndex; - NSString *name; - NSString *extendee; - NSString *typeName; - NSString *defaultValue; - GPBFieldOptions *options; - NSString *jsonName; -} GPBFieldDescriptorProto__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 = GPBFieldDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFieldDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "extendee", - .number = GPBFieldDescriptorProto_FieldNumber_Extendee, - .hasIndex = 5, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFieldDescriptorProto__storage_, extendee), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "number", - .number = GPBFieldDescriptorProto_FieldNumber_Number, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBFieldDescriptorProto__storage_, number), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "label", - .number = GPBFieldDescriptorProto_FieldNumber_Label, - .hasIndex = 2, - .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, - .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBFieldDescriptorProto__storage_, label), - .defaultValue.valueEnum = GPBFieldDescriptorProto_Label_LabelOptional, - .dataTypeSpecific.enumDescFunc = GPBFieldDescriptorProto_Label_EnumDescriptor, - .fieldOptions = NULL, - }, - { - .name = "type", - .number = GPBFieldDescriptorProto_FieldNumber_Type, - .hasIndex = 3, - .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, - .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBFieldDescriptorProto__storage_, type), - .defaultValue.valueEnum = GPBFieldDescriptorProto_Type_TypeDouble, - .dataTypeSpecific.enumDescFunc = GPBFieldDescriptorProto_Type_EnumDescriptor, - .fieldOptions = NULL, - }, - { - .name = "typeName", - .number = GPBFieldDescriptorProto_FieldNumber_TypeName, - .hasIndex = 4, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFieldDescriptorProto__storage_, typeName), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "defaultValue", - .number = GPBFieldDescriptorProto_FieldNumber_DefaultValue, - .hasIndex = 6, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFieldDescriptorProto__storage_, defaultValue), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBFieldDescriptorProto_FieldNumber_Options, - .hasIndex = 9, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFieldDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBFieldOptions), - .fieldOptions = NULL, - }, - { - .name = "oneofIndex", - .number = GPBFieldDescriptorProto_FieldNumber_OneofIndex, - .hasIndex = 7, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBFieldDescriptorProto__storage_, oneofIndex), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "jsonName", - .number = GPBFieldDescriptorProto_FieldNumber_JsonName, - .hasIndex = 8, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFieldDescriptorProto__storage_, jsonName), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - static GPBMessageEnumDescription enums[] = { - { .enumDescriptorFunc = GPBFieldDescriptorProto_Type_EnumDescriptor }, - { .enumDescriptorFunc = GPBFieldDescriptorProto_Label_EnumDescriptor }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBFieldDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:enums - enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription) - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBFieldDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Enum GPBFieldDescriptorProto_Type - -GPBEnumDescriptor *GPBFieldDescriptorProto_Type_EnumDescriptor(void) { - static GPBEnumDescriptor *descriptor = NULL; - if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "TypeDouble", .number = GPBFieldDescriptorProto_Type_TypeDouble }, - { .name = "TypeFloat", .number = GPBFieldDescriptorProto_Type_TypeFloat }, - { .name = "TypeInt64", .number = GPBFieldDescriptorProto_Type_TypeInt64 }, - { .name = "TypeUint64", .number = GPBFieldDescriptorProto_Type_TypeUint64 }, - { .name = "TypeInt32", .number = GPBFieldDescriptorProto_Type_TypeInt32 }, - { .name = "TypeFixed64", .number = GPBFieldDescriptorProto_Type_TypeFixed64 }, - { .name = "TypeFixed32", .number = GPBFieldDescriptorProto_Type_TypeFixed32 }, - { .name = "TypeBool", .number = GPBFieldDescriptorProto_Type_TypeBool }, - { .name = "TypeString", .number = GPBFieldDescriptorProto_Type_TypeString }, - { .name = "TypeGroup", .number = GPBFieldDescriptorProto_Type_TypeGroup }, - { .name = "TypeMessage", .number = GPBFieldDescriptorProto_Type_TypeMessage }, - { .name = "TypeBytes", .number = GPBFieldDescriptorProto_Type_TypeBytes }, - { .name = "TypeUint32", .number = GPBFieldDescriptorProto_Type_TypeUint32 }, - { .name = "TypeEnum", .number = GPBFieldDescriptorProto_Type_TypeEnum }, - { .name = "TypeSfixed32", .number = GPBFieldDescriptorProto_Type_TypeSfixed32 }, - { .name = "TypeSfixed64", .number = GPBFieldDescriptorProto_Type_TypeSfixed64 }, - { .name = "TypeSint32", .number = GPBFieldDescriptorProto_Type_TypeSint32 }, - { .name = "TypeSint64", .number = GPBFieldDescriptorProto_Type_TypeSint64 }, - }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldDescriptorProto_Type) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBFieldDescriptorProto_Type_IsValidValue]; - } - return descriptor; -} - -BOOL GPBFieldDescriptorProto_Type_IsValidValue(int32_t value__) { - switch (value__) { - case GPBFieldDescriptorProto_Type_TypeDouble: - case GPBFieldDescriptorProto_Type_TypeFloat: - case GPBFieldDescriptorProto_Type_TypeInt64: - case GPBFieldDescriptorProto_Type_TypeUint64: - case GPBFieldDescriptorProto_Type_TypeInt32: - case GPBFieldDescriptorProto_Type_TypeFixed64: - case GPBFieldDescriptorProto_Type_TypeFixed32: - case GPBFieldDescriptorProto_Type_TypeBool: - case GPBFieldDescriptorProto_Type_TypeString: - case GPBFieldDescriptorProto_Type_TypeGroup: - case GPBFieldDescriptorProto_Type_TypeMessage: - case GPBFieldDescriptorProto_Type_TypeBytes: - case GPBFieldDescriptorProto_Type_TypeUint32: - case GPBFieldDescriptorProto_Type_TypeEnum: - case GPBFieldDescriptorProto_Type_TypeSfixed32: - case GPBFieldDescriptorProto_Type_TypeSfixed64: - case GPBFieldDescriptorProto_Type_TypeSint32: - case GPBFieldDescriptorProto_Type_TypeSint64: - return YES; - default: - return NO; - } -} - -#pragma mark - Enum GPBFieldDescriptorProto_Label - -GPBEnumDescriptor *GPBFieldDescriptorProto_Label_EnumDescriptor(void) { - static GPBEnumDescriptor *descriptor = NULL; - if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "LabelOptional", .number = GPBFieldDescriptorProto_Label_LabelOptional }, - { .name = "LabelRequired", .number = GPBFieldDescriptorProto_Label_LabelRequired }, - { .name = "LabelRepeated", .number = GPBFieldDescriptorProto_Label_LabelRepeated }, - }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldDescriptorProto_Label) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBFieldDescriptorProto_Label_IsValidValue]; - } - return descriptor; -} - -BOOL GPBFieldDescriptorProto_Label_IsValidValue(int32_t value__) { - switch (value__) { - case GPBFieldDescriptorProto_Label_LabelOptional: - case GPBFieldDescriptorProto_Label_LabelRequired: - case GPBFieldDescriptorProto_Label_LabelRepeated: - return YES; - default: - return NO; - } -} - -#pragma mark - GPBOneofDescriptorProto - -@implementation GPBOneofDescriptorProto - -@dynamic hasName, name; - -typedef struct GPBOneofDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - NSString *name; -} GPBOneofDescriptorProto__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 = GPBOneofDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBOneofDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBOneofDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBOneofDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBEnumDescriptorProto - -@implementation GPBEnumDescriptorProto - -@dynamic hasName, name; -@dynamic valueArray, valueArray_Count; -@dynamic hasOptions, options; - -typedef struct GPBEnumDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - NSString *name; - NSMutableArray *valueArray; - GPBEnumOptions *options; -} GPBEnumDescriptorProto__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 = GPBEnumDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBEnumDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "valueArray", - .number = GPBEnumDescriptorProto_FieldNumber_ValueArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnumDescriptorProto__storage_, valueArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValueDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBEnumDescriptorProto_FieldNumber_Options, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnumDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumOptions), - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBEnumDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBEnumDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBEnumValueDescriptorProto - -@implementation GPBEnumValueDescriptorProto - -@dynamic hasName, name; -@dynamic hasNumber, number; -@dynamic hasOptions, options; - -typedef struct GPBEnumValueDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - int32_t number; - NSString *name; - GPBEnumValueOptions *options; -} GPBEnumValueDescriptorProto__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 = GPBEnumValueDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBEnumValueDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "number", - .number = GPBEnumValueDescriptorProto_FieldNumber_Number, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBEnumValueDescriptorProto__storage_, number), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBEnumValueDescriptorProto_FieldNumber_Options, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnumValueDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValueOptions), - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBEnumValueDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBEnumValueDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBServiceDescriptorProto - -@implementation GPBServiceDescriptorProto - -@dynamic hasName, name; -@dynamic methodArray, methodArray_Count; -@dynamic hasOptions, options; - -typedef struct GPBServiceDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - NSString *name; - NSMutableArray *methodArray; - GPBServiceOptions *options; -} GPBServiceDescriptorProto__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 = GPBServiceDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBServiceDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "methodArray", - .number = GPBServiceDescriptorProto_FieldNumber_MethodArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBServiceDescriptorProto__storage_, methodArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBMethodDescriptorProto), - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBServiceDescriptorProto_FieldNumber_Options, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBServiceDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBServiceOptions), - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBServiceDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBServiceDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBMethodDescriptorProto - -@implementation GPBMethodDescriptorProto - -@dynamic hasName, name; -@dynamic hasInputType, inputType; -@dynamic hasOutputType, outputType; -@dynamic hasOptions, options; -@dynamic hasClientStreaming, clientStreaming; -@dynamic hasServerStreaming, serverStreaming; - -typedef struct GPBMethodDescriptorProto__storage_ { - uint32_t _has_storage_[1]; - BOOL clientStreaming; - BOOL serverStreaming; - NSString *name; - NSString *inputType; - NSString *outputType; - GPBMethodOptions *options; -} GPBMethodDescriptorProto__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 = GPBMethodDescriptorProto_FieldNumber_Name, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBMethodDescriptorProto__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "inputType", - .number = GPBMethodDescriptorProto_FieldNumber_InputType, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBMethodDescriptorProto__storage_, inputType), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "outputType", - .number = GPBMethodDescriptorProto_FieldNumber_OutputType, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBMethodDescriptorProto__storage_, outputType), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "options", - .number = GPBMethodDescriptorProto_FieldNumber_Options, - .hasIndex = 3, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBMethodDescriptorProto__storage_, options), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBMethodOptions), - .fieldOptions = NULL, - }, - { - .name = "clientStreaming", - .number = GPBMethodDescriptorProto_FieldNumber_ClientStreaming, - .hasIndex = 4, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMethodDescriptorProto__storage_, clientStreaming), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "serverStreaming", - .number = GPBMethodDescriptorProto_FieldNumber_ServerStreaming, - .hasIndex = 5, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMethodDescriptorProto__storage_, serverStreaming), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBMethodDescriptorProto class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBMethodDescriptorProto__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBFileOptions - -@implementation GPBFileOptions - -@dynamic hasJavaPackage, javaPackage; -@dynamic hasJavaOuterClassname, javaOuterClassname; -@dynamic hasJavaMultipleFiles, javaMultipleFiles; -@dynamic hasJavaGenerateEqualsAndHash, javaGenerateEqualsAndHash; -@dynamic hasJavaStringCheckUtf8, javaStringCheckUtf8; -@dynamic hasOptimizeFor, optimizeFor; -@dynamic hasGoPackage, goPackage; -@dynamic hasCcGenericServices, ccGenericServices; -@dynamic hasJavaGenericServices, javaGenericServices; -@dynamic hasPyGenericServices, pyGenericServices; -@dynamic hasDeprecated, deprecated; -@dynamic hasCcEnableArenas, ccEnableArenas; -@dynamic hasObjcClassPrefix, objcClassPrefix; -@dynamic hasCsharpNamespace, csharpNamespace; -@dynamic hasJavananoUseDeprecatedPackage, javananoUseDeprecatedPackage; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBFileOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL javaMultipleFiles; - BOOL ccGenericServices; - BOOL javaGenericServices; - BOOL pyGenericServices; - BOOL javaGenerateEqualsAndHash; - BOOL deprecated; - BOOL javaStringCheckUtf8; - BOOL ccEnableArenas; - BOOL javananoUseDeprecatedPackage; - GPBFileOptions_OptimizeMode optimizeFor; - NSString *javaPackage; - NSString *javaOuterClassname; - NSString *goPackage; - NSString *objcClassPrefix; - NSString *csharpNamespace; - NSMutableArray *uninterpretedOptionArray; -} GPBFileOptions__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 = "javaPackage", - .number = GPBFileOptions_FieldNumber_JavaPackage, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileOptions__storage_, javaPackage), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "javaOuterClassname", - .number = GPBFileOptions_FieldNumber_JavaOuterClassname, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileOptions__storage_, javaOuterClassname), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "optimizeFor", - .number = GPBFileOptions_FieldNumber_OptimizeFor, - .hasIndex = 5, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue | GPBFieldHasEnumDescriptor, - .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBFileOptions__storage_, optimizeFor), - .defaultValue.valueEnum = GPBFileOptions_OptimizeMode_Speed, - .dataTypeSpecific.enumDescFunc = GPBFileOptions_OptimizeMode_EnumDescriptor, - .fieldOptions = NULL, - }, - { - .name = "javaMultipleFiles", - .number = GPBFileOptions_FieldNumber_JavaMultipleFiles, - .hasIndex = 2, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, javaMultipleFiles), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "goPackage", - .number = GPBFileOptions_FieldNumber_GoPackage, - .hasIndex = 6, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileOptions__storage_, goPackage), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "ccGenericServices", - .number = GPBFileOptions_FieldNumber_CcGenericServices, - .hasIndex = 7, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, ccGenericServices), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "javaGenericServices", - .number = GPBFileOptions_FieldNumber_JavaGenericServices, - .hasIndex = 8, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, javaGenericServices), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "pyGenericServices", - .number = GPBFileOptions_FieldNumber_PyGenericServices, - .hasIndex = 9, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, pyGenericServices), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "javaGenerateEqualsAndHash", - .number = GPBFileOptions_FieldNumber_JavaGenerateEqualsAndHash, - .hasIndex = 3, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, javaGenerateEqualsAndHash), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "deprecated", - .number = GPBFileOptions_FieldNumber_Deprecated, - .hasIndex = 10, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "javaStringCheckUtf8", - .number = GPBFileOptions_FieldNumber_JavaStringCheckUtf8, - .hasIndex = 4, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, javaStringCheckUtf8), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "ccEnableArenas", - .number = GPBFileOptions_FieldNumber_CcEnableArenas, - .hasIndex = 11, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFileOptions__storage_, ccEnableArenas), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "objcClassPrefix", - .number = GPBFileOptions_FieldNumber_ObjcClassPrefix, - .hasIndex = 12, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileOptions__storage_, objcClassPrefix), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "csharpNamespace", - .number = GPBFileOptions_FieldNumber_CsharpNamespace, - .hasIndex = 13, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBFileOptions__storage_, csharpNamespace), - .defaultValue.valueString = nil, - .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, - #if GPBOBJC_INCLUDE_FIELD_OPTIONS - .fieldOptions = "\000\000\000\002\030\001", - #else - .fieldOptions = NULL, - #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS - }, - { - .name = "uninterpretedOptionArray", - .number = GPBFileOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFileOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBMessageEnumDescription enums[] = { - { .enumDescriptorFunc = GPBFileOptions_OptimizeMode_EnumDescriptor }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBFileOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:enums - enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription) - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBFileOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Enum GPBFileOptions_OptimizeMode - -GPBEnumDescriptor *GPBFileOptions_OptimizeMode_EnumDescriptor(void) { - static GPBEnumDescriptor *descriptor = NULL; - if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "Speed", .number = GPBFileOptions_OptimizeMode_Speed }, - { .name = "CodeSize", .number = GPBFileOptions_OptimizeMode_CodeSize }, - { .name = "LiteRuntime", .number = GPBFileOptions_OptimizeMode_LiteRuntime }, - }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFileOptions_OptimizeMode) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBFileOptions_OptimizeMode_IsValidValue]; - } - return descriptor; -} - -BOOL GPBFileOptions_OptimizeMode_IsValidValue(int32_t value__) { - switch (value__) { - case GPBFileOptions_OptimizeMode_Speed: - case GPBFileOptions_OptimizeMode_CodeSize: - case GPBFileOptions_OptimizeMode_LiteRuntime: - return YES; - default: - return NO; - } -} - -#pragma mark - GPBMessageOptions - -@implementation GPBMessageOptions - -@dynamic hasMessageSetWireFormat, messageSetWireFormat; -@dynamic hasNoStandardDescriptorAccessor, noStandardDescriptorAccessor; -@dynamic hasDeprecated, deprecated; -@dynamic hasMapEntry, mapEntry; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBMessageOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL messageSetWireFormat; - BOOL noStandardDescriptorAccessor; - BOOL deprecated; - BOOL mapEntry; - NSMutableArray *uninterpretedOptionArray; -} GPBMessageOptions__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 = "messageSetWireFormat", - .number = GPBMessageOptions_FieldNumber_MessageSetWireFormat, - .hasIndex = 0, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMessageOptions__storage_, messageSetWireFormat), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "noStandardDescriptorAccessor", - .number = GPBMessageOptions_FieldNumber_NoStandardDescriptorAccessor, - .hasIndex = 1, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMessageOptions__storage_, noStandardDescriptorAccessor), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "deprecated", - .number = GPBMessageOptions_FieldNumber_Deprecated, - .hasIndex = 2, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMessageOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "mapEntry", - .number = GPBMessageOptions_FieldNumber_MapEntry, - .hasIndex = 3, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMessageOptions__storage_, mapEntry), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "uninterpretedOptionArray", - .number = GPBMessageOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBMessageOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBMessageOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBMessageOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBFieldOptions - -@implementation GPBFieldOptions - -@dynamic hasCtype, ctype; -@dynamic hasPacked, packed; -@dynamic hasJstype, jstype; -@dynamic hasLazy, lazy; -@dynamic hasDeprecated, deprecated; -@dynamic hasWeak, weak; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBFieldOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL packed; - BOOL deprecated; - BOOL lazy; - BOOL weak; - GPBFieldOptions_CType ctype; - GPBFieldOptions_JSType jstype; - NSMutableArray *uninterpretedOptionArray; -} GPBFieldOptions__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 = "ctype", - .number = GPBFieldOptions_FieldNumber_Ctype, - .hasIndex = 0, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue | GPBFieldHasEnumDescriptor, - .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBFieldOptions__storage_, ctype), - .defaultValue.valueEnum = GPBFieldOptions_CType_String, - .dataTypeSpecific.enumDescFunc = GPBFieldOptions_CType_EnumDescriptor, - .fieldOptions = NULL, - }, - { - .name = "packed", - .number = GPBFieldOptions_FieldNumber_Packed, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFieldOptions__storage_, packed), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "deprecated", - .number = GPBFieldOptions_FieldNumber_Deprecated, - .hasIndex = 4, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFieldOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "lazy", - .number = GPBFieldOptions_FieldNumber_Lazy, - .hasIndex = 3, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFieldOptions__storage_, lazy), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "jstype", - .number = GPBFieldOptions_FieldNumber_Jstype, - .hasIndex = 2, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue | GPBFieldHasEnumDescriptor, - .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBFieldOptions__storage_, jstype), - .defaultValue.valueEnum = GPBFieldOptions_JSType_JsNormal, - .dataTypeSpecific.enumDescFunc = GPBFieldOptions_JSType_EnumDescriptor, - .fieldOptions = NULL, - }, - { - .name = "weak", - .number = GPBFieldOptions_FieldNumber_Weak, - .hasIndex = 5, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBFieldOptions__storage_, weak), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "uninterpretedOptionArray", - .number = GPBFieldOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBFieldOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBMessageEnumDescription enums[] = { - { .enumDescriptorFunc = GPBFieldOptions_CType_EnumDescriptor }, - { .enumDescriptorFunc = GPBFieldOptions_JSType_EnumDescriptor }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBFieldOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:enums - enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription) - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBFieldOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Enum GPBFieldOptions_CType - -GPBEnumDescriptor *GPBFieldOptions_CType_EnumDescriptor(void) { - static GPBEnumDescriptor *descriptor = NULL; - if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "String", .number = GPBFieldOptions_CType_String }, - { .name = "Cord", .number = GPBFieldOptions_CType_Cord }, - { .name = "StringPiece", .number = GPBFieldOptions_CType_StringPiece }, - }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldOptions_CType) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBFieldOptions_CType_IsValidValue]; - } - return descriptor; -} - -BOOL GPBFieldOptions_CType_IsValidValue(int32_t value__) { - switch (value__) { - case GPBFieldOptions_CType_String: - case GPBFieldOptions_CType_Cord: - case GPBFieldOptions_CType_StringPiece: - return YES; - default: - return NO; - } -} - -#pragma mark - Enum GPBFieldOptions_JSType - -GPBEnumDescriptor *GPBFieldOptions_JSType_EnumDescriptor(void) { - static GPBEnumDescriptor *descriptor = NULL; - if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "JsNormal", .number = GPBFieldOptions_JSType_JsNormal }, - { .name = "JsString", .number = GPBFieldOptions_JSType_JsString }, - { .name = "JsNumber", .number = GPBFieldOptions_JSType_JsNumber }, - }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBFieldOptions_JSType) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBFieldOptions_JSType_IsValidValue]; - } - return descriptor; -} - -BOOL GPBFieldOptions_JSType_IsValidValue(int32_t value__) { - switch (value__) { - case GPBFieldOptions_JSType_JsNormal: - case GPBFieldOptions_JSType_JsString: - case GPBFieldOptions_JSType_JsNumber: - return YES; - default: - return NO; - } -} - -#pragma mark - GPBEnumOptions - -@implementation GPBEnumOptions - -@dynamic hasAllowAlias, allowAlias; -@dynamic hasDeprecated, deprecated; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBEnumOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL allowAlias; - BOOL deprecated; - NSMutableArray *uninterpretedOptionArray; -} GPBEnumOptions__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 = "allowAlias", - .number = GPBEnumOptions_FieldNumber_AllowAlias, - .hasIndex = 0, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBEnumOptions__storage_, allowAlias), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "deprecated", - .number = GPBEnumOptions_FieldNumber_Deprecated, - .hasIndex = 1, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBEnumOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "uninterpretedOptionArray", - .number = GPBEnumOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnumOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBEnumOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBEnumOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBEnumValueOptions - -@implementation GPBEnumValueOptions - -@dynamic hasDeprecated, deprecated; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBEnumValueOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL deprecated; - NSMutableArray *uninterpretedOptionArray; -} GPBEnumValueOptions__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 = "deprecated", - .number = GPBEnumValueOptions_FieldNumber_Deprecated, - .hasIndex = 0, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBEnumValueOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "uninterpretedOptionArray", - .number = GPBEnumValueOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnumValueOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBEnumValueOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBEnumValueOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBServiceOptions - -@implementation GPBServiceOptions - -@dynamic hasDeprecated, deprecated; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBServiceOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL deprecated; - NSMutableArray *uninterpretedOptionArray; -} GPBServiceOptions__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 = "deprecated", - .number = GPBServiceOptions_FieldNumber_Deprecated, - .hasIndex = 0, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBServiceOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "uninterpretedOptionArray", - .number = GPBServiceOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBServiceOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBServiceOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBServiceOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBMethodOptions - -@implementation GPBMethodOptions - -@dynamic hasDeprecated, deprecated; -@dynamic uninterpretedOptionArray, uninterpretedOptionArray_Count; - -typedef struct GPBMethodOptions__storage_ { - uint32_t _has_storage_[1]; - BOOL deprecated; - NSMutableArray *uninterpretedOptionArray; -} GPBMethodOptions__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 = "deprecated", - .number = GPBMethodOptions_FieldNumber_Deprecated, - .hasIndex = 0, - .flags = GPBFieldOptional | GPBFieldHasDefaultValue, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBMethodOptions__storage_, deprecated), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "uninterpretedOptionArray", - .number = GPBMethodOptions_FieldNumber_UninterpretedOptionArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBMethodOptions__storage_, uninterpretedOptionArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption), - .fieldOptions = NULL, - }, - }; - static GPBExtensionRange ranges[] = { - { .start = 1000, .end = 536870912 }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBMethodOptions class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:ranges - rangeCount:sizeof(ranges) / sizeof(GPBExtensionRange) - storageSize:sizeof(GPBMethodOptions__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBUninterpretedOption - -@implementation GPBUninterpretedOption - -@dynamic nameArray, nameArray_Count; -@dynamic hasIdentifierValue, identifierValue; -@dynamic hasPositiveIntValue, positiveIntValue; -@dynamic hasNegativeIntValue, negativeIntValue; -@dynamic hasDoubleValue, doubleValue; -@dynamic hasStringValue, stringValue; -@dynamic hasAggregateValue, aggregateValue; - -typedef struct GPBUninterpretedOption__storage_ { - uint32_t _has_storage_[1]; - NSMutableArray *nameArray; - NSString *identifierValue; - NSData *stringValue; - NSString *aggregateValue; - uint64_t positiveIntValue; - int64_t negativeIntValue; - double doubleValue; -} GPBUninterpretedOption__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 = "nameArray", - .number = GPBUninterpretedOption_FieldNumber_NameArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBUninterpretedOption__storage_, nameArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBUninterpretedOption_NamePart), - .fieldOptions = NULL, - }, - { - .name = "identifierValue", - .number = GPBUninterpretedOption_FieldNumber_IdentifierValue, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBUninterpretedOption__storage_, identifierValue), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "positiveIntValue", - .number = GPBUninterpretedOption_FieldNumber_PositiveIntValue, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeUInt64, - .offset = offsetof(GPBUninterpretedOption__storage_, positiveIntValue), - .defaultValue.valueUInt64 = 0ULL, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "negativeIntValue", - .number = GPBUninterpretedOption_FieldNumber_NegativeIntValue, - .hasIndex = 3, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt64, - .offset = offsetof(GPBUninterpretedOption__storage_, negativeIntValue), - .defaultValue.valueInt64 = 0LL, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "doubleValue", - .number = GPBUninterpretedOption_FieldNumber_DoubleValue, - .hasIndex = 4, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeDouble, - .offset = offsetof(GPBUninterpretedOption__storage_, doubleValue), - .defaultValue.valueDouble = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "stringValue", - .number = GPBUninterpretedOption_FieldNumber_StringValue, - .hasIndex = 5, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeBytes, - .offset = offsetof(GPBUninterpretedOption__storage_, stringValue), - .defaultValue.valueData = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "aggregateValue", - .number = GPBUninterpretedOption_FieldNumber_AggregateValue, - .hasIndex = 6, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBUninterpretedOption__storage_, aggregateValue), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBUninterpretedOption class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBUninterpretedOption__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBUninterpretedOption_NamePart - -@implementation GPBUninterpretedOption_NamePart - -@dynamic hasNamePart, namePart; -@dynamic hasIsExtension, isExtension; - -typedef struct GPBUninterpretedOption_NamePart__storage_ { - uint32_t _has_storage_[1]; - BOOL isExtension; - NSString *namePart; -} GPBUninterpretedOption_NamePart__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 = "namePart", - .number = GPBUninterpretedOption_NamePart_FieldNumber_NamePart, - .hasIndex = 0, - .flags = GPBFieldRequired, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBUninterpretedOption_NamePart__storage_, namePart), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "isExtension", - .number = GPBUninterpretedOption_NamePart_FieldNumber_IsExtension, - .hasIndex = 1, - .flags = GPBFieldRequired, - .dataType = GPBDataTypeBool, - .offset = offsetof(GPBUninterpretedOption_NamePart__storage_, isExtension), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBUninterpretedOption_NamePart class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBUninterpretedOption_NamePart__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBSourceCodeInfo - -@implementation GPBSourceCodeInfo - -@dynamic locationArray, locationArray_Count; - -typedef struct GPBSourceCodeInfo__storage_ { - uint32_t _has_storage_[1]; - NSMutableArray *locationArray; -} GPBSourceCodeInfo__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 = "locationArray", - .number = GPBSourceCodeInfo_FieldNumber_LocationArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBSourceCodeInfo__storage_, locationArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceCodeInfo_Location), - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBSourceCodeInfo class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBSourceCodeInfo__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBSourceCodeInfo_Location - -@implementation GPBSourceCodeInfo_Location - -@dynamic pathArray, pathArray_Count; -@dynamic spanArray, spanArray_Count; -@dynamic hasLeadingComments, leadingComments; -@dynamic hasTrailingComments, trailingComments; -@dynamic leadingDetachedCommentsArray, leadingDetachedCommentsArray_Count; - -typedef struct GPBSourceCodeInfo_Location__storage_ { - uint32_t _has_storage_[1]; - GPBInt32Array *pathArray; - GPBInt32Array *spanArray; - NSString *leadingComments; - NSString *trailingComments; - NSMutableArray *leadingDetachedCommentsArray; -} GPBSourceCodeInfo_Location__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 = "pathArray", - .number = GPBSourceCodeInfo_Location_FieldNumber_PathArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated | GPBFieldPacked, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBSourceCodeInfo_Location__storage_, pathArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - #if GPBOBJC_INCLUDE_FIELD_OPTIONS - .fieldOptions = "\000\000\000\002\020\001", - #else - .fieldOptions = NULL, - #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS - }, - { - .name = "spanArray", - .number = GPBSourceCodeInfo_Location_FieldNumber_SpanArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated | GPBFieldPacked, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBSourceCodeInfo_Location__storage_, spanArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - #if GPBOBJC_INCLUDE_FIELD_OPTIONS - .fieldOptions = "\000\000\000\002\020\001", - #else - .fieldOptions = NULL, - #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS - }, - { - .name = "leadingComments", - .number = GPBSourceCodeInfo_Location_FieldNumber_LeadingComments, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBSourceCodeInfo_Location__storage_, leadingComments), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "trailingComments", - .number = GPBSourceCodeInfo_Location_FieldNumber_TrailingComments, - .hasIndex = 3, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBSourceCodeInfo_Location__storage_, trailingComments), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "leadingDetachedCommentsArray", - .number = GPBSourceCodeInfo_Location_FieldNumber_LeadingDetachedCommentsArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBSourceCodeInfo_Location__storage_, leadingDetachedCommentsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBSourceCodeInfo_Location class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBSourceCodeInfo_Location__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBGeneratedCodeInfo - -@implementation GPBGeneratedCodeInfo - -@dynamic annotationArray, annotationArray_Count; - -typedef struct GPBGeneratedCodeInfo__storage_ { - uint32_t _has_storage_[1]; - NSMutableArray *annotationArray; -} GPBGeneratedCodeInfo__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 = "annotationArray", - .number = GPBGeneratedCodeInfo_FieldNumber_AnnotationArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated, - .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBGeneratedCodeInfo__storage_, annotationArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBGeneratedCodeInfo_Annotation), - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBGeneratedCodeInfo class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBGeneratedCodeInfo__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - GPBGeneratedCodeInfo_Annotation - -@implementation GPBGeneratedCodeInfo_Annotation - -@dynamic pathArray, pathArray_Count; -@dynamic hasSourceFile, sourceFile; -@dynamic hasBegin, begin; -@dynamic hasEnd, end; - -typedef struct GPBGeneratedCodeInfo_Annotation__storage_ { - uint32_t _has_storage_[1]; - int32_t begin; - int32_t end; - GPBInt32Array *pathArray; - NSString *sourceFile; -} GPBGeneratedCodeInfo_Annotation__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 = "pathArray", - .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_PathArray, - .hasIndex = GPBNoHasBit, - .flags = GPBFieldRepeated | GPBFieldPacked, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, pathArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - #if GPBOBJC_INCLUDE_FIELD_OPTIONS - .fieldOptions = "\000\000\000\002\020\001", - #else - .fieldOptions = NULL, - #endif // GPBOBJC_INCLUDE_FIELD_OPTIONS - }, - { - .name = "sourceFile", - .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_SourceFile, - .hasIndex = 1, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeString, - .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, sourceFile), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "begin", - .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_Begin, - .hasIndex = 2, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, begin), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - { - .name = "end", - .number = GPBGeneratedCodeInfo_Annotation_FieldNumber_End, - .hasIndex = 3, - .flags = GPBFieldOptional, - .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBGeneratedCodeInfo_Annotation__storage_, end), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[GPBGeneratedCodeInfo_Annotation class] - rootClass:[GPBDescriptorRoot class] - file:GPBDescriptorRoot_FileDescriptor() - fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 - storageSize:sizeof(GPBGeneratedCodeInfo_Annotation__storage_) - wireFormat:NO]; - NSAssert(descriptor == nil, @"Startup recursed!"); - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -// @@protoc_insertion_point(global_scope) diff --git a/objectivec/google/protobuf/Duration.pbobjc.h b/objectivec/google/protobuf/Duration.pbobjc.h index ebf9119e..3685a614 100644 --- a/objectivec/google/protobuf/Duration.pbobjc.h +++ b/objectivec/google/protobuf/Duration.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Duration.pbobjc.m b/objectivec/google/protobuf/Duration.pbobjc.m index e4fd4951..bb79c7a3 100644 --- a/objectivec/google/protobuf/Duration.pbobjc.m +++ b/objectivec/google/protobuf/Duration.pbobjc.m @@ -46,25 +46,21 @@ typedef struct GPBDuration__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "seconds", + .dataTypeSpecific.className = NULL, .number = GPBDuration_FieldNumber_Seconds, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBDuration__storage_, seconds), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt64, - .offset = offsetof(GPBDuration__storage_, seconds), - .defaultValue.valueInt64 = 0LL, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "nanos", + .dataTypeSpecific.className = NULL, .number = GPBDuration_FieldNumber_Nanos, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBDuration__storage_, nanos), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBDuration__storage_, nanos), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -72,15 +68,9 @@ typedef struct GPBDuration__storage_ { rootClass:[GPBDurationRoot class] file:GPBDurationRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBDuration__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Empty.pbobjc.h b/objectivec/google/protobuf/Empty.pbobjc.h index ca09f71d..6651ef71 100644 --- a/objectivec/google/protobuf/Empty.pbobjc.h +++ b/objectivec/google/protobuf/Empty.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Empty.pbobjc.m b/objectivec/google/protobuf/Empty.pbobjc.m index 17f0c1ac..5d7f8f19 100644 --- a/objectivec/google/protobuf/Empty.pbobjc.m +++ b/objectivec/google/protobuf/Empty.pbobjc.m @@ -31,7 +31,7 @@ static GPBFileDescriptor *GPBEmptyRoot_FileDescriptor(void) { typedef struct GPBEmpty__storage_ { - uint32_t _has_storage_[0]; + uint32_t _has_storage_[1]; } GPBEmpty__storage_; // This method is threadsafe because it is initially called @@ -45,14 +45,8 @@ typedef struct GPBEmpty__storage_ { file:GPBEmptyRoot_FileDescriptor() fields:NULL fieldCount:0 - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 storageSize:sizeof(GPBEmpty__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.h b/objectivec/google/protobuf/FieldMask.pbobjc.h index f861a986..931f664c 100644 --- a/objectivec/google/protobuf/FieldMask.pbobjc.h +++ b/objectivec/google/protobuf/FieldMask.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.m b/objectivec/google/protobuf/FieldMask.pbobjc.m index f9684f51..36fc758e 100644 --- a/objectivec/google/protobuf/FieldMask.pbobjc.m +++ b/objectivec/google/protobuf/FieldMask.pbobjc.m @@ -44,14 +44,12 @@ typedef struct GPBFieldMask__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "pathsArray", + .dataTypeSpecific.className = NULL, .number = GPBFieldMask_FieldNumber_PathsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBFieldMask__storage_, pathsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeString, - .offset = offsetof(GPBFieldMask__storage_, pathsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -59,15 +57,9 @@ typedef struct GPBFieldMask__storage_ { rootClass:[GPBFieldMaskRoot class] file:GPBFieldMaskRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBFieldMask__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.h b/objectivec/google/protobuf/SourceContext.pbobjc.h index 546db674..67b6d479 100644 --- a/objectivec/google/protobuf/SourceContext.pbobjc.h +++ b/objectivec/google/protobuf/SourceContext.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.m b/objectivec/google/protobuf/SourceContext.pbobjc.m index ac1827fc..4e8bf3d2 100644 --- a/objectivec/google/protobuf/SourceContext.pbobjc.m +++ b/objectivec/google/protobuf/SourceContext.pbobjc.m @@ -44,14 +44,12 @@ typedef struct GPBSourceContext__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "fileName", + .dataTypeSpecific.className = NULL, .number = GPBSourceContext_FieldNumber_FileName, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBSourceContext__storage_, fileName), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBSourceContext__storage_, fileName), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -59,15 +57,9 @@ typedef struct GPBSourceContext__storage_ { rootClass:[GPBSourceContextRoot class] file:GPBSourceContextRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBSourceContext__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Struct.pbobjc.h b/objectivec/google/protobuf/Struct.pbobjc.h index 7b9c45a0..e2388e22 100644 --- a/objectivec/google/protobuf/Struct.pbobjc.h +++ b/objectivec/google/protobuf/Struct.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Struct.pbobjc.m b/objectivec/google/protobuf/Struct.pbobjc.m index 14b8f271..0601a4b2 100644 --- a/objectivec/google/protobuf/Struct.pbobjc.m +++ b/objectivec/google/protobuf/Struct.pbobjc.m @@ -30,13 +30,20 @@ static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) { GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) { static GPBEnumDescriptor *descriptor = NULL; if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "NullValue", .number = GPBNullValue_NullValue }, + static const char *valueNames = + "NullValue\000"; + static const int32_t values[] = { + GPBNullValue_NullValue, }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBNullValue) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBNullValue_IsValidValue]; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBNullValue) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBNullValue_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } } return descriptor; } @@ -69,14 +76,12 @@ typedef struct GPBStruct__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "fields", + .dataTypeSpecific.className = GPBStringifySymbol(GPBValue), .number = GPBStruct_FieldNumber_Fields, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBStruct__storage_, fields), .flags = GPBFieldMapKeyString, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBStruct__storage_, fields), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBValue), - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -84,15 +89,9 @@ typedef struct GPBStruct__storage_ { rootClass:[GPBStructRoot class] file:GPBStructRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBStruct__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -115,7 +114,6 @@ typedef struct GPBStruct__storage_ { typedef struct GPBValue__storage_ { uint32_t _has_storage_[2]; - BOOL boolValue; GPBNullValue nullValue; NSString *stringValue; GPBStruct *structValue; @@ -128,78 +126,60 @@ typedef struct GPBValue__storage_ { + (GPBDescriptor *)descriptor { static GPBDescriptor *descriptor = nil; if (!descriptor) { - static GPBMessageOneofDescription oneofs[] = { - { - .name = "kind", - .index = -1, - }, - }; static GPBMessageFieldDescription fields[] = { { .name = "nullValue", + .dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor, .number = GPBValue_FieldNumber_NullValue, .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, nullValue), .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBValue__storage_, nullValue), - .defaultValue.valueEnum = GPBNullValue_NullValue, - .dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor, - .fieldOptions = NULL, }, { .name = "numberValue", + .dataTypeSpecific.className = NULL, .number = GPBValue_FieldNumber_NumberValue, .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, numberValue), .flags = GPBFieldOptional, .dataType = GPBDataTypeDouble, - .offset = offsetof(GPBValue__storage_, numberValue), - .defaultValue.valueDouble = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "stringValue", + .dataTypeSpecific.className = NULL, .number = GPBValue_FieldNumber_StringValue, .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, stringValue), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBValue__storage_, stringValue), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "boolValue", + .dataTypeSpecific.className = NULL, .number = GPBValue_FieldNumber_BoolValue, .hasIndex = -1, + .offset = 0, // Stored in _has_storage_ to save space. .flags = GPBFieldOptional, .dataType = GPBDataTypeBool, - .offset = offsetof(GPBValue__storage_, boolValue), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "structValue", + .dataTypeSpecific.className = GPBStringifySymbol(GPBStruct), .number = GPBValue_FieldNumber_StructValue, .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, structValue), .flags = GPBFieldOptional, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBValue__storage_, structValue), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBStruct), - .fieldOptions = NULL, }, { .name = "listValue", + .dataTypeSpecific.className = GPBStringifySymbol(GPBListValue), .number = GPBValue_FieldNumber_ListValue, .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, listValue), .flags = GPBFieldOptional, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBValue__storage_, listValue), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBListValue), - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -207,15 +187,15 @@ typedef struct GPBValue__storage_ { rootClass:[GPBStructRoot class] file:GPBStructRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:oneofs - oneofCount:sizeof(oneofs) / sizeof(GPBMessageOneofDescription) - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBValue__storage_) - wireFormat:NO]; + flags:0]; + static const char *oneofs[] = { + "kind", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -239,7 +219,7 @@ void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value) { void GPBValue_ClearKindOneOfCase(GPBValue *message) { GPBDescriptor *descriptor = [message descriptor]; GPBOneofDescriptor *oneof = descriptor->oneofs_[0]; - GPBMaybeClearOneof(message, oneof, 0); + GPBMaybeClearOneof(message, oneof, -1, 0); } #pragma mark - GPBListValue @@ -260,14 +240,12 @@ typedef struct GPBListValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "valuesArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBValue), .number = GPBListValue_FieldNumber_ValuesArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBListValue__storage_, valuesArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBListValue__storage_, valuesArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBValue), - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -275,15 +253,9 @@ typedef struct GPBListValue__storage_ { rootClass:[GPBStructRoot class] file:GPBStructRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBListValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.h b/objectivec/google/protobuf/Timestamp.pbobjc.h index d17c2860..b66b323a 100644 --- a/objectivec/google/protobuf/Timestamp.pbobjc.h +++ b/objectivec/google/protobuf/Timestamp.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.m b/objectivec/google/protobuf/Timestamp.pbobjc.m index a206f159..14161159 100644 --- a/objectivec/google/protobuf/Timestamp.pbobjc.m +++ b/objectivec/google/protobuf/Timestamp.pbobjc.m @@ -46,25 +46,21 @@ typedef struct GPBTimestamp__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "seconds", + .dataTypeSpecific.className = NULL, .number = GPBTimestamp_FieldNumber_Seconds, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBTimestamp__storage_, seconds), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt64, - .offset = offsetof(GPBTimestamp__storage_, seconds), - .defaultValue.valueInt64 = 0LL, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "nanos", + .dataTypeSpecific.className = NULL, .number = GPBTimestamp_FieldNumber_Nanos, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBTimestamp__storage_, nanos), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBTimestamp__storage_, nanos), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -72,15 +68,9 @@ typedef struct GPBTimestamp__storage_ { rootClass:[GPBTimestampRoot class] file:GPBTimestampRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBTimestamp__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Type.pbobjc.h b/objectivec/google/protobuf/Type.pbobjc.h index 9301e4f4..efaeab39 100644 --- a/objectivec/google/protobuf/Type.pbobjc.h +++ b/objectivec/google/protobuf/Type.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Type.pbobjc.m b/objectivec/google/protobuf/Type.pbobjc.m index b4e0a5f6..175c0233 100644 --- a/objectivec/google/protobuf/Type.pbobjc.m +++ b/objectivec/google/protobuf/Type.pbobjc.m @@ -45,14 +45,21 @@ static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) { GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void) { static GPBEnumDescriptor *descriptor = NULL; if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "SyntaxProto2", .number = GPBSyntax_SyntaxProto2 }, - { .name = "SyntaxProto3", .number = GPBSyntax_SyntaxProto3 }, + static const char *valueNames = + "SyntaxProto2\000SyntaxProto3\000"; + static const int32_t values[] = { + GPBSyntax_SyntaxProto2, + GPBSyntax_SyntaxProto3, }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBSyntax) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBSyntax_IsValidValue]; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBSyntax) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBSyntax_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } } return descriptor; } @@ -96,69 +103,57 @@ typedef struct GPBType__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBType_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBType__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBType__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "fieldsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBField), .number = GPBType_FieldNumber_FieldsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBType__storage_, fieldsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBType__storage_, fieldsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBField), - .fieldOptions = NULL, }, { .name = "oneofsArray", + .dataTypeSpecific.className = NULL, .number = GPBType_FieldNumber_OneofsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBType__storage_, oneofsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeString, - .offset = offsetof(GPBType__storage_, oneofsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), .number = GPBType_FieldNumber_OptionsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBType__storage_, optionsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBType__storage_, optionsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), - .fieldOptions = NULL, }, { .name = "sourceContext", + .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), .number = GPBType_FieldNumber_SourceContext, - .hasIndex = 4, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBType__storage_, sourceContext), .flags = GPBFieldOptional, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBType__storage_, sourceContext), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), - .fieldOptions = NULL, }, { .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, .number = GPBType_FieldNumber_Syntax, - .hasIndex = 5, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBType__storage_, syntax), .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBType__storage_, syntax), - .defaultValue.valueEnum = GPBSyntax_SyntaxProto2, - .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -166,15 +161,9 @@ typedef struct GPBType__storage_ { rootClass:[GPBTypeRoot class] file:GPBTypeRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBType__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -212,7 +201,6 @@ void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value) { typedef struct GPBField__storage_ { uint32_t _has_storage_[1]; - BOOL packed; GPBField_Kind kind; GPBField_Cardinality cardinality; int32_t number; @@ -232,139 +220,108 @@ typedef struct GPBField__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "kind", + .dataTypeSpecific.enumDescFunc = GPBField_Kind_EnumDescriptor, .number = GPBField_FieldNumber_Kind, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBField__storage_, kind), .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBField__storage_, kind), - .defaultValue.valueEnum = GPBField_Kind_TypeUnknown, - .dataTypeSpecific.enumDescFunc = GPBField_Kind_EnumDescriptor, - .fieldOptions = NULL, }, { .name = "cardinality", + .dataTypeSpecific.enumDescFunc = GPBField_Cardinality_EnumDescriptor, .number = GPBField_FieldNumber_Cardinality, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBField__storage_, cardinality), .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBField__storage_, cardinality), - .defaultValue.valueEnum = GPBField_Cardinality_CardinalityUnknown, - .dataTypeSpecific.enumDescFunc = GPBField_Cardinality_EnumDescriptor, - .fieldOptions = NULL, }, { .name = "number", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_Number, .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBField__storage_, number), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBField__storage_, number), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_Name, .hasIndex = 3, + .offset = (uint32_t)offsetof(GPBField__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBField__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "typeURL", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_TypeURL, .hasIndex = 4, + .offset = (uint32_t)offsetof(GPBField__storage_, typeURL), .flags = GPBFieldOptional | GPBFieldTextFormatNameCustom, .dataType = GPBDataTypeString, - .offset = offsetof(GPBField__storage_, typeURL), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "oneofIndex", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_OneofIndex, .hasIndex = 5, + .offset = (uint32_t)offsetof(GPBField__storage_, oneofIndex), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBField__storage_, oneofIndex), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "packed", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_Packed, .hasIndex = 6, + .offset = 7, // Stored in _has_storage_ to save space. .flags = GPBFieldOptional, .dataType = GPBDataTypeBool, - .offset = offsetof(GPBField__storage_, packed), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), .number = GPBField_FieldNumber_OptionsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBField__storage_, optionsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBField__storage_, optionsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), - .fieldOptions = NULL, }, { .name = "jsonName", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_JsonName, .hasIndex = 8, + .offset = (uint32_t)offsetof(GPBField__storage_, jsonName), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBField__storage_, jsonName), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "defaultValue", + .dataTypeSpecific.className = NULL, .number = GPBField_FieldNumber_DefaultValue, .hasIndex = 9, + .offset = (uint32_t)offsetof(GPBField__storage_, defaultValue), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBField__storage_, defaultValue), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; - static GPBMessageEnumDescription enums[] = { - { .enumDescriptorFunc = GPBField_Kind_EnumDescriptor }, - { .enumDescriptorFunc = GPBField_Cardinality_EnumDescriptor }, - }; -#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - const char *extraTextFormatInfo = NULL; -#else - static const char *extraTextFormatInfo = "\001\006\004\241!!\000"; -#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS GPBDescriptor *localDescriptor = [GPBDescriptor allocDescriptorForClass:[GPBField class] rootClass:[GPBTypeRoot class] file:GPBTypeRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:enums - enumCount:sizeof(enums) / sizeof(GPBMessageEnumDescription) - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBField__storage_) - wireFormat:NO - extraTextFormatInfo:extraTextFormatInfo]; + flags:0]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\006\004\241!!\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -402,31 +359,43 @@ void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value) { GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void) { static GPBEnumDescriptor *descriptor = NULL; if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "TypeUnknown", .number = GPBField_Kind_TypeUnknown }, - { .name = "TypeDouble", .number = GPBField_Kind_TypeDouble }, - { .name = "TypeFloat", .number = GPBField_Kind_TypeFloat }, - { .name = "TypeInt64", .number = GPBField_Kind_TypeInt64 }, - { .name = "TypeUint64", .number = GPBField_Kind_TypeUint64 }, - { .name = "TypeInt32", .number = GPBField_Kind_TypeInt32 }, - { .name = "TypeFixed64", .number = GPBField_Kind_TypeFixed64 }, - { .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 }, - { .name = "TypeEnum", .number = GPBField_Kind_TypeEnum }, - { .name = "TypeSfixed32", .number = GPBField_Kind_TypeSfixed32 }, - { .name = "TypeSfixed64", .number = GPBField_Kind_TypeSfixed64 }, - { .name = "TypeSint32", .number = GPBField_Kind_TypeSint32 }, - { .name = "TypeSint64", .number = GPBField_Kind_TypeSint64 }, + static const char *valueNames = + "TypeUnknown\000TypeDouble\000TypeFloat\000TypeInt" + "64\000TypeUint64\000TypeInt32\000TypeFixed64\000Type" + "Fixed32\000TypeBool\000TypeString\000TypeGroup\000Ty" + "peMessage\000TypeBytes\000TypeUint32\000TypeEnum\000" + "TypeSfixed32\000TypeSfixed64\000TypeSint32\000Typ" + "eSint64\000"; + static const int32_t values[] = { + GPBField_Kind_TypeUnknown, + GPBField_Kind_TypeDouble, + GPBField_Kind_TypeFloat, + GPBField_Kind_TypeInt64, + GPBField_Kind_TypeUint64, + GPBField_Kind_TypeInt32, + GPBField_Kind_TypeFixed64, + GPBField_Kind_TypeFixed32, + GPBField_Kind_TypeBool, + GPBField_Kind_TypeString, + GPBField_Kind_TypeGroup, + GPBField_Kind_TypeMessage, + GPBField_Kind_TypeBytes, + GPBField_Kind_TypeUint32, + GPBField_Kind_TypeEnum, + GPBField_Kind_TypeSfixed32, + GPBField_Kind_TypeSfixed64, + GPBField_Kind_TypeSint32, + GPBField_Kind_TypeSint64, }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Kind) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBField_Kind_IsValidValue]; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Kind) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBField_Kind_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } } return descriptor; } @@ -463,16 +432,24 @@ BOOL GPBField_Kind_IsValidValue(int32_t value__) { GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void) { static GPBEnumDescriptor *descriptor = NULL; if (!descriptor) { - static GPBMessageEnumValueDescription values[] = { - { .name = "CardinalityUnknown", .number = GPBField_Cardinality_CardinalityUnknown }, - { .name = "CardinalityOptional", .number = GPBField_Cardinality_CardinalityOptional }, - { .name = "CardinalityRequired", .number = GPBField_Cardinality_CardinalityRequired }, - { .name = "CardinalityRepeated", .number = GPBField_Cardinality_CardinalityRepeated }, + static const char *valueNames = + "CardinalityUnknown\000CardinalityOptional\000C" + "ardinalityRequired\000CardinalityRepeated\000"; + static const int32_t values[] = { + GPBField_Cardinality_CardinalityUnknown, + GPBField_Cardinality_CardinalityOptional, + GPBField_Cardinality_CardinalityRequired, + GPBField_Cardinality_CardinalityRepeated, }; - descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Cardinality) - values:values - valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription) - enumVerifier:GPBField_Cardinality_IsValidValue]; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Cardinality) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBField_Cardinality_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } } return descriptor; } @@ -516,58 +493,48 @@ typedef struct GPBEnum__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBEnum_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBEnum__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBEnum__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "enumvalueArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValue), .number = GPBEnum_FieldNumber_EnumvalueArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBEnum__storage_, enumvalueArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnum__storage_, enumvalueArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValue), - .fieldOptions = NULL, }, { .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), .number = GPBEnum_FieldNumber_OptionsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBEnum__storage_, optionsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnum__storage_, optionsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), - .fieldOptions = NULL, }, { .name = "sourceContext", + .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), .number = GPBEnum_FieldNumber_SourceContext, - .hasIndex = 3, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBEnum__storage_, sourceContext), .flags = GPBFieldOptional, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnum__storage_, sourceContext), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), - .fieldOptions = NULL, }, { .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, .number = GPBEnum_FieldNumber_Syntax, - .hasIndex = 4, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBEnum__storage_, syntax), .flags = GPBFieldOptional | GPBFieldHasEnumDescriptor, .dataType = GPBDataTypeEnum, - .offset = offsetof(GPBEnum__storage_, syntax), - .defaultValue.valueEnum = GPBSyntax_SyntaxProto2, - .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -575,15 +542,9 @@ typedef struct GPBEnum__storage_ { rootClass:[GPBTypeRoot class] file:GPBTypeRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBEnum__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -627,36 +588,30 @@ typedef struct GPBEnumValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBEnumValue_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBEnumValue__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBEnumValue__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "number", + .dataTypeSpecific.className = NULL, .number = GPBEnumValue_FieldNumber_Number, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBEnumValue__storage_, number), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBEnumValue__storage_, number), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), .number = GPBEnumValue_FieldNumber_OptionsArray, .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBEnumValue__storage_, optionsArray), .flags = GPBFieldRepeated, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBEnumValue__storage_, optionsArray), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -664,15 +619,9 @@ typedef struct GPBEnumValue__storage_ { rootClass:[GPBTypeRoot class] file:GPBTypeRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBEnumValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -702,25 +651,21 @@ typedef struct GPBOption__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "name", + .dataTypeSpecific.className = NULL, .number = GPBOption_FieldNumber_Name, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBOption__storage_, name), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBOption__storage_, name), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, { .name = "value", + .dataTypeSpecific.className = GPBStringifySymbol(GPBAny), .number = GPBOption_FieldNumber_Value, .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBOption__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeMessage, - .offset = offsetof(GPBOption__storage_, value), - .defaultValue.valueMessage = nil, - .dataTypeSpecific.className = GPBStringifySymbol(GPBAny), - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -728,15 +673,9 @@ typedef struct GPBOption__storage_ { rootClass:[GPBTypeRoot class] file:GPBTypeRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBOption__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.h b/objectivec/google/protobuf/Wrappers.pbobjc.h index 38b99622..0ca439a8 100644 --- a/objectivec/google/protobuf/Wrappers.pbobjc.h +++ b/objectivec/google/protobuf/Wrappers.pbobjc.h @@ -3,7 +3,7 @@ #import "GPBProtocolBuffers.h" -#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 +#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 #error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources. #endif diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.m b/objectivec/google/protobuf/Wrappers.pbobjc.m index 0403b464..b1b5be69 100644 --- a/objectivec/google/protobuf/Wrappers.pbobjc.m +++ b/objectivec/google/protobuf/Wrappers.pbobjc.m @@ -44,14 +44,12 @@ typedef struct GPBDoubleValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBDoubleValue_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBDoubleValue__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeDouble, - .offset = offsetof(GPBDoubleValue__storage_, value), - .defaultValue.valueDouble = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -59,15 +57,9 @@ typedef struct GPBDoubleValue__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBDoubleValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -95,14 +87,12 @@ typedef struct GPBFloatValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBFloatValue_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBFloatValue__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeFloat, - .offset = offsetof(GPBFloatValue__storage_, value), - .defaultValue.valueFloat = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -110,15 +100,9 @@ typedef struct GPBFloatValue__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBFloatValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -146,14 +130,12 @@ typedef struct GPBInt64Value__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBInt64Value_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBInt64Value__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt64, - .offset = offsetof(GPBInt64Value__storage_, value), - .defaultValue.valueInt64 = 0LL, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -161,15 +143,9 @@ typedef struct GPBInt64Value__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBInt64Value__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -197,14 +173,12 @@ typedef struct GPBUInt64Value__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBUInt64Value_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBUInt64Value__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeUInt64, - .offset = offsetof(GPBUInt64Value__storage_, value), - .defaultValue.valueUInt64 = 0ULL, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -212,15 +186,9 @@ typedef struct GPBUInt64Value__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBUInt64Value__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -248,14 +216,12 @@ typedef struct GPBInt32Value__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBInt32Value_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBInt32Value__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeInt32, - .offset = offsetof(GPBInt32Value__storage_, value), - .defaultValue.valueInt32 = 0, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -263,15 +229,9 @@ typedef struct GPBInt32Value__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBInt32Value__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -299,14 +259,12 @@ typedef struct GPBUInt32Value__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBUInt32Value_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBUInt32Value__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeUInt32, - .offset = offsetof(GPBUInt32Value__storage_, value), - .defaultValue.valueUInt32 = 0U, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -314,15 +272,9 @@ typedef struct GPBUInt32Value__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBUInt32Value__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -339,7 +291,6 @@ typedef struct GPBUInt32Value__storage_ { typedef struct GPBBoolValue__storage_ { uint32_t _has_storage_[1]; - BOOL value; } GPBBoolValue__storage_; // This method is threadsafe because it is initially called @@ -350,14 +301,12 @@ typedef struct GPBBoolValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBBoolValue_FieldNumber_Value, .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. .flags = GPBFieldOptional, .dataType = GPBDataTypeBool, - .offset = offsetof(GPBBoolValue__storage_, value), - .defaultValue.valueBool = NO, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -365,15 +314,9 @@ typedef struct GPBBoolValue__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBBoolValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -401,14 +344,12 @@ typedef struct GPBStringValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBStringValue_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBStringValue__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeString, - .offset = offsetof(GPBStringValue__storage_, value), - .defaultValue.valueString = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -416,15 +357,9 @@ typedef struct GPBStringValue__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBStringValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } @@ -452,14 +387,12 @@ typedef struct GPBBytesValue__storage_ { static GPBMessageFieldDescription fields[] = { { .name = "value", + .dataTypeSpecific.className = NULL, .number = GPBBytesValue_FieldNumber_Value, .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBBytesValue__storage_, value), .flags = GPBFieldOptional, .dataType = GPBDataTypeBytes, - .offset = offsetof(GPBBytesValue__storage_, value), - .defaultValue.valueData = nil, - .dataTypeSpecific.className = NULL, - .fieldOptions = NULL, }, }; GPBDescriptor *localDescriptor = @@ -467,15 +400,9 @@ typedef struct GPBBytesValue__storage_ { rootClass:[GPBWrappersRoot class] file:GPBWrappersRoot_FileDescriptor() fields:fields - fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) - oneofs:NULL - oneofCount:0 - enums:NULL - enumCount:0 - ranges:NULL - rangeCount:0 + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBBytesValue__storage_) - wireFormat:NO]; + flags:0]; NSAssert(descriptor == nil, @"Startup recursed!"); descriptor = localDescriptor; } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index 857d24a4..3f81dcb8 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -122,16 +122,6 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { "\n", "name", name_); - printer->Print( - "GPBEnumDescriptor *$name$_EnumDescriptor(void) {\n" - " static GPBEnumDescriptor *descriptor = NULL;\n" - " if (!descriptor) {\n" - " static GPBMessageEnumValueDescription values[] = {\n", - "name", name_); - printer->Indent(); - printer->Indent(); - printer->Indent(); - // Note: For the TextFormat decode info, we can't use the enum value as // the key because protocol buffer enums have 'allow_alias', which lets // a value be used more than once. Instead, the index into the list of @@ -139,41 +129,66 @@ void EnumGenerator::GenerateSource(io::Printer* printer) { // will be zero. TextFormatDecodeData text_format_decode_data; int enum_value_description_key = -1; + string text_blob; for (int i = 0; i < all_values_.size(); i++) { ++enum_value_description_key; string short_name(EnumValueShortName(all_values_[i])); - printer->Print("{ .name = \"$short_name$\", .number = $name$ },\n", - "short_name", short_name, - "name", EnumValueName(all_values_[i])); + text_blob += short_name + '\0'; if (UnCamelCaseEnumShortName(short_name) != all_values_[i]->name()) { text_format_decode_data.AddString(enum_value_description_key, short_name, all_values_[i]->name()); } } - printer->Outdent(); - printer->Outdent(); - printer->Outdent(); + + printer->Print( + "GPBEnumDescriptor *$name$_EnumDescriptor(void) {\n" + " static GPBEnumDescriptor *descriptor = NULL;\n" + " if (!descriptor) {\n", + "name", name_); + + static const int kBytesPerLine = 40; // allow for escaping + printer->Print( + " static const char *valueNames ="); + for (int i = 0; i < text_blob.size(); i += kBytesPerLine) { + printer->Print( + "\n \"$data$\"", + "data", EscapeTrigraphs(CEscape(text_blob.substr(i, kBytesPerLine)))); + } + printer->Print( + ";\n" + " static const int32_t values[] = {\n"); + for (int i = 0; i < all_values_.size(); i++) { + printer->Print(" $name$,\n", "name", EnumValueName(all_values_[i])); + } printer->Print(" };\n"); + if (text_format_decode_data.num_entries() == 0) { printer->Print( - " descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n" - " values:values\n" - " valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)\n" - " enumVerifier:$name$_IsValidValue];\n", + " GPBEnumDescriptor *worker =\n" + " [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n" + " valueNames:valueNames\n" + " values:values\n" + " count:(uint32_t)(sizeof(values) / sizeof(int32_t))\n" + " enumVerifier:$name$_IsValidValue];\n", "name", name_); } else { printer->Print( " static const char *extraTextFormatInfo = \"$extraTextFormatInfo$\";\n" - " descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n" - " values:values\n" - " valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)\n" - " enumVerifier:$name$_IsValidValue\n" - " extraTextFormatInfo:extraTextFormatInfo];\n", + " GPBEnumDescriptor *worker =\n" + " [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\n" + " valueNames:valueNames\n" + " values:values\n" + " count:(uint32_t)(sizeof(values) / sizeof(int32_t))\n" + " enumVerifier:$name$_IsValidValue\n" + " extraTextFormatInfo:extraTextFormatInfo];\n", "name", name_, "extraTextFormatInfo", CEscape(text_format_decode_data.Data())); } printer->Print( + " if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) {\n" + " [worker release];\n" + " }\n" " }\n" " return descriptor;\n" "}\n\n"); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc index cfbb8c52..b63bc0de 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc @@ -59,6 +59,9 @@ void SetEnumVariables(const FieldDescriptor* descriptor, (*variables)["enum_verifier"] = type + "_IsValidValue"; (*variables)["enum_desc_func"] = type + "_EnumDescriptor"; + (*variables)["dataTypeSpecific_name"] = "enumDescFunc"; + (*variables)["dataTypeSpecific_value"] = (*variables)["enum_desc_func"]; + const Descriptor* msg_descriptor = descriptor->containing_type(); (*variables)["owning_message_class"] = ClassName(msg_descriptor); } @@ -72,13 +75,6 @@ EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor, EnumFieldGenerator::~EnumFieldGenerator() {} -void EnumFieldGenerator::GenerateFieldDescriptionTypeSpecific( - io::Printer* printer) const { - printer->Print( - variables_, - " .dataTypeSpecific.enumDescFunc = $enum_desc_func$,\n"); -} - void EnumFieldGenerator::GenerateCFunctionDeclarations( io::Printer* printer) const { if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { @@ -145,13 +141,6 @@ void RepeatedEnumFieldGenerator::FinishInitialization(void) { "// |" + variables_["name"] + "| contains |" + variables_["storage_type"] + "|\n"; } -void RepeatedEnumFieldGenerator::GenerateFieldDescriptionTypeSpecific( - io::Printer* printer) const { - printer->Print( - variables_, - " .dataTypeSpecific.enumDescFunc = $enum_desc_func$,\n"); -} - } // namespace objectivec } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h index ae2f57e3..946faa81 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h @@ -45,7 +45,6 @@ class EnumFieldGenerator : public SingleFieldGenerator { const Options& options); public: - virtual void GenerateFieldDescriptionTypeSpecific(io::Printer* printer) const; virtual void GenerateCFunctionDeclarations(io::Printer* printer) const; virtual void GenerateCFunctionImplementations(io::Printer* printer) const; virtual void DetermineForwardDeclarations(set* fwd_decls) const; @@ -64,7 +63,6 @@ class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator { public: virtual void FinishInitialization(); - virtual void GenerateFieldDescriptionTypeSpecific(io::Printer* printer) const; protected: RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index 4e348393..3f7ab9d3 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -114,14 +114,14 @@ void ExtensionGenerator::GenerateStaticVariablesInitialization( printer->Print(vars, "{\n" + " .defaultValue.$default_name$ = $default$,\n" " .singletonName = GPBStringifySymbol($root_class_and_method_name$),\n" - " .dataType = $extension_type$,\n" " .extendedClass = GPBStringifySymbol($extended_type$),\n" - " .fieldNumber = $number$,\n" - " .defaultValue.$default_name$ = $default$,\n" " .messageOrGroupClassName = $type$,\n" - " .options = $options$,\n" " .enumDescriptorFunc = $enum_desc_func_name$,\n" + " .fieldNumber = $number$,\n" + " .dataType = $extension_type$,\n" + " .options = $options$,\n" "},\n"); } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 8697e225..7bb9837d 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -28,6 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include + #include #include #include @@ -75,7 +77,6 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["field_number_name"] = classname + "_FieldNumber_" + capitalized_name; (*variables)["field_number"] = SimpleItoa(descriptor->number()); - (*variables)["has_index"] = SimpleItoa(descriptor->index()); (*variables)["field_type"] = GetCapitalizedType(descriptor); std::vector field_flags; if (descriptor->is_repeated()) field_flags.push_back("GPBFieldRepeated"); @@ -99,18 +100,9 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["dataTypeSpecific_name"] = "className"; (*variables)["dataTypeSpecific_value"] = "NULL"; - string field_options = descriptor->options().SerializeAsString(); - // Must convert to a standard byte order for packing length into - // a cstring. - uint32 length = ghtonl(field_options.length()); - if (length > 0) { - string bytes((const char*)&length, sizeof(length)); - bytes.append(field_options); - string options_str = "\"" + CEscape(bytes) + "\""; - (*variables)["fieldoptions"] = "\"" + CEscape(bytes) + "\""; - } else { - (*variables)["fieldoptions"] = ""; - } + (*variables)["storage_offset_value"] = + "(uint32_t)offsetof(" + classname + "__storage_, " + camel_case_name + ")"; + (*variables)["storage_offset_comment"] = ""; // Clear some common things so they can be set just when needed. (*variables)["storage_attribute"] = ""; @@ -190,52 +182,54 @@ void FieldGenerator::DetermineForwardDeclarations( } void FieldGenerator::GenerateFieldDescription( - io::Printer* printer) const { - printer->Print( - variables_, - "{\n" - " .name = \"$name$\",\n" - " .number = $field_number_name$,\n" - " .hasIndex = $has_index$,\n" - " .flags = $fieldflags$,\n" - " .dataType = GPBDataType$field_type$,\n" - " .offset = offsetof($classname$__storage_, $name$),\n" - " .defaultValue.$default_name$ = $default$,\n"); - - // TODO(thomasvl): It might be useful to add a CPP wrapper to support - // compiling away the EnumDescriptors. To do that, we'd need a #if here - // to control setting the descriptor vs. the validator, and above in - // SetCommonFieldVariables() we'd want to wrap how we add - // GPBFieldHasDefaultValue to the flags. - - // " .dataTypeSpecific.value* = [something]," - GenerateFieldDescriptionTypeSpecific(printer); - - const string& field_options(variables_.find("fieldoptions")->second); - if (field_options.empty()) { - printer->Print(" .fieldOptions = NULL,\n"); + io::Printer* printer, bool include_default) const { + // Printed in the same order as the structure decl. + if (include_default) { + printer->Print( + variables_, + "{\n" + " .defaultValue.$default_name$ = $default$,\n" + " .core.name = \"$name$\",\n" + " .core.dataTypeSpecific.$dataTypeSpecific_name$ = $dataTypeSpecific_value$,\n" + " .core.number = $field_number_name$,\n" + " .core.hasIndex = $has_index$,\n" + " .core.offset = $storage_offset_value$,$storage_offset_comment$\n" + " .core.flags = $fieldflags$,\n" + " .core.dataType = GPBDataType$field_type$,\n" + "},\n"); } else { - // Can't use PrintRaw() here to get the #if/#else/#endif lines completely - // outdented because the need for indent captured on the previous - // printing of a \n and there is no way to get the current indent level - // to call the right number of Outdent()/Indents() to maintain state. printer->Print( variables_, - "#if GPBOBJC_INCLUDE_FIELD_OPTIONS\n" - " .fieldOptions = $fieldoptions$,\n" - "#else\n" - " .fieldOptions = NULL,\n" - "#endif // GPBOBJC_INCLUDE_FIELD_OPTIONS\n"); + "{\n" + " .name = \"$name$\",\n" + " .dataTypeSpecific.$dataTypeSpecific_name$ = $dataTypeSpecific_value$,\n" + " .number = $field_number_name$,\n" + " .hasIndex = $has_index$,\n" + " .offset = $storage_offset_value$,$storage_offset_comment$\n" + " .flags = $fieldflags$,\n" + " .dataType = GPBDataType$field_type$,\n" + "},\n"); } +} - printer->Print("},\n"); +void FieldGenerator::SetRuntimeHasBit(int has_index) { + variables_["has_index"] = SimpleItoa(has_index); } -void FieldGenerator::GenerateFieldDescriptionTypeSpecific( - io::Printer* printer) const { - printer->Print( - variables_, - " .dataTypeSpecific.$dataTypeSpecific_name$ = $dataTypeSpecific_value$,\n"); +void FieldGenerator::SetNoHasBit(void) { + variables_["has_index"] = "GPBNoHasBit"; +} + +int FieldGenerator::ExtraRuntimeHasBitsNeeded(void) const { + return 0; +} + +void FieldGenerator::SetExtraRuntimeHasBitsBase(int index_base) { + // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some + // error cases, so it seems to be ok to use as a back door for errors. + cerr << "Error: should have overriden SetExtraRuntimeHasBitsBase()." << endl; + cerr.flush(); + abort(); } void FieldGenerator::SetOneofIndexBase(int index_base) { @@ -302,6 +296,14 @@ bool SingleFieldGenerator::WantsHasProperty(void) const { return false; } +bool SingleFieldGenerator::RuntimeUsesHasBit(void) const { + if (descriptor_->containing_oneof() != NULL) { + // The oneof tracks what is set instead. + return false; + } + return true; +} + ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor, const Options& options) : SingleFieldGenerator(descriptor, options) { @@ -347,8 +349,6 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration( RepeatedFieldGenerator::RepeatedFieldGenerator( const FieldDescriptor* descriptor, const Options& options) : ObjCObjFieldGenerator(descriptor, options) { - // Repeated fields don't use the has index. - variables_["has_index"] = "GPBNoHasBit"; // Default to no comment and let the cases needing it fill it in. variables_["array_comment"] = ""; } @@ -402,6 +402,10 @@ bool RepeatedFieldGenerator::WantsHasProperty(void) const { return false; } +bool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const { + return false; // The array having anything is what is used. +} + FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, const Options& options) : descriptor_(descriptor), @@ -432,12 +436,40 @@ const FieldGenerator& FieldGeneratorMap::get_extension(int index) const { return *extension_generators_[index]; } +int FieldGeneratorMap::CalculateHasBits(void) { + int total_bits = 0; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (field_generators_[i]->RuntimeUsesHasBit()) { + field_generators_[i]->SetRuntimeHasBit(total_bits); + ++total_bits; + } else { + field_generators_[i]->SetNoHasBit(); + } + int extra_bits = field_generators_[i]->ExtraRuntimeHasBitsNeeded(); + if (extra_bits) { + field_generators_[i]->SetExtraRuntimeHasBitsBase(total_bits); + total_bits += extra_bits; + } + } + return total_bits; +} + void FieldGeneratorMap::SetOneofIndexBase(int index_base) { for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_[i]->SetOneofIndexBase(index_base); } } +bool FieldGeneratorMap::DoesAnyFieldHaveNonZeroDefault(void) const { + for (int i = 0; i < descriptor_->field_count(); i++) { + if (HasNonZeroDefaultValue(descriptor_->field(i))) { + return true; + } + } + + return false; +} + } // namespace objectivec } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.h b/src/google/protobuf/compiler/objectivec/objectivec_field.h index e8a20a72..a3a4b1b6 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.h @@ -61,7 +61,6 @@ class FieldGenerator { // Called by GenerateFieldDescription, exposed for classes that need custom // generation. - virtual void GenerateFieldDescriptionTypeSpecific(io::Printer* printer) const; // Exposed for subclasses to extend, base does nothing. virtual void GenerateCFunctionDeclarations(io::Printer* printer) const; @@ -71,9 +70,16 @@ class FieldGenerator { virtual void DetermineForwardDeclarations(set* fwd_decls) const; // Used during generation, not intended to be extended by subclasses. - void GenerateFieldDescription(io::Printer* printer) const; + void GenerateFieldDescription( + io::Printer* printer, bool include_default) const; void GenerateFieldNumberConstant(io::Printer* printer) const; + // Exposed to get and set the has bits information. + virtual bool RuntimeUsesHasBit(void) const = 0; + void SetRuntimeHasBit(int has_index); + void SetNoHasBit(void); + virtual int ExtraRuntimeHasBitsNeeded(void) const; + virtual void SetExtraRuntimeHasBitsBase(int index_base); void SetOneofIndexBase(int index_base); string variable(const char* key) const { @@ -109,6 +115,8 @@ class SingleFieldGenerator : public FieldGenerator { virtual void GeneratePropertyImplementation(io::Printer* printer) const; + virtual bool RuntimeUsesHasBit(void) const; + protected: SingleFieldGenerator(const FieldDescriptor* descriptor, const Options& options); @@ -143,6 +151,8 @@ class RepeatedFieldGenerator : public ObjCObjFieldGenerator { virtual void GeneratePropertyImplementation(io::Printer* printer) const; + virtual bool RuntimeUsesHasBit(void) const; + protected: RepeatedFieldGenerator(const FieldDescriptor* descriptor, const Options& options); @@ -162,8 +172,14 @@ class FieldGeneratorMap { const FieldGenerator& get(const FieldDescriptor* field) const; const FieldGenerator& get_extension(int index) const; + // Assigns the has bits and returns the number of bits needed. + int CalculateHasBits(void); + void SetOneofIndexBase(int index_base); + // Check if any field of this message has a non zero default. + bool DoesAnyFieldHaveNonZeroDefault(void) const; + private: const Descriptor* descriptor_; scoped_array > field_generators_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index 16199884..c58e7530 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -45,7 +45,7 @@ namespace protobuf { // This is also found in GPBBootstrap.h, and needs to be kept in sync. It // is the version check done to ensure generated code works with the current // runtime being used. -const int32 GOOGLE_PROTOBUF_OBJC_GEN_VERSION = 30000; +const int32 GOOGLE_PROTOBUF_OBJC_GEN_VERSION = 30001; namespace compiler { namespace objectivec { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index b912ea67..fda51807 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -220,11 +220,6 @@ string NameFromFieldDescriptor(const FieldDescriptor* field) { } } -// Escape C++ trigraphs by escaping question marks to \? -string EscapeTrigraphs(const string& to_escape) { - return StringReplace(to_escape, "?", "\\?", true); -} - void PathSplit(const string& path, string* directory, string* basename) { string::size_type last_slash = path.rfind('/'); if (last_slash == string::npos) { @@ -264,6 +259,11 @@ bool IsSpecialName(const string& name, const string* special_names, } // namespace +// Escape C++ trigraphs by escaping question marks to \? +string EscapeTrigraphs(const string& to_escape) { + return StringReplace(to_escape, "?", "\\?", true); +} + string StripProto(const string& filename) { if (HasSuffixString(filename, ".protodevel")) { return StripSuffixString(filename, ".protodevel"); @@ -734,7 +734,7 @@ string DefaultValue(const FieldDescriptor* field) { uint32 length = ghtonl(default_string.length()); string bytes((const char*)&length, sizeof(length)); bytes.append(default_string); - return "(NSData*)\"" + CEscape(bytes) + "\""; + return "(NSData*)\"" + EscapeTrigraphs(CEscape(bytes)) + "\""; } else { return "@\"" + EscapeTrigraphs(CEscape(default_string)) + "\""; } @@ -751,6 +751,50 @@ string DefaultValue(const FieldDescriptor* field) { return NULL; } +bool HasNonZeroDefaultValue(const FieldDescriptor* field) { + // Repeated fields don't have defaults. + if (field->is_repeated()) { + return false; + } + + if (!field->has_default_value()) { + // No custom default set in the proto file. + return false; + } + + // Some proto file set the default to the zero value, so make sure the value + // isn't the zero case. + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_INT32: + return field->default_value_int32() != 0; + case FieldDescriptor::CPPTYPE_UINT32: + return field->default_value_uint32() != 0U; + case FieldDescriptor::CPPTYPE_INT64: + return field->default_value_int64() != 0LL; + case FieldDescriptor::CPPTYPE_UINT64: + return field->default_value_uint64() != 0ULL; + case FieldDescriptor::CPPTYPE_DOUBLE: + return field->default_value_double() != 0.0; + case FieldDescriptor::CPPTYPE_FLOAT: + return field->default_value_float() != 0.0f; + case FieldDescriptor::CPPTYPE_BOOL: + return field->default_value_bool(); + case FieldDescriptor::CPPTYPE_STRING: { + const string& default_string = field->default_value_string(); + return default_string.length() != 0; + } + case FieldDescriptor::CPPTYPE_ENUM: + return field->default_value_enum()->number() != 0; + case FieldDescriptor::CPPTYPE_MESSAGE: + return false; + } + + // Some compilers report reaching end of function even though all cases of + // the enum are handed in the switch. + GOOGLE_LOG(FATAL) << "Can't get here."; + return false; +} + string BuildFlagsString(const vector& strings) { if (strings.size() == 0) { return "0"; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index a301493e..0db9de94 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -48,6 +48,9 @@ struct Options { string expected_prefixes_path; }; +// Escape C++ trigraphs by escaping question marks to "\?". +string EscapeTrigraphs(const string& to_escape); + // Strips ".proto" or ".protodevel" from the end of a filename. string StripProto(const string& filename); @@ -143,6 +146,7 @@ bool IsReferenceType(const FieldDescriptor* field); string GPBGenericValueFieldName(const FieldDescriptor* field); string DefaultValue(const FieldDescriptor* field); +bool HasNonZeroDefaultValue(const FieldDescriptor* field); string BuildFlagsString(const vector& strings); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc index 2751e936..ac5d8aea 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc @@ -140,13 +140,18 @@ MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor, value_field_generator_->variable("storage_type") + "*>"; } } + + variables_["dataTypeSpecific_name"] = + value_field_generator_->variable("dataTypeSpecific_name"); + variables_["dataTypeSpecific_value"] = + value_field_generator_->variable("dataTypeSpecific_value"); } MapFieldGenerator::~MapFieldGenerator() {} void MapFieldGenerator::FinishInitialization(void) { RepeatedFieldGenerator::FinishInitialization(); - // Use the array_comment suport in RepeatedFieldGenerator to output what the + // Use the array_comment support in RepeatedFieldGenerator to output what the // values in the map are. const FieldDescriptor* value_descriptor = descriptor_->message_type()->FindFieldByName("value"); @@ -156,13 +161,6 @@ void MapFieldGenerator::FinishInitialization(void) { } } -void MapFieldGenerator::GenerateFieldDescriptionTypeSpecific( - io::Printer* printer) const { - // Relay it to the value generator to provide enum validator, message - // class, etc. - value_field_generator_->GenerateFieldDescriptionTypeSpecific(printer); -} - void MapFieldGenerator::DetermineForwardDeclarations( set* fwd_decls) const { RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h index 7351ea05..bc68a682 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h @@ -46,7 +46,6 @@ class MapFieldGenerator : public RepeatedFieldGenerator { public: virtual void FinishInitialization(void); - virtual void GenerateFieldDescriptionTypeSpecific(io::Printer* printer) const; protected: MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index e0ea8bd2..3ebeeade 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -66,11 +66,12 @@ int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) { // The first item in the object structure is our uint32[] for has bits. // We then want to order things to make the instances as small as // possible. So we follow the has bits with: - // 1. Bools (1 byte) - // 2. Anything always 4 bytes - float, *32, enums - // 3. Anything that is always a pointer (they will be 8 bytes on 64 bit + // 1. Anything always 4 bytes - float, *32, enums + // 2. Anything that is always a pointer (they will be 8 bytes on 64 bit // builds and 4 bytes on 32bit builds. - // 4. Anything always 8 bytes - double, *64 + // 3. Anything always 8 bytes - double, *64 + // + // NOTE: Bools aren't listed, they were stored in the has bits. // // Why? Using 64bit builds as an example, this means worse case, we have // enough bools that we overflow 1 byte from 4 byte alignment, so 3 bytes @@ -115,9 +116,9 @@ int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) { case FieldDescriptor::TYPE_ENUM: return 2; - // 1 byte. + // 0 bytes. Stored in the has bits. case FieldDescriptor::TYPE_BOOL: - return 1; + return 99; // End of the list (doesn't really matter). } // Some compilers report reaching end of function even though all cases of @@ -404,32 +405,28 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { sort(sorted_extensions.begin(), sorted_extensions.end(), ExtensionRangeOrdering()); - // TODO(thomasvl): Finish optimizing has bit. The current behavior is as - // follows: - // 1. objectivec_field.cc's SetCommonFieldVariables() defaults the has_index - // to the field's index in the list of fields. - // 2. RepeatedFieldGenerator::RepeatedFieldGenerator() sets has_index to - // GPBNoHasBit because repeated fields & map<> fields don't use the has - // bit. - // 3. FieldGenerator::SetOneofIndexBase() overrides has_bit with a negative - // index that groups all the elements on of the oneof. - // So in has_storage, we need enough bits for the single fields that aren't - // in any oneof, and then one int32 for each oneof (to store the field - // number). So we could save a little space by not using the field's index - // and instead make a second pass only assigning indexes for the fields - // that would need it. The only savings would come when messages have over - // a multiple of 32 fields with some number being repeated or in oneofs to - // drop the count below that 32 multiple; so it hasn't seemed worth doing - // at the moment. - size_t num_has_bits = descriptor_->field_count(); + // Assign has bits: + // 1. FieldGeneratorMap::CalculateHasBits() loops through the fields seeing + // who needs has bits and assigning them. + // 2. FieldGenerator::SetOneofIndexBase() overrides has_bit with a negative + // index that groups all the elements in the oneof. + size_t num_has_bits = field_generators_.CalculateHasBits(); size_t sizeof_has_storage = (num_has_bits + 31) / 32; + if (sizeof_has_storage == 0) { + // In the case where no field needs has bits, don't let the _has_storage_ + // end up as zero length (zero length arrays are sort of a grey area + // since it has to be at the start of the struct). This also ensures a + // field with only oneofs keeps the required negative indices they need. + sizeof_has_storage = 1; + } // Tell all the fields the oneof base. for (vector::iterator iter = oneof_generators_.begin(); iter != oneof_generators_.end(); ++iter) { (*iter)->SetOneofIndexBase(sizeof_has_storage); } field_generators_.SetOneofIndexBase(sizeof_has_storage); - // Add an int32 for each oneof to store which is set. + // sizeof_has_storage needs enough bits for the single fields that aren't in + // any oneof, and then one int32 for each oneof (to store the field number). sizeof_has_storage += descriptor_->oneof_decl_count(); printer->Print( @@ -456,47 +453,26 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " static GPBDescriptor *descriptor = nil;\n" " if (!descriptor) {\n"); - bool has_oneofs = oneof_generators_.size(); - if (has_oneofs) { - printer->Print( - " static GPBMessageOneofDescription oneofs[] = {\n"); - printer->Indent(); - printer->Indent(); - printer->Indent(); - for (vector::iterator iter = oneof_generators_.begin(); - iter != oneof_generators_.end(); ++iter) { - (*iter)->GenerateDescription(printer); - } - printer->Outdent(); - printer->Outdent(); - printer->Outdent(); - printer->Print( - " };\n"); - } - TextFormatDecodeData text_format_decode_data; bool has_fields = descriptor_->field_count() > 0; + bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault(); + string field_description_type; + if (need_defaults) { + field_description_type = "GPBMessageFieldDescriptionWithDefault"; + } else { + field_description_type = "GPBMessageFieldDescription"; + } if (has_fields) { - // TODO(thomasvl): The plugin's FieldGenerator::GenerateFieldDescription() - // wraps the fieldOptions's value of this structure in an CPP gate so - // they can be compiled away; but that still results in a const char* in - // the structure for a NULL pointer for every message field. If the - // fieldOptions are moved to a separate payload like the TextFormat extra - // data is, then it would shrink that static data shrinking the binaries - // a little more. - // TODO(thomasvl): proto3 syntax doens't need a defaultValue in the - // structure because primitive types are always zero. If we add a second - // structure and a different initializer, we can avoid the wasted static - // storage for every field in a proto3 message. printer->Print( - " static GPBMessageFieldDescription fields[] = {\n"); + " static $field_description_type$ fields[] = {\n", + "field_description_type", field_description_type); printer->Indent(); printer->Indent(); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); ++i) { const FieldGenerator& field_generator = field_generators_.get(sorted_fields[i]); - field_generator.GenerateFieldDescription(printer); + field_generator.GenerateFieldDescription(printer, need_defaults); if (field_generator.needs_textformat_name_support()) { text_format_decode_data.AddString(sorted_fields[i]->number(), field_generator.generated_objc_name(), @@ -510,111 +486,89 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " };\n"); } - bool has_enums = enum_generators_.size(); - if (has_enums) { + map vars; + vars["classname"] = class_name_; + vars["rootclassname"] = root_classname_; + vars["fields"] = has_fields ? "fields" : "NULL"; + if (has_fields) { + vars["fields_count"] = + "(uint32_t)(sizeof(fields) / sizeof(" + field_description_type + "))"; + } else { + vars["fields_count"] = "0"; + } + + std::vector init_flags; + if (need_defaults) { + init_flags.push_back("GPBDescriptorInitializationFlag_FieldsWithDefault"); + } + if (descriptor_->options().message_set_wire_format()) { + init_flags.push_back("GPBDescriptorInitializationFlag_WireFormat"); + } + vars["init_flags"] = BuildFlagsString(init_flags); + + printer->Print( + vars, + " GPBDescriptor *localDescriptor =\n" + " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n" + " rootClass:[$rootclassname$ class]\n" + " file:$rootclassname$_FileDescriptor()\n" + " fields:$fields$\n" + " fieldCount:$fields_count$\n" + " storageSize:sizeof($classname$__storage_)\n" + " flags:$init_flags$];\n"); + if (oneof_generators_.size() != 0) { printer->Print( - " static GPBMessageEnumDescription enums[] = {\n"); - printer->Indent(); - printer->Indent(); - printer->Indent(); - for (vector::iterator iter = enum_generators_.begin(); - iter != enum_generators_.end(); ++iter) { - printer->Print("{ .enumDescriptorFunc = $name$_EnumDescriptor },\n", - "name", (*iter)->name()); + " static const char *oneofs[] = {\n"); + for (vector::iterator iter = oneof_generators_.begin(); + iter != oneof_generators_.end(); ++iter) { + printer->Print( + " \"$name$\",\n", + "name", (*iter)->DescriptorName()); } - printer->Outdent(); - printer->Outdent(); - printer->Outdent(); printer->Print( - " };\n"); + " };\n" + " [localDescriptor setupOneofs:oneofs\n" + " count:(uint32_t)(sizeof(oneofs) / sizeof(char*))\n" + " firstHasIndex:$first_has_index$];\n", + "first_has_index", oneof_generators_[0]->HasIndexAsString()); } - - bool has_extensions = sorted_extensions.size(); - if (has_extensions) { + if (text_format_decode_data.num_entries() != 0) { + const string text_format_data_str(text_format_decode_data.Data()); printer->Print( - " static GPBExtensionRange ranges[] = {\n"); - printer->Indent(); - printer->Indent(); - printer->Indent(); - for (int i = 0; i < sorted_extensions.size(); i++) { - printer->Print("{ .start = $start$, .end = $end$ },\n", - "start", SimpleItoa(sorted_extensions[i]->start), - "end", SimpleItoa(sorted_extensions[i]->end)); + "#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n" + " static const char *extraTextFormatInfo ="); + static const int kBytesPerLine = 40; // allow for escaping + for (int i = 0; i < text_format_data_str.size(); i += kBytesPerLine) { + printer->Print( + "\n \"$data$\"", + "data", EscapeTrigraphs( + CEscape(text_format_data_str.substr(i, kBytesPerLine)))); } - printer->Outdent(); - printer->Outdent(); - printer->Outdent(); printer->Print( - " };\n"); + ";\n" + " [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\n" + "#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n"); } - - map vars; - vars["classname"] = class_name_; - vars["rootclassname"] = root_classname_; - vars["fields"] = has_fields ? "fields" : "NULL"; - vars["fields_count"] = - has_fields ? "sizeof(fields) / sizeof(GPBMessageFieldDescription)" : "0"; - vars["oneofs"] = has_oneofs ? "oneofs" : "NULL"; - vars["oneof_count"] = - has_oneofs ? "sizeof(oneofs) / sizeof(GPBMessageOneofDescription)" : "0"; - vars["enums"] = has_enums ? "enums" : "NULL"; - vars["enum_count"] = - has_enums ? "sizeof(enums) / sizeof(GPBMessageEnumDescription)" : "0"; - vars["ranges"] = has_extensions ? "ranges" : "NULL"; - vars["range_count"] = - has_extensions ? "sizeof(ranges) / sizeof(GPBExtensionRange)" : "0"; - vars["wireformat"] = - descriptor_->options().message_set_wire_format() ? "YES" : "NO"; - - if (text_format_decode_data.num_entries() == 0) { + if (sorted_extensions.size() != 0) { printer->Print( - vars, - " GPBDescriptor *localDescriptor =\n" - " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n" - " rootClass:[$rootclassname$ class]\n" - " file:$rootclassname$_FileDescriptor()\n" - " fields:$fields$\n" - " fieldCount:$fields_count$\n" - " oneofs:$oneofs$\n" - " oneofCount:$oneof_count$\n" - " enums:$enums$\n" - " enumCount:$enum_count$\n" - " ranges:$ranges$\n" - " rangeCount:$range_count$\n" - " storageSize:sizeof($classname$__storage_)\n" - " wireFormat:$wireformat$];\n"); - } else { - vars["extraTextFormatInfo"] = CEscape(text_format_decode_data.Data()); - printer->Print( - vars, - "#if GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n" - " const char *extraTextFormatInfo = NULL;\n" - "#else\n" - " static const char *extraTextFormatInfo = \"$extraTextFormatInfo$\";\n" - "#endif // GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n" - " GPBDescriptor *localDescriptor =\n" - " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n" - " rootClass:[$rootclassname$ class]\n" - " file:$rootclassname$_FileDescriptor()\n" - " fields:$fields$\n" - " fieldCount:$fields_count$\n" - " oneofs:$oneofs$\n" - " oneofCount:$oneof_count$\n" - " enums:$enums$\n" - " enumCount:$enum_count$\n" - " ranges:$ranges$\n" - " rangeCount:$range_count$\n" - " storageSize:sizeof($classname$__storage_)\n" - " wireFormat:$wireformat$\n" - " extraTextFormatInfo:extraTextFormatInfo];\n"); + " static const GPBExtensionRange ranges[] = {\n"); + for (int i = 0; i < sorted_extensions.size(); i++) { + printer->Print(" { .start = $start$, .end = $end$ },\n", + "start", SimpleItoa(sorted_extensions[i]->start), + "end", SimpleItoa(sorted_extensions[i]->end)); } printer->Print( - " NSAssert(descriptor == nil, @\"Startup recursed!\");\n" - " descriptor = localDescriptor;\n" - " }\n" - " return descriptor;\n" - "}\n\n" - "@end\n\n"); + " };\n" + " [localDescriptor setupExtensionRanges:ranges\n" + " count:(uint32_t)(sizeof(ranges) / sizeof(GPBExtensionRange))];\n"); + } + printer->Print( + " NSAssert(descriptor == nil, @\"Startup recursed!\");\n" + " descriptor = localDescriptor;\n" + " }\n" + " return descriptor;\n" + "}\n\n" + "@end\n\n"); for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(descriptor_->field(i)) diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc index 24e6df07..44bafd7f 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc @@ -120,17 +120,16 @@ void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) { "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message) {\n" " GPBDescriptor *descriptor = [message descriptor];\n" " GPBOneofDescriptor *oneof = descriptor->oneofs_[$raw_index$];\n" - " GPBMaybeClearOneof(message, oneof, 0);\n" + " GPBMaybeClearOneof(message, oneof, $index$, 0);\n" "}\n"); } -void OneofGenerator::GenerateDescription(io::Printer* printer) { - printer->Print( - variables_, - "{\n" - " .name = \"$name$\",\n" - " .index = $index$,\n" - "},\n"); +string OneofGenerator::DescriptorName(void) const { + return variables_.find("name")->second; +} + +string OneofGenerator::HasIndexAsString(void) const { + return variables_.find("index")->second; } } // namespace objectivec diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h index bcba82da..3d9df4db 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h @@ -61,7 +61,9 @@ class OneofGenerator { void GeneratePropertyImplementation(io::Printer* printer); void GenerateClearFunctionImplementation(io::Printer* printer); - void GenerateDescription(io::Printer* printer); + + string DescriptorName(void) const; + string HasIndexAsString(void) const; private: const OneofDescriptor* descriptor_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc index ea7f1b91..d49350f4 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc @@ -134,6 +134,32 @@ PrimitiveFieldGenerator::PrimitiveFieldGenerator( PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {} +void PrimitiveFieldGenerator::GenerateFieldStorageDeclaration( + io::Printer* printer) const { + if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) { + // Nothing, BOOLs are stored in the has bits. + } else { + SingleFieldGenerator::GenerateFieldStorageDeclaration(printer); + } +} + +int PrimitiveFieldGenerator::ExtraRuntimeHasBitsNeeded(void) const { + if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) { + // Reserve a bit for the storage of the boolean. + return 1; + } + return 0; +} + +void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) { + if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) { + // Set into the offset the has bit to use for the actual value. + variables_["storage_offset_value"] = SimpleItoa(has_base); + variables_["storage_offset_comment"] = + " // Stored in _has_storage_ to save space."; + } +} + PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator( const FieldDescriptor* descriptor, const Options& options) : ObjCObjFieldGenerator(descriptor, options) { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h index 87139afb..69bb1fdd 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h @@ -49,6 +49,11 @@ class PrimitiveFieldGenerator : public SingleFieldGenerator { const Options& options); virtual ~PrimitiveFieldGenerator(); + virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const; + + virtual int ExtraRuntimeHasBitsNeeded(void) const; + virtual void SetExtraRuntimeHasBitsBase(int index_base); + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); }; -- cgit v1.2.3 From 64dfb5f80a4c09ebf09d7f5c2bf0655c840e690b Mon Sep 17 00:00:00 2001 From: topillar Date: Tue, 22 Mar 2016 23:45:41 +0800 Subject: Update coded_stream.h fix warning treated as error prevents building on 64-bit windows. --- src/google/protobuf/io/coded_stream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index e3771003..c81a33ac 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -1136,7 +1136,7 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) { // this write won't cross the end, so we can skip the checks. uint8* target = buffer_; uint8* end = WriteVarint32ToArray(value, target); - int size = end - target; + int size = static_cast(end - target); Advance(size); } else { WriteVarint32SlowPath(value); -- cgit v1.2.3 From e164f1083fd08e61bbad9c79a37058f1aeca4086 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Tue, 29 Mar 2016 15:25:49 -0700 Subject: Use the T() instead of NULL for the default value. The template can be specialized on primitives, e.g. double, where converting NULL will trigger a warning. --- src/google/protobuf/stubs/statusor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h index ad848701..29f869ad 100644 --- a/src/google/protobuf/stubs/statusor.h +++ b/src/google/protobuf/stubs/statusor.h @@ -224,7 +224,7 @@ inline StatusOr& StatusOr::operator=(const StatusOr& other) { template template inline StatusOr::StatusOr(const StatusOr& other) - : status_(other.status_), value_(other.status_.ok() ? other.value_ : NULL) { + : status_(other.status_), value_(other.status_.ok() ? other.value_ : T()) { } template -- cgit v1.2.3