From e41a2d7ba0b66898c627b6a35bb3dff19ff26cf9 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 11 Jan 2023 21:25:34 -0800 Subject: [PATCH] upb is self-hosting! This CL changes the upb compiler to no longer depend on C++ protobuf libraries. upb now uses its own reflection libraries to implement its code generator. # Key Benefits 1. upb can now use its own reflection libraries throughout the compiler. This makes upb more consistent and principled, and gives us more chances to dogfood our own C++ reflection API. This highlighted several parts of the C++ reflection API that were incomplete. 2. This CL removes code duplication that previously existed in the compiler. The upb reflection library has code to build MiniDescriptors and MiniTables out of descriptors, but prior to this CL the upb compiler could not use it. The upb compiler had a separate copy of this logic, and the compiler's copy of this logic was especially tricky and hard to maintain. This CL removes the separate copy of that logic. 3. This CL (mostly) removes upb's dependency on the C++ protobuf library. We still depend on `protoc` (the binary), but the runtime and compiler no longer link against C++'s libraries. This opens up the possibility of speeding up some builds significantly if we can use a prebuilt `protoc` binary. # Bootstrap Stages To bootstrap, we check in a copy of our generated code for `descriptor.proto` and `plugin.proto`. This allows the compiler to depend on the generated code for these two protos without creating a circular dependency. This code is checked in to the `stage0` directory. The bootstrapping process is divided into a few stages. All `cc_library()`, `upb_proto_library()`, and `cc_binary()` targets that would otherwise be circular participate in this staging process. That currently includes: * `//third_party/upb:descriptor_upb_proto` * `//third_party/upb:plugin_upb_proto` * `//third_party/upb:reflection` * `//third_party/upb:reflection_internal` * `//third_party/upbc:common` * `//third_party/upbc:file_layout` * `//third_party/upbc:plugin` * `//third_party/upbc:protoc-gen-upb` For each of these targets, we produce a rule for each stage (the logic for this is nicely encapsulated in Blaze/Bazel macros like `bootstrap_cc_library()` and `bootstrap_upb_proto_library()`, so the `BUILD` file remains readable). For example: * `//third_party/upb:descriptor_upb_proto_stage0` * `//third_party/upb:descriptor_upb_proto_stage1` * `//third_party/upb:descriptor_upb_proto` The stages are: 1. `stage0`: This uses the checked-in version of the generated code. The stage0 compiler is correct and outputs the same code as all other compilers, but it is unnecessarily slow because its protos were compiled in bootstrap mode. The stage0 compiler is used to generate protos for stage1. 2. `stage1`: The stage1 compiler is correct and fast, and therefore we use it in almost all cases (eg. `upb_proto_library()`). However its own protos were not generated using `upb_proto_library()`, so its `cc_library()` targets cannot be safely mixed with `upb_proto_library()`, as this would lead to duplicate symbols. 3. final (no stage): The final compiler is identical to the `stage1` compiler. The only difference is that its protos were built with `upb_proto_library()`. This doesn't matter very much for the compiler binary, but for the `cc_library()` targets like `//third_party/upb:reflection`, only the final targets can be safely linked in by other applications. # "Bootstrap Mode" Protos The checked-in generated code is generated in a special "bootstrap" mode that is a bit different than normal generated code. Bootstrap mode avoids depending on the internal representation of MiniTables or the messages, at the cost of slower runtime performance. Bootstrap mode only interacts with MiniTables and messages using public APIs such as `upb_MiniTable_Build()`, `upb_Message_GetInt32()`, etc. This is very important as it allows us to change the internal representation without needing to regenerate our bootstrap protos. This will make it far easier to write CLs that change the internal representation, because it avoids the awkward dance of trying to regenerate the bootstrap protos when the compiler itself is broken due to bootstrap protos being out of date. The bootstrap generated code does have two downsides: 1. The accessors are less efficient, because they look up MiniTable fields by number instead of hard-coding the MiniTableField into the generated code. 2. It requires runtime initialization of the MiniTables, which costs CPU cycles at startup, and also allocates memory which is never freed. Per google3 rules this is not really a leak, since this memory is still reachable via static variables, but it is undesirable in many contexts. We could fix this part by introducing the equivalent of `google::protobuf::ShutdownProtobufLibrary()`). These downsides are fine for the bootstrapping process, but they are reason enough not to enable bootstrap mode in general for all protos. # Bootstrapping Always Uses OSS Protos To enable smooth syncing between Google3 and OSS, we always use an OSS version of the checked in generated code for `stage0`, even in google3. This requires that the google3 code can be switched to reference the OSS proto names using a preprocessor define. We introduce the `UPB_DESC(xyz)` macro for this, which will expand into either `proto2_xyz` or `google_protobuf_xyz`. Any libraries used in `stage0` must use `UPB_DESC(xyz)` rather than refer to the symbol names directly. PiperOrigin-RevId: 501458451 --- BUILD | 24 +- bazel/protobuf.patch | 16 + bazel/upb_proto_library.bzl | 2 +- cmake/build_defs.bzl | 5 +- cmake/make_cmakelists.py | 6 + protos_generator/gen_accessors.cc | 36 +- protos_generator/gen_accessors.h | 4 +- protos_generator/gen_messages.cc | 5 +- protos_generator/gen_utils.cc | 78 + protos_generator/gen_utils.h | 9 + protos_generator/protoc-gen-upb-protos.cc | 41 +- upb/message/test.cc | 1 + upb/port/def.inc | 4 +- upb/port/undef.inc | 2 + upb/reflection/common.h | 10 + upb/reflection/def.hpp | 219 +- upb/reflection/def_builder_internal.h | 1 + upb/reflection/def_pool.c | 9 + upb/reflection/def_pool_internal.h | 2 + upb/reflection/message_def.c | 4 +- .../stage0/google/protobuf/descriptor.upb.c | 397 ++ .../stage0/google/protobuf/descriptor.upb.h | 4683 +++++++++++++++++ upbc/BUILD | 102 +- upbc/bootstrap_compiler.bzl | 166 + upbc/common.cc | 30 +- upbc/common.h | 46 +- upbc/file_layout.cc | 373 +- upbc/file_layout.h | 196 +- upbc/names.cc | 33 + upbc/names.h | 12 + upbc/plugin.h | 198 + upbc/protoc-gen-upb.cc | 1041 ++-- upbc/protoc-gen-upbdefs.cc | 132 +- .../google/protobuf/compiler/plugin.upb.c | 68 + .../google/protobuf/compiler/plugin.upb.h | 585 ++ 35 files changed, 7428 insertions(+), 1112 deletions(-) create mode 100644 upb/reflection/stage0/google/protobuf/descriptor.upb.c create mode 100644 upb/reflection/stage0/google/protobuf/descriptor.upb.h create mode 100644 upbc/bootstrap_compiler.bzl create mode 100644 upbc/plugin.h create mode 100644 upbc/stage0/google/protobuf/compiler/plugin.upb.c create mode 100644 upbc/stage0/google/protobuf/compiler/plugin.upb.h diff --git a/BUILD b/BUILD index c2b4103684..55a5fce5cd 100644 --- a/BUILD +++ b/BUILD @@ -36,6 +36,11 @@ load( "upb_proto_reflection_library", ) load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") +load( + "//upbc:bootstrap_compiler.bzl", + "bootstrap_cc_library", + "bootstrap_upb_proto_library", +) # begin:google_only # load( @@ -415,14 +420,21 @@ cc_library( ":base", ":descriptor_upb_proto", ":hash", + ":mini_table_internal", ":reflection_internal", ], ) -upb_proto_library( +bootstrap_upb_proto_library( name = "descriptor_upb_proto", + base_dir = "upb/reflection/", + google3_src_files = ["net/proto2/proto/descriptor.proto"], + google3_src_rules = ["//net/proto2/proto:descriptor_proto_source"], + oss_src_files = ["google/protobuf/descriptor.proto"], + oss_src_rules = ["@com_google_protobuf//:descriptor_proto_srcs"], + oss_strip_prefix = "third_party/protobuf/github/bootstrap/src", + proto_lib_deps = ["@com_google_protobuf//:descriptor_proto"], visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:descriptor_proto"], ) upb_proto_reflection_library( @@ -476,7 +488,7 @@ cc_library( # TODO(b/232091617): Once we can delete the deprecated forwarding headers # (= everything in upb/) we can move this build target down into reflection/ -cc_library( +bootstrap_cc_library( name = "reflection", hdrs = [ "upb/def.h", @@ -488,17 +500,17 @@ cc_library( "upb/reflection/message.h", "upb/reflection/message.hpp", ], + bootstrap_deps = [":reflection_internal"], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ ":collections", ":port", - ":reflection_internal", ":upb", ], ) -cc_library( +bootstrap_cc_library( name = "reflection_internal", srcs = [ "upb/reflection/def_builder.c", @@ -552,11 +564,11 @@ cc_library( "upb/reflection/service_def.h", "upb/reflection/service_def_internal.h", ], + bootstrap_deps = [":descriptor_upb_proto"], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ ":collections", - ":descriptor_upb_proto", ":hash", ":message_accessors", ":mini_table_internal", diff --git a/bazel/protobuf.patch b/bazel/protobuf.patch index f92bde95ca..895414d438 100644 --- a/bazel/protobuf.patch +++ b/bazel/protobuf.patch @@ -1,3 +1,19 @@ +--- src/google/protobuf/compiler/BUILD.bazel ++++ src/google/protobuf/compiler/BUILD.bazel +@@ -169,6 +169,12 @@ filegroup( + ], + ) + ++filegroup( ++ name = "plugin_proto_src", ++ srcs = ["plugin.proto"], ++ visibility = ["@upb//:__subpackages__"], ++) ++ + exports_files( + srcs = ["plugin.proto"], + visibility = ["//:__pkg__"], + --- python/google/protobuf/internal/test_util.py +++ python/google/protobuf/internal/test_util.py @@ -39,6 +39,7 @@ __author__ = 'robinson@google.com (Will Robinson)' diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl index 73045b11cb..f59fdd04a7 100644 --- a/bazel/upb_proto_library.bzl +++ b/bazel/upb_proto_library.bzl @@ -320,7 +320,7 @@ upb_proto_library_aspect = aspect( "_gen_upb": attr.label( executable = True, cfg = "exec", - default = "//upbc:protoc-gen-upb", + default = "//upbc:protoc-gen-upb_stage1", ), "_protoc": attr.label( executable = True, diff --git a/cmake/build_defs.bzl b/cmake/build_defs.bzl index eddeaf0d32..084a34f048 100644 --- a/cmake/build_defs.bzl +++ b/cmake/build_defs.bzl @@ -25,7 +25,7 @@ """Bazel support functions related to CMake support.""" -def staleness_test(name, outs, generated_pattern, **kwargs): +def staleness_test(name, outs, generated_pattern, target_files = None, **kwargs): """Tests that checked-in file(s) match the contents of generated file(s). The resulting test will verify that all output files exist and have the @@ -38,6 +38,9 @@ def staleness_test(name, outs, generated_pattern, **kwargs): generated_pattern: the pattern for transforming each "out" file into a generated file. For example, if generated_pattern="generated/%s" then a file foo.txt will look for generated file generated/foo.txt. + target_files: A glob representing all of the files that should be + covered by this rule. Files in this glob but not generated will + be deleted. (Not currently implemented in OSS). **kwargs: Additional keyword arguments to pass through to py_test(). """ diff --git a/cmake/make_cmakelists.py b/cmake/make_cmakelists.py index 6d2c374ee1..7de97e450b 100755 --- a/cmake/make_cmakelists.py +++ b/cmake/make_cmakelists.py @@ -200,6 +200,12 @@ class BuildFileFunctions(object): def bool_flag(self, **kwargs): pass + def bootstrap_upb_proto_library(self, **kwargs): + pass + + def bootstrap_cc_library(self, **kwargs): + pass + class WorkspaceFileFunctions(object): def __init__(self, converter): diff --git a/protos_generator/gen_accessors.cc b/protos_generator/gen_accessors.cc index 79a0574059..a6cfe5320e 100644 --- a/protos_generator/gen_accessors.cc +++ b/protos_generator/gen_accessors.cc @@ -31,7 +31,6 @@ #include "google/protobuf/descriptor.h" #include "protos_generator/gen_utils.h" #include "protos_generator/output.h" -#include "upbc/file_layout.h" #include "upbc/keywords.h" #include "upbc/names.h" @@ -39,7 +38,6 @@ namespace protos_generator { namespace protobuf = ::google::protobuf; -using FileLayout = ::upbc::FileLayout; using NameToFieldDescriptorMap = absl::flat_hash_map; @@ -47,12 +45,12 @@ void WriteFieldAccessorHazzer(const protobuf::Descriptor* desc, const protobuf::FieldDescriptor* field, const absl::string_view resolved_field_name, const absl::string_view resolved_upbc_name, - const FileLayout& layout, Output& output); + Output& output); void WriteFieldAccessorClear(const protobuf::Descriptor* desc, const protobuf::FieldDescriptor* field, const absl::string_view resolved_field_name, const absl::string_view resolved_upbc_name, - const FileLayout& layout, Output& output); + Output& output); void WriteMapFieldAccessors(const protobuf::Descriptor* desc, const protobuf::FieldDescriptor* field, const absl::string_view resolved_field_name, @@ -99,22 +97,20 @@ NameToFieldDescriptorMap CreateFieldNameMap( void WriteFieldAccessorsInHeader(const protobuf::Descriptor* desc, Output& output) { - FileLayout layout(desc->file()); - // Generate const methods. OutputIndenter i(output); auto field_names = CreateFieldNameMap(desc); auto upbc_field_names = upbc::CreateFieldNameMap(desc); - for (auto field : ::upbc::FieldNumberOrder(desc)) { + for (const auto* field : FieldNumberOrder(desc)) { std::string resolved_field_name = ResolveFieldName(field, field_names); std::string resolved_upbc_name = upbc::ResolveFieldName(field, upbc_field_names); WriteFieldAccessorHazzer(desc, field, resolved_field_name, - resolved_upbc_name, layout, output); + resolved_upbc_name, output); WriteFieldAccessorClear(desc, field, resolved_field_name, - resolved_upbc_name, layout, output); + resolved_upbc_name, output); if (field->is_map()) { WriteMapFieldAccessors(desc, field, resolved_field_name, @@ -188,9 +184,9 @@ void WriteFieldAccessorHazzer(const protobuf::Descriptor* desc, const protobuf::FieldDescriptor* field, const absl::string_view resolved_field_name, const absl::string_view resolved_upbc_name, - const FileLayout& layout, Output& output) { + Output& output) { // Generate hazzer (if any). - if (layout.HasHasbit(field) || field->real_containing_oneof()) { + if (field->has_presence()) { // Has presence. output("inline bool has_$0() const { return $1_has_$2(msg_); }\n", resolved_field_name, MessageName(desc), resolved_upbc_name); @@ -201,8 +197,8 @@ void WriteFieldAccessorClear(const protobuf::Descriptor* desc, const protobuf::FieldDescriptor* field, const absl::string_view resolved_field_name, const absl::string_view resolved_upbc_name, - const FileLayout& layout, Output& output) { - if (layout.HasHasbit(field) || field->real_containing_oneof()) { + Output& output) { + if (field->has_presence()) { output("void clear_$0() { $2_clear_$1(msg_); }\n", resolved_field_name, resolved_upbc_name, MessageName(desc)); } @@ -245,8 +241,7 @@ void WriteMapFieldAccessors(const protobuf::Descriptor* desc, } } -void WriteAccessorsInSource(const protobuf::Descriptor* desc, - const FileLayout& layout, Output& output) { +void WriteAccessorsInSource(const protobuf::Descriptor* desc, Output& output) { std::string class_name = ClassName(desc); absl::StrAppend(&class_name, "Access"); output("namespace internal {\n"); @@ -256,7 +251,7 @@ void WriteAccessorsInSource(const protobuf::Descriptor* desc, // Generate const methods. OutputIndenter i(output); - for (auto field : ::upbc::FieldNumberOrder(desc)) { + for (const auto* field : FieldNumberOrder(desc)) { std::string resolved_field_name = ResolveFieldName(field, field_names); std::string resolved_upbc_name = upbc::ResolveFieldName(field, upbc_field_names); @@ -601,7 +596,6 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, void WriteUsingAccessorsInHeader(const protobuf::Descriptor* desc, MessageClassType handle_type, Output& output) { - FileLayout layout(desc->file()); bool read_only = handle_type == MessageClassType::kMessageCProxy; // Generate const methods. @@ -609,15 +603,11 @@ void WriteUsingAccessorsInHeader(const protobuf::Descriptor* desc, std::string class_name = ClassName(desc); auto field_names = CreateFieldNameMap(desc); - for (auto field : ::upbc::FieldNumberOrder(desc)) { + for (const auto* field : FieldNumberOrder(desc)) { std::string resolved_field_name = ResolveFieldName(field, field_names); // Generate hazzer (if any). - if (layout.HasHasbit(field) || field->real_containing_oneof()) { - // Has presence. + if (field->has_presence()) { output("using $0Access::has_$1;\n", class_name, resolved_field_name); - } - // Generate clear. - if (layout.HasHasbit(field) || field->real_containing_oneof()) { output("using $0Access::clear_$1;\n", class_name, resolved_field_name); } if (field->is_map()) { diff --git a/protos_generator/gen_accessors.h b/protos_generator/gen_accessors.h index 90da017db3..070cb886d8 100644 --- a/protos_generator/gen_accessors.h +++ b/protos_generator/gen_accessors.h @@ -29,7 +29,6 @@ #include "google/protobuf/descriptor.h" #include "protos_generator/gen_utils.h" #include "protos_generator/output.h" -#include "upbc/file_layout.h" namespace protos_generator { @@ -37,8 +36,7 @@ namespace protobuf = ::google::protobuf; void WriteFieldAccessorsInHeader(const protobuf::Descriptor* desc, Output& output); -void WriteAccessorsInSource(const protobuf::Descriptor* desc, - const ::upbc::FileLayout& layout, Output& output); +void WriteAccessorsInSource(const protobuf::Descriptor* desc, Output& output); void WriteUsingAccessorsInHeader(const protobuf::Descriptor* desc, MessageClassType handle_type, Output& output); } // namespace protos_generator diff --git a/protos_generator/gen_messages.cc b/protos_generator/gen_messages.cc index 7433ba5050..194fab0a15 100644 --- a/protos_generator/gen_messages.cc +++ b/protos_generator/gen_messages.cc @@ -313,11 +313,10 @@ void WriteMessageImplementation( R"cc( const upb_MiniTable* $0::minitable() { return &$1; } )cc", - ClassName(descriptor), ::upbc::MessageInit(descriptor)); + ClassName(descriptor), ::upbc::MessageInit(descriptor->full_name())); } - ::upbc::FileLayout layout(descriptor->file()); - WriteAccessorsInSource(descriptor, layout, output); + WriteAccessorsInSource(descriptor, output); if (!message_is_map_entry) { output( diff --git a/protos_generator/gen_utils.cc b/protos_generator/gen_utils.cc index 25297aafee..476924c2c5 100644 --- a/protos_generator/gen_utils.cc +++ b/protos_generator/gen_utils.cc @@ -207,4 +207,82 @@ std::string MessageProxyType(const protobuf::FieldDescriptor* field, "Proxy"; } +void AddEnums(const protobuf::Descriptor* message, + std::vector* enums) { + enums->reserve(enums->size() + message->enum_type_count()); + for (int i = 0; i < message->enum_type_count(); i++) { + enums->push_back(message->enum_type(i)); + } + for (int i = 0; i < message->nested_type_count(); i++) { + AddEnums(message->nested_type(i), enums); + } +} + +std::vector SortedEnums( + const protobuf::FileDescriptor* file) { + std::vector enums; + enums.reserve(file->enum_type_count()); + for (int i = 0; i < file->enum_type_count(); i++) { + enums.push_back(file->enum_type(i)); + } + for (int i = 0; i < file->message_type_count(); i++) { + AddEnums(file->message_type(i), &enums); + } + return enums; +} + +void AddMessages(const protobuf::Descriptor* message, + std::vector* messages) { + messages->push_back(message); + for (int i = 0; i < message->nested_type_count(); i++) { + AddMessages(message->nested_type(i), messages); + } +} + +std::vector SortedMessages( + const protobuf::FileDescriptor* file) { + std::vector messages; + for (int i = 0; i < file->message_type_count(); i++) { + AddMessages(file->message_type(i), &messages); + } + return messages; +} + +void AddExtensionsFromMessage( + const protobuf::Descriptor* message, + std::vector* exts) { + for (int i = 0; i < message->extension_count(); i++) { + exts->push_back(message->extension(i)); + } + for (int i = 0; i < message->nested_type_count(); i++) { + AddExtensionsFromMessage(message->nested_type(i), exts); + } +} + +std::vector SortedExtensions( + const protobuf::FileDescriptor* file) { + std::vector ret; + for (int i = 0; i < file->extension_count(); i++) { + ret.push_back(file->extension(i)); + } + for (int i = 0; i < file->message_type_count(); i++) { + AddExtensionsFromMessage(file->message_type(i), &ret); + } + return ret; +} + +std::vector FieldNumberOrder( + const protobuf::Descriptor* message) { + std::vector fields; + for (int i = 0; i < message->field_count(); i++) { + fields.push_back(message->field(i)); + } + std::sort(fields.begin(), fields.end(), + [](const protobuf::FieldDescriptor* a, + const protobuf::FieldDescriptor* b) { + return a->number() < b->number(); + }); + return fields; +} + } // namespace protos_generator diff --git a/protos_generator/gen_utils.h b/protos_generator/gen_utils.h index 045777812c..5563f9f26a 100644 --- a/protos_generator/gen_utils.h +++ b/protos_generator/gen_utils.h @@ -77,6 +77,15 @@ std::string MessageCProxyType(const protobuf::FieldDescriptor* field, std::string MessageProxyType(const protobuf::FieldDescriptor* field, bool is_const); +std::vector SortedEnums( + const protobuf::FileDescriptor* file); +std::vector SortedMessages( + const protobuf::FileDescriptor* file); +std::vector SortedExtensions( + const protobuf::FileDescriptor* file); +std::vector FieldNumberOrder( + const protobuf::Descriptor* message); + inline constexpr absl::string_view kNoPackageNamePrefix = "protos_"; } // namespace protos_generator diff --git a/protos_generator/protoc-gen-upb-protos.cc b/protos_generator/protoc-gen-upb-protos.cc index 12de664956..2e5fbd4a2e 100644 --- a/protos_generator/protoc-gen-upb-protos.cc +++ b/protos_generator/protoc-gen-upb-protos.cc @@ -28,6 +28,7 @@ #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/plugin.h" +#include "google/protobuf/descriptor.h" #include "protos_generator/gen_enums.h" #include "protos_generator/gen_extensions.h" #include "protos_generator/gen_messages.h" @@ -41,12 +42,12 @@ namespace { namespace protoc = ::google::protobuf::compiler; namespace protobuf = ::google::protobuf; using FileDescriptor = ::google::protobuf::FileDescriptor; -using FileLayout = ::upbc::FileLayout; -void WriteSource(const FileLayout& layout, Output& output, +void WriteSource(const protobuf::FileDescriptor* file, Output& output, bool fasttable_enabled); -void WriteHeader(const FileLayout& layout, Output& output); -void WriteForwardingHeader(const FileLayout& layout, Output& output); +void WriteHeader(const protobuf::FileDescriptor* file, Output& output); +void WriteForwardingHeader(const protobuf::FileDescriptor* file, + Output& output); void WriteMessageImplementations(const protobuf::FileDescriptor* file, Output& output); void WriteTypedefForwardingHeader( @@ -87,26 +88,24 @@ bool Generator::Generate(const protobuf::FileDescriptor* file, } } - FileLayout layout(file); - // Write model.upb.fwd.h Output forwarding_header_output( context->Open(ForwardingHeaderFilename(file))); - WriteForwardingHeader(layout, forwarding_header_output); + WriteForwardingHeader(file, forwarding_header_output); // Write model.upb.proto.h Output header_output(context->Open(CppHeaderFilename(file))); - WriteHeader(layout, header_output); + WriteHeader(file, header_output); // Write model.upb.proto.cc Output cc_output(context->Open(CppSourceFilename(file))); - WriteSource(layout, cc_output, fasttable_enabled); + WriteSource(file, cc_output, fasttable_enabled); return true; } // The forwarding header defines Access/Proxy/CProxy for message classes // used to include when referencing dependencies to prevent transitive // dependency headers from being included. -void WriteForwardingHeader(const FileLayout& layout, Output& output) { - const protobuf::FileDescriptor* file = layout.descriptor(); +void WriteForwardingHeader(const protobuf::FileDescriptor* file, + Output& output) { EmitFileWarning(file, output); output( R"cc( @@ -116,13 +115,12 @@ void WriteForwardingHeader(const FileLayout& layout, Output& output) { ToPreproc(file->name())); output("\n"); const std::vector this_file_messages = - ::upbc::SortedMessages(file); + SortedMessages(file); WriteTypedefForwardingHeader(file, this_file_messages, output); output("#endif /* $0_UPB_FWD_H_ */\n", ToPreproc(file->name())); } -void WriteHeader(const FileLayout& layout, Output& output) { - const protobuf::FileDescriptor* file = layout.descriptor(); +void WriteHeader(const protobuf::FileDescriptor* file, Output& output) { EmitFileWarning(file, output); output( R"cc( @@ -153,9 +151,9 @@ void WriteHeader(const FileLayout& layout, Output& output) { output("#include \"upb/port/def.inc\"\n"); const std::vector this_file_messages = - ::upbc::SortedMessages(file); + SortedMessages(file); const std::vector this_file_exts = - ::upbc::SortedExtensions(file); + SortedExtensions(file); if (!this_file_messages.empty()) { output("\n"); @@ -166,7 +164,7 @@ void WriteHeader(const FileLayout& layout, Output& output) { WriteStartNamespace(file, output); std::vector this_file_enums = - ::upbc::SortedEnums(file); + SortedEnums(file); // Write Class and Enums. WriteEnumDeclarations(this_file_enums, output); @@ -189,9 +187,8 @@ void WriteHeader(const FileLayout& layout, Output& output) { } // Writes a .upb.cc source file. -void WriteSource(const FileLayout& layout, Output& output, +void WriteSource(const protobuf::FileDescriptor* file, Output& output, bool fasttable_enabled) { - const protobuf::FileDescriptor* file = layout.descriptor(); EmitFileWarning(file, output); output( @@ -212,7 +209,7 @@ void WriteSource(const FileLayout& layout, Output& output, WriteStartNamespace(file, output); WriteMessageImplementations(file, output); const std::vector this_file_exts = - ::upbc::SortedExtensions(file); + SortedExtensions(file); WriteExtensionIdentifiers(this_file_exts, output); WriteEndNamespace(file, output); @@ -222,9 +219,9 @@ void WriteSource(const FileLayout& layout, Output& output, void WriteMessageImplementations(const protobuf::FileDescriptor* file, Output& output) { const std::vector file_exts = - ::upbc::SortedExtensions(file); + SortedExtensions(file); const std::vector this_file_messages = - ::upbc::SortedMessages(file); + SortedMessages(file); for (auto message : this_file_messages) { WriteMessageImplementation(message, file_exts, output); } diff --git a/upb/message/test.cc b/upb/message/test.cc index bd0e296778..0537a24ac7 100644 --- a/upb/message/test.cc +++ b/upb/message/test.cc @@ -271,6 +271,7 @@ TEST(MessageTest, Proto2Enum) { pb = upb_test_Proto2EnumMessage_serialize(enum_msg, arena.ptr(), &size); upb_test_Proto2FakeEnumMessage* fake_msg2 = upb_test_Proto2FakeEnumMessage_parse(pb, size, arena.ptr()); + ASSERT_TRUE(fake_msg2 != nullptr); EXPECT_EQ(true, upb_test_Proto2FakeEnumMessage_has_optional_enum(fake_msg2)); EXPECT_EQ(999, upb_test_Proto2FakeEnumMessage_optional_enum(fake_msg2)); diff --git a/upb/port/def.inc b/upb/port/def.inc index dfcbce6a5a..ae76afade4 100644 --- a/upb/port/def.inc +++ b/upb/port/def.inc @@ -246,8 +246,10 @@ * degrade to non-fasttable if the runtime or platform do not support it. */ #if !UPB_FASTTABLE #define UPB_FASTTABLE_INIT(...) +#define UPB_FASTTABLE_MASK(mask) -1 #else #define UPB_FASTTABLE_INIT(...) __VA_ARGS__ +#define UPB_FASTTABLE_MASK(mask) mask #endif #undef UPB_FASTTABLE_SUPPORTED @@ -307,7 +309,7 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size); // #define UPB_IS_GOOGLE3 // end:google_only -#if defined(UPB_IS_GOOGLE3) +#if defined(UPB_IS_GOOGLE3) && !defined(UPB_BOOTSTRAP_STAGE0) #define UPB_DESC(sym) proto2_##sym #else #define UPB_DESC(sym) google_protobuf_##sym diff --git a/upb/port/undef.inc b/upb/port/undef.inc index fd201e321c..a4782838ae 100644 --- a/upb/port/undef.inc +++ b/upb/port/undef.inc @@ -56,6 +56,7 @@ #undef UPB_PTRADD #undef UPB_MUSTTAIL #undef UPB_FASTTABLE_SUPPORTED +#undef UPB_FASTTABLE_MASK #undef UPB_FASTTABLE #undef UPB_FASTTABLE_INIT #undef UPB_POISON_MEMORY_REGION @@ -64,5 +65,6 @@ #undef UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 #undef UPB_DEPRECATED #undef UPB_GNUC_MIN +#undef UPB_DESCRIPTOR_UPB_H_FILENAME #undef UPB_DESC #undef UPB_IS_GOOGLE3 diff --git a/upb/reflection/common.h b/upb/reflection/common.h index 581ecff869..797fbb223e 100644 --- a/upb/reflection/common.h +++ b/upb/reflection/common.h @@ -32,7 +32,17 @@ #ifndef UPB_REFLECTION_COMMON_H_ #define UPB_REFLECTION_COMMON_H_ +// begin:google_only +// #ifndef UPB_BOOTSTRAP_STAGE0 +// #include "net/proto2/proto/descriptor.upb.h" +// #else +// #include "google/protobuf/descriptor.upb.h" +// #endif +// end:google_only + +// begin:github_only #include "google/protobuf/descriptor.upb.h" +// end:github_only typedef enum { kUpb_Syntax_Proto2 = 2, kUpb_Syntax_Proto3 = 3 } upb_Syntax; diff --git a/upb/reflection/def.hpp b/upb/reflection/def.hpp index 55dd3b9a85..1da809a3f4 100644 --- a/upb/reflection/def.hpp +++ b/upb/reflection/def.hpp @@ -32,9 +32,14 @@ #include #include "upb/reflection/def.h" +#include "upb/reflection/def_pool_internal.h" +#include "upb/reflection/enum_def_internal.h" #include "upb/reflection/message.h" #include "upb/upb.hpp" +// Must be last +#include "upb/port/def.inc" + namespace upb { typedef upb_MessageValue MessageValue; @@ -53,20 +58,31 @@ class FieldDefPtr { explicit FieldDefPtr(const upb_FieldDef* ptr) : ptr_(ptr) {} const upb_FieldDef* ptr() const { return ptr_; } - explicit operator bool() const { return ptr_ != nullptr; } - typedef upb_CType Type; + typedef upb_FieldType Type; + typedef upb_CType CType; typedef upb_Label Label; - typedef upb_FieldType DescriptorType; + FileDefPtr file() const; const char* full_name() const { return upb_FieldDef_FullName(ptr_); } - Type type() const { return upb_FieldDef_CType(ptr_); } + const upb_MiniTableField* mini_table() const { + return upb_FieldDef_MiniTable(ptr_); + } + + const UPB_DESC(FieldOptions) * options() const { + return upb_FieldDef_Options(ptr_); + } + + Type type() const { return upb_FieldDef_Type(ptr_); } + CType ctype() const { return upb_FieldDef_CType(ptr_); } Label label() const { return upb_FieldDef_Label(ptr_); } const char* name() const { return upb_FieldDef_Name(ptr_); } const char* json_name() const { return upb_FieldDef_JsonName(ptr_); } uint32_t number() const { return upb_FieldDef_Number(ptr_); } bool is_extension() const { return upb_FieldDef_IsExtension(ptr_); } + bool is_required() const { return upb_FieldDef_IsRequired(ptr_); } + bool has_presence() const { return upb_FieldDef_HasPresence(ptr_); } // For non-string, non-submessage fields, this indicates whether binary // protobufs are encoded in packed or non-packed format. @@ -81,26 +97,18 @@ class FieldDefPtr { // been finalized. uint32_t index() const { return upb_FieldDef_Index(ptr_); } - // The MessageDef to which this field belongs. - // - // If this field has been added to a MessageDef, that message can be retrieved - // directly (this is always the case for frozen FieldDefs). - // - // If the field has not yet been added to a MessageDef, you can set the name - // of the containing type symbolically instead. This is mostly useful for - // extensions, where the extension is declared separately from the message. + // The MessageDef to which this field belongs (for extensions, the extended + // message). MessageDefPtr containing_type() const; + // For extensions, the message the extension is declared inside, or NULL if + // none. + MessageDefPtr extension_scope() const; + // The OneofDef to which this field belongs, or NULL if this field is not part // of a oneof. OneofDefPtr containing_oneof() const; - - // The field's type according to the enum in descriptor.proto. This is not - // the same as UPB_TYPE_*, because it distinguishes between (for example) - // INT32 and SINT32, whereas our "type" enum does not. This return of - // descriptor_type() is a function of type(), integer_format(), and - // is_tag_delimited(). - DescriptorType descriptor_type() const { return upb_FieldDef_Type(ptr_); } + OneofDefPtr real_containing_oneof() const; // Convenient field type tests. bool IsSubMessage() const { return upb_FieldDef_IsSubMessage(ptr_); } @@ -115,7 +123,17 @@ class FieldDefPtr { // type must match (ie. you may only call enum_subdef() for fields where // type() == kUpb_CType_Enum). EnumDefPtr enum_subdef() const; - MessageDefPtr message_subdef() const; + MessageDefPtr message_type() const; + + explicit operator bool() const { return ptr_ != nullptr; } + + friend bool operator==(FieldDefPtr lhs, FieldDefPtr rhs) { + return lhs.ptr_ == rhs.ptr_; + } + + friend bool operator!=(FieldDefPtr lhs, FieldDefPtr rhs) { + return !(lhs == rhs); + } private: const upb_FieldDef* ptr_; @@ -130,11 +148,16 @@ class OneofDefPtr { const upb_OneofDef* ptr() const { return ptr_; } explicit operator bool() const { return ptr_ != nullptr; } + const UPB_DESC(OneofOptions) * options() const { + return upb_OneofDef_Options(ptr_); + } + // Returns the MessageDef that contains this OneofDef. MessageDefPtr containing_type() const; // Returns the name of this oneof. const char* name() const { return upb_OneofDef_Name(ptr_); } + const char* full_name() const { return upb_OneofDef_FullName(ptr_); } // Returns the number of fields in the oneof. int field_count() const { return upb_OneofDef_FieldCount(ptr_); } @@ -170,14 +193,28 @@ class MessageDefPtr { MessageDefPtr() : ptr_(nullptr) {} explicit MessageDefPtr(const upb_MessageDef* ptr) : ptr_(ptr) {} + const UPB_DESC(MessageOptions) * options() const { + return upb_MessageDef_Options(ptr_); + } + + std::string MiniDescriptorEncode() const { + upb::Arena arena; + upb_StringView md; + upb_MessageDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md); + return std::string(md.data, md.size); + } + const upb_MessageDef* ptr() const { return ptr_; } - explicit operator bool() const { return ptr_ != nullptr; } FileDefPtr file() const; const char* full_name() const { return upb_MessageDef_FullName(ptr_); } const char* name() const { return upb_MessageDef_Name(ptr_); } + const upb_MiniTable* mini_table() const { + return upb_MessageDef_MiniTable(ptr_); + } + // The number of fields that belong to the MessageDef. int field_count() const { return upb_MessageDef_FieldCount(ptr_); } FieldDefPtr field(int i) const { @@ -186,10 +223,32 @@ class MessageDefPtr { // The number of oneofs that belong to the MessageDef. int oneof_count() const { return upb_MessageDef_OneofCount(ptr_); } + int real_oneof_count() const { return upb_MessageDef_RealOneofCount(ptr_); } OneofDefPtr oneof(int i) const { return OneofDefPtr(upb_MessageDef_Oneof(ptr_, i)); } + int enum_type_count() const { return upb_MessageDef_NestedEnumCount(ptr_); } + EnumDefPtr enum_type(int i) const; + + int nested_message_count() const { + return upb_MessageDef_NestedMessageCount(ptr_); + } + MessageDefPtr nested_message(int i) const { + return MessageDefPtr(upb_MessageDef_NestedMessage(ptr_, i)); + } + + int nested_extension_count() const { + return upb_MessageDef_NestedExtensionCount(ptr_); + } + FieldDefPtr nested_extension(int i) const { + return FieldDefPtr(upb_MessageDef_NestedExtension(ptr_, i)); + } + + int extension_range_count() const { + return upb_MessageDef_ExtensionRangeCount(ptr_); + } + upb_Syntax syntax() const { return upb_MessageDef_Syntax(ptr_); } // These return null pointers if the field is not found. @@ -224,12 +283,32 @@ class MessageDefPtr { // Is this message a map entry? bool mapentry() const { return upb_MessageDef_IsMapEntry(ptr_); } + FieldDefPtr map_key() const { + if (!mapentry()) return FieldDefPtr(); + return FieldDefPtr(upb_MessageDef_Field(ptr_, 0)); + } + + FieldDefPtr map_value() const { + if (!mapentry()) return FieldDefPtr(); + return FieldDefPtr(upb_MessageDef_Field(ptr_, 1)); + } + // Return the type of well known type message. kUpb_WellKnown_Unspecified for // non-well-known message. upb_WellKnown wellknowntype() const { return upb_MessageDef_WellKnownType(ptr_); } + explicit operator bool() const { return ptr_ != nullptr; } + + friend bool operator==(MessageDefPtr lhs, MessageDefPtr rhs) { + return lhs.ptr_ == rhs.ptr_; + } + + friend bool operator!=(MessageDefPtr lhs, MessageDefPtr rhs) { + return !(lhs == rhs); + } + private: class FieldIter { public: @@ -296,6 +375,10 @@ class EnumValDefPtr { EnumValDefPtr() : ptr_(nullptr) {} explicit EnumValDefPtr(const upb_EnumValueDef* ptr) : ptr_(ptr) {} + const UPB_DESC(EnumValueOptions) * options() const { + return upb_EnumValueDef_Options(ptr_); + } + int32_t number() const { return upb_EnumValueDef_Number(ptr_); } const char* full_name() const { return upb_EnumValueDef_FullName(ptr_); } const char* name() const { return upb_EnumValueDef_Name(ptr_); } @@ -309,11 +392,27 @@ class EnumDefPtr { EnumDefPtr() : ptr_(nullptr) {} explicit EnumDefPtr(const upb_EnumDef* ptr) : ptr_(ptr) {} + const UPB_DESC(EnumOptions) * options() const { + return upb_EnumDef_Options(ptr_); + } + + const upb_MiniTableEnum* mini_table() const { + return _upb_EnumDef_MiniTable(ptr_); + } + + std::string MiniDescriptorEncode() const { + upb::Arena arena; + upb_StringView md; + upb_EnumDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md); + return std::string(md.data, md.size); + } + const upb_EnumDef* ptr() const { return ptr_; } explicit operator bool() const { return ptr_ != nullptr; } const char* full_name() const { return upb_EnumDef_FullName(ptr_); } const char* name() const { return upb_EnumDef_Name(ptr_); } + bool is_closed() const { return upb_EnumDef_IsClosed(ptr_); } // The value that is used as the default when no field default is specified. // If not set explicitly, the first value that was added will be used. @@ -325,6 +424,9 @@ class EnumDefPtr { // multiple names can refer to the same number, so this may be greater than // the total number of unique numbers. int value_count() const { return upb_EnumDef_ValueCount(ptr_); } + EnumValDefPtr value(int i) const { + return EnumValDefPtr(upb_EnumDef_Value(ptr_, i)); + } // Lookups from name to integer, returning true if found. EnumValDefPtr FindValueByName(const char* name) const { @@ -350,8 +452,11 @@ class FileDefPtr { public: explicit FileDefPtr(const upb_FileDef* ptr) : ptr_(ptr) {} + const UPB_DESC(FileOptions) * options() const { + return upb_FileDef_Options(ptr_); + } + const upb_FileDef* ptr() const { return ptr_; } - explicit operator bool() const { return ptr_ != nullptr; } // Get/set name of the file (eg. "foo/bar.proto"). const char* name() const { return upb_FileDef_Name(ptr_); } @@ -365,10 +470,48 @@ class FileDefPtr { // Get the list of dependencies from the file. These are returned in the // order that they were added to the FileDefPtr. int dependency_count() const { return upb_FileDef_DependencyCount(ptr_); } - const FileDefPtr dependency(int index) const { + FileDefPtr dependency(int index) const { return FileDefPtr(upb_FileDef_Dependency(ptr_, index)); } + int public_dependency_count() const { + return upb_FileDef_PublicDependencyCount(ptr_); + } + FileDefPtr public_dependency(int index) const { + return FileDefPtr(upb_FileDef_PublicDependency(ptr_, index)); + } + + int toplevel_enum_count() const { + return upb_FileDef_TopLevelEnumCount(ptr_); + } + EnumDefPtr toplevel_enum(int index) const { + return EnumDefPtr(upb_FileDef_TopLevelEnum(ptr_, index)); + } + + int toplevel_message_count() const { + return upb_FileDef_TopLevelMessageCount(ptr_); + } + MessageDefPtr toplevel_message(int index) const { + return MessageDefPtr(upb_FileDef_TopLevelMessage(ptr_, index)); + } + + int toplevel_extension_count() const { + return upb_FileDef_TopLevelExtensionCount(ptr_); + } + FieldDefPtr toplevel_extension(int index) const { + return FieldDefPtr(upb_FileDef_TopLevelExtension(ptr_, index)); + } + + explicit operator bool() const { return ptr_ != nullptr; } + + friend bool operator==(FileDefPtr lhs, FileDefPtr rhs) { + return lhs.ptr_ == rhs.ptr_; + } + + friend bool operator!=(FileDefPtr lhs, FileDefPtr rhs) { + return !(lhs == rhs); + } + private: const upb_FileDef* ptr_; }; @@ -396,10 +539,18 @@ class DefPool { return FileDefPtr(upb_DefPool_FindFileByName(ptr_.get(), name)); } + FieldDefPtr FindExtensionByName(const char* name) const { + return FieldDefPtr(upb_DefPool_FindExtensionByName(ptr_.get(), name)); + } + + void _SetPlatform(upb_MiniTablePlatform platform) { + _upb_DefPool_SetPlatform(ptr_.get(), platform); + } + // TODO: iteration? // Adds the given serialized FileDescriptorProto to the pool. - FileDefPtr AddFile(const google_protobuf_FileDescriptorProto* file_proto, + FileDefPtr AddFile(const UPB_DESC(FileDescriptorProto) * file_proto, Status* status) { return FileDefPtr( upb_DefPool_AddFile(ptr_.get(), file_proto, status->ptr())); @@ -412,11 +563,19 @@ class DefPool { // TODO(b/236632406): This typedef is deprecated. Delete it. using SymbolTable = DefPool; +inline FileDefPtr FieldDefPtr::file() const { + return FileDefPtr(upb_FieldDef_File(ptr_)); +} + inline FileDefPtr MessageDefPtr::file() const { return FileDefPtr(upb_MessageDef_File(ptr_)); } -inline MessageDefPtr FieldDefPtr::message_subdef() const { +inline EnumDefPtr MessageDefPtr::enum_type(int i) const { + return EnumDefPtr(upb_MessageDef_NestedEnum(ptr_, i)); +} + +inline MessageDefPtr FieldDefPtr::message_type() const { return MessageDefPtr(upb_FieldDef_MessageSubDef(ptr_)); } @@ -424,6 +583,10 @@ inline MessageDefPtr FieldDefPtr::containing_type() const { return MessageDefPtr(upb_FieldDef_ContainingType(ptr_)); } +inline MessageDefPtr FieldDefPtr::extension_scope() const { + return MessageDefPtr(upb_FieldDef_ExtensionScope(ptr_)); +} + inline MessageDefPtr OneofDefPtr::containing_type() const { return MessageDefPtr(upb_OneofDef_ContainingType(ptr_)); } @@ -432,10 +595,16 @@ inline OneofDefPtr FieldDefPtr::containing_oneof() const { return OneofDefPtr(upb_FieldDef_ContainingOneof(ptr_)); } +inline OneofDefPtr FieldDefPtr::real_containing_oneof() const { + return OneofDefPtr(upb_FieldDef_RealContainingOneof(ptr_)); +} + inline EnumDefPtr FieldDefPtr::enum_subdef() const { return EnumDefPtr(upb_FieldDef_EnumSubDef(ptr_)); } } // namespace upb +#include "upb/port/undef.inc" + #endif // UPB_REFLECTION_DEF_HPP_ diff --git a/upb/reflection/def_builder_internal.h b/upb/reflection/def_builder_internal.h index ad43135020..d8e2f950eb 100644 --- a/upb/reflection/def_builder_internal.h +++ b/upb/reflection/def_builder_internal.h @@ -61,6 +61,7 @@ struct upb_DefBuilder { upb_Arena* tmp_arena; // For temporary allocations. upb_Status* status; // Record errors here. const upb_MiniTableFile* layout; // NULL if we should build layouts. + upb_MiniTablePlatform platform; // Platform we are targeting. int enum_count; // Count of enums built so far. int msg_count; // Count of messages built so far. int ext_count; // Count of extensions built so far. diff --git a/upb/reflection/def_pool.c b/upb/reflection/def_pool.c index 3f88dc5cd5..dc521ff83b 100644 --- a/upb/reflection/def_pool.c +++ b/upb/reflection/def_pool.c @@ -46,6 +46,7 @@ struct upb_DefPool { upb_strtable files; // file_name -> (upb_FileDef*) upb_inttable exts; // (upb_MiniTableExtension*) -> (upb_FieldDef*) upb_ExtensionRegistry* extreg; + upb_MiniTablePlatform platform; void* scratch_data; size_t scratch_size; size_t bytes_loaded; @@ -75,6 +76,8 @@ upb_DefPool* upb_DefPool_New(void) { s->extreg = upb_ExtensionRegistry_New(s->arena); if (!s->extreg) goto err; + s->platform = kUpb_MiniTablePlatform_Native; + return s; err: @@ -128,6 +131,11 @@ size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s) { return (size_t*)&s->scratch_size; } +void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform) { + assert(upb_strtable_count(&s->files) == 0); + s->platform = platform; +} + const upb_MessageDef* upb_DefPool_FindMessageByName(const upb_DefPool* s, const char* sym) { return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_MSG); @@ -305,6 +313,7 @@ static const upb_FileDef* _upb_DefPool_AddFile( upb_DefBuilder ctx = { .symtab = s, .layout = layout, + .platform = s->platform, .msg_count = 0, .enum_count = 0, .ext_count = 0, diff --git a/upb/reflection/def_pool_internal.h b/upb/reflection/def_pool_internal.h index da5f9a25b2..762adc32f0 100644 --- a/upb/reflection/def_pool_internal.h +++ b/upb/reflection/def_pool_internal.h @@ -28,6 +28,7 @@ #ifndef UPB_REFLECTION_DEF_POOL_INTERNAL_H_ #define UPB_REFLECTION_DEF_POOL_INTERNAL_H_ +#include "upb/mini_table/decode.h" #include "upb/reflection/def_pool.h" // Must be last. @@ -50,6 +51,7 @@ bool _upb_DefPool_LookupSym(const upb_DefPool* s, const char* sym, size_t size, void** _upb_DefPool_ScratchData(const upb_DefPool* s); size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s); +void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform); // For generated code only: loads a generated descriptor. typedef struct _upb_DefPool_Init { diff --git a/upb/reflection/message_def.c b/upb/reflection/message_def.c index a2b71c1852..6f0f37a083 100644 --- a/upb/reflection/message_def.c +++ b/upb/reflection/message_def.c @@ -355,8 +355,8 @@ static upb_MiniTable* _upb_MessageDef_MakeMiniTable(upb_DefBuilder* ctx, void** scratch_data = _upb_DefPool_ScratchData(ctx->symtab); size_t* scratch_size = _upb_DefPool_ScratchSize(ctx->symtab); upb_MiniTable* ret = upb_MiniTable_BuildWithBuf( - desc.data, desc.size, kUpb_MiniTablePlatform_Native, ctx->arena, - scratch_data, scratch_size, ctx->status); + desc.data, desc.size, ctx->platform, ctx->arena, scratch_data, + scratch_size, ctx->status); if (!ret) _upb_DefBuilder_FailJmp(ctx); return ret; diff --git a/upb/reflection/stage0/google/protobuf/descriptor.upb.c b/upb/reflection/stage0/google/protobuf/descriptor.upb.c new file mode 100644 index 0000000000..da9b960425 --- /dev/null +++ b/upb/reflection/stage0/google/protobuf/descriptor.upb.c @@ -0,0 +1,397 @@ +#include +#include "upb/collections/array_internal.h" +#include "upb/message/internal.h" +#include "upb/mini_table/decode.h" +#include "upb/mini_table/enum_internal.h" +#include "google/protobuf/descriptor.upb.h" + +static upb_Arena* upb_BootstrapArena() { + static upb_Arena* arena = NULL; + if (!arena) arena = upb_Arena_New(); + return arena; +} + +const upb_MiniTable* google_protobuf_FileDescriptorSet_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 1), google_protobuf_FileDescriptorProto_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_FileDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$11EGGGG33<<11"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 4), google_protobuf_DescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 5), google_protobuf_EnumDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 6), google_protobuf_ServiceDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 7), google_protobuf_FieldDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 8), google_protobuf_FileOptions_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 9), google_protobuf_SourceCodeInfo_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_DescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1GGGGG3GGE"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 2), google_protobuf_FieldDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 6), google_protobuf_FieldDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 3), google_protobuf_DescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 4), google_protobuf_EnumDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 5), google_protobuf_DescriptorProto_ExtensionRange_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 8), google_protobuf_OneofDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 7), google_protobuf_MessageOptions_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 9), google_protobuf_DescriptorProto_ReservedRange_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_DescriptorProto_ExtensionRange_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$((3"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 3), google_protobuf_ExtensionRangeOptions_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_DescriptorProto_ReservedRange_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$(("; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + return mini_table; +} + +const upb_MiniTable* google_protobuf_ExtensionRangeOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$Pf~G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_FieldDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$11(44113(1f/"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubEnum(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 4), google_protobuf_FieldDescriptorProto_Label_enum_init()); + upb_MiniTable_SetSubEnum(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 5), google_protobuf_FieldDescriptorProto_Type_enum_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 8), google_protobuf_FieldOptions_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_OneofDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$13"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 2), google_protobuf_OneofOptions_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_EnumDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1G3GE"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 2), google_protobuf_EnumValueDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 3), google_protobuf_EnumOptions_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 4), google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$(("; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + return mini_table; +} + +const upb_MiniTable* google_protobuf_EnumValueDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1(3"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 3), google_protobuf_EnumValueOptions_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_ServiceDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1G3"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 2), google_protobuf_MethodDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 3), google_protobuf_ServiceOptions_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_MethodDescriptorProto_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1113//"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 4), google_protobuf_MethodOptions_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_FileOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$P1f14/1d///a/b/c/c/d11a111/a11y|G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubEnum(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 9), google_protobuf_FileOptions_OptimizeMode_enum_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_MessageOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$P///c/c/{}G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_FieldOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$P4//a/4c/d//v}G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubEnum(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 1), google_protobuf_FieldOptions_CType_enum_init()); + upb_MiniTable_SetSubEnum(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 6), google_protobuf_FieldOptions_JSType_enum_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_OneofOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$Pf~G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_EnumOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$Pa//b/`~G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_EnumValueOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$P/e~G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_ServiceOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$P``/e}G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_MethodOptions_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$P``/4d}G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubEnum(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 34), google_protobuf_MethodOptions_IdempotencyLevel_enum_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 999), google_protobuf_UninterpretedOption_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_UninterpretedOption_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$aG1,+ 01"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 2), google_protobuf_UninterpretedOption_NamePart_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_UninterpretedOption_NamePart_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1N/N"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + return mini_table; +} + +const upb_MiniTable* google_protobuf_SourceCodeInfo_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$G"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 1), google_protobuf_SourceCodeInfo_Location_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_SourceCodeInfo_Location_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$size; + return (const google_protobuf_FileDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet* msg) { + size_t size; + google_protobuf_FileDescriptorSet_file(msg, &size); + return size != 0; +} + +UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorSet_msg_init(), 1); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_FileDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorSet_msg_init(), 1); + return (google_protobuf_FileDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorSet_msg_init(), 1); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(google_protobuf_FileDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.FileDescriptorProto */ + +UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_FileDescriptorProto*)_upb_Message_New(google_protobuf_FileDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FileDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FileDescriptorProto* ret = google_protobuf_FileDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FileDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FileDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FileDescriptorProto_serialize_ex(const google_protobuf_FileDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FileDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_name(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_package(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 3); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_dependency(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_dependency(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_message_type(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 4); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_DescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_message_type(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_enum_type(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 5); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_enum_type(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_service(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 6); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_service(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_extension(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 7); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 7); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_extension(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_options(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 8); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto* msg) { + const google_protobuf_FileOptions* default_val = NULL; + const google_protobuf_FileOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 8); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 8); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_source_code_info(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 9); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto* msg) { + const google_protobuf_SourceCodeInfo* default_val = NULL; + const google_protobuf_SourceCodeInfo* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 9); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 9); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_public_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 10); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 10); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_public_dependency(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_public_dependency(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_weak_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 11); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 11); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_weak_dependency(const google_protobuf_FileDescriptorProto* msg) { + size_t size; + google_protobuf_FileDescriptorProto_weak_dependency(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_syntax(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 12); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 12); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 12); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_edition(const google_protobuf_FileDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_has_edition(const google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 3); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 3); + return (upb_StringView*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 3); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 4); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_DescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 4); + return (google_protobuf_DescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 4); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(google_protobuf_DescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 5); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_EnumDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 5); + return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 5); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(google_protobuf_EnumDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 6); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_ServiceDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 6); + return (google_protobuf_ServiceDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 6); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)_upb_Message_New(google_protobuf_ServiceDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 7); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_FieldDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 7); + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 7); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(google_protobuf_FieldDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 8); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FileOptions*)_upb_Message_New(google_protobuf_FileOptions_msg_init(), arena); + if (sub) google_protobuf_FileDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 9); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg); + if (sub == NULL) { + sub = (struct google_protobuf_SourceCodeInfo*)_upb_Message_New(google_protobuf_SourceCodeInfo_msg_init(), arena); + if (sub) google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub); + } + return sub; +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 10); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 10); + return (int32_t*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 10); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 11); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 11); + return (int32_t*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 11); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 12); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_set_edition(google_protobuf_FileDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileDescriptorProto_msg_init(), 13); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.DescriptorProto */ + +UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_DescriptorProto*)_upb_Message_New(google_protobuf_DescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_DescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_DescriptorProto* ret = google_protobuf_DescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_DescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_DescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_DescriptorProto_serialize_ex(const google_protobuf_DescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_DescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_name(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_field(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 2); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_field(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_nested_type(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 3); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_DescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_nested_type(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_enum_type(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 4); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_enum_type(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_extension_range(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 5); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_extension_range(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_extension(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 6); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_extension(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_options(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 7); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto* msg) { + const google_protobuf_MessageOptions* default_val = NULL; + const google_protobuf_MessageOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 7); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 7); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_oneof_decl(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 8); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 8); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_oneof_decl(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_range(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 9); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 9); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_reserved_range(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_reserved_name(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 10); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 10); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_name(const google_protobuf_DescriptorProto* msg) { + size_t size; + google_protobuf_DescriptorProto_reserved_name(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 2); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_FieldDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 2); + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 2); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(google_protobuf_FieldDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 3); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_DescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 3); + return (google_protobuf_DescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 3); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_Message_New(google_protobuf_DescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 4); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_EnumDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 4); + return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 4); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_Message_New(google_protobuf_EnumDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 5); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 5); + return (google_protobuf_DescriptorProto_ExtensionRange**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 5); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 6); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_FieldDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 6); + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 6); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_Message_New(google_protobuf_FieldDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 7); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_MessageOptions*)_upb_Message_New(google_protobuf_MessageOptions_msg_init(), arena); + if (sub) google_protobuf_DescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 8); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_OneofDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 8); + return (google_protobuf_OneofDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 8); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)_upb_Message_New(google_protobuf_OneofDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 9); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 9); + return (google_protobuf_DescriptorProto_ReservedRange**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 9); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(google_protobuf_DescriptorProto_ReservedRange_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 10); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 10); + return (upb_StringView*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_msg_init(), 10); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} + +/* google.protobuf.DescriptorProto.ExtensionRange */ + +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_new(upb_Arena* arena) { + return (google_protobuf_DescriptorProto_ExtensionRange*)_upb_Message_New(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), arena); +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_DescriptorProto_ExtensionRange_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_ExtensionRange_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_DescriptorProto_ExtensionRange* ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_DescriptorProto_ExtensionRange_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ExtensionRange_serialize_ex(const google_protobuf_DescriptorProto_ExtensionRange* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_DescriptorProto_ExtensionRange_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_start(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_end(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_options(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const google_protobuf_ExtensionRangeOptions* default_val = NULL; + const google_protobuf_ExtensionRangeOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ExtensionRange_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange* msg, upb_Arena* arena) { + struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_ExtensionRangeOptions*)_upb_Message_New(google_protobuf_ExtensionRangeOptions_msg_init(), arena); + if (sub) google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.DescriptorProto.ReservedRange */ + +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_new(upb_Arena* arena) { + return (google_protobuf_DescriptorProto_ReservedRange*)_upb_Message_New(google_protobuf_DescriptorProto_ReservedRange_msg_init(), arena); +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_DescriptorProto_ReservedRange_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_ReservedRange_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_DescriptorProto_ReservedRange* ret = google_protobuf_DescriptorProto_ReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_DescriptorProto_ReservedRange_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_DescriptorProto_ReservedRange_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_DescriptorProto_ReservedRange_serialize_ex(const google_protobuf_DescriptorProto_ReservedRange* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_DescriptorProto_ReservedRange_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_start(google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_end(google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_DescriptorProto_ReservedRange_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.ExtensionRangeOptions */ + +UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_new(upb_Arena* arena) { + return (google_protobuf_ExtensionRangeOptions*)_upb_Message_New(google_protobuf_ExtensionRangeOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_ExtensionRangeOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ExtensionRangeOptions* google_protobuf_ExtensionRangeOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions* ret = google_protobuf_ExtensionRangeOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_ExtensionRangeOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_ExtensionRangeOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_serialize_ex(const google_protobuf_ExtensionRangeOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_ExtensionRangeOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ExtensionRangeOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ExtensionRangeOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) { + size_t size; + google_protobuf_ExtensionRangeOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ExtensionRangeOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ExtensionRangeOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ExtensionRangeOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.FieldDescriptorProto */ + +UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_FieldDescriptorProto*)_upb_Message_New(google_protobuf_FieldDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FieldDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldDescriptorProto* google_protobuf_FieldDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldDescriptorProto* ret = google_protobuf_FieldDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FieldDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FieldDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldDescriptorProto_serialize_ex(const google_protobuf_FieldDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FieldDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_extendee(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_number(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_label(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 4); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 4); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 5); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 5); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 6); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 6); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_default_value(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 7); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 7); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 7); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_options(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 8); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto* msg) { + const google_protobuf_FieldOptions* default_val = NULL; + const google_protobuf_FieldOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 8); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 8); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_oneof_index(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 9); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 9); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 9); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_json_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 10); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 10); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 10); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_proto3_optional(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 17); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 17); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 17); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 4); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 5); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 6); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 7); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 8); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FieldOptions*)_upb_Message_New(google_protobuf_FieldOptions_msg_init(), arena); + if (sub) google_protobuf_FieldDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 9); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 10); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldDescriptorProto_msg_init(), 17); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.OneofDescriptorProto */ + +UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_OneofDescriptorProto*)_upb_Message_New(google_protobuf_OneofDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_OneofDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_OneofDescriptorProto* google_protobuf_OneofDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_OneofDescriptorProto* ret = google_protobuf_OneofDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_OneofDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_OneofDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_OneofDescriptorProto_serialize_ex(const google_protobuf_OneofDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_OneofDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_name(google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_options(google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto* msg) { + const google_protobuf_OneofOptions* default_val = NULL; + const google_protobuf_OneofOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofDescriptorProto_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_OneofOptions*)_upb_Message_New(google_protobuf_OneofOptions_msg_init(), arena); + if (sub) google_protobuf_OneofDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.EnumDescriptorProto */ + +UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_EnumDescriptorProto*)_upb_Message_New(google_protobuf_EnumDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumDescriptorProto* google_protobuf_EnumDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto* ret = google_protobuf_EnumDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_serialize_ex(const google_protobuf_EnumDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_name(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_value(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 2); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto* msg) { + size_t size; + google_protobuf_EnumDescriptorProto_value(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_options(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto* msg) { + const google_protobuf_EnumOptions* default_val = NULL; + const google_protobuf_EnumOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_range(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 4); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto* msg) { + size_t size; + google_protobuf_EnumDescriptorProto_reserved_range(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_name(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 5); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_name(const google_protobuf_EnumDescriptorProto* msg) { + size_t size; + google_protobuf_EnumDescriptorProto_reserved_name(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 2); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_EnumValueDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 2); + return (google_protobuf_EnumValueDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 2); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumValueDescriptorProto* sub = (struct google_protobuf_EnumValueDescriptorProto*)_upb_Message_New(google_protobuf_EnumValueDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_EnumOptions*)_upb_Message_New(google_protobuf_EnumOptions_msg_init(), arena); + if (sub) google_protobuf_EnumDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 4); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 4); + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 4); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_EnumDescriptorProto_EnumReservedRange* sub = (struct google_protobuf_EnumDescriptorProto_EnumReservedRange*)_upb_Message_New(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE upb_StringView* google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 5); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 5); + return (upb_StringView*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_msg_init(), 5); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} + +/* google.protobuf.EnumDescriptorProto.EnumReservedRange */ + +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_Arena* arena) { + return (google_protobuf_EnumDescriptorProto_EnumReservedRange*)_upb_Message_New(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), arena); +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto_EnumReservedRange* ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_EnumReservedRange_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumDescriptorProto_EnumReservedRange* ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize_ex(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_clear_start(google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_clear_end(google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.EnumValueDescriptorProto */ + +UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_EnumValueDescriptorProto*)_upb_Message_New(google_protobuf_EnumValueDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumValueDescriptorProto* ret = google_protobuf_EnumValueDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumValueDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumValueDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumValueDescriptorProto* ret = google_protobuf_EnumValueDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumValueDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumValueDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumValueDescriptorProto_serialize_ex(const google_protobuf_EnumValueDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumValueDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_name(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_number(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_options(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto* msg) { + const google_protobuf_EnumValueOptions* default_val = NULL; + const google_protobuf_EnumValueOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueDescriptorProto_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_EnumValueOptions*)_upb_Message_New(google_protobuf_EnumValueOptions_msg_init(), arena); + if (sub) google_protobuf_EnumValueDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.ServiceDescriptorProto */ + +UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_ServiceDescriptorProto*)_upb_Message_New(google_protobuf_ServiceDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ServiceDescriptorProto* ret = google_protobuf_ServiceDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_ServiceDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ServiceDescriptorProto* google_protobuf_ServiceDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ServiceDescriptorProto* ret = google_protobuf_ServiceDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_ServiceDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_ServiceDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ServiceDescriptorProto_serialize_ex(const google_protobuf_ServiceDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_ServiceDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_name(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_method(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 2); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_MethodDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto* msg) { + size_t size; + google_protobuf_ServiceDescriptorProto_method(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_options(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto* msg) { + const google_protobuf_ServiceOptions* default_val = NULL; + const google_protobuf_ServiceOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 2); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_MethodDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 2); + return (google_protobuf_MethodDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 2); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_MethodDescriptorProto* sub = (struct google_protobuf_MethodDescriptorProto*)_upb_Message_New(google_protobuf_MethodDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceDescriptorProto_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_ServiceOptions*)_upb_Message_New(google_protobuf_ServiceOptions_msg_init(), arena); + if (sub) google_protobuf_ServiceDescriptorProto_set_options(msg, sub); + } + return sub; +} + +/* google.protobuf.MethodDescriptorProto */ + +UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_new(upb_Arena* arena) { + return (google_protobuf_MethodDescriptorProto*)_upb_Message_New(google_protobuf_MethodDescriptorProto_msg_init(), arena); +} +UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_MethodDescriptorProto* ret = google_protobuf_MethodDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_MethodDescriptorProto_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_MethodDescriptorProto* google_protobuf_MethodDescriptorProto_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_MethodDescriptorProto* ret = google_protobuf_MethodDescriptorProto_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_MethodDescriptorProto_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_MethodDescriptorProto_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_MethodDescriptorProto_serialize_ex(const google_protobuf_MethodDescriptorProto* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_MethodDescriptorProto_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_name(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_input_type(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_output_type(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_options(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto* msg) { + const google_protobuf_MethodOptions* default_val = NULL; + const google_protobuf_MethodOptions* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 4); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 4); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_client_streaming(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 5); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 5); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_server_streaming(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 6); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 6); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 4); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto* msg, upb_Arena* arena) { + struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg); + if (sub == NULL) { + sub = (struct google_protobuf_MethodOptions*)_upb_Message_New(google_protobuf_MethodOptions_msg_init(), arena); + if (sub) google_protobuf_MethodDescriptorProto_set_options(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 5); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodDescriptorProto_msg_init(), 6); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.FileOptions */ + +UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_new(upb_Arena* arena) { + return (google_protobuf_FileOptions*)_upb_Message_New(google_protobuf_FileOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FileOptions* ret = google_protobuf_FileOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FileOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FileOptions* google_protobuf_FileOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FileOptions* ret = google_protobuf_FileOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FileOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FileOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FileOptions_serialize_ex(const google_protobuf_FileOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FileOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_outer_classname(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 8); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 8); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 8); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_optimize_for(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 9); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 9); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 9); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_multiple_files(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 10); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 10); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 10); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_go_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 11); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 11); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 11); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_cc_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 16); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 16); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 16); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 17); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 17); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 17); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_py_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 18); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 18); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 18); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_generate_equals_and_hash(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 20); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 20); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 20); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_deprecated(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 23); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 23); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 23); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_string_check_utf8(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 27); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 27); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 27); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_cc_enable_arenas(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 31); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions* msg) { + bool default_val = true; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 31); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 31); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_objc_class_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 36); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 36); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 36); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_csharp_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 37); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 37); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 37); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_swift_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 39); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 39); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 39); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_class_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 40); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 40); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 40); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 41); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 41); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 41); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 42); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 42); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 42); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_metadata_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 44); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 44); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 44); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_ruby_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 45); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 45); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 45); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_uninterpreted_option(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions* msg) { + size_t size; + google_protobuf_FileOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 8); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 9); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 10); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 11); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 16); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 17); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 18); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 20); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 23); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 27); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 31); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 36); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 37); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 39); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 40); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 41); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 42); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 44); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 45); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FileOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.MessageOptions */ + +UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_new(upb_Arena* arena) { + return (google_protobuf_MessageOptions*)_upb_Message_New(google_protobuf_MessageOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_MessageOptions* ret = google_protobuf_MessageOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_MessageOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_MessageOptions* google_protobuf_MessageOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_MessageOptions* ret = google_protobuf_MessageOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_MessageOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_MessageOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_MessageOptions_serialize_ex(const google_protobuf_MessageOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_MessageOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_MessageOptions_clear_message_set_wire_format(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_no_standard_descriptor_accessor(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_deprecated(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_map_entry(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 7); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 7); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 7); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_deprecated_legacy_json_field_conflicts(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 11); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MessageOptions_deprecated_legacy_json_field_conflicts(const google_protobuf_MessageOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 11); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated_legacy_json_field_conflicts(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 11); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_uninterpreted_option(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions* msg) { + size_t size; + google_protobuf_MessageOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 7); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_deprecated_legacy_json_field_conflicts(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 11); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MessageOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.FieldOptions */ + +UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_new(upb_Arena* arena) { + return (google_protobuf_FieldOptions*)_upb_Message_New(google_protobuf_FieldOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldOptions* ret = google_protobuf_FieldOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FieldOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldOptions* google_protobuf_FieldOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldOptions* ret = google_protobuf_FieldOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_FieldOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FieldOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldOptions_serialize_ex(const google_protobuf_FieldOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_FieldOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldOptions_clear_ctype(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_packed(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_deprecated(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_lazy(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 5); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 5); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_jstype(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 6); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 6); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_weak(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 10); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 10); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 10); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_unverified_lazy(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 15); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_unverified_lazy(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 15); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_unverified_lazy(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 15); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_debug_redact(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 16); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_FieldOptions_debug_redact(const google_protobuf_FieldOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 16); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_debug_redact(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 16); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_uninterpreted_option(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions* msg) { + size_t size; + google_protobuf_FieldOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 5); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 6); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 10); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_unverified_lazy(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 15); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_debug_redact(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 16); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_FieldOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.OneofOptions */ + +UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_new(upb_Arena* arena) { + return (google_protobuf_OneofOptions*)_upb_Message_New(google_protobuf_OneofOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_OneofOptions* ret = google_protobuf_OneofOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_OneofOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_OneofOptions* google_protobuf_OneofOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_OneofOptions* ret = google_protobuf_OneofOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_OneofOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_OneofOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_OneofOptions_serialize_ex(const google_protobuf_OneofOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_OneofOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_OneofOptions_clear_uninterpreted_option(google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions* msg) { + size_t size; + google_protobuf_OneofOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_OneofOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.EnumOptions */ + +UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_new(upb_Arena* arena) { + return (google_protobuf_EnumOptions*)_upb_Message_New(google_protobuf_EnumOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumOptions* ret = google_protobuf_EnumOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumOptions* google_protobuf_EnumOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumOptions* ret = google_protobuf_EnumOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumOptions_serialize_ex(const google_protobuf_EnumOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumOptions_clear_allow_alias(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_deprecated(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_deprecated_legacy_json_field_conflicts(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_EnumOptions_deprecated_legacy_json_field_conflicts(const google_protobuf_EnumOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 6); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated_legacy_json_field_conflicts(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 6); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_uninterpreted_option(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions* msg) { + size_t size; + google_protobuf_EnumOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_deprecated_legacy_json_field_conflicts(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 6); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.EnumValueOptions */ + +UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_new(upb_Arena* arena) { + return (google_protobuf_EnumValueOptions*)_upb_Message_New(google_protobuf_EnumValueOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_EnumValueOptions* ret = google_protobuf_EnumValueOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumValueOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_EnumValueOptions* google_protobuf_EnumValueOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_EnumValueOptions* ret = google_protobuf_EnumValueOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_EnumValueOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumValueOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_EnumValueOptions_serialize_ex(const google_protobuf_EnumValueOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_EnumValueOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_deprecated(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_uninterpreted_option(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions* msg) { + size_t size; + google_protobuf_EnumValueOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_EnumValueOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.ServiceOptions */ + +UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_new(upb_Arena* arena) { + return (google_protobuf_ServiceOptions*)_upb_Message_New(google_protobuf_ServiceOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ServiceOptions* ret = google_protobuf_ServiceOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_ServiceOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ServiceOptions* google_protobuf_ServiceOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ServiceOptions* ret = google_protobuf_ServiceOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_ServiceOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_ServiceOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ServiceOptions_serialize_ex(const google_protobuf_ServiceOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_ServiceOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_deprecated(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 33); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 33); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 33); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_uninterpreted_option(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions* msg) { + size_t size; + google_protobuf_ServiceOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 33); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_ServiceOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.MethodOptions */ + +UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_new(upb_Arena* arena) { + return (google_protobuf_MethodOptions*)_upb_Message_New(google_protobuf_MethodOptions_msg_init(), arena); +} +UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_MethodOptions* ret = google_protobuf_MethodOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_MethodOptions_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_MethodOptions* google_protobuf_MethodOptions_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_MethodOptions* ret = google_protobuf_MethodOptions_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_MethodOptions_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_MethodOptions_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_MethodOptions_serialize_ex(const google_protobuf_MethodOptions* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_MethodOptions_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_MethodOptions_clear_deprecated(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 33); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 33); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 33); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_idempotency_level(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 34); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 34); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 34); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_uninterpreted_option(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 999); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 999); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions* msg) { + size_t size; + google_protobuf_MethodOptions_uninterpreted_option(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 33); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 34); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 999); + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_MethodOptions_msg_init(), 999); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.UninterpretedOption */ + +UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_new(upb_Arena* arena) { + return (google_protobuf_UninterpretedOption*)_upb_Message_New(google_protobuf_UninterpretedOption_msg_init(), arena); +} +UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_UninterpretedOption* ret = google_protobuf_UninterpretedOption_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_UninterpretedOption_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_UninterpretedOption* google_protobuf_UninterpretedOption_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_UninterpretedOption* ret = google_protobuf_UninterpretedOption_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_UninterpretedOption_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_UninterpretedOption_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_serialize_ex(const google_protobuf_UninterpretedOption* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_UninterpretedOption_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_name(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 2); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_UninterpretedOption_NamePart* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption* msg) { + size_t size; + google_protobuf_UninterpretedOption_name(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_identifier_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_positive_int_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption* msg) { + uint64_t default_val = (uint64_t)0ull; + uint64_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 4); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 4); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_negative_int_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption* msg) { + int64_t default_val = (int64_t)0ll; + int64_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 5); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 5); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_double_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption* msg) { + double default_val = 0; + double ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 6); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 6); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_string_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 7); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 7); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 7); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_aggregate_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 8); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 8); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 8); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 2); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 2); + return (google_protobuf_UninterpretedOption_NamePart**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 2); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_UninterpretedOption_NamePart* sub = (struct google_protobuf_UninterpretedOption_NamePart*)_upb_Message_New(google_protobuf_UninterpretedOption_NamePart_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 4); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 5); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 6); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 7); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_msg_init(), 8); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.UninterpretedOption.NamePart */ + +UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_new(upb_Arena* arena) { + return (google_protobuf_UninterpretedOption_NamePart*)_upb_Message_New(google_protobuf_UninterpretedOption_NamePart_msg_init(), arena); +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_UninterpretedOption_NamePart* ret = google_protobuf_UninterpretedOption_NamePart_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_UninterpretedOption_NamePart_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_NamePart_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_UninterpretedOption_NamePart* ret = google_protobuf_UninterpretedOption_NamePart_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_UninterpretedOption_NamePart_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_UninterpretedOption_NamePart_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_UninterpretedOption_NamePart_serialize_ex(const google_protobuf_UninterpretedOption_NamePart* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_UninterpretedOption_NamePart_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_clear_name_part(google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_clear_is_extension(google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_UninterpretedOption_NamePart_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.SourceCodeInfo */ + +UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_new(upb_Arena* arena) { + return (google_protobuf_SourceCodeInfo*)_upb_Message_New(google_protobuf_SourceCodeInfo_msg_init(), arena); +} +UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_SourceCodeInfo* ret = google_protobuf_SourceCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_SourceCodeInfo_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_SourceCodeInfo* google_protobuf_SourceCodeInfo_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_SourceCodeInfo* ret = google_protobuf_SourceCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_SourceCodeInfo_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_SourceCodeInfo_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_serialize_ex(const google_protobuf_SourceCodeInfo* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_SourceCodeInfo_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_clear_location(google_protobuf_SourceCodeInfo* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_msg_init(), 1); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_SourceCodeInfo_Location* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo* msg) { + size_t size; + google_protobuf_SourceCodeInfo_location(msg, &size); + return size != 0; +} + +UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_msg_init(), 1); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_SourceCodeInfo_Location**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_msg_init(), 1); + return (google_protobuf_SourceCodeInfo_Location**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_msg_init(), 1); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_SourceCodeInfo_Location* sub = (struct google_protobuf_SourceCodeInfo_Location*)_upb_Message_New(google_protobuf_SourceCodeInfo_Location_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.SourceCodeInfo.Location */ + +UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_new(upb_Arena* arena) { + return (google_protobuf_SourceCodeInfo_Location*)_upb_Message_New(google_protobuf_SourceCodeInfo_Location_msg_init(), arena); +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_SourceCodeInfo_Location* ret = google_protobuf_SourceCodeInfo_Location_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_SourceCodeInfo_Location_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_Location_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_SourceCodeInfo_Location* ret = google_protobuf_SourceCodeInfo_Location_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_SourceCodeInfo_Location_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_SourceCodeInfo_Location_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_SourceCodeInfo_Location_serialize_ex(const google_protobuf_SourceCodeInfo_Location* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_SourceCodeInfo_Location_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_path(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 1); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_path(const google_protobuf_SourceCodeInfo_Location* msg) { + size_t size; + google_protobuf_SourceCodeInfo_Location_path(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_span(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 2); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_span(const google_protobuf_SourceCodeInfo_Location* msg) { + size_t size; + google_protobuf_SourceCodeInfo_Location_span(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_leading_comments(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_trailing_comments(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 4); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 4); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_clear_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 6); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 6); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg) { + size_t size; + google_protobuf_SourceCodeInfo_Location_leading_detached_comments(msg, &size); + return size != 0; +} + +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 1); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 1); + return (int32_t*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 1); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 2); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 2); + return (int32_t*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 2); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 4); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE upb_StringView* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 6); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 6); + return (upb_StringView*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_SourceCodeInfo_Location_msg_init(), 6); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} + +/* google.protobuf.GeneratedCodeInfo */ + +UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_new(upb_Arena* arena) { + return (google_protobuf_GeneratedCodeInfo*)_upb_Message_New(google_protobuf_GeneratedCodeInfo_msg_init(), arena); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo* ret = google_protobuf_GeneratedCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_GeneratedCodeInfo_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_GeneratedCodeInfo* google_protobuf_GeneratedCodeInfo_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo* ret = google_protobuf_GeneratedCodeInfo_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_GeneratedCodeInfo_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_GeneratedCodeInfo_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_serialize_ex(const google_protobuf_GeneratedCodeInfo* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_GeneratedCodeInfo_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_clear_annotation(google_protobuf_GeneratedCodeInfo* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_msg_init(), 1); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo* msg) { + size_t size; + google_protobuf_GeneratedCodeInfo_annotation(msg, &size); + return size != 0; +} + +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_msg_init(), 1); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_msg_init(), 1); + return (google_protobuf_GeneratedCodeInfo_Annotation**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_msg_init(), 1); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_GeneratedCodeInfo_Annotation* sub = (struct google_protobuf_GeneratedCodeInfo_Annotation*)_upb_Message_New(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.GeneratedCodeInfo.Annotation */ + +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_new(upb_Arena* arena) { + return (google_protobuf_GeneratedCodeInfo_Annotation*)_upb_Message_New(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), arena); +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo_Annotation* ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_Annotation_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_GeneratedCodeInfo_Annotation* ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_GeneratedCodeInfo_Annotation_serialize_ex(const google_protobuf_GeneratedCodeInfo_Annotation* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_path(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 1); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + size_t size; + google_protobuf_GeneratedCodeInfo_Annotation_path(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_source_file(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_begin(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_end(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 4); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 4); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_semantic(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 5); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_semantic(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 5); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_semantic(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 5); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 1); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (int32_t*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 1); + return (int32_t*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 1); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 4); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_semantic(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_GeneratedCodeInfo_Annotation_msg_init(), 5); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +extern const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout; + +/* Max size 32 is google.protobuf.FileOptions */ +/* Max size 64 is google.protobuf.FileOptions */ +#define _UPB_MAXOPT_SIZE UPB_SIZE(104, 192) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port/undef.inc" + +#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */ diff --git a/upbc/BUILD b/upbc/BUILD index c2e7caa5a8..0b52c984ba 100644 --- a/upbc/BUILD +++ b/upbc/BUILD @@ -33,6 +33,12 @@ load( "upb_proto_library", "upb_proto_reflection_library", ) +load( + "//upbc:bootstrap_compiler.bzl", + "bootstrap_cc_binary", + "bootstrap_cc_library", + "bootstrap_upb_proto_library", +) licenses(["notice"]) @@ -55,10 +61,27 @@ upb_proto_reflection_library( deps = [":code_generator_request"], ) -upb_proto_library( +bootstrap_upb_proto_library( name = "plugin_upb_proto", + base_dir = "", + google3_src_files = [ + "src/google/protobuf/compiler/plugin.proto", + "net/proto2/compiler/proto/profile.proto", + ], + google3_src_rules = [ + "//net/proto2/proto:descriptor_proto_source", + "//net/proto2/compiler/proto:plugin.proto", + "//net/proto2/compiler/proto:profile.proto", + ], + oss_src_files = ["google/protobuf/compiler/plugin.proto"], + oss_src_rules = [ + "@com_google_protobuf//:descriptor_proto_srcs", + "@com_google_protobuf//src/google/protobuf/compiler:plugin_proto_src", + ], + oss_strip_prefix = "third_party/protobuf/github/bootstrap/src", + proto_lib_deps = ["@com_google_protobuf//:compiler_plugin_proto"], visibility = ["//:friends"], - deps = ["@com_google_protobuf//:compiler_plugin_proto"], + deps = ["//:descriptor_upb_proto"], ) upb_proto_reflection_library( @@ -85,7 +108,7 @@ cc_binary( ], ) -cc_library( +bootstrap_cc_library( name = "common", srcs = [ "common.cc", @@ -93,15 +116,17 @@ cc_library( hdrs = [ "common.h", ], + bootstrap_deps = [ + "//:reflection", + ], copts = UPB_DEFAULT_CPPOPTS, visibility = ["//protos_generator:__pkg__"], deps = [ "@com_google_absl//absl/strings", - "@com_google_protobuf//:protobuf", ], ) -cc_library( +bootstrap_cc_library( name = "file_layout", srcs = [ "file_layout.cc", @@ -109,16 +134,20 @@ cc_library( hdrs = [ "file_layout.h", ], + bootstrap_deps = [ + ":common", + "//:reflection", + "//:descriptor_upb_proto", + ], copts = UPB_DEFAULT_CPPOPTS, visibility = ["//protos_generator:__pkg__"], deps = [ - ":common", "//:mini_table", "//:mini_table_internal", + "//:port", "//:upb", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/strings", - "@com_google_protobuf//src/google/protobuf/compiler:code_generator", ], ) @@ -134,7 +163,28 @@ cc_library( visibility = ["//protos_generator:__pkg__"], ) -cc_library( +bootstrap_cc_library( + name = "plugin", + hdrs = [ + "plugin.h", + ], + bootstrap_deps = [ + ":plugin_upb_proto", + "//:descriptor_upb_proto", + "//:reflection", + ], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//protos_generator:__pkg__"], + deps = [ + "//:port", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", + "@com_google_absl//absl/strings", + ], +) + +bootstrap_cc_library( name = "names", srcs = [ "names.cc", @@ -142,6 +192,9 @@ cc_library( hdrs = [ "names.h", ], + bootstrap_deps = [ + "//:reflection", + ], copts = UPB_DEFAULT_CPPOPTS, visibility = ["//protos_generator:__pkg__"], deps = [ @@ -177,22 +230,31 @@ cc_library( ], ) -cc_binary( +bootstrap_cc_binary( name = "protoc-gen-upb", srcs = ["protoc-gen-upb.cc"], - copts = UPB_DEFAULT_CPPOPTS, - visibility = ["//visibility:public"], - deps = [ + bootstrap_deps = [ ":common", ":file_layout", ":names", + ":plugin", + ":plugin_upb_proto", + "//:descriptor_upb_proto", + "//:reflection", + ], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + "//:base", + "//:mem", "//:mini_table_internal", "//:port", + "//:wire_types", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", - "@com_google_protobuf//:protobuf", - "@com_google_protobuf//src/google/protobuf/compiler:code_generator", ], ) @@ -202,11 +264,19 @@ cc_binary( "protoc-gen-upbdefs.cc", ], copts = UPB_DEFAULT_CPPOPTS, + # To work around the following link error from ABSL: + # /usr/bin/x86_64-linux-gnu-ld: bazel-out/k8-opt-exec-2B5CBBC6-ST-c1776f9924ec/bin/external/com_google_absl/absl/time/libtime.a(duration.o): undefined reference to symbol 'floor@@GLIBC_2.2.5' + # /usr/bin/x86_64-linux-gnu-ld: /opt/manylinux/2014/x86_64/lib64/libm.so.6: error adding symbols: DSO missing from command line + # clang-14: error: linker command failed with exit code 1 (use -v to see invocation) + linkopts = ["-lm"], visibility = ["//visibility:public"], deps = [ ":common", - "@com_google_protobuf//:protobuf", - "@com_google_protobuf//src/google/protobuf/compiler:code_generator", + ":file_layout", + ":plugin", + "//:descriptor_upb_proto", + "//:reflection", + "//upb/util:def_to_proto", ], ) diff --git a/upbc/bootstrap_compiler.bzl b/upbc/bootstrap_compiler.bzl new file mode 100644 index 0000000000..3a9e645bd8 --- /dev/null +++ b/upbc/bootstrap_compiler.bzl @@ -0,0 +1,166 @@ +"""Macros that implement bootstrapping for the upb code generator.""" + +load( + "//bazel:upb_proto_library.bzl", + "upb_proto_library", +) +load( + "//cmake:build_defs.bzl", + "staleness_test", +) + +_stages = ["_stage0", "_stage1", ""] +_protoc = "@com_google_protobuf//:protoc" +_upbc_base = "//upbc:protoc-gen-upb" + +# begin:google_only +# _is_google3 = True +# _extra_proto_path = "" +# end:google_only + +# begin:github_only +_is_google3 = False +_extra_proto_path = "-Iexternal/com_google_protobuf/src " +# end:github_only + +def _upbc(stage): + return _upbc_base + _stages[stage] + +def bootstrap_cc_library(name, visibility, deps, bootstrap_deps, **kwargs): + for stage in _stages: + stage_visibility = visibility if stage == "" else ["//upbc:__pkg__"] + native.cc_library( + name = name + stage, + deps = deps + [dep + stage for dep in bootstrap_deps], + visibility = stage_visibility, + **kwargs + ) + +def bootstrap_cc_binary(name, deps, bootstrap_deps, **kwargs): + for stage in _stages: + native.cc_binary( + name = name + stage, + deps = deps + [dep + stage for dep in bootstrap_deps], + **kwargs + ) + +def _generated_srcs_for_suffix(prefix, srcs, suffix): + return [prefix + "/" + src[:-len(".proto")] + suffix for src in srcs] + +def _generated_srcs(prefix, srcs): + return _generated_srcs_for_suffix(prefix, srcs, ".upb.h") + _generated_srcs_for_suffix(prefix, srcs, ".upb.c") + +def _stage0_proto_staleness_test(name, base_dir, src_files, src_rules, strip_prefix): + native.genrule( + name = name + "_generate_bootstrap", + srcs = src_rules, + outs = _generated_srcs("bootstrap_generated_sources/" + base_dir + "stage0", src_files), + tools = [_protoc, _upbc(0)], + cmd = + "$(location " + _protoc + ") " + + "-I$(GENDIR)/" + strip_prefix + " " + _extra_proto_path + + "--plugin=protoc-gen-upb=$(location " + _upbc(0) + ") " + + "--upb_out=bootstrap_upb:$(@D)/bootstrap_generated_sources/" + base_dir + "stage0 " + + " ".join(src_files), + ) + + staleness_test( + name = name + "_staleness_test", + outs = _generated_srcs(base_dir + "stage0", src_files), + generated_pattern = "bootstrap_generated_sources/%s", + target_files = native.glob([base_dir + "stage0/**"]), + # To avoid skew problems for descriptor.proto/pluging.proto between + # GitHub repos. It's not critical that the checked-in protos are up to + # date for every change, they just needs to be complete enough to have + # everything needed by the code generator itself. + tags = ["manual"], + ) + +def bootstrap_upb_proto_library( + name, + base_dir, + google3_src_files, + google3_src_rules, + oss_src_files, + oss_src_rules, + oss_strip_prefix, + proto_lib_deps, + visibility, + deps = [], + **kwargs): + """A version of upb_proto_library() that is augmented to allow for bootstrapping the compiler. + + Args: + name: Name of this rule. This name will resolve to a upb_proto_library(). + base_dir: The directory that all generated files should be placed under. + google3_src_files: Google3 filenames of .proto files that should be built by this rule. + The names should be relative to the depot base. + google3_src_rules: Target names of the Blaze rules that will provide these filenames. + oss_src_files: OSS filenames of .proto files that should be built by this rule. + oss_src_rules: Target names of the Bazel rules that will provide these filenames. + oss_strip_prefix: Prefix that should be stripped from OSS file names. + proto_lib_deps: proto_library() rules that we will use to build the protos when we are + not bootstrapping. + visibility: Visibility list for the final upb_proto_library() rule. Bootstrapping rules + will always be hidden, and will not honor the visibility parameter passed here. + deps: other bootstrap_upb_proto_library() rules that this one depends on. + **kwargs: Other arguments that will be passed through to cc_library(), genrule(), and + upb_proto_library(). + """ + _stage0_proto_staleness_test(name, base_dir, oss_src_files, oss_src_rules, oss_strip_prefix) + + # stage0 uses checked-in protos. + native.cc_library( + name = name + "_stage0", + srcs = _generated_srcs_for_suffix(base_dir + "stage0", oss_src_files, ".upb.c"), + hdrs = _generated_srcs_for_suffix(base_dir + "stage0", oss_src_files, ".upb.h"), + includes = [base_dir + "stage0"], + visibility = ["//upbc:__pkg__"], + # This macro signals to the runtime that it must use OSS APIs for descriptor.proto/plugin.proto. + defines = ["UPB_BOOTSTRAP_STAGE0"], + deps = [ + "//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + "//:mini_table", + ] + [dep + "_stage0" for dep in deps], + **kwargs + ) + + src_files = google3_src_files if _is_google3 else oss_src_files + src_rules = google3_src_rules if _is_google3 else oss_src_rules + + # Generate stage1 protos using stage0 compiler. + native.genrule( + name = "gen_" + name + "_stage1", + srcs = src_rules, + outs = _generated_srcs(base_dir + "stage1", src_files), + cmd = "$(location " + _protoc + ") " + + "--plugin=protoc-gen-upb=$(location " + _upbc(0) + ") " + _extra_proto_path + + "--upb_out=$(@D)/" + base_dir + "stage1 " + + " ".join(src_files), + visibility = ["//upbc:__pkg__"], + tools = [ + _protoc, + _upbc(0), + ], + **kwargs + ) + + native.cc_library( + name = name + "_stage1", + srcs = _generated_srcs_for_suffix(base_dir + "stage1", src_files, ".upb.c"), + hdrs = _generated_srcs_for_suffix(base_dir + "stage1", src_files, ".upb.h"), + includes = [base_dir + "stage1"], + visibility = ["//upbc:__pkg__"], + deps = [ + "//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + ] + [dep + "_stage1" for dep in deps], + **kwargs + ) + + # The final protos are generated via normal upb_proto_library(). + upb_proto_library( + name = name, + deps = proto_lib_deps, + visibility = visibility, + **kwargs + ) diff --git a/upbc/common.cc b/upbc/common.cc index a63813948c..b4942e6d7f 100644 --- a/upbc/common.cc +++ b/upbc/common.cc @@ -26,13 +26,9 @@ #include "upbc/common.h" #include "absl/strings/str_replace.h" +#include "upb/reflection/def.hpp" namespace upbc { -namespace { - -namespace protobuf = ::google::protobuf; - -} // namespace std::string StripExtension(absl::string_view fname) { size_t lastdot = fname.find_last_of('.'); @@ -50,7 +46,7 @@ std::string ToPreproc(absl::string_view str) { return absl::AsciiStrToUpper(ToCIdent(str)); } -void EmitFileWarning(const protobuf::FileDescriptor* file, Output& output) { +void EmitFileWarning(absl::string_view name, Output& output) { output( "/* This file was generated by upbc (the upb compiler) from the input\n" " * file:\n" @@ -59,27 +55,27 @@ void EmitFileWarning(const protobuf::FileDescriptor* file, Output& output) { " *\n" " * Do not edit -- your changes will be discarded when the file is\n" " * regenerated. */\n\n", - file->name()); + name); } -std::string MessageName(const protobuf::Descriptor* descriptor) { - return ToCIdent(descriptor->full_name()); +std::string MessageName(upb::MessageDefPtr descriptor) { + return ToCIdent(descriptor.full_name()); } -std::string FileLayoutName(const google::protobuf::FileDescriptor* file) { - return ToCIdent(file->name()) + "_upb_file_layout"; +std::string FileLayoutName(upb::FileDefPtr file) { + return ToCIdent(file.name()) + "_upb_file_layout"; } -std::string HeaderFilename(const google::protobuf::FileDescriptor* file) { - return StripExtension(file->name()) + ".upb.h"; +std::string HeaderFilename(upb::FileDefPtr file) { + return StripExtension(file.name()) + ".upb.h"; } -std::string MessageInit(const protobuf::Descriptor* descriptor) { - return MessageName(descriptor) + "_msg_init"; +std::string MessageInit(absl::string_view full_name) { + return ToCIdent(full_name) + "_msg_init"; } -std::string EnumInit(const protobuf::EnumDescriptor* descriptor) { - return ToCIdent(descriptor->full_name()) + "_enum_init"; +std::string EnumInit(upb::EnumDefPtr descriptor) { + return ToCIdent(descriptor.full_name()) + "_enum_init"; } } // namespace upbc diff --git a/upbc/common.h b/upbc/common.h index c6d54ff842..aaa43a6c4d 100644 --- a/upbc/common.h +++ b/upbc/common.h @@ -32,21 +32,19 @@ #include "absl/strings/str_replace.h" #include "absl/strings/substitute.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/io/zero_copy_stream.h" +#include "upb/reflection/def.hpp" namespace upbc { class Output { public: - Output(google::protobuf::io::ZeroCopyOutputStream* stream) : stream_(stream) {} - ~Output() { stream_->BackUp((int)size_); } - template void operator()(absl::string_view format, const Arg&... arg) { Write(absl::Substitute(format, arg...)); } + absl::string_view output() const { return output_; } + private: void Write(absl::string_view data) { std::string stripped; @@ -69,44 +67,22 @@ class Output { data = stripped; } } - while (!data.empty()) { - RefreshOutput(); - size_t to_write = std::min(data.size(), size_); - memcpy(ptr_, data.data(), to_write); - data.remove_prefix(to_write); - ptr_ += to_write; - size_ -= to_write; - } - } - - void RefreshOutput() { - while (size_ == 0) { - void* ptr; - int size; - if (!stream_->Next(&ptr, &size)) { - fprintf(stderr, "upbc: Failed to write to to output\n"); - abort(); - } - ptr_ = static_cast(ptr); - size_ = size; - } + absl::StrAppend(&output_, data); } - google::protobuf::io::ZeroCopyOutputStream* stream_; - char* ptr_ = nullptr; - size_t size_ = 0; + std::string output_; }; std::string StripExtension(absl::string_view fname); std::string ToCIdent(absl::string_view str); std::string ToPreproc(absl::string_view str); -void EmitFileWarning(const google::protobuf::FileDescriptor* file, Output& output); -std::string MessageName(const google::protobuf::Descriptor* descriptor); -std::string FileLayoutName(const google::protobuf::FileDescriptor* file); -std::string HeaderFilename(const google::protobuf::FileDescriptor* file); +void EmitFileWarning(absl::string_view name, Output& output); +std::string MessageName(upb::MessageDefPtr descriptor); +std::string FileLayoutName(upb::FileDefPtr file); +std::string HeaderFilename(upb::FileDefPtr file); -std::string MessageInit(const google::protobuf::Descriptor* descriptor); -std::string EnumInit(const google::protobuf::EnumDescriptor* descriptor); +std::string MessageInit(absl::string_view full_name); +std::string EnumInit(upb::EnumDefPtr descriptor); } // namespace upbc diff --git a/upbc/file_layout.cc b/upbc/file_layout.cc index 8535f4691e..6810aee375 100644 --- a/upbc/file_layout.cc +++ b/upbc/file_layout.cc @@ -28,48 +28,42 @@ #include #include -#include "upb/mini_table/encode_internal.hpp" #include "upb/mini_table/extension_internal.h" #include "upbc/common.h" namespace upbc { -namespace protobuf = ::google::protobuf; - const char* kEnumsInit = "enums_layout"; const char* kExtensionsInit = "extensions_layout"; const char* kMessagesInit = "messages_layout"; -void AddEnums(const protobuf::Descriptor* message, - std::vector* enums) { - enums->reserve(enums->size() + message->enum_type_count()); - for (int i = 0; i < message->enum_type_count(); i++) { - enums->push_back(message->enum_type(i)); +void AddEnums(upb::MessageDefPtr message, std::vector* enums) { + enums->reserve(enums->size() + message.enum_type_count()); + for (int i = 0; i < message.enum_type_count(); i++) { + enums->push_back(message.enum_type(i)); } - for (int i = 0; i < message->nested_type_count(); i++) { - AddEnums(message->nested_type(i), enums); + for (int i = 0; i < message.nested_message_count(); i++) { + AddEnums(message.nested_message(i), enums); } } -std::vector SortedEnums( - const protobuf::FileDescriptor* file) { - std::vector enums; - enums.reserve(file->enum_type_count()); - for (int i = 0; i < file->enum_type_count(); i++) { - enums.push_back(file->enum_type(i)); +std::vector SortedEnums(upb::FileDefPtr file) { + std::vector enums; + enums.reserve(file.toplevel_enum_count()); + for (int i = 0; i < file.toplevel_enum_count(); i++) { + enums.push_back(file.toplevel_enum(i)); } - for (int i = 0; i < file->message_type_count(); i++) { - AddEnums(file->message_type(i), &enums); + for (int i = 0; i < file.toplevel_message_count(); i++) { + AddEnums(file.toplevel_message(i), &enums); } return enums; } -std::vector SortedUniqueEnumNumbers( - const protobuf::EnumDescriptor* e) { +std::vector SortedUniqueEnumNumbers(upb::EnumDefPtr e) { std::vector values; - values.reserve(e->value_count()); - for (int i = 0; i < e->value_count(); i++) { - values.push_back(static_cast(e->value(i)->number())); + values.reserve(e.value_count()); + for (int i = 0; i < e.value_count(); i++) { + values.push_back(static_cast(e.value(i).number())); } std::sort(values.begin(), values.end()); auto last = std::unique(values.begin(), values.end()); @@ -77,11 +71,11 @@ std::vector SortedUniqueEnumNumbers( return values; } -void AddMessages(const protobuf::Descriptor* message, - std::vector* messages) { +void AddMessages(upb::MessageDefPtr message, + std::vector* messages) { messages->push_back(message); - for (int i = 0; i < message->nested_type_count(); i++) { - AddMessages(message->nested_type(i), messages); + for (int i = 0; i < message.nested_message_count(); i++) { + AddMessages(message.nested_message(i), messages); } } @@ -90,23 +84,21 @@ void AddMessages(const protobuf::Descriptor* message, // The ordering is significant because each upb_MessageDef* will point at the // corresponding upb_MiniTable and we just iterate through the list without // any search or lookup. -std::vector SortedMessages( - const protobuf::FileDescriptor* file) { - std::vector messages; - for (int i = 0; i < file->message_type_count(); i++) { - AddMessages(file->message_type(i), &messages); +std::vector SortedMessages(upb::FileDefPtr file) { + std::vector messages; + for (int i = 0; i < file.toplevel_message_count(); i++) { + AddMessages(file.toplevel_message(i), &messages); } return messages; } -void AddExtensionsFromMessage( - const protobuf::Descriptor* message, - std::vector* exts) { - for (int i = 0; i < message->extension_count(); i++) { - exts->push_back(message->extension(i)); +void AddExtensionsFromMessage(upb::MessageDefPtr message, + std::vector* exts) { + for (int i = 0; i < message.nested_extension_count(); i++) { + exts->push_back(message.nested_extension(i)); } - for (int i = 0; i < message->nested_type_count(); i++) { - AddExtensionsFromMessage(message->nested_type(i), exts); + for (int i = 0; i < message.nested_message_count(); i++) { + AddExtensionsFromMessage(message.nested_message(i), exts); } } @@ -115,304 +107,29 @@ void AddExtensionsFromMessage( // The ordering is significant because each upb_FieldDef* will point at the // corresponding upb_MiniTableExtension and we just iterate through the list // without any search or lookup. -std::vector SortedExtensions( - const protobuf::FileDescriptor* file) { - std::vector ret; - for (int i = 0; i < file->extension_count(); i++) { - ret.push_back(file->extension(i)); +std::vector SortedExtensions(upb::FileDefPtr file) { + std::vector ret; + ret.reserve(file.toplevel_extension_count()); + for (int i = 0; i < file.toplevel_extension_count(); i++) { + ret.push_back(file.toplevel_extension(i)); } - for (int i = 0; i < file->message_type_count(); i++) { - AddExtensionsFromMessage(file->message_type(i), &ret); + for (int i = 0; i < file.toplevel_message_count(); i++) { + AddExtensionsFromMessage(file.toplevel_message(i), &ret); } return ret; } -std::vector FieldNumberOrder( - const protobuf::Descriptor* message) { - std::vector fields; - for (int i = 0; i < message->field_count(); i++) { - fields.push_back(message->field(i)); +std::vector FieldNumberOrder(upb::MessageDefPtr message) { + std::vector fields; + fields.reserve(message.field_count()); + for (int i = 0; i < message.field_count(); i++) { + fields.push_back(message.field(i)); } std::sort(fields.begin(), fields.end(), - [](const protobuf::FieldDescriptor* a, - const protobuf::FieldDescriptor* b) { - return a->number() < b->number(); + [](upb::FieldDefPtr a, upb::FieldDefPtr b) { + return a.number() < b.number(); }); return fields; } -upb_MiniTable* FilePlatformLayout::GetMiniTable( - const protobuf::Descriptor* m) const { - auto it = table_map_.find(m); - assert(it != table_map_.end()); - return it->second; -} - -upb_MiniTableEnum* FilePlatformLayout::GetEnumTable( - const protobuf::EnumDescriptor* d) const { - auto it = enum_map_.find(d); - assert(it != enum_map_.end()); - return it->second; -} - -const upb_MiniTableExtension* FilePlatformLayout::GetExtension( - const protobuf::FieldDescriptor* fd) const { - auto it = extension_map_.find(fd); - assert(it != extension_map_.end()); - return &it->second; -} - -void FilePlatformLayout::ResolveIntraFileReferences() { - // This properly resolves references within a file, in order to set any - // necessary flags (eg. is a map). - for (const auto& pair : table_map_) { - upb_MiniTable* mt = pair.second; - // First we properly resolve for defs within the file. - for (const auto* f : FieldNumberOrder(pair.first)) { - if (f->message_type() && f->message_type()->file() == f->file()) { - // const_cast is safe because the mini-table is owned exclusively - // by us, and was allocated from an arena (known-writable memory). - upb_MiniTableField* mt_f = const_cast( - upb_MiniTable_FindFieldByNumber(mt, f->number())); - upb_MiniTable* sub_mt = GetMiniTable(f->message_type()); - upb_MiniTable_SetSubMessage(mt, mt_f, sub_mt); - } - // We don't worry about enums here, because resolving an enum will - // never alter the mini-table. - } - } -} - -upb_MiniTableSub FilePlatformLayout::PackSub(const char* data, SubTag tag) { - uintptr_t val = reinterpret_cast(data); - assert((val & kMask) == 0); - upb_MiniTableSub sub; - sub.submsg = reinterpret_cast(val | tag); - return sub; -} - -bool FilePlatformLayout::IsNull(upb_MiniTableSub sub) { - return reinterpret_cast(sub.subenum) == 0; -} - -std::string FilePlatformLayout::GetSub(upb_MiniTableSub sub) { - uintptr_t as_int = reinterpret_cast(sub.submsg); - const char* str = reinterpret_cast(as_int & ~SubTag::kMask); - switch (as_int & SubTag::kMask) { - case SubTag::kMessage: - return absl::Substitute("{.submsg = &$0}", str); - case SubTag::kEnum: - return absl::Substitute("{.subenum = &$0}", str); - default: - return std::string("{.submsg = NULL}"); - } - return std::string("ERROR in GetSub"); -} - -void FilePlatformLayout::SetSubTableStrings() { - for (const auto& pair : table_map_) { - upb_MiniTable* mt = pair.second; - for (const auto* f : FieldNumberOrder(pair.first)) { - upb_MiniTableField* mt_f = const_cast( - upb_MiniTable_FindFieldByNumber(mt, f->number())); - assert(mt_f); - upb_MiniTableSub sub = PackSubForField(f, mt_f); - if (IsNull(sub)) continue; - // const_cast is safe because the mini-table is owned exclusively - // by us, and was allocated from an arena (known-writable memory). - *const_cast(&mt->subs[mt_f->submsg_index]) = sub; - } - } -} - -upb_MiniTableSub FilePlatformLayout::PackSubForField( - const protobuf::FieldDescriptor* f, const upb_MiniTableField* mt_f) { - if (mt_f->submsg_index == kUpb_NoSub) { - return PackSub(nullptr, SubTag::kNull); - } else if (f->message_type()) { - return PackSub(AllocStr(MessageInit(f->message_type())), SubTag::kMessage); - } else { - ABSL_ASSERT(f->enum_type()); - return PackSub(AllocStr(EnumInit(f->enum_type())), SubTag::kEnum); - } -} - -const char* FilePlatformLayout::AllocStr(absl::string_view str) { - char* ret = - static_cast(upb_Arena_Malloc(arena_.ptr(), str.size() + 1)); - memcpy(ret, str.data(), str.size()); - ret[str.size()] = '\0'; - return ret; -} - -void FilePlatformLayout::BuildMiniTables(const protobuf::FileDescriptor* fd) { - for (const auto& m : SortedMessages(fd)) { - table_map_[m] = MakeMiniTable(m); - } - for (const auto& e : SortedEnums(fd)) { - enum_map_[e] = MakeMiniTableEnum(e); - } - ResolveIntraFileReferences(); - SetSubTableStrings(); -} - -void FilePlatformLayout::BuildExtensions(const protobuf::FileDescriptor* fd) { - std::vector sorted = SortedExtensions(fd); - upb::Status status; - for (const auto* f : sorted) { - upb::MtDataEncoder e; - e.EncodeExtension(static_cast(f->type()), f->number(), - GetFieldModifiers(f)); - upb_MiniTableExtension& ext = extension_map_[f]; - upb_MiniTableSub sub; - // The extendee may be from another file, so we build a temporary MiniTable - // for it, just for the purpose of building the extension. - // Note, we are not caching so this could use more memory than is necessary. - upb_MiniTable* extendee = MakeMiniTable(f->containing_type()); - bool ok = - _upb_MiniTableExtension_Build(e.data().data(), e.data().size(), &ext, - extendee, sub, platform_, status.ptr()); - if (!ok) { - // TODO(haberman): Use ABSL CHECK() when it is available. - fprintf(stderr, "Error building mini-table: %s\n", - status.error_message()); - } - ABSL_ASSERT(ok); - ext.extendee = reinterpret_cast( - AllocStr(MessageInit(f->containing_type()))); - ext.sub = PackSubForField(f, &ext.field); - } -} - -upb_MiniTable* FilePlatformLayout::MakeMiniTable( - const protobuf::Descriptor* m) { - if (m->options().message_set_wire_format()) { - return MakeMessageSetMiniTable(m); - } else if (m->options().map_entry()) { - return MakeMapMiniTable(m); - } else { - return MakeRegularMiniTable(m); - } -} - -upb_MiniTable* FilePlatformLayout::MakeMapMiniTable( - const protobuf::Descriptor* m) { - const auto key_type = static_cast(m->map_key()->type()); - const auto val_type = static_cast(m->map_value()->type()); - - upb::MtDataEncoder e; - e.EncodeMap(key_type, val_type, GetFieldModifiers(m->map_key()), - GetFieldModifiers(m->map_value())); - - const absl::string_view str = e.data(); - upb::Status status; - upb_MiniTable* ret = _upb_MiniTable_Build(str.data(), str.size(), platform_, - arena_.ptr(), status.ptr()); - if (!ret) { - fprintf(stderr, "Error building mini-table: %s\n", status.error_message()); - } - assert(ret); - return ret; -} - -upb_MiniTable* FilePlatformLayout::MakeMessageSetMiniTable( - const protobuf::Descriptor* m) { - upb::MtDataEncoder e; - e.EncodeMessageSet(); - - const absl::string_view str = e.data(); - upb::Status status; - upb_MiniTable* ret = _upb_MiniTable_Build(str.data(), str.size(), platform_, - arena_.ptr(), status.ptr()); - if (!ret) { - fprintf(stderr, "Error building mini-table: %s\n", status.error_message()); - } - assert(ret); - return ret; -} - -upb_MiniTable* FilePlatformLayout::MakeRegularMiniTable( - const protobuf::Descriptor* m) { - upb::MtDataEncoder e; - e.StartMessage(GetMessageModifiers(m)); - for (const auto* f : FieldNumberOrder(m)) { - e.PutField(static_cast(f->type()), f->number(), - GetFieldModifiers(f)); - } - for (int i = 0; i < m->real_oneof_decl_count(); i++) { - const protobuf::OneofDescriptor* oneof = m->oneof_decl(i); - e.StartOneof(); - for (int j = 0; j < oneof->field_count(); j++) { - const protobuf::FieldDescriptor* f = oneof->field(j); - e.PutOneofField(f->number()); - } - } - absl::string_view str = e.data(); - upb::Status status; - upb_MiniTable* ret = _upb_MiniTable_Build(str.data(), str.size(), platform_, - arena_.ptr(), status.ptr()); - if (!ret) { - fprintf(stderr, "Error building mini-table: %s\n", status.error_message()); - } - assert(ret); - return ret; -} - -upb_MiniTableEnum* FilePlatformLayout::MakeMiniTableEnum( - const protobuf::EnumDescriptor* d) { - upb::Arena arena; - upb::MtDataEncoder e; - - e.StartEnum(); - for (uint32_t i : SortedUniqueEnumNumbers(d)) { - e.PutEnumValue(i); - } - e.EndEnum(); - - absl::string_view str = e.data(); - upb::Status status; - upb_MiniTableEnum* ret = upb_MiniTableEnum_Build(str.data(), str.size(), - arena_.ptr(), status.ptr()); - if (!ret) { - fprintf(stderr, "Error building mini-table: %s\n", status.error_message()); - } - assert(ret); - return ret; -} - -uint64_t FilePlatformLayout::GetMessageModifiers( - const protobuf::Descriptor* m) { - uint64_t ret = 0; - - if (m->file()->syntax() == protobuf::FileDescriptor::SYNTAX_PROTO3) { - ret |= kUpb_MessageModifier_ValidateUtf8; - ret |= kUpb_MessageModifier_DefaultIsPacked; - } - - if (m->extension_range_count() > 0) { - ret |= kUpb_MessageModifier_IsExtendable; - } - - assert(!m->options().map_entry()); - return ret; -} - -uint64_t FilePlatformLayout::GetFieldModifiers( - const protobuf::FieldDescriptor* f) { - uint64_t ret = 0; - - if (f->is_repeated()) ret |= kUpb_FieldModifier_IsRepeated; - if (f->is_required()) ret |= kUpb_FieldModifier_IsRequired; - if (f->is_packed()) ret |= kUpb_FieldModifier_IsPacked; - if (f->enum_type() && f->enum_type()->file()->syntax() == - protobuf::FileDescriptor::SYNTAX_PROTO2) { - ret |= kUpb_FieldModifier_IsClosedEnum; - } - if (f->is_optional() && !f->has_presence()) { - ret |= kUpb_FieldModifier_IsProto3Singular; - } - - return ret; -} - } // namespace upbc diff --git a/upbc/file_layout.h b/upbc/file_layout.h index 265dfe3c83..3acd3808cd 100644 --- a/upbc/file_layout.h +++ b/upbc/file_layout.h @@ -27,185 +27,97 @@ #include -#include "google/protobuf/descriptor.pb.h" +// begin:google_only +// #ifndef UPB_BOOTSTRAP_STAGE0 +// #include "net/proto2/proto/descriptor.upb.h" +// #else +// #include "google/protobuf/descriptor.upb.h" +// #endif +// end:google_only + +// begin:github_only +#include "google/protobuf/descriptor.upb.h" +// end:github_only + #include "absl/container/flat_hash_map.h" -#include "absl/strings/substitute.h" #include "upb/mini_table/decode.h" -#include "upb/mini_table/encode_internal.hpp" -#include "upb/mini_table/extension_internal.h" +#include "upb/reflection/def.h" +#include "upb/reflection/def.hpp" #include "upb/upb.hpp" -namespace upbc { +// Must be last +#include "upb/port/def.inc" -namespace protoc = ::google::protobuf::compiler; -namespace protobuf = ::google::protobuf; +namespace upbc { -std::vector SortedEnums( - const protobuf::FileDescriptor* file); +std::vector SortedEnums(upb::FileDefPtr file); // Ordering must match upb/def.c! // // The ordering is significant because each upb_MessageDef* will point at the // corresponding upb_MiniTable and we just iterate through the list without // any search or lookup. -std::vector SortedMessages( - const protobuf::FileDescriptor* file); +std::vector SortedMessages(upb::FileDefPtr file); // Ordering must match upb/def.c! // // The ordering is significant because each upb_FieldDef* will point at the // corresponding upb_MiniTableExtension and we just iterate through the list // without any search or lookup. -std::vector SortedExtensions( - const protobuf::FileDescriptor* file); - -std::vector FieldNumberOrder( - const protobuf::Descriptor* message); - -//////////////////////////////////////////////////////////////////////////////// -// FilePlatformLayout -//////////////////////////////////////////////////////////////////////////////// - -// FilePlatformLayout builds and vends upb MiniTables for a given platform (32 -// or 64 bit). -class FilePlatformLayout { - public: - FilePlatformLayout(const protobuf::FileDescriptor* fd, - upb_MiniTablePlatform platform) - : platform_(platform) { - BuildMiniTables(fd); - BuildExtensions(fd); - } - - // Retrieves a upb MiniTable or Extension given a protobuf descriptor. The - // descriptor must be from this layout's file. - upb_MiniTable* GetMiniTable(const protobuf::Descriptor* m) const; - upb_MiniTableEnum* GetEnumTable(const protobuf::EnumDescriptor* d) const; - const upb_MiniTableExtension* GetExtension( - const protobuf::FieldDescriptor* fd) const; - - // Get the initializer for the given sub-message/sub-enum link. - static std::string GetSub(upb_MiniTableSub sub); - - private: - // Functions to build mini-tables for this file's messages and extensions. - void BuildMiniTables(const protobuf::FileDescriptor* fd); - void BuildExtensions(const protobuf::FileDescriptor* fd); - upb_MiniTable* MakeMiniTable(const protobuf::Descriptor* m); - upb_MiniTable* MakeMapMiniTable(const protobuf::Descriptor* m); - upb_MiniTable* MakeMessageSetMiniTable(const protobuf::Descriptor* m); - upb_MiniTable* MakeRegularMiniTable(const protobuf::Descriptor* m); - upb_MiniTableEnum* MakeMiniTableEnum(const protobuf::EnumDescriptor* d); - uint64_t GetMessageModifiers(const protobuf::Descriptor* m); - uint64_t GetFieldModifiers(const protobuf::FieldDescriptor* f); - void ResolveIntraFileReferences(); - - // When we are generating code, tables are linked to sub-tables via name (ie. - // a string) rather than by pointer. We need to emit an initializer like - // `&foo_sub_table`. To do this, we store `const char*` strings in all the - // links that would normally be pointers: - // field -> sub-message - // field -> enum table (proto2 only) - // extension -> extendee - // - // This requires a bit of reinterpret_cast<>(), but it's confined to a few - // functions. We tag the pointer so we know which member of the union to - // initialize. - enum SubTag { - kNull = 0, - kMessage = 1, - kEnum = 2, - kMask = 3, - }; - - static upb_MiniTableSub PackSub(const char* data, SubTag tag); - static bool IsNull(upb_MiniTableSub sub); - void SetSubTableStrings(); - upb_MiniTableSub PackSubForField(const protobuf::FieldDescriptor* f, - const upb_MiniTableField* mt_f); - const char* AllocStr(absl::string_view str); +std::vector SortedExtensions(upb::FileDefPtr file); - private: - using TableMap = - absl::flat_hash_map; - using EnumMap = - absl::flat_hash_map; - using ExtensionMap = absl::flat_hash_map; - upb::Arena arena_; - TableMap table_map_; - EnumMap enum_map_; - ExtensionMap extension_map_; - upb_MiniTablePlatform platform_; -}; - -//////////////////////////////////////////////////////////////////////////////// -// FileLayout -//////////////////////////////////////////////////////////////////////////////// +std::vector FieldNumberOrder(upb::MessageDefPtr message); -// FileLayout is a pair of platform layouts: one for 32-bit and one for 64-bit. -class FileLayout { +// DefPoolPair is a pair of DefPools: one for 32-bit and one for 64-bit. +class DefPoolPair { public: - FileLayout(const protobuf::FileDescriptor* fd) - : descriptor_(fd), - layout32_(fd, kUpb_MiniTablePlatform_32Bit), - layout64_(fd, kUpb_MiniTablePlatform_64Bit) {} - - const protobuf::FileDescriptor* descriptor() const { return descriptor_; } - - const upb_MiniTable* GetMiniTable32(const protobuf::Descriptor* m) const { - return layout32_.GetMiniTable(m); - } - - const upb_MiniTable* GetMiniTable64(const protobuf::Descriptor* m) const { - return layout64_.GetMiniTable(m); - } - - const upb_MiniTableField* GetField32( - const protobuf::FieldDescriptor* f) const { - if (f->is_extension()) return &layout32_.GetExtension(f)->field; - return upb_MiniTable_FindFieldByNumber(GetMiniTable32(f->containing_type()), - f->number()); + DefPoolPair() { + pool32_._SetPlatform(kUpb_MiniTablePlatform_32Bit); + pool64_._SetPlatform(kUpb_MiniTablePlatform_64Bit); } - const upb_MiniTableField* GetField64( - const protobuf::FieldDescriptor* f) const { - if (f->is_extension()) return &layout64_.GetExtension(f)->field; - return upb_MiniTable_FindFieldByNumber(GetMiniTable64(f->containing_type()), - f->number()); + upb::FileDefPtr AddFile(const UPB_DESC(FileDescriptorProto) * file_proto, + upb::Status* status) { + upb::FileDefPtr file32 = pool32_.AddFile(file_proto, status); + upb::FileDefPtr file64 = pool64_.AddFile(file_proto, status); + if (!file32) return file32; + return file64; } - const upb_MiniTableEnum* GetEnumTable( - const protobuf::EnumDescriptor* d) const { - return layout64_.GetEnumTable(d); + const upb_MiniTable* GetMiniTable32(upb::MessageDefPtr m) const { + return pool32_.FindMessageByName(m.full_name()).mini_table(); } - std::string GetMessageSize(const protobuf::Descriptor* d) const { - return UpbSize(GetMiniTable32(d)->size, GetMiniTable64(d)->size); + const upb_MiniTable* GetMiniTable64(upb::MessageDefPtr m) const { + return pool64_.FindMessageByName(m.full_name()).mini_table(); } - int GetHasbitIndex(const protobuf::FieldDescriptor* f) const { - const upb_MiniTableField* f_64 = upb_MiniTable_FindFieldByNumber( - GetMiniTable64(f->containing_type()), f->number()); - return f_64->presence; + const upb_MiniTableField* GetField32(upb::FieldDefPtr f) const { + return GetFieldFromPool(&pool32_, f); } - bool HasHasbit(const protobuf::FieldDescriptor* f) const { - return GetHasbitIndex(f) > 0; + const upb_MiniTableField* GetField64(upb::FieldDefPtr f) const { + return GetFieldFromPool(&pool64_, f); } - template - static std::string UpbSize(T a, T b) { - if (a == b) return absl::Substitute("$0", a); - return absl::Substitute("UPB_SIZE($0, $1)", a, b); + private: + static const upb_MiniTableField* GetFieldFromPool(const upb::DefPool* pool, + upb::FieldDefPtr f) { + if (f.is_extension()) { + return pool->FindExtensionByName(f.full_name()).mini_table(); + } else { + return pool->FindMessageByName(f.containing_type().full_name()) + .FindFieldByNumber(f.number()) + .mini_table(); + } } - private: - const protobuf::FileDescriptor* descriptor_; - FilePlatformLayout layout32_; - FilePlatformLayout layout64_; + upb::DefPool pool32_; + upb::DefPool pool64_; }; } // namespace upbc +#include "upb/port/undef.inc" + #endif // UPBC_FILE_LAYOUT_H diff --git a/upbc/names.cc b/upbc/names.cc index d87a41d71d..6a74c05784 100644 --- a/upbc/names.cc +++ b/upbc/names.cc @@ -31,6 +31,7 @@ #include "absl/strings/match.h" #include "google/protobuf/descriptor.h" +#include "upb/reflection/def.hpp" namespace upbc { @@ -82,4 +83,36 @@ NameToFieldDescriptorMap CreateFieldNameMap( return field_names; } +NameToFieldDefMap CreateFieldNameMap(upb::MessageDefPtr message) { + NameToFieldDefMap field_names; + field_names.reserve(message.field_count()); + for (const auto& field : message.fields()) { + field_names.emplace(field.name(), field); + } + return field_names; +} + +std::string ResolveFieldName(upb::FieldDefPtr field, + const NameToFieldDefMap& field_names) { + absl::string_view field_name(field.name()); + for (absl::string_view prefix : kAccessorPrefixes) { + // If field name starts with a prefix such as clear_ and the proto + // contains a field name with trailing end, depending on type of field + // (repeated, map, message) we have a conflict to resolve. + if (absl::StartsWith(field_name, prefix)) { + auto match = field_names.find(field_name.substr(prefix.size())); + if (match != field_names.end()) { + const auto candidate = match->second; + if (candidate.IsSequence() || candidate.IsMap() || + (candidate.ctype() == kUpb_CType_String && + prefix == kClearAccessor) || + prefix == kSetAccessor) { + return absl::StrCat(field_name, "_"); + } + } + } + } + return std::string(field_name); +} + } // namespace upbc diff --git a/upbc/names.h b/upbc/names.h index 560d350b3b..7a6897f357 100644 --- a/upbc/names.h +++ b/upbc/names.h @@ -32,6 +32,7 @@ #include "absl/container/flat_hash_map.h" #include "google/protobuf/descriptor.h" +#include "upb/reflection/def.hpp" namespace upbc { @@ -46,6 +47,17 @@ std::string ResolveFieldName(const google::protobuf::FieldDescriptor* field, // Returns field map by name to use for conflict checks. NameToFieldDescriptorMap CreateFieldNameMap(const google::protobuf::Descriptor* message); +using NameToFieldDefMap = + absl::flat_hash_map; + +// Returns field name by resolving naming conflicts across +// proto field names (such as clear_ prefixes). +std::string ResolveFieldName(upb::FieldDefPtr field, + const NameToFieldDefMap& field_names); + +// Returns field map by name to use for conflict checks. +NameToFieldDefMap CreateFieldNameMap(upb::MessageDefPtr message); + } // namespace upbc #endif // UPB_PROTOS_GENERATOR_NAMES_H diff --git a/upbc/plugin.h b/upbc/plugin.h new file mode 100644 index 0000000000..7118ffa82c --- /dev/null +++ b/upbc/plugin.h @@ -0,0 +1,198 @@ +// Copyright (c) 2009-2021, Google LLC +// All rights reserved. +// +// 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 LLC 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 Google LLC 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. + +#ifndef UPB_UPBC_PLUGIN_H_ +#define UPB_UPBC_PLUGIN_H_ + +#include +#include + +// begin:google_only +// #ifndef UPB_BOOTSTRAP_STAGE0 +// #include "net/proto2/compiler/proto/plugin.upb.h" +// #include "net/proto2/proto/descriptor.upb.h" +// #else +// #include "google/protobuf/compiler/plugin.upb.h" +// #include "google/protobuf/descriptor.upb.h" +// #endif +// end:google_only + +// begin:github_only +#include "google/protobuf/compiler/plugin.upb.h" +#include "google/protobuf/descriptor.upb.h" +// end:github_only + +#include "absl/container/flat_hash_set.h" +#include "absl/log/log.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "upb/reflection/def.hpp" + +// Must be last. +#include "upb/port/def.inc" + +namespace upbc { + +inline std::vector> ParseGeneratorParameter( + const absl::string_view text) { + std::vector> ret; + for (absl::string_view sp : absl::StrSplit(text, ',', absl::SkipEmpty())) { + std::string::size_type equals_pos = sp.find_first_of('='); + std::pair value; + if (equals_pos == std::string::npos) { + value.first = std::string(sp); + } else { + value.first = std::string(sp.substr(0, equals_pos)); + value.second = std::string(sp.substr(equals_pos + 1)); + } + ret.push_back(std::move(value)); + } + return ret; +} + +class Plugin { + public: + Plugin() { ReadRequest(); } + ~Plugin() { WriteResponse(); } + + absl::string_view parameter() const { + return ToStringView( + UPB_DESC(compiler_CodeGeneratorRequest_parameter)(request_)); + } + + template + void GenerateFilesRaw(T&& func) { + absl::flat_hash_set files_to_generate; + size_t size; + const upb_StringView* file_to_generate = UPB_DESC( + compiler_CodeGeneratorRequest_file_to_generate)(request_, &size); + for (size_t i = 0; i < size; i++) { + files_to_generate.insert( + {file_to_generate[i].data, file_to_generate[i].size}); + } + + const UPB_DESC(FileDescriptorProto)* const* files = + UPB_DESC(compiler_CodeGeneratorRequest_proto_file)(request_, &size); + for (size_t i = 0; i < size; i++) { + upb::Status status; + absl::string_view name = + ToStringView(UPB_DESC(FileDescriptorProto_name)(files[i])); + func(files[i], files_to_generate.contains(name)); + } + } + + template + void GenerateFiles(T&& func) { + GenerateFilesRaw( + [this, &func](const UPB_DESC(FileDescriptorProto) * file_proto, + bool generate) { + upb::Status status; + upb::FileDefPtr file = pool_.AddFile(file_proto, &status); + if (!file) { + absl::string_view name = + ToStringView(UPB_DESC(FileDescriptorProto_name)(file_proto)); + LOG(FATAL) << "Couldn't add file " << name + << " to DefPool: " << status.error_message(); + } + if (generate) func(file); + }); + } + + void SetError(absl::string_view error) { + char* data = + static_cast(upb_Arena_Malloc(arena_.ptr(), error.size())); + memcpy(data, error.data(), error.size()); + UPB_DESC(compiler_CodeGeneratorResponse_set_error) + (response_, upb_StringView_FromDataAndSize(data, error.size())); + } + + void AddOutputFile(absl::string_view filename, absl::string_view content) { + UPB_DESC(compiler_CodeGeneratorResponse_File)* file = UPB_DESC( + compiler_CodeGeneratorResponse_add_file)(response_, arena_.ptr()); + UPB_DESC(compiler_CodeGeneratorResponse_File_set_name) + (file, StringDup(filename)); + UPB_DESC(compiler_CodeGeneratorResponse_File_set_content) + (file, StringDup(content)); + } + + private: + upb::Arena arena_; + upb::DefPool pool_; + UPB_DESC(compiler_CodeGeneratorRequest) * request_; + UPB_DESC(compiler_CodeGeneratorResponse) * response_; + + static absl::string_view ToStringView(upb_StringView sv) { + return absl::string_view(sv.data, sv.size); + } + + upb_StringView StringDup(absl::string_view s) { + char* data = + reinterpret_cast(upb_Arena_Malloc(arena_.ptr(), s.size())); + memcpy(data, s.data(), s.size()); + return upb_StringView_FromDataAndSize(data, s.size()); + } + + std::string ReadAllStdinBinary() { + std::string data; + stdin = freopen(nullptr, "rb", stdin); + char buf[4096]; + while (size_t len = fread(buf, 1, sizeof(buf), stdin)) { + data.append(buf, len); + } + return data; + } + + void ReadRequest() { + std::string data = ReadAllStdinBinary(); + request_ = UPB_DESC(compiler_CodeGeneratorRequest_parse)( + data.data(), data.size(), arena_.ptr()); + if (!request_) { + LOG(FATAL) << "Failed to parse CodeGeneratorRequest"; + } + response_ = UPB_DESC(compiler_CodeGeneratorResponse_new)(arena_.ptr()); + UPB_DESC(compiler_CodeGeneratorResponse_set_supported_features) + (response_, + UPB_DESC(compiler_CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)); + } + + void WriteResponse() { + size_t size; + char* serialized = UPB_DESC(compiler_CodeGeneratorResponse_serialize)( + response_, arena_.ptr(), &size); + if (!serialized) { + LOG(FATAL) << "Failed to serialize CodeGeneratorResponse"; + } + + if (fwrite(serialized, 1, size, stdout) != size) { + LOG(FATAL) << "Failed to write response to stdout"; + } + } +}; + +} // namespace upbc + +#include "upb/port/undef.inc" + +#endif // UPB_UPBC_PLUGIN_H_ diff --git a/upbc/protoc-gen-upb.cc b/upbc/protoc-gen-upb.cc index c20d00210d..3b5f4d6da7 100644 --- a/upbc/protoc-gen-upb.cc +++ b/upbc/protoc-gen-upb.cc @@ -23,23 +23,42 @@ // (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 #include -#include "google/protobuf/descriptor.pb.h" +// begin:google_only +// #ifndef UPB_BOOTSTRAP_STAGE0 +// #include "net/proto2/proto/descriptor.upb.h" +// #else +// #include "google/protobuf/descriptor.upb.h" +// #endif +// end:google_only + +// begin:github_only +#include "google/protobuf/descriptor.upb.h" +// end:github_only + #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" +#include "absl/log/check.h" +#include "absl/log/log.h" +#include "absl/strings/escaping.h" +#include "absl/strings/string_view.h" #include "absl/strings/substitute.h" -#include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/compiler/plugin.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/wire_format.h" -#include "upb/mini_table/encode_internal.hpp" +#include "upb/base/descriptor_constants.h" +#include "upb/base/string_view.h" +#include "upb/mem/arena.h" #include "upb/mini_table/enum_internal.h" #include "upb/mini_table/extension_internal.h" +#include "upb/reflection/def.hpp" +#include "upb/wire/types.h" #include "upbc/common.h" #include "upbc/file_layout.h" #include "upbc/names.h" +#include "upbc/plugin.h" // Must be last. #include "upb/port/def.inc" @@ -47,92 +66,109 @@ namespace upbc { namespace { -namespace protoc = ::google::protobuf::compiler; -namespace protobuf = ::google::protobuf; +struct Options { + bool bootstrap = false; +}; // Returns fields in order of "hotness", eg. how frequently they appear in // serialized payloads. Ideally this will use a profile. When we don't have // that, we assume that fields with smaller numbers are used more frequently. -inline std::vector FieldHotnessOrder( - const google::protobuf::Descriptor* message) { - std::vector fields; - size_t field_count = message->field_count(); +inline std::vector FieldHotnessOrder( + upb::MessageDefPtr message) { + std::vector fields; + size_t field_count = message.field_count(); fields.reserve(field_count); for (size_t i = 0; i < field_count; i++) { - fields.push_back(message->field(i)); - } - std::sort( - fields.begin(), fields.end(), - [](const google::protobuf::FieldDescriptor* a, const google::protobuf::FieldDescriptor* b) { - return std::make_pair(!a->is_required(), a->number()) < - std::make_pair(!b->is_required(), b->number()); - }); + fields.push_back(message.field(i)); + } + std::sort(fields.begin(), fields.end(), + [](upb::FieldDefPtr a, upb::FieldDefPtr b) { + return std::make_pair(!a.is_required(), a.number()) < + std::make_pair(!b.is_required(), b.number()); + }); return fields; } -std::string SourceFilename(const google::protobuf::FileDescriptor* file) { - return StripExtension(file->name()) + ".upb.c"; +std::string SourceFilename(upb::FileDefPtr file) { + return StripExtension(file.name()) + ".upb.c"; +} + +std::string MessageInitName(upb::MessageDefPtr descriptor) { + return absl::StrCat(MessageName(descriptor), "_msg_init"); } -std::string MessageInit(const protobuf::Descriptor* descriptor) { - return MessageName(descriptor) + "_msg_init"; +std::string MessageMiniTableRef(upb::MessageDefPtr descriptor, + const Options& options) { + if (options.bootstrap) { + return absl::StrCat(MessageInitName(descriptor), "()"); + } else { + return absl::StrCat("&", MessageInitName(descriptor)); + } } -std::string EnumInit(const protobuf::EnumDescriptor* descriptor) { - return ToCIdent(descriptor->full_name()) + "_enum_init"; +std::string EnumInitName(upb::EnumDefPtr descriptor) { + return ToCIdent(descriptor.full_name()) + "_enum_init"; } -std::string ExtensionIdentBase(const protobuf::FieldDescriptor* ext) { - assert(ext->is_extension()); +std::string EnumMiniTableRef(upb::EnumDefPtr descriptor, + const Options& options) { + if (options.bootstrap) { + return absl::StrCat(EnumInitName(descriptor), "()"); + } else { + return absl::StrCat("&", EnumInitName(descriptor)); + } +} + +std::string ExtensionIdentBase(upb::FieldDefPtr ext) { + assert(ext.is_extension()); std::string ext_scope; - if (ext->extension_scope()) { - return MessageName(ext->extension_scope()); + if (ext.extension_scope()) { + return MessageName(ext.extension_scope()); } else { - return ToCIdent(ext->file()->package()); + return ToCIdent(ext.file().package()); } } -std::string ExtensionLayout(const google::protobuf::FieldDescriptor* ext) { - return absl::StrCat(ExtensionIdentBase(ext), "_", ext->name(), "_ext"); +std::string ExtensionLayout(upb::FieldDefPtr ext) { + return absl::StrCat(ExtensionIdentBase(ext), "_", ext.name(), "_ext"); } const char* kEnumsInit = "enums_layout"; const char* kExtensionsInit = "extensions_layout"; const char* kMessagesInit = "messages_layout"; -std::string EnumValueSymbol(const protobuf::EnumValueDescriptor* value) { - return ToCIdent(value->full_name()); +std::string EnumValueSymbol(upb::EnumValDefPtr value) { + return ToCIdent(value.full_name()); } -std::string CTypeInternal(const protobuf::FieldDescriptor* field, - bool is_const) { +std::string CTypeInternal(upb::FieldDefPtr field, bool is_const) { std::string maybe_const = is_const ? "const " : ""; - switch (field->cpp_type()) { - case protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { + switch (field.ctype()) { + case kUpb_CType_Message: { std::string maybe_struct = - field->file() != field->message_type()->file() ? "struct " : ""; - return maybe_const + maybe_struct + MessageName(field->message_type()) + + field.file() != field.message_type().file() ? "struct " : ""; + return maybe_const + maybe_struct + MessageName(field.message_type()) + "*"; } - case protobuf::FieldDescriptor::CPPTYPE_BOOL: + case kUpb_CType_Bool: return "bool"; - case protobuf::FieldDescriptor::CPPTYPE_FLOAT: + case kUpb_CType_Float: return "float"; - case protobuf::FieldDescriptor::CPPTYPE_INT32: - case protobuf::FieldDescriptor::CPPTYPE_ENUM: + case kUpb_CType_Int32: + case kUpb_CType_Enum: return "int32_t"; - case protobuf::FieldDescriptor::CPPTYPE_UINT32: + case kUpb_CType_UInt32: return "uint32_t"; - case protobuf::FieldDescriptor::CPPTYPE_DOUBLE: + case kUpb_CType_Double: return "double"; - case protobuf::FieldDescriptor::CPPTYPE_INT64: + case kUpb_CType_Int64: return "int64_t"; - case protobuf::FieldDescriptor::CPPTYPE_UINT64: + case kUpb_CType_UInt64: return "uint64_t"; - case protobuf::FieldDescriptor::CPPTYPE_STRING: + case kUpb_CType_String: + case kUpb_CType_Bytes: return "upb_StringView"; default: - fprintf(stderr, "Unexpected type"); abort(); } } @@ -161,85 +197,87 @@ std::string DoubleToCLiteral(double value) { } } -std::string FieldDefault(const protobuf::FieldDescriptor* field) { - switch (field->cpp_type()) { - case protobuf::FieldDescriptor::CPPTYPE_MESSAGE: +std::string FieldDefault(upb::FieldDefPtr field) { + switch (field.ctype()) { + case kUpb_CType_Message: return "NULL"; - case protobuf::FieldDescriptor::CPPTYPE_STRING: - return absl::Substitute("upb_StringView_FromString(\"$0\")", - absl::CEscape(field->default_value_string())); - case protobuf::FieldDescriptor::CPPTYPE_INT32: - return absl::Substitute("(int32_t)$0", field->default_value_int32()); - case protobuf::FieldDescriptor::CPPTYPE_INT64: - return absl::Substitute("(int64_t)$0ll", field->default_value_int64()); - case protobuf::FieldDescriptor::CPPTYPE_UINT32: - return absl::Substitute("(uint32_t)$0u", field->default_value_uint32()); - case protobuf::FieldDescriptor::CPPTYPE_UINT64: - return absl::Substitute("(uint64_t)$0ull", field->default_value_uint64()); - case protobuf::FieldDescriptor::CPPTYPE_FLOAT: - return FloatToCLiteral(field->default_value_float()); - case protobuf::FieldDescriptor::CPPTYPE_DOUBLE: - return DoubleToCLiteral(field->default_value_double()); - case protobuf::FieldDescriptor::CPPTYPE_BOOL: - return field->default_value_bool() ? "true" : "false"; - case protobuf::FieldDescriptor::CPPTYPE_ENUM: + case kUpb_CType_Bytes: + case kUpb_CType_String: { + upb_StringView str = field.default_value().str_val; + return absl::Substitute( + "upb_StringView_FromString(\"$0\")", + absl::CEscape(absl::string_view(str.data, str.size))); + } + case kUpb_CType_Int32: + return absl::Substitute("(int32_t)$0", field.default_value().int32_val); + case kUpb_CType_Int64: + return absl::Substitute("(int64_t)$0ll", field.default_value().int64_val); + case kUpb_CType_UInt32: + return absl::Substitute("(uint32_t)$0u", + field.default_value().uint32_val); + case kUpb_CType_UInt64: + return absl::Substitute("(uint64_t)$0ull", + field.default_value().uint64_val); + case kUpb_CType_Float: + return FloatToCLiteral(field.default_value().float_val); + case kUpb_CType_Double: + return DoubleToCLiteral(field.default_value().double_val); + case kUpb_CType_Bool: + return field.default_value().bool_val ? "true" : "false"; + case kUpb_CType_Enum: // Use a number instead of a symbolic name so that we don't require // this enum's header to be included. - return absl::StrCat(field->default_value_enum()->number()); + return absl::StrCat(field.default_value().int32_val); } ABSL_ASSERT(false); return "XXX"; } -std::string CType(const protobuf::FieldDescriptor* field) { +std::string CType(upb::FieldDefPtr field) { return CTypeInternal(field, false); } -std::string CTypeConst(const protobuf::FieldDescriptor* field) { +std::string CTypeConst(upb::FieldDefPtr field) { return CTypeInternal(field, true); } -std::string MapKeyCType(const protobuf::FieldDescriptor* map_field) { - return CType(map_field->message_type()->map_key()); +std::string MapKeyCType(upb::FieldDefPtr map_field) { + return CType(map_field.message_type().map_key()); } -std::string MapValueCType(const protobuf::FieldDescriptor* map_field) { - return CType(map_field->message_type()->map_value()); +std::string MapValueCType(upb::FieldDefPtr map_field) { + return CType(map_field.message_type().map_value()); } -std::string MapKeySize(const protobuf::FieldDescriptor* map_field, - absl::string_view expr) { - return map_field->message_type()->map_key()->cpp_type() == - protobuf::FieldDescriptor::CPPTYPE_STRING +std::string MapKeySize(upb::FieldDefPtr map_field, absl::string_view expr) { + return map_field.message_type().map_key().ctype() == kUpb_CType_String ? "0" : absl::StrCat("sizeof(", expr, ")"); } -std::string MapValueSize(const protobuf::FieldDescriptor* map_field, - absl::string_view expr) { - return map_field->message_type()->map_value()->cpp_type() == - protobuf::FieldDescriptor::CPPTYPE_STRING +std::string MapValueSize(upb::FieldDefPtr map_field, absl::string_view expr) { + return map_field.message_type().map_value().ctype() == kUpb_CType_String ? "0" : absl::StrCat("sizeof(", expr, ")"); } -std::string FieldInitializer(const FileLayout& layout, - const protobuf::FieldDescriptor* field); +std::string FieldInitializer(const DefPoolPair& pools, upb::FieldDefPtr field, + const Options& options); -void DumpEnumValues(const protobuf::EnumDescriptor* desc, Output& output) { - std::vector values; - for (int i = 0; i < desc->value_count(); i++) { - values.push_back(desc->value(i)); +void DumpEnumValues(upb::EnumDefPtr desc, Output& output) { + std::vector values; + values.reserve(desc.value_count()); + for (int i = 0; i < desc.value_count(); i++) { + values.push_back(desc.value(i)); } std::sort(values.begin(), values.end(), - [](const protobuf::EnumValueDescriptor* a, - const protobuf::EnumValueDescriptor* b) { - return a->number() < b->number(); + [](upb::EnumValDefPtr a, upb::EnumValDefPtr b) { + return a.number() < b.number(); }); for (size_t i = 0; i < values.size(); i++) { auto value = values[i]; - output(" $0 = $1", EnumValueSymbol(value), value->number()); + output(" $0 = $1", EnumValueSymbol(value), value.number()); if (i != values.size() - 1) { output(","); } @@ -247,18 +285,17 @@ void DumpEnumValues(const protobuf::EnumDescriptor* desc, Output& output) { } } -std::string GetFieldRep(const FileLayout& layout, - const protobuf::FieldDescriptor* field); +std::string GetFieldRep(const DefPoolPair& pools, upb::FieldDefPtr field); -void GenerateExtensionInHeader(const protobuf::FieldDescriptor* ext, - const FileLayout& layout, Output& output) { +void GenerateExtensionInHeader(const DefPoolPair& pools, upb::FieldDefPtr ext, + Output& output) { output( R"cc( UPB_INLINE bool $0_has_$1(const struct $2* msg) { return _upb_Message_HasExtensionField(msg, &$3); } )cc", - ExtensionIdentBase(ext), ext->name(), MessageName(ext->containing_type()), + ExtensionIdentBase(ext), ext.name(), MessageName(ext.containing_type()), ExtensionLayout(ext)); output( @@ -267,10 +304,10 @@ void GenerateExtensionInHeader(const protobuf::FieldDescriptor* ext, _upb_Message_ClearExtensionField(msg, &$3); } )cc", - ExtensionIdentBase(ext), ext->name(), MessageName(ext->containing_type()), + ExtensionIdentBase(ext), ext.name(), MessageName(ext.containing_type()), ExtensionLayout(ext)); - if (ext->is_repeated()) { + if (ext.IsSequence()) { // TODO(b/259861668): We need generated accessors for repeated extensions. } else { output( @@ -285,9 +322,9 @@ void GenerateExtensionInHeader(const protobuf::FieldDescriptor* ext, return ret; } )cc", - CTypeConst(ext), ExtensionIdentBase(ext), ext->name(), - MessageName(ext->containing_type()), ExtensionLayout(ext), - GetFieldRep(layout, ext), FieldDefault(ext)); + CTypeConst(ext), ExtensionIdentBase(ext), ext.name(), + MessageName(ext.containing_type()), ExtensionLayout(ext), + GetFieldRep(pools, ext), FieldDefault(ext)); output( R"cc( UPB_INLINE void $1_set_$2(struct $3* msg, $0 val, upb_Arena* arena) { @@ -298,25 +335,25 @@ void GenerateExtensionInHeader(const protobuf::FieldDescriptor* ext, UPB_ASSERT(ok); } )cc", - CTypeConst(ext), ExtensionIdentBase(ext), ext->name(), - MessageName(ext->containing_type()), ExtensionLayout(ext), - GetFieldRep(layout, ext)); + CTypeConst(ext), ExtensionIdentBase(ext), ext.name(), + MessageName(ext.containing_type()), ExtensionLayout(ext), + GetFieldRep(pools, ext)); } } -void GenerateMessageFunctionsInHeader(const protobuf::Descriptor* message, - Output& output) { +void GenerateMessageFunctionsInHeader(upb::MessageDefPtr message, + const Options& options, Output& output) { // TODO(b/235839510): The generated code here does not check the return values // from upb_Encode(). How can we even fix this without breaking other things? output( R"cc( UPB_INLINE $0* $0_new(upb_Arena* arena) { - return ($0*)_upb_Message_New(&$1, arena); + return ($0*)_upb_Message_New($1, arena); } UPB_INLINE $0* $0_parse(const char* buf, size_t size, upb_Arena* arena) { $0* ret = $0_new(arena); if (!ret) return NULL; - if (upb_Decode(buf, size, ret, &$1, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + if (upb_Decode(buf, size, ret, $1, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; @@ -326,7 +363,7 @@ void GenerateMessageFunctionsInHeader(const protobuf::Descriptor* message, int options, upb_Arena* arena) { $0* ret = $0_new(arena); if (!ret) return NULL; - if (upb_Decode(buf, size, ret, &$1, extreg, options, arena) != + if (upb_Decode(buf, size, ret, $1, extreg, options, arena) != kUpb_DecodeStatus_Ok) { return NULL; } @@ -334,27 +371,27 @@ void GenerateMessageFunctionsInHeader(const protobuf::Descriptor* message, } UPB_INLINE char* $0_serialize(const $0* msg, upb_Arena* arena, size_t* len) { char* ptr; - (void)upb_Encode(msg, &$1, 0, arena, &ptr, len); + (void)upb_Encode(msg, $1, 0, arena, &ptr, len); return ptr; } UPB_INLINE char* $0_serialize_ex(const $0* msg, int options, upb_Arena* arena, size_t* len) { char* ptr; - (void)upb_Encode(msg, &$1, options, arena, &ptr, len); + (void)upb_Encode(msg, $1, options, arena, &ptr, len); return ptr; } )cc", - MessageName(message), MessageInit(message)); + MessageName(message), MessageMiniTableRef(message, options)); } -void GenerateOneofInHeader(const protobuf::OneofDescriptor* oneof, - const FileLayout& layout, absl::string_view msg_name, +void GenerateOneofInHeader(upb::OneofDefPtr oneof, const DefPoolPair& pools, + absl::string_view msg_name, const Options& options, Output& output) { - std::string fullname = ToCIdent(oneof->full_name()); + std::string fullname = ToCIdent(oneof.full_name()); output("typedef enum {\n"); - for (int j = 0; j < oneof->field_count(); j++) { - const protobuf::FieldDescriptor* field = oneof->field(j); - output(" $0_$1 = $2,\n", fullname, field->name(), field->number()); + for (int j = 0; j < oneof.field_count(); j++) { + upb::FieldDefPtr field = oneof.field(j); + output(" $0_$1 = $2,\n", fullname, field.name(), field.number()); } output( " $0_NOT_SET = 0\n" @@ -367,16 +404,16 @@ void GenerateOneofInHeader(const protobuf::OneofDescriptor* oneof, return ($0_oneofcases)upb_Message_WhichOneofFieldNumber(msg, &field); } )cc", - fullname, msg_name, oneof->name(), - FieldInitializer(layout, oneof->field(0))); + fullname, msg_name, oneof.name(), + FieldInitializer(pools, oneof.field(0), options)); } -void GenerateHazzer(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { +void GenerateHazzer(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { std::string resolved_name = ResolveFieldName(field, field_names); - if (field->has_presence()) { + if (field.has_presence()) { output( R"cc( UPB_INLINE bool $0_has_$1(const $0* msg) { @@ -384,8 +421,8 @@ void GenerateHazzer(const protobuf::FieldDescriptor* field, return _upb_Message_HasNonExtensionField(msg, &field); } )cc", - msg_name, resolved_name, FieldInitializer(layout, field)); - } else if (field->is_map()) { + msg_name, resolved_name, FieldInitializer(pools, field, options)); + } else if (field.IsMap()) { // TODO(b/259616267): remove. output( R"cc( @@ -394,7 +431,7 @@ void GenerateHazzer(const protobuf::FieldDescriptor* field, } )cc", msg_name, resolved_name); - } else if (field->is_repeated()) { + } else if (field.IsSequence()) { // TODO(b/259616267): remove. output( R"cc( @@ -408,12 +445,12 @@ void GenerateHazzer(const protobuf::FieldDescriptor* field, } } -void GenerateClear(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, +void GenerateClear(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, const Options& options, Output& output) { - if (field == field->containing_type()->map_key() || - field == field->containing_type()->map_value()) { + if (field == field.containing_type().map_key() || + field == field.containing_type().map_value()) { // Cannot be cleared. return; } @@ -425,13 +462,13 @@ void GenerateClear(const protobuf::FieldDescriptor* field, _upb_Message_ClearNonExtensionField(msg, &field); } )cc", - msg_name, resolved_name, FieldInitializer(layout, field)); + msg_name, resolved_name, FieldInitializer(pools, field, options)); } -void GenerateMapGetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { +void GenerateMapGetters(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { std::string resolved_name = ResolveFieldName(field, field_names); output( R"cc( @@ -441,7 +478,7 @@ void GenerateMapGetters(const protobuf::FieldDescriptor* field, return map ? _upb_Map_Size(map) : 0; } )cc", - msg_name, resolved_name, FieldInitializer(layout, field)); + msg_name, resolved_name, FieldInitializer(pools, field, options)); output( R"cc( UPB_INLINE bool $0_$1_get(const $0* msg, $2 key, $3* val) { @@ -452,7 +489,7 @@ void GenerateMapGetters(const protobuf::FieldDescriptor* field, } )cc", msg_name, resolved_name, MapKeyCType(field), MapValueCType(field), - FieldInitializer(layout, field), MapKeySize(field, "key"), + FieldInitializer(pools, field, options), MapKeySize(field, "key"), MapValueSize(field, "*val")); output( R"cc( @@ -464,11 +501,11 @@ void GenerateMapGetters(const protobuf::FieldDescriptor* field, } )cc", CTypeConst(field), msg_name, resolved_name, - FieldInitializer(layout, field)); + FieldInitializer(pools, field, options)); } -void GenerateMapEntryGetters(const protobuf::FieldDescriptor* field, - absl::string_view msg_name, Output& output) { +void GenerateMapEntryGetters(upb::FieldDefPtr field, absl::string_view msg_name, + Output& output) { output( R"cc( UPB_INLINE $0 $1_$2(const $1* msg) { @@ -477,17 +514,14 @@ void GenerateMapEntryGetters(const protobuf::FieldDescriptor* field, return ret; } )cc", - CTypeConst(field), msg_name, field->name(), CType(field), - field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING - ? "0" - : "sizeof(ret)"); + CTypeConst(field), msg_name, field.name(), CType(field), + field.ctype() == kUpb_CType_String ? "0" : "sizeof(ret)"); } -void GenerateRepeatedGetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, +void GenerateRepeatedGetters(upb::FieldDefPtr field, const DefPoolPair& pools, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { output( R"cc( UPB_INLINE $0 const* $1_$2(const $1* msg, size_t* size) { @@ -503,13 +537,13 @@ void GenerateRepeatedGetters(const protobuf::FieldDescriptor* field, } )cc", CTypeConst(field), msg_name, ResolveFieldName(field, field_names), - FieldInitializer(layout, field)); + FieldInitializer(pools, field, options)); } -void GenerateScalarGetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { +void GenerateScalarGetters(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, + const Options& Options, Output& output) { std::string field_name = ResolveFieldName(field, field_names); output( R"cc( @@ -522,28 +556,30 @@ void GenerateScalarGetters(const protobuf::FieldDescriptor* field, } )cc", CTypeConst(field), msg_name, field_name, FieldDefault(field), - FieldInitializer(layout, field)); + FieldInitializer(pools, field, Options)); } -void GenerateGetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { - if (field->is_map()) { - GenerateMapGetters(field, layout, msg_name, field_names, output); - } else if (field->containing_type()->options().map_entry()) { +void GenerateGetters(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { + if (field.IsMap()) { + GenerateMapGetters(field, pools, msg_name, field_names, options, output); + } else if (UPB_DESC(MessageOptions_map_entry)( + field.containing_type().options())) { GenerateMapEntryGetters(field, msg_name, output); - } else if (field->is_repeated()) { - GenerateRepeatedGetters(field, layout, msg_name, field_names, output); + } else if (field.IsSequence()) { + GenerateRepeatedGetters(field, pools, msg_name, field_names, options, + output); } else { - GenerateScalarGetters(field, layout, msg_name, field_names, output); + GenerateScalarGetters(field, pools, msg_name, field_names, options, output); } } -void GenerateMapSetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { +void GenerateMapSetters(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { std::string resolved_name = ResolveFieldName(field, field_names); output( R"cc( @@ -554,7 +590,7 @@ void GenerateMapSetters(const protobuf::FieldDescriptor* field, _upb_Map_Clear(map); } )cc", - msg_name, resolved_name, FieldInitializer(layout, field)); + msg_name, resolved_name, FieldInitializer(pools, field, options)); output( R"cc( UPB_INLINE bool $0_$1_set($0* msg, $2 key, $3 val, upb_Arena* a) { @@ -565,7 +601,7 @@ void GenerateMapSetters(const protobuf::FieldDescriptor* field, } )cc", msg_name, resolved_name, MapKeyCType(field), MapValueCType(field), - FieldInitializer(layout, field), MapKeySize(field, "key"), + FieldInitializer(pools, field, options), MapKeySize(field, "key"), MapValueSize(field, "val")); output( R"cc( @@ -577,7 +613,7 @@ void GenerateMapSetters(const protobuf::FieldDescriptor* field, } )cc", msg_name, resolved_name, MapKeyCType(field), - FieldInitializer(layout, field), MapKeySize(field, "key")); + FieldInitializer(pools, field, options), MapKeySize(field, "key")); output( R"cc( UPB_INLINE $0 $1_$2_nextmutable($1* msg, size_t* iter) { @@ -587,14 +623,14 @@ void GenerateMapSetters(const protobuf::FieldDescriptor* field, return ($0)_upb_map_next(map, iter); } )cc", - CType(field), msg_name, resolved_name, FieldInitializer(layout, field)); + CType(field), msg_name, resolved_name, + FieldInitializer(pools, field, options)); } -void GenerateRepeatedSetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, +void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { std::string resolved_name = ResolveFieldName(field, field_names); output( R"cc( @@ -610,7 +646,8 @@ void GenerateRepeatedSetters(const protobuf::FieldDescriptor* field, } } )cc", - CType(field), msg_name, resolved_name, FieldInitializer(layout, field)); + CType(field), msg_name, resolved_name, + FieldInitializer(pools, field, options)); output( R"cc( UPB_INLINE $0* $1_resize_$2($1* msg, size_t size, upb_Arena* arena) { @@ -618,8 +655,9 @@ void GenerateRepeatedSetters(const protobuf::FieldDescriptor* field, return ($0*)upb_Message_ResizeArray(msg, &field, size, arena); } )cc", - CType(field), msg_name, resolved_name, FieldInitializer(layout, field)); - if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { + CType(field), msg_name, resolved_name, + FieldInitializer(pools, field, options)); + if (field.ctype() == kUpb_CType_Message) { output( R"cc( UPB_INLINE struct $0* $1_add_$2($1* msg, upb_Arena* arena) { @@ -628,14 +666,15 @@ void GenerateRepeatedSetters(const protobuf::FieldDescriptor* field, if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { return NULL; } - struct $0* sub = (struct $0*)_upb_Message_New(&$3, arena); + struct $0* sub = (struct $0*)_upb_Message_New($3, arena); if (!arr || !sub) return NULL; _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); return sub; } )cc", - MessageName(field->message_type()), msg_name, resolved_name, - MessageInit(field->message_type()), FieldInitializer(layout, field)); + MessageName(field.message_type()), msg_name, resolved_name, + MessageMiniTableRef(field.message_type(), options), + FieldInitializer(pools, field, options)); } else { output( R"cc( @@ -649,104 +688,119 @@ void GenerateRepeatedSetters(const protobuf::FieldDescriptor* field, return true; } )cc", - CType(field), msg_name, resolved_name, FieldInitializer(layout, field)); + CType(field), msg_name, resolved_name, + FieldInitializer(pools, field, options)); } } -void GenerateNonRepeatedSetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, +void GenerateNonRepeatedSetters(upb::FieldDefPtr field, + const DefPoolPair& pools, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { - if (field == field->containing_type()->map_key()) { + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { + if (field == field.containing_type().map_key()) { // Key cannot be mutated. return; } std::string field_name = ResolveFieldName(field, field_names); - if (field == field->containing_type()->map_value()) { + if (field == field.containing_type().map_value()) { output(R"cc( UPB_INLINE void $0_set_$1($0 *msg, $2 value) { _upb_msg_map_set_value(msg, &value, $3); - })cc", + } + )cc", msg_name, field_name, CType(field), - field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING - ? "0" - : "sizeof(" + CType(field) + ")"); + field.ctype() == kUpb_CType_String ? "0" + : "sizeof(" + CType(field) + ")"); } else { output(R"cc( UPB_INLINE void $0_set_$1($0 *msg, $2 value) { const upb_MiniTableField field = $3; _upb_Message_SetNonExtensionField(msg, &field, &value); - })cc", - msg_name, field_name, CType(field), FieldInitializer(layout, field)); + } + )cc", + msg_name, field_name, CType(field), + FieldInitializer(pools, field, options)); } // Message fields also have a Msg_mutable_foo() accessor that will create // the sub-message if it doesn't already exist. - if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE && - !field->containing_type()->options().map_entry()) { + if (field.ctype() == kUpb_CType_Message && + !UPB_DESC(MessageOptions_map_entry)(field.containing_type().options())) { output( R"cc( UPB_INLINE struct $0* $1_mutable_$2($1* msg, upb_Arena* arena) { struct $0* sub = (struct $0*)$1_$2(msg); if (sub == NULL) { - sub = (struct $0*)_upb_Message_New(&$3, arena); + sub = (struct $0*)_upb_Message_New($3, arena); if (sub) $1_set_$2(msg, sub); } return sub; } )cc", - MessageName(field->message_type()), msg_name, field_name, - MessageInit(field->message_type())); + MessageName(field.message_type()), msg_name, field_name, + MessageMiniTableRef(field.message_type(), options)); } } -void GenerateSetters(const protobuf::FieldDescriptor* field, - const FileLayout& layout, absl::string_view msg_name, - const NameToFieldDescriptorMap& field_names, - Output& output) { - if (field->is_map()) { - GenerateMapSetters(field, layout, msg_name, field_names, output); - } else if (field->is_repeated()) { - GenerateRepeatedSetters(field, layout, msg_name, field_names, output); +void GenerateSetters(upb::FieldDefPtr field, const DefPoolPair& pools, + absl::string_view msg_name, + const NameToFieldDefMap& field_names, + const Options& options, Output& output) { + if (field.IsMap()) { + GenerateMapSetters(field, pools, msg_name, field_names, options, output); + } else if (field.IsSequence()) { + GenerateRepeatedSetters(field, pools, msg_name, field_names, options, + output); } else { - GenerateNonRepeatedSetters(field, layout, msg_name, field_names, output); + GenerateNonRepeatedSetters(field, pools, msg_name, field_names, options, + output); } } -void GenerateMessageInHeader(const protobuf::Descriptor* message, - const FileLayout& layout, Output& output) { - output("/* $0 */\n\n", message->full_name()); - std::string msg_name = ToCIdent(message->full_name()); - if (!message->options().map_entry()) { - GenerateMessageFunctionsInHeader(message, output); +void GenerateMessageInHeader(upb::MessageDefPtr message, + const DefPoolPair& pools, const Options& options, + Output& output) { + output("/* $0 */\n\n", message.full_name()); + std::string msg_name = ToCIdent(message.full_name()); + if (!UPB_DESC(MessageOptions_map_entry)(message.options())) { + GenerateMessageFunctionsInHeader(message, options, output); } - for (int i = 0; i < message->real_oneof_decl_count(); i++) { - GenerateOneofInHeader(message->oneof_decl(i), layout, msg_name, output); + for (int i = 0; i < message.real_oneof_count(); i++) { + GenerateOneofInHeader(message.oneof(i), pools, msg_name, options, output); } auto field_names = CreateFieldNameMap(message); for (auto field : FieldNumberOrder(message)) { - GenerateClear(field, layout, msg_name, field_names, output); - GenerateGetters(field, layout, msg_name, field_names, output); - GenerateHazzer(field, layout, msg_name, field_names, output); + GenerateClear(field, pools, msg_name, field_names, options, output); + GenerateGetters(field, pools, msg_name, field_names, options, output); + GenerateHazzer(field, pools, msg_name, field_names, options, output); } output("\n"); for (auto field : FieldNumberOrder(message)) { - GenerateSetters(field, layout, msg_name, field_names, output); + GenerateSetters(field, pools, msg_name, field_names, options, output); } output("\n"); } -void WriteHeader(const FileLayout& layout, Output& output) { - const protobuf::FileDescriptor* file = layout.descriptor(); - EmitFileWarning(file, output); +void ForwardDeclareMiniTableInit(upb::MessageDefPtr message, + const Options& options, Output& output) { + if (options.bootstrap) { + output("extern const upb_MiniTable* $0();\n", MessageInitName(message)); + } else { + output("extern const upb_MiniTable $0;\n", MessageInitName(message)); + } +} + +void WriteHeader(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Output& output) { + EmitFileWarning(file.name(), output); output( "#ifndef $0_UPB_H_\n" "#define $0_UPB_H_\n\n" @@ -758,19 +812,20 @@ void WriteHeader(const FileLayout& layout, Output& output) { "#include \"upb/wire/decode.h\"\n" "#include \"upb/wire/decode_fast.h\"\n" "#include \"upb/wire/encode.h\"\n\n", - ToPreproc(file->name())); + ToPreproc(file.name())); - for (int i = 0; i < file->public_dependency_count(); i++) { + for (int i = 0; i < file.public_dependency_count(); i++) { if (i == 0) { output("/* Public Imports. */\n"); } - output("#include \"$0\"\n", HeaderFilename(file->public_dependency(i))); - if (i == file->public_dependency_count() - 1) { + output("#include \"$0\"\n", HeaderFilename(file.public_dependency(i))); + if (i == file.public_dependency_count() - 1) { output("\n"); } } output( + "// Must be last. \n" "#include \"upb/port/def.inc\"\n" "\n" "#ifdef __cplusplus\n" @@ -778,17 +833,16 @@ void WriteHeader(const FileLayout& layout, Output& output) { "#endif\n" "\n"); - const std::vector this_file_messages = + const std::vector this_file_messages = SortedMessages(file); - const std::vector this_file_exts = - SortedExtensions(file); + const std::vector this_file_exts = SortedExtensions(file); // Forward-declare types defined in this file. for (auto message : this_file_messages) { - output("typedef struct $0 $0;\n", ToCIdent(message->full_name())); + output("typedef struct $0 $0;\n", ToCIdent(message.full_name())); } for (auto message : this_file_messages) { - output("extern const upb_MiniTable $0;\n", MessageInit(message)); + ForwardDeclareMiniTableInit(message, options, output); } for (auto ext : this_file_exts) { output("extern const upb_MiniTableExtension $0;\n", ExtensionLayout(ext)); @@ -796,81 +850,83 @@ void WriteHeader(const FileLayout& layout, Output& output) { // Forward-declare types not in this file, but used as submessages. // Order by full name for consistent ordering. - std::map forward_messages; - - for (auto* message : this_file_messages) { - for (int i = 0; i < message->field_count(); i++) { - const protobuf::FieldDescriptor* field = message->field(i); - if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE && - field->file() != field->message_type()->file()) { - forward_messages[field->message_type()->full_name()] = - field->message_type(); + std::map forward_messages; + + for (auto message : this_file_messages) { + for (int i = 0; i < message.field_count(); i++) { + upb::FieldDefPtr field = message.field(i); + if (field.ctype() == kUpb_CType_Message && + field.file() != field.message_type().file()) { + forward_messages[field.message_type().full_name()] = + field.message_type(); } } } for (auto ext : this_file_exts) { - if (ext->file() != ext->containing_type()->file()) { - forward_messages[ext->containing_type()->full_name()] = - ext->containing_type(); + if (ext.file() != ext.containing_type().file()) { + forward_messages[ext.containing_type().full_name()] = + ext.containing_type(); } } for (const auto& pair : forward_messages) { output("struct $0;\n", MessageName(pair.second)); } for (const auto& pair : forward_messages) { - output("extern const upb_MiniTable $0;\n", MessageInit(pair.second)); + ForwardDeclareMiniTableInit(pair.second, options, output); } if (!this_file_messages.empty()) { output("\n"); } - std::vector this_file_enums = - SortedEnums(file); - std::sort( - this_file_enums.begin(), this_file_enums.end(), - [](const protobuf::EnumDescriptor* a, const protobuf::EnumDescriptor* b) { - return a->full_name() < b->full_name(); - }); + std::vector this_file_enums = SortedEnums(file); + std::sort(this_file_enums.begin(), this_file_enums.end(), + [](upb::EnumDefPtr a, upb::EnumDefPtr b) { + return a.full_name() < b.full_name(); + }); for (auto enumdesc : this_file_enums) { output("typedef enum {\n"); DumpEnumValues(enumdesc, output); - output("} $0;\n\n", ToCIdent(enumdesc->full_name())); + output("} $0;\n\n", ToCIdent(enumdesc.full_name())); } output("\n"); - if (file->syntax() == protobuf::FileDescriptor::SYNTAX_PROTO2) { - for (const auto* enumdesc : this_file_enums) { - output("extern const upb_MiniTableEnum $0;\n", EnumInit(enumdesc)); + if (file.syntax() == kUpb_Syntax_Proto2) { + for (const auto enumdesc : this_file_enums) { + if (options.bootstrap) { + output("extern const upb_MiniTableEnum* $0();\n", EnumInit(enumdesc)); + } else { + output("extern const upb_MiniTableEnum $0;\n", EnumInit(enumdesc)); + } } } output("\n"); for (auto message : this_file_messages) { - GenerateMessageInHeader(message, layout, output); + GenerateMessageInHeader(message, pools, options, output); } for (auto ext : this_file_exts) { - GenerateExtensionInHeader(ext, layout, output); + GenerateExtensionInHeader(pools, ext, output); } output("extern const upb_MiniTableFile $0;\n\n", FileLayoutName(file)); - if (file->name() == - protobuf::FileDescriptorProto::descriptor()->file()->name()) { + if (absl::string_view(file.name()) == "google/protobuf/descriptor.proto" || + absl::string_view(file.name()) == "net/proto2/proto/descriptor.proto") { // This is gratuitously inefficient with how many times it rebuilds // MessageLayout objects for the same message. But we only do this for one // proto (descriptor.proto) so we don't worry about it. - const protobuf::Descriptor* max32_message = nullptr; - const protobuf::Descriptor* max64_message = nullptr; + upb::MessageDefPtr max32_message; + upb::MessageDefPtr max64_message; size_t max32 = 0; size_t max64 = 0; - for (const auto* message : this_file_messages) { - if (absl::EndsWith(message->name(), "Options")) { - size_t size32 = layout.GetMiniTable32(message)->size; - size_t size64 = layout.GetMiniTable64(message)->size; + for (const auto message : this_file_messages) { + if (absl::EndsWith(message.name(), "Options")) { + size_t size32 = pools.GetMiniTable32(message)->size; + size_t size64 = pools.GetMiniTable64(message)->size; if (size32 > max32) { max32 = size32; max32_message = message; @@ -882,8 +938,8 @@ void WriteHeader(const FileLayout& layout, Output& output) { } } - output("/* Max size 32 is $0 */\n", max32_message->full_name()); - output("/* Max size 64 is $0 */\n", max64_message->full_name()); + output("/* Max size 32 is $0 */\n", max32_message.full_name()); + output("/* Max size 64 is $0 */\n", max64_message.full_name()); output("#define _UPB_MAXOPT_SIZE UPB_SIZE($0, $1)\n\n", max32, max64); } @@ -895,26 +951,68 @@ void WriteHeader(const FileLayout& layout, Output& output) { "#include \"upb/port/undef.inc\"\n" "\n" "#endif /* $0_UPB_H_ */\n", - ToPreproc(file->name())); + ToPreproc(file.name())); } typedef std::pair TableEntry; -uint64_t GetEncodedTag(const protobuf::FieldDescriptor* field) { - protobuf::internal::WireFormatLite::WireType wire_type = - protobuf::internal::WireFormat::WireTypeForField(field); - uint32_t unencoded_tag = - protobuf::internal::WireFormatLite::MakeTag(field->number(), wire_type); - uint8_t tag_bytes[10] = {0}; - protobuf::io::CodedOutputStream::WriteVarint32ToArray(unencoded_tag, - tag_bytes); +uint32_t GetWireTypeForField(upb::FieldDefPtr field) { + if (field.packed()) return kUpb_WireType_Delimited; + switch (field.type()) { + case kUpb_FieldType_Double: + case kUpb_FieldType_Fixed64: + case kUpb_FieldType_SFixed64: + return kUpb_WireType_64Bit; + case kUpb_FieldType_Float: + case kUpb_FieldType_Fixed32: + case kUpb_FieldType_SFixed32: + return kUpb_WireType_32Bit; + case kUpb_FieldType_Int64: + case kUpb_FieldType_UInt64: + case kUpb_FieldType_Int32: + case kUpb_FieldType_Bool: + case kUpb_FieldType_UInt32: + case kUpb_FieldType_Enum: + case kUpb_FieldType_SInt32: + case kUpb_FieldType_SInt64: + return kUpb_WireType_Varint; + case kUpb_FieldType_Group: + return kUpb_WireType_StartGroup; + case kUpb_FieldType_Message: + case kUpb_FieldType_String: + case kUpb_FieldType_Bytes: + return kUpb_WireType_Delimited; + } + UPB_UNREACHABLE(); +} + +uint32_t MakeTag(uint32_t field_number, uint32_t wire_type) { + return field_number << 3 | wire_type; +} + +size_t WriteVarint32ToArray(uint64_t val, char* buf) { + size_t i = 0; + do { + uint8_t byte = val & 0x7fU; + val >>= 7; + if (val) byte |= 0x80U; + buf[i++] = byte; + } while (val); + return i; +} + +uint64_t GetEncodedTag(upb::FieldDefPtr field) { + uint32_t wire_type = GetWireTypeForField(field); + uint32_t unencoded_tag = MakeTag(field.number(), wire_type); + char tag_bytes[10] = {0}; + WriteVarint32ToArray(unencoded_tag, tag_bytes); uint64_t encoded_tag = 0; memcpy(&encoded_tag, tag_bytes, sizeof(encoded_tag)); // TODO: byte-swap for big endian. return encoded_tag; } -int GetTableSlot(const protobuf::FieldDescriptor* field) { +int GetTableSlot(upb::FieldDefPtr field) { uint64_t tag = GetEncodedTag(field); if (tag > 0x7fff) { // Tag must fit within a two-byte varint. @@ -923,12 +1021,11 @@ int GetTableSlot(const protobuf::FieldDescriptor* field) { return (tag & 0xf8) >> 3; } -bool TryFillTableEntry(const FileLayout& layout, - const protobuf::FieldDescriptor* field, +bool TryFillTableEntry(const DefPoolPair& pools, upb::FieldDefPtr field, TableEntry& ent) { - const upb_MiniTable* mt = layout.GetMiniTable64(field->containing_type()); + const upb_MiniTable* mt = pools.GetMiniTable64(field.containing_type()); const upb_MiniTableField* mt_f = - upb_MiniTable_FindFieldByNumber(mt, field->number()); + upb_MiniTable_FindFieldByNumber(mt, field.number()); std::string type = ""; std::string cardinality = ""; switch (mt_f->descriptortype) { @@ -1007,14 +1104,14 @@ bool TryFillTableEntry(const FileLayout& layout, uint64_t data = static_cast(mt_f->offset) << 48 | expected_tag; - if (field->is_repeated()) { + if (field.IsSequence()) { // No hasbit/oneof-related fields. } - if (field->real_containing_oneof()) { + if (field.real_containing_oneof()) { uint64_t case_offset = ~mt_f->presence; if (case_offset > 0xffff) return false; - assert(field->number() < 256); - data |= field->number() << 24; + assert(field.number() < 256); + data |= field.number() << 24; data |= case_offset << 32; } else { uint64_t hasbit_index = 63; // No hasbit (set a high, unused bit). @@ -1025,20 +1122,19 @@ bool TryFillTableEntry(const FileLayout& layout, data |= hasbit_index << 24; } - if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { + if (field.ctype() == kUpb_CType_Message) { uint64_t idx = mt_f->submsg_index; if (idx > 255) return false; data |= idx << 16; std::string size_ceil = "max"; size_t size = SIZE_MAX; - if (field->message_type()->file() == field->file()) { + if (field.message_type().file() == field.file()) { // We can only be guaranteed the size of the sub-message if it is in the // same file as us. We could relax this to increase the speed of // cross-file sub-message parsing if we are comfortable requiring that // users compile all messages at the same time. - const upb_MiniTable* sub_mt = - layout.GetMiniTable64(field->message_type()); + const upb_MiniTable* sub_mt = pools.GetMiniTable64(field.message_type()); size = sub_mt->size + 8; } std::vector breaks = {64, 128, 192, 256}; @@ -1059,8 +1155,8 @@ bool TryFillTableEntry(const FileLayout& layout, return true; } -std::vector FastDecodeTable(const protobuf::Descriptor* message, - const FileLayout& layout) { +std::vector FastDecodeTable(upb::MessageDefPtr message, + const DefPoolPair& pools) { std::vector table; for (const auto field : FieldHotnessOrder(message)) { TableEntry ent; @@ -1070,7 +1166,7 @@ std::vector FastDecodeTable(const protobuf::Descriptor* message, // Tag can't fit in the table. continue; } - if (!TryFillTableEntry(layout, field, ent)) { + if (!TryFillTableEntry(pools, field, ent)) { // Unsupported field type or offset, hasbit index, etc. doesn't fit. continue; } @@ -1087,6 +1183,11 @@ std::vector FastDecodeTable(const protobuf::Descriptor* message, return table; } +std::string ArchDependentSize(int64_t size32, int64_t size64) { + if (size32 == size64) return absl::StrCat(size32); + return absl::Substitute("UPB_SIZE($0, $1)", size32, size64); +} + std::string GetFieldRep(const upb_MiniTableField* field32, const upb_MiniTableField* field64) { switch (_upb_MiniTableField_GetRep(field32)) { @@ -1112,9 +1213,8 @@ std::string GetFieldRep(const upb_MiniTableField* field32, UPB_UNREACHABLE(); } -std::string GetFieldRep(const FileLayout& layout, - const protobuf::FieldDescriptor* field) { - return GetFieldRep(layout.GetField32(field), layout.GetField64(field)); +std::string GetFieldRep(const DefPoolPair& pools, upb::FieldDefPtr field) { + return GetFieldRep(pools.GetField32(field), pools.GetField64(field)); } // Returns the field mode as a string initializer. @@ -1157,44 +1257,67 @@ std::string GetModeInit(const upb_MiniTableField* field32, return ret; } -std::string FieldInitializer(const upb_MiniTableField* field64, - const upb_MiniTableField* field32) { - return absl::Substitute( - "{$0, $1, $2, $3, $4, $5}", field64->number, - FileLayout::UpbSize(field32->offset, field64->offset), - FileLayout::UpbSize(field32->presence, field64->presence), - field64->submsg_index == kUpb_NoSub - ? "kUpb_NoSub" - : absl::StrCat(field64->submsg_index).c_str(), - field64->descriptortype, GetModeInit(field32, field64)); +std::string FieldInitializer(upb::FieldDefPtr field, + const upb_MiniTableField* field64, + const upb_MiniTableField* field32, + const Options& options) { + if (options.bootstrap) { + CHECK(!field.is_extension()); + return absl::Substitute( + "*upb_MiniTable_FindFieldByNumber($0, $1)", + MessageMiniTableRef(field.containing_type(), options), field.number()); + } else { + return absl::Substitute( + "{$0, $1, $2, $3, $4, $5}", field64->number, + ArchDependentSize(field32->offset, field64->offset), + ArchDependentSize(field32->presence, field64->presence), + field64->submsg_index == kUpb_NoSub + ? "kUpb_NoSub" + : absl::StrCat(field64->submsg_index).c_str(), + field64->descriptortype, GetModeInit(field32, field64)); + } } -std::string FieldInitializer(const FileLayout& layout, - const protobuf::FieldDescriptor* field) { - return FieldInitializer(layout.GetField64(field), layout.GetField32(field)); +std::string FieldInitializer(const DefPoolPair& pools, upb::FieldDefPtr field, + const Options& options) { + return FieldInitializer(field, pools.GetField64(field), + pools.GetField32(field), options); } // Writes a single field into a .upb.c source file. -void WriteMessageField(const upb_MiniTableField* field64, - const upb_MiniTableField* field32, Output& output) { - output(" $0,\n", FieldInitializer(field64, field32)); +void WriteMessageField(upb::FieldDefPtr field, + const upb_MiniTableField* field64, + const upb_MiniTableField* field32, + const Options& options, Output& output) { + output(" $0,\n", FieldInitializer(field, field64, field32, options)); +} + +std::string GetSub(upb::FieldDefPtr field) { + if (auto message_def = field.message_type(); message_def) { + return absl::Substitute("{.submsg = &$0}", MessageInitName(message_def)); + } else if (auto enum_def = field.enum_subdef(); + enum_def && enum_def.is_closed()) { + return absl::Substitute("{.subenum = &$0}", EnumInit(enum_def)); + } else { + return std::string("{.submsg = NULL}"); + } } // Writes a single message into a .upb.c source file. -void WriteMessage(const protobuf::Descriptor* message, const FileLayout& layout, - Output& output) { - std::string msg_name = ToCIdent(message->full_name()); +void WriteMessage(upb::MessageDefPtr message, const DefPoolPair& pools, + const Options& options, Output& output) { + std::string msg_name = ToCIdent(message.full_name()); std::string fields_array_ref = "NULL"; std::string submsgs_array_ref = "NULL"; std::string subenums_array_ref = "NULL"; - const upb_MiniTable* mt_32 = layout.GetMiniTable32(message); - const upb_MiniTable* mt_64 = layout.GetMiniTable64(message); + const upb_MiniTable* mt_32 = pools.GetMiniTable32(message); + const upb_MiniTable* mt_64 = pools.GetMiniTable64(message); std::vector subs; for (int i = 0; i < mt_64->field_count; i++) { const upb_MiniTableField* f = &mt_64->fields[i]; if (f->submsg_index != kUpb_NoSub) { - subs.push_back(FilePlatformLayout::GetSub(mt_64->subs[f->submsg_index])); + subs.push_back(GetSub(message.FindFieldByNumber(f->number))); } } @@ -1217,7 +1340,8 @@ void WriteMessage(const protobuf::Descriptor* message, const FileLayout& layout, output("static const upb_MiniTableField $0[$1] = {\n", fields_array_name, mt_64->field_count); for (int i = 0; i < mt_64->field_count; i++) { - WriteMessageField(&mt_64->fields[i], &mt_32->fields[i], output); + WriteMessageField(message.FindFieldByNumber(mt_64->fields[i].number), + &mt_64->fields[i], &mt_32->fields[i], options, output); } output("};\n\n"); } @@ -1225,7 +1349,7 @@ void WriteMessage(const protobuf::Descriptor* message, const FileLayout& layout, std::vector table; uint8_t table_mask = -1; - table = FastDecodeTable(message, layout); + table = FastDecodeTable(message, pools); if (table.size() > 1) { assert((table.size() & (table.size() - 1)) == 0); @@ -1234,20 +1358,20 @@ void WriteMessage(const protobuf::Descriptor* message, const FileLayout& layout, std::string msgext = "kUpb_ExtMode_NonExtendable"; - if (message->extension_range_count()) { - if (message->options().message_set_wire_format()) { + if (message.extension_range_count()) { + if (UPB_DESC(MessageOptions_message_set_wire_format)(message.options())) { msgext = "kUpb_ExtMode_IsMessageSet"; } else { msgext = "kUpb_ExtMode_Extendable"; } } - output("const upb_MiniTable $0 = {\n", MessageInit(message)); + output("const upb_MiniTable $0 = {\n", MessageInitName(message)); output(" $0,\n", submsgs_array_ref); output(" $0,\n", fields_array_ref); - output(" $0, $1, $2, $3, $4, $5,\n", layout.GetMessageSize(message), - mt_64->field_count, msgext, mt_64->dense_below, table_mask, - mt_64->required_count); + output(" $0, $1, $2, $3, UPB_FASTTABLE_MASK($4), $5,\n", + ArchDependentSize(mt_32->size, mt_64->size), mt_64->field_count, + msgext, mt_64->dense_below, table_mask, mt_64->required_count); if (!table.empty()) { output(" UPB_FASTTABLE_INIT({\n"); for (const auto& ent : table) { @@ -1259,9 +1383,9 @@ void WriteMessage(const protobuf::Descriptor* message, const FileLayout& layout, output("};\n\n"); } -void WriteEnum(const upb_MiniTableEnum* mt, const protobuf::EnumDescriptor* e, - Output& output) { +void WriteEnum(upb::EnumDefPtr e, Output& output) { std::string values_init = "{\n"; + const upb_MiniTableEnum* mt = e.mini_table(); uint32_t value_count = (mt->mask_limit / 32) + mt->value_count; for (uint32_t i = 0; i < value_count; i++) { absl::StrAppend(&values_init, " 0x", absl::Hex(mt->data[i]), @@ -1281,24 +1405,19 @@ void WriteEnum(const upb_MiniTableEnum* mt, const protobuf::EnumDescriptor* e, output("\n"); } -int WriteEnums(const FileLayout& layout, Output& output) { - const protobuf::FileDescriptor* file = layout.descriptor(); +int WriteEnums(const DefPoolPair& pools, upb::FileDefPtr file, Output& output) { + if (file.syntax() != kUpb_Syntax_Proto2) return 0; - if (file->syntax() != protobuf::FileDescriptor::SYNTAX_PROTO2) { - return 0; - } - - std::vector this_file_enums = - SortedEnums(file); + std::vector this_file_enums = SortedEnums(file); - for (const auto* e : this_file_enums) { - WriteEnum(layout.GetEnumTable(e), e, output); + for (const auto e : this_file_enums) { + WriteEnum(e, output); } if (!this_file_enums.empty()) { output("static const upb_MiniTableEnum *$0[$1] = {\n", kEnumsInit, this_file_enums.size()); - for (const auto* e : this_file_enums) { + for (const auto e : this_file_enums) { output(" &$0,\n", EnumInit(e)); } output("};\n"); @@ -1308,59 +1427,56 @@ int WriteEnums(const FileLayout& layout, Output& output) { return this_file_enums.size(); } -int WriteMessages(const FileLayout& layout, Output& output) { - const protobuf::FileDescriptor* file = layout.descriptor(); - std::vector file_messages = SortedMessages(file); +int WriteMessages(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Output& output) { + std::vector file_messages = SortedMessages(file); if (file_messages.empty()) return 0; for (auto message : file_messages) { - WriteMessage(message, layout, output); + WriteMessage(message, pools, options, output); } output("static const upb_MiniTable *$0[$1] = {\n", kMessagesInit, file_messages.size()); for (auto message : file_messages) { - output(" &$0,\n", MessageInit(message)); + output(" &$0,\n", MessageInitName(message)); } output("};\n"); output("\n"); return file_messages.size(); } -void WriteExtension(const protobuf::FieldDescriptor* ext, - const FileLayout& layout, Output& output) { - output("$0,\n", FieldInitializer(layout, ext)); - const upb_MiniTableExtension* mt_ext = - reinterpret_cast(layout.GetField32(ext)); - output(" &$0,\n", reinterpret_cast(mt_ext->extendee)); - output(" $0,\n", FilePlatformLayout::GetSub(mt_ext->sub)); +void WriteExtension(upb::FieldDefPtr ext, const DefPoolPair& pools, + const Options& options, Output& output) { + output("$0,\n", FieldInitializer(pools, ext, options)); + output(" &$0,\n", MessageInitName(ext.containing_type())); + output(" $0,\n", GetSub(ext)); } -int WriteExtensions(const FileLayout& layout, Output& output) { - auto exts = SortedExtensions(layout.descriptor()); - absl::flat_hash_set forward_decls; +int WriteExtensions(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Output& output) { + auto exts = SortedExtensions(file); if (exts.empty()) return 0; // Order by full name for consistent ordering. - std::map forward_messages; + std::map forward_messages; for (auto ext : exts) { - forward_messages[ext->containing_type()->full_name()] = - ext->containing_type(); - if (ext->message_type()) { - forward_messages[ext->message_type()->full_name()] = ext->message_type(); + forward_messages[ext.containing_type().full_name()] = ext.containing_type(); + if (ext.message_type()) { + forward_messages[ext.message_type().full_name()] = ext.message_type(); } } for (const auto& decl : forward_messages) { - output("extern const upb_MiniTable $0;\n", MessageInit(decl.second)); + ForwardDeclareMiniTableInit(decl.second, options, output); } for (auto ext : exts) { output("const upb_MiniTableExtension $0 = {\n ", ExtensionLayout(ext)); - WriteExtension(ext, layout, output); + WriteExtension(ext, pools, options, output); output("\n};\n"); } @@ -1379,10 +1495,9 @@ int WriteExtensions(const FileLayout& layout, Output& output) { return exts.size(); } -// Writes a .upb.cc source file. -void WriteSource(const FileLayout& layout, Output& output) { - const protobuf::FileDescriptor* file = layout.descriptor(); - EmitFileWarning(file, output); +void WriteMiniTableSource(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Output& output) { + EmitFileWarning(file.name(), output); output( "#include \n" @@ -1392,18 +1507,19 @@ void WriteSource(const FileLayout& layout, Output& output) { "#include \"$0\"\n", HeaderFilename(file)); - for (int i = 0; i < file->dependency_count(); i++) { - output("#include \"$0\"\n", HeaderFilename(file->dependency(i))); + for (int i = 0; i < file.dependency_count(); i++) { + output("#include \"$0\"\n", HeaderFilename(file.dependency(i))); } output( "\n" + "// Must be last.\n" "#include \"upb/port/def.inc\"\n" "\n"); - int msg_count = WriteMessages(layout, output); - int ext_count = WriteExtensions(layout, output); - int enum_count = WriteEnums(layout, output); + int msg_count = WriteMessages(pools, file, options, output); + int ext_count = WriteExtensions(pools, file, options, output); + int enum_count = WriteEnums(pools, file, output); output("const upb_MiniTableFile $0 = {\n", FileLayoutName(file)); output(" $0,\n", msg_count ? kMessagesInit : "NULL"); @@ -1418,48 +1534,155 @@ void WriteSource(const FileLayout& layout, Output& output) { output("\n"); } -class Generator : public protoc::CodeGenerator { - ~Generator() override {} - bool Generate(const protobuf::FileDescriptor* file, - const std::string& parameter, protoc::GeneratorContext* context, - std::string* error) const override; - uint64_t GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; +void WriteMessageMiniDescriptorInitializer(upb::MessageDefPtr msg, + const Options& options, + Output& output) { + Output resolve_calls; + for (int i = 0; i < msg.field_count(); i++) { + upb::FieldDefPtr field = msg.field(i); + if (!field.message_type() && !field.enum_subdef()) continue; + if (field.message_type()) { + resolve_calls( + "upb_MiniTable_SetSubMessage(mini_table, " + "(upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, " + "$0), $1);\n ", + field.number(), MessageMiniTableRef(field.message_type(), options)); + } else if (field.enum_subdef() && field.enum_subdef().is_closed()) { + resolve_calls( + "upb_MiniTable_SetSubEnum(mini_table, " + "(upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, " + "$0), $1);\n ", + field.number(), EnumMiniTableRef(field.enum_subdef(), options)); + } } -}; -bool Generator::Generate(const protobuf::FileDescriptor* file, - const std::string& parameter, - protoc::GeneratorContext* context, - std::string* error) const { - std::vector> params; - google::protobuf::compiler::ParseGeneratorParameter(parameter, ¶ms); + output( + R"cc( + const upb_MiniTable* $0() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + $2return mini_table; + } + )cc", + MessageInitName(msg), msg.MiniDescriptorEncode(), resolve_calls.output()); + output("\n"); +} + +void WriteEnumMiniDescriptorInitializer(upb::EnumDefPtr enum_def, + const Options& options, + Output& output) { + output( + R"cc( + const upb_MiniTableEnum* $0() { + static const upb_MiniTableEnum* mini_table = NULL; + static const char* mini_descriptor = "$1"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTableEnum_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + return mini_table; + } + )cc", + EnumInitName(enum_def), enum_def.MiniDescriptorEncode()); + output("\n"); +} - for (const auto& pair : params) { - *error = "Unknown parameter: " + pair.first; - return false; +void WriteMiniDescriptorSource(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Output& output) { + output( + "#include \n" + "#include \"upb/collections/array_internal.h\"\n" + "#include \"upb/message/internal.h\"\n" + "#include \"upb/mini_table/decode.h\"\n" + "#include \"upb/mini_table/enum_internal.h\"\n" + "#include \"$0\"\n\n", + HeaderFilename(file)); + + for (int i = 0; i < file.dependency_count(); i++) { + output("#include \"$0\"\n", HeaderFilename(file.dependency(i))); } - FileLayout layout(file); + output( + R"cc( + static upb_Arena* upb_BootstrapArena() { + static upb_Arena* arena = NULL; + if (!arena) arena = upb_Arena_New(); + return arena; + } + )cc"); + + output("\n"); - std::unique_ptr h_output_stream( - context->Open(HeaderFilename(file))); - Output h_output(h_output_stream.get()); - WriteHeader(layout, h_output); + for (const auto msg : SortedMessages(file)) { + WriteMessageMiniDescriptorInitializer(msg, options, output); + } - std::unique_ptr c_output_stream( - context->Open(SourceFilename(file))); - Output c_output(c_output_stream.get()); - WriteSource(layout, c_output); + for (const auto msg : SortedEnums(file)) { + WriteEnumMiniDescriptorInitializer(msg, options, output); + } +} + +void WriteSource(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Output& output) { + if (options.bootstrap) { + WriteMiniDescriptorSource(pools, file, options, output); + } else { + WriteMiniTableSource(pools, file, options, output); + } +} + +void GenerateFile(const DefPoolPair& pools, upb::FileDefPtr file, + const Options& options, Plugin* plugin) { + Output h_output; + WriteHeader(pools, file, options, h_output); + plugin->AddOutputFile(HeaderFilename(file), h_output.output()); + + Output c_output; + WriteSource(pools, file, options, c_output); + plugin->AddOutputFile(SourceFilename(file), c_output.output()); +} + +bool ParseOptions(Plugin* plugin, Options* options) { + for (const auto& pair : ParseGeneratorParameter(plugin->parameter())) { + if (pair.first == "bootstrap_upb") { + options->bootstrap = true; + } else { + plugin->SetError(absl::Substitute("Unknown parameter: $0", pair.first)); + return false; + } + } return true; } +absl::string_view ToStringView(upb_StringView str) { + return absl::string_view(str.data, str.size); +} + } // namespace + } // namespace upbc int main(int argc, char** argv) { - std::unique_ptr generator( - new upbc::Generator()); - return google::protobuf::compiler::PluginMain(argc, argv, generator.get()); + upbc::DefPoolPair pools; + upbc::Plugin plugin; + upbc::Options options; + if (!ParseOptions(&plugin, &options)) return 0; + plugin.GenerateFilesRaw([&](const UPB_DESC(FileDescriptorProto) * file_proto, + bool generate) { + upb::Status status; + upb::FileDefPtr file = pools.AddFile(file_proto, &status); + if (!file) { + absl::string_view name = + upbc::ToStringView(UPB_DESC(FileDescriptorProto_name)(file_proto)); + LOG(FATAL) << "Couldn't add file " << name + << " to DefPool: " << status.error_message(); + } + if (generate) GenerateFile(pools, file, options, &plugin); + }); + return 0; } diff --git a/upbc/protoc-gen-upbdefs.cc b/upbc/protoc-gen-upbdefs.cc index 95117874a0..2d781a67a6 100644 --- a/upbc/protoc-gen-upbdefs.cc +++ b/upbc/protoc-gen-upbdefs.cc @@ -25,46 +25,39 @@ #include -#include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/compiler/plugin.h" -#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor.upb.h" +#include "upb/reflection/def.hpp" +#include "upb/util/def_to_proto.h" #include "upbc/common.h" +#include "upbc/file_layout.h" +#include "upbc/plugin.h" namespace upbc { namespace { -namespace protoc = ::google::protobuf::compiler; -namespace protobuf = ::google::protobuf; - -std::string DefInitSymbol(const protobuf::FileDescriptor* file) { - return ToCIdent(file->name()) + "_upbdefinit"; +std::string DefInitSymbol(upb::FileDefPtr file) { + return ToCIdent(file.name()) + "_upbdefinit"; } -static std::string DefHeaderFilename(std::string proto_filename) { - return StripExtension(proto_filename) + ".upbdefs.h"; +static std::string DefHeaderFilename(upb::FileDefPtr file) { + return StripExtension(file.name()) + ".upbdefs.h"; } -static std::string DefSourceFilename(std::string proto_filename) { - return StripExtension(proto_filename) + ".upbdefs.c"; +static std::string DefSourceFilename(upb::FileDefPtr file) { + return StripExtension(file.name()) + ".upbdefs.c"; } -void GenerateMessageDefAccessor(const protobuf::Descriptor* d, Output& output) { +void GenerateMessageDefAccessor(upb::MessageDefPtr d, Output& output) { output("UPB_INLINE const upb_MessageDef *$0_getmsgdef(upb_DefPool *s) {\n", - ToCIdent(d->full_name())); - output(" _upb_DefPool_LoadDefInit(s, &$0);\n", DefInitSymbol(d->file())); - output(" return upb_DefPool_FindMessageByName(s, \"$0\");\n", - d->full_name()); + ToCIdent(d.full_name())); + output(" _upb_DefPool_LoadDefInit(s, &$0);\n", DefInitSymbol(d.file())); + output(" return upb_DefPool_FindMessageByName(s, \"$0\");\n", d.full_name()); output("}\n"); output("\n"); - - for (int i = 0; i < d->nested_type_count(); i++) { - GenerateMessageDefAccessor(d->nested_type(i), output); - } } -void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) { - EmitFileWarning(file, output); +void WriteDefHeader(upb::FileDefPtr file, Output& output) { + EmitFileWarning(file.name(), output); output( "#ifndef $0_UPBDEFS_H_\n" @@ -75,7 +68,7 @@ void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) { "#ifdef __cplusplus\n" "extern \"C\" {\n" "#endif\n\n", - ToPreproc(file->name())); + ToPreproc(file.name())); output("#include \"upb/reflection/def.h\"\n"); output("\n"); @@ -85,8 +78,8 @@ void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) { output("extern _upb_DefPool_Init $0;\n", DefInitSymbol(file)); output("\n"); - for (int i = 0; i < file->message_type_count(); i++) { - GenerateMessageDefAccessor(file->message_type(i), output); + for (auto msg : SortedMessages(file)) { + GenerateMessageDefAccessor(msg, output); } output( @@ -97,35 +90,37 @@ void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) { "#include \"upb/port/undef.inc\"\n" "\n" "#endif /* $0_UPBDEFS_H_ */\n", - ToPreproc(file->name())); + ToPreproc(file.name())); } -void WriteDefSource(const protobuf::FileDescriptor* file, Output& output) { - EmitFileWarning(file, output); +void WriteDefSource(upb::FileDefPtr file, Output& output) { + EmitFileWarning(file.name(), output); output("#include \"upb/reflection/def.h\"\n"); - output("#include \"$0\"\n", DefHeaderFilename(file->name())); + output("#include \"$0\"\n", DefHeaderFilename(file)); output("#include \"$0\"\n", HeaderFilename(file)); output("\n"); - for (int i = 0; i < file->dependency_count(); i++) { - output("extern _upb_DefPool_Init $0;\n", - DefInitSymbol(file->dependency(i))); + for (int i = 0; i < file.dependency_count(); i++) { + output("extern _upb_DefPool_Init $0;\n", DefInitSymbol(file.dependency(i))); } - protobuf::FileDescriptorProto file_proto; - file->CopyTo(&file_proto); - std::string file_data; - file_proto.SerializeToString(&file_data); + upb::Arena arena; + google_protobuf_FileDescriptorProto* file_proto = + upb_FileDef_ToProto(file.ptr(), arena.ptr()); + size_t serialized_size; + const char* serialized = google_protobuf_FileDescriptorProto_serialize( + file_proto, arena.ptr(), &serialized_size); + absl::string_view file_data(serialized, serialized_size); - output("static const char descriptor[$0] = {", file_data.size()); + output("static const char descriptor[$0] = {", serialized_size); // C90 only guarantees that strings can be up to 509 characters, and some // implementations have limits here (for example, MSVC only allows 64k: // https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1091. // So we always emit an array instead of a string. - for (size_t i = 0; i < file_data.size();) { - for (size_t j = 0; j < 25 && i < file_data.size(); ++i, ++j) { + for (size_t i = 0; i < serialized_size;) { + for (size_t j = 0; j < 25 && i < serialized_size; ++i, ++j) { output("'$0', ", absl::CEscape(file_data.substr(i, 1))); } output("\n"); @@ -133,9 +128,9 @@ void WriteDefSource(const protobuf::FileDescriptor* file, Output& output) { output("};\n\n"); output("static _upb_DefPool_Init *deps[$0] = {\n", - file->dependency_count() + 1); - for (int i = 0; i < file->dependency_count(); i++) { - output(" &$0,\n", DefInitSymbol(file->dependency(i))); + file.dependency_count() + 1); + for (int i = 0; i < file.dependency_count(); i++) { + output(" &$0,\n", DefInitSymbol(file.dependency(i))); } output(" NULL\n"); output("};\n"); @@ -144,51 +139,32 @@ void WriteDefSource(const protobuf::FileDescriptor* file, Output& output) { output("_upb_DefPool_Init $0 = {\n", DefInitSymbol(file)); output(" deps,\n"); output(" &$0,\n", FileLayoutName(file)); - output(" \"$0\",\n", file->name()); + output(" \"$0\",\n", file.name()); output(" UPB_STRINGVIEW_INIT(descriptor, $0)\n", file_data.size()); output("};\n"); } -class Generator : public protoc::CodeGenerator { - ~Generator() override {} - bool Generate(const protobuf::FileDescriptor* file, - const std::string& parameter, protoc::GeneratorContext* context, - std::string* error) const override; - uint64_t GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; - } -}; - -bool Generator::Generate(const protobuf::FileDescriptor* file, - const std::string& parameter, - protoc::GeneratorContext* context, - std::string* error) const { - std::vector> params; - google::protobuf::compiler::ParseGeneratorParameter(parameter, ¶ms); - - for (const auto& pair : params) { - *error = "Unknown parameter: " + pair.first; - return false; - } - - std::unique_ptr h_output_stream( - context->Open(DefHeaderFilename(file->name()))); - Output h_def_output(h_output_stream.get()); +void GenerateFile(upb::FileDefPtr file, Plugin* plugin) { + Output h_def_output; WriteDefHeader(file, h_def_output); + plugin->AddOutputFile(DefHeaderFilename(file), h_def_output.output()); - std::unique_ptr c_output_stream( - context->Open(DefSourceFilename(file->name()))); - Output c_def_output(c_output_stream.get()); + Output c_def_output; WriteDefSource(file, c_def_output); - - return true; + plugin->AddOutputFile(DefSourceFilename(file), c_def_output.output()); } } // namespace } // namespace upbc int main(int argc, char** argv) { - std::unique_ptr generator( - new upbc::Generator()); - return google::protobuf::compiler::PluginMain(argc, argv, generator.get()); + upbc::Plugin plugin; + if (!plugin.parameter().empty()) { + plugin.SetError( + absl::StrCat("Expected no parameters, got: ", plugin.parameter())); + return 0; + } + plugin.GenerateFiles( + [&](upb::FileDefPtr file) { upbc::GenerateFile(file, &plugin); }); + return 0; } diff --git a/upbc/stage0/google/protobuf/compiler/plugin.upb.c b/upbc/stage0/google/protobuf/compiler/plugin.upb.c new file mode 100644 index 0000000000..70ada66331 --- /dev/null +++ b/upbc/stage0/google/protobuf/compiler/plugin.upb.c @@ -0,0 +1,68 @@ +#include +#include "upb/collections/array_internal.h" +#include "upb/message/internal.h" +#include "upb/mini_table/decode.h" +#include "upb/mini_table/enum_internal.h" +#include "google/protobuf/compiler/plugin.upb.h" + +#include "google/protobuf/descriptor.upb.h" +static upb_Arena* upb_BootstrapArena() { + static upb_Arena* arena = NULL; + if (!arena) arena = upb_Arena_New(); + return arena; +} + +const upb_MiniTable* google_protobuf_compiler_Version_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$(((1"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + return mini_table; +} + +const upb_MiniTable* google_protobuf_compiler_CodeGeneratorRequest_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$E13kG"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 15), google_protobuf_FileDescriptorProto_msg_init()); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 3), google_protobuf_compiler_Version_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_compiler_CodeGeneratorResponse_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$1,lG"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 15), google_protobuf_compiler_CodeGeneratorResponse_File_msg_init()); + return mini_table; +} + +const upb_MiniTable* google_protobuf_compiler_CodeGeneratorResponse_File_msg_init() { + static upb_MiniTable* mini_table = NULL; + static const char* mini_descriptor = "$11l13"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTable_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + upb_MiniTable_SetSubMessage(mini_table, (upb_MiniTableField*)upb_MiniTable_FindFieldByNumber(mini_table, 16), google_protobuf_GeneratedCodeInfo_msg_init()); + return mini_table; +} + +const upb_MiniTableEnum* google_protobuf_compiler_CodeGeneratorResponse_Feature_enum_init() { + static const upb_MiniTableEnum* mini_table = NULL; + static const char* mini_descriptor = "!$"; + if (mini_table) return mini_table; + mini_table = + upb_MiniTableEnum_Build(mini_descriptor, strlen(mini_descriptor), + upb_BootstrapArena(), NULL); + return mini_table; +} + diff --git a/upbc/stage0/google/protobuf/compiler/plugin.upb.h b/upbc/stage0/google/protobuf/compiler/plugin.upb.h new file mode 100644 index 0000000000..a7ae766e83 --- /dev/null +++ b/upbc/stage0/google/protobuf/compiler/plugin.upb.h @@ -0,0 +1,585 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * google/protobuf/compiler/plugin.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_ +#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_ + +#include "upb/collections/array_internal.h" +#include "upb/collections/map_gencode_util.h" +#include "upb/message/accessors.h" +#include "upb/message/internal.h" +#include "upb/mini_table/enum_internal.h" +#include "upb/wire/decode.h" +#include "upb/wire/decode_fast.h" +#include "upb/wire/encode.h" + +// Must be last. +#include "upb/port/def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct google_protobuf_compiler_Version google_protobuf_compiler_Version; +typedef struct google_protobuf_compiler_CodeGeneratorRequest google_protobuf_compiler_CodeGeneratorRequest; +typedef struct google_protobuf_compiler_CodeGeneratorResponse google_protobuf_compiler_CodeGeneratorResponse; +typedef struct google_protobuf_compiler_CodeGeneratorResponse_File google_protobuf_compiler_CodeGeneratorResponse_File; +extern const upb_MiniTable* google_protobuf_compiler_Version_msg_init(); +extern const upb_MiniTable* google_protobuf_compiler_CodeGeneratorRequest_msg_init(); +extern const upb_MiniTable* google_protobuf_compiler_CodeGeneratorResponse_msg_init(); +extern const upb_MiniTable* google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(); +struct google_protobuf_FileDescriptorProto; +struct google_protobuf_GeneratedCodeInfo; +extern const upb_MiniTable* google_protobuf_FileDescriptorProto_msg_init(); +extern const upb_MiniTable* google_protobuf_GeneratedCodeInfo_msg_init(); + +typedef enum { + google_protobuf_compiler_CodeGeneratorResponse_FEATURE_NONE = 0, + google_protobuf_compiler_CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL = 1 +} google_protobuf_compiler_CodeGeneratorResponse_Feature; + + +extern const upb_MiniTableEnum* google_protobuf_compiler_CodeGeneratorResponse_Feature_enum_init(); + +/* google.protobuf.compiler.Version */ + +UPB_INLINE google_protobuf_compiler_Version* google_protobuf_compiler_Version_new(upb_Arena* arena) { + return (google_protobuf_compiler_Version*)_upb_Message_New(google_protobuf_compiler_Version_msg_init(), arena); +} +UPB_INLINE google_protobuf_compiler_Version* google_protobuf_compiler_Version_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_compiler_Version* ret = google_protobuf_compiler_Version_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_Version_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_compiler_Version* google_protobuf_compiler_Version_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_compiler_Version* ret = google_protobuf_compiler_Version_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_Version_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_compiler_Version_serialize(const google_protobuf_compiler_Version* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_Version_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_compiler_Version_serialize_ex(const google_protobuf_compiler_Version* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_Version_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_compiler_Version_clear_major(google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_compiler_Version_major(const google_protobuf_compiler_Version* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_Version_has_major(const google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_Version_clear_minor(google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_compiler_Version_minor(const google_protobuf_compiler_Version* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_Version_has_minor(const google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_Version_clear_patch(google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_compiler_Version_patch(const google_protobuf_compiler_Version* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_Version_has_patch(const google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_Version_clear_suffix(google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 4); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_compiler_Version_suffix(const google_protobuf_compiler_Version* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 4); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_Version_has_suffix(const google_protobuf_compiler_Version* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 4); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_compiler_Version_set_major(google_protobuf_compiler_Version *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_Version_set_minor(google_protobuf_compiler_Version *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_Version_set_patch(google_protobuf_compiler_Version *msg, int32_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_Version_set_suffix(google_protobuf_compiler_Version *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_Version_msg_init(), 4); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.compiler.CodeGeneratorRequest */ + +UPB_INLINE google_protobuf_compiler_CodeGeneratorRequest* google_protobuf_compiler_CodeGeneratorRequest_new(upb_Arena* arena) { + return (google_protobuf_compiler_CodeGeneratorRequest*)_upb_Message_New(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), arena); +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorRequest* google_protobuf_compiler_CodeGeneratorRequest_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_compiler_CodeGeneratorRequest* ret = google_protobuf_compiler_CodeGeneratorRequest_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_CodeGeneratorRequest_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorRequest* google_protobuf_compiler_CodeGeneratorRequest_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_compiler_CodeGeneratorRequest* ret = google_protobuf_compiler_CodeGeneratorRequest_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_CodeGeneratorRequest_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_compiler_CodeGeneratorRequest_serialize(const google_protobuf_compiler_CodeGeneratorRequest* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_compiler_CodeGeneratorRequest_serialize_ex(const google_protobuf_compiler_CodeGeneratorRequest* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_CodeGeneratorRequest_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_clear_file_to_generate(google_protobuf_compiler_CodeGeneratorRequest* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView const* google_protobuf_compiler_CodeGeneratorRequest_file_to_generate(const google_protobuf_compiler_CodeGeneratorRequest* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 1); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorRequest_has_file_to_generate(const google_protobuf_compiler_CodeGeneratorRequest* msg) { + size_t size; + google_protobuf_compiler_CodeGeneratorRequest_file_to_generate(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_clear_parameter(google_protobuf_compiler_CodeGeneratorRequest* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_compiler_CodeGeneratorRequest_parameter(const google_protobuf_compiler_CodeGeneratorRequest* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorRequest_has_parameter(const google_protobuf_compiler_CodeGeneratorRequest* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_clear_compiler_version(google_protobuf_compiler_CodeGeneratorRequest* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 3); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_compiler_Version* google_protobuf_compiler_CodeGeneratorRequest_compiler_version(const google_protobuf_compiler_CodeGeneratorRequest* msg) { + const google_protobuf_compiler_Version* default_val = NULL; + const google_protobuf_compiler_Version* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 3); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorRequest_has_compiler_version(const google_protobuf_compiler_CodeGeneratorRequest* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 3); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_clear_proto_file(google_protobuf_compiler_CodeGeneratorRequest* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 15); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const struct google_protobuf_FileDescriptorProto* const* google_protobuf_compiler_CodeGeneratorRequest_proto_file(const google_protobuf_compiler_CodeGeneratorRequest* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 15); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const struct google_protobuf_FileDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorRequest_has_proto_file(const google_protobuf_compiler_CodeGeneratorRequest* msg) { + size_t size; + google_protobuf_compiler_CodeGeneratorRequest_proto_file(msg, &size); + return size != 0; +} + +UPB_INLINE upb_StringView* google_protobuf_compiler_CodeGeneratorRequest_mutable_file_to_generate(google_protobuf_compiler_CodeGeneratorRequest* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 1); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (upb_StringView*)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE upb_StringView* google_protobuf_compiler_CodeGeneratorRequest_resize_file_to_generate(google_protobuf_compiler_CodeGeneratorRequest* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 1); + return (upb_StringView*)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorRequest_add_file_to_generate(google_protobuf_compiler_CodeGeneratorRequest* msg, upb_StringView val, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 1); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return false; + } + _upb_Array_Set(arr, arr->size - 1, &val, sizeof(val)); + return true; +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_set_parameter(google_protobuf_compiler_CodeGeneratorRequest *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_set_compiler_version(google_protobuf_compiler_CodeGeneratorRequest *msg, google_protobuf_compiler_Version* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 3); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_compiler_Version* google_protobuf_compiler_CodeGeneratorRequest_mutable_compiler_version(google_protobuf_compiler_CodeGeneratorRequest* msg, upb_Arena* arena) { + struct google_protobuf_compiler_Version* sub = (struct google_protobuf_compiler_Version*)google_protobuf_compiler_CodeGeneratorRequest_compiler_version(msg); + if (sub == NULL) { + sub = (struct google_protobuf_compiler_Version*)_upb_Message_New(google_protobuf_compiler_Version_msg_init(), arena); + if (sub) google_protobuf_compiler_CodeGeneratorRequest_set_compiler_version(msg, sub); + } + return sub; +} +UPB_INLINE struct google_protobuf_FileDescriptorProto** google_protobuf_compiler_CodeGeneratorRequest_mutable_proto_file(google_protobuf_compiler_CodeGeneratorRequest* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 15); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (struct google_protobuf_FileDescriptorProto**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE struct google_protobuf_FileDescriptorProto** google_protobuf_compiler_CodeGeneratorRequest_resize_proto_file(google_protobuf_compiler_CodeGeneratorRequest* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 15); + return (struct google_protobuf_FileDescriptorProto**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_compiler_CodeGeneratorRequest_add_proto_file(google_protobuf_compiler_CodeGeneratorRequest* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorRequest_msg_init(), 15); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(google_protobuf_FileDescriptorProto_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.compiler.CodeGeneratorResponse */ + +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse* google_protobuf_compiler_CodeGeneratorResponse_new(upb_Arena* arena) { + return (google_protobuf_compiler_CodeGeneratorResponse*)_upb_Message_New(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), arena); +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse* google_protobuf_compiler_CodeGeneratorResponse_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_compiler_CodeGeneratorResponse* ret = google_protobuf_compiler_CodeGeneratorResponse_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_CodeGeneratorResponse_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse* google_protobuf_compiler_CodeGeneratorResponse_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_compiler_CodeGeneratorResponse* ret = google_protobuf_compiler_CodeGeneratorResponse_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_CodeGeneratorResponse_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_compiler_CodeGeneratorResponse_serialize(const google_protobuf_compiler_CodeGeneratorResponse* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_compiler_CodeGeneratorResponse_serialize_ex(const google_protobuf_compiler_CodeGeneratorResponse* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_CodeGeneratorResponse_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_clear_error(google_protobuf_compiler_CodeGeneratorResponse* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_compiler_CodeGeneratorResponse_error(const google_protobuf_compiler_CodeGeneratorResponse* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_has_error(const google_protobuf_compiler_CodeGeneratorResponse* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_clear_supported_features(google_protobuf_compiler_CodeGeneratorResponse* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE uint64_t google_protobuf_compiler_CodeGeneratorResponse_supported_features(const google_protobuf_compiler_CodeGeneratorResponse* msg) { + uint64_t default_val = (uint64_t)0ull; + uint64_t ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_has_supported_features(const google_protobuf_compiler_CodeGeneratorResponse* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_clear_file(google_protobuf_compiler_CodeGeneratorResponse* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 15); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_compiler_CodeGeneratorResponse_File* const* google_protobuf_compiler_CodeGeneratorResponse_file(const google_protobuf_compiler_CodeGeneratorResponse* msg, size_t* size) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 15); + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_compiler_CodeGeneratorResponse_File* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_has_file(const google_protobuf_compiler_CodeGeneratorResponse* msg) { + size_t size; + google_protobuf_compiler_CodeGeneratorResponse_file(msg, &size); + return size != 0; +} + +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_set_error(google_protobuf_compiler_CodeGeneratorResponse *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_set_supported_features(google_protobuf_compiler_CodeGeneratorResponse *msg, uint64_t value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File** google_protobuf_compiler_CodeGeneratorResponse_mutable_file(google_protobuf_compiler_CodeGeneratorResponse* msg, size_t* size) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 15); + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_compiler_CodeGeneratorResponse_File**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File** google_protobuf_compiler_CodeGeneratorResponse_resize_file(google_protobuf_compiler_CodeGeneratorResponse* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 15); + return (google_protobuf_compiler_CodeGeneratorResponse_File**)upb_Message_ResizeArray(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_compiler_CodeGeneratorResponse_File* google_protobuf_compiler_CodeGeneratorResponse_add_file(google_protobuf_compiler_CodeGeneratorResponse* msg, upb_Arena* arena) { + upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_msg_init(), 15); + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_compiler_CodeGeneratorResponse_File* sub = (struct google_protobuf_compiler_CodeGeneratorResponse_File*)_upb_Message_New(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), arena); + if (!arr || !sub) return NULL; + _upb_Array_Set(arr, arr->size - 1, &sub, sizeof(sub)); + return sub; +} + +/* google.protobuf.compiler.CodeGeneratorResponse.File */ + +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File* google_protobuf_compiler_CodeGeneratorResponse_File_new(upb_Arena* arena) { + return (google_protobuf_compiler_CodeGeneratorResponse_File*)_upb_Message_New(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), arena); +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File* google_protobuf_compiler_CodeGeneratorResponse_File_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_compiler_CodeGeneratorResponse_File* ret = google_protobuf_compiler_CodeGeneratorResponse_File_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File* google_protobuf_compiler_CodeGeneratorResponse_File_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_compiler_CodeGeneratorResponse_File* ret = google_protobuf_compiler_CodeGeneratorResponse_File_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_compiler_CodeGeneratorResponse_File_serialize(const google_protobuf_compiler_CodeGeneratorResponse_File* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_compiler_CodeGeneratorResponse_File_serialize_ex(const google_protobuf_compiler_CodeGeneratorResponse_File* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_clear_name(google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 1); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_compiler_CodeGeneratorResponse_File_name(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 1); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_File_has_name(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 1); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_clear_insertion_point(google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 2); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_compiler_CodeGeneratorResponse_File_insertion_point(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 2); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_File_has_insertion_point(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 2); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_clear_content(google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 15); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_compiler_CodeGeneratorResponse_File_content(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 15); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_File_has_content(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 15); + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_clear_generated_code_info(google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 16); + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const struct google_protobuf_GeneratedCodeInfo* google_protobuf_compiler_CodeGeneratorResponse_File_generated_code_info(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const struct google_protobuf_GeneratedCodeInfo* default_val = NULL; + const struct google_protobuf_GeneratedCodeInfo* ret; + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 16); + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_compiler_CodeGeneratorResponse_File_has_generated_code_info(const google_protobuf_compiler_CodeGeneratorResponse_File* msg) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 16); + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_set_name(google_protobuf_compiler_CodeGeneratorResponse_File *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 1); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_set_insertion_point(google_protobuf_compiler_CodeGeneratorResponse_File *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 2); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_set_content(google_protobuf_compiler_CodeGeneratorResponse_File *msg, upb_StringView value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 15); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_compiler_CodeGeneratorResponse_File_set_generated_code_info(google_protobuf_compiler_CodeGeneratorResponse_File *msg, struct google_protobuf_GeneratedCodeInfo* value) { + const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google_protobuf_compiler_CodeGeneratorResponse_File_msg_init(), 16); + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_GeneratedCodeInfo* google_protobuf_compiler_CodeGeneratorResponse_File_mutable_generated_code_info(google_protobuf_compiler_CodeGeneratorResponse_File* msg, upb_Arena* arena) { + struct google_protobuf_GeneratedCodeInfo* sub = (struct google_protobuf_GeneratedCodeInfo*)google_protobuf_compiler_CodeGeneratorResponse_File_generated_code_info(msg); + if (sub == NULL) { + sub = (struct google_protobuf_GeneratedCodeInfo*)_upb_Message_New(google_protobuf_GeneratedCodeInfo_msg_init(), arena); + if (sub) google_protobuf_compiler_CodeGeneratorResponse_File_set_generated_code_info(msg, sub); + } + return sub; +} + +extern const upb_MiniTableFile google_protobuf_compiler_plugin_proto_upb_file_layout; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port/undef.inc" + +#endif /* GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_ */