diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml deleted file mode 100644 index 38ca79304f..0000000000 --- a/.bazelci/presubmit.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -tasks: - ubuntu: - platform: ubuntu1604 - test_targets: - - //... - macos: - platform: macos - test_targets: - - //... diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index 7b9da717aa..0000000000 --- a/.bazelrc +++ /dev/null @@ -1,22 +0,0 @@ -# Use our custom-configured c++ toolchain. - -build:m32 --copt=-m32 --linkopt=-m32 -build:asan --copt=-fsanitize=address --linkopt=-fsanitize=address -build:valgrind --run_under='valgrind --leak-check=full --error-exitcode=1' - -build:ubsan --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 -# Workaround for the fact that Bazel links with $CC, not $CXX -# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748 -build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr - -build:Werror --copt=-Werror -build:Werror --per_file_copt=json/parser@-Wno-error -build:Werror --per_file_copt=com_google_protobuf@-Wno-error - -# GCC's -fanalyzer, a deeper static analysis than normal warnings. -build:analyzer --copt=-fanalyzer --copt=-Werror -build:analyzer --per_file_copt=json/parser@-fno-analyzer -build:analyzer --per_file_copt=com_google_protobuf@-fno-analyzer -build:analyzer --per_file_copt=com_github_google_benchmark@-fno-analyzer - -build:asan-fuzzer --copt=-fsanitize=address,fuzzer --linkopt=-fsanitize=address,fuzzer --define fuzz=true diff --git a/.gitignore b/.gitignore index c9bd5becf8..79d6c53f83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -*.s?? +*.sw? obj/ lib/ bazel-* +_build +.vscode diff --git a/BUILD b/BUILD deleted file mode 100644 index 2e133263a7..0000000000 --- a/BUILD +++ /dev/null @@ -1,410 +0,0 @@ -load( - "//bazel:build_defs.bzl", - "UPB_DEFAULT_COPTS", - "upb_amalgamation", # copybara:strip_for_google3 -) -load( - "//bazel:upb_proto_library.bzl", - "upb_fasttable_enabled", - "upb_proto_library", - "upb_proto_library_copts", - "upb_proto_reflection_library", -) - -# copybara:strip_for_google3_begin -load( - "@rules_proto//proto:defs.bzl", - "proto_library", -) - -# copybara:strip_end - -licenses(["notice"]) # BSD (Google-authored w/ possible external contributions) - -exports_files([ - "LICENSE", - "build_defs", -]) - -config_setting( - name = "windows", - constraint_values = ["@bazel_tools//platforms:windows"], -) - -upb_fasttable_enabled( - name = "fasttable_enabled", - build_setting_default = False, - visibility = ["//visibility:public"], -) - -config_setting( - name = "fasttable_enabled_setting", - flag_values = {"//:fasttable_enabled": "true"}, -) - -upb_proto_library_copts( - name = "upb_proto_library_copts__for_generated_code_only_do_not_use", - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], -) - -# Public C/C++ libraries ####################################################### - -cc_library( - name = "port", - copts = UPB_DEFAULT_COPTS, - textual_hdrs = [ - "upb/port_def.inc", - "upb/port_undef.inc", - ], - visibility = ["//tests:__pkg__"], -) - -cc_library( - name = "upb", - srcs = [ - "upb/decode.c", - "upb/decode.int.h", - "upb/encode.c", - "upb/msg.c", - "upb/msg.h", - "upb/table.c", - "upb/table.int.h", - "upb/upb.c", - "upb/upb.int.h", - ], - hdrs = [ - "upb/decode.h", - "upb/encode.h", - "upb/upb.h", - "upb/upb.hpp", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":fastdecode", - ":port", - "//third_party/wyhash", - ], -) - -cc_library( - name = "fastdecode", - srcs = [ - "upb/decode.int.h", - "upb/decode_fast.c", - "upb/decode_fast.h", - "upb/msg.h", - "upb/upb.int.h", - ], - copts = UPB_DEFAULT_COPTS, - deps = [ - ":port", - ":table", - ], -) - -# Common support routines used by generated code. This library has no -# implementation, but depends on :upb and exposes a few more hdrs. -# -# This is public only because we have no way of visibility-limiting it to -# upb_proto_library() only. This interface is not stable and by using it you -# give up any backward compatibility guarantees. -cc_library( - name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", - hdrs = [ - "upb/decode_fast.h", - "upb/msg.h", - "upb/port_def.inc", - "upb/port_undef.inc", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":table", - ":upb", - ], -) - -upb_proto_library( - name = "descriptor_upb_proto", - visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:descriptor_proto"], -) - -upb_proto_reflection_library( - name = "descriptor_upb_proto_reflection", - visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:descriptor_proto"], -) - -cc_library( - name = "reflection", - srcs = [ - "upb/def.c", - "upb/msg.h", - "upb/reflection.c", - ], - hdrs = [ - "upb/def.h", - "upb/def.hpp", - "upb/reflection.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":descriptor_upb_proto", - ":port", - ":table", - ":upb", - ], -) - -cc_library( - name = "textformat", - srcs = [ - "upb/text_encode.c", - ], - hdrs = [ - "upb/text_encode.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":port", - ":reflection", - ], -) - -cc_library( - name = "json", - srcs = [ - "upb/json_decode.c", - "upb/json_encode.c", - ], - hdrs = [ - "upb/json_decode.h", - "upb/json_encode.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":port", - ":reflection", - ":upb", - ], -) - -# Internal C/C++ libraries ##################################################### - -cc_library( - name = "table", - hdrs = [ - "upb/table.int.h", - "upb/upb.h", - ], - visibility = ["//tests:__pkg__"], - deps = [ - ":port", - ], -) - -# Legacy C/C++ Libraries (not recommended for new code) ######################## - -cc_library( - name = "handlers", - srcs = [ - "upb/handlers.c", - "upb/handlers-inl.h", - "upb/sink.c", - ], - hdrs = [ - "upb/handlers.h", - "upb/sink.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//tests:__pkg__"], - deps = [ - ":port", - ":reflection", - ":table", - ":upb", - ], -) - -cc_library( - name = "upb_pb", - srcs = [ - "upb/pb/compile_decoder.c", - "upb/pb/decoder.c", - "upb/pb/decoder.int.h", - "upb/pb/encoder.c", - "upb/pb/textprinter.c", - "upb/pb/varint.c", - "upb/pb/varint.int.h", - ], - hdrs = [ - "upb/pb/decoder.h", - "upb/pb/encoder.h", - "upb/pb/textprinter.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//tests:__pkg__"], - deps = [ - ":descriptor_upb_proto", - ":handlers", - ":port", - ":reflection", - ":table", - ":upb", - ], -) - -# copybara:strip_for_google3_begin -cc_library( - name = "upb_json", - srcs = [ - "upb/json/parser.c", - "upb/json/printer.c", - ], - hdrs = [ - "upb/json/parser.h", - "upb/json/printer.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//tests:__pkg__"], - deps = [ - ":upb", - ":upb_pb", - ], -) - -genrule( - name = "generate_json_ragel", - srcs = ["//:upb/json/parser.rl"], - outs = ["upb/json/parser.c"], - cmd = "$(location @ragel//:ragelc) -C -o upb/json/parser.c $< && mv upb/json/parser.c $@", - tools = ["@ragel//:ragelc"], - visibility = ["//cmake:__pkg__"], -) - -# Amalgamation ################################################################# - -py_binary( - name = "amalgamate", - srcs = ["tools/amalgamate.py"], -) - -upb_amalgamation( - name = "gen_amalgamation", - outs = [ - "upb.c", - "upb.h", - ], - amalgamator = ":amalgamate", - libs = [ - ":upb", - ":fastdecode", - ":descriptor_upb_proto", - ":reflection", - ":handlers", - ":port", - ":upb_pb", - ":upb_json", - ], -) - -cc_library( - name = "amalgamation", - srcs = ["upb.c"], - hdrs = ["upb.h"], - copts = UPB_DEFAULT_COPTS, - deps = ["//third_party/wyhash"], -) - -upb_amalgamation( - name = "gen_php_amalgamation", - outs = [ - "php-upb.c", - "php-upb.h", - ], - amalgamator = ":amalgamate", - libs = [ - ":upb", - ":fastdecode", - ":descriptor_upb_proto", - ":descriptor_upb_proto_reflection", - ":reflection", - ":port", - ":json", - ], - prefix = "php-", -) - -cc_library( - name = "php_amalgamation", - srcs = ["php-upb.c"], - hdrs = ["php-upb.h"], - copts = UPB_DEFAULT_COPTS, - deps = ["//third_party/wyhash"], -) - -upb_amalgamation( - name = "gen_ruby_amalgamation", - outs = [ - "ruby-upb.c", - "ruby-upb.h", - ], - amalgamator = ":amalgamate", - libs = [ - ":upb", - ":fastdecode", - ":descriptor_upb_proto", - ":reflection", - ":port", - ":json", - ], - prefix = "ruby-", -) - -cc_library( - name = "ruby_amalgamation", - srcs = ["ruby-upb.c"], - hdrs = ["ruby-upb.h"], - copts = UPB_DEFAULT_COPTS, - deps = ["//third_party/wyhash"], -) - -exports_files( - [ - "upb/json/parser.rl", - "BUILD", - "WORKSPACE", - ], - visibility = ["//cmake:__pkg__"], -) - -exports_files( - [ - "third_party/lunit/console.lua", - "third_party/lunit/lunit.lua", - ], - visibility = ["//tests/bindings/lua:__pkg__"], -) - -filegroup( - name = "cmake_files", - srcs = glob([ - "upb/json/parser.c", - "CMakeLists.txt", - "generated_for_cmake/**/*", - "google/**/*", - "upbc/**/*", - "upb/**/*", - "tests/**/*", - "third_party/**/*", - ]), - visibility = ["//cmake:__pkg__"], -) - -# copybara:strip_end diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 2f866b4e29..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,7 +0,0 @@ -## Signing the CLA - -Please sign the [Google Contributor License Agreement -(CLA)](https://cla.developers.google.com/) -before sending pull requests. For any code changes to be -accepted, the CLA must be signed. It's a quick process, I -promise! diff --git a/DESIGN.md b/DESIGN.md deleted file mode 100644 index a7a8a28451..0000000000 --- a/DESIGN.md +++ /dev/null @@ -1,72 +0,0 @@ - -μpb Design ----------- - -μpb has the following design goals: - -- C89 compatible. -- small code size (both for the core library and generated messages). -- fast performance (hundreds of MB/s). -- idiomatic for C programs. -- easy to wrap in high-level languages (Python, Ruby, Lua, etc) with - good performance and all standard protobuf features. -- hands-off about memory management, allowing for easy integration - with existing VMs and/or garbage collectors. -- offers binary ABI compatibility between apps, generated messages, and - the core library (doesn't require re-generating messages or recompiling - your application when the core library changes). -- provides all features that users expect from a protobuf library - (generated messages in C, reflection, text format, etc.). -- layered, so the core is small and doesn't require descriptors. -- tidy about symbol references, so that any messages or features that - aren't used by a C program can have their code GC'd by the linker. -- possible to use protobuf binary format without leaking message/field - names into the binary. - -μpb accomplishes these goals by keeping a very small core that does not contain -descriptors. We need some way of knowing what fields are in each message and -where they live, but instead of descriptors, we keep a small/lightweight summary -of the .proto file. We call this a `upb_msglayout`. It contains the bare -minimum of what we need to know to parse and serialize protobuf binary format -into our internal representation for messages, `upb_msg`. - -The core then contains functions to parse/serialize a message, given a `upb_msg*` -and a `const upb_msglayout*`. - -This approach is similar to [nanopb](https://github.com/nanopb/nanopb) which -also compiles message definitions to a compact, internal representation without -names. However nanopb does not aim to be a fully-featured library, and has no -support for text format, JSON, or descriptors. μpb is unique in that it has a -small core similar to nanopb (though not quite as small), but also offers a -full-featured protobuf library for applications that want reflection, text -format, JSON format, etc. - -Without descriptors, the core doesn't have access to field names, so it cannot -parse/serialize to protobuf text format or JSON. Instead this functionality -lives in separate modules that depend on the module implementing descriptors. -With the descriptor module we can parse/serialize binary descriptors and -validate that they follow all the rules of protobuf schemas. - -To provide binary compatibility, we version the structs that generated messages -use to create a `upb_msglayout*`. The current initializers are -`upb_msglayout_msginit_v1`, `upb_msglayout_fieldinit_v1`, etc. Then -`upb_msglayout*` uses these as its internal representation. If upb changes its -internal representation for a `upb_msglayout*`, it will also include code to -convert the old representation to the new representation. This will use some -more memory/CPU at runtime to convert between the two, but apps that statically -link μpb will never need to worry about this. - -TODO ----- - -1. revise our generated code until it is in a state where we feel comfortable - committing to API/ABI stability for it. In particular there is an open - question of whether non-ABI-compatible field accesses should have a - fastpath different from the ABI-compatible field access. -1. Add missing features (maps, extensions, unknown fields). -1. Flesh out C++ wrappers. -1. *(lower-priority)*: revise all of the existing encoders/decoders and - handlers. We probably will want to keep handlers, since they let us decouple - encoders/decoders from `upb_msg`, but we need to simplify all of that a LOT. - Likely we will want to make handlers only per-message instead of per-field, - except for variable-length fields. diff --git a/README.md b/README.md index a08aa0e909..76ff0f6e6f 100644 --- a/README.md +++ b/README.md @@ -1,134 +1,3 @@ +# As of August 25, 2023, μpb has moved into the protobuf repo [here](https://github.com/protocolbuffers/protobuf/tree/main/upb). All further development is happening there, and this repo is no longer being updated. -# μpb - a small protobuf implementation in C - -|Platform|Build Status| -|--------|------------| -|macOS|[![Build Status](https://storage.googleapis.com/upb-kokoro-results/status-badge/macos.png)](https://fusion.corp.google.com/projectanalysis/summary/KOKORO/prod%3Aupb%2Fmacos%2Fcontinuous)| -|ubuntu|[![Build Status](https://storage.googleapis.com/upb-kokoro-results/status-badge/ubuntu.png)](https://fusion.corp.google.com/projectanalysis/summary/KOKORO/prod%3Aupb%2Fubuntu%2Fcontinuous)| - -μpb (often written 'upb') is a small protobuf implementation written in C. - -upb generates a C API for creating, parsing, and serializing messages -as declared in `.proto` files. upb is heavily arena-based: all -messages always live in an arena (note: the arena can live in stack or -static memory if desired). Here is a simple example: - -```c -#include "conformance/conformance.upb.h" - -void foo(const char* data, size_t size) { - upb_arena *arena; - - /* Generated message type. */ - conformance_ConformanceRequest *request; - conformance_ConformanceResponse *response; - - arena = upb_arena_new(); - request = conformance_ConformanceRequest_parse(data, size, arena); - response = conformance_ConformanceResponse_new(arena); - - switch (conformance_ConformanceRequest_payload_case(request)) { - case conformance_ConformanceRequest_payload_protobuf_payload: { - upb_strview payload = conformance_ConformanceRequest_protobuf_payload(request); - // ... - break; - } - - case conformance_ConformanceRequest_payload_NOT_SET: - fprintf(stderr, "conformance_upb: Request didn't have payload.\n"); - break; - - default: { - static const char msg[] = "Unsupported input format."; - conformance_ConformanceResponse_set_skipped( - response, upb_strview_make(msg, sizeof(msg))); - break; - } - } - - /* Frees all messages on the arena. */ - upb_arena_free(arena); -} -``` - -API and ABI are both subject to change! Please do not distribute -as a shared library for this reason (for now at least). - -## Using upb in your project - -Currently only Bazel is supported (CMake support is partial and incomplete -but full CMake support is an eventual goal). - -To use upb in your Bazel project, first add upb to your `WORKSPACE` file, -either as a `git_repository()` or as a `new_local_repository()` with a -Git Submodule. (For an example, see `examples/bazel/ in this repo). - -```python -# Add this to your WORKSPACE file. -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -git_repository( - name = "upb", - remote = "https://github.com/protocolbuffers/upb.git", - commit = "d16bf99ac4658793748cda3251226059892b3b7b", -) - -load("@upb//bazel:workspace_deps.bzl", "upb_deps") - -upb_deps() -``` - -Then in your BUILD file you can add `upb_proto_library()` rules that -generate code for a corresponding `proto_library()` rule. For -example: - -```python -# Add this to your BUILD file. -load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") - -proto_library( - name = "foo_proto", - srcs = ["foo.proto"], -) - -upb_proto_library( - name = "foo_upbproto", - deps = [":foo_proto"], -) - -cc_binary( - name = "test_binary", - srcs = ["test_binary.c"], - deps = [":foo_upbproto"], -) -``` - -Then in your `.c` file you can #include the generated header: - -```c -#include "foo.upb.h" - -/* Insert code that uses generated types. */ -``` - -## Old "handlers" interfaces - -This library contains several semi-deprecated interfaces (see BUILD -file for more info about which interfaces are deprecated). These -deprecated interfaces are still used in some significant projects, -such as the Ruby and PHP C bindings for protobuf in the [main protobuf -repo](https://github.com/protocolbuffers/protobuf). The goal is to -migrate the Ruby/PHP bindings to use the newer, simpler interfaces -instead. Please do not use the old interfaces in new code. - -## Lua bindings - -This repo has some Lua bindings for the core library. These are -experimental and very incomplete. These are currently included in -order to validate that the C API is suitable for wrapping. As the -project matures these Lua bindings may become publicly available. - -## Contact - -Author: Josh Haberman ([jhaberman@gmail.com](mailto:jhaberman@gmail.com), -[haberman@google.com](mailto:haberman@google.com)) +## μpb: small, fast C protos (archived) diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index a0b04ad044..0000000000 --- a/WORKSPACE +++ /dev/null @@ -1,48 +0,0 @@ -workspace(name = "upb") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") -load("//bazel:workspace_deps.bzl", "upb_deps") - -upb_deps() - -http_archive( - name = "lua", - build_file = "//bazel:lua.BUILD", - sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b", - strip_prefix = "lua-5.2.4", - urls = [ - "https://mirror.bazel.build/www.lua.org/ftp/lua-5.2.4.tar.gz", - "https://www.lua.org/ftp/lua-5.2.4.tar.gz", - ], -) - -http_archive( - name = "ragel", - build_file = "//bazel:ragel.BUILD", - sha256 = "5f156edb65d20b856d638dd9ee2dfb43285914d9aa2b6ec779dac0270cd56c3f", - strip_prefix = "ragel-6.10", - urls = ["http://www.colm.net/files/ragel/ragel-6.10.tar.gz"], -) - -http_archive( - name = "com_google_googletest", - urls = ["https://github.com/google/googletest/archive/b6cd405286ed8635ece71c72f118e659f4ade3fb.zip"], # 2019-01-07 - strip_prefix = "googletest-b6cd405286ed8635ece71c72f118e659f4ade3fb", - sha256 = "ff7a82736e158c077e76188232eac77913a15dac0b22508c390ab3f88e6d6d86", -) - -http_archive( - name = "com_github_google_benchmark", - urls = ["https://github.com/google/benchmark/archive/16703ff83c1ae6d53e5155df3bb3ab0bc96083be.zip"], - strip_prefix = "benchmark-16703ff83c1ae6d53e5155df3bb3ab0bc96083be", - sha256 = "59f918c8ccd4d74b6ac43484467b500f1d64b40cc1010daa055375b322a43ba3", -) - -new_git_repository( - name = "com_google_googleapis", - remote = "https://github.com/googleapis/googleapis.git", - branch = "master", - build_file = "//benchmarks:BUILD.googleapis", - patch_cmds = ["find google -type f -name BUILD.bazel -delete"], -) diff --git a/archive/.bazelci/presubmit.yml b/archive/.bazelci/presubmit.yml new file mode 100644 index 0000000000..c763047142 --- /dev/null +++ b/archive/.bazelci/presubmit.yml @@ -0,0 +1,16 @@ +--- +tasks: + ubuntu: + platform: ubuntu2004 + shell_commands: + - "sudo apt -y update && sudo apt -y install libreadline-dev cmake rsync" + build_flags: + - "--incompatible_disallow_empty_glob" + test_targets: + - //... + macos: + platform: macos + build_flags: + - "--incompatible_disallow_empty_glob" + test_targets: + - //... diff --git a/archive/.bazelignore b/archive/.bazelignore new file mode 100644 index 0000000000..e35d8850c9 --- /dev/null +++ b/archive/.bazelignore @@ -0,0 +1 @@ +_build diff --git a/archive/.bazelrc b/archive/.bazelrc new file mode 100644 index 0000000000..464bef55b1 --- /dev/null +++ b/archive/.bazelrc @@ -0,0 +1,63 @@ +# temporary fix for https://github.com/bazelbuild/bazel/issues/12905 on macOS +build --features=-debug_prefix_map_pwd_is_dot + +# Pin to C++17 +build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 +build:cpp17_msvc --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 + +# Disallow empty globs +build: --incompatible_disallow_empty_glob + +# Use our custom-configured c++ toolchain. + +build:m32 --copt=-m32 --linkopt=-m32 +build:asan --copt=-fsanitize=address --linkopt=-fsanitize=address +build:msan --copt=-fsanitize=memory --linkopt=-fsanitize=memory + +# For Valgrind, we have to disable checks of "possible" leaks because the Python +# interpreter does the sorts of things that flag Valgrind "possible" leak checks. +# Ideally we could enforce a stricter check for the non-Python tests, but I don't +# know of an easy way to do that. +# +# We also have to disable pymalloc to avoid triggering Valgrind. +build:valgrind --run_under='valgrind --leak-check=full --track-origins=yes --trace-children=yes --show-leak-kinds=all --error-exitcode=1 --num-callers=500 ' --action_env=PYTHONMALLOC=malloc + +build:ubsan --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 +# Workaround for the fact that Bazel links with $CC, not $CXX +# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748 +build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr +# Workaround for https://bugs.llvm.org/show_bug.cgi?id=16404 +build:ubsan --linkopt=--rtlib=compiler-rt --linkopt=-lunwind + +build:Werror --copt=-Werror +build:Werror --per_file_copt=json/parser@-Wno-error +build:Werror --per_file_copt=com_google_protobuf@-Wno-error + +# GCC's -fanalyzer, a deeper static analysis than normal warnings. +build:analyzer --copt=-fanalyzer --copt=-Werror +build:analyzer --per_file_copt=json/parser@-fno-analyzer +build:analyzer --per_file_copt=com_google_protobuf@-fno-analyzer +build:analyzer --per_file_copt=com_github_google_benchmark@-fno-analyzer + +# --config=asan-libfuzzer +build:asan-libfuzzer --action_env=CC=clang +build:asan-libfuzzer --action_env=CXX=clang++ +build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer +build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan + +# --config=msan-libfuzzer +build:msan-libfuzzer --action_env=CC=clang +build:msan-libfuzzer --action_env=CXX=clang++ +build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer +build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan + +# --config=ubsan-libfuzzer +build:ubsan-libfuzzer --action_env=CC=clang +build:ubsan-libfuzzer --action_env=CXX=clang++ +build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer +build:ubsan-libfuzzer --copt=-fsanitize=undefined +build:ubsan-libfuzzer --linkopt=-fsanitize=undefined +build:ubsan-libfuzzer --linkopt=-fsanitize-link-c++-runtime diff --git a/archive/.clang-format b/archive/.clang-format new file mode 100644 index 0000000000..24d97f2b22 --- /dev/null +++ b/archive/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: Google +DerivePointerAlignment: false +PointerAlignment: Left diff --git a/archive/.github/actions/setup-bazel-cache/action.yml b/archive/.github/actions/setup-bazel-cache/action.yml new file mode 100644 index 0000000000..ac9ea83329 --- /dev/null +++ b/archive/.github/actions/setup-bazel-cache/action.yml @@ -0,0 +1,21 @@ +name: "Setup Bazel Caching" +description: "Sets up Bazel caching" +inputs: + cache_url: + description: "URL of the Bazel cache to read/write" + required: false + default: https://storage.googleapis.com/protobuf-bazel-cache/upb + read_only: + description: "If true, we can read from the cache but not write it." + required: false + default: ${{ github.event.pull_request.head.repo.full_name != 'protocolbuffers/upb' }} +outputs: + cache_args: + description: "Caching related arguments to pass to 'bazel build" + value: --remote_cache=${{ inputs.cache_url }} ${{ steps.set_auth_arg.outputs.auth_arg }} +runs: + using: "composite" + steps: + - id: set_auth_arg + run: echo auth_arg=${{ inputs.read_only == 'true' && '--remote_upload_local_results=false' || '--google_default_credentials' }} >> $GITHUB_OUTPUT + shell: bash diff --git a/archive/.github/workflows/bazel_tests.yml b/archive/.github/workflows/bazel_tests.yml new file mode 100644 index 0000000000..851f0f024a --- /dev/null +++ b/archive/.github/workflows/bazel_tests.yml @@ -0,0 +1,107 @@ +name: Bazel Tests + +on: + push: + branches: + - main + - '[0-9]+.x' + pull_request: + branches: + - main + - '[0-9]+.x' + workflow_dispatch: + +jobs: + + ubuntu: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false # Don't cancel all jobs if one fails. + matrix: + include: + - { NAME: "Fastbuild", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "" } + - { NAME: "Optimized", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "-c opt" } # Some warnings only fire with -c opt + - { NAME: "GCC Optimized", BAZEL: bazel, CC: gcc-12, os: ubuntu-22.04, flags: "-c opt" } + - { NAME: "FastTable", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--//:fasttable_enabled=true -- -cmake:test_generated_files" } + - { NAME: "ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg -- -benchmarks:benchmark -python/..." } + - { NAME: "UBSAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=ubsan -c dbg -- -benchmarks:benchmark -python/... -lua/...", install: "libunwind-dev" } + - { NAME: "32-bit", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--copt=-m32 --linkopt=-m32 -- benchmarks:benchmark -python/...", install: "g++-multilib" } + - { NAME: "32-bit ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg --copt=-m32 --linkopt=-m32 -- -//benchmarks/... -//python/... -//upb/message:copy_test -//upb/message:promote_test -//upb/message:test -//upb/test:test_generated_code", install: "g++-multilib" } + - { NAME: "Windows", BAZEL: bazel, os: windows-2019, startup-flags: "--output_user_root=C:/tmp", flags: "--config=cpp17_msvc", targets: "upb/... upbc/... python/... protos/... protos_generator/..." } + - { NAME: "macOS", BAZEL: bazel, CC: clang, os: macos-11 } + # Current github runners are all Intel based, so just build/compile for Apple Silicon to detect issues there. + - { NAME: "macOS ARM (build only)", BAZEL: bazel, BAZEL_CMD: build, CC: clang, os: macos-11, flags: "--cpu=darwin_arm64"} + # We support two Bazel versions back per https://opensource.google/documentation/policies/cplusplus-support + - { NAME: "Bazel 5.3.0", BAZEL: bazel-5.3.0-linux-x86_64, CC: clang, os: ubuntu-20-large } + - { NAME: "Bazel 6.1.0", BAZEL: bazel-6.1.0-linux-x86_64, CC: clang, os: ubuntu-20-large } + + name: ${{ matrix.NAME }} + + steps: + - uses: actions/checkout@v2 + - name: Set up Cloud SDK + uses: google-github-actions/auth@v0 + with: + credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} + export_environment_variables: true + if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }} + - name: Download historical Bazel version + run: | + FILENAME=$HOME/bin/${{ matrix.BAZEL }} + VERSION=$(echo ${{ matrix.BAZEL }} | cut -d- -f 2 ) + mkdir -p $HOME/bin + echo $HOME/bin >> $GITHUB_PATH + wget -O $FILENAME https://github.com/bazelbuild/bazel/releases/download/$VERSION/${{ matrix.BAZEL }} + chmod a+x $FILENAME + if: ${{ matrix.BAZEL != 'bazel' }} + - name: Check compiler versions + if: matrix.CC + run: ${{ matrix.CC }} --version + - name: Check Bazel versions + run: ${{ matrix.BAZEL }} --version + - id: bazel-cache + name: Set up Bazel caching + uses: ./.github/actions/setup-bazel-cache + - name: Setup Python venv + if: ${{ runner.os != 'Windows' }} + run: rm -rf /tmp/venv && python3 -m venv /tmp/venv && source /tmp/venv/bin/activate && python3 --version + - name: Install dependencies + run: sudo apt update && sudo apt install -y ${{ matrix.install }} + if: matrix.install != '' + - name: Install numpy + run: pip3 install numpy + - name: Setup environment variables + if: matrix.CC + run: echo "CC=${{ matrix.CC }}" >> $GITHUB_ENV + - name: Run tests + run: cd ${{ github.workspace }} && ${{ matrix.BAZEL }} ${{ matrix.startup-flags }} ${{ matrix.BAZEL_CMD || 'test' }} --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} ${{ matrix.targets || '...' }} ${{ matrix.flags }} + - uses: actions/upload-artifact@v3 + with: + name: logs + path: | + **/*.log + + no-python: + runs-on: ubuntu-20-large + + strategy: + fail-fast: false # Don't cancel all jobs if one fails. + + name: "No System Python" + + steps: + - uses: actions/checkout@v2 + - name: Set up Cloud SDK + uses: google-github-actions/auth@v0 + with: + credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} + export_environment_variables: true + if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }} + - id: bazel-cache + name: Set up Bazel caching + uses: ./.github/actions/setup-bazel-cache + - name: Uninstall python + run: which python3 && sudo mv `which python3` /tmp && ! which python3 + - name: Run tests + run: cd ${{ github.workspace }} && bazel test --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} //python/... -- -//python/dist:source_wheel diff --git a/archive/.github/workflows/clang_format.yml b/archive/.github/workflows/clang_format.yml new file mode 100644 index 0000000000..5103500586 --- /dev/null +++ b/archive/.github/workflows/clang_format.yml @@ -0,0 +1,22 @@ +name: Check ClangFormat + +on: + push: + branches: + - main + - '[0-9]+.x' + pull_request: + branches: + - main + - '[0-9]+.x' + workflow_dispatch: + +jobs: + check_clang_format: + runs-on: ubuntu-20-large + steps: + - uses: actions/checkout@v2 + - name: Run ClangFormat + run: find . | grep -E '\.(c|h|cc)$' | grep -E -v '^./(third_party|cmake)' | xargs clang-format -i + - name: Check for differences + run: git diff --exit-code diff --git a/archive/.github/workflows/generate_files.yml b/archive/.github/workflows/generate_files.yml new file mode 100644 index 0000000000..ce9d4da3e2 --- /dev/null +++ b/archive/.github/workflows/generate_files.yml @@ -0,0 +1,24 @@ +name: Generate Files + +# After any push to the main branch, re-generate pregenerated files. +on: + push: + branches: + - main + - '[0-9]+.x' + +jobs: + generate: + if: github.repository == 'protocolbuffers/upb' + runs-on: ubuntu-22-large + + steps: + - uses: actions/checkout@v3 + with: + # Note: this token has an expiration date, so if the workflow starts + # failing then you may need to generate a fresh token. + token: ${{ secrets.BOT_ACCESS_TOKEN }} + - name: Configure name and email address in Git + run: cd ${{ github.workspace }} && git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com" + - name: Commit and push update + run: cd ${{ github.workspace }} && ./cmake/push_auto_update.sh diff --git a/archive/.github/workflows/mergeable.yml b/archive/.github/workflows/mergeable.yml new file mode 100644 index 0000000000..255bc1c92c --- /dev/null +++ b/archive/.github/workflows/mergeable.yml @@ -0,0 +1,15 @@ +mergeable: + pull_requests: + label: + and: + - must_exclude: + regex: '^disposition/DO NOT MERGE' + message: 'Pull request marked not mergeable' + - must_include: + regex: 'mergeable:force-allow' + message: 'Pull requests should not be merged directly and should instead + be handled by Copybara. + + To enable Github merges, add the `mergeable:force-allow` label and get a second + approval. This should almost never be used except for releases or as a break glass + measure after discussing with the team.' \ No newline at end of file diff --git a/archive/.github/workflows/python_tests.yml b/archive/.github/workflows/python_tests.yml new file mode 100644 index 0000000000..42d93a739b --- /dev/null +++ b/archive/.github/workflows/python_tests.yml @@ -0,0 +1,173 @@ +name: Python Tests + +on: + push: + branches: + - main + - '[0-9]+.x' + pull_request: + branches: + - main + - '[0-9]+.x' + workflow_dispatch: + +jobs: + build_wheels: + name: Build Wheels + runs-on: ubuntu-large + if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }} + env: + # Bazel 5.4.0. Once we have moved to toolchains, we can update to Bazel 6.x. + DOCKER_IMAGE: us-docker.pkg.dev/protobuf-build/release-containers/linux/apple@sha256:bb1d14738449916d489c1cbb062508c4dca5bd265ea3e67a2628ae40912b9b00 + + steps: + - uses: actions/checkout@v2 + - name: Set up Cloud SDK + uses: google-github-actions/auth@v0 + with: + credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} + export_environment_variables: true + - name: Use gcloud CLI + run: gcloud info + - name: Configure Docker + run: gcloud auth configure-docker -q us-docker.pkg.dev + - name: Pull Docker Image + run: docker pull $DOCKER_IMAGE + - name: Check Bazel version + run: cd ${{ github.workspace }} && docker run -v$PWD:/workspace $DOCKER_IMAGE --version + - id: bazel-cache + name: Set up Bazel caching + uses: ./.github/actions/setup-bazel-cache + - name: Build Wheels + run: cd ${{ github.workspace }} && docker run -e GOOGLE_APPLICATION_CREDENTIALS=/workspace/$(basename $GOOGLE_APPLICATION_CREDENTIALS) -v$PWD:/workspace $DOCKER_IMAGE build $BAZEL_CACHE --crosstool_top=@com_google_protobuf//toolchain:clang_suite --@com_google_protobuf//toolchain:release=true --symlink_prefix=/ -c dbg python/dist ${{ steps.bazel-cache.outputs.cache_args }} python/dist:test_wheel python/dist:source_wheel + - name: Move Wheels + run: mkdir wheels && find _build/out \( -name 'protobuf*.whl' -o -name 'protobuf-*.tar.gz' \) -exec mv '{}' wheels ';' + - uses: actions/upload-artifact@v3 + with: + name: python-wheels + path: wheels/ + - uses: actions/upload-artifact@v3 + with: + name: requirements + # Tests shouldn't have access to the whole upb repo, upload the one file we need + path: python/requirements.txt + + test_wheels: + name: Test Wheels + needs: build_wheels + strategy: + fail-fast: false # Don't cancel all jobs if one fails. + matrix: + include: + # Linux and Mac use the limited API, so all Python versions will use a single wheel. + # As a result we can just test the oldest and newest supported Python versions and assume + # this gives us sufficient test coverage. + - { os: ubuntu-18-large, python-version: "3.7", architecture: x64, type: 'binary' } + - { os: macos-11, python-version: "3.7", architecture: x64, type: 'binary' } + - { os: ubuntu-20-large, python-version: "3.10", architecture: x64, type: 'binary' } + - { os: macos-12, python-version: "3.10", architecture: x64, type: 'binary' } + - { os: ubuntu-18-large, python-version: "3.7", architecture: x64, type: 'source' } + - { os: macos-11, python-version: "3.7", architecture: x64, type: 'source' } + - { os: ubuntu-20-large, python-version: "3.10", architecture: x64, type: 'source' } + - { os: macos-12, python-version: "3.10", architecture: x64, type: 'source' } + + # Windows uses the full API up until Python 3.10, so each of these + # jobs tests a distinct binary wheel. + - { os: windows-2019-large, python-version: "3.7", architecture: x86, type: 'binary' } + - { os: windows-2019-large, python-version: "3.8", architecture: x86, type: 'binary' } + - { os: windows-2019-large, python-version: "3.9", architecture: x86, type: 'binary' } + - { os: windows-2019-large, python-version: "3.10", architecture: x86, type: 'binary' } + - { os: windows-2019-large, python-version: "3.7", architecture: x64, type: 'binary' } + - { os: windows-2019-large, python-version: "3.8", architecture: x64, type: 'binary' } + - { os: windows-2019-large, python-version: "3.9", architecture: x64, type: 'binary' } + - { os: windows-2019-large, python-version: "3.10", architecture: x64, type: 'binary' } + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: + - name: Download Wheels + uses: actions/download-artifact@v3 + with: + name: python-wheels + path: wheels + - name: Download Requirements + uses: actions/download-artifact@v3 + with: + name: requirements + path: requirements + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} + - name: Setup Python venv + run: | + python -m pip install --upgrade pip + python -m venv env + # Windows uses 'Scripts' instead of 'bin' + source env/bin/activate || source env/Scripts/activate + echo "VIRTUAL ENV:" $VIRTUAL_ENV + - name: Install tzdata + run: pip install tzdata + # Only needed on Windows, Linux ships with tzdata. + if: ${{ contains(matrix.os, 'windows') }} + - name: Install requirements + run: pip install -r requirements/requirements.txt + - name: Install Protobuf Binary Wheel + run: pip install -vvv --no-index --find-links wheels protobuf + if: ${{ matrix.type == 'binary' }} + - name: Install Protobuf Source Wheel + run: | + cd wheels + tar -xzvf *.tar.gz + cd protobuf-*/ + pip install . + if: ${{ matrix.type == 'source' }} + - name: Test that module is importable + run: python -v -c 'from google._upb import _message; assert "google._upb._message.MessageMeta" in str(_message.MessageMeta)' + if: ${{ !matrix.pure_python }} + - name: Install Protobuf Test Wheel + run: pip install -vvv --no-index --find-links wheels protobuftests + - name: Run the unit tests + run: | + TESTS=$(pip show -f protobuftests | grep pb_unit_tests.*py$ | sed 's,/,.,g' | sed 's,\\,.,g' | sed -E 's,.py$,,g') + for test in $TESTS; do + python -m unittest -v $test + done + + test_pure_python_wheels: + name: Test Pure Python Wheels + needs: build_wheels + strategy: + fail-fast: false # Don't cancel all jobs if one fails. + matrix: + python-version: ["3.7", "3.10"] + runs-on: ubuntu-large + + steps: + - name: Download Wheels + uses: actions/download-artifact@v3 + with: + name: python-wheels + path: wheels + - name: Delete Binary Wheels + run: find wheels -type f | grep -v none-any | xargs rm + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Setup Python venv + run: | + python -m pip install --upgrade pip + python -m venv env + source env/bin/activate + echo "VIRTUAL ENV:" $VIRTUAL_ENV + - name: Install numpy + run: pip install numpy + - name: Install Protobuf Wheels + run: pip install -vvv --no-index --find-links wheels protobuf protobuftests + - name: Run the unit tests + run: | + TESTS=$(pip show -f protobuftests | grep _test.py | sed 's,/,.,g' | sed -E 's,.py$,,g') + for test in $TESTS; do + python -m unittest -v $test + done diff --git a/archive/BUILD b/archive/BUILD new file mode 100644 index 0000000000..49aa2ccf8b --- /dev/null +++ b/archive/BUILD @@ -0,0 +1,744 @@ +# 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. + +load("@rules_python//python:defs.bzl", "py_binary") +load("//bazel:build_defs.bzl", "UPB_DEFAULT_COPTS") +load( + "//bazel:upb_proto_library.bzl", + "upb_proto_library_copts", + "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("//tools/build_defs/kotlin/native:rules.bzl", "kt_native_interop_hint") +# load("//tools/build_defs/license:license.bzl", "license") +# end:google_only + +# begin:github_only +load( + "//bazel:amalgamation.bzl", + "upb_amalgamation", +) +# end:github_only + +# begin:google_only +# package(default_applicable_licenses = ["//:license"]) +# +# license( +# name = "license", +# package_name = "upb", +# ) +# end:google_only + +licenses(["notice"]) + +exports_files(["LICENSE"]) + +exports_files( + [ + "BUILD", + "WORKSPACE", + ], + visibility = ["//cmake:__pkg__"], +) + +config_setting( + name = "windows", + constraint_values = ["@platforms//os:windows"], + visibility = ["//visibility:public"], +) + +bool_flag( + name = "fasttable_enabled", + build_setting_default = False, + visibility = ["//visibility:public"], +) + +config_setting( + name = "fasttable_enabled_setting", + flag_values = {"//:fasttable_enabled": "true"}, + visibility = ["//visibility:public"], +) + +upb_proto_library_copts( + name = "upb_proto_library_copts__for_generated_code_only_do_not_use", + copts = UPB_DEFAULT_COPTS, + visibility = ["//visibility:public"], +) + +# Please update copy.bara.sky target = ":friends" if +# you make changes to this list. +package_group( + name = "friends", + packages = ["//..."], +) + +# This is a stub library to keep gRPC happy. Do not use it for any reason, +# use the smaller targets below instead. +cc_library( + name = "upb", + hdrs = [ + "upb/upb.hpp", + ], + copts = UPB_DEFAULT_COPTS, + visibility = ["//visibility:public"], + deps = [ + ":base", + ":mem", + ], +) + +# Common support routines used by generated code. This library has no +# implementation, but depends on :upb and exposes a few more hdrs. +# +# This is public only because we have no way of visibility-limiting it to +# upb_proto_library() only. This interface is not stable and by using it you +# give up any backward compatibility guarantees. +cc_library( + name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + hdrs = ["upb/generated_code_support.h"], + copts = UPB_DEFAULT_COPTS, + textual_hdrs = [ + "//upb/port:inc", + ], + visibility = ["//visibility:public"], + deps = [ + ":base", + ":collections", + ":collections_internal", + ":mem", + ":message", + ":message_accessors", + ":message_accessors_internal", + ":message_internal", + ":mini_descriptor", + ":mini_table", + ":wire", + ":wire_internal", + ], +) + +# Common support code for C++ generated code. +cc_library( + name = "generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + copts = UPB_DEFAULT_COPTS, + textual_hdrs = [ + "//upb/port:inc", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + hdrs = [ + "upb/reflection/def.h", + "upb/reflection/internal/def_pool.h", + ], + copts = UPB_DEFAULT_COPTS, + textual_hdrs = [ + "//upb/port:inc", + ], + visibility = ["//visibility:public"], + deps = [ + ":mem", + ":mini_descriptor", + ":reflection_internal", + ], +) + +bootstrap_upb_proto_library( + name = "descriptor_upb_proto", + base_dir = "upb/reflection/", + # TODO(b/289127200): Export 'net/proto2/proto/descriptor.upb.h' and remove "-layering_check". + features = ["-layering_check"], + 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"], +) + +upb_proto_reflection_library( + name = "descriptor_upb_proto_reflection", + visibility = ["//visibility:public"], + deps = ["@com_google_protobuf//:descriptor_proto"], +) + +# TODO(b/232091617): Once we can delete the deprecated forwarding headers +# (= everything in upb/) we can move this build target down into reflection/ +bootstrap_cc_library( + name = "reflection", + hdrs = [ + "upb/reflection/def.h", + "upb/reflection/def.hpp", + "upb/reflection/message.h", + "upb/reflection/message.hpp", + ], + bootstrap_deps = [":reflection_internal"], + copts = UPB_DEFAULT_COPTS, + visibility = ["//visibility:public"], + deps = [ + ":base", + ":collections", + ":mem", + ":port", + ], +) + +bootstrap_cc_library( + name = "reflection_internal", + srcs = [ + "upb/reflection/def_builder.c", + "upb/reflection/def_pool.c", + "upb/reflection/def_type.c", + "upb/reflection/desc_state.c", + "upb/reflection/enum_def.c", + "upb/reflection/enum_reserved_range.c", + "upb/reflection/enum_value_def.c", + "upb/reflection/extension_range.c", + "upb/reflection/field_def.c", + "upb/reflection/file_def.c", + "upb/reflection/message.c", + "upb/reflection/message_def.c", + "upb/reflection/message_reserved_range.c", + "upb/reflection/method_def.c", + "upb/reflection/oneof_def.c", + "upb/reflection/service_def.c", + ], + hdrs = [ + "upb/reflection/common.h", + "upb/reflection/def.h", + "upb/reflection/def.hpp", + "upb/reflection/def_pool.h", + "upb/reflection/def_type.h", + "upb/reflection/enum_def.h", + "upb/reflection/enum_reserved_range.h", + "upb/reflection/enum_value_def.h", + "upb/reflection/extension_range.h", + "upb/reflection/field_def.h", + "upb/reflection/file_def.h", + "upb/reflection/internal/def_builder.h", + "upb/reflection/internal/def_pool.h", + "upb/reflection/internal/desc_state.h", + "upb/reflection/internal/enum_def.h", + "upb/reflection/internal/enum_reserved_range.h", + "upb/reflection/internal/enum_value_def.h", + "upb/reflection/internal/extension_range.h", + "upb/reflection/internal/field_def.h", + "upb/reflection/internal/file_def.h", + "upb/reflection/internal/message_def.h", + "upb/reflection/internal/message_reserved_range.h", + "upb/reflection/internal/method_def.h", + "upb/reflection/internal/oneof_def.h", + "upb/reflection/internal/service_def.h", + "upb/reflection/message.h", + "upb/reflection/message.hpp", + "upb/reflection/message_def.h", + "upb/reflection/message_reserved_range.h", + "upb/reflection/method_def.h", + "upb/reflection/oneof_def.h", + "upb/reflection/service_def.h", + ], + bootstrap_deps = [":descriptor_upb_proto"], + copts = UPB_DEFAULT_COPTS, + visibility = ["//visibility:public"], + deps = [ + ":base", + ":collections", + ":hash", + ":mem", + ":message", + ":message_accessors", + ":mini_descriptor", + ":mini_descriptor_internal", + ":mini_table", + ":port", + ], +) + +# Aliases ###################################################################### +# TODO(b/295870230): Remove these. + +alias( + name = "base", + actual = "//upb/base", + visibility = ["//visibility:public"], +) + +alias( + name = "base_internal", + actual = "//upb/base:internal", + visibility = ["//visibility:public"], +) + +alias( + name = "collections", + actual = "//upb/collections", + visibility = ["//visibility:public"], +) + +alias( + name = "collections_internal", + actual = "//upb/collections:internal", + visibility = ["//visibility:public"], +) + +alias( + name = "collections_split64", + actual = "//upb/collections:split64", + visibility = ["//visibility:public"], +) + +alias( + name = "hash", + actual = "//upb/hash", + visibility = ["//visibility:public"], +) + +alias( + name = "json", + actual = "//upb/json", + visibility = ["//visibility:public"], +) + +alias( + name = "lex", + actual = "//upb/lex", + visibility = ["//visibility:public"], +) + +alias( + name = "mem", + actual = "//upb/mem", + visibility = ["//visibility:public"], +) + +alias( + name = "mem_internal", + actual = "//upb/mem:internal", + visibility = ["//:__subpackages__"], +) + +alias( + name = "message", + actual = "//upb/message", + visibility = ["//visibility:public"], +) + +alias( + name = "message_accessors", + actual = "//upb/message:accessors", + visibility = ["//visibility:public"], +) + +alias( + name = "message_accessors_internal", + actual = "//upb/message:accessors_internal", + visibility = ["//:friends"], +) + +alias( + name = "message_copy", + actual = "//upb/message:copy", + visibility = ["//visibility:public"], +) + +alias( + name = "message_internal", + actual = "//upb/message:internal", + visibility = ["//visibility:public"], +) + +alias( + name = "message_promote", + actual = "//upb/message:promote", + visibility = ["//visibility:public"], +) + +alias( + name = "message_rep_internal", + actual = "//upb/message:rep_internal", + visibility = ["//visibility:public"], +) + +alias( + name = "message_split64", + actual = "//upb/message:split64", + visibility = ["//visibility:public"], +) + +alias( + name = "message_tagged_ptr", + actual = "//upb/message:tagged_ptr", + visibility = ["//:friends"], +) + +alias( + name = "message_types", + actual = "//upb/message:types", + visibility = ["//visibility:public"], +) + +alias( + name = "mini_descriptor", + actual = "//upb/mini_descriptor", + visibility = ["//visibility:public"], +) + +alias( + name = "mini_descriptor_internal", + actual = "//upb/mini_descriptor:internal", + visibility = ["//:__subpackages__"], +) + +alias( + name = "mini_table", + actual = "//upb/mini_table", + visibility = ["//:friends"], +) + +# begin:google_only +# alias( +# name = "mini_table_compat", +# actual = "//upb/mini_table:compat", +# compatible_with = ["//buildenv/target:non_prod"], +# visibility = ["//:friends"], +# ) +# end:google_only + +alias( + name = "mini_table_internal", + actual = "//upb/mini_table:internal", + visibility = ["//visibility:public"], +) + +alias( + name = "port", + actual = "//upb/port", + visibility = ["//visibility:public"], +) + +alias( + name = "text", + actual = "//upb/text", + visibility = ["//visibility:public"], +) + +alias( + name = "wire", + actual = "//upb/wire", + visibility = ["//visibility:public"], +) + +alias( + name = "wire_internal", + actual = "//upb/wire:internal", + visibility = ["//visibility:public"], +) + +alias( + name = "wire_reader", + actual = "//upb/wire:reader", + visibility = ["//visibility:public"], +) + +alias( + name = "wire_types", + actual = "//upb/wire:types", + visibility = ["//visibility:public"], +) + +alias( + name = "eps_copy_input_stream", + actual = "//upb/wire:eps_copy_input_stream", + visibility = ["//visibility:public"], +) + +# Tests ######################################################################## + +cc_test( + name = "def_builder_test", + srcs = [ + "upb/reflection/common.h", + "upb/reflection/def_builder_test.cc", + "upb/reflection/def_type.h", + "upb/reflection/internal/def_builder.h", + ], + deps = [ + ":descriptor_upb_proto", + ":hash", + ":mem", + ":port", + ":reflection", + ":reflection_internal", + "@com_google_absl//absl/strings", + "@com_google_googletest//:gtest_main", + ], +) + +# Internal C/C++ libraries ##################################################### + +cc_binary( + name = "libupb.so", + srcs = ["upb/upb_so.c"], + copts = UPB_DEFAULT_COPTS + ["-DUPB_BUILD_API"], + linkshared = 1, + linkstatic = 1, + visibility = ["//visibility:public"], + deps = [ + ":collections", + ":collections_split64", + ":mem", + ":message", + ":message_accessors", + ":message_split64", + ":mini_descriptor", + ":mini_table", + ":port", + ], +) + +# Amalgamation ################################################################# + +# begin:github_only + +upb_amalgamation( + name = "gen_amalgamation", + outs = [ + "upb.c", + "upb.h", + ], + libs = [ + ":base", + ":base_internal", + ":collections_internal", + ":descriptor_upb_proto", + ":eps_copy_input_stream", + ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + ":hash", + ":lex", + ":mem", + ":mem_internal", + ":message", + ":message_accessors", + ":message_internal", + ":message_rep_internal", + ":message_tagged_ptr", + ":message_types", + ":mini_descriptor", + ":mini_descriptor_internal", + ":mini_table", + ":mini_table_internal", + ":port", + ":reflection", + ":reflection_internal", + ":wire", + ":wire_internal", + ":wire_reader", + ":wire_types", + ], + strip_import_prefix = ["src"], +) + +cc_library( + name = "amalgamation", + srcs = ["upb.c"], + hdrs = ["upb.h"], + copts = UPB_DEFAULT_COPTS, + deps = ["@utf8_range"], +) + +upb_amalgamation( + name = "gen_php_amalgamation", + outs = [ + "php-upb.c", + "php-upb.h", + ], + libs = [ + ":base", + ":base_internal", + ":collections_internal", + ":descriptor_upb_proto_reflection", + ":descriptor_upb_proto", + ":eps_copy_input_stream", + ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + ":hash", + ":json", + ":lex", + ":mem", + ":mem_internal", + ":message", + ":message_accessors", + ":message_internal", + ":message_rep_internal", + ":message_tagged_ptr", + ":message_types", + ":mini_descriptor", + ":mini_descriptor_internal", + ":mini_table", + ":mini_table_internal", + ":port", + ":reflection", + ":reflection_internal", + ":wire", + ":wire_internal", + ":wire_reader", + ":wire_types", + ], + prefix = "php-", + strip_import_prefix = ["src"], + visibility = ["@com_google_protobuf//php:__subpackages__"], +) + +cc_library( + name = "php_amalgamation", + srcs = ["php-upb.c"], + hdrs = ["php-upb.h"], + copts = UPB_DEFAULT_COPTS, + deps = ["@utf8_range"], +) + +upb_amalgamation( + name = "gen_ruby_amalgamation", + outs = [ + "ruby-upb.c", + "ruby-upb.h", + ], + libs = [ + ":base", + ":base_internal", + ":collections_internal", + ":descriptor_upb_proto", + ":eps_copy_input_stream", + ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + ":hash", + ":json", + ":lex", + ":mem", + ":mem_internal", + ":message", + ":message_accessors", + ":message_internal", + ":message_rep_internal", + ":message_tagged_ptr", + ":message_types", + ":mini_descriptor", + ":mini_descriptor_internal", + ":mini_table", + ":mini_table_internal", + ":port", + ":reflection", + ":reflection_internal", + ":wire", + ":wire_internal", + ":wire_reader", + ":wire_types", + ], + prefix = "ruby-", + strip_import_prefix = ["src"], + visibility = ["@com_google_protobuf//ruby:__subpackages__"], +) + +cc_library( + name = "ruby_amalgamation", + srcs = ["ruby-upb.c"], + hdrs = ["ruby-upb.h"], + copts = UPB_DEFAULT_COPTS, + deps = ["@utf8_range"], +) + +exports_files( + [ + "third_party/lunit/console.lua", + "third_party/lunit/lunit.lua", + ], + visibility = ["//lua:__pkg__"], +) + +filegroup( + name = "source_files", + srcs = glob( + [ + "upb/**/*.c", + "upb/**/*.h", + "upb/**/*.hpp", + ], + exclude = [ + "upb/**/conformance_upb.c", + "upb/reflection/stage0/**/*", + ], + ), + visibility = [ + "//cmake:__pkg__", + "//python/dist:__pkg__", + ] +) +# end:github_only + +# begin:google_only +# +# py_binary( +# name = "update_check_runs", +# srcs = ["update_check_runs.py"], +# main = "update_check_runs.py", +# deps = [ +# "//third_party/py/absl:app", +# "//third_party/py/absl/flags", +# ], +# ) +# +# kt_native_interop_hint( +# name = "upb_kotlin_native_hint", +# compatible_with = ["//buildenv/target:non_prod"], +# headers_to_exclude = glob([ +# "**/*.hpp", +# ]), +# kotlin_package = "upb", +# no_string_conversion = ["_upb_MiniTable_Build"], +# strict_enums = [ +# "upb_CType", +# "upb_DecodeStatus", +# "upb_EncodeStatus", +# "upb_FieldType", +# "upb_FindUnknown_Status", +# "upb_GetExtension_Status", +# "upb_GetExtensionAsBytes_Status", +# "upb_Label", +# "upb_MapInsertStatus", +# "upb_UnknownToMessage_Status", +# "upb_WireType", +# ], +# visibility = ["//:__subpackages__"], +# ) +# +# end:google_only diff --git a/archive/CONTRIBUTING.md b/archive/CONTRIBUTING.md new file mode 100644 index 0000000000..df48bf6325 --- /dev/null +++ b/archive/CONTRIBUTING.md @@ -0,0 +1,37 @@ + +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Get in touch + +If your idea will take you more than, say, 30 minutes to +implement, please get in touch first via the issue tracker +to touch base about your plan. That will give an +opportunity for early feedback and help avoid wasting your +time. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code Reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows [Google's Open Source Community +Guidelines](https://opensource.google/conduct/). diff --git a/LICENSE b/archive/LICENSE similarity index 88% rename from LICENSE rename to archive/LICENSE index da939845db..7f3bd16837 100644 --- a/LICENSE +++ b/archive/LICENSE @@ -1,5 +1,5 @@ -Copyright (c) 2009-2011, Google Inc. +Copyright (c) 2009-2021, Google LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -10,14 +10,14 @@ modification, are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of any other + * Neither the name of Google LLC nor the names of any other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``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 INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +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 diff --git a/archive/WORKSPACE b/archive/WORKSPACE new file mode 100644 index 0000000000..a9dd26700e --- /dev/null +++ b/archive/WORKSPACE @@ -0,0 +1,86 @@ +workspace(name = "upb") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//bazel:workspace_deps.bzl", "upb_deps") + +upb_deps() + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") +protobuf_deps() + +load("@utf8_range//:workspace_deps.bzl", "utf8_range_deps") +utf8_range_deps() + +http_archive( + name = "lua", + build_file = "//bazel:lua.BUILD", + sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b", + strip_prefix = "lua-5.2.4", + urls = [ + "https://mirror.bazel.build/www.lua.org/ftp/lua-5.2.4.tar.gz", + "https://www.lua.org/ftp/lua-5.2.4.tar.gz", + ], +) + +http_archive( + name = "com_github_google_benchmark", + urls = ["https://github.com/google/benchmark/archive/0baacde3618ca617da95375e0af13ce1baadea47.zip"], + strip_prefix = "benchmark-0baacde3618ca617da95375e0af13ce1baadea47", + sha256 = "62e2f2e6d8a744d67e4bbc212fcfd06647080de4253c97ad5c6749e09faf2cb0", +) + +http_archive( + name = "com_google_googleapis", + urls = ["https://github.com/googleapis/googleapis/archive/refs/heads/master.zip"], + build_file = "//benchmarks:BUILD.googleapis", + strip_prefix = "googleapis-master", + patch_cmds = ["find google -type f -name BUILD.bazel -delete"], +) + +http_archive( + name = "com_google_absl", + sha256 = "e7fdfe0bed87702a22c5b73b6b5fe08bedd25f17d617e52df6061b0f47d480b0", + strip_prefix = "abseil-cpp-e6044634dd7caec2d79a13aecc9e765023768757", + urls = [ + "https://github.com/abseil/abseil-cpp/archive/e6044634dd7caec2d79a13aecc9e765023768757.tar.gz" + ], +) + +http_archive( + name = "com_google_googletest", + sha256 = "730215d76eace9dd49bf74ce044e8daa065d175f1ac891cc1d6bb184ef94e565", + strip_prefix = "googletest-f53219cdcb7b084ef57414efea92ee5b71989558", + urls = [ + "https://github.com/google/googletest/archive/f53219cdcb7b084ef57414efea92ee5b71989558.tar.gz" # 2023-03-16 + ], +) + +load("@com_google_googletest//:googletest_deps.bzl", "googletest_deps") + +googletest_deps() + +load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") + +rules_pkg_dependencies() + +load("//bazel:system_python.bzl", "system_python") +system_python( + name = "system_python", + minimum_python_version = "3.7", +) + +load("@system_python//:register.bzl", "register_system_python") +register_system_python() + +load("@system_python//:pip.bzl", "pip_parse") + +pip_parse( + name="pip_deps", + requirements = "//python:requirements.txt", + requirements_overrides = { + "3.11": "//python:requirements_311.txt", + }, +) + +load("@pip_deps//:requirements.bzl", "install_deps") +install_deps() diff --git a/archive/bazel/BUILD b/archive/bazel/BUILD new file mode 100644 index 0000000000..4ef36264bc --- /dev/null +++ b/archive/bazel/BUILD @@ -0,0 +1,63 @@ +# 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. + +load("@rules_python//python:defs.bzl", "py_binary") +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +# begin:google_only +# package(default_applicable_licenses = ["//:license"]) +# end:google_only + +licenses(["notice"]) + +exports_files( + ["workspace_deps.bzl"], + visibility = ["//cmake:__pkg__"], +) + +py_binary( + name = "amalgamate", + srcs = ["amalgamate.py"], + visibility = ["//:__pkg__"], +) + +# py_proto_library() is private rule, only intended for internal use by upb. +# Hopefully py_proto_library() will eventually be availble in rules_proto or +# another upstream package. +bzl_library( + name = "py_proto_library_bzl", + srcs = ["py_proto_library.bzl"], +) + +bzl_library( + name = "upb_proto_library_bzl", + srcs = ["upb_proto_library.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_skylib//lib:paths", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + "@rules_proto//proto:defs", + ], +) diff --git a/archive/bazel/amalgamate.py b/archive/bazel/amalgamate.py new file mode 100755 index 0000000000..6f9f436c7b --- /dev/null +++ b/archive/bazel/amalgamate.py @@ -0,0 +1,134 @@ +#!/usr/bin/python +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import sys +import re +import os + +INCLUDE_RE = re.compile('^#include "([^"]*)"$') + +def parse_include(line): + match = INCLUDE_RE.match(line) + return match.groups()[0] if match else None + +class Amalgamator: + def __init__(self, h_out, c_out): + self.include_paths = ["."] + self.included = set() + self.output_h = open(h_out, "w") + self.output_c = open(c_out, "w") + self.h_out = h_out.split("/")[-1] + + def amalgamate(self, h_files, c_files): + self.h_files = set(h_files) + self.output_c.write("/* Amalgamated source file */\n") + self.output_c.write('#include "%s"\n' % (self.h_out)) + if self.h_out == "ruby-upb.h": + self.output_h.write("// Ruby is still using proto3 enum semantics for proto2\n") + self.output_h.write("#define UPB_DISABLE_PROTO2_ENUM_CHECKING\n") + + self.output_h.write("/* Amalgamated source file */\n") + + port_def = self._find_include_file("upb/port/def.inc") + port_undef = self._find_include_file("upb/port/undef.inc") + self._process_file(port_def, self.output_h) + self._process_file(port_def, self.output_c) + + for file in c_files: + self._process_file(file, self.output_c) + + self._process_file(port_undef, self.output_h) + self._process_file(port_undef, self.output_c) + + def _process_file(self, infile_name, outfile): + lines = open(infile_name).readlines() + + has_copyright = lines[0].startswith( + "// Protocol Buffers - Google's data interchange format" + ) + if has_copyright: + while not lines[0].startswith( + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH" + " DAMAGE" + ): + lines.pop(0) + lines.pop(0) + + for line in lines: + if not self._process_include(line): + outfile.write(line) + + def _find_include_file(self, name): + for h_file in self.h_files: + if h_file.endswith(name): + return h_file + + def _process_include(self, line): + include = parse_include(line) + if not include: + return False + if not (include.startswith("upb") or include.startswith("google")): + return False + if include and (include.endswith("port/def.inc") or include.endswith("port/undef.inc")): + # Skip, we handle this separately + return True + if include.endswith("hpp"): + # Skip, we don't support the amalgamation from C++. + return True + elif include in self.included: + return True + else: + # Include this upb header inline. + h_file = self._find_include_file(include) + if h_file: + self.h_files.remove(h_file) + self.included.add(include) + self._process_file(h_file, self.output_h) + return True + raise RuntimeError("Couldn't find include: " + include + ", h_files=" + repr(self.h_files)) + +# ---- main ---- + +c_out = sys.argv[1] +h_out = sys.argv[2] +amalgamator = Amalgamator(h_out, c_out) +c_files = [] +h_files = [] + +for arg in sys.argv[3:]: + arg = arg.strip() + if arg.endswith(".h") or arg.endswith(".inc"): + h_files.append(arg) + else: + c_files.append(arg) + +amalgamator.amalgamate(h_files, c_files) diff --git a/archive/bazel/amalgamation.bzl b/archive/bazel/amalgamation.bzl new file mode 100644 index 0000000000..cabbaccd91 --- /dev/null +++ b/archive/bazel/amalgamation.bzl @@ -0,0 +1,85 @@ +# 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. + +"""Internal rules for building upb.""" + +load(":upb_proto_library.bzl", "GeneratedSrcsInfo") + +# upb_amalgamation() rule, with file_list aspect. + +SrcList = provider( + fields = { + "srcs": "list of srcs", + }, +) + +def _file_list_aspect_impl(target, ctx): + if GeneratedSrcsInfo in target: + srcs = target[GeneratedSrcsInfo] + return [SrcList(srcs = srcs.srcs + srcs.hdrs)] + + srcs = [] + for src in ctx.rule.attr.srcs: + srcs += src.files.to_list() + for hdr in ctx.rule.attr.hdrs: + srcs += hdr.files.to_list() + for hdr in ctx.rule.attr.textual_hdrs: + srcs += hdr.files.to_list() + return [SrcList(srcs = srcs)] + +_file_list_aspect = aspect( + implementation = _file_list_aspect_impl, +) + +def _upb_amalgamation(ctx): + inputs = [] + for lib in ctx.attr.libs: + inputs += lib[SrcList].srcs + srcs = [src for src in inputs if not src.path.endswith("hpp")] + ctx.actions.run( + inputs = inputs, + outputs = ctx.outputs.outs, + arguments = [f.path for f in ctx.outputs.outs] + [f.path for f in srcs], + progress_message = "Making amalgamation", + executable = ctx.executable._amalgamator, + ) + return [] + +upb_amalgamation = rule( + attrs = { + "_amalgamator": attr.label( + executable = True, + cfg = "exec", + default = "//bazel:amalgamate", + ), + "prefix": attr.string( + default = "", + ), + "libs": attr.label_list(aspects = [_file_list_aspect]), + "outs": attr.output_list(), + "strip_import_prefix": attr.string_list(), + }, + implementation = _upb_amalgamation, +) diff --git a/archive/bazel/build_defs.bzl b/archive/bazel/build_defs.bzl new file mode 100644 index 0000000000..e4212b3c67 --- /dev/null +++ b/archive/bazel/build_defs.bzl @@ -0,0 +1,101 @@ +# 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. + +"""Internal rules for building upb.""" + +_DEFAULT_CPPOPTS = [] +_DEFAULT_COPTS = [] + +# begin:github_only +_DEFAULT_CPPOPTS.extend([ + "-Wextra", + # "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang) + "-Werror", + "-Wno-unused-parameter", + "-Wno-long-long", +]) +_DEFAULT_COPTS.extend([ + "-std=c99", + "-Wall", + "-Wstrict-prototypes", + # GCC (at least) emits spurious warnings for this that cannot be fixed + # without introducing redundant initialization (with runtime cost): + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 + #"-Wno-maybe-uninitialized", +]) +# end:github_only + +UPB_DEFAULT_CPPOPTS = select({ + "//:windows": [], + "//conditions:default": _DEFAULT_CPPOPTS, +}) + +UPB_DEFAULT_COPTS = select({ + "//:windows": [], + "//:fasttable_enabled_setting": ["-std=gnu99", "-DUPB_ENABLE_FASTTABLE"], + "//conditions:default": _DEFAULT_COPTS, +}) + +runfiles_init = """\ +# --- begin runfiles.bash initialization v2 --- +# Copy-pasted from the Bazel Bash runfiles library v2. +set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v2 --- +""" + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + return short_path + +def _get_real_root(file): + real_short_path = _get_real_short_path(file) + return file.path[:-len(real_short_path) - 1] + +def _get_real_roots(files): + roots = {} + for file in files: + real_root = _get_real_root(file) + if real_root: + roots[real_root] = True + return roots.keys() + +def make_shell_script(name, contents, out): + contents = contents.replace("$", "$$") + native.genrule( + name = "gen_" + name, + outs = [out], + cmd = "(cat <<'HEREDOC'\n%s\nHEREDOC\n) > $@" % contents, + ) diff --git a/bazel/lua.BUILD b/archive/bazel/lua.BUILD similarity index 57% rename from bazel/lua.BUILD rename to archive/bazel/lua.BUILD index 113c71f9ae..11755a4f73 100644 --- a/bazel/lua.BUILD +++ b/archive/bazel/lua.BUILD @@ -1,3 +1,28 @@ +# 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. + package( default_visibility = ["//visibility:public"], ) diff --git a/archive/bazel/protobuf.patch b/archive/bazel/protobuf.patch new file mode 100644 index 0000000000..16e41c0cbb --- /dev/null +++ b/archive/bazel/protobuf.patch @@ -0,0 +1,40 @@ +--- python/google/protobuf/internal/test_util.py ++++ python/google/protobuf/internal/test_util.py +@@ -39,6 +39,7 @@ __author__ = 'robinson@google.com (Will Robinson)' + import numbers + import operator + import os.path ++import pathlib + + from google.protobuf import unittest_import_pb2 + from google.protobuf import unittest_pb2 +@@ -617,17 +618,22 @@ def ExpectAllFieldsSet(test_case, message): + message.default_import_enum) + + ++def _SearchUp(path, filename): ++ path = pathlib.Path(path).resolve() ++ for parent in [path] + list(path.parents): ++ file_path = parent / ('google/protobuf/testdata/' + filename) ++ if file_path.exists(): ++ # Found it. Load the golden file from the testdata directory. ++ return file_path.open('rb') ++ return None ++ + def GoldenFile(filename): + """Finds the given golden file and returns a file object representing it.""" + + # Search up the directory tree looking for the C++ protobuf source code. +- path = '.' +- while os.path.exists(path): +- if os.path.exists(os.path.join(path, 'src/google/protobuf')): +- # Found it. Load the golden file from the testdata directory. +- full_path = os.path.join(path, 'src/google/protobuf/testdata', filename) +- return open(full_path, 'rb') +- path = os.path.join(path, '..') ++ f = _SearchUp('.', filename) or _SearchUp(__file__, filename) ++ if f: ++ return f + + # Search internally. + path = '.' \ No newline at end of file diff --git a/archive/bazel/py_proto_library.bzl b/archive/bazel/py_proto_library.bzl new file mode 100644 index 0000000000..1ce3a6e11b --- /dev/null +++ b/archive/bazel/py_proto_library.bzl @@ -0,0 +1,157 @@ +# 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. + +"""An implementation of py_proto_library(). + +We have to implement this ourselves because there is currently no reasonable +py_proto_library() rule available for Bazel. + +Our py_proto_library() is similar to how a real py_proto_library() should work. +But it hasn't been deeply tested or reviewed, and upb should not be in the +business of vending py_proto_library(), so we keep it private to upb. +""" + +load("@bazel_skylib//lib:paths.bzl", "paths") + +# begin:github_only +load("@rules_proto//proto:defs.bzl", "ProtoInfo") +# end:github_only + +# Generic support code ######################################################### + +# begin:github_only +_is_google3 = False +# end:github_only + +# begin:google_only +# _is_google3 = True +# end:google_only + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + + # Sometimes it has another few prefixes like: + # _virtual_imports/any_proto/google/protobuf/any.proto + # benchmarks/_virtual_imports/100_msgs_proto/benchmarks/100_msgs.proto + # We want just google/protobuf/any.proto. + virtual_imports = "_virtual_imports/" + if virtual_imports in short_path: + short_path = short_path.split(virtual_imports)[1].split("/", 1)[1] + return short_path + +def _get_real_root(ctx, file): + real_short_path = _get_real_short_path(file) + root = file.path[:-len(real_short_path) - 1] + + if not _is_google3 and ctx.rule.attr.strip_import_prefix: + root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:]) + return root + +def _generate_output_file(ctx, src, extension): + package = ctx.label.package + if not _is_google3: + strip_import_prefix = ctx.rule.attr.strip_import_prefix + if strip_import_prefix and strip_import_prefix != "/": + if not package.startswith(strip_import_prefix[1:]): + fail("%s does not begin with prefix %s" % (package, strip_import_prefix)) + package = package[len(strip_import_prefix):] + + real_short_path = _get_real_short_path(src) + real_short_path = paths.relativize(real_short_path, package) + output_filename = paths.replace_extension(real_short_path, extension) + ret = ctx.actions.declare_file(output_filename) + return ret + +# py_proto_library() ########################################################### + +def _py_proto_library_rule_impl(ctx): + # A real py_proto_library() should enforce this constraint. + # We don't bother for now, since it saves us some effort not to. + # + # if len(ctx.attr.deps) != 1: + # fail("only one deps dependency allowed.") + + files = [] + for dep in ctx.attr.deps: + files += dep[PyInfo].transitive_sources.to_list() + return [ + DefaultInfo(files = depset(direct = files)), + ] + +def _py_proto_library_aspect_impl(target, ctx): + proto_info = target[ProtoInfo] + proto_sources = proto_info.direct_sources + srcs = [_generate_output_file(ctx, name, "_pb2.py") for name in proto_sources] + transitive_sets = proto_info.transitive_descriptor_sets.to_list() + ctx.actions.run( + inputs = depset( + direct = [proto_info.direct_descriptor_set], + transitive = [proto_info.transitive_descriptor_sets], + ), + outputs = srcs, + executable = ctx.executable._protoc, + arguments = [ + "--python_out=" + _get_real_root(ctx, srcs[0]), + "--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets]), + ] + + [_get_real_short_path(file) for file in proto_sources], + progress_message = "Generating Python protos for :" + ctx.label.name, + ) + outs_depset = depset(srcs) + return [ + PyInfo(transitive_sources = outs_depset), + ] + +_py_proto_library_aspect = aspect( + attrs = { + "_protoc": attr.label( + executable = True, + cfg = "exec", + default = "@com_google_protobuf//:protoc", + ), + }, + implementation = _py_proto_library_aspect_impl, + provides = [ + PyInfo, + ], + attr_aspects = ["deps"], +) + +py_proto_library = rule( + output_to_genfiles = True, + implementation = _py_proto_library_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [_py_proto_library_aspect], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + }, +) diff --git a/archive/bazel/python_downloads.bzl b/archive/bazel/python_downloads.bzl new file mode 100644 index 0000000000..e237c93631 --- /dev/null +++ b/archive/bazel/python_downloads.bzl @@ -0,0 +1,84 @@ +"""Helper methods to download different python versions""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +limited_api_build_file = """ +cc_library( + name = "python_headers", + hdrs = glob(["**/Include/**/*.h"]), + strip_include_prefix = "Python-{}/Include", + visibility = ["//visibility:public"], +) +""" + +def python_source_archive(name, sha256): + """Helper method to create a python_headers target that will work for linux and macos. + + Args: + name: The name of the target, should be in the form python_{VERSION} + sha256: The sha256 of the python package for the specified version + """ + version = name.split("-")[1] + http_archive( + name = name, + urls = [ + "https://www.python.org/ftp/python/{0}/Python-{0}.tgz" + .format(version), + ], + sha256 = sha256, + build_file_content = limited_api_build_file.format(version), + patch_cmds = [ + "echo '#define SIZEOF_WCHAR_T 4' > Python-{}/Include/pyconfig.h" + .format(version), + ], + ) + +nuget_build_file = """ +cc_import( + name = "python_full_api", + hdrs = glob(["**/*.h"]), + shared_library = "python{0}.dll", + interface_library = "libs/python{0}.lib", + visibility = ["@upb//python:__pkg__"], +) + +cc_import( + name = "python_limited_api", + hdrs = glob(["**/*.h"]), + shared_library = "python{1}.dll", + interface_library = "libs/python{1}.lib", + visibility = ["@upb//python:__pkg__"], +) +""" + +def python_nuget_package(name, sha256): + """Helper method to create full and limited api dependencies for windows using nuget + + Args: + name: The name of the target, should be in the form nuget_python_{CPU}_{VERSION} + sha256: The sha256 of the nuget package for that version + """ + cpu = name.split("_")[2] + version = name.split("_")[3] + + full_api_lib_number = version.split(".")[0] + version.split(".")[1] + limited_api_lib_number = version.split(".")[0] + + folder_name_dict = { + "i686": "pythonx86", + "x86-64": "python", + } + + http_archive( + name = name, + urls = [ + "https://www.nuget.org/api/v2/package/{}/{}" + .format(folder_name_dict[cpu], version), + ], + sha256 = sha256, + strip_prefix = "tools", + build_file_content = + nuget_build_file.format(full_api_lib_number, limited_api_lib_number), + type = "zip", + patch_cmds = ["cp -r include/* ."], + ) diff --git a/archive/bazel/system_python.bzl b/archive/bazel/system_python.bzl new file mode 100644 index 0000000000..04b53c2a27 --- /dev/null +++ b/archive/bazel/system_python.bzl @@ -0,0 +1,293 @@ +# 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. + +"""Repository rule for using Python 3.x headers from the system.""" + +# Mock out rules_python's pip.bzl for cases where no system python is found. +_mock_pip = """ +def _pip_install_impl(repository_ctx): + repository_ctx.file("BUILD.bazel", ''' +py_library( + name = "noop", + visibility = ["//visibility:public"], +) +''') + repository_ctx.file("requirements.bzl", ''' +def install_deps(*args, **kwargs): + print("WARNING: could not install pip dependencies") + +def requirement(*args, **kwargs): + return "@{}//:noop" +'''.format(repository_ctx.attr.name)) +pip_install = repository_rule( + implementation = _pip_install_impl, + attrs = { + "requirements": attr.string(), + "requirements_overrides": attr.string_dict(), + "python_interpreter_target": attr.string(), + }, +) +pip_parse = pip_install +""" + +# Alias rules_python's pip.bzl for cases where a system python is found. +_alias_pip = """ +load("@rules_python//python:pip.bzl", _pip_install = "pip_install", _pip_parse = "pip_parse") + +def _get_requirements(requirements, requirements_overrides): + for version, override in requirements_overrides.items(): + if version in "{python_version}": + requirements = override + break + return requirements + +def pip_install(requirements, requirements_overrides={{}}, **kwargs): + _pip_install( + python_interpreter_target = "@{repo}//:interpreter", + requirements = _get_requirements(requirements, requirements_overrides), + **kwargs, + ) +def pip_parse(requirements, requirements_overrides={{}}, **kwargs): + _pip_parse( + python_interpreter_target = "@{repo}//:interpreter", + requirements = _get_requirements(requirements, requirements_overrides), + **kwargs, + ) +""" + +_mock_fuzzing_py = """ +def fuzzing_py_install_deps(): + print("WARNING: could not install fuzzing_py dependencies") +""" + +# Alias rules_fuzzing's requirements.bzl for cases where a system python is found. +_alias_fuzzing_py = """ +load("@fuzzing_py_deps//:requirements.bzl", _fuzzing_py_install_deps = "install_deps") + +def fuzzing_py_install_deps(): + _fuzzing_py_install_deps() +""" + +_build_file = """ +load("@bazel_skylib//lib:selects.bzl", "selects") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") + +cc_library( + name = "python_headers", + hdrs = glob(["python/**/*.h"], allow_empty = True), + includes = ["python"], + visibility = ["//visibility:public"], +) + +string_flag( + name = "internal_python_support", + build_setting_default = "{support}", + values = [ + "None", + "Supported", + "Unsupported", + ] +) + +config_setting( + name = "none", + flag_values = {{ + ":internal_python_support": "None", + }}, + visibility = ["//visibility:public"], +) + +config_setting( + name = "supported", + flag_values = {{ + ":internal_python_support": "Supported", + }}, + visibility = ["//visibility:public"], +) + +config_setting( + name = "unsupported", + flag_values = {{ + ":internal_python_support": "Unsupported", + }}, + visibility = ["//visibility:public"], +) + +selects.config_setting_group( + name = "exists", + match_any = [":supported", ":unsupported"], + visibility = ["//visibility:public"], +) + +sh_binary( + name = "interpreter", + srcs = ["interpreter"], + visibility = ["//visibility:public"], +) + +py_runtime( + name = "py3_runtime", + interpreter_path = "{interpreter}", + python_version = "PY3", +) + +py_runtime_pair( + name = "runtime_pair", + py3_runtime = ":py3_runtime", +) + +toolchain( + name = "python_toolchain", + toolchain = ":runtime_pair", + toolchain_type = "@rules_python//python:toolchain_type", +) +""" + +_register = """ +def register_system_python(): + native.register_toolchains("@{}//:python_toolchain") +""" + +_mock_register = """ +def register_system_python(): + pass +""" + +def _get_python_version(repository_ctx): + py_program = "import sys; print(str(sys.version_info.major) + '.' + str(sys.version_info.minor) + '.' + str(sys.version_info.micro))" + result = repository_ctx.execute(["python3", "-c", py_program]) + return (result.stdout).strip().split(".") + +def _get_python_path(repository_ctx): + py_program = "import sysconfig; print(sysconfig.get_config_var('%s'), end='')" + result = repository_ctx.execute(["python3", "-c", py_program % ("INCLUDEPY")]) + if result.return_code != 0: + return None + return result.stdout + +def _populate_package(ctx, path, python3, python_version): + ctx.symlink(path, "python") + supported = True + for idx, v in enumerate(ctx.attr.minimum_python_version.split(".")): + if int(python_version[idx]) < int(v): + supported = False + break + if "win" in ctx.os.name: + # buildifier: disable=print + print("WARNING: python is not supported on Windows") + supported = False + + build_file = _build_file.format( + interpreter = python3, + support = "Supported" if supported else "Unsupported", + ) + + ctx.file("interpreter", "#!/bin/sh\nexec {} \"$@\"".format(python3)) + ctx.file("BUILD.bazel", build_file) + ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = '{}{}'".format(python_version[0], python_version[1])) + ctx.file("register.bzl", _register.format(ctx.attr.name)) + if supported: + ctx.file("pip.bzl", _alias_pip.format( + python_version = ".".join(python_version), + repo = ctx.attr.name, + )) + ctx.file("fuzzing_py.bzl", _alias_fuzzing_py) + else: + # Dependencies are unlikely to be satisfiable for unsupported versions of python. + ctx.file("pip.bzl", _mock_pip) + ctx.file("fuzzing_py.bzl", _mock_fuzzing_py) + +def _populate_empty_package(ctx): + # Mock out all the entrypoints we need to run from WORKSPACE. Targets that + # actually need python should use `target_compatible_with` and the generated + # @system_python//:exists or @system_python//:supported constraints. + ctx.file( + "BUILD.bazel", + _build_file.format( + interpreter = "", + support = "None", + ), + ) + ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = 'None'") + ctx.file("register.bzl", _mock_register) + ctx.file("pip.bzl", _mock_pip) + ctx.file("fuzzing_py.bzl", _mock_fuzzing_py) + +def _system_python_impl(repository_ctx): + path = _get_python_path(repository_ctx) + python3 = repository_ctx.which("python3") + python_version = _get_python_version(repository_ctx) + + if path and python_version[0] == "3": + _populate_package(repository_ctx, path, python3, python_version) + else: + # buildifier: disable=print + print("WARNING: no system python available, builds against system python will fail") + _populate_empty_package(repository_ctx) + +# The system_python() repository rule exposes information from the version of python installed in the current system. +# +# In WORKSPACE: +# system_python( +# name = "system_python_repo", +# minimum_python_version = "3.7", +# ) +# +# This repository exposes some repository rules for configuring python in Bazel. The python toolchain +# *must* be registered in your WORKSPACE: +# load("@system_python_repo//:register.bzl", "register_system_python") +# register_system_python() +# +# Pip dependencies can optionally be specified using a wrapper around rules_python's repository rules: +# load("@system_python//:pip.bzl", "pip_install") +# pip_install( +# name="pip_deps", +# requirements = "@com_google_protobuf//python:requirements.txt", +# ) +# An optional argument `requirements_overrides` takes a dictionary mapping python versions to alternate +# requirements files. This works around the requirement for fully pinned dependencies in python_rules. +# +# Four config settings are exposed from this repository to help declare target compatibility in Bazel. +# For example, `@system_python_repo//:exists` will be true if a system python version has been found. +# The `none` setting will be true only if no python version was found, and `supported`/`unsupported` +# correspond to whether or not the system version is compatible with `minimum_python_version`. +# +# This repository also exposes a header rule that you can depend on from BUILD files: +# cc_library( +# name = "foobar", +# srcs = ["foobar.cc"], +# deps = ["@system_python_repo//:python_headers"], +# ) +# +# The headers should correspond to the version of python obtained by running +# the `python3` command on the system. +system_python = repository_rule( + implementation = _system_python_impl, + local = True, + attrs = { + "minimum_python_version": attr.string(default = "3.7"), + }, +) diff --git a/archive/bazel/upb_proto_library.bzl b/archive/bazel/upb_proto_library.bzl new file mode 100644 index 0000000000..9c4f85be36 --- /dev/null +++ b/archive/bazel/upb_proto_library.bzl @@ -0,0 +1,530 @@ +# 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. + +"""Public rules for using upb protos: + - upb_proto_library() + - upb_proto_reflection_library() +""" + +load("@bazel_skylib//lib:paths.bzl", "paths") + +# begin:google_only +# load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") +# end:google_only + +# begin:github_only +# Compatibility code for Bazel 4.x. Remove this when we drop support for Bazel 4.x. +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") + +def use_cpp_toolchain(): + return ["@bazel_tools//tools/cpp:toolchain_type"] +# end:github_only + +# Generic support code ######################################################### + +# begin:github_only +_is_google3 = False +# end:github_only + +# begin:google_only +# _is_google3 = True +# end:google_only + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + + # Sometimes it has another few prefixes like: + # _virtual_imports/any_proto/google/protobuf/any.proto + # benchmarks/_virtual_imports/100_msgs_proto/benchmarks/100_msgs.proto + # We want just google/protobuf/any.proto. + virtual_imports = "_virtual_imports/" + if virtual_imports in short_path: + short_path = short_path.split(virtual_imports)[1].split("/", 1)[1] + return short_path + +def _get_real_root(ctx, file): + real_short_path = _get_real_short_path(file) + root = file.path[:-len(real_short_path) - 1] + + if not _is_google3 and ctx.rule.attr.strip_import_prefix: + root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:]) + return root + +def _generate_output_file(ctx, src, extension): + package = ctx.label.package + if not _is_google3: + strip_import_prefix = ctx.rule.attr.strip_import_prefix + if strip_import_prefix and strip_import_prefix != "/": + if not package.startswith(strip_import_prefix[1:]): + fail("%s does not begin with prefix %s" % (package, strip_import_prefix)) + package = package[len(strip_import_prefix):] + + real_short_path = _get_real_short_path(src) + real_short_path = paths.relativize(real_short_path, package) + output_filename = paths.replace_extension(real_short_path, extension) + ret = ctx.actions.declare_file(output_filename) + return ret + +def _generate_include_path(src, out, extension): + short_path = _get_real_short_path(src) + short_path = paths.replace_extension(short_path, extension) + if not out.path.endswith(short_path): + fail("%s does not end with %s" % (out.path, short_path)) + + return out.path[:-len(short_path)] + +def _filter_none(elems): + out = [] + for elem in elems: + if elem: + out.append(elem) + return out + +def _cc_library_func(ctx, name, hdrs, srcs, copts, includes, dep_ccinfos): + """Like cc_library(), but callable from rules. + + Args: + ctx: Rule context. + name: Unique name used to generate output files. + hdrs: Public headers that can be #included from other rules. + srcs: C/C++ source files. + copts: Additional options for cc compilation. + includes: Additional include paths. + dep_ccinfos: CcInfo providers of dependencies we should build/link against. + + Returns: + CcInfo provider for this compilation. + """ + + compilation_contexts = [info.compilation_context for info in dep_ccinfos] + linking_contexts = [info.linking_context for info in dep_ccinfos] + toolchain = find_cpp_toolchain(ctx) + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) + + (compilation_context, compilation_outputs) = cc_common.compile( + actions = ctx.actions, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + name = name, + srcs = srcs, + includes = includes, + public_hdrs = hdrs, + user_compile_flags = copts, + compilation_contexts = compilation_contexts, + ) + + # buildifier: disable=unused-variable + (linking_context, linking_outputs) = cc_common.create_linking_context_from_compilation_outputs( + actions = ctx.actions, + name = name, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + compilation_outputs = compilation_outputs, + linking_contexts = linking_contexts, + disallow_dynamic_library = cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "targets_windows") or not cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "supports_dynamic_linker"), + ) + + return CcInfo( + compilation_context = compilation_context, + linking_context = linking_context, + ) + +# Dummy rule to expose select() copts to aspects ############################## + +UpbProtoLibraryCoptsInfo = provider( + "Provides copts for upb proto targets", + fields = { + "copts": "copts for upb_proto_library()", + }, +) + +def upb_proto_library_copts_impl(ctx): + return UpbProtoLibraryCoptsInfo(copts = ctx.attr.copts) + +upb_proto_library_copts = rule( + implementation = upb_proto_library_copts_impl, + attrs = {"copts": attr.string_list(default = [])}, +) + +# upb_proto_library / upb_proto_reflection_library shared code ################# + +GeneratedSrcsInfo = provider( + "Provides generated headers and sources", + fields = { + "srcs": "list of srcs", + "hdrs": "list of hdrs", + "thunks": "Experimental, do not use. List of srcs defining C API. Incompatible with hdrs.", + "includes": "list of extra includes", + }, +) + +def _concat_lists(lists): + ret = [] + for lst in lists: + ret = ret + lst + return ret + +def _merge_generated_srcs(srcs): + return GeneratedSrcsInfo( + srcs = _concat_lists([s.srcs for s in srcs]), + hdrs = _concat_lists([s.hdrs for s in srcs]), + thunks = _concat_lists([s.thunks for s in srcs]), + includes = _concat_lists([s.includes for s in srcs]), + ) + +UpbWrappedCcInfo = provider("Provider for cc_info for protos", fields = ["cc_info", "cc_info_with_thunks"]) + +def _merge_wrapped_cc_infos(infos, cc_infos): + return UpbWrappedCcInfo( + cc_info = cc_common.merge_cc_infos( + direct_cc_infos = cc_infos + [info.cc_info for info in infos], + ), + cc_info_with_thunks = cc_common.merge_cc_infos( + direct_cc_infos = [info.cc_info_with_thunks for info in infos], + ), + ) + +_UpbDefsWrappedCcInfo = provider("Provider for cc_info for protos", fields = ["cc_info"]) +_UpbWrappedGeneratedSrcsInfo = provider("Provider for generated sources", fields = ["srcs"]) +_WrappedDefsGeneratedSrcsInfo = provider( + "Provider for generated reflective sources", + fields = ["srcs"], +) + +def _generate_upb_protos(ctx, generator, proto_info, proto_sources): + if len(proto_sources) == 0: + return GeneratedSrcsInfo(srcs = [], hdrs = [], thunks = [], includes = []) + + ext = "." + generator + tool = getattr(ctx.executable, "_gen_" + generator) + srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources] + hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources] + thunks = [] + if generator == "upb": + thunks = [_generate_output_file(ctx, name, ext + ".thunks.c") for name in proto_sources] + transitive_sets = proto_info.transitive_descriptor_sets.to_list() + + args = ctx.actions.args() + args.use_param_file(param_file_arg = "@%s") + args.set_param_file_format("multiline") + + args.add("--" + generator + "_out=" + _get_real_root(ctx, srcs[0])) + args.add("--plugin=protoc-gen-" + generator + "=" + tool.path) + args.add("--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets])) + args.add_all(proto_sources, map_each = _get_real_short_path) + + ctx.actions.run( + inputs = depset( + direct = [proto_info.direct_descriptor_set], + transitive = [proto_info.transitive_descriptor_sets], + ), + tools = [tool], + outputs = srcs + hdrs, + executable = ctx.executable._protoc, + arguments = [args], + progress_message = "Generating upb protos for :" + ctx.label.name, + mnemonic = "GenUpbProtos", + ) + if generator == "upb": + ctx.actions.run_shell( + inputs = hdrs, + outputs = thunks, + command = " && ".join([ + "sed 's/UPB_INLINE //' {} > {}".format(hdr.path, thunk.path) + for (hdr, thunk) in zip(hdrs, thunks) + ]), + progress_message = "Generating thunks for upb protos API for: " + ctx.label.name, + mnemonic = "GenUpbProtosThunks", + ) + return GeneratedSrcsInfo( + srcs = srcs, + hdrs = hdrs, + thunks = thunks, + includes = [_generate_include_path(proto_sources[0], hdrs[0], ext + ".h")], + ) + +def _upb_proto_rule_impl(ctx): + if len(ctx.attr.deps) != 1: + fail("only one deps dependency allowed.") + dep = ctx.attr.deps[0] + + if _WrappedDefsGeneratedSrcsInfo in dep: + srcs = dep[_WrappedDefsGeneratedSrcsInfo].srcs + elif _UpbWrappedGeneratedSrcsInfo in dep: + srcs = dep[_UpbWrappedGeneratedSrcsInfo].srcs + else: + fail("proto_library rule must generate _UpbWrappedGeneratedSrcsInfo or " + + "_WrappedDefsGeneratedSrcsInfo (aspect should have handled this).") + + if _UpbDefsWrappedCcInfo in dep: + cc_info = dep[_UpbDefsWrappedCcInfo].cc_info + elif UpbWrappedCcInfo in dep: + cc_info = dep[UpbWrappedCcInfo].cc_info + else: + fail("proto_library rule must generate UpbWrappedCcInfo or " + + "_UpbDefsWrappedCcInfo (aspect should have handled this).") + + lib = cc_info.linking_context.linker_inputs.to_list()[0].libraries[0] + files = _filter_none([ + lib.static_library, + lib.pic_static_library, + lib.dynamic_library, + ]) + return [ + DefaultInfo(files = depset(files + srcs.hdrs + srcs.srcs)), + srcs, + cc_info, + ] + +def _generate_name(ctx, generator, thunks = False): + if thunks: + return ctx.rule.attr.name + "." + generator + ".thunks" + return ctx.rule.attr.name + "." + generator + +def _get_dep_cc_info(target, ctx, generator): + deps = ctx.rule.attr.deps + getattr(ctx.attr, "_" + generator) + dep_ccinfos = [dep[CcInfo] for dep in deps if CcInfo in dep] + dep_ccinfos += [dep[_UpbDefsWrappedCcInfo].cc_info for dep in deps if _UpbDefsWrappedCcInfo in dep] + + dep_wrapped_infos = [dep[UpbWrappedCcInfo] for dep in deps if UpbWrappedCcInfo in dep] + if generator == "upbdefs": + if UpbWrappedCcInfo not in target: + fail("Target should have UpbWrappedCcInfo provider") + dep_wrapped_infos.append(target[UpbWrappedCcInfo]) + + return _merge_wrapped_cc_infos(dep_wrapped_infos, dep_ccinfos) + +def _compile_upb_protos(ctx, files, generator, dep_wrapped_ccinfo, cc_provider): + cc_info = _cc_library_func( + ctx = ctx, + name = _generate_name(ctx, generator), + hdrs = files.hdrs, + srcs = files.srcs, + includes = files.includes, + copts = ctx.attr._copts[UpbProtoLibraryCoptsInfo].copts, + dep_ccinfos = [dep_wrapped_ccinfo.cc_info], + ) + + if files.thunks: + cc_info_with_thunks = _cc_library_func( + ctx = ctx, + name = _generate_name(ctx, generator, files.thunks), + hdrs = [], + srcs = files.thunks, + includes = files.includes, + copts = ctx.attr._copts[UpbProtoLibraryCoptsInfo].copts, + dep_ccinfos = [dep_wrapped_ccinfo.cc_info, cc_info], + ) + return cc_provider( + cc_info = cc_info, + cc_info_with_thunks = cc_info_with_thunks, + ) + else: + return cc_provider( + cc_info = cc_info, + ) + +def _get_hint_providers(ctx, generator): + if generator not in _GENERATORS: + fail("Please add new generator '{}' to _GENERATORS list".format(generator)) + + possible_owners = [] + for generator in _GENERATORS: + possible_owners.append(ctx.label.relative(_generate_name(ctx, generator))) + possible_owners.append(ctx.label.relative(_generate_name(ctx, generator, thunks = True))) + + if hasattr(cc_common, "CcSharedLibraryHintInfo"): + return [cc_common.CcSharedLibraryHintInfo(owners = possible_owners)] + elif hasattr(cc_common, "CcSharedLibraryHintInfo_6_X_constructor_do_not_use"): + # This branch can be deleted once 6.X is not supported by upb rules + return [cc_common.CcSharedLibraryHintInfo_6_X_constructor_do_not_use(owners = possible_owners)] + + return [] + +def _upb_proto_aspect_impl(target, ctx, generator, cc_provider, file_provider, provide_cc_shared_library_hints = True): + dep_wrapped_ccinfo = _get_dep_cc_info(target, ctx, generator) + if not getattr(ctx.rule.attr, "srcs", []): + # This target doesn't declare any sources, reexport all its deps instead. + # This is known as an "alias library": + # https://bazel.build/reference/be/protocol-buffer#proto_library.srcs + files = _merge_generated_srcs([dep[file_provider].srcs for dep in ctx.rule.attr.deps]) + wrapped_cc_info = dep_wrapped_ccinfo + else: + proto_info = target[ProtoInfo] + files = _generate_upb_protos( + ctx, + generator, + proto_info, + proto_info.direct_sources, + ) + wrapped_cc_info = _compile_upb_protos( + ctx, + files, + generator, + dep_wrapped_ccinfo, + cc_provider, + ) + + hints = _get_hint_providers(ctx, generator) if provide_cc_shared_library_hints else [] + + return hints + [ + file_provider(srcs = files), + wrapped_cc_info, + ] + +_GENERATORS = ["upb", "upbdefs"] + +def upb_proto_library_aspect_impl(target, ctx): + return _upb_proto_aspect_impl(target, ctx, "upb", UpbWrappedCcInfo, _UpbWrappedGeneratedSrcsInfo) + +def _upb_proto_reflection_library_aspect_impl(target, ctx): + return _upb_proto_aspect_impl(target, ctx, "upbdefs", _UpbDefsWrappedCcInfo, _WrappedDefsGeneratedSrcsInfo, provide_cc_shared_library_hints = False) + +# upb_proto_library() ########################################################## + +def _get_upb_proto_library_aspect_provides(): + provides = [ + UpbWrappedCcInfo, + _UpbWrappedGeneratedSrcsInfo, + ] + + if hasattr(cc_common, "CcSharedLibraryHintInfo"): + provides.append(cc_common.CcSharedLibraryHintInfo) + elif hasattr(cc_common, "CcSharedLibraryHintInfo_6_X_getter_do_not_use"): + # This branch can be deleted once 6.X is not supported by upb rules + provides.append(cc_common.CcSharedLibraryHintInfo_6_X_getter_do_not_use) + + return provides + +upb_proto_library_aspect = aspect( + attrs = { + "_copts": attr.label( + default = "//:upb_proto_library_copts__for_generated_code_only_do_not_use", + ), + "_gen_upb": attr.label( + executable = True, + cfg = "exec", + default = "//upbc:protoc-gen-upb_stage1", + ), + "_protoc": attr.label( + executable = True, + cfg = "exec", + default = "@com_google_protobuf//:protoc", + ), + "_cc_toolchain": attr.label( + default = "@bazel_tools//tools/cpp:current_cc_toolchain", + ), + "_upb": attr.label_list(default = [ + "//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + ]), + "_fasttable_enabled": attr.label(default = "//:fasttable_enabled"), + }, + implementation = upb_proto_library_aspect_impl, + provides = _get_upb_proto_library_aspect_provides(), + attr_aspects = ["deps"], + fragments = ["cpp"], + toolchains = use_cpp_toolchain(), + incompatible_use_toolchain_transition = True, +) + +upb_proto_library = rule( + output_to_genfiles = True, + implementation = _upb_proto_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [upb_proto_library_aspect], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + }, + provides = [CcInfo], +) + +# upb_proto_reflection_library() ############################################### + +_upb_proto_reflection_library_aspect = aspect( + attrs = { + "_copts": attr.label( + default = "//:upb_proto_library_copts__for_generated_code_only_do_not_use", + ), + "_gen_upbdefs": attr.label( + executable = True, + cfg = "exec", + default = "//upbc:protoc-gen-upbdefs", + ), + "_protoc": attr.label( + executable = True, + cfg = "exec", + default = "@com_google_protobuf//:protoc", + ), + "_cc_toolchain": attr.label( + default = "@bazel_tools//tools/cpp:current_cc_toolchain", + ), + "_upbdefs": attr.label_list( + default = [ + "//:generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + ], + ), + }, + implementation = _upb_proto_reflection_library_aspect_impl, + provides = [ + _UpbDefsWrappedCcInfo, + _WrappedDefsGeneratedSrcsInfo, + ], + required_aspect_providers = [ + UpbWrappedCcInfo, + _UpbWrappedGeneratedSrcsInfo, + ], + attr_aspects = ["deps"], + fragments = ["cpp"], + toolchains = use_cpp_toolchain(), + incompatible_use_toolchain_transition = True, +) + +upb_proto_reflection_library = rule( + output_to_genfiles = True, + implementation = _upb_proto_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [ + upb_proto_library_aspect, + _upb_proto_reflection_library_aspect, + ], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + }, + provides = [CcInfo], +) diff --git a/archive/bazel/workspace_deps.bzl b/archive/bazel/workspace_deps.bzl new file mode 100644 index 0000000000..937ffcd98f --- /dev/null +++ b/archive/bazel/workspace_deps.bzl @@ -0,0 +1,104 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") +load("//bazel:python_downloads.bzl", "python_nuget_package", "python_source_archive") + +def _github_archive(repo, commit, **kwargs): + repo_name = repo.split("/")[-1] + http_archive( + urls = [repo + "/archive/" + commit + ".zip"], + strip_prefix = repo_name + "-" + commit, + **kwargs + ) + +def upb_deps(): + maybe( + _github_archive, + name = "com_google_absl", + repo = "https://github.com/abseil/abseil-cpp", + commit = "c2435f8342c2d0ed8101cb43adfd605fdc52dca2", # Abseil LTS 20230125.3 + sha256 = "ea1d31db00eb37e607bfda17ffac09064670ddf05da067944c4766f517876390", + ) + + maybe( + _github_archive, + name = "com_google_protobuf", + repo = "https://github.com/protocolbuffers/protobuf", + commit = "22e845e279bd79ad013bff4b79660b8c8b72d935", + sha256 = "276215041e767973f274299783b5d7b7de1a3c55628b9890bd9eb064dfa5daaf", + patches = ["@upb//bazel:protobuf.patch"], + ) + + maybe( + _github_archive, + name = "utf8_range", + repo = "https://github.com/protocolbuffers/utf8_range", + commit = "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", + sha256 = "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702", + ) + + maybe( + http_archive, + name = "rules_pkg", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz", + "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz", + ], + sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2", + ) + + maybe( + _github_archive, + name = "rules_python", + repo = "https://github.com/bazelbuild/rules_python", + commit = "912a5051f51581784fd64094f6bdabf93f6d698f", # 0.14.0 + sha256 = "a3e4b4ade7c4a52e757b16a16e94d0b2640333062180cba577d81fac087a501d", + ) + + maybe( + http_archive, + name = "bazel_skylib", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + ], + sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", + ) + + #Python Downloads + + python_source_archive( + name = "python-3.7.0", + sha256 = "85bb9feb6863e04fb1700b018d9d42d1caac178559ffa453d7e6a436e259fd0d", + ) + python_nuget_package( + name = "nuget_python_i686_3.7.0", + sha256 = "a8bb49fa1ca62ad55430fcafaca1b58015e22943e66b1a87d5e7cef2556c6a54", + ) + python_nuget_package( + name = "nuget_python_x86-64_3.7.0", + sha256 = "66eb796a5bdb1e6787b8f655a1237a6b6964af2115b7627cf4f0032cf068b4b2", + ) + python_nuget_package( + name = "nuget_python_i686_3.8.0", + sha256 = "87a6481f5eef30b42ac12c93f06f73bd0b8692f26313b76a6615d1641c4e7bca", + ) + python_nuget_package( + name = "nuget_python_x86-64_3.8.0", + sha256 = "96c61321ce90dd053c8a04f305a5f6cc6d91350b862db34440e4a4f069b708a0", + ) + python_nuget_package( + name = "nuget_python_i686_3.9.0", + sha256 = "229abecbe49dc08fe5709e0b31e70edfb3b88f23335ebfc2904c44f940fd59b6", + ) + python_nuget_package( + name = "nuget_python_x86-64_3.9.0", + sha256 = "6af58a733e7dfbfcdd50d55788134393d6ffe7ab8270effbf724bdb786558832", + ) + python_nuget_package( + name = "nuget_python_i686_3.10.0", + sha256 = "e115e102eb90ce160ab0ef7506b750a8d7ecc385bde0a496f02a54337a8bc333", + ) + python_nuget_package( + name = "nuget_python_x86-64_3.10.0", + sha256 = "4474c83c25625d93e772e926f95f4cd398a0abbb52793625fa30f39af3d2cc00", + ) diff --git a/archive/benchmarks/BUILD b/archive/benchmarks/BUILD new file mode 100644 index 0000000000..9983ba89b3 --- /dev/null +++ b/archive/benchmarks/BUILD @@ -0,0 +1,262 @@ +# 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. + +load("@rules_python//python:defs.bzl", "py_binary") + +# begin:google_only +# load("@rules_cc//cc:defs.bzl", "cc_proto_library") +# end:google_only + +load( + "//bazel:upb_proto_library.bzl", + "upb_proto_library", + "upb_proto_reflection_library", +) +load( + ":build_defs.bzl", + "cc_optimizefor_proto_library", + "expand_suffixes", + "proto_library", + "tmpl_cc_binary", +) + +# begin:google_only +# package(default_applicable_licenses = ["//:license"]) +# end:google_only + +licenses(["notice"]) + +proto_library( + name = "descriptor_proto", + srcs = ["descriptor.proto"], +) + +upb_proto_library( + name = "benchmark_descriptor_upb_proto", + deps = [":descriptor_proto"], +) + +upb_proto_reflection_library( + name = "benchmark_descriptor_upb_proto_reflection", + deps = [":descriptor_proto"], +) + +upb_proto_reflection_library( + name = "ads_upb_proto_reflection", + deps = ["@com_google_googleapis//:ads_proto"], +) + +cc_proto_library( + name = "benchmark_descriptor_cc_proto", + deps = [":descriptor_proto"], +) + +proto_library( + name = "benchmark_descriptor_sv_proto", + srcs = ["descriptor_sv.proto"], +) + +cc_proto_library( + name = "benchmark_descriptor_sv_cc_proto", + deps = [":benchmark_descriptor_sv_proto"], +) + +cc_test( + name = "benchmark", + testonly = 1, + srcs = ["benchmark.cc"], + deps = [ + ":ads_upb_proto_reflection", + ":benchmark_descriptor_cc_proto", + ":benchmark_descriptor_sv_cc_proto", + ":benchmark_descriptor_upb_proto", + ":benchmark_descriptor_upb_proto_reflection", + "//:base", + "//:base_internal", + "//:descriptor_upb_proto", + "//:mem", + "//:reflection", + "@com_github_google_benchmark//:benchmark_main", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_protobuf//:protobuf", + ], +) + +# Size benchmarks. + +SIZE_BENCHMARKS = { + "empty": "Empty", + "descriptor": "FileDescriptorSet", + "100_msgs": "Message100", + "200_msgs": "Message200", + "100_fields": "Message", + "200_fields": "Message", +} + +py_binary( + name = "gen_synthetic_protos", + srcs = ["gen_synthetic_protos.py"], + python_version = "PY3", +) + +py_binary( + name = "gen_upb_binary_c", + srcs = ["gen_upb_binary_c.py"], + python_version = "PY3", +) + +py_binary( + name = "gen_protobuf_binary_cc", + srcs = ["gen_protobuf_binary_cc.py"], + python_version = "PY3", +) + +genrule( + name = "do_gen_synthetic_protos", + outs = [ + "100_msgs.proto", + "200_msgs.proto", + "100_fields.proto", + "200_fields.proto", + ], + cmd = "$(execpath :gen_synthetic_protos) $(RULEDIR)", + tools = [":gen_synthetic_protos"], +) + +proto_library( + name = "100_msgs_proto", + srcs = ["100_msgs.proto"], +) + +proto_library( + name = "200_msgs_proto", + srcs = ["200_msgs.proto"], +) + +proto_library( + name = "100_fields_proto", + srcs = ["100_fields.proto"], +) + +proto_library( + name = "200_fields_proto", + srcs = ["200_fields.proto"], +) + +proto_library( + name = "empty_proto", + srcs = ["empty.proto"], +) + +[( + upb_proto_library( + name = k + "_upb_proto", + deps = [":" + k + "_proto"], + ), + cc_proto_library( + name = k + "_cc_proto", + deps = [":" + k + "_proto"], + ), + tmpl_cc_binary( + name = k + "_upb_binary", + testonly = 1, + args = [ + package_name() + "/" + k + ".upb.h", + "upb_benchmark_" + v, + ], + gen = ":gen_upb_binary_c", + deps = [ + ":" + k + "_upb_proto", + ], + ), + tmpl_cc_binary( + name = k + "_protobuf_binary", + testonly = 1, + args = [ + package_name() + "/" + k + ".pb.h", + "upb_benchmark::" + v, + ], + gen = ":gen_protobuf_binary_cc", + deps = [ + ":" + k + "_cc_proto", + ], + ), + cc_optimizefor_proto_library( + name = k + "_cc_lite_proto", + srcs = [k + ".proto"], + outs = [k + "_lite.proto"], + optimize_for = "LITE_RUNTIME", + ), + tmpl_cc_binary( + name = k + "_lite_protobuf_binary", + testonly = 1, + args = [ + package_name() + "/" + k + "_lite.pb.h", + "upb_benchmark::" + v, + ], + gen = ":gen_protobuf_binary_cc", + deps = [ + ":" + k + "_cc_lite_proto", + ], + ), + cc_optimizefor_proto_library( + name = k + "_cc_codesize_proto", + srcs = [k + ".proto"], + outs = [k + "_codesize.proto"], + optimize_for = "CODE_SIZE", + ), + tmpl_cc_binary( + name = k + "_codesize_protobuf_binary", + testonly = 1, + args = [ + package_name() + "/" + k + "_codesize.pb.h", + "upb_benchmark::" + v, + ], + gen = ":gen_protobuf_binary_cc", + deps = [ + ":" + k + "_cc_codesize_proto", + ], + ), +) for k, v in SIZE_BENCHMARKS.items()] + +genrule( + name = "size_data", + testonly = 1, + srcs = expand_suffixes( + SIZE_BENCHMARKS.keys(), + suffixes = [ + "_upb_binary", + "_protobuf_binary", + "_lite_protobuf_binary", + "_codesize_protobuf_binary", + ], + ), + outs = ["size_data.txt"], + # We want --format=GNU which counts rodata with data, not text. + cmd = "size $$($$OSTYPE == 'linux-gnu' ? '--format=GNU -d' : '') $(SRCS) > $@", + # "size" sometimes isn't available remotely. + local = 1, + tags = ["no-remote-exec"], +) diff --git a/archive/benchmarks/BUILD.googleapis b/archive/benchmarks/BUILD.googleapis new file mode 100644 index 0000000000..446967898c --- /dev/null +++ b/archive/benchmarks/BUILD.googleapis @@ -0,0 +1,59 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +load( + "@rules_proto//proto:defs.bzl", + "proto_library", +) + +proto_library( + name = "ads_proto", + srcs = glob([ + "google/ads/googleads/v13/**/*.proto", + "google/api/**/*.proto", + "google/rpc/**/*.proto", + "google/longrunning/**/*.proto", + "google/logging/**/*.proto", + ]), + #srcs = ["google/ads/googleads/v5/services/google_ads_service.proto"], + visibility = ["//visibility:public"], + deps = [ + "@com_google_protobuf//:any_proto", + "@com_google_protobuf//:api_proto", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:duration_proto", + "@com_google_protobuf//:empty_proto", + "@com_google_protobuf//:field_mask_proto", + "@com_google_protobuf//:struct_proto", + "@com_google_protobuf//:timestamp_proto", + "@com_google_protobuf//:type_proto", + "@com_google_protobuf//:wrappers_proto", + ], +) diff --git a/archive/benchmarks/benchmark.cc b/archive/benchmarks/benchmark.cc new file mode 100644 index 0000000000..a2e2cc20ea --- /dev/null +++ b/archive/benchmarks/benchmark.cc @@ -0,0 +1,390 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +#include + +#include + +#include "google/ads/googleads/v13/services/google_ads_service.upbdefs.h" +#include "google/protobuf/descriptor.pb.h" +#include "absl/container/flat_hash_set.h" +#include "google/protobuf/dynamic_message.h" +#include "benchmarks/descriptor.pb.h" +#include "benchmarks/descriptor.upb.h" +#include "benchmarks/descriptor.upbdefs.h" +#include "benchmarks/descriptor_sv.pb.h" +#include "upb/base/internal/log2.h" +#include "upb/mem/arena.h" +#include "upb/reflection/def.hpp" + +upb_StringView descriptor = benchmarks_descriptor_proto_upbdefinit.descriptor; +namespace protobuf = ::google::protobuf; + +// A buffer big enough to parse descriptor.proto without going to heap. +// We use 64-bit ints here to force alignment. +int64_t buf[8191]; + +void CollectFileDescriptors( + const _upb_DefPool_Init* file, + std::vector& serialized_files, + absl::flat_hash_set& seen) { + if (!seen.insert(file).second) return; + for (_upb_DefPool_Init** deps = file->deps; *deps; deps++) { + CollectFileDescriptors(*deps, serialized_files, seen); + } + serialized_files.push_back(file->descriptor); +} + +static void BM_ArenaOneAlloc(benchmark::State& state) { + for (auto _ : state) { + upb_Arena* arena = upb_Arena_New(); + upb_Arena_Malloc(arena, 1); + upb_Arena_Free(arena); + } +} +BENCHMARK(BM_ArenaOneAlloc); + +static void BM_ArenaInitialBlockOneAlloc(benchmark::State& state) { + for (auto _ : state) { + upb_Arena* arena = upb_Arena_Init(buf, sizeof(buf), nullptr); + upb_Arena_Malloc(arena, 1); + upb_Arena_Free(arena); + } +} +BENCHMARK(BM_ArenaInitialBlockOneAlloc); + +static void BM_ArenaFuseUnbalanced(benchmark::State& state) { + std::vector arenas(state.range(0)); + size_t n = 0; + for (auto _ : state) { + for (auto& arena : arenas) { + arena = upb_Arena_New(); + } + for (auto& arena : arenas) { + upb_Arena_Fuse(arenas[0], arena); + } + for (auto& arena : arenas) { + upb_Arena_Free(arena); + } + n += arenas.size(); + } + state.SetItemsProcessed(n); +} +BENCHMARK(BM_ArenaFuseUnbalanced)->Range(2, 128); + +static void BM_ArenaFuseBalanced(benchmark::State& state) { + std::vector arenas(state.range(0)); + size_t n = 0; + + for (auto _ : state) { + for (auto& arena : arenas) { + arena = upb_Arena_New(); + } + + // Perform a series of fuses that keeps the halves balanced. + size_t max = upb_Log2Ceiling(arenas.size()); + for (size_t n = 0; n <= max; n++) { + size_t step = 1 << n; + for (size_t i = 0; i + step < arenas.size(); i += (step * 2)) { + upb_Arena_Fuse(arenas[i], arenas[i + step]); + } + } + + for (auto& arena : arenas) { + upb_Arena_Free(arena); + } + n += arenas.size(); + } + state.SetItemsProcessed(n); +} +BENCHMARK(BM_ArenaFuseBalanced)->Range(2, 128); + +enum LoadDescriptorMode { + NoLayout, + WithLayout, +}; + +// This function is mostly copied from upb/def.c, but it is modified to avoid +// passing in the pre-generated mini-tables, in order to force upb to compute +// them dynamically. Generally you would never want to do this, but we want to +// simulate the cost we would pay if we were loading these types purely from +// descriptors, with no mini-tales available. +bool LoadDefInit_BuildLayout(upb_DefPool* s, const _upb_DefPool_Init* init, + size_t* bytes) { + _upb_DefPool_Init** deps = init->deps; + google_protobuf_FileDescriptorProto* file; + upb_Arena* arena; + upb_Status status; + + upb_Status_Clear(&status); + + if (upb_DefPool_FindFileByName(s, init->filename)) { + return true; + } + + arena = upb_Arena_New(); + + for (; *deps; deps++) { + if (!LoadDefInit_BuildLayout(s, *deps, bytes)) goto err; + } + + file = google_protobuf_FileDescriptorProto_parse_ex( + init->descriptor.data, init->descriptor.size, nullptr, + kUpb_DecodeOption_AliasString, arena); + *bytes += init->descriptor.size; + + if (!file) { + upb_Status_SetErrorFormat( + &status, + "Failed to parse compiled-in descriptor for file '%s'. This should " + "never happen.", + init->filename); + goto err; + } + + // KEY DIFFERENCE: Here we pass in only the descriptor, and not the + // pre-generated minitables. + if (!upb_DefPool_AddFile(s, file, &status)) { + goto err; + } + + upb_Arena_Free(arena); + return true; + +err: + fprintf(stderr, + "Error loading compiled-in descriptor for file '%s' (this should " + "never happen): %s\n", + init->filename, upb_Status_ErrorMessage(&status)); + exit(1); +} + +template +static void BM_LoadAdsDescriptor_Upb(benchmark::State& state) { + size_t bytes_per_iter = 0; + for (auto _ : state) { + upb::DefPool defpool; + if (Mode == NoLayout) { + google_ads_googleads_v13_services_SearchGoogleAdsRequest_getmsgdef( + defpool.ptr()); + bytes_per_iter = _upb_DefPool_BytesLoaded(defpool.ptr()); + } else { + bytes_per_iter = 0; + LoadDefInit_BuildLayout( + defpool.ptr(), + &google_ads_googleads_v13_services_google_ads_service_proto_upbdefinit, + &bytes_per_iter); + } + } + state.SetBytesProcessed(state.iterations() * bytes_per_iter); +} +BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Upb, NoLayout); +BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Upb, WithLayout); + +template +static void BM_LoadAdsDescriptor_Proto2(benchmark::State& state) { + extern _upb_DefPool_Init + google_ads_googleads_v13_services_google_ads_service_proto_upbdefinit; + std::vector serialized_files; + absl::flat_hash_set seen_files; + CollectFileDescriptors( + &google_ads_googleads_v13_services_google_ads_service_proto_upbdefinit, + serialized_files, seen_files); + size_t bytes_per_iter = 0; + for (auto _ : state) { + bytes_per_iter = 0; + protobuf::Arena arena; + protobuf::DescriptorPool pool; + for (auto file : serialized_files) { + absl::string_view input(file.data, file.size); + auto proto = + protobuf::Arena::CreateMessage(&arena); + bool ok = proto->ParseFrom(input) && + pool.BuildFile(*proto) != nullptr; + if (!ok) { + printf("Failed to add file.\n"); + exit(1); + } + bytes_per_iter += input.size(); + } + + if (Mode == WithLayout) { + protobuf::DynamicMessageFactory factory; + const protobuf::Descriptor* d = pool.FindMessageTypeByName( + "google.ads.googleads.v13.services.SearchGoogleAdsResponse"); + if (!d) { + printf("Failed to find descriptor.\n"); + exit(1); + } + factory.GetPrototype(d); + } + } + state.SetBytesProcessed(state.iterations() * bytes_per_iter); +} +BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Proto2, NoLayout); +BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Proto2, WithLayout); + +enum CopyStrings { + Copy, + Alias, +}; + +enum ArenaMode { + NoArena, + UseArena, + InitBlock, +}; + +template +static void BM_Parse_Upb_FileDesc(benchmark::State& state) { + for (auto _ : state) { + upb_Arena* arena; + if (AMode == InitBlock) { + arena = upb_Arena_Init(buf, sizeof(buf), nullptr); + } else { + arena = upb_Arena_New(); + } + upb_benchmark_FileDescriptorProto* set = + upb_benchmark_FileDescriptorProto_parse_ex( + descriptor.data, descriptor.size, nullptr, + Copy == Alias ? kUpb_DecodeOption_AliasString : 0, arena); + if (!set) { + printf("Failed to parse.\n"); + exit(1); + } + upb_Arena_Free(arena); + } + state.SetBytesProcessed(state.iterations() * descriptor.size); +} +BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, UseArena, Copy); +BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, UseArena, Alias); +BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, InitBlock, Copy); +BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, InitBlock, Alias); + +template +struct Proto2Factory; + +template +struct Proto2Factory { + public: + P* GetProto() { return &proto; } + + private: + P proto; +}; + +template +struct Proto2Factory { + public: + P* GetProto() { return protobuf::Arena::CreateMessage

(&arena); } + + private: + protobuf::Arena arena; +}; + +template +struct Proto2Factory { + public: + Proto2Factory() : arena(GetOptions()) {} + P* GetProto() { return protobuf::Arena::CreateMessage

(&arena); } + + private: + protobuf::ArenaOptions GetOptions() { + protobuf::ArenaOptions opts; + opts.initial_block = (char*)buf; + opts.initial_block_size = sizeof(buf); + return opts; + } + + protobuf::Arena arena; +}; + +using FileDesc = ::upb_benchmark::FileDescriptorProto; +using FileDescSV = ::upb_benchmark::sv::FileDescriptorProto; + +template +void BM_Parse_Proto2(benchmark::State& state) { + constexpr protobuf::MessageLite::ParseFlags kParseFlags = + kCopy == Copy + ? protobuf::MessageLite::ParseFlags::kMergePartial + : protobuf::MessageLite::ParseFlags::kMergePartialWithAliasing; + for (auto _ : state) { + Proto2Factory proto_factory; + auto proto = proto_factory.GetProto(); + absl::string_view input(descriptor.data, descriptor.size); + bool ok = proto->template ParseFrom(input); + if (!ok) { + printf("Failed to parse.\n"); + exit(1); + } + } + state.SetBytesProcessed(state.iterations() * descriptor.size); +} +BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDesc, NoArena, Copy); +BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDesc, UseArena, Copy); +BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDesc, InitBlock, Copy); +BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDescSV, InitBlock, Alias); + +static void BM_SerializeDescriptor_Proto2(benchmark::State& state) { + upb_benchmark::FileDescriptorProto proto; + proto.ParseFromArray(descriptor.data, descriptor.size); + for (auto _ : state) { + proto.SerializePartialToArray(buf, sizeof(buf)); + } + state.SetBytesProcessed(state.iterations() * descriptor.size); +} +BENCHMARK(BM_SerializeDescriptor_Proto2); + +static void BM_SerializeDescriptor_Upb(benchmark::State& state) { + int64_t total = 0; + upb_Arena* arena = upb_Arena_New(); + upb_benchmark_FileDescriptorProto* set = + upb_benchmark_FileDescriptorProto_parse(descriptor.data, descriptor.size, + arena); + if (!set) { + printf("Failed to parse.\n"); + exit(1); + } + for (auto _ : state) { + upb_Arena* enc_arena = upb_Arena_Init(buf, sizeof(buf), nullptr); + size_t size; + char* data = + upb_benchmark_FileDescriptorProto_serialize(set, enc_arena, &size); + if (!data) { + printf("Failed to serialize.\n"); + exit(1); + } + total += size; + } + state.SetBytesProcessed(total); +} +BENCHMARK(BM_SerializeDescriptor_Upb); diff --git a/archive/benchmarks/build_defs.bzl b/archive/benchmarks/build_defs.bzl new file mode 100644 index 0000000000..168dab6634 --- /dev/null +++ b/archive/benchmarks/build_defs.bzl @@ -0,0 +1,88 @@ +# 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. + +# begin:google_only +# load("@rules_cc//cc:defs.bzl", _cc_proto_library = "cc_proto_library") +# +# _is_google3 = True +# end:google_only + +# begin:github_only +_cc_proto_library = native.cc_proto_library +_is_google3 = False +# end:github_only + +def proto_library(**kwargs): + if _is_google3: + kwargs["cc_api_version"] = 2 + native.proto_library( + **kwargs + ) + +def tmpl_cc_binary(name, gen, args, replacements = [], **kwargs): + srcs = [name + ".cc"] + native.genrule( + name = name + "_gen_srcs", + tools = [gen], + outs = srcs, + cmd = "$(location " + gen + ") " + " ".join(args) + " > $@", + ) + + if _is_google3: + kwargs["malloc"] = "//base:system_malloc" + kwargs["features"] = ["-static_linking_mode"] + native.cc_binary( + name = name, + srcs = srcs, + **kwargs + ) + +def cc_optimizefor_proto_library(name, srcs, outs, optimize_for): + if len(srcs) != 1: + fail("Currently srcs must have exactly 1 element") + + native.genrule( + name = name + "_gen_proto", + srcs = srcs, + outs = outs, + cmd = "cp $< $@ && chmod a+w $@ && echo 'option optimize_for = " + optimize_for + ";' >> $@", + ) + + proto_library( + name = name + "_proto", + srcs = outs, + ) + + _cc_proto_library( + name = name, + deps = [":" + name + "_proto"], + ) + +def expand_suffixes(vals, suffixes): + ret = [] + for val in vals: + for suffix in suffixes: + ret.append(val + suffix) + return ret diff --git a/benchmarks/compare.py b/archive/benchmarks/compare.py similarity index 50% rename from benchmarks/compare.py rename to archive/benchmarks/compare.py index 8d62d94272..027d994132 100755 --- a/benchmarks/compare.py +++ b/archive/benchmarks/compare.py @@ -1,4 +1,35 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + """Benchmarks the current working directory against a given baseline. This script benchmarks both size and speed. Sample output: @@ -38,27 +69,30 @@ def Benchmark(outbase, bench_cpu=True, runs=12, fasttable=False): if bench_cpu: Run("CC=clang bazel build -c opt --copt=-march=native benchmarks:benchmark" + extra_args) - Run("./bazel-bin/benchmarks/benchmark --benchmark_out_format=json --benchmark_out={} --benchmark_repetitions={}".format(tmpfile, runs)) + Run("./bazel-bin/benchmarks/benchmark --benchmark_out_format=json --benchmark_out={} --benchmark_repetitions={} --benchmark_min_time=0.05 --benchmark_enable_random_interleaving=true".format(tmpfile, runs)) with open(tmpfile) as f: bench_json = json.load(f) # Translate into the format expected by benchstat. - with open(outbase + ".txt", "w") as f: + txt_filename = outbase + ".txt" + with open(txt_filename, "w") as f: for run in bench_json["benchmarks"]: + if run["run_type"] == "aggregate": + continue name = run["name"] name = name.replace(" ", "") name = re.sub(r'^BM_', 'Benchmark', name) - if name.endswith("_mean") or name.endswith("_median") or name.endswith("_stddev"): - continue values = (name, run["iterations"], run["cpu_time"]) print("{} {} {} ns/op".format(*values), file=f) + Run("sort {} -o {} ".format(txt_filename, txt_filename)) - Run("CC=clang bazel build -c opt --copt=-g tests:conformance_upb" + extra_args) - Run("cp -f bazel-bin/tests/conformance_upb {}.bin".format(outbase)) + Run("CC=clang bazel build -c opt --copt=-g --copt=-march=native :conformance_upb" + + extra_args) + Run("cp -f bazel-bin/conformance_upb {}.bin".format(outbase)) -baseline = "master" -bench_cpu = False +baseline = "main" +bench_cpu = True fasttable = False if len(sys.argv) > 1: diff --git a/benchmarks/descriptor.proto b/archive/benchmarks/descriptor.proto similarity index 99% rename from benchmarks/descriptor.proto rename to archive/benchmarks/descriptor.proto index b69b27f89e..a912dbf2ef 100644 --- a/benchmarks/descriptor.proto +++ b/archive/benchmarks/descriptor.proto @@ -36,7 +36,6 @@ // A valid .proto file can be translated directly to a FileDescriptorProto // without any other information (e.g. without reading its imports). - syntax = "proto2"; package upb_benchmark; @@ -45,7 +44,7 @@ option go_package = "google.golang.org/protobuf/types/descriptorpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection"; -option objc_class_prefix = "GPB"; +option objc_class_prefix = "UPBB"; option cc_enable_arenas = true; // The protocol compiler can output a FileDescriptorSet containing the .proto @@ -125,7 +124,6 @@ message ExtensionRangeOptions { // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; - // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; } @@ -302,7 +300,6 @@ message MethodDescriptorProto { optional bool server_streaming = 6 [default = false]; } - // =================================================================== // Options @@ -336,14 +333,12 @@ message MethodDescriptorProto { // to automatically assign option numbers. message FileOptions { - // Sets the Java package where classes generated from this .proto will be // placed. By default, the proto package is used, but this is often // inappropriate because proto packages do not normally start with backwards // domain names. optional string java_package = 1; - // If set, all the classes from the .proto file are wrapped in a single // outer class with the given name. This applies to both Proto1 // (equivalent to the old "--one_java_file" option) and Proto2 (where @@ -360,7 +355,7 @@ message FileOptions { optional bool java_multiple_files = 10 [default = false]; // This option does nothing. - optional bool java_generate_equals_and_hash = 20 [deprecated=true]; + optional bool java_generate_equals_and_hash = 20 [deprecated = true]; // If set true, then the Java2 code generator will generate code that // throws an exception whenever an attempt is made to assign a non-UTF-8 @@ -370,7 +365,6 @@ message FileOptions { // This option has no effect on when used with the lite runtime. optional bool java_string_check_utf8 = 27 [default = false]; - // Generated classes can be optimized for speed or code size. enum OptimizeMode { SPEED = 1; // Generate complete code for parsing, serialization, @@ -387,9 +381,6 @@ message FileOptions { // - Otherwise, the basename of the .proto file, without extension. optional string go_package = 11; - - - // Should generic services be generated in each language? "Generic" services // are not specific to any particular RPC system. They are generated by the // main code generators in each language (without additional plugins). @@ -415,7 +406,6 @@ message FileOptions { // only to generated classes for C++. optional bool cc_enable_arenas = 31 [default = true]; - // Sets the objective c class prefix which is prepended to all objective c // generated classes from this .proto. There is no default. optional string objc_class_prefix = 36; @@ -448,7 +438,6 @@ message FileOptions { // determining the ruby package. optional string ruby_package = 45; - // The parser stores options it doesn't recognize here. // See the documentation for the "Options" section above. repeated UninterpretedOption uninterpreted_option = 999; @@ -518,7 +507,6 @@ message MessageOptions { reserved 8; // javalite_serializable reserved 9; // javanano_as_lite - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -609,7 +597,6 @@ message FieldOptions { // For Google-internal migration only. Do not use. optional bool weak = 10 [default = false]; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -628,7 +615,6 @@ message OneofOptions { } message EnumOptions { - // Set this option to true to allow mapping different tag names to the same // value. optional bool allow_alias = 2; @@ -663,7 +649,6 @@ message EnumValueOptions { } message ServiceOptions { - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC // framework. We apologize for hoarding these numbers to ourselves, but // we were already using them long before we decided to release Protocol @@ -683,7 +668,6 @@ message ServiceOptions { } message MethodOptions { - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC // framework. We apologize for hoarding these numbers to ourselves, but // we were already using them long before we decided to release Protocol @@ -713,7 +697,6 @@ message MethodOptions { extensions 1000 to max; } - // A message representing a option the parser does not recognize. This only // appears in options protos created by the compiler::Parser class. // DescriptorPool resolves these when building Descriptor objects. Therefore, diff --git a/benchmarks/descriptor_sv.proto b/archive/benchmarks/descriptor_sv.proto similarity index 100% rename from benchmarks/descriptor_sv.proto rename to archive/benchmarks/descriptor_sv.proto diff --git a/archive/benchmarks/empty.proto b/archive/benchmarks/empty.proto new file mode 100644 index 0000000000..3c32ccc38b --- /dev/null +++ b/archive/benchmarks/empty.proto @@ -0,0 +1,35 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package upb_benchmark; + +message Empty {} diff --git a/archive/benchmarks/gen_protobuf_binary_cc.py b/archive/benchmarks/gen_protobuf_binary_cc.py new file mode 100644 index 0000000000..ece5b2372e --- /dev/null +++ b/archive/benchmarks/gen_protobuf_binary_cc.py @@ -0,0 +1,69 @@ +#!/usr/bin/python3 +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import sys +import re + +include = sys.argv[1] +msg_basename = sys.argv[2] +count = 1 + +m = re.search(r'(.*\D)(\d+)$', sys.argv[2]) +if m: + msg_basename = m.group(1) + count = int(m.group(2)) + +print(''' +#include "{include}" + +char buf[1]; + +int main() {{ +'''.format(include=include)) + +def RefMessage(name): + print(''' + {{ + {name} proto; + proto.ParseFromArray(buf, 0); + proto.SerializePartialToArray(&buf[0], 0); + }} + '''.format(name=name)) + +RefMessage(msg_basename) + +for i in range(2, count + 1): + RefMessage(msg_basename + str(i)) + +print(''' + return 0; +}''') diff --git a/benchmarks/gen_synthetic_protos.py b/archive/benchmarks/gen_synthetic_protos.py similarity index 64% rename from benchmarks/gen_synthetic_protos.py rename to archive/benchmarks/gen_synthetic_protos.py index a95deff080..3b4e37e695 100644 --- a/benchmarks/gen_synthetic_protos.py +++ b/archive/benchmarks/gen_synthetic_protos.py @@ -1,3 +1,34 @@ +#!/usr/bin/python3 +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import sys import random diff --git a/archive/benchmarks/gen_upb_binary_c.py b/archive/benchmarks/gen_upb_binary_c.py new file mode 100644 index 0000000000..a68a7794db --- /dev/null +++ b/archive/benchmarks/gen_upb_binary_c.py @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import sys +import re + +include = sys.argv[1] +msg_basename = sys.argv[2] +count = 1 + +m = re.search(r'(.*\D)(\d+)$', sys.argv[2]) +if m: + msg_basename = m.group(1) + count = int(m.group(2)) + +print(''' +#include "{include}" + +char buf[1]; + +int main() {{ + upb_Arena *arena = upb_Arena_New(); + size_t size; +'''.format(include=include)) + +def RefMessage(name): + print(''' + {{ + {name} *proto = {name}_parse(buf, 1, arena); + {name}_serialize(proto, arena, &size); + }} + '''.format(name=name)) + +RefMessage(msg_basename) + +for i in range(2, count + 1): + RefMessage(msg_basename + str(i)) + +print(''' + return 0; +}''') diff --git a/archive/cmake/BUILD.bazel b/archive/cmake/BUILD.bazel new file mode 100644 index 0000000000..aec46152b4 --- /dev/null +++ b/archive/cmake/BUILD.bazel @@ -0,0 +1,125 @@ +# 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. + +load( + ":build_defs.bzl", + "staleness_test", +) +load( + "//bazel:build_defs.bzl", + "make_shell_script", +) + +licenses(["notice"]) + +exports_files(["staleness_test.py"]) + +py_library( + name = "staleness_test_lib", + testonly = 1, + srcs = ["staleness_test_lib.py"], + # This is public only for use by the staleness_test() macro. Please do not + # depend on this target directly. + visibility = ["//visibility:public"], +) + +py_binary( + name = "make_cmakelists", + srcs = ["make_cmakelists.py"], +) + +genrule( + name = "gen_cmakelists", + srcs = [ + "//:BUILD", + "//:WORKSPACE", + "//bazel:workspace_deps.bzl", + ], + outs = ["generated-in/CMakeLists.txt"], + cmd = "$(location :make_cmakelists) " + + "$(location //bazel:workspace_deps.bzl) " + + "$(location //:WORKSPACE) " + + "$(location //:BUILD) $@", + tools = [":make_cmakelists"], +) + +genrule( + name = "copy_protos", + srcs = ["//:descriptor_upb_proto"], + outs = [ + "generated-in/google/protobuf/descriptor.upb.c", + "generated-in/google/protobuf/descriptor.upb.h", + ], + cmd = "cp $(SRCS) $(@D)/generated-in/google/protobuf", +) + +staleness_test( + name = "test_generated_files", + outs = [ + "CMakeLists.txt", + "google/protobuf/descriptor.upb.c", + "google/protobuf/descriptor.upb.h", + ], + generated_pattern = "generated-in/%s", + tags = ["manual"], +) + +# Test the CMake build ######################################################### + +make_shell_script( + name = "gen_run_cmake_build", + out = "run_cmake_build.sh", + contents = "set -ex\n" + + "cd $(dirname $1) && cp -r . .. && cd ../..\n" + + "mkdir build && cd build && cmake ../cmake && make -j8 && make test", +) + +sh_test( + name = "cmake_build", + srcs = ["run_cmake_build.sh"], + args = ["$(location :gen_cmakelists)"], + data = [ + ":copy_protos", + ":gen_cmakelists", + "//:source_files", + "//upb/base:source_files", + "//upb/collections:source_files", + "//upb/hash:source_files", + "//upb/lex:source_files", + "//upb/mem:source_files", + "//upb/message:source_files", + "//upb/mini_descriptor:source_files", + "//upb/mini_table:source_files", + "//upb/port:source_files", + "//upb/text:source_files", + "//upb/wire:source_files", + "@utf8_range//:utf8_range_srcs", + ], + target_compatible_with = select({ + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), + deps = ["@bazel_tools//tools/bash/runfiles"], +) diff --git a/archive/cmake/CMakeLists.txt b/archive/cmake/CMakeLists.txt new file mode 100644 index 0000000000..1952dc32a3 --- /dev/null +++ b/archive/cmake/CMakeLists.txt @@ -0,0 +1,129 @@ +# This file was generated from BUILD using tools/make_cmakelists.py. + +cmake_minimum_required(VERSION 3.10...3.24) + +project(upb) +set(CMAKE_C_STANDARD 99) + + +# Prevent CMake from setting -rdynamic on Linux (!!). +SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +# Set default build type. +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." + FORCE) +endif() + +# When using Ninja, compiler output won't be colorized without this. +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG(-fdiagnostics-color=always SUPPORTS_COLOR_ALWAYS) +if(SUPPORTS_COLOR_ALWAYS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") +endif() + +# Implement ASAN/UBSAN options +if(UPB_ENABLE_ASAN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") +endif() + +if(UPB_ENABLE_UBSAN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") +endif() + +if(NOT TARGET utf8_range) + if(EXISTS ../external/utf8_range) + # utf8_range is already installed + include_directories(../external/utf8_range) + elseif(EXISTS ../../utf8_range) + include_directories(../../utf8_range) + else() + include(FetchContent) + FetchContent_Declare( + utf8_range + GIT_REPOSITORY "https://github.com/protocolbuffers/utf8_range.git" + GIT_TAG "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f" + ) + FetchContent_GetProperties(utf8_range) + if(NOT utf8_range_POPULATED) + FetchContent_Populate(utf8_range) + include_directories(${utf8_range_SOURCE_DIR}) + endif() + endif() +endif() + +if(APPLE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -flat_namespace") +elseif(UNIX) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id") +endif() + +enable_testing() + + +add_library(upb INTERFACE + +) +target_include_directories(upb INTERFACE + $ + $ + $ +) +target_link_libraries(upb INTERFACE + base + mem) + +add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + +) +target_include_directories(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + $ + $ + $ +) +target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + base + collections + collections_internal + mem + message + message_accessors + message_accessors_internal + message_internal + mini_descriptor + mini_table + wire + wire_internal) + +add_library(generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + +) +target_include_directories(generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + $ + $ + $ +) + +add_library(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + +) +target_include_directories(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + $ + $ + $ +) +target_link_libraries(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + mem + mini_descriptor + reflection_internal) + + diff --git a/cmake/README.md b/archive/cmake/README.md similarity index 100% rename from cmake/README.md rename to archive/cmake/README.md diff --git a/archive/cmake/build_defs.bzl b/archive/cmake/build_defs.bzl new file mode 100644 index 0000000000..157c3cb053 --- /dev/null +++ b/archive/cmake/build_defs.bzl @@ -0,0 +1,77 @@ +# 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. + +"""Bazel support functions related to CMake support.""" + +def staleness_test(name, outs, generated_pattern, target_files = None, tags = [], **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 + correct contents. If the test fails, it can be invoked with --fix to + bring the checked-in files up to date. + + Args: + name: Name of the rule. + outs: the checked-in files that are copied from generated files. + 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(). + """ + + script_name = name + ".py" + script_src = Label("//cmake:staleness_test.py") + + # Filter out non-existing rules so Blaze doesn't error out before we even + # run the test. + existing_outs = native.glob(include = outs) + + # The file list contains a few extra bits of information at the end. + # These get unpacked by the Config class in staleness_test_lib.py. + file_list = outs + [generated_pattern, native.package_name() or ".", name] + + native.genrule( + name = name + "_makescript", + outs = [script_name], + srcs = [script_src], + testonly = 1, + cmd = "cp $< $@; " + + "sed -i.bak -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@", + ) + + native.py_test( + name = name, + srcs = [script_name], + data = existing_outs + [generated_pattern % file for file in outs], + python_version = "PY3", + deps = [ + Label("//cmake:staleness_test_lib"), + ], + tags = ["staleness_test"] + tags, + **kwargs + ) diff --git a/archive/cmake/google/protobuf/descriptor.upb.c b/archive/cmake/google/protobuf/descriptor.upb.c new file mode 100644 index 0000000000..24b4f8a604 --- /dev/null +++ b/archive/cmake/google/protobuf/descriptor.upb.c @@ -0,0 +1,1327 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#include +#include "upb/generated_code_support.h" +#include "google/protobuf/descriptor.upb.h" + +// Must be last. +#include "upb/port/def.inc" + +static const upb_MiniTableSub google_protobuf_FileDescriptorSet_submsgs[1] = { + {.submsg = &google_protobuf_FileDescriptorProto_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_FileDescriptorSet__fields[1] = { + {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FileDescriptorSet_msg_init = { + &google_protobuf_FileDescriptorSet_submsgs[0], + &google_protobuf_FileDescriptorSet__fields[0], + 8, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000000003f00000a, &upb_prm_1bt_max192b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FileDescriptorProto_submsgs[6] = { + {.submsg = &google_protobuf_DescriptorProto_msg_init}, + {.submsg = &google_protobuf_EnumDescriptorProto_msg_init}, + {.submsg = &google_protobuf_ServiceDescriptorProto_msg_init}, + {.submsg = &google_protobuf_FieldDescriptorProto_msg_init}, + {.submsg = &google_protobuf_FileOptions_msg_init}, + {.submsg = &google_protobuf_SourceCodeInfo_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_FileDescriptorProto__fields[13] = { + {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(48, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(24, 80), 3, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {9, UPB_SIZE(28, 88), 4, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {12, UPB_SIZE(56, 112), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {13, UPB_SIZE(64, 128), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FileDescriptorProto_msg_init = { + &google_protobuf_FileDescriptorProto_submsgs[0], + &google_protobuf_FileDescriptorProto__fields[0], + UPB_SIZE(72, 144), 13, kUpb_ExtMode_NonExtendable, 13, UPB_FASTTABLE_MASK(120), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x0018000002000012, &upb_pss_1bt}, + {0x002800003f00001a, &upb_prs_1bt}, + {0x003000003f000022, &upb_prm_1bt_max128b}, + {0x003800003f01002a, &upb_prm_1bt_max64b}, + {0x004000003f020032, &upb_prm_1bt_max64b}, + {0x004800003f03003a, &upb_prm_1bt_max128b}, + {0x0050000003040042, &upb_psm_1bt_max256b}, + {0x005800000405004a, &upb_psm_1bt_max64b}, + {0x006000003f000050, &upb_prv4_1bt}, + {0x006800003f000058, &upb_prv4_1bt}, + {0x0070000005000062, &upb_pss_1bt}, + {0x008000000600006a, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_DescriptorProto_submsgs[8] = { + {.submsg = &google_protobuf_FieldDescriptorProto_msg_init}, + {.submsg = &google_protobuf_DescriptorProto_msg_init}, + {.submsg = &google_protobuf_EnumDescriptorProto_msg_init}, + {.submsg = &google_protobuf_DescriptorProto_ExtensionRange_msg_init}, + {.submsg = &google_protobuf_FieldDescriptorProto_msg_init}, + {.submsg = &google_protobuf_MessageOptions_msg_init}, + {.submsg = &google_protobuf_OneofDescriptorProto_msg_init}, + {.submsg = &google_protobuf_DescriptorProto_ReservedRange_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_DescriptorProto__fields[10] = { + {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(24, 64), 2, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_DescriptorProto_msg_init = { + &google_protobuf_DescriptorProto_submsgs[0], + &google_protobuf_DescriptorProto__fields[0], + UPB_SIZE(48, 96), 10, kUpb_ExtMode_NonExtendable, 10, UPB_FASTTABLE_MASK(120), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x001800003f000012, &upb_prm_1bt_max128b}, + {0x002000003f01001a, &upb_prm_1bt_max128b}, + {0x002800003f020022, &upb_prm_1bt_max64b}, + {0x003000003f03002a, &upb_prm_1bt_max64b}, + {0x003800003f040032, &upb_prm_1bt_max128b}, + {0x004000000205003a, &upb_psm_1bt_max64b}, + {0x004800003f060042, &upb_prm_1bt_max64b}, + {0x005000003f07004a, &upb_prm_1bt_max64b}, + {0x005800003f000052, &upb_prs_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = { + {.submsg = &google_protobuf_ExtensionRangeOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_DescriptorProto_ExtensionRange__fields[3] = { + {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(12, 16), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_DescriptorProto_ExtensionRange_msg_init = { + &google_protobuf_DescriptorProto_ExtensionRange_submsgs[0], + &google_protobuf_DescriptorProto_ExtensionRange__fields[0], + UPB_SIZE(16, 24), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0004000001000008, &upb_psv4_1bt}, + {0x0008000002000010, &upb_psv4_1bt}, + {0x001000000300001a, &upb_psm_1bt_max64b}, + }) +}; + +static const upb_MiniTableField google_protobuf_DescriptorProto_ReservedRange__fields[2] = { + {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_DescriptorProto_ReservedRange_msg_init = { + NULL, + &google_protobuf_DescriptorProto_ReservedRange__fields[0], + 16, 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0004000001000008, &upb_psv4_1bt}, + {0x0008000002000010, &upb_psv4_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_ExtensionRangeOptions_submsgs[4] = { + {.submsg = &google_protobuf_ExtensionRangeOptions_Declaration_msg_init}, + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, + {.subenum = &google_protobuf_ExtensionRangeOptions_VerificationState_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_ExtensionRangeOptions__fields[4] = { + {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 4), 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {50, UPB_SIZE(12, 16), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_ExtensionRangeOptions_msg_init = { + &google_protobuf_ExtensionRangeOptions_submsgs[0], + &google_protobuf_ExtensionRangeOptions__fields[0], + UPB_SIZE(24, 32), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800003f000012, &upb_prm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0010000002010392, &upb_psm_2bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800003f023eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_ExtensionRangeOptions_Declaration__fields[5] = { + {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 16), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(20, 32), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {5, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, 9, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_ExtensionRangeOptions_Declaration_msg_init = { + NULL, + &google_protobuf_ExtensionRangeOptions_Declaration__fields[0], + UPB_SIZE(32, 48), 5, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(56), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0004000001000008, &upb_psv4_1bt}, + {0x0010000002000012, &upb_pss_1bt}, + {0x002000000300001a, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0008000004000028, &upb_psb1_1bt}, + {0x0009000005000030, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FieldDescriptorProto_submsgs[3] = { + {.submsg = &google_protobuf_FieldOptions_msg_init}, + {.subenum = &google_protobuf_FieldDescriptorProto_Label_enum_init}, + {.subenum = &google_protobuf_FieldDescriptorProto_Type_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FieldDescriptorProto__fields[11] = { + {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, 4, 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, 8, 4, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, 12, 5, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(44, 56), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(52, 72), 7, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(16, 88), 8, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {9, UPB_SIZE(20, 16), 9, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {10, UPB_SIZE(60, 96), 10, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {17, UPB_SIZE(24, 20), 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FieldDescriptorProto_msg_init = { + &google_protobuf_FieldDescriptorProto_submsgs[0], + &google_protobuf_FieldDescriptorProto__fields[0], + UPB_SIZE(72, 112), 11, kUpb_ExtMode_NonExtendable, 10, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800000100000a, &upb_pss_1bt}, + {0x0028000002000012, &upb_pss_1bt}, + {0x0004000003000018, &upb_psv4_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0038000006000032, &upb_pss_1bt}, + {0x004800000700003a, &upb_pss_1bt}, + {0x0058000008000042, &upb_psm_1bt_max64b}, + {0x0010000009000048, &upb_psv4_1bt}, + {0x006000000a000052, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001400000b000188, &upb_psb1_2bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_OneofDescriptorProto_submsgs[1] = { + {.submsg = &google_protobuf_OneofOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_OneofDescriptorProto__fields[2] = { + {1, 8, 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(4, 24), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_OneofDescriptorProto_msg_init = { + &google_protobuf_OneofDescriptorProto_submsgs[0], + &google_protobuf_OneofDescriptorProto__fields[0], + UPB_SIZE(16, 32), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x0018000002000012, &upb_psm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_EnumDescriptorProto_submsgs[3] = { + {.submsg = &google_protobuf_EnumValueDescriptorProto_msg_init}, + {.submsg = &google_protobuf_EnumOptions_msg_init}, + {.submsg = &google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumDescriptorProto__fields[5] = { + {1, UPB_SIZE(20, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_EnumDescriptorProto_msg_init = { + &google_protobuf_EnumDescriptorProto_submsgs[0], + &google_protobuf_EnumDescriptorProto__fields[0], + UPB_SIZE(32, 56), 5, kUpb_ExtMode_NonExtendable, 5, UPB_FASTTABLE_MASK(56), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x001800003f000012, &upb_prm_1bt_max64b}, + {0x002000000201001a, &upb_psm_1bt_max64b}, + {0x002800003f020022, &upb_prm_1bt_max64b}, + {0x003000003f00002a, &upb_prs_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2] = { + {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init = { + NULL, + &google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[0], + 16, 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0004000001000008, &upb_psv4_1bt}, + {0x0008000002000010, &upb_psv4_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_EnumValueDescriptorProto_submsgs[1] = { + {.submsg = &google_protobuf_EnumValueOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumValueDescriptorProto__fields[3] = { + {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, 4, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 24), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_EnumValueDescriptorProto_msg_init = { + &google_protobuf_EnumValueDescriptorProto_submsgs[0], + &google_protobuf_EnumValueDescriptorProto__fields[0], + UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x0004000002000010, &upb_psv4_1bt}, + {0x001800000300001a, &upb_psm_1bt_max64b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_ServiceDescriptorProto_submsgs[2] = { + {.submsg = &google_protobuf_MethodDescriptorProto_msg_init}, + {.submsg = &google_protobuf_ServiceOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_ServiceDescriptorProto__fields[3] = { + {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_ServiceDescriptorProto_msg_init = { + &google_protobuf_ServiceDescriptorProto_submsgs[0], + &google_protobuf_ServiceDescriptorProto__fields[0], + UPB_SIZE(24, 40), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x001800003f000012, &upb_prm_1bt_max128b}, + {0x002000000201001a, &upb_psm_1bt_max64b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_MethodDescriptorProto_submsgs[1] = { + {.submsg = &google_protobuf_MethodOptions_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_MethodDescriptorProto__fields[6] = { + {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(20, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(28, 40), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(4, 56), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(8, 1), 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(9, 2), 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_MethodDescriptorProto_msg_init = { + &google_protobuf_MethodDescriptorProto_submsgs[0], + &google_protobuf_MethodDescriptorProto__fields[0], + UPB_SIZE(40, 64), 6, kUpb_ExtMode_NonExtendable, 6, UPB_FASTTABLE_MASK(56), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x0018000002000012, &upb_pss_1bt}, + {0x002800000300001a, &upb_pss_1bt}, + {0x0038000004000022, &upb_psm_1bt_max64b}, + {0x0001000005000028, &upb_psb1_1bt}, + {0x0002000006000030, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FileOptions_submsgs[3] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, + {.subenum = &google_protobuf_FileOptions_OptimizeMode_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FileOptions__fields[22] = { + {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {9, 4, 3, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {10, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {11, UPB_SIZE(44, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {16, 9, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {17, 10, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {18, 11, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {20, 12, 9, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {23, 13, 10, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {27, 14, 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {31, 15, 12, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {36, UPB_SIZE(52, 72), 13, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {37, UPB_SIZE(60, 88), 14, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {39, UPB_SIZE(68, 104), 15, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {40, UPB_SIZE(76, 120), 16, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {41, UPB_SIZE(84, 136), 17, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {42, 16, 18, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {44, UPB_SIZE(92, 152), 19, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {45, UPB_SIZE(100, 168), 20, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {50, UPB_SIZE(20, 184), 21, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FileOptions_msg_init = { + &google_protobuf_FileOptions_submsgs[0], + &google_protobuf_FileOptions__fields[0], + UPB_SIZE(112, 200), 22, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001800000100000a, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0028000002000042, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0008000004000050, &upb_psb1_1bt}, + {0x003800000500005a, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0009000006000180, &upb_psb1_2bt}, + {0x000a000007000188, &upb_psb1_2bt}, + {0x000b000008000190, &upb_psb1_2bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000c0000090001a0, &upb_psb1_2bt}, + {0x005800000e0002aa, &upb_pss_2bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000d00000a0001b8, &upb_psb1_2bt}, + {0x00780000100002c2, &upb_pss_2bt}, + {0x00880000110002ca, &upb_pss_2bt}, + {0x00100000120002d0, &upb_psb1_2bt}, + {0x000e00000b0001d8, &upb_psb1_2bt}, + {0x00980000130002e2, &upb_pss_2bt}, + {0x00a80000140002ea, &upb_pss_2bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000f00000c0001f8, &upb_psb1_2bt}, + }) +}; + +static const upb_MiniTableSub google_protobuf_MessageOptions_submsgs[2] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_MessageOptions__fields[7] = { + {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {2, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {3, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {7, 4, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {11, 5, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {12, 8, 6, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_MessageOptions_msg_init = { + &google_protobuf_MessageOptions_submsgs[0], + &google_protobuf_MessageOptions__fields[0], + UPB_SIZE(16, 24), 7, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0001000001000008, &upb_psb1_1bt}, + {0x0002000002000010, &upb_psb1_1bt}, + {0x0003000003000018, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0004000004000038, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0005000005000058, &upb_psb1_1bt}, + {0x0008000006000062, &upb_psm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FieldOptions_submsgs[7] = { + {.submsg = &google_protobuf_FieldOptions_EditionDefault_msg_init}, + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, + {.subenum = &google_protobuf_FieldOptions_CType_enum_init}, + {.subenum = &google_protobuf_FieldOptions_JSType_enum_init}, + {.subenum = &google_protobuf_FieldOptions_OptionRetention_enum_init}, + {.subenum = &google_protobuf_FieldOptions_OptionTargetType_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FieldOptions__fields[13] = { + {1, 4, 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 8, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {3, 9, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {5, 10, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, 12, 5, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {10, 16, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {15, 17, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {16, 18, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {17, 20, 9, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {21, UPB_SIZE(32, 40), 10, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FieldOptions_msg_init = { + &google_protobuf_FieldOptions_submsgs[0], + &google_protobuf_FieldOptions__fields[0], + UPB_SIZE(40, 56), 13, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0008000002000010, &upb_psb1_1bt}, + {0x0009000003000018, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000a000004000028, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0010000006000050, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0011000007000078, &upb_psb1_1bt}, + {0x0012000008000180, &upb_psb1_2bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x002000003f0001a2, &upb_prm_2bt_max64b}, + {0x002800000a0101aa, &upb_psm_2bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x003000003f023eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_FieldOptions_EditionDefault__fields[2] = { + {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(12, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FieldOptions_EditionDefault_msg_init = { + NULL, + &google_protobuf_FieldOptions_EditionDefault__fields[0], + UPB_SIZE(24, 40), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(24), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x0018000002000012, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_OneofOptions_submsgs[2] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_OneofOptions__fields[2] = { + {1, UPB_SIZE(4, 8), 1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_OneofOptions_msg_init = { + &google_protobuf_OneofOptions_submsgs[0], + &google_protobuf_OneofOptions__fields[0], + UPB_SIZE(16, 24), 2, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_psm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_EnumOptions_submsgs[2] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumOptions__fields[5] = { + {2, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {3, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {6, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(4, 8), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_EnumOptions_msg_init = { + &google_protobuf_EnumOptions_submsgs[0], + &google_protobuf_EnumOptions__fields[0], + UPB_SIZE(16, 24), 5, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0001000001000010, &upb_psb1_1bt}, + {0x0002000002000018, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0003000003000030, &upb_psb1_1bt}, + {0x000800000400003a, &upb_psm_1bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_EnumValueOptions_submsgs[2] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_EnumValueOptions__fields[4] = { + {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 2), 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_EnumValueOptions_msg_init = { + &google_protobuf_EnumValueOptions_submsgs[0], + &google_protobuf_EnumValueOptions__fields[0], + UPB_SIZE(16, 24), 4, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0001000001000008, &upb_psb1_1bt}, + {0x0008000002000012, &upb_psm_1bt_max64b}, + {0x0002000003000018, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_ServiceOptions_submsgs[2] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_ServiceOptions__fields[3] = { + {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {34, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_ServiceOptions_msg_init = { + &google_protobuf_ServiceOptions_submsgs[0], + &google_protobuf_ServiceOptions__fields[0], + UPB_SIZE(16, 24), 3, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0001000001000288, &upb_psb1_2bt}, + {0x0008000002000292, &upb_psm_2bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_MethodOptions_submsgs[3] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.submsg = &google_protobuf_UninterpretedOption_msg_init}, + {.subenum = &google_protobuf_MethodOptions_IdempotencyLevel_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_MethodOptions__fields[4] = { + {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, + {34, 4, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {35, 8, 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_MethodOptions_msg_init = { + &google_protobuf_MethodOptions_submsgs[0], + &google_protobuf_MethodOptions__fields[0], + UPB_SIZE(16, 24), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0001000001000288, &upb_psb1_2bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000300029a, &upb_psm_2bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f013eba, &upb_prm_2bt_max128b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_UninterpretedOption_submsgs[1] = { + {.submsg = &google_protobuf_UninterpretedOption_NamePart_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_UninterpretedOption__fields[7] = { + {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 16), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(16, 32), 2, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(24, 40), 3, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(32, 48), 4, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}, + {7, UPB_SIZE(40, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {8, UPB_SIZE(48, 72), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_UninterpretedOption_msg_init = { + &google_protobuf_UninterpretedOption_submsgs[0], + &google_protobuf_UninterpretedOption__fields[0], + UPB_SIZE(56, 88), 7, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(120), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800003f000012, &upb_prm_1bt_max64b}, + {0x001000000100001a, &upb_pss_1bt}, + {0x0020000002000020, &upb_psv8_1bt}, + {0x0028000003000028, &upb_psv8_1bt}, + {0x0030000004000031, &upb_psf8_1bt}, + {0x003800000500003a, &upb_psb_1bt}, + {0x0048000006000042, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableField google_protobuf_UninterpretedOption_NamePart__fields[2] = { + {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {2, 1, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_UninterpretedOption_NamePart_msg_init = { + NULL, + &google_protobuf_UninterpretedOption_NamePart__fields[0], + UPB_SIZE(16, 24), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(24), 2, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800000100000a, &upb_pss_1bt}, + {0x0001000002000010, &upb_psb1_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_FeatureSet_submsgs[7] = { + {.submsg = &google_protobuf_FeatureSet_msg_init}, + {.subenum = &google_protobuf_FeatureSet_FieldPresence_enum_init}, + {.subenum = &google_protobuf_FeatureSet_EnumType_enum_init}, + {.subenum = &google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init}, + {.subenum = &google_protobuf_FeatureSet_StringFieldValidation_enum_init}, + {.subenum = &google_protobuf_FeatureSet_MessageEncoding_enum_init}, + {.subenum = &google_protobuf_FeatureSet_JsonFormat_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_FeatureSet__fields[7] = { + {1, 4, 1, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {2, 8, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {3, 12, 3, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, 16, 4, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, 20, 5, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {6, 24, 6, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {999, UPB_SIZE(28, 32), 7, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_FeatureSet_msg_init = { + &google_protobuf_FeatureSet_submsgs[0], + &google_protobuf_FeatureSet__fields[0], + UPB_SIZE(32, 40), 7, kUpb_ExtMode_Extendable, 6, UPB_FASTTABLE_MASK(248), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0020000007003eba, &upb_psm_2bt_max64b}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_SourceCodeInfo_submsgs[1] = { + {.submsg = &google_protobuf_SourceCodeInfo_Location_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_SourceCodeInfo__fields[1] = { + {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_SourceCodeInfo_msg_init = { + &google_protobuf_SourceCodeInfo_submsgs[0], + &google_protobuf_SourceCodeInfo__fields[0], + 8, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000000003f00000a, &upb_prm_1bt_max128b}, + }) +}; + +static const upb_MiniTableField google_protobuf_SourceCodeInfo_Location__fields[5] = { + {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(16, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(24, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_SourceCodeInfo_Location_msg_init = { + NULL, + &google_protobuf_SourceCodeInfo_Location__fields[0], + UPB_SIZE(32, 64), 5, kUpb_ExtMode_NonExtendable, 4, UPB_FASTTABLE_MASK(56), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000800003f00000a, &upb_ppv4_1bt}, + {0x001000003f000012, &upb_ppv4_1bt}, + {0x001800000100001a, &upb_pss_1bt}, + {0x0028000002000022, &upb_pss_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x003800003f000032, &upb_prs_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTableSub google_protobuf_GeneratedCodeInfo_submsgs[1] = { + {.submsg = &google_protobuf_GeneratedCodeInfo_Annotation_msg_init}, +}; + +static const upb_MiniTableField google_protobuf_GeneratedCodeInfo__fields[1] = { + {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_GeneratedCodeInfo_msg_init = { + &google_protobuf_GeneratedCodeInfo_submsgs[0], + &google_protobuf_GeneratedCodeInfo__fields[0], + 8, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x000000003f00000a, &upb_prm_1bt_max64b}, + }) +}; + +static const upb_MiniTableSub google_protobuf_GeneratedCodeInfo_Annotation_submsgs[1] = { + {.subenum = &google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init}, +}; + +static const upb_MiniTableField google_protobuf_GeneratedCodeInfo_Annotation__fields[5] = { + {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}, + {2, UPB_SIZE(20, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, + {3, UPB_SIZE(8, 4), 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {4, UPB_SIZE(12, 8), 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, + {5, UPB_SIZE(16, 12), 4, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, +}; + +const upb_MiniTable google_protobuf_GeneratedCodeInfo_Annotation_msg_init = { + &google_protobuf_GeneratedCodeInfo_Annotation_submsgs[0], + &google_protobuf_GeneratedCodeInfo_Annotation__fields[0], + UPB_SIZE(32, 40), 5, kUpb_ExtMode_NonExtendable, 5, UPB_FASTTABLE_MASK(56), 0, + UPB_FASTTABLE_INIT({ + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x001000003f00000a, &upb_ppv4_1bt}, + {0x0018000001000012, &upb_pss_1bt}, + {0x0004000002000018, &upb_psv4_1bt}, + {0x0008000003000020, &upb_psv4_1bt}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + {0x0000000000000000, &_upb_FastDecoder_DecodeGeneric}, + }) +}; + +static const upb_MiniTable *messages_layout[30] = { + &google_protobuf_FileDescriptorSet_msg_init, + &google_protobuf_FileDescriptorProto_msg_init, + &google_protobuf_DescriptorProto_msg_init, + &google_protobuf_DescriptorProto_ExtensionRange_msg_init, + &google_protobuf_DescriptorProto_ReservedRange_msg_init, + &google_protobuf_ExtensionRangeOptions_msg_init, + &google_protobuf_ExtensionRangeOptions_Declaration_msg_init, + &google_protobuf_FieldDescriptorProto_msg_init, + &google_protobuf_OneofDescriptorProto_msg_init, + &google_protobuf_EnumDescriptorProto_msg_init, + &google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init, + &google_protobuf_EnumValueDescriptorProto_msg_init, + &google_protobuf_ServiceDescriptorProto_msg_init, + &google_protobuf_MethodDescriptorProto_msg_init, + &google_protobuf_FileOptions_msg_init, + &google_protobuf_MessageOptions_msg_init, + &google_protobuf_FieldOptions_msg_init, + &google_protobuf_FieldOptions_EditionDefault_msg_init, + &google_protobuf_OneofOptions_msg_init, + &google_protobuf_EnumOptions_msg_init, + &google_protobuf_EnumValueOptions_msg_init, + &google_protobuf_ServiceOptions_msg_init, + &google_protobuf_MethodOptions_msg_init, + &google_protobuf_UninterpretedOption_msg_init, + &google_protobuf_UninterpretedOption_NamePart_msg_init, + &google_protobuf_FeatureSet_msg_init, + &google_protobuf_SourceCodeInfo_msg_init, + &google_protobuf_SourceCodeInfo_Location_msg_init, + &google_protobuf_GeneratedCodeInfo_msg_init, + &google_protobuf_GeneratedCodeInfo_Annotation_msg_init, +}; + +const upb_MiniTableEnum google_protobuf_ExtensionRangeOptions_VerificationState_enum_init = { + 64, + 0, + { + 0x3, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_EnumType_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_FieldPresence_enum_init = { + 64, + 0, + { + 0xf, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_JsonFormat_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_MessageEncoding_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FeatureSet_StringFieldValidation_enum_init = { + 64, + 0, + { + 0xf, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Label_enum_init = { + 64, + 0, + { + 0xe, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Type_enum_init = { + 64, + 0, + { + 0x7fffe, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_CType_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_JSType_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_OptionRetention_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FieldOptions_OptionTargetType_enum_init = { + 64, + 0, + { + 0x3ff, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_FileOptions_OptimizeMode_enum_init = { + 64, + 0, + { + 0xe, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init = { + 64, + 0, + { + 0x7, + 0x0, + }, +}; + +static const upb_MiniTableEnum *enums_layout[16] = { + &google_protobuf_ExtensionRangeOptions_VerificationState_enum_init, + &google_protobuf_FeatureSet_EnumType_enum_init, + &google_protobuf_FeatureSet_FieldPresence_enum_init, + &google_protobuf_FeatureSet_JsonFormat_enum_init, + &google_protobuf_FeatureSet_MessageEncoding_enum_init, + &google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init, + &google_protobuf_FeatureSet_StringFieldValidation_enum_init, + &google_protobuf_FieldDescriptorProto_Label_enum_init, + &google_protobuf_FieldDescriptorProto_Type_enum_init, + &google_protobuf_FieldOptions_CType_enum_init, + &google_protobuf_FieldOptions_JSType_enum_init, + &google_protobuf_FieldOptions_OptionRetention_enum_init, + &google_protobuf_FieldOptions_OptionTargetType_enum_init, + &google_protobuf_FileOptions_OptimizeMode_enum_init, + &google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init, + &google_protobuf_MethodOptions_IdempotencyLevel_enum_init, +}; + +const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout = { + messages_layout, + enums_layout, + NULL, + 30, + 16, + 0, +}; + +#include "upb/port/undef.inc" + diff --git a/archive/cmake/google/protobuf/descriptor.upb.h b/archive/cmake/google/protobuf/descriptor.upb.h new file mode 100644 index 0000000000..80cf72e001 --- /dev/null +++ b/archive/cmake/google/protobuf/descriptor.upb.h @@ -0,0 +1,6236 @@ +/* This file was generated by upbc (the upb compiler) from the input + * file: + * + * google/protobuf/descriptor.proto + * + * Do not edit -- your changes will be discarded when the file is + * regenerated. */ + +#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ +#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ + +#include "upb/generated_code_support.h" +// Must be last. +#include "upb/port/def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet; +typedef struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto; +typedef struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto; +typedef struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange; +typedef struct google_protobuf_DescriptorProto_ReservedRange google_protobuf_DescriptorProto_ReservedRange; +typedef struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions; +typedef struct google_protobuf_ExtensionRangeOptions_Declaration google_protobuf_ExtensionRangeOptions_Declaration; +typedef struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto; +typedef struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto; +typedef struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto; +typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange google_protobuf_EnumDescriptorProto_EnumReservedRange; +typedef struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto; +typedef struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto; +typedef struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto; +typedef struct google_protobuf_FileOptions google_protobuf_FileOptions; +typedef struct google_protobuf_MessageOptions google_protobuf_MessageOptions; +typedef struct google_protobuf_FieldOptions google_protobuf_FieldOptions; +typedef struct google_protobuf_FieldOptions_EditionDefault google_protobuf_FieldOptions_EditionDefault; +typedef struct google_protobuf_OneofOptions google_protobuf_OneofOptions; +typedef struct google_protobuf_EnumOptions google_protobuf_EnumOptions; +typedef struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions; +typedef struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions; +typedef struct google_protobuf_MethodOptions google_protobuf_MethodOptions; +typedef struct google_protobuf_UninterpretedOption google_protobuf_UninterpretedOption; +typedef struct google_protobuf_UninterpretedOption_NamePart google_protobuf_UninterpretedOption_NamePart; +typedef struct google_protobuf_FeatureSet google_protobuf_FeatureSet; +typedef struct google_protobuf_SourceCodeInfo google_protobuf_SourceCodeInfo; +typedef struct google_protobuf_SourceCodeInfo_Location google_protobuf_SourceCodeInfo_Location; +typedef struct google_protobuf_GeneratedCodeInfo google_protobuf_GeneratedCodeInfo; +typedef struct google_protobuf_GeneratedCodeInfo_Annotation google_protobuf_GeneratedCodeInfo_Annotation; +extern const upb_MiniTable google_protobuf_FileDescriptorSet_msg_init; +extern const upb_MiniTable google_protobuf_FileDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_DescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_DescriptorProto_ExtensionRange_msg_init; +extern const upb_MiniTable google_protobuf_DescriptorProto_ReservedRange_msg_init; +extern const upb_MiniTable google_protobuf_ExtensionRangeOptions_msg_init; +extern const upb_MiniTable google_protobuf_ExtensionRangeOptions_Declaration_msg_init; +extern const upb_MiniTable google_protobuf_FieldDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_OneofDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_EnumDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_EnumDescriptorProto_EnumReservedRange_msg_init; +extern const upb_MiniTable google_protobuf_EnumValueDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_ServiceDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_MethodDescriptorProto_msg_init; +extern const upb_MiniTable google_protobuf_FileOptions_msg_init; +extern const upb_MiniTable google_protobuf_MessageOptions_msg_init; +extern const upb_MiniTable google_protobuf_FieldOptions_msg_init; +extern const upb_MiniTable google_protobuf_FieldOptions_EditionDefault_msg_init; +extern const upb_MiniTable google_protobuf_OneofOptions_msg_init; +extern const upb_MiniTable google_protobuf_EnumOptions_msg_init; +extern const upb_MiniTable google_protobuf_EnumValueOptions_msg_init; +extern const upb_MiniTable google_protobuf_ServiceOptions_msg_init; +extern const upb_MiniTable google_protobuf_MethodOptions_msg_init; +extern const upb_MiniTable google_protobuf_UninterpretedOption_msg_init; +extern const upb_MiniTable google_protobuf_UninterpretedOption_NamePart_msg_init; +extern const upb_MiniTable google_protobuf_FeatureSet_msg_init; +extern const upb_MiniTable google_protobuf_SourceCodeInfo_msg_init; +extern const upb_MiniTable google_protobuf_SourceCodeInfo_Location_msg_init; +extern const upb_MiniTable google_protobuf_GeneratedCodeInfo_msg_init; +extern const upb_MiniTable google_protobuf_GeneratedCodeInfo_Annotation_msg_init; + +typedef enum { + google_protobuf_ExtensionRangeOptions_DECLARATION = 0, + google_protobuf_ExtensionRangeOptions_UNVERIFIED = 1 +} google_protobuf_ExtensionRangeOptions_VerificationState; + +typedef enum { + google_protobuf_FeatureSet_ENUM_TYPE_UNKNOWN = 0, + google_protobuf_FeatureSet_OPEN = 1, + google_protobuf_FeatureSet_CLOSED = 2 +} google_protobuf_FeatureSet_EnumType; + +typedef enum { + google_protobuf_FeatureSet_FIELD_PRESENCE_UNKNOWN = 0, + google_protobuf_FeatureSet_EXPLICIT = 1, + google_protobuf_FeatureSet_IMPLICIT = 2, + google_protobuf_FeatureSet_LEGACY_REQUIRED = 3 +} google_protobuf_FeatureSet_FieldPresence; + +typedef enum { + google_protobuf_FeatureSet_JSON_FORMAT_UNKNOWN = 0, + google_protobuf_FeatureSet_ALLOW = 1, + google_protobuf_FeatureSet_LEGACY_BEST_EFFORT = 2 +} google_protobuf_FeatureSet_JsonFormat; + +typedef enum { + google_protobuf_FeatureSet_MESSAGE_ENCODING_UNKNOWN = 0, + google_protobuf_FeatureSet_LENGTH_PREFIXED = 1, + google_protobuf_FeatureSet_DELIMITED = 2 +} google_protobuf_FeatureSet_MessageEncoding; + +typedef enum { + google_protobuf_FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN = 0, + google_protobuf_FeatureSet_PACKED = 1, + google_protobuf_FeatureSet_EXPANDED = 2 +} google_protobuf_FeatureSet_RepeatedFieldEncoding; + +typedef enum { + google_protobuf_FeatureSet_STRING_FIELD_VALIDATION_UNKNOWN = 0, + google_protobuf_FeatureSet_MANDATORY = 1, + google_protobuf_FeatureSet_HINT = 2, + google_protobuf_FeatureSet_NONE = 3 +} google_protobuf_FeatureSet_StringFieldValidation; + +typedef enum { + google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, + google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, + google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3 +} google_protobuf_FieldDescriptorProto_Label; + +typedef enum { + google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1, + google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2, + google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3, + google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4, + google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5, + google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6, + google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7, + google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8, + google_protobuf_FieldDescriptorProto_TYPE_STRING = 9, + google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10, + google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11, + google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12, + google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13, + google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14, + google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15, + google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16, + google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17, + google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18 +} google_protobuf_FieldDescriptorProto_Type; + +typedef enum { + google_protobuf_FieldOptions_STRING = 0, + google_protobuf_FieldOptions_CORD = 1, + google_protobuf_FieldOptions_STRING_PIECE = 2 +} google_protobuf_FieldOptions_CType; + +typedef enum { + google_protobuf_FieldOptions_JS_NORMAL = 0, + google_protobuf_FieldOptions_JS_STRING = 1, + google_protobuf_FieldOptions_JS_NUMBER = 2 +} google_protobuf_FieldOptions_JSType; + +typedef enum { + google_protobuf_FieldOptions_RETENTION_UNKNOWN = 0, + google_protobuf_FieldOptions_RETENTION_RUNTIME = 1, + google_protobuf_FieldOptions_RETENTION_SOURCE = 2 +} google_protobuf_FieldOptions_OptionRetention; + +typedef enum { + google_protobuf_FieldOptions_TARGET_TYPE_UNKNOWN = 0, + google_protobuf_FieldOptions_TARGET_TYPE_FILE = 1, + google_protobuf_FieldOptions_TARGET_TYPE_EXTENSION_RANGE = 2, + google_protobuf_FieldOptions_TARGET_TYPE_MESSAGE = 3, + google_protobuf_FieldOptions_TARGET_TYPE_FIELD = 4, + google_protobuf_FieldOptions_TARGET_TYPE_ONEOF = 5, + google_protobuf_FieldOptions_TARGET_TYPE_ENUM = 6, + google_protobuf_FieldOptions_TARGET_TYPE_ENUM_ENTRY = 7, + google_protobuf_FieldOptions_TARGET_TYPE_SERVICE = 8, + google_protobuf_FieldOptions_TARGET_TYPE_METHOD = 9 +} google_protobuf_FieldOptions_OptionTargetType; + +typedef enum { + google_protobuf_FileOptions_SPEED = 1, + google_protobuf_FileOptions_CODE_SIZE = 2, + google_protobuf_FileOptions_LITE_RUNTIME = 3 +} google_protobuf_FileOptions_OptimizeMode; + +typedef enum { + google_protobuf_GeneratedCodeInfo_Annotation_NONE = 0, + google_protobuf_GeneratedCodeInfo_Annotation_SET = 1, + google_protobuf_GeneratedCodeInfo_Annotation_ALIAS = 2 +} google_protobuf_GeneratedCodeInfo_Annotation_Semantic; + +typedef enum { + google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0, + google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1, + google_protobuf_MethodOptions_IDEMPOTENT = 2 +} google_protobuf_MethodOptions_IdempotencyLevel; + + +extern const upb_MiniTableEnum google_protobuf_ExtensionRangeOptions_VerificationState_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_EnumType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_FieldPresence_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_JsonFormat_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_MessageEncoding_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init; +extern const upb_MiniTableEnum google_protobuf_FeatureSet_StringFieldValidation_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Label_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldDescriptorProto_Type_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_CType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_JSType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_OptionRetention_enum_init; +extern const upb_MiniTableEnum google_protobuf_FieldOptions_OptionTargetType_enum_init; +extern const upb_MiniTableEnum google_protobuf_FileOptions_OptimizeMode_enum_init; +extern const upb_MiniTableEnum google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init; +extern const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init; + +/* google.protobuf.FileDescriptorSet */ + +UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_new(upb_Arena* arena) { + return (google_protobuf_FileDescriptorSet*)_upb_Message_New(&google_protobuf_FileDescriptorSet_msg_init, arena); +} +UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FileDescriptorSet* google_protobuf_FileDescriptorSet_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FileDescriptorSet* ret = google_protobuf_FileDescriptorSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msg_init, extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_FileDescriptorSet_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FileDescriptorSet_serialize_ex(const google_protobuf_FileDescriptorSet* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_FileDescriptorSet_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FileDescriptorSet_clear_file(google_protobuf_FileDescriptorSet* msg) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet* msg, size_t* size) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_FileDescriptorProto* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorSet_file_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorSet_file_mutable_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FileDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_package(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(48, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(48, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(48, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_message_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_message_type_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_enum_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_enum_type_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_service_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_service_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_extension_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_extension_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {8, UPB_SIZE(24, 80), 3, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(24, 80), 3, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(24, 80), 3, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_source_code_info(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(28, 88), 4, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(28, 88), 4, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(28, 88), 4, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_public_dependency(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {12, UPB_SIZE(56, 112), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {12, UPB_SIZE(56, 112), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {12, UPB_SIZE(56, 112), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileDescriptorProto_clear_edition(google_protobuf_FileDescriptorProto* msg) { + const upb_MiniTableField field = {13, UPB_SIZE(64, 128), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {13, UPB_SIZE(64, 128), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {13, UPB_SIZE(64, 128), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(48, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(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 = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {4, UPB_SIZE(8, 48), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {5, UPB_SIZE(12, 56), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_ServiceDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {6, UPB_SIZE(16, 64), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {7, UPB_SIZE(20, 72), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {8, UPB_SIZE(24, 80), 3, 4, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(28, 88), 4, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(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 = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(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 = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {12, UPB_SIZE(56, 112), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {13, UPB_SIZE(64, 128), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_field(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_field_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_field_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_nested_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_nested_type_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_enum_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_enum_type_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_extension_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_range_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_extension_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {7, UPB_SIZE(24, 64), 2, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(24, 64), 2, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(24, 64), 2, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_clear_oneof_decl(google_protobuf_DescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_oneof_decl_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_oneof_decl_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_reserved_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_range_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_DescriptorProto_reserved_name_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_name_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, UPB_SIZE(40, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {3, UPB_SIZE(8, 32), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto_ExtensionRange**)upb_Message_ResizeArrayUninitialized(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 = {5, UPB_SIZE(16, 48), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {6, UPB_SIZE(20, 56), 0, 4, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {7, UPB_SIZE(24, 64), 2, 5, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_OneofDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {8, UPB_SIZE(28, 72), 0, 6, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_DescriptorProto_ReservedRange**)upb_Message_ResizeArrayUninitialized(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 = {9, UPB_SIZE(32, 80), 0, 7, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(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 = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_end(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_clear_options(google_protobuf_DescriptorProto_ExtensionRange* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(12, 16), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(12, 16), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(12, 16), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(12, 16), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_clear_end(google_protobuf_DescriptorProto_ReservedRange* msg) { + const upb_MiniTableField field = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + 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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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_declaration(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_ExtensionRangeOptions_Declaration* const* google_protobuf_ExtensionRangeOptions_declaration(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_ExtensionRangeOptions_Declaration* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_mutable_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_declaration(const google_protobuf_ExtensionRangeOptions* msg) { + size_t size; + google_protobuf_ExtensionRangeOptions_declaration(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_verification(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 4), 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_ExtensionRangeOptions_verification(const google_protobuf_ExtensionRangeOptions* msg) { + int32_t default_val = 1; + int32_t ret; + const upb_MiniTableField field = {3, UPB_SIZE(8, 4), 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_verification(const google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 4), 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_features(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(12, 16), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_ExtensionRangeOptions_features(const google_protobuf_ExtensionRangeOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {50, UPB_SIZE(12, 16), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_features(const google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(12, 16), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_clear_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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_ExtensionRangeOptions_Declaration** google_protobuf_ExtensionRangeOptions_mutable_declaration(google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_ExtensionRangeOptions_Declaration**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration** google_protobuf_ExtensionRangeOptions_resize_declaration(google_protobuf_ExtensionRangeOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_ExtensionRangeOptions_Declaration**)upb_Message_ResizeArrayUninitialized(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_add_declaration(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_ExtensionRangeOptions_Declaration* sub = (struct google_protobuf_ExtensionRangeOptions_Declaration*)_upb_Message_New(&google_protobuf_ExtensionRangeOptions_Declaration_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_ExtensionRangeOptions_set_verification(google_protobuf_ExtensionRangeOptions *msg, int32_t value) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 4), 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_set_features(google_protobuf_ExtensionRangeOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {50, UPB_SIZE(12, 16), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_ExtensionRangeOptions_mutable_features(google_protobuf_ExtensionRangeOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_ExtensionRangeOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_ExtensionRangeOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(16, 24), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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.ExtensionRangeOptions.Declaration */ + +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_new(upb_Arena* arena) { + return (google_protobuf_ExtensionRangeOptions_Declaration*)_upb_Message_New(&google_protobuf_ExtensionRangeOptions_Declaration_msg_init, arena); +} +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions_Declaration* ret = google_protobuf_ExtensionRangeOptions_Declaration_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_Declaration_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_ExtensionRangeOptions_Declaration* google_protobuf_ExtensionRangeOptions_Declaration_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_ExtensionRangeOptions_Declaration* ret = google_protobuf_ExtensionRangeOptions_Declaration_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_Declaration_msg_init, extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_Declaration_serialize(const google_protobuf_ExtensionRangeOptions_Declaration* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_Declaration_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_ExtensionRangeOptions_Declaration_serialize_ex(const google_protobuf_ExtensionRangeOptions_Declaration* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_ExtensionRangeOptions_Declaration_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_number(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_ExtensionRangeOptions_Declaration_number(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + int32_t default_val = (int32_t)0; + int32_t ret; + const upb_MiniTableField field = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_number(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_full_name(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_ExtensionRangeOptions_Declaration_full_name(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_full_name(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_type(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(20, 32), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_ExtensionRangeOptions_Declaration_type(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {3, UPB_SIZE(20, 32), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_type(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(20, 32), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_reserved(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {5, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_reserved(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {5, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_reserved(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {5, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_clear_repeated(google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {6, 9, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_repeated(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {6, 9, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ExtensionRangeOptions_Declaration_has_repeated(const google_protobuf_ExtensionRangeOptions_Declaration* msg) { + const upb_MiniTableField field = {6, 9, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_number(google_protobuf_ExtensionRangeOptions_Declaration *msg, int32_t value) { + const upb_MiniTableField field = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_full_name(google_protobuf_ExtensionRangeOptions_Declaration *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 16), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_type(google_protobuf_ExtensionRangeOptions_Declaration *msg, upb_StringView value) { + const upb_MiniTableField field = {3, UPB_SIZE(20, 32), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_reserved(google_protobuf_ExtensionRangeOptions_Declaration *msg, bool value) { + const upb_MiniTableField field = {5, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_ExtensionRangeOptions_Declaration_set_repeated(google_protobuf_ExtensionRangeOptions_Declaration *msg, bool value) { + const upb_MiniTableField field = {6, 9, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* 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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_extendee(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_number(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {3, 4, 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 4, 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 4, 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_label(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {4, 8, 4, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {4, 8, 4, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {4, 8, 4, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {5, 12, 5, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {5, 12, 5, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {5, 12, 5, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_type_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(44, 56), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(44, 56), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(44, 56), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_default_value(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(52, 72), 7, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(52, 72), 7, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(52, 72), 7, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_options(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(16, 88), 8, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(16, 88), 8, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(16, 88), 8, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_oneof_index(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {9, UPB_SIZE(20, 16), 9, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(20, 16), 9, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(20, 16), 9, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_json_name(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {10, UPB_SIZE(60, 96), 10, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {10, UPB_SIZE(60, 96), 10, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {10, UPB_SIZE(60, 96), 10, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldDescriptorProto_clear_proto3_optional(google_protobuf_FieldDescriptorProto* msg) { + const upb_MiniTableField field = {17, UPB_SIZE(24, 20), 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {17, UPB_SIZE(24, 20), 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {17, UPB_SIZE(24, 20), 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, 4, 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {4, 8, 4, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {5, 12, 5, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(44, 56), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(52, 72), 7, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(16, 88), 8, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {9, UPB_SIZE(20, 16), 9, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {10, UPB_SIZE(60, 96), 10, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {17, UPB_SIZE(24, 20), 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 8, 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, 8, 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, 8, 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_OneofDescriptorProto_clear_options(google_protobuf_OneofDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 8, 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(20, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(20, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(20, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_value(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_EnumDescriptorProto_value_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_value_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_clear_reserved_range(google_protobuf_EnumDescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, UPB_SIZE(20, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumValueDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)upb_Message_ResizeArrayUninitialized(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 = {4, UPB_SIZE(12, 40), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(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 = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_clear_end(google_protobuf_EnumDescriptorProto_EnumReservedRange* msg) { + const upb_MiniTableField field = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + 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 = {1, 4, 1, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_number(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {2, 4, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 4, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 4, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueDescriptorProto_clear_options(google_protobuf_EnumValueDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 24), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 24), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 24), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, 4, 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 24), 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ServiceDescriptorProto_clear_method(google_protobuf_ServiceDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_ServiceDescriptorProto_method_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ServiceDescriptorProto_method_mutable_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_MethodDescriptorProto**)upb_Message_ResizeArrayUninitialized(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 = {2, UPB_SIZE(4, 24), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(8, 32), 2, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_input_type(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(20, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(20, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(20, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_output_type(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(28, 40), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(28, 40), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(28, 40), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_options(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(4, 56), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(4, 56), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(4, 56), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_client_streaming(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(8, 1), 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(8, 1), 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(8, 1), 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodDescriptorProto_clear_server_streaming(google_protobuf_MethodDescriptorProto* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(9, 2), 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(9, 2), 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(9, 2), 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(12, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(20, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(28, 40), 3, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(4, 56), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(8, 1), 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(9, 2), 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_outer_classname(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_optimize_for(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {9, 4, 3, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {9, 4, 3, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {9, 4, 3, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_multiple_files(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {10, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {10, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {10, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_go_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {11, UPB_SIZE(44, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {11, UPB_SIZE(44, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {11, UPB_SIZE(44, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_cc_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {16, 9, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {16, 9, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {16, 9, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_java_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {17, 10, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {17, 10, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {17, 10, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_py_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {18, 11, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {18, 11, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {18, 11, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {20, 12, 9, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {20, 12, 9, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {20, 12, 9, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_deprecated(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {23, 13, 10, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {23, 13, 10, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {23, 13, 10, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {27, 14, 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {27, 14, 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {27, 14, 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_cc_enable_arenas(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {31, 15, 12, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {31, 15, 12, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {31, 15, 12, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_objc_class_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {36, UPB_SIZE(52, 72), 13, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {36, UPB_SIZE(52, 72), 13, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {36, UPB_SIZE(52, 72), 13, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_csharp_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {37, UPB_SIZE(60, 88), 14, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {37, UPB_SIZE(60, 88), 14, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {37, UPB_SIZE(60, 88), 14, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_swift_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {39, UPB_SIZE(68, 104), 15, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {39, UPB_SIZE(68, 104), 15, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {39, UPB_SIZE(68, 104), 15, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_class_prefix(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {40, UPB_SIZE(76, 120), 16, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {40, UPB_SIZE(76, 120), 16, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {40, UPB_SIZE(76, 120), 16, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {41, UPB_SIZE(84, 136), 17, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {41, UPB_SIZE(84, 136), 17, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {41, UPB_SIZE(84, 136), 17, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_generic_services(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {42, 16, 18, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {42, 16, 18, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {42, 16, 18, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_php_metadata_namespace(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {44, UPB_SIZE(92, 152), 19, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {44, UPB_SIZE(92, 152), 19, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {44, UPB_SIZE(92, 152), 19, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_ruby_package(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {45, UPB_SIZE(100, 168), 20, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {45, UPB_SIZE(100, 168), 20, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {45, UPB_SIZE(100, 168), 20, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_features(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(20, 184), 21, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FileOptions_features(const google_protobuf_FileOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {50, UPB_SIZE(20, 184), 21, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FileOptions_has_features(const google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {50, UPB_SIZE(20, 184), 21, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FileOptions_clear_uninterpreted_option(google_protobuf_FileOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FileOptions_uninterpreted_option_upb_array(const google_protobuf_FileOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FileOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_FileOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, UPB_SIZE(28, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(36, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {9, 4, 3, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {10, 8, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {11, UPB_SIZE(44, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {16, 9, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {17, 10, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {18, 11, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {20, 12, 9, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) { + const upb_MiniTableField field = {23, 13, 10, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {27, 14, 11, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {31, 15, 12, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {36, UPB_SIZE(52, 72), 13, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {37, UPB_SIZE(60, 88), 14, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {39, UPB_SIZE(68, 104), 15, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {40, UPB_SIZE(76, 120), 16, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {41, UPB_SIZE(84, 136), 17, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {42, 16, 18, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {44, UPB_SIZE(92, 152), 19, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {45, UPB_SIZE(100, 168), 20, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FileOptions_set_features(google_protobuf_FileOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {50, UPB_SIZE(20, 184), 21, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FileOptions_mutable_features(google_protobuf_FileOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FileOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_FileOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(24, 192), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {2, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_deprecated(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {3, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_map_entry(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {7, 4, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {7, 4, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {7, 4, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {11, 5, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {11, 5, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {11, 5, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_features(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {12, 8, 6, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_MessageOptions_features(const google_protobuf_MessageOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {12, 8, 6, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MessageOptions_has_features(const google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {12, 8, 6, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MessageOptions_clear_uninterpreted_option(google_protobuf_MessageOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_upb_array(const google_protobuf_MessageOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_MessageOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) { + const upb_MiniTableField field = {3, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {7, 4, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {11, 5, 5, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MessageOptions_set_features(google_protobuf_MessageOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {12, 8, 6, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_MessageOptions_mutable_features(google_protobuf_MessageOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_MessageOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_MessageOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 4, 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 4, 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_packed(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {2, 8, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 8, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_deprecated(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {3, 9, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 9, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 9, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_lazy(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {5, 10, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {5, 10, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {5, 10, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_jstype(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {6, 12, 5, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {6, 12, 5, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {6, 12, 5, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_weak(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {10, 16, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {10, 16, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {10, 16, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_unverified_lazy(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {15, 17, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {15, 17, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {15, 17, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_debug_redact(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {16, 18, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {16, 18, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {16, 18, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_retention(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {17, 20, 9, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FieldOptions_retention(const google_protobuf_FieldOptions* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {17, 20, 9, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_retention(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {17, 20, 9, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_targets(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t const* google_protobuf_FieldOptions_targets(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FieldOptions_targets_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FieldOptions_targets_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_targets(const google_protobuf_FieldOptions* msg) { + size_t size; + google_protobuf_FieldOptions_targets(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FieldOptions_clear_edition_defaults(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FieldOptions_EditionDefault* const* google_protobuf_FieldOptions_edition_defaults(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (const google_protobuf_FieldOptions_EditionDefault* const*)_upb_array_constptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_edition_defaults_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FieldOptions_edition_defaults_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_edition_defaults(const google_protobuf_FieldOptions* msg) { + size_t size; + google_protobuf_FieldOptions_edition_defaults(msg, &size); + return size != 0; +} +UPB_INLINE void google_protobuf_FieldOptions_clear_features(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {21, UPB_SIZE(32, 40), 10, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FieldOptions_features(const google_protobuf_FieldOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {21, UPB_SIZE(32, 40), 10, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_has_features(const google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {21, UPB_SIZE(32, 40), 10, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_clear_uninterpreted_option(google_protobuf_FieldOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, 4, 1, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {2, 8, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {3, 9, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {5, 10, 4, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, 12, 5, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) { + const upb_MiniTableField field = {10, 16, 6, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {15, 17, 7, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {16, 18, 8, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_set_retention(google_protobuf_FieldOptions *msg, int32_t value) { + const upb_MiniTableField field = {17, 20, 9, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE int32_t* google_protobuf_FieldOptions_mutable_targets(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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_FieldOptions_resize_targets(google_protobuf_FieldOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(msg, &field, size, arena); +} +UPB_INLINE bool google_protobuf_FieldOptions_add_targets(google_protobuf_FieldOptions* msg, int32_t val, upb_Arena* arena) { + upb_MiniTableField field = {19, 24, 0, 6, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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_FieldOptions_EditionDefault** google_protobuf_FieldOptions_mutable_edition_defaults(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetMutableArray(msg, &field); + if (arr) { + if (size) *size = arr->size; + return (google_protobuf_FieldOptions_EditionDefault**)_upb_array_ptr(arr); + } else { + if (size) *size = 0; + return NULL; + } +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault** google_protobuf_FieldOptions_resize_edition_defaults(google_protobuf_FieldOptions* msg, size_t size, upb_Arena* arena) { + upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_FieldOptions_EditionDefault**)upb_Message_ResizeArrayUninitialized(msg, &field, size, arena); +} +UPB_INLINE struct google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_add_edition_defaults(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + upb_MiniTableField field = {20, UPB_SIZE(28, 32), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena); + if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) { + return NULL; + } + struct google_protobuf_FieldOptions_EditionDefault* sub = (struct google_protobuf_FieldOptions_EditionDefault*)_upb_Message_New(&google_protobuf_FieldOptions_EditionDefault_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_FieldOptions_set_features(google_protobuf_FieldOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {21, UPB_SIZE(32, 40), 10, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FieldOptions_mutable_features(google_protobuf_FieldOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FieldOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_FieldOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(36, 48), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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.EditionDefault */ + +UPB_INLINE google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_EditionDefault_new(upb_Arena* arena) { + return (google_protobuf_FieldOptions_EditionDefault*)_upb_Message_New(&google_protobuf_FieldOptions_EditionDefault_msg_init, arena); +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_EditionDefault_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FieldOptions_EditionDefault* ret = google_protobuf_FieldOptions_EditionDefault_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_FieldOptions_EditionDefault_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FieldOptions_EditionDefault* google_protobuf_FieldOptions_EditionDefault_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FieldOptions_EditionDefault* ret = google_protobuf_FieldOptions_EditionDefault_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_FieldOptions_EditionDefault_msg_init, extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FieldOptions_EditionDefault_serialize(const google_protobuf_FieldOptions_EditionDefault* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_FieldOptions_EditionDefault_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FieldOptions_EditionDefault_serialize_ex(const google_protobuf_FieldOptions_EditionDefault* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_FieldOptions_EditionDefault_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_edition(google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldOptions_EditionDefault_edition(const google_protobuf_FieldOptions_EditionDefault* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_edition(const google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_clear_value(google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE upb_StringView google_protobuf_FieldOptions_EditionDefault_value(const google_protobuf_FieldOptions_EditionDefault* msg) { + upb_StringView default_val = upb_StringView_FromString(""); + upb_StringView ret; + const upb_MiniTableField field = {2, UPB_SIZE(12, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FieldOptions_EditionDefault_has_value(const google_protobuf_FieldOptions_EditionDefault* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_edition(google_protobuf_FieldOptions_EditionDefault *msg, upb_StringView value) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FieldOptions_EditionDefault_set_value(google_protobuf_FieldOptions_EditionDefault *msg, upb_StringView value) { + const upb_MiniTableField field = {2, UPB_SIZE(12, 24), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* 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_features(google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_OneofOptions_features(const google_protobuf_OneofOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_OneofOptions_has_features(const google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_OneofOptions_clear_uninterpreted_option(google_protobuf_OneofOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_upb_array(const google_protobuf_OneofOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_OneofOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 void google_protobuf_OneofOptions_set_features(google_protobuf_OneofOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_OneofOptions_mutable_features(google_protobuf_OneofOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_OneofOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_OneofOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_deprecated(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {3, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {3, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {6, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_features(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(4, 8), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_EnumOptions_features(const google_protobuf_EnumOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {7, UPB_SIZE(4, 8), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumOptions_has_features(const google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(4, 8), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumOptions_clear_uninterpreted_option(google_protobuf_EnumOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_upb_array(const google_protobuf_EnumOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_EnumOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {2, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) { + const upb_MiniTableField field = {3, 2, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {6, 3, 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumOptions_set_features(google_protobuf_EnumOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {7, UPB_SIZE(4, 8), 4, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_EnumOptions_mutable_features(google_protobuf_EnumOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_EnumOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_EnumOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_features(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_EnumValueOptions_features(const google_protobuf_EnumValueOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_features(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_debug_redact(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 2), 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE bool google_protobuf_EnumValueOptions_debug_redact(const google_protobuf_EnumValueOptions* msg) { + bool default_val = false; + bool ret; + const upb_MiniTableField field = {3, UPB_SIZE(8, 2), 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_EnumValueOptions_has_debug_redact(const google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 2), 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_EnumValueOptions_clear_uninterpreted_option(google_protobuf_EnumValueOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_EnumValueOptions_set_features(google_protobuf_EnumValueOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_EnumValueOptions_mutable_features(google_protobuf_EnumValueOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_EnumValueOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_EnumValueOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE void google_protobuf_EnumValueOptions_set_debug_redact(google_protobuf_EnumValueOptions *msg, bool value) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 2), 3, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_features(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {34, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_ServiceOptions_features(const google_protobuf_ServiceOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {34, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_ServiceOptions_has_features(const google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {34, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_ServiceOptions_clear_uninterpreted_option(google_protobuf_ServiceOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_ServiceOptions_set_features(google_protobuf_ServiceOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {34, UPB_SIZE(4, 8), 2, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_ServiceOptions_mutable_features(google_protobuf_ServiceOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_ServiceOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_ServiceOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(8, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_idempotency_level(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {34, 4, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {34, 4, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {34, 4, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_features(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {35, 8, 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_MethodOptions_features(const google_protobuf_MethodOptions* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {35, 8, 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_MethodOptions_has_features(const google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {35, 8, 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_MethodOptions_clear_uninterpreted_option(google_protobuf_MethodOptions* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_upb_array(const google_protobuf_MethodOptions* msg, size_t* size) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_MethodOptions* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {33, 1, 1, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {34, 4, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_MethodOptions_set_features(google_protobuf_MethodOptions *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {35, 8, 3, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_MethodOptions_mutable_features(google_protobuf_MethodOptions* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_MethodOptions_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_MethodOptions_set_features(msg, sub); + } + return sub; +} +UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions* msg, size_t* size) { + upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption**)upb_Message_ResizeArrayUninitialized(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 = {999, UPB_SIZE(12, 16), 0, 1, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_UninterpretedOption_name_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_UninterpretedOption_name_mutable_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {3, UPB_SIZE(8, 16), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 16), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 16), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_positive_int_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(16, 32), 2, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(16, 32), 2, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(16, 32), 2, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_negative_int_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(24, 40), 3, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(24, 40), 3, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(24, 40), 3, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_double_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {6, UPB_SIZE(32, 48), 4, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(32, 48), 4, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(32, 48), 4, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_string_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {7, UPB_SIZE(40, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(40, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(40, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_UninterpretedOption_clear_aggregate_value(google_protobuf_UninterpretedOption* msg) { + const upb_MiniTableField field = {8, UPB_SIZE(48, 72), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(48, 72), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(48, 72), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_UninterpretedOption_NamePart**)upb_Message_ResizeArrayUninitialized(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 = {2, UPB_SIZE(4, 8), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(8, 16), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(16, 32), 2, kUpb_NoSub, 4, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(24, 40), 3, kUpb_NoSub, 3, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(32, 48), 4, kUpb_NoSub, 1, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_8Byte << kUpb_FieldRep_Shift)}; + _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 = {7, UPB_SIZE(40, 56), 5, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {8, UPB_SIZE(48, 72), 6, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + 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 = {2, 1, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 1, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _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 = {2, 1, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(4, 8), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, 1, 2, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} + +/* google.protobuf.FeatureSet */ + +UPB_INLINE google_protobuf_FeatureSet* google_protobuf_FeatureSet_new(upb_Arena* arena) { + return (google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); +} +UPB_INLINE google_protobuf_FeatureSet* google_protobuf_FeatureSet_parse(const char* buf, size_t size, upb_Arena* arena) { + google_protobuf_FeatureSet* ret = google_protobuf_FeatureSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_FeatureSet_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE google_protobuf_FeatureSet* google_protobuf_FeatureSet_parse_ex(const char* buf, size_t size, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena) { + google_protobuf_FeatureSet* ret = google_protobuf_FeatureSet_new(arena); + if (!ret) return NULL; + if (upb_Decode(buf, size, ret, &google_protobuf_FeatureSet_msg_init, extreg, options, arena) != + kUpb_DecodeStatus_Ok) { + return NULL; + } + return ret; +} +UPB_INLINE char* google_protobuf_FeatureSet_serialize(const google_protobuf_FeatureSet* msg, upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_FeatureSet_msg_init, 0, arena, &ptr, len); + return ptr; +} +UPB_INLINE char* google_protobuf_FeatureSet_serialize_ex(const google_protobuf_FeatureSet* msg, int options, + upb_Arena* arena, size_t* len) { + char* ptr; + (void)upb_Encode(msg, &google_protobuf_FeatureSet_msg_init, options, arena, &ptr, len); + return ptr; +} +UPB_INLINE void google_protobuf_FeatureSet_clear_field_presence(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {1, 4, 1, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_field_presence(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {1, 4, 1, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_field_presence(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {1, 4, 1, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_enum_type(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {2, 8, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_enum_type(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {2, 8, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_enum_type(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {2, 8, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_repeated_field_encoding(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {3, 12, 3, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_repeated_field_encoding(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {3, 12, 3, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_repeated_field_encoding(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {3, 12, 3, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_string_field_validation(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {4, 16, 4, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_string_field_validation(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {4, 16, 4, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_string_field_validation(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {4, 16, 4, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_message_encoding(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {5, 20, 5, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_message_encoding(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {5, 20, 5, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_message_encoding(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {5, 20, 5, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_json_format(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {6, 24, 6, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE int32_t google_protobuf_FeatureSet_json_format(const google_protobuf_FeatureSet* msg) { + int32_t default_val = 0; + int32_t ret; + const upb_MiniTableField field = {6, 24, 6, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_json_format(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {6, 24, 6, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_FeatureSet_clear_raw_features(google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 32), 7, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_ClearNonExtensionField(msg, &field); +} +UPB_INLINE const google_protobuf_FeatureSet* google_protobuf_FeatureSet_raw_features(const google_protobuf_FeatureSet* msg) { + const google_protobuf_FeatureSet* default_val = NULL; + const google_protobuf_FeatureSet* ret; + const upb_MiniTableField field = {999, UPB_SIZE(28, 32), 7, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); + return ret; +} +UPB_INLINE bool google_protobuf_FeatureSet_has_raw_features(const google_protobuf_FeatureSet* msg) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 32), 7, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} + +UPB_INLINE void google_protobuf_FeatureSet_set_field_presence(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {1, 4, 1, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_enum_type(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {2, 8, 2, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_repeated_field_encoding(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {3, 12, 3, 3, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_string_field_validation(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {4, 16, 4, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_message_encoding(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {5, 20, 5, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_json_format(google_protobuf_FeatureSet *msg, int32_t value) { + const upb_MiniTableField field = {6, 24, 6, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE void google_protobuf_FeatureSet_set_raw_features(google_protobuf_FeatureSet *msg, google_protobuf_FeatureSet* value) { + const upb_MiniTableField field = {999, UPB_SIZE(28, 32), 7, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _upb_Message_SetNonExtensionField(msg, &field, &value); +} +UPB_INLINE struct google_protobuf_FeatureSet* google_protobuf_FeatureSet_mutable_raw_features(google_protobuf_FeatureSet* msg, upb_Arena* arena) { + struct google_protobuf_FeatureSet* sub = (struct google_protobuf_FeatureSet*)google_protobuf_FeatureSet_raw_features(msg); + if (sub == NULL) { + sub = (struct google_protobuf_FeatureSet*)_upb_Message_New(&google_protobuf_FeatureSet_msg_init, arena); + if (sub) google_protobuf_FeatureSet_set_raw_features(msg, sub); + } + return sub; +} + +/* 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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_SourceCodeInfo_location_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_location_mutable_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_SourceCodeInfo_Location**)upb_Message_ResizeArrayUninitialized(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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_SourceCodeInfo_Location_path_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_path_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_SourceCodeInfo_Location_span_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_span_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {3, UPB_SIZE(16, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(16, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(16, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + 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 = {4, UPB_SIZE(24, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(24, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(24, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + 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 = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) { + const upb_MiniTableField field = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(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 = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(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 = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {3, UPB_SIZE(16, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(24, 40), 2, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (upb_StringView*)upb_Message_ResizeArrayUninitialized(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 = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsAlternate | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_mutable_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (google_protobuf_GeneratedCodeInfo_Annotation**)upb_Message_ResizeArrayUninitialized(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 = {1, 0, 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + _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 = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 const upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + const upb_Array* arr = upb_Message_GetArray(msg, &field); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_mutable_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size, upb_Arena* arena) { + const upb_MiniTableField field = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + upb_Array* arr = upb_Message_GetOrCreateMutableArray( + (upb_Message*)msg, &field, arena); + if (size) { + *size = arr ? arr->size : 0; + } + return arr; +} +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 = {2, UPB_SIZE(20, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(20, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {2, UPB_SIZE(20, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_begin(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {3, UPB_SIZE(8, 4), 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 4), 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 4), 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_end(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {4, UPB_SIZE(12, 8), 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(12, 8), 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(12, 8), 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + return _upb_Message_HasNonExtensionField(msg, &field); +} +UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_clear_semantic(google_protobuf_GeneratedCodeInfo_Annotation* msg) { + const upb_MiniTableField field = {5, UPB_SIZE(16, 12), 4, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(16, 12), 4, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(16, 12), 4, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + return (int32_t*)upb_Message_ResizeArrayUninitialized(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 = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; + 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 = {2, UPB_SIZE(20, 24), 1, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; + _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 = {3, UPB_SIZE(8, 4), 2, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {4, UPB_SIZE(12, 8), 3, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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 = {5, UPB_SIZE(16, 12), 4, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; + _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(112, 200) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port/undef.inc" + +#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */ diff --git a/cmake/make_cmakelists.py b/archive/cmake/make_cmakelists.py similarity index 52% rename from cmake/make_cmakelists.py rename to archive/cmake/make_cmakelists.py index 035debb730..b38dccab29 100755 --- a/cmake/make_cmakelists.py +++ b/archive/cmake/make_cmakelists.py @@ -1,8 +1,39 @@ -#!/usr/bin/env python - -"""TODO(haberman): DO NOT SUBMIT without one-line documentation for make_cmakelists. - -TODO(haberman): DO NOT SUBMIT without a detailed description of make_cmakelists. +#!/usr/bin/python +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""A tool to convert {WORKSPACE, BUILD} -> CMakeLists.txt. + +This tool is very upb-specific at the moment, and should not be seen as a +generic Bazel -> CMake converter. """ from __future__ import absolute_import @@ -13,12 +44,25 @@ import textwrap import os -def StripColons(deps): - return map(lambda x: x[1:], deps) +def StripFirstChar(deps): + return [dep[1:] for dep in deps] def IsSourceFile(name): return name.endswith(".c") or name.endswith(".cc") + +ADD_LIBRARY_FORMAT = """ +add_library(%(name)s %(type)s + %(sources)s +) +target_include_directories(%(name)s %(keyword)s + $ + $ + $ +) +""" + + class BuildFileFunctions(object): def __init__(self, converter): self.converter = converter @@ -29,12 +73,12 @@ def _add_deps(self, kwargs, keyword=""): self.converter.toplevel += "target_link_libraries(%s%s\n %s)\n" % ( kwargs["name"], keyword, - "\n ".join(StripColons(kwargs["deps"])) + "\n ".join(StripFirstChar(kwargs["deps"])) ) def load(self, *args): pass - + def cc_library(self, **kwargs): if kwargs["name"].endswith("amalgamation"): return @@ -42,30 +86,38 @@ def cc_library(self, **kwargs): return if kwargs["name"] == "lupb": return + if "testonly" in kwargs: + return files = kwargs.get("srcs", []) + kwargs.get("hdrs", []) found_files = [] + pregenerated_files = [ + "CMakeLists.txt", "descriptor.upb.h", "descriptor.upb.c" + ] for file in files: - if os.path.isfile(file): - found_files.append("../" + file) - elif os.path.isfile("cmake/" + file): - found_files.append("../cmake/" + file) - else: - print("Warning: no such file: " + file) + if os.path.basename(file) in pregenerated_files: + found_files.append("../cmake/" + file) + else: + found_files.append("../" + file) if list(filter(IsSourceFile, files)): # Has sources, make this a normal library. - self.converter.toplevel += "add_library(%s\n %s)\n" % ( - kwargs["name"], - "\n ".join(found_files) - ) + self.converter.toplevel += ADD_LIBRARY_FORMAT % { + "name": kwargs["name"], + "type": "", + "keyword": "PUBLIC", + "sources": "\n ".join(found_files), + } self._add_deps(kwargs) else: # Header-only library, have to do a couple things differently. # For some info, see: # http://mariobadr.com/creating-a-header-only-library-with-cmake.html - self.converter.toplevel += "add_library(%s INTERFACE)\n" % ( - kwargs["name"] - ) + self.converter.toplevel += ADD_LIBRARY_FORMAT % { + "name": kwargs["name"], + "type": "INTERFACE", + "keyword": "INTERFACE", + "sources": "", + } self._add_deps(kwargs, " INTERFACE") def cc_binary(self, **kwargs): @@ -96,6 +148,12 @@ def cc_test(self, **kwargs): # self._add_deps(kwargs) pass + def cc_fuzz_test(self, **kwargs): + pass + + def pkg_files(self, **kwargs): + pass + def py_library(self, **kwargs): pass @@ -120,7 +178,7 @@ def proto_library(self, **kwargs): def cc_proto_library(self, **kwargs): pass - def generated_file_staleness_test(self, **kwargs): + def staleness_test(self, **kwargs): pass def upb_amalgamation(self, **kwargs): @@ -150,7 +208,7 @@ def upb_fasttable_enabled(self, **kwargs): def select(self, arg_dict): return [] - def glob(self, *args): + def glob(self, *args, **kwargs): return [] def licenses(self, *args): @@ -162,18 +220,38 @@ def filegroup(self, **kwargs): def map_dep(self, arg): return arg + def package_group(self, **kwargs): + pass + + def bool_flag(self, **kwargs): + pass + + def bootstrap_upb_proto_library(self, **kwargs): + pass + + def bootstrap_cc_library(self, **kwargs): + pass + + def alias(self, **kwargs): + pass + class WorkspaceFileFunctions(object): def __init__(self, converter): self.converter = converter - def load(self, *args): + def load(self, *args, **kwargs): pass def workspace(self, **kwargs): self.converter.prelude += "project(%s)\n" % (kwargs["name"]) self.converter.prelude += "set(CMAKE_C_STANDARD 99)\n" + def maybe(self, rule, **kwargs): + if kwargs["name"] == "utf8_range": + self.converter.utf8_range_commit = kwargs["commit"] + pass + def http_archive(self, **kwargs): pass @@ -186,7 +264,46 @@ def new_git_repository(self, **kwargs): def bazel_version_repository(self, **kwargs): pass - def upb_deps(self): + def protobuf_deps(self): + pass + + def utf8_range_deps(self): + pass + + def pip_parse(self, **kwargs): + pass + + def rules_fuzzing_dependencies(self): + pass + + def rules_fuzzing_init(self): + pass + + def rules_pkg_dependencies(self): + pass + + def system_python(self, **kwargs): + pass + + def register_system_python(self, **kwargs): + pass + + def register_toolchains(self, toolchain): + pass + + def python_source_archive(self, **kwargs): + pass + + def python_nuget_package(self, **kwargs): + pass + + def install_deps(self): + pass + + def fuzzing_py_install_deps(self): + pass + + def googletest_deps(self): pass @@ -195,26 +312,19 @@ def __init__(self): self.prelude = "" self.toplevel = "" self.if_lua = "" + self.utf8_range_commit = "" def convert(self): return self.template % { "prelude": converter.prelude, "toplevel": converter.toplevel, + "utf8_range_commit": converter.utf8_range_commit, } template = textwrap.dedent("""\ # This file was generated from BUILD using tools/make_cmakelists.py. - cmake_minimum_required(VERSION 3.1) - - if(${CMAKE_VERSION} VERSION_LESS 3.12) - cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) - else() - cmake_policy(VERSION 3.12) - endif() - - cmake_minimum_required (VERSION 3.0) - cmake_policy(SET CMP0048 NEW) + cmake_minimum_required(VERSION 3.10...3.24) %(prelude)s @@ -252,9 +362,26 @@ def convert(self): set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") endif() - include_directories(..) - include_directories(../cmake) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) + if(NOT TARGET utf8_range) + if(EXISTS ../external/utf8_range) + # utf8_range is already installed + include_directories(../external/utf8_range) + elseif(EXISTS ../../utf8_range) + include_directories(../../utf8_range) + else() + include(FetchContent) + FetchContent_Declare( + utf8_range + GIT_REPOSITORY "https://github.com/protocolbuffers/utf8_range.git" + GIT_TAG "%(utf8_range_commit)s" + ) + FetchContent_GetProperties(utf8_range) + if(NOT utf8_range_POPULATED) + FetchContent_Populate(utf8_range) + include_directories(${utf8_range_SOURCE_DIR}) + endif() + endif() + endif() if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -flat_namespace") @@ -274,6 +401,7 @@ def convert(self): def GetDict(obj): ret = {} ret["UPB_DEFAULT_COPTS"] = [] # HACK + ret["UPB_DEFAULT_CPPOPTS"] = [] # HACK for k in dir(obj): if not k.startswith("_"): ret[k] = getattr(obj, k); @@ -281,9 +409,12 @@ def GetDict(obj): globs = GetDict(converter) -exec(open("WORKSPACE").read(), GetDict(WorkspaceFileFunctions(converter))) -exec(open("BUILD").read(), GetDict(BuildFileFunctions(converter))) -exec(open("third_party/wyhash/BUILD").read(), GetDict(BuildFileFunctions(converter))) +workspace_dict = GetDict(WorkspaceFileFunctions(converter)) +# We take all file paths as command-line arguments to ensure that we can find +# each file regardless of how exactly Bazel was invoked. +exec(open(sys.argv[1]).read(), workspace_dict) # workspace_deps.bzl +exec(open(sys.argv[2]).read(), workspace_dict) # WORKSPACE +exec(open(sys.argv[3]).read(), GetDict(BuildFileFunctions(converter))) # BUILD -with open(sys.argv[1], "w") as f: +with open(sys.argv[4], "w") as f: f.write(converter.convert()) diff --git a/archive/cmake/push_auto_update.sh b/archive/cmake/push_auto_update.sh new file mode 100755 index 0000000000..6b7dba00ad --- /dev/null +++ b/archive/cmake/push_auto_update.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# This script updates checked-in generated files (currently CMakeLists.txt, +# descriptor.upb.h, and descriptor.upb.c), commits the resulting change, and +# pushes it. This does not do anything useful when run manually, but should be +# run by our GitHub action instead. + +set -ex + +# Exit early if the previous commit was made by the bot. This reduces the risk +# of a bug causing an infinite loop of auto-generated commits. +if (git log -1 --pretty=format:'%an' | grep -q "Protobuf Team Bot"); then + echo "Previous commit was authored by bot" + exit 0 +fi + +cd $(dirname -- "$0")/.. +bazel test //cmake:test_generated_files || bazel-bin/cmake/test_generated_files --fix + +# Try to determine the most recent pull request number. +title=$(git log -1 --pretty='%s') +pr_from_merge=$(echo "$title" | sed -n 's/^Merge pull request #\([0-9]\+\).*/\1/p') +pr_from_squash=$(echo "$title" | sed -n 's/^.*(#\([0-9]\+\))$/\1/p') + +pr_number="" +if [ ! -z "$pr_from_merge" ]; then + pr_number="$pr_from_merge" +elif [ ! -z "$pr_from_squash" ]; then + pr_number="$pr_from_squash" +fi + +if [ ! -z "$pr_number" ]; then + commit_message="Auto-generate CMake file lists after PR #$pr_number" +else + # If we are unable to determine the pull request number, we fall back on this + # default commit message. Typically this should not occur, but could happen + # if a pull request was merged via a rebase. + commit_message="Auto-generate CMake file lists" +fi + +git add -A +git diff --staged --quiet || git commit -am "$commit_message" +git push diff --git a/archive/cmake/staleness_test.py b/archive/cmake/staleness_test.py new file mode 100644 index 0000000000..c2971c289d --- /dev/null +++ b/archive/cmake/staleness_test.py @@ -0,0 +1,60 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""The py_test() script for staleness_test() rules. + +Note that this file is preprocessed! The INSERT_<...> text below is replaced +with the actual list of files before we actually run the script. +""" + +from __future__ import absolute_import + +from cmake import staleness_test_lib +import unittest +import sys + +file_list = """ + INSERT_FILE_LIST_HERE +""".split() + +config = staleness_test_lib.Config(file_list) + + +class TestFilesMatch(unittest.TestCase): + + def testFilesMatch(self): + errors = staleness_test_lib.CheckFilesMatch(config) + self.assertFalse(errors, errors) + + +if len(sys.argv) > 1 and sys.argv[1] == "--fix": + staleness_test_lib.FixFiles(config) +else: + unittest.main() diff --git a/cmake/staleness_test_lib.py b/archive/cmake/staleness_test_lib.py similarity index 65% rename from cmake/staleness_test_lib.py rename to archive/cmake/staleness_test_lib.py index cdfcc0d17a..d9b78a6eb7 100644 --- a/cmake/staleness_test_lib.py +++ b/archive/cmake/staleness_test_lib.py @@ -1,12 +1,44 @@ -"""Shared code for validating generated_file_staleness_test() rules. - -This code is used by test scripts generated from -generated_file_staleness_test() rules. +#!/usr/bin/python +# +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Shared code for validating staleness_test() rules. + +This code is used by test scripts generated from staleness_test() rules. """ from __future__ import absolute_import from __future__ import print_function +import difflib import sys import os from shutil import copyfile @@ -145,7 +177,10 @@ def CheckFilesMatch(config): continue for pair in stale_files: - diff_errors.append("File %s is out of date" % pair.target) + with open(pair.generated) as g, open(pair.target) as t: + diff = ''.join(difflib.unified_diff(g.read().splitlines(keepends=True), + t.read().splitlines(keepends=True))) + diff_errors.append("File %s is out of date:\n%s" % (pair.target, diff)) if diff_errors: error_msg = "Files out of date!\n\n" diff --git a/archive/docs/design.md b/archive/docs/design.md new file mode 100644 index 0000000000..a46364af02 --- /dev/null +++ b/archive/docs/design.md @@ -0,0 +1,429 @@ +# upb Design + +[TOC] + +upb is a protobuf kernel written in C. It is a fast and conformant +implementation of protobuf, with a low-level C API that is designed to be +wrapped in other languages. + +upb is not designed to be used by applications directly. The C API is very +low-level, unsafe, and changes frequently. It is important that upb is able to +make breaking API changes as necessary, to avoid taking on technical debt that +would compromise upb's goals of small code size and fast performance. + +## Design goals + +Goals: + +- Full protobuf conformance +- Small code size +- Fast performance (without compromising code size) +- Easy to wrap in language runtimes +- Easy to adapt to different memory management schemes (refcounting, GC, etc) + +Non-Goals: + +- Stable API +- Safe API +- Ergonomic API for applications + +Parameters: + +- C99 +- 32 or 64-bit CPU (assumes 4 or 8 byte pointers) +- Uses pointer tagging, but avoids other implementation-defined behavior +- Aims to never invoke undefined behavior (tests with ASAN, UBSAN, etc) +- No global state, fully re-entrant + +## Arenas + +All memory management in upb uses arenas, using the type `upb_Arena`. Arenas are +an alternative to `malloc()` and `free()` that significantly reduces the costs +of memory allocation. + +Arenas obtain blocks of memory using some underlying allocator (likely +`malloc()` and `free()`), and satisfy allocations using a simple bump allocator +that walks through each block in linear order. Allocations cannot be freed +individually: it is only possible to free the arena as a whole, which frees all +of the underlying blocks. + +Here is an example of using the `upb_Arena` type: + +```c + upb_Arena* arena = upb_Arena_New(); + + // Perform some allocations. + int* x = upb_Arena_Malloc(arena, sizeof(*x)); + int* y = upb_Arena_Malloc(arena, sizeof(*y)); + + // We cannot free `x` and `y` separately, we can only free the arena + // as a whole. + upb_Arena_Free(arena); +``` + +upb uses arenas for all memory management, and this fact is reflected in the API +for all upb data structures. All upb functions that allocate take a `upb_Arena*` +parameter and perform allocations using that arena rather than calling +`malloc()` or `free()`. + +```c +// upb API to create a message. +UPB_API upb_Message* upb_Message_New(const upb_MiniTable* mini_table, + upb_Arena* arena); + +void MakeMessage(const upb_MiniTable* mini_table) { + upb_Arena* arena = upb_Arena_New(); + + // This message is allocated on our arena. + upb_Message* msg = upb_Message_New(mini_table, arena); + + // We can free the arena whenever we want, but we cannot free the + // message separately from the arena. + upb_Arena_Free(arena); + + // msg is now deleted. +} +``` + +Arenas are a key part of upb's performance story. Parsing a large protobuf +payload usually involves rapidly creating a series of messages, arrays (repeated +fields), and maps. It is crucial for parsing performance that these allocations +are as fast as possible. Equally important, freeing the tree of messages should +be as fast as possible, and arenas can reduce this cost from `O(n)` to `O(lg +n)`. + +### Avoiding Dangling Pointers + +Objects allocated on an arena will frequently contain pointers to other +arena-allocated objects. For example, a `upb_Message` will have pointers to +sub-messages that are also arena-allocated. + +Unlike unique ownership schemes (such as `unique_ptr<>`), arenas cannot provide +automatic safety from dangling pointers. Instead, upb provides tools to help +bridge between higher-level memory management schemes (GC, refcounting, RAII, +borrow checkers) and arenas. + +If there is only one arena, dangling pointers within the arena are impossible, +because all objects are freed at the same time. This is the simplest case. The +user must still be careful not to keep dangling pointers that point at arena +memory after it has been freed, but dangling pointers *between* the arena +objects will be impossible. + +But what if there are multiple arenas? If we have a pointer from one arena to +another, how do we ensure that this will not become a dangling pointer? + +To help with the multiple arena case, upb provides a primitive called "fuse". + +```c +// Fuses the lifetimes of `a` and `b`. None of the blocks from `a` or `b` +// will be freed until both arenas are freed. +UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b); +``` + +When two arenas are fused together, their lifetimes are irreversibly joined, +such that none of the arena blocks in either arena will be freed until *both* +arenas are freed with `upb_Arena_Free()`. This means that dangling pointers +between the two arenas will no longer be possible. + +Fuse is useful when joining two messages from separate arenas (making one a +sub-message of the other). Fuse is a relatively cheap operation, on the order of +150ns, and is very nearly `O(1)` in the number of arenas being fused (the true +complexity is the inverse Ackermann function, which grows extremely slowly). + +Each arena does consume some memory, so repeatedly creating and fusing an +additional arena is not free, but the CPU cost of fusing two arenas together is +modest. + +### Initial Block and Custom Allocators + +`upb_Arena` normally uses `malloc()` and `free()` to allocate and return its +underlying blocks. But this default strategy can be customized to support the +needs of a particular language. + +The lowest-level function for creating a `upb_Arena` is: + +```c +// Creates an arena from the given initial block (if any -- n may be 0). +// Additional blocks will be allocated from |alloc|. If |alloc| is NULL, +// this is a fixed-size arena and cannot grow. +UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc); +``` + +The buffer `[mem, n]` will be used as an "initial block", which is used to +satisfy allocations before calling any underlying allocation function. Note that +the `upb_Arena` itself will be allocated from the initial block if possible, so +the amount of memory available for allocation from the arena will be less than +`n`. + +The `alloc` parameter specifies a custom memory allocation function which will +be used once the initial block is exhausted. The user can pass `NULL` as the +allocation function, in which case the initial block is the only memory +available in the arena. This can allow upb to be used even in situations where +there is no heap. + +It follows that `upb_Arena_Malloc()` is a fallible operation, and all allocating +operations like `upb_Message_New()` should be checked for failure if there is +any possibility that a fixed size arena is in use. + +## Schemas + +Nearly all operations in upb require that you have a schema. A protobuf schema +is a data structure that contains all of the message, field, enum, etc. +definitions that are specified in a `.proto` file. To create, parse, serialize, +or access a message you must have a schema. For this reason, loading a schema is +generally the first thing you must do when you use upb. [^0] + +[^0]: This requirement comes from the protobuf wire format itself, which is a + deep insight about the nature of protobuf (or at least the existing wire + format). Unlike JSON, protobuf cannot be parsed or manipulated in a + schema-less way. This is because the binary wire format does not + distinguish between strings and sub-messages, so a generic parser that is + oblivious to the schema is not possible. If a future version of the wire + format did distinguish between these, it could be possible to have a + schema-agnostic data representation, parser, and serializer. + +upb has two main data structures that represent a protobuf schema: + +* **MiniTables** are a compact, stripped down version of the schema that + contains only the information necessary for parsing and serializing the + binary wire format. +* **Reflection** contains basically all of the data from a `.proto` file, + including the original names of all messages/fields/etc., and all options. + +The table below summarizes the main differences between these two: + +| | MiniTables | Reflection | +| ------------------- | ------------------------- | -------------------------- | +| Contains | Field numbers and types | All data in `.proto` file, | +: : only : including names of : +: : : everything : +| Used to parse | binary format | JSON / TextFormat | +| Wire representation | MiniDescriptor | Descriptor | +| Type names | `upb_MiniTable`, | `upb_MessageDef`, | +: : `upb_MiniTableField`, ... : `upb_FieldDef`, ... : +| Registry | `upb_ExtensionRegistry` | `upb_DefPool` | +: : (for extensions) : : + +MiniTables are useful if you only need the binary wire format, because they are +much lighter weight than full reflection. + +Reflection is useful if you need to parse JSON or TextFormat, or you need access +to options that were specified in the `proto` file. Note that reflection also +includes MiniTables, so if you have reflection, you also have MiniTables +available. + +### MiniTables + +MiniTables are represented by a set of data structures with names like +`upb_MiniTable` (representing a message), `upb_MiniTableField`, +`upb_MiniTableFile`, etc. Whenever you see one of these types in a function +signature, you know that this particular operation requires a MiniTable. For +example: + +``` +// Parses the wire format data in the given buffer `[buf, size]` and writes it +// to the message `msg`, which has the type `mt`. +UPB_API upb_DecodeStatus upb_Decode(const char* buf, size_t size, + upb_Message* msg, const upb_MiniTable* mt, + const upb_ExtensionRegistry* extreg, + int options, upb_Arena* arena); +``` + +The subset of upb that requires only MiniTables can be thought of as "upb lite," +because both the code size and the runtime memory overhead will be less than +"upb full" (the parts that use reflection). + +#### Loading + +There are three main ways of loading a MiniTable: + +1. **From C generated code:** The upb code generator can emit `.upb.c` files that + contain the MiniTables as global constant variables. When the main program + links against these, the MiniTable will be placed into `.rodata` (or + `.data.rel.ro`) in the binary. The MiniTable can then be obtained from a + generated function. In Blaze/Bazel these files can be generated and linked + using the `upb_proto_library()` rule. +2. **From MiniDescriptors:** The user can build MiniDescriptors into MiniTables + at runtime. MiniDescriptors are a compact upb-specific wire format designed + specially for this purpose. The user can call `upb_MiniTable_Build()` at + runtime to convert MiniDescriptors to MiniTables. +3. **From reflection:** If you have already built reflection data structures + for your type, then you can obtain the `upb_MiniTable` corresponding to a + `upb_MessageDef` using `upb_MessageDef_MiniTable()`. + +For languages that are already using reflection, (3) is an obvious choice. + +For languages that are avoiding reflection, here is a general guideline for +choosing between (1) and (2): if the language being wrapped participates in the +standard binary linking model on a given platform (in particular, if it is +generally linked using `ld`), then it is better to use (1), which is also known +as "static loading". + +Static loading of MiniTables has the benefit of requiring no runtime +initialization[^2], leading to faster startup. Static loading of MiniTables also +facilitates cross-language sharing of proto messages, because sharing generally +requires that both languages are using exactly the same MiniTables. + +The main downside of static loading is that it requires the user to generate one +`.upb.c` file per `.proto` and link against the transitive closure of `.upb.c` +files. Blaze and Bazel make this reasonably easy, but for other build systems it +can be more of a challenge. + +[^2]: aside from possible pointer relocations performed by the ELF/Mach-O loader + if the library or binary is position-independent + +Loading from MiniDescriptors, as in option (2), has the advantage that it does +not require per-message linking of C code. For many language toolchains, +generating and linking some custom C code for every protobuf file or message +type would be a burdensome requirement. MiniDescriptors are a convenient way of +loading MiniTables without needing to cross the FFI boundary outside the core +runtime. + +A common pattern when using dynamic loading is to embed strings containing +MiniDescriptors directly into generated code. For example, the generated code in +Dart for a message with only primitive fields currently looks something like: + +```dart + const desc = r'$(+),*-#$%&! /10'; + _accessor = $pb.instance.registry.newMessageAccessor(desc); +``` + +The implementation of `newMessageAccesor()` is mainly just a wrapper around +`upb_MiniTable_Build()`, which builds a MiniTable from a MiniDescriptor. In the +code generator, the MiniDescriptor can be obtained from the +`upb_MessageDef_MiniDescriptorEncode()` API; users should never need to encode a +MiniDescriptor manually. + +#### Linking + +When building MiniTables dynamically, it is the user's responsibility to link +each message to the to the appropriate sub-messages and or enums. Each message +must have its message and closed enum fields linked using +`upb_MiniTable_SetSubMessage()` and `upb_MiniTable_SetSubEnum()`, respectively. + +A higher-level function that links all fields at the same time is also +available, as `upb_MiniTable_Link()`. This function pairs well with +`upb_MiniTable_GetSubList()` which can be used in a code generator to get a list +of all the messages and enums which must be passed to `upb_MiniTable_Link()`. + +A common pattern is to embed the `link()` calls directly into the generated +code. For example, here is an example from Dart of building a MiniTable that +contains sub-messages and enums: + +```dart + const desc = r'$3334'; + _accessor = $pb.instance.registry.newMessageAccessor(desc); + _accessor!.link( + [ + M2.$_accessor, + M3.$_accessor, + M4.$_accessor, + ], + [ + E.$_accessor, + ], + ); +``` + +In this case, `upb_MiniTable_GetSubList()` was used in the code generator to +discover the 3 sub-message fields and 1 sub-enum field that require linking. At +runtime, these lists of MiniTables are passed to the `link()` function, which +will internally call `upb_MiniTable_Link()`. + +Note that in some cases, the application may choose to delay or even skip the +registration of sub-message types, as part of a tree shaking strategy. + +When using static MiniTables, a manual link step is not necessary, as linking is +performed automatically by `ld`. + +#### Enums + +MiniTables primarily carry data about messages, fields, and extensions. However +for closed enums, we must also have a `upb_MiniTableEnum` structure that stores +the set of all numbers that are defined in the enum. This is because closed +enums have the unfortunate behavior of putting unknown enum values into the +unknown field set. + +Over time, closed enums will hopefully be phased out via editions, and the +relevance and overhead of `upb_MiniTableEnum` will shrink and eventually +disappear. + +### Reflection + +Reflection uses types like `upb_MessageDef` and `upb_FieldDef` to represent the +full contents of a `.proto` file at runtime. These types are upb's direct +equivalents of `google::protobuf::Descriptor`, `google::protobuf::FieldDescriptor`, etc. [^1] + +[^1]: upb consistently uses `Def` where C++ would use `Descriptor` in type + names. This introduces divergence with C++; the rationale was to conserve + horizontal line length, as `Def` is less than 1/3 the length of + `Descriptor`. This is more relevant in C, where the type name is repeated + in every function, eg. `upb_FieldDef_Name()` vs. + `upb_FieldDescriptor_Name()`. + +Whenever you see one of these types in a function signature, you know that the +given operation requires reflection. For example: + +```c +// Parses JSON format into a message object, using reflection. +UPB_API bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg, + const upb_MessageDef* m, const upb_DefPool* symtab, + int options, upb_Arena* arena, upb_Status* status); +``` + +The part of upb that requires reflection can be thought of as "upb full." These +parts of the library cannot be used if a given application has only loaded +MiniTables. There is no way to convert a MiniTable into reflection. + +The `upb_DefPool` type is the top-level container that builds and owns some set +of defs. This type is a close analogue of `google::protobuf::DescriptorPool` in C++. The +user must always ensure that the `upb_DefPool` outlives any def objects that it +owns. + +#### Loading + +As with MiniTable loading, we have multiple options for how to load full +reflection: + +1. **From C generated code**: The upb code generator can create `foo.upbdefs.c` + files that embed the descriptors and exports generated C functions for + adding them to a user-provided `upb_DefPool`. +2. **From descriptors**: The user can make manual calls to + `upb_DefPool_AddFile()`, using descriptors obtained at runtime. Defs for + individual messages can then be obtained using + `upb_DefPool_FindMessageByName()`. + +Unlike MiniTables, loading from generated code requires runtime initialization, +as reflection data structures like `upb_MessageDef` are not capable of being +emitted directly into `.rodata` like `upb_MiniTable` is. Instead, the generated +code embeds serialized descriptor protos into `.rodata` which are then built +into heap objects at runtime. + +From this you might conclude that option (1) is nothing but a convenience +wrapper around option (2), but that is not quite correct either. Option (1) +*does* link against the static `.upb.c` structures for the MiniTables, whereas +option (2) will build the MiniTables from scratch on the heap. So option (1) +will use marginally less CPU and RAM when the descriptors are loaded into a +`upb_DefPool`. More importantly, the resulting descriptors will be capable of +reflecting over any messages built from the generated `.upb.c` MiniTables, +whereas descriptors built using option (2) will have distinct MiniTables that +cannot reflect over messages that use the generated MiniTables. + +A common pattern for dynamic languages like PHP, Ruby, or Python, is to use +option (2) with descriptors that are embedded into the generated code. For +example, the generated code in Python currently looks something like: + +```python +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf.internal import builder as _builder + +_desc = b'\n\x1aprotoc_explorer/main.proto\x12\x03pkg' + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(_desc) +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google3.protoc_explorer.main_pb2', _globals) +``` + +The `AddSerializedFile()` API above is mainly just a thin wrapper around +`upb_DefPool_AddFile()`. diff --git a/archive/docs/render.py b/archive/docs/render.py new file mode 100755 index 0000000000..0f3bdc28db --- /dev/null +++ b/archive/docs/render.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 + +# Protocol Buffers - Google's data interchange format +# Copyright 2023 Google LLC. All rights reserved. +# https://developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import subprocess +import sys +import shutil +import os + +if len(sys.argv) < 2: + print("Must pass a filename argument") + sys.exit(1) + +in_filename = sys.argv[1] +out_filename = in_filename.replace(".in.md", ".md") +out_dir = in_filename.replace(".in.md", "") + +if in_filename == out_filename: + print("File must end in .in.md") + sys.exit(1) + +if os.path.isdir(out_dir): + shutil.rmtree(out_dir) + +os.mkdir(out_dir) +file_num = 1 + +with open(out_filename, "wb") as out_file, open(in_filename, "rb") as in_file: + for line in in_file: + if line.startswith(b"```dot"): + dot_lines = [] + while True: + dot_line = next(in_file) + if dot_line == b"```\n": + break + dot_lines.append(dot_line) + dot_input = b"".join(dot_lines) + svg_filename = out_dir + "/" + str(file_num) + ".svg" + svg = subprocess.check_output(['dot', '-Tsvg', '-o', svg_filename], input=dot_input) + out_file.write(b"

\n") + out_file.write(b"\n" % (svg_filename.encode('utf-8'))) + out_file.write(b"
\n") + file_num += 1 + else: + out_file.write(line) diff --git a/archive/docs/style-guide.md b/archive/docs/style-guide.md new file mode 100644 index 0000000000..e02571b524 --- /dev/null +++ b/archive/docs/style-guide.md @@ -0,0 +1,65 @@ +# C style guide + + + +Since upb is written in pure C, we supplement the +[Google C++ style guide](https://google.github.io/styleguide/cppguide.html) with +some C-specific guidance. + +Everything written here is intended to follow the spirit of the C++ style guide. + +upb is currently inconsistent about following these conventions. It is intended +that all code will be updated to match these guidelines. The priority is +converting public interfaces as these are more difficult to change later. + +## Naming + +### Functions and Types + +C does not have namespaces. Anywhere you would normally use a namespace +separator (`::`) in C++, we use an underscore (`_`) in C: + +```c++ +// C equivalent for upb::Arena::New() +upb_Arena* upb_Arena_New(); +``` + +Since we rely on `_` to be our namespace separator, we never use it to merely +separate words in function or type names: + +```c++ +// BAD: this would be interpreted as upb::FieldDef::has::default(). +bool upb_FieldDef_has_default(const upb_FieldDef* f); + +// GOOD: this is equivalent to upb::FieldDef::HasDefault(). +bool upb_FieldDef_HasDefault(const upb_FieldDef* f); +``` + +For multi-word namespaces, we use `PascalCase`: + +```c++ +// `PyUpb` is the namespace. +PyObject* PyUpb_CMessage_GetAttr(PyObject* _self, PyObject* attr); +``` + +### Private Functions and Members + +Since we do not have `private` in C++, we use a leading underscore convention +to mark internal functions and variables that should only be accessed from +upb: + +```c++ +// Internal-only function. +int64_t _upb_Int64_FromLL(); + +// Internal-only members. Underscore prefixes are only necessary when the +// structure is defined in a header file. +typedef struct { + const int32_t* _values; // List of values <0 or >63 + uint64_t _mask; // Bits are set for acceptable value 0 <= x < 64 + int _value_count; +} upb_MiniTableEnum; +``` diff --git a/archive/docs/vs-cpp-protos.md b/archive/docs/vs-cpp-protos.md new file mode 100644 index 0000000000..fe2a864e4d --- /dev/null +++ b/archive/docs/vs-cpp-protos.md @@ -0,0 +1,261 @@ + + +# upb vs. C++ Protobuf Design + +[upb](https://github.com/protocolbuffers/upb) is a small C protobuf library. +While some of the design follows in the footsteps of the C++ Protobuf Library, +upb departs from C++'s design in several key ways. This document compares +and contrasts the two libraries on several design points. + +## Design Goals + +Before we begin, it is worth calling out that upb and C++ have different design +goals, and this motivates some of the differences we will see. + +C++ protobuf is a user-level library: it is designed to be used directly by C++ +applications. These applications will expect a full-featured C++ API surface +that uses C++ idioms. The C++ library is also willing to add features to +increase server performance, even if these features would add size or complexity +to the library. Because C++ protobuf is a user-level library, API stability is +of utmost importance: breaking API changes are rare and carefully managed when +they do occur. The focus on C++ also means that ABI compatibility with C is not +a priority. + +upb, on the other hand, is designed primarily to be wrapped by other languages. +It is a C protobuf kernel that forms the basis on which a user-level protobuf +library can be built. This means we prefer to keep the API surface as small and +orthogonal as possible. While upb supports all protobuf features required for +full conformance, upb prioritizes simplicity and small code size, and avoids +adding features like lazy fields that can accelerate some use cases but at great +cost in terms of complexity. As upb is not aimed directly at users, there is +much more freedom to make API-breaking changes when necessary, which helps the +core to stay small and simple. We want to be compatible with all FFI +interfaces, so C ABI compatibility is a must. + +Despite these differences, C++ protos and upb offer [roughly the same core set +of features](https://github.com/protocolbuffers/upb#features). + +## Arenas + +upb and C++ protos both offer arena allocation, but there are some key +differences. + +### C++ + +As a matter of history, when C++ protos were open-sourced in 2008, they did not +support arenas. Originally there was only unique ownership, whereby each +message uniquely owns all child messages and will free them when the parent is +freed. + +Arena allocation was added as a feature in 2014 as a way of dramatically +reducing allocation and (especially) deallocation costs. But the library was +not at liberty to remove the unique ownership model, because it would break far +too many users. As a result, C++ has supported a **hybrid allocation model** +ever since, allowing users to allocate messages either directly from the +stack/heap or from an arena. The library attempts to ensure that there are +no dangling pointers by performing automatic copies in some cases (for example +`a->set_allocated_b(b)`, where `a` and `b` are on different arenas). + +C++'s arena object itself `google::protobuf::Arena` is **thread-safe** by +design, which allows users to allocate from multiple threads simultaneously +without external synchronization. The user can supply an initial block of +memory to the arena, and can choose some parameters to control the arena block +size. The user can also supply block alloc/dealloc functions, but the alloc +function is expected to always return some memory. The C++ library in general +does not attempt to handle out of memory conditions. + +### upb + +upb uses **arena allocation exclusively**. All messages must be allocated from +an arena, and can only be freed by freeing the arena. It is entirely the user's +responsibility to ensure that there are no dangling pointers: when a user sets a +message field, this will always trivially overwrite the pointer and will never +perform an implicit copy. + +upb's `upb::Arena` is **thread-compatible**, which means it cannot be used +concurrently without synchronization. The arena can be seeded with an initial +block of memory, but it does not explicitly support any parameters for choosing +block size. It supports a custom alloc/dealloc function, and this function is +allowed to return `NULL` if no dynamic memory is available. This allows upb +arenas to have a max/fixed size, and makes it possible in theory to write code +that is tolerant to out-of-memory errors. + +upb's arena also supports a novel operation known as **fuse**, which joins two +arenas together into a single lifetime. Though both arenas must still be freed +separately, none of the memory will actually be freed until *both* arenas have +been freed. This is useful for avoiding dangling pointers when reparenting a +message with one that may be on a different arena. + +### Comparison + +**hybrid allocation vs. arena-only** + +* The C++ hybrid allocation model introduces a great deal of complexity and + unpredictability into the library. upb benefits from having a much simpler + and more predictable design. +* Some of the complexity in C++'s hybrid model arises from the fact that arenas + were added after the fact. Designing for a hybrid model from the outset + would likely yield a simpler result. +* Unique ownership does support some usage patterns that arenas cannot directly + accommodate. For example, you can reparent a message and the child will precisely + follow the lifetime of its new parent. An arena would require you to either + perform a deep copy or extend the lifetime. + +**thread-compatible vs. thread-safe arena** + +* A thread-safe arena (as in C++) is safer and easier to use. A thread-compatible + arena requires that the user prove that the arena cannot be used concurrently. +* [Thread Sanitizer](https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual) + is far more accessible than it was in 2014 (when C++ introduced a thread-safe + arena). We now have more tools at our disposal to ensure that we do not trigger + data races in a thread-compatible arena like upb. +* Thread-compatible arenas are more performant. +* Thread-compatible arenas have a far simpler implementation. The C++ thread-safe + arena relies on thread-local variables, which introduce complications on some + platforms. It also requires far more subtle reasoning for correctness and + performance. + +**fuse vs. no fuse** + +* The `upb_Arena_Fuse()` operation is a key part of how upb supports reparenting + of messages when the parent may be on a different arena. Without this, upb has + no way of supporting `foo.bar = bar` in dynamic languages without performing a + deep copy. +* A downside of `upb_Arena_Fuse()` is that passing an arena to a function can allow + that function to extend the lifetime of the arena in potentially + unpredictable ways. This can be prevented if necessary, as fuse can fail, eg. if + one arena has an initial block. But this adds some complexity by requiring callers + to handle the case where fuse fails. + +## Code Generation vs. Tables + +The C++ protobuf library has always been built around code generation, while upb +generates only tables. In other words, `foo.pb.cc` files contain functions, +whereas `foo.upb.c` files emit only data structures. + +### C++ + +C++ generated code emits a large number of functions into `foo.pb.cc` files. +An incomplete list: + +* `FooMsg::FooMsg()` (constructor): initializes all fields to their default value. +* `FooMsg::~FooMsg()` (destructor): frees any present child messages. +* `FooMsg::Clear()`: clears all fields back to their default/empty value. +* `FooMsg::_InternalParse()`: generated code for parsing a message. +* `FooMsg::_InternalSerialize()`: generated code for serializing a message. +* `FooMsg::ByteSizeLong()`: calculates serialized size, as a first pass before serializing. +* `FooMsg::MergeFrom()`: copies/appends present fields from another message. +* `FooMsg::IsInitialized()`: checks whether required fields are set. + +This code lives in the `.text` section and contains function calls to the generated +classes for child messages. + +### upb + +upb does not generate any code into `foo.upb.c` files, only data structures. upb uses a +compact data table known as a *mini table* to represent the schema and all fields. + +upb uses mini tables to perform all of the operations that would traditionally be done +with generated code. Revisiting the list from the previous section: + +* `FooMsg::FooMsg()` (constructor): upb instead initializes all messages with `memset(msg, 0, size)`. + Non-zero defaults are injected in the accessors. +* `FooMsg::~FooMsg()` (destructor): upb messages are freed by freeing the arena. +* `FooMsg::Clear()`: can be performed with `memset(msg, 0, size)`. +* `FooMsg::_InternalParse()`: upb's parser uses mini tables as data, instead of generating code. +* `FooMsg::_InternalSerialize()`: upb's serializer also uses mini-tables instead of generated code. +* `FooMsg::ByteSizeLong()`: upb performs serialization in reverse so that an initial pass is not required. +* `FooMsg::MergeFrom()`: upb supports this via serialize+parse from the other message. +* `FooMsg::IsInitialized()`: upb's encoder and decoder have special flags to check for required fields. + A util library `upb/util/required_fields.h` handles the corner cases. + +### Comparison + +If we compare compiled code size, upb is far smaller. Here is a comparison of the code +size of a trivial binary that does nothing but a parse and serialize of `descriptor.proto`. +This means we are seeing both the overhead of the core library itself as well as the +generated code (or table) for `descriptor.proto`. (For extra clarity we should break this +down by generated code vs core library in the future). + + +| Library | `.text` | `.data` | `.bss` | +|------------ |---------|---------|--------| +| upb | 26Ki | 0.6Ki | 0.01Ki | +| C++ (lite) | 187Ki | 2.8Ki | 1.25Ki | +| C++ (code size) | 904Ki | 6.1Ki | 1.88Ki | +| C++ (full) | 983Ki | 6.1Ki | 1.88Ki | + +"C++ (code size)" refers to protos compiled with `optimize_for = CODE_SIZE`, a mode +in which generated code contains reflection only, in an attempt to make the +generated code size smaller (however it requires the full runtime instead +of the lite runtime). + +## Bifurcated vs. Optional Reflection + +upb and C++ protos both offer reflection without making it mandatory. However +the models for enabling/disabling reflection are very different. + +### C++ + +C++ messages offer full reflection by default. Messages in C++ generally +derive from `Message`, and the base class provides a member function +`Reflection* Message::GetReflection()` which returns the reflection object. + +It follows that any message deriving from `Message` will always have reflection +linked into the binary, whether or not the reflection object is ever used. +Because `GetReflection()` is a function on the base class, it is not possible +to statically determine if a given message's reflection is used: + +```c++ +Reflection* GetReflection(const Message& message) { + // Can refer to any message in the whole binary. + return message.GetReflection(); +} +``` + +The C++ library does provide a way of omitting reflection: `MessageLite`. We can +cause a message to be lite in two different ways: + +* `optimize_for = LITE_RUNTIME` in a `.proto` file will cause all messages in that + file to be lite. +* `lite` as a codegen param: this will force all messages to lite, even if the + `.proto` file does not have `optimize_for = LITE_RUNTIME`. + +A lite message will derive from `MessageLite` instead of `Message`. Since +`MessageLite` has no `GetReflection()` function, this means no reflection is +available, so we can avoid taking the code size hit. + +### upb + +upb does not have the `Message` vs. `MessageLite` bifurcation. There is only one +kind of message type `upb_Message`, which means there is no need to configure in +a `.proto` file which messages will need reflection and which will not. +Every message has the *option* to link in reflection from a separate `foo.upbdefs.o` +file, without needing to change the message itself in any way. + +upb does not provide the equivalent of `Message::GetReflection()`: there is no +facility for retrieving the reflection of a message whose type is not known statically. +It would be possible to layer such a facility on top of the upb core, though this +would probably require some kind of code generation. + +### Comparison + +* Most messages in C++ will not bother to declare themselves as "lite". This means + that many C++ messages will link in reflection even when it is never used, bloating + binaries unnecessarily. +* `optimize_for = LITE_RUNTIME` is difficult to use in practice, because it prevents + any non-lite protos from `import`ing that file. +* Forcing all protos to lite via a codegen parameter (for example, when building for + mobile) is more practical than `optimize_for = LITE_RUNTIME`. But this will break + the compile for any code that tries to upcast to `Message`, or tries to use a + non-lite method. +* The one major advantage of the C++ model is that it can support `msg.DebugString()` + on a type-erased proto. For upb you have to explicitly pass the `upb_MessageDef*` + separately if you want to perform an operation like printing a proto to text format. + +## Explicit Registration vs. Globals + +TODO diff --git a/archive/docs/wrapping-upb.md b/archive/docs/wrapping-upb.md new file mode 100644 index 0000000000..bc1bd63a97 --- /dev/null +++ b/archive/docs/wrapping-upb.md @@ -0,0 +1,444 @@ + + + +# Building a protobuf library on upb + +This is a guide for creating a new protobuf implementation based on upb. It +starts from the beginning and walks you through the process, highlighting +some important design choices you will need to make. + +## Overview + +A protobuf implementation consists of two main pieces: + +1. a code generator, run at compile time, to turn `.proto` files into source + files in your language (we will call this "zlang", assuming an extension of ".z"). +2. a runtime component, which implements the wire format and provides the data + structures for representing protobuf data and metadata. + +
+ +```dot {align="center"} +digraph { + rankdir=LR; + newrank=true; + node [style="rounded,filled" shape=box] + "foo.proto" -> protoc; + "foo.proto" [shape=folder]; + protoc [fillcolor=lightgrey]; + protoc -> "protoc-gen-zlang"; + "protoc-gen-zlang" -> "foo.z"; + "protoc-gen-zlang" [fillcolor=palegreen3]; + "foo.z" [shape=folder]; + labelloc="b"; + label="Compile Time"; +} +``` + +
+ +```dot {align="center"} +digraph { + newrank=true; + node [style="rounded,filled" shape=box fillcolor=lightgrey] + "foo.z" -> "zlang/upb glue (FFI)"; + "zlang/upb glue (FFI)" -> "upb (C)"; + "zlang/upb glue (FFI)" [fillcolor=palegreen3]; + labelloc="b"; + label="Runtime"; +} +``` + +The parts in green are what you will need to implement. + +Note that your code generator (`protoc-gen-zlang`) does *not* need to generate +any C code (eg. `foo.c`). While upb itself is written in C, upb's parsers and +serializers are fully table-driven, which means there is never any need or even +benefit to generating C code for each proto. upb is capable of full-speed +parsing even when schema data is loaded at runtime from strings embedded into +`foo.z`. This is a key benefit of upb compared with C++ protos, which have +traditionally relied on generated parsers in `foo.pb.cc` files to achieve full +parsing speed, and suffered a ~10x speed penalty in the parser when the schema +data was loaded at runtime. + +## Prerequisites + +There are a few things that the language runtime must provide in order to wrap +upb. + +1. **FFI**: To wrap upb, your language must be able to call into a C API + through a Foreign Function Interface (FFI). Most languages support FFI in + some form, either through "native extensions" (in which you write some C + code to implement new methods in your language) or through a direct FFI (in + which you can call into regular C functions directly from your language + using a special library). +2. **Finalizers, Destructors, or Cleaners**: The runtime must provide + finalizers or destructors of some sort. There must be a way of triggering a + call to a C function when the language garbage collects or otherwise + destroys an object. We don't care much whether it is a finalizer, a + destructor, or a cleaner, as long as it gets called eventually when the + object is destroyed. upb allocates memory in C space, and a finalizer is our + only way of making sure that memory is freed and does not leak. +3. **HashMap with weak values**: (optional) This is not a strong requirement, + but it is sometimes helpful to have a global hashmap with weak values to act + as a `upb_msg* -> wrapper` object cache. We want the values to be weak (not + the keys). There is some question about whether we want to continue to use + this pattern going forward. + +## Reflection vs. MiniTables + +The first key design decision you will need to make is whether your generated +code will access message data via reflection or minitables. Generally more +dynamic languages will want to use reflection and more static languages will +want to use minitables. + +### Reflection + +Reflection-based data access makes the most sense in highly dynamic language +interpreters, where method dispatch is generally resolved via strings and hash +table lookups. + +In such languages, you can often implement a special method like `__getattr__` +(Python) or `method_missing` (Ruby) that receives the method name as a string. +Using upb's reflection, you can look up a field name using the method name, +thereby using a hash table belonging to upb instead of one provided by the +language. + +```python +class FooMessage: + # Written in Python for illustration, but in practice we will want to + # implement this in C for speed. + def __getattr__(self, name): + field = FooMessage.descriptor.fields_by_name[name] + return field.get_value(self) +``` + +Using this design, we only need to attach a single `__getattr__` method to each +message class, instead of defining a getter/setter for each field. In this way +we can avoid duplicating hash tables between upb and the language interpreter, +reducing memory usage. + +Reflection-based access requires loading full reflection at runtime. Your +generated code will need to embed serialized descriptors (ie. a serialized +message of `descriptor.proto`), which has some amount of size overhead and +exposes all message/field names to the binary. It also forces a hash table +lookup in the critical path of field access. If method calls in your language +already have this overhead, then this is no added burden, but for statically +dispatched languages it would cause extra overhead. + +If we take this path to its logical conclusion, all class creation can be +performed fully dynamically, using only a binary descriptor as input. The +"generated code" becomes little more than an embedded descriptor plus a +library call to load it. Python has recently gone down this path. Generated +code now looks something like this: + +```python +# main_pb2.py +from google3.net.proto2.python.internal import builder as _builder +from google3.net.proto2.python.public import descriptor_pool as _descriptor_pool + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile("<...>") +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google3.main_pb2', globals()) +``` + +This is all the runtime needs to create all of the classes for messages defined +in that serialized descriptor. This code has no pretense of readability, but +a separate `.pyi` stub file provides a fully expanded and readable list of all +methods a user can expect to be available: + +```python +# main_pb2.pyi +from google3.net.proto2.python.public import descriptor as _descriptor +from google3.net.proto2.python.public import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class MyMessage(_message.Message): + __slots__ = ["my_field"] + MY_FIELD_FIELD_NUMBER: _ClassVar[int] + my_field: str + def __init__(self, my_field: _Optional[str] = ...) -> None: ... +``` + +To use reflection-based access: + +1. Load and access descriptor data using the interfaces in upb/reflection/def.h. +2. Access message data using the interfaces in upb/reflection/message.h. + +### MiniTables + +MiniTables are a "lite" schema representation that are much smaller than +reflection. MiniTables omit names, options, and almost everything else from the +`.proto` file, retaining only enough information to parse and serialize binary +format. + +MiniTables can be loaded into upb through *MiniDescriptors*. MiniDescriptors are +a byte-oriented format that can be embedded into your generated code and passed +to upb to construct MiniTables. MiniDescriptors only use printable characters, +and therefore do not require escaping when embedding them into generated code +strings. Overall the size savings of MiniDescriptors are ~60x compared with +regular descriptors. + +MiniTables and MiniDescriptors are a natural choice for compiled languages that +resolve method calls at compile time. For languages that are sometimes compiled +and sometimes interpreted, there might not be an obvious choice. When a method +call is statically bound, we want to remove as much overhead as possible, +especially from accessors. In the extreme case, we can use unsafe APIs to read +raw memory at a known offset: + +```java +// Example of a maximally-optimized generated accessor. +class FooMessage { + public long getBarField() { + // Using Unsafe should give us performance that is comparable to a + // native member access. + // + // The constant "24" is obtained from upb at compile time. + sun.misc.Unsafe.getLong(this.ptr, 24); + } +} +``` + +This design is very low-level, and tightly couples the generated code to one +specific version of the schema and compiler. A slower but safer version would +look up a field by field number: + +```java +// Example of a more loosely-coupled accessor. +class FooMessage { + public long getBarField() { + // The constant "2" is the field number. Internally this will look + // up the number "2" in the MiniTable and use that to read the value + // from the message. + upb.glue.getLong(this.ptr, 2); + } +} +``` + +One downside of MiniTables is that they cannot support parsing or serializing +to JSON or TextFormat, because they do not know the field names. It should be +possible to generate reflection data "on the side", into separate generated +code files, so that reflection is only pulled in if it is being used. However +APIs to do this do not exist yet. + +To use MiniTable-based access: + +1. Load and access MiniDescriptors data using the interfaces in upb/mini_descriptor/decode.h. +2. Access message data using the interfaces in upb/message/accessors.h. + +## Memory Management + +One of the core design challenges when wrapping upb is memory management. Every +language runtime will have some memory management system, whether it is +garbage collection, reference counting, manual memory management, or some hybrid +of these. upb is written in C and uses arenas for memory management, but upb is +designed to integrate with a wide variety of memory management schemes, and it +provides a number of tools for making this integration as smooth as possible. + +### Arenas + +upb defines data structures in C to represent messages, arrays (repeated +fields), and maps. A protobuf message is a hierarchical tree of these objects. +For example, a relatively simple protobuf tree might look something like this: + +```dot {align="center"} +digraph G { + rankdir=LR; + newrank=true; + node [style="rounded,filled" shape=box colorscheme=accent8 fillcolor=1, ordering=out] + upb_msg -> upb_msg2; + upb_msg -> upb_array; + upb_msg [label="upb Message" fillcolor=1] + upb_msg2 [label="upb Message"]; + upb_array [label="upb Array"] +} +``` + +All upb objects are allocated from an arena. An arena lets you allocate objects +individually, but you cannot free individual objects; you can only free the arena +as a whole. When the arena is freed, all of the individual objects allocated +from that arena are freed together. + +```dot {align="center"} +digraph G { + rankdir=LR; + newrank=true; + subgraph cluster_0 { + label = "upb Arena" + graph[style="rounded,filled" fillcolor=gray] + node [style="rounded,filled" shape=box colorscheme=accent8 fillcolor=1, ordering=out] + upb_msg -> upb_array; + upb_msg -> upb_msg2; + upb_msg [label="upb Message" fillcolor=1] + upb_msg2 [label="upb Message"]; + upb_array [label="upb Array"]; + } +} +``` + +In simple cases, the entire tree of objects will all live in a single arena. +This has the nice property that there cannot be any dangling pointers between +objects, since all objects are freed at the same time. + +However upb allows you to create links between any two objects, whether or +not they are in the same arena. The library does not know or care what arenas +the objects are in when you create links between them. + +```dot {align="center"} +digraph G { + rankdir=LR; + newrank=true; + subgraph cluster_0 { + label = "upb Arena 1" + graph[style="rounded,filled" fillcolor=gray] + node [style="rounded,filled" shape=box colorscheme=accent8 fillcolor=1, ordering=out] + upb_msg -> upb_array; + upb_msg -> upb_msg2; + upb_msg [label="upb Message 1" fillcolor=1] + upb_msg2 [label="upb Message 2"]; + upb_array [label="upb Array"]; + } + subgraph cluster_1 { + label = "upb Arena 2" + graph[style="rounded,filled" fillcolor=gray] + node [style="rounded,filled" shape=box colorscheme=accent8 fillcolor=1] + upb_msg3; + } + upb_msg2 -> upb_msg3; + upb_msg3 [label="upb Message 3"]; +} +``` + +When objects are on separate arenas, it is the user's responsibility to ensure +that there are no dangling pointers. In the example above, this means Arena 2 +must outlive Message 1 and Message 2. + +### Integrating GC with upb + +In languages with automatic memory management, the goal is to handle all of the +arenas behind the scenes, so that the user does not have to manage them manually +or even know that they exist. + +We can achieve this goal if we set up the object graph in a particular way. The +general strategy is to create wrapper objects around all of the C objects, +including the arena. Our key goal is to make sure the arena wrapper is not +GC'd until all of the C objects in that arena have become unreachable. + +For this example, we will assume we are wrapping upb in Python: + +```dot {align="center"} +digraph G { + rankdir=LR; + newrank=true; + compound=true; + + subgraph cluster_1 { + label = "upb Arena" + graph[style="rounded,filled" fillcolor=gray] + node [style="rounded,filled" shape=box colorscheme=accent8 fillcolor=1, ordering=out] + upb_msg -> upb_array [style=dashed]; + upb_msg -> upb_msg2 [style=dashed]; + upb_msg [label="upb Message" fillcolor=1] + upb_msg2 [label="upb Message"]; + upb_array [label="upb Array"] + dummy [style=invis] + } + subgraph cluster_python { + node [style="rounded,filled" shape=box colorscheme=accent8 fillcolor=2] + peripheries=0 + py_upb_msg [label="Python Message"]; + py_upb_msg2 [label="Python Message"]; + py_upb_arena [label="Python Arena"]; + } + py_upb_msg -> upb_msg [style=dashed]; + py_upb_msg2->upb_msg2 [style=dashed]; + py_upb_msg2 -> py_upb_arena [color=springgreen4]; + py_upb_msg -> py_upb_arena [color=springgreen4]; + py_upb_arena -> dummy [lhead=cluster_1, color=red]; + { + rank=same; + upb_msg; + py_upb_msg; + } + { + rank=same; + upb_array; + upb_msg2; + py_upb_msg2; + } + { rank=same; + dummy; + py_upb_arena; + } + dummy->upb_array [style=invis]; + dummy->upb_msg2 [style=invis]; + + subgraph cluster_01 { + node [shape=plaintext] + peripheries=0 + key [label=< + + + +
raw ptr
unique ptr
shared (GC) ptr
>] + key2 [label=< + + + +
 
 
 
>] + key:i1:e -> key2:i1:w [style=dashed] + key:i2:e -> key2:i2:w [color=red] + key:i3:e -> key2:i3:w [color=springgreen4] + } + key2:i1:w -> upb_msg [style=invis]; + { + rank=same; + key; + upb_msg; + } +} +``` + +In this example we have three different kinds of pointers: + +* **raw ptr**: This is a pointer that carries no ownership. +* **unique ptr**: This is a pointer has *unique ownership* of the target. The owner + will free the target in its destructor (or finalizer, or cleaner). There can + only be a single unique pointer to a given object. +* **shared (GC) ptr**: This is a pointer that has *shared ownership* of the + target. Many objects can point to the target, and the target will be deleted + only when all such references are gone. In a runtime with automatic memory + management (GC), this is a reference that participates in GC. In Python such + references use reference counting, but in other VMs they may use mark and + sweep or some other form of GC instead. + +The Python Message wrappers have only raw pointers to the underlying message, +but they contain a shared pointer to the arena that will ensure that the raw +pointer remains valid. Only when all message wrapper objects are destroyed +will the Python Arena become unreachable, and the upb arena ultimately freed. + +### Links between arenas with "Fuse" + +The design given above works well for objects that live in a single arena. But +what if a user wants to create a link between two objects in different arenas? + +TODO + +## UTF-8 vs. UTF-16 + +TODO + +## Object Cache + +TODO diff --git a/archive/lua/BUILD.bazel b/archive/lua/BUILD.bazel new file mode 100644 index 0000000000..e8e200de18 --- /dev/null +++ b/archive/lua/BUILD.bazel @@ -0,0 +1,130 @@ +# 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. + +load( + "//bazel:build_defs.bzl", + "UPB_DEFAULT_COPTS", + "UPB_DEFAULT_CPPOPTS", +) +load( + "//lua:lua_proto_library.bzl", + "lua_proto_library", +) + +licenses(["notice"]) + +cc_library( + name = "lupb", + srcs = [ + "def.c", + "msg.c", + "upb.c", + ], + hdrs = [ + "upb.h", + ], + copts = UPB_DEFAULT_COPTS, + visibility = ["//visibility:public"], + deps = [ + "//:json", + "//:message", + "//:reflection", + "//:text", + "@lua//:liblua", + ], +) + +cc_binary( + name = "protoc-gen-lua", + srcs = ["upbc.cc"], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + "@com_google_absl//absl/strings", + "@com_google_protobuf//src/google/protobuf/compiler:code_generator", + ], +) + +exports_files(["upb.lua"]) + +cc_test( + name = "test_lua", + srcs = ["main.c"], + args = ["$(location :test_upb.lua)"], + copts = UPB_DEFAULT_COPTS, + data = [ + "test_upb.lua", + ":descriptor_proto_lua", + ":empty_proto_lua", + ":test_messages_proto2_proto_lua", + ":test_messages_proto3_proto_lua", + ":test_proto_lua", + "//:third_party/lunit/console.lua", + "//:third_party/lunit/lunit.lua", + "//lua:upb.lua", + "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//conformance:conformance_proto", + ], + linkstatic = 1, + deps = [ + "//lua:lupb", + "@lua//:liblua", + ], +) + +proto_library( + name = "test_proto", + testonly = 1, + srcs = ["test.proto"], + deps = ["@com_google_protobuf//:timestamp_proto"], +) + +lua_proto_library( + name = "test_proto_lua", + testonly = 1, + deps = [":test_proto"], +) + +lua_proto_library( + name = "descriptor_proto_lua", + deps = ["@com_google_protobuf//:descriptor_proto"], +) + +lua_proto_library( + name = "empty_proto_lua", + deps = ["@com_google_protobuf//:empty_proto"], +) + +lua_proto_library( + name = "test_messages_proto3_proto_lua", + testonly = 1, + deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"], +) + +lua_proto_library( + name = "test_messages_proto2_proto_lua", + testonly = 1, + deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto2_proto"], +) diff --git a/archive/lua/README.md b/archive/lua/README.md new file mode 100644 index 0000000000..9374f266fc --- /dev/null +++ b/archive/lua/README.md @@ -0,0 +1,8 @@ +# upb Lua bindings + +These are some bare-bones upb bindings for Lua. + +These bindings exist primarily for experimentation and testing. +They are incomplete and are not really intended for use in any application. +This is by no means a complete or supported protobuf library, and in fact +we don't even claim it to be functional. diff --git a/archive/lua/def.c b/archive/lua/def.c new file mode 100644 index 0000000000..9affe52c12 --- /dev/null +++ b/archive/lua/def.c @@ -0,0 +1,943 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "upb/reflection/def.h" + +#include +#include +#include +#include + +#include "lauxlib.h" +#include "lua/upb.h" +#include "upb/reflection/message.h" + +#define LUPB_ENUMDEF "lupb.enumdef" +#define LUPB_ENUMVALDEF "lupb.enumvaldef" +#define LUPB_FIELDDEF "lupb.fielddef" +#define LUPB_FILEDEF "lupb.filedef" +#define LUPB_MSGDEF "lupb.msgdef" +#define LUPB_ONEOFDEF "lupb.oneof" +#define LUPB_SYMTAB "lupb.defpool" +#define LUPB_OBJCACHE "lupb.objcache" + +static void lupb_DefPool_pushwrapper(lua_State* L, int narg, const void* def, + const char* type); + +/* lupb_wrapper ***************************************************************/ + +/* Wrappers around upb def objects. The userval contains a reference to the + * defpool. */ + +#define LUPB_SYMTAB_INDEX 1 + +typedef struct { + const void* def; /* upb_MessageDef, upb_EnumDef, upb_OneofDef, etc. */ +} lupb_wrapper; + +static const void* lupb_wrapper_check(lua_State* L, int narg, + const char* type) { + lupb_wrapper* w = luaL_checkudata(L, narg, type); + return w->def; +} + +static void lupb_wrapper_pushdefpool(lua_State* L, int narg) { + lua_getiuservalue(L, narg, LUPB_SYMTAB_INDEX); +} + +/* lupb_wrapper_pushwrapper() + * + * For a given def wrapper at index |narg|, pushes a wrapper for the given |def| + * and the given |type|. The new wrapper will be part of the same defpool. */ +static void lupb_wrapper_pushwrapper(lua_State* L, int narg, const void* def, + const char* type) { + lupb_wrapper_pushdefpool(L, narg); + lupb_DefPool_pushwrapper(L, -1, def, type); + lua_replace(L, -2); /* Remove defpool from stack. */ +} + +/* lupb_MessageDef_pushsubmsgdef() + * + * Pops the msgdef wrapper at the top of the stack and replaces it with a msgdef + * wrapper for field |f| of this msgdef (submsg may not be direct, for example + * it may be the submessage of the map value). + */ +void lupb_MessageDef_pushsubmsgdef(lua_State* L, const upb_FieldDef* f) { + const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); + assert(m); + lupb_wrapper_pushwrapper(L, -1, m, LUPB_MSGDEF); + lua_replace(L, -2); /* Replace msgdef with submsgdef. */ +} + +/* lupb_FieldDef **************************************************************/ + +const upb_FieldDef* lupb_FieldDef_check(lua_State* L, int narg) { + return lupb_wrapper_check(L, narg, LUPB_FIELDDEF); +} + +static int lupb_FieldDef_ContainingOneof(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + const upb_OneofDef* o = upb_FieldDef_ContainingOneof(f); + lupb_wrapper_pushwrapper(L, 1, o, LUPB_ONEOFDEF); + return 1; +} + +static int lupb_FieldDef_ContainingType(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + const upb_MessageDef* m = upb_FieldDef_ContainingType(f); + lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF); + return 1; +} + +static int lupb_FieldDef_Default(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + upb_CType type = upb_FieldDef_CType(f); + if (type == kUpb_CType_Message) { + return luaL_error(L, "Message fields do not have explicit defaults."); + } + lupb_pushmsgval(L, 0, type, upb_FieldDef_Default(f)); + return 1; +} + +static int lupb_FieldDef_Type(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushnumber(L, upb_FieldDef_Type(f)); + return 1; +} + +static int lupb_FieldDef_HasSubDef(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushboolean(L, upb_FieldDef_HasSubDef(f)); + return 1; +} + +static int lupb_FieldDef_Index(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushinteger(L, upb_FieldDef_Index(f)); + return 1; +} + +static int lupb_FieldDef_IsExtension(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushboolean(L, upb_FieldDef_IsExtension(f)); + return 1; +} + +static int lupb_FieldDef_Label(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushinteger(L, upb_FieldDef_Label(f)); + return 1; +} + +static int lupb_FieldDef_Name(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushstring(L, upb_FieldDef_Name(f)); + return 1; +} + +static int lupb_FieldDef_Number(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + int32_t num = upb_FieldDef_Number(f); + if (num) { + lua_pushinteger(L, num); + } else { + lua_pushnil(L); + } + return 1; +} + +static int lupb_FieldDef_IsPacked(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushboolean(L, upb_FieldDef_IsPacked(f)); + return 1; +} + +static int lupb_FieldDef_MessageSubDef(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f); + lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF); + return 1; +} + +static int lupb_FieldDef_EnumSubDef(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + const upb_EnumDef* e = upb_FieldDef_EnumSubDef(f); + lupb_wrapper_pushwrapper(L, 1, e, LUPB_ENUMDEF); + return 1; +} + +static int lupb_FieldDef_CType(lua_State* L) { + const upb_FieldDef* f = lupb_FieldDef_check(L, 1); + lua_pushinteger(L, upb_FieldDef_CType(f)); + return 1; +} + +static const struct luaL_Reg lupb_FieldDef_m[] = { + {"containing_oneof", lupb_FieldDef_ContainingOneof}, + {"containing_type", lupb_FieldDef_ContainingType}, + {"default", lupb_FieldDef_Default}, + {"descriptor_type", lupb_FieldDef_Type}, + {"has_subdef", lupb_FieldDef_HasSubDef}, + {"index", lupb_FieldDef_Index}, + {"is_extension", lupb_FieldDef_IsExtension}, + {"label", lupb_FieldDef_Label}, + {"name", lupb_FieldDef_Name}, + {"number", lupb_FieldDef_Number}, + {"packed", lupb_FieldDef_IsPacked}, + {"msgsubdef", lupb_FieldDef_MessageSubDef}, + {"enumsubdef", lupb_FieldDef_EnumSubDef}, + {"type", lupb_FieldDef_CType}, + {NULL, NULL}}; + +/* lupb_OneofDef **************************************************************/ + +const upb_OneofDef* lupb_OneofDef_check(lua_State* L, int narg) { + return lupb_wrapper_check(L, narg, LUPB_ONEOFDEF); +} + +static int lupb_OneofDef_ContainingType(lua_State* L) { + const upb_OneofDef* o = lupb_OneofDef_check(L, 1); + const upb_MessageDef* m = upb_OneofDef_ContainingType(o); + lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF); + return 1; +} + +static int lupb_OneofDef_Field(lua_State* L) { + const upb_OneofDef* o = lupb_OneofDef_check(L, 1); + int32_t idx = lupb_checkint32(L, 2); + int count = upb_OneofDef_FieldCount(o); + + if (idx < 0 || idx >= count) { + const char* msg = + lua_pushfstring(L, "index %d exceeds field count %d", idx, count); + return luaL_argerror(L, 2, msg); + } + + lupb_wrapper_pushwrapper(L, 1, upb_OneofDef_Field(o, idx), LUPB_FIELDDEF); + return 1; +} + +static int lupb_oneofiter_next(lua_State* L) { + const upb_OneofDef* o = lupb_OneofDef_check(L, lua_upvalueindex(1)); + int* index = lua_touserdata(L, lua_upvalueindex(2)); + const upb_FieldDef* f; + if (*index == upb_OneofDef_FieldCount(o)) return 0; + f = upb_OneofDef_Field(o, (*index)++); + lupb_wrapper_pushwrapper(L, lua_upvalueindex(1), f, LUPB_FIELDDEF); + return 1; +} + +static int lupb_OneofDef_Fields(lua_State* L) { + int* index = lua_newuserdata(L, sizeof(int)); + lupb_OneofDef_check(L, 1); + *index = 0; + + /* Closure upvalues are: oneofdef, index. */ + lua_pushcclosure(L, &lupb_oneofiter_next, 2); + return 1; +} + +static int lupb_OneofDef_len(lua_State* L) { + const upb_OneofDef* o = lupb_OneofDef_check(L, 1); + lua_pushinteger(L, upb_OneofDef_FieldCount(o)); + return 1; +} + +/* lupb_OneofDef_lookupfield() + * + * Handles: + * oneof.lookup_field(field_number) + * oneof.lookup_field(field_name) + */ +static int lupb_OneofDef_lookupfield(lua_State* L) { + const upb_OneofDef* o = lupb_OneofDef_check(L, 1); + const upb_FieldDef* f; + + switch (lua_type(L, 2)) { + case LUA_TNUMBER: + f = upb_OneofDef_LookupNumber(o, lua_tointeger(L, 2)); + break; + case LUA_TSTRING: + f = upb_OneofDef_LookupName(o, lua_tostring(L, 2)); + break; + default: { + const char* msg = lua_pushfstring(L, "number or string expected, got %s", + luaL_typename(L, 2)); + return luaL_argerror(L, 2, msg); + } + } + + lupb_wrapper_pushwrapper(L, 1, f, LUPB_FIELDDEF); + return 1; +} + +static int lupb_OneofDef_Name(lua_State* L) { + const upb_OneofDef* o = lupb_OneofDef_check(L, 1); + lua_pushstring(L, upb_OneofDef_Name(o)); + return 1; +} + +static const struct luaL_Reg lupb_OneofDef_m[] = { + {"containing_type", lupb_OneofDef_ContainingType}, + {"field", lupb_OneofDef_Field}, + {"fields", lupb_OneofDef_Fields}, + {"lookup_field", lupb_OneofDef_lookupfield}, + {"name", lupb_OneofDef_Name}, + {NULL, NULL}}; + +static const struct luaL_Reg lupb_OneofDef_mm[] = {{"__len", lupb_OneofDef_len}, + {NULL, NULL}}; + +/* lupb_MessageDef + * ****************************************************************/ + +typedef struct { + const upb_MessageDef* md; +} lupb_MessageDef; + +const upb_MessageDef* lupb_MessageDef_check(lua_State* L, int narg) { + return lupb_wrapper_check(L, narg, LUPB_MSGDEF); +} + +static int lupb_MessageDef_FieldCount(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushinteger(L, upb_MessageDef_FieldCount(m)); + return 1; +} + +static int lupb_MessageDef_OneofCount(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushinteger(L, upb_MessageDef_OneofCount(m)); + return 1; +} + +static bool lupb_MessageDef_pushnested(lua_State* L, int msgdef, int name) { + const upb_MessageDef* m = lupb_MessageDef_check(L, msgdef); + lupb_wrapper_pushdefpool(L, msgdef); + upb_DefPool* defpool = lupb_DefPool_check(L, -1); + lua_pop(L, 1); + + /* Construct full package.Message.SubMessage name. */ + lua_pushstring(L, upb_MessageDef_FullName(m)); + lua_pushstring(L, "."); + lua_pushvalue(L, name); + lua_concat(L, 3); + const char* nested_name = lua_tostring(L, -1); + + /* Try lookup. */ + const upb_MessageDef* nested = + upb_DefPool_FindMessageByName(defpool, nested_name); + if (!nested) return false; + lupb_wrapper_pushwrapper(L, msgdef, nested, LUPB_MSGDEF); + return true; +} + +/* lupb_MessageDef_Field() + * + * Handles: + * msg.field(field_number) -> fielddef + * msg.field(field_name) -> fielddef + */ +static int lupb_MessageDef_Field(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + const upb_FieldDef* f; + + switch (lua_type(L, 2)) { + case LUA_TNUMBER: + f = upb_MessageDef_FindFieldByNumber(m, lua_tointeger(L, 2)); + break; + case LUA_TSTRING: + f = upb_MessageDef_FindFieldByName(m, lua_tostring(L, 2)); + break; + default: { + const char* msg = lua_pushfstring(L, "number or string expected, got %s", + luaL_typename(L, 2)); + return luaL_argerror(L, 2, msg); + } + } + + lupb_wrapper_pushwrapper(L, 1, f, LUPB_FIELDDEF); + return 1; +} + +/* lupb_MessageDef_FindByNameWithSize() + * + * Handles: + * msg.lookup_name(name) -> fielddef or oneofdef + */ +static int lupb_MessageDef_FindByNameWithSize(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + const upb_FieldDef* f; + const upb_OneofDef* o; + + if (!upb_MessageDef_FindByName(m, lua_tostring(L, 2), &f, &o)) { + lua_pushnil(L); + } else if (o) { + lupb_wrapper_pushwrapper(L, 1, o, LUPB_ONEOFDEF); + } else { + lupb_wrapper_pushwrapper(L, 1, f, LUPB_FIELDDEF); + } + + return 1; +} + +/* lupb_MessageDef_Name() + * + * Handles: + * msg.name() -> string + */ +static int lupb_MessageDef_Name(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushstring(L, upb_MessageDef_Name(m)); + return 1; +} + +static int lupb_msgfielditer_next(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, lua_upvalueindex(1)); + int* index = lua_touserdata(L, lua_upvalueindex(2)); + const upb_FieldDef* f; + if (*index == upb_MessageDef_FieldCount(m)) return 0; + f = upb_MessageDef_Field(m, (*index)++); + lupb_wrapper_pushwrapper(L, lua_upvalueindex(1), f, LUPB_FIELDDEF); + return 1; +} + +static int lupb_MessageDef_Fields(lua_State* L) { + int* index = lua_newuserdata(L, sizeof(int)); + lupb_MessageDef_check(L, 1); + *index = 0; + + /* Closure upvalues are: msgdef, index. */ + lua_pushcclosure(L, &lupb_msgfielditer_next, 2); + return 1; +} + +static int lupb_MessageDef_File(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + const upb_FileDef* file = upb_MessageDef_File(m); + lupb_wrapper_pushwrapper(L, 1, file, LUPB_FILEDEF); + return 1; +} + +static int lupb_MessageDef_FullName(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushstring(L, upb_MessageDef_FullName(m)); + return 1; +} + +static int lupb_MessageDef_index(lua_State* L) { + if (!lupb_MessageDef_pushnested(L, 1, 2)) { + luaL_error(L, "No such nested message"); + } + return 1; +} + +static int lupb_msgoneofiter_next(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, lua_upvalueindex(1)); + int* index = lua_touserdata(L, lua_upvalueindex(2)); + const upb_OneofDef* o; + if (*index == upb_MessageDef_OneofCount(m)) return 0; + o = upb_MessageDef_Oneof(m, (*index)++); + lupb_wrapper_pushwrapper(L, lua_upvalueindex(1), o, LUPB_ONEOFDEF); + return 1; +} + +static int lupb_MessageDef_Oneofs(lua_State* L) { + int* index = lua_newuserdata(L, sizeof(int)); + lupb_MessageDef_check(L, 1); + *index = 0; + + /* Closure upvalues are: msgdef, index. */ + lua_pushcclosure(L, &lupb_msgoneofiter_next, 2); + return 1; +} + +static int lupb_MessageDef_IsMapEntry(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushboolean(L, upb_MessageDef_IsMapEntry(m)); + return 1; +} + +static int lupb_MessageDef_Syntax(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushinteger(L, upb_MessageDef_Syntax(m)); + return 1; +} + +static int lupb_MessageDef_tostring(lua_State* L) { + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + lua_pushfstring(L, "", + upb_MessageDef_FullName(m), + (int)upb_MessageDef_FieldCount(m)); + return 1; +} + +static const struct luaL_Reg lupb_MessageDef_mm[] = { + {"__call", lupb_MessageDef_call}, + {"__index", lupb_MessageDef_index}, + {"__len", lupb_MessageDef_FieldCount}, + {"__tostring", lupb_MessageDef_tostring}, + {NULL, NULL}}; + +static const struct luaL_Reg lupb_MessageDef_m[] = { + {"field", lupb_MessageDef_Field}, + {"fields", lupb_MessageDef_Fields}, + {"field_count", lupb_MessageDef_FieldCount}, + {"file", lupb_MessageDef_File}, + {"full_name", lupb_MessageDef_FullName}, + {"lookup_name", lupb_MessageDef_FindByNameWithSize}, + {"name", lupb_MessageDef_Name}, + {"oneof_count", lupb_MessageDef_OneofCount}, + {"oneofs", lupb_MessageDef_Oneofs}, + {"syntax", lupb_MessageDef_Syntax}, + {"_map_entry", lupb_MessageDef_IsMapEntry}, + {NULL, NULL}}; + +/* lupb_EnumDef ***************************************************************/ + +const upb_EnumDef* lupb_EnumDef_check(lua_State* L, int narg) { + return lupb_wrapper_check(L, narg, LUPB_ENUMDEF); +} + +static int lupb_EnumDef_len(lua_State* L) { + const upb_EnumDef* e = lupb_EnumDef_check(L, 1); + lua_pushinteger(L, upb_EnumDef_ValueCount(e)); + return 1; +} + +static int lupb_EnumDef_File(lua_State* L) { + const upb_EnumDef* e = lupb_EnumDef_check(L, 1); + const upb_FileDef* file = upb_EnumDef_File(e); + lupb_wrapper_pushwrapper(L, 1, file, LUPB_FILEDEF); + return 1; +} + +/* lupb_EnumDef_Value() + * + * Handles: + * enum.value(number) -> enumval + * enum.value(name) -> enumval + */ +static int lupb_EnumDef_Value(lua_State* L) { + const upb_EnumDef* e = lupb_EnumDef_check(L, 1); + const upb_EnumValueDef* ev; + + switch (lua_type(L, 2)) { + case LUA_TNUMBER: + ev = upb_EnumDef_FindValueByNumber(e, lupb_checkint32(L, 2)); + break; + case LUA_TSTRING: + ev = upb_EnumDef_FindValueByName(e, lua_tostring(L, 2)); + break; + default: { + const char* msg = lua_pushfstring(L, "number or string expected, got %s", + luaL_typename(L, 2)); + return luaL_argerror(L, 2, msg); + } + } + + lupb_wrapper_pushwrapper(L, 1, ev, LUPB_ENUMVALDEF); + return 1; +} + +static const struct luaL_Reg lupb_EnumDef_mm[] = {{"__len", lupb_EnumDef_len}, + {NULL, NULL}}; + +static const struct luaL_Reg lupb_EnumDef_m[] = { + {"file", lupb_EnumDef_File}, {"value", lupb_EnumDef_Value}, {NULL, NULL}}; + +/* lupb_EnumValueDef + * ************************************************************/ + +const upb_EnumValueDef* lupb_enumvaldef_check(lua_State* L, int narg) { + return lupb_wrapper_check(L, narg, LUPB_ENUMVALDEF); +} + +static int lupb_EnumValueDef_Enum(lua_State* L) { + const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1); + const upb_EnumDef* e = upb_EnumValueDef_Enum(ev); + lupb_wrapper_pushwrapper(L, 1, e, LUPB_ENUMDEF); + return 1; +} + +static int lupb_EnumValueDef_FullName(lua_State* L) { + const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1); + lua_pushstring(L, upb_EnumValueDef_FullName(ev)); + return 1; +} + +static int lupb_EnumValueDef_Name(lua_State* L) { + const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1); + lua_pushstring(L, upb_EnumValueDef_Name(ev)); + return 1; +} + +static int lupb_EnumValueDef_Number(lua_State* L) { + const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1); + lupb_pushint32(L, upb_EnumValueDef_Number(ev)); + return 1; +} + +static const struct luaL_Reg lupb_enumvaldef_m[] = { + {"enum", lupb_EnumValueDef_Enum}, + {"full_name", lupb_EnumValueDef_FullName}, + {"name", lupb_EnumValueDef_Name}, + {"number", lupb_EnumValueDef_Number}, + {NULL, NULL}}; + +/* lupb_FileDef ***************************************************************/ + +const upb_FileDef* lupb_FileDef_check(lua_State* L, int narg) { + return lupb_wrapper_check(L, narg, LUPB_FILEDEF); +} + +static int lupb_FileDef_Dependency(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + int index = luaL_checkint(L, 2); + const upb_FileDef* dep = upb_FileDef_Dependency(f, index); + lupb_wrapper_pushwrapper(L, 1, dep, LUPB_FILEDEF); + return 1; +} + +static int lupb_FileDef_DependencyCount(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + lua_pushnumber(L, upb_FileDef_DependencyCount(f)); + return 1; +} + +static int lupb_FileDef_enum(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + int index = luaL_checkint(L, 2); + const upb_EnumDef* e = upb_FileDef_TopLevelEnum(f, index); + lupb_wrapper_pushwrapper(L, 1, e, LUPB_ENUMDEF); + return 1; +} + +static int lupb_FileDef_enumcount(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + lua_pushnumber(L, upb_FileDef_TopLevelEnumCount(f)); + return 1; +} + +static int lupb_FileDef_msg(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + int index = luaL_checkint(L, 2); + const upb_MessageDef* m = upb_FileDef_TopLevelMessage(f, index); + lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF); + return 1; +} + +static int lupb_FileDef_msgcount(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + lua_pushnumber(L, upb_FileDef_TopLevelMessageCount(f)); + return 1; +} + +static int lupb_FileDef_Name(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + lua_pushstring(L, upb_FileDef_Name(f)); + return 1; +} + +static int lupb_FileDef_Package(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + lua_pushstring(L, upb_FileDef_Package(f)); + return 1; +} + +static int lupb_FileDef_Pool(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + const upb_DefPool* defpool = upb_FileDef_Pool(f); + lupb_wrapper_pushwrapper(L, 1, defpool, LUPB_SYMTAB); + return 1; +} + +static int lupb_FileDef_Syntax(lua_State* L) { + const upb_FileDef* f = lupb_FileDef_check(L, 1); + lua_pushnumber(L, upb_FileDef_Syntax(f)); + return 1; +} + +static const struct luaL_Reg lupb_FileDef_m[] = { + {"dep", lupb_FileDef_Dependency}, + {"depcount", lupb_FileDef_DependencyCount}, + {"enum", lupb_FileDef_enum}, + {"enumcount", lupb_FileDef_enumcount}, + {"msg", lupb_FileDef_msg}, + {"msgcount", lupb_FileDef_msgcount}, + {"name", lupb_FileDef_Name}, + {"package", lupb_FileDef_Package}, + {"defpool", lupb_FileDef_Pool}, + {"syntax", lupb_FileDef_Syntax}, + {NULL, NULL}}; + +/* lupb_DefPool + * ****************************************************************/ + +/* The defpool owns all defs. Thus GC-rooting the defpool ensures that all + * underlying defs stay alive. + * + * The defpool's userval is a cache of def* -> object. */ + +#define LUPB_CACHE_INDEX 1 + +typedef struct { + upb_DefPool* defpool; +} lupb_DefPool; + +upb_DefPool* lupb_DefPool_check(lua_State* L, int narg) { + lupb_DefPool* ldefpool = luaL_checkudata(L, narg, LUPB_SYMTAB); + if (!ldefpool->defpool) { + luaL_error(L, "called into dead object"); + } + return ldefpool->defpool; +} + +void lupb_DefPool_pushwrapper(lua_State* L, int narg, const void* def, + const char* type) { + narg = lua_absindex(L, narg); + assert(luaL_testudata(L, narg, LUPB_SYMTAB)); + + if (def == NULL) { + lua_pushnil(L); + return; + } + + lua_getiuservalue(L, narg, LUPB_CACHE_INDEX); /* Get cache. */ + + /* Index by "def" pointer. */ + lua_rawgetp(L, -1, def); + + /* Stack is now: cache, cached value. */ + if (lua_isnil(L, -1)) { + /* Create new wrapper. */ + lupb_wrapper* w = lupb_newuserdata(L, sizeof(*w), 1, type); + w->def = def; + lua_replace(L, -2); /* Replace nil */ + + /* Set defpool as userval. */ + lua_pushvalue(L, narg); + lua_setiuservalue(L, -2, LUPB_SYMTAB_INDEX); + + /* Add wrapper to the the cache. */ + lua_pushvalue(L, -1); + lua_rawsetp(L, -3, def); + } + + lua_replace(L, -2); /* Remove cache, leaving only the wrapper. */ +} + +/* upb_DefPool_New() + * + * Handles: + * upb.DefPool() -> + */ +static int lupb_DefPool_New(lua_State* L) { + lupb_DefPool* ldefpool = + lupb_newuserdata(L, sizeof(*ldefpool), 1, LUPB_SYMTAB); + ldefpool->defpool = upb_DefPool_New(); + + /* Create our object cache. */ + lua_newtable(L); + + /* Cache metatable: specifies that values are weak. */ + lua_createtable(L, 0, 1); + lua_pushstring(L, "v"); + lua_setfield(L, -2, "__mode"); + lua_setmetatable(L, -2); + + /* Put the defpool itself in the cache metatable. */ + lua_pushvalue(L, -2); + lua_rawsetp(L, -2, ldefpool->defpool); + + /* Set the cache as our userval. */ + lua_setiuservalue(L, -2, LUPB_CACHE_INDEX); + + return 1; +} + +static int lupb_DefPool_gc(lua_State* L) { + lupb_DefPool* ldefpool = luaL_checkudata(L, 1, LUPB_SYMTAB); + upb_DefPool_Free(ldefpool->defpool); + ldefpool->defpool = NULL; + return 0; +} + +static int lupb_DefPool_AddFile(lua_State* L) { + size_t len; + upb_DefPool* s = lupb_DefPool_check(L, 1); + const char* str = luaL_checklstring(L, 2, &len); + upb_Arena* arena = lupb_Arena_pushnew(L); + const google_protobuf_FileDescriptorProto* file; + const upb_FileDef* file_def; + upb_Status status; + + upb_Status_Clear(&status); + file = google_protobuf_FileDescriptorProto_parse(str, len, arena); + + if (!file) { + luaL_argerror(L, 2, "failed to parse descriptor"); + } + + file_def = upb_DefPool_AddFile(s, file, &status); + lupb_checkstatus(L, &status); + + lupb_DefPool_pushwrapper(L, 1, file_def, LUPB_FILEDEF); + + return 1; +} + +static int lupb_DefPool_addset(lua_State* L) { + size_t i, n, len; + const google_protobuf_FileDescriptorProto* const* files; + google_protobuf_FileDescriptorSet* set; + upb_DefPool* s = lupb_DefPool_check(L, 1); + const char* str = luaL_checklstring(L, 2, &len); + upb_Arena* arena = lupb_Arena_pushnew(L); + upb_Status status; + + upb_Status_Clear(&status); + set = google_protobuf_FileDescriptorSet_parse(str, len, arena); + + if (!set) { + luaL_argerror(L, 2, "failed to parse descriptor"); + } + + files = google_protobuf_FileDescriptorSet_file(set, &n); + for (i = 0; i < n; i++) { + upb_DefPool_AddFile(s, files[i], &status); + lupb_checkstatus(L, &status); + } + + return 0; +} + +static int lupb_DefPool_FindMessageByName(lua_State* L) { + const upb_DefPool* s = lupb_DefPool_check(L, 1); + const upb_MessageDef* m = + upb_DefPool_FindMessageByName(s, luaL_checkstring(L, 2)); + lupb_DefPool_pushwrapper(L, 1, m, LUPB_MSGDEF); + return 1; +} + +static int lupb_DefPool_FindEnumByName(lua_State* L) { + const upb_DefPool* s = lupb_DefPool_check(L, 1); + const upb_EnumDef* e = upb_DefPool_FindEnumByName(s, luaL_checkstring(L, 2)); + lupb_DefPool_pushwrapper(L, 1, e, LUPB_ENUMDEF); + return 1; +} + +static int lupb_DefPool_FindEnumByNameval(lua_State* L) { + const upb_DefPool* s = lupb_DefPool_check(L, 1); + const upb_EnumValueDef* e = + upb_DefPool_FindEnumByNameval(s, luaL_checkstring(L, 2)); + lupb_DefPool_pushwrapper(L, 1, e, LUPB_ENUMVALDEF); + return 1; +} + +static int lupb_DefPool_tostring(lua_State* L) { + lua_pushfstring(L, ""); + return 1; +} + +static const struct luaL_Reg lupb_DefPool_m[] = { + {"add_file", lupb_DefPool_AddFile}, + {"add_set", lupb_DefPool_addset}, + {"lookup_msg", lupb_DefPool_FindMessageByName}, + {"lookup_enum", lupb_DefPool_FindEnumByName}, + {"lookup_enumval", lupb_DefPool_FindEnumByNameval}, + {NULL, NULL}}; + +static const struct luaL_Reg lupb_DefPool_mm[] = { + {"__gc", lupb_DefPool_gc}, + {"__tostring", lupb_DefPool_tostring}, + {NULL, NULL}}; + +/* lupb toplevel **************************************************************/ + +static void lupb_setfieldi(lua_State* L, const char* field, int i) { + lua_pushinteger(L, i); + lua_setfield(L, -2, field); +} + +static const struct luaL_Reg lupbdef_toplevel_m[] = { + {"DefPool", lupb_DefPool_New}, {NULL, NULL}}; + +void lupb_def_registertypes(lua_State* L) { + lupb_setfuncs(L, lupbdef_toplevel_m); + + /* Register types. */ + lupb_register_type(L, LUPB_ENUMDEF, lupb_EnumDef_m, lupb_EnumDef_mm); + lupb_register_type(L, LUPB_ENUMVALDEF, lupb_enumvaldef_m, NULL); + lupb_register_type(L, LUPB_FIELDDEF, lupb_FieldDef_m, NULL); + lupb_register_type(L, LUPB_FILEDEF, lupb_FileDef_m, NULL); + lupb_register_type(L, LUPB_MSGDEF, lupb_MessageDef_m, lupb_MessageDef_mm); + lupb_register_type(L, LUPB_ONEOFDEF, lupb_OneofDef_m, lupb_OneofDef_mm); + lupb_register_type(L, LUPB_SYMTAB, lupb_DefPool_m, lupb_DefPool_mm); + + /* Register constants. */ + lupb_setfieldi(L, "LABEL_OPTIONAL", kUpb_Label_Optional); + lupb_setfieldi(L, "LABEL_REQUIRED", kUpb_Label_Required); + lupb_setfieldi(L, "LABEL_REPEATED", kUpb_Label_Repeated); + + lupb_setfieldi(L, "TYPE_DOUBLE", kUpb_CType_Double); + lupb_setfieldi(L, "TYPE_FLOAT", kUpb_CType_Float); + lupb_setfieldi(L, "TYPE_INT64", kUpb_CType_Int64); + lupb_setfieldi(L, "TYPE_UINT64", kUpb_CType_UInt64); + lupb_setfieldi(L, "TYPE_INT32", kUpb_CType_Int32); + lupb_setfieldi(L, "TYPE_BOOL", kUpb_CType_Bool); + lupb_setfieldi(L, "TYPE_STRING", kUpb_CType_String); + lupb_setfieldi(L, "TYPE_MESSAGE", kUpb_CType_Message); + lupb_setfieldi(L, "TYPE_BYTES", kUpb_CType_Bytes); + lupb_setfieldi(L, "TYPE_UINT32", kUpb_CType_UInt32); + lupb_setfieldi(L, "TYPE_ENUM", kUpb_CType_Enum); + + lupb_setfieldi(L, "DESCRIPTOR_TYPE_DOUBLE", kUpb_FieldType_Double); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_FLOAT", kUpb_FieldType_Float); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_INT64", kUpb_FieldType_Int64); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_UINT64", kUpb_FieldType_UInt64); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_INT32", kUpb_FieldType_Int32); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_FIXED64", kUpb_FieldType_Fixed64); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_FIXED32", kUpb_FieldType_Fixed32); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_BOOL", kUpb_FieldType_Bool); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_STRING", kUpb_FieldType_String); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_GROUP", kUpb_FieldType_Group); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_MESSAGE", kUpb_FieldType_Message); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_BYTES", kUpb_FieldType_Bytes); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_UINT32", kUpb_FieldType_UInt32); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_ENUM", kUpb_FieldType_Enum); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_SFIXED32", kUpb_FieldType_SFixed32); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_SFIXED64", kUpb_FieldType_SFixed64); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_SINT32", kUpb_FieldType_SInt32); + lupb_setfieldi(L, "DESCRIPTOR_TYPE_SINT64", kUpb_FieldType_SInt64); + + lupb_setfieldi(L, "SYNTAX_PROTO2", kUpb_Syntax_Proto2); + lupb_setfieldi(L, "SYNTAX_PROTO3", kUpb_Syntax_Proto3); +} diff --git a/upb/bindings/lua/lua_proto_library.bzl b/archive/lua/lua_proto_library.bzl similarity index 50% rename from upb/bindings/lua/lua_proto_library.bzl rename to archive/lua/lua_proto_library.bzl index d6ac301ad8..cc1486a60b 100644 --- a/upb/bindings/lua/lua_proto_library.bzl +++ b/archive/lua/lua_proto_library.bzl @@ -1,8 +1,41 @@ +# 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. + +"""lua_proto_library(): a rule for building Lua protos.""" + load("@bazel_skylib//lib:paths.bzl", "paths") # Generic support code ######################################################### -_is_bazel = not hasattr(native, "genmpm") +# begin:github_only +_is_google3 = False +# end:github_only + +# begin:google_only +# _is_google3 = True +# end:google_only def _get_real_short_path(file): # For some reason, files from other archives have short paths that look like: @@ -14,25 +47,36 @@ def _get_real_short_path(file): # Sometimes it has another few prefixes like: # _virtual_imports/any_proto/google/protobuf/any.proto + # benchmarks/_virtual_imports/100_msgs_proto/benchmarks/100_msgs.proto # We want just google/protobuf/any.proto. - if short_path.startswith("_virtual_imports"): - short_path = short_path.split("/", 2)[-1] + virtual_imports = "_virtual_imports/" + if virtual_imports in short_path: + short_path = short_path.split(virtual_imports)[1].split("/", 1)[1] return short_path -def _get_real_root(file): +def _get_real_root(ctx, file): real_short_path = _get_real_short_path(file) - return file.path[:-len(real_short_path) - 1] + root = file.path[:-len(real_short_path) - 1] + if not _is_google3 and ctx.rule.attr.strip_import_prefix: + root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:]) + return root def _generate_output_file(ctx, src, extension): + package = ctx.label.package + if not _is_google3 and ctx.rule.attr.strip_import_prefix and ctx.rule.attr.strip_import_prefix != "/": + package = package[len(ctx.rule.attr.strip_import_prefix):] real_short_path = _get_real_short_path(src) - real_short_path = paths.relativize(real_short_path, ctx.label.package) + real_short_path = paths.relativize(real_short_path, package) output_filename = paths.replace_extension(real_short_path, extension) ret = ctx.actions.declare_file(output_filename) return ret # upb_proto_library / upb_proto_reflection_library shared code ################# -_LuaFiles = provider(fields = ["files"]) +_LuaFilesInfo = provider( + "A set of lua files generated from .proto files", + fields = ["files"], +) def _compile_upb_protos(ctx, proto_info, proto_sources): files = [_generate_output_file(ctx, name, "_pb.lua") for name in proto_sources] @@ -46,7 +90,7 @@ def _compile_upb_protos(ctx, proto_info, proto_sources): outputs = files, executable = ctx.executable._protoc, arguments = [ - "--lua_out=" + _get_real_root(files[0]), + "--lua_out=" + _get_real_root(ctx, files[0]), "--plugin=protoc-gen-lua=" + ctx.executable._upbc.path, "--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets]), ] + @@ -59,9 +103,9 @@ def _lua_proto_rule_impl(ctx): if len(ctx.attr.deps) != 1: fail("only one deps dependency allowed.") dep = ctx.attr.deps[0] - if _LuaFiles not in dep: - fail("proto_library rule must generate _LuaFiles (aspect should have handled this).") - files = dep[_LuaFiles].files + if _LuaFilesInfo not in dep: + fail("proto_library rule must generate _LuaFilesInfo (aspect should have handled this).") + files = dep[_LuaFilesInfo].files return [ DefaultInfo( files = files, @@ -73,8 +117,8 @@ def _lua_proto_library_aspect_impl(target, ctx): proto_info = target[ProtoInfo] files = _compile_upb_protos(ctx, proto_info, proto_info.direct_sources) deps = ctx.rule.attr.deps - transitive = [dep[_LuaFiles].files for dep in deps if _LuaFiles in dep] - return [_LuaFiles(files = depset(direct = files, transitive = transitive))] + transitive = [dep[_LuaFilesInfo].files for dep in deps if _LuaFilesInfo in dep] + return [_LuaFilesInfo(files = depset(direct = files, transitive = transitive))] # lua_proto_library() ########################################################## @@ -82,17 +126,17 @@ _lua_proto_library_aspect = aspect( attrs = { "_upbc": attr.label( executable = True, - cfg = "host", - default = "//upb/bindings/lua:protoc-gen-lua", + cfg = "exec", + default = "//lua:protoc-gen-lua", ), "_protoc": attr.label( executable = True, - cfg = "host", + cfg = "exec", default = "@com_google_protobuf//:protoc", ), }, implementation = _lua_proto_library_aspect_impl, - provides = [_LuaFiles], + provides = [_LuaFilesInfo], attr_aspects = ["deps"], fragments = ["cpp"], ) diff --git a/archive/lua/main.c b/archive/lua/main.c new file mode 100644 index 0000000000..6d2b56da9c --- /dev/null +++ b/archive/lua/main.c @@ -0,0 +1,96 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include +#include + +#include "lua/upb.h" + +lua_State* L; + +static void interrupt(lua_State* L, lua_Debug* ar) { + (void)ar; + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "SIGINT"); +} + +static void sighandler(int i) { + fprintf(stderr, "Signal!\n"); + signal(i, SIG_DFL); + lua_sethook(L, interrupt, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + +const char* init = + "package.preload['lupb'] = ... " + "package.path = '" + "./?.lua;" + "./third_party/lunit/?.lua;" + "external/com_google_protobuf/?.lua;" + "external/com_google_protobuf/src/?.lua;" + "bazel-bin/?.lua;" + "bazel-bin/external/com_google_protobuf/src/?.lua;" + "bazel-bin/external/com_google_protobuf/?.lua;" + "lua/?.lua;" + // These additional paths handle the case where this test is invoked from + // the protobuf repo's Bazel workspace. + "external/upb/?.lua;" + "external/upb/third_party/lunit/?.lua;" + "src/?.lua;" + "bazel-bin/external/upb/?.lua;" + "external/upb/lua/?.lua" + "'"; + +int main(int argc, char** argv) { + if (argc < 2) { + fprintf(stderr, "missing argument with path to .lua file\n"); + return 1; + } + + int ret = 0; + L = luaL_newstate(); + luaL_openlibs(L); + lua_pushcfunction(L, luaopen_lupb); + ret = luaL_loadstring(L, init); + lua_pushcfunction(L, luaopen_lupb); + + signal(SIGINT, sighandler); + ret = ret || lua_pcall(L, 1, LUA_MULTRET, 0) || luaL_dofile(L, argv[1]); + signal(SIGINT, SIG_DFL); + + if (ret) { + fprintf(stderr, "error testing Lua: %s\n", lua_tostring(L, -1)); + ret = 1; + } + + lua_close(L); + return ret; +} diff --git a/archive/lua/msg.c b/archive/lua/msg.c new file mode 100644 index 0000000000..bdec7a2d09 --- /dev/null +++ b/archive/lua/msg.c @@ -0,0 +1,1118 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* + * lupb_Message -- Message/Array/Map objects in Lua/C that wrap upb + */ + +#include +#include +#include +#include +#include + +#include "lauxlib.h" +#include "lua/upb.h" +#include "upb/collections/map.h" +#include "upb/json/decode.h" +#include "upb/json/encode.h" +#include "upb/message/message.h" +#include "upb/port/def.inc" +#include "upb/reflection/message.h" +#include "upb/text/encode.h" + +/* + * Message/Map/Array objects. These objects form a directed graph: a message + * can contain submessages, arrays, and maps, which can then point to other + * messages. This graph can technically be cyclic, though this is an error and + * a cyclic graph cannot be serialized. So it's better to think of this as a + * tree of objects. + * + * The actual data exists at the upb level (upb_Message, upb_Map, upb_Array), + * independently of Lua. The upb objects contain all the canonical data and + * edges between objects. Lua wrapper objects expose the upb objects to Lua, + * but ultimately they are just wrappers. They pass through all reads and + * writes to the underlying upb objects. + * + * Each upb object lives in a upb arena. We have a Lua object to wrap the upb + * arena, but arenas are never exposed to the user. The Lua arena object just + * serves to own the upb arena and free it at the proper time, once the Lua GC + * has determined that there are no more references to anything that lives in + * that arena. All wrapper objects strongly reference the arena to which they + * belong. + * + * A global object cache stores a mapping of C pointer (upb_Message*, + * upb_Array*, upb_Map*) to a corresponding Lua wrapper. These references are + * weak so that the wrappers can be collected if they are no longer needed. A + * new wrapper object can always be recreated later. + * + * +-----+ + * lupb_Arena |cache|-weak-+ + * | ^ +-----+ | + * | | V + * Lua level | +------------lupb_Message + * ----------------|-----------------|------------------------------------------ + * upb level | | + * | +----V----------------------------------+ + * +->upb_Arena | upb_Message ...(empty arena storage) | + * +---------------------------------------+ + * + * If the user creates a reference between two objects that have different + * arenas, we need to fuse the two arenas together, so that the blocks will + * outlive both arenas. + * + * +-------------------------->(fused)<----------------+ + * | | + * V +-----+ V + * lupb_Arena +-weak-|cache|-weak-+ lupb_Arena + * | ^ | +-----+ | ^ | + * | | V V | | + * Lua level | +------------lupb_Message lupb_Message--+ | + * ----------------|-----------------|----------------------|-----------|------ + * upb level | | | | + * | +----V--------+ +----V--------+ V + * +->upb_Arena | upb_Message | | upb_Message | upb_Arena + * +------|------+ +--^----------+ + * +------------------+ + * Key invariants: + * 1. every wrapper references the arena that contains it. + * 2. every fused arena includes all arenas that own upb objects reachable + * from that arena. In other words, when a wrapper references an arena, + * this is sufficient to ensure that any upb object reachable from that + * wrapper will stay alive. + * + * Additionally, every message object contains a strong reference to the + * corresponding Descriptor object. Likewise, array/map objects reference a + * Descriptor object if they are typed to store message values. + */ + +#define LUPB_ARENA "lupb.arena" +#define LUPB_ARRAY "lupb.array" +#define LUPB_MAP "lupb.map" +#define LUPB_MSG "lupb.msg" + +#define LUPB_ARENA_INDEX 1 +#define LUPB_MSGDEF_INDEX 2 /* For msg, and map/array that store msg */ + +static void lupb_Message_Newmsgwrapper(lua_State* L, int narg, + upb_MessageValue val); +static upb_Message* lupb_msg_check(lua_State* L, int narg); + +static upb_CType lupb_checkfieldtype(lua_State* L, int narg) { + uint32_t n = lupb_checkuint32(L, narg); + bool ok = n >= kUpb_CType_Bool && n <= kUpb_CType_Bytes; + luaL_argcheck(L, ok, narg, "invalid field type"); + return n; +} + +char cache_key; + +/* lupb_cacheinit() + * + * Creates the global cache used by lupb_cacheget() and lupb_cacheset(). + */ +static void lupb_cacheinit(lua_State* L) { + /* Create our object cache. */ + lua_newtable(L); + + /* Cache metatable gives the cache weak values */ + lua_createtable(L, 0, 1); + lua_pushstring(L, "v"); + lua_setfield(L, -2, "__mode"); + lua_setmetatable(L, -2); + + /* Set cache in the registry. */ + lua_rawsetp(L, LUA_REGISTRYINDEX, &cache_key); +} + +/* lupb_cacheget() + * + * Pushes cache[key] and returns true if this key is present in the cache. + * Otherwise returns false and leaves nothing on the stack. + */ +static bool lupb_cacheget(lua_State* L, const void* key) { + if (key == NULL) { + lua_pushnil(L); + return true; + } + + lua_rawgetp(L, LUA_REGISTRYINDEX, &cache_key); + lua_rawgetp(L, -1, key); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* Pop table, nil. */ + return false; + } else { + lua_replace(L, -2); /* Replace cache table. */ + return true; + } +} + +/* lupb_cacheset() + * + * Sets cache[key] = val, where "val" is the value at the top of the stack. + * Does not pop the value. + */ +static void lupb_cacheset(lua_State* L, const void* key) { + lua_rawgetp(L, LUA_REGISTRYINDEX, &cache_key); + lua_pushvalue(L, -2); + lua_rawsetp(L, -2, key); + lua_pop(L, 1); /* Pop table. */ +} + +/* lupb_Arena *****************************************************************/ + +/* lupb_Arena only exists to wrap a upb_Arena. It is never exposed to users; it + * is an internal memory management detail. Other wrapper objects refer to this + * object from their userdata to keep the arena-owned data alive. + */ + +typedef struct { + upb_Arena* arena; +} lupb_Arena; + +static upb_Arena* lupb_Arena_check(lua_State* L, int narg) { + lupb_Arena* a = luaL_checkudata(L, narg, LUPB_ARENA); + return a->arena; +} + +upb_Arena* lupb_Arena_pushnew(lua_State* L) { + lupb_Arena* a = lupb_newuserdata(L, sizeof(lupb_Arena), 1, LUPB_ARENA); + a->arena = upb_Arena_New(); + return a->arena; +} + +/** + * lupb_Arena_Fuse() + * + * Merges |from| into |to| so that there is a single arena group that contains + * both, and both arenas will point at this new table. */ +static void lupb_Arena_Fuse(lua_State* L, int to, int from) { + upb_Arena* to_arena = lupb_Arena_check(L, to); + upb_Arena* from_arena = lupb_Arena_check(L, from); + upb_Arena_Fuse(to_arena, from_arena); +} + +static void lupb_Arena_Fuseobjs(lua_State* L, int to, int from) { + lua_getiuservalue(L, to, LUPB_ARENA_INDEX); + lua_getiuservalue(L, from, LUPB_ARENA_INDEX); + lupb_Arena_Fuse(L, lua_absindex(L, -2), lua_absindex(L, -1)); + lua_pop(L, 2); +} + +static int lupb_Arena_gc(lua_State* L) { + upb_Arena* a = lupb_Arena_check(L, 1); + upb_Arena_Free(a); + return 0; +} + +static const struct luaL_Reg lupb_Arena_mm[] = {{"__gc", lupb_Arena_gc}, + {NULL, NULL}}; + +/* lupb_Arenaget() + * + * Returns the arena from the given message, array, or map object. + */ +static upb_Arena* lupb_Arenaget(lua_State* L, int narg) { + upb_Arena* arena; + lua_getiuservalue(L, narg, LUPB_ARENA_INDEX); + arena = lupb_Arena_check(L, -1); + lua_pop(L, 1); + return arena; +} + +/* upb <-> Lua type conversion ************************************************/ + +/* Whether string data should be copied into the containing arena. We can + * avoid a copy if the string data is only needed temporarily (like for a map + * lookup). + */ +typedef enum { + LUPB_COPY, /* Copy string data into the arena. */ + LUPB_REF /* Reference the Lua copy of the string data. */ +} lupb_copy_t; + +/** + * lupb_tomsgval() + * + * Converts the given Lua value |narg| to a upb_MessageValue. + */ +static upb_MessageValue lupb_tomsgval(lua_State* L, upb_CType type, int narg, + int container, lupb_copy_t copy) { + upb_MessageValue ret; + switch (type) { + case kUpb_CType_Int32: + case kUpb_CType_Enum: + ret.int32_val = lupb_checkint32(L, narg); + break; + case kUpb_CType_Int64: + ret.int64_val = lupb_checkint64(L, narg); + break; + case kUpb_CType_UInt32: + ret.uint32_val = lupb_checkuint32(L, narg); + break; + case kUpb_CType_UInt64: + ret.uint64_val = lupb_checkuint64(L, narg); + break; + case kUpb_CType_Double: + ret.double_val = lupb_checkdouble(L, narg); + break; + case kUpb_CType_Float: + ret.float_val = lupb_checkfloat(L, narg); + break; + case kUpb_CType_Bool: + ret.bool_val = lupb_checkbool(L, narg); + break; + case kUpb_CType_String: + case kUpb_CType_Bytes: { + size_t len; + const char* ptr = lupb_checkstring(L, narg, &len); + switch (copy) { + case LUPB_COPY: { + upb_Arena* arena = lupb_Arenaget(L, container); + char* data = upb_Arena_Malloc(arena, len); + memcpy(data, ptr, len); + ret.str_val = upb_StringView_FromDataAndSize(data, len); + break; + } + case LUPB_REF: + ret.str_val = upb_StringView_FromDataAndSize(ptr, len); + break; + } + break; + } + case kUpb_CType_Message: + ret.msg_val = lupb_msg_check(L, narg); + /* Typecheck message. */ + lua_getiuservalue(L, container, LUPB_MSGDEF_INDEX); + lua_getiuservalue(L, narg, LUPB_MSGDEF_INDEX); + luaL_argcheck(L, lua_rawequal(L, -1, -2), narg, "message type mismatch"); + lua_pop(L, 2); + break; + } + return ret; +} + +void lupb_pushmsgval(lua_State* L, int container, upb_CType type, + upb_MessageValue val) { + switch (type) { + case kUpb_CType_Int32: + case kUpb_CType_Enum: + lupb_pushint32(L, val.int32_val); + return; + case kUpb_CType_Int64: + lupb_pushint64(L, val.int64_val); + return; + case kUpb_CType_UInt32: + lupb_pushuint32(L, val.uint32_val); + return; + case kUpb_CType_UInt64: + lupb_pushuint64(L, val.uint64_val); + return; + case kUpb_CType_Double: + lua_pushnumber(L, val.double_val); + return; + case kUpb_CType_Float: + lua_pushnumber(L, val.float_val); + return; + case kUpb_CType_Bool: + lua_pushboolean(L, val.bool_val); + return; + case kUpb_CType_String: + case kUpb_CType_Bytes: + lua_pushlstring(L, val.str_val.data, val.str_val.size); + return; + case kUpb_CType_Message: + assert(container); + if (!lupb_cacheget(L, val.msg_val)) { + lupb_Message_Newmsgwrapper(L, container, val); + } + return; + } + LUPB_UNREACHABLE(); +} + +/* lupb_array *****************************************************************/ + +typedef struct { + upb_Array* arr; + upb_CType type; +} lupb_array; + +static lupb_array* lupb_array_check(lua_State* L, int narg) { + return luaL_checkudata(L, narg, LUPB_ARRAY); +} + +/** + * lupb_array_checkindex() + * + * Checks the array index at Lua stack index |narg| to verify that it is an + * integer between 1 and |max|, inclusively. Also corrects it to be zero-based + * for C. + */ +static int lupb_array_checkindex(lua_State* L, int narg, uint32_t max) { + uint32_t n = lupb_checkuint32(L, narg); + luaL_argcheck(L, n != 0 && n <= max, narg, "invalid array index"); + return n - 1; /* Lua uses 1-based indexing. */ +} + +/* lupb_array Public API */ + +/* lupb_Array_New(): + * + * Handles: + * Array(upb.TYPE_INT32) + * Array(message_type) + */ +static int lupb_Array_New(lua_State* L) { + int arg_count = lua_gettop(L); + lupb_array* larray; + upb_Arena* arena; + + if (lua_type(L, 1) == LUA_TNUMBER) { + upb_CType type = lupb_checkfieldtype(L, 1); + larray = lupb_newuserdata(L, sizeof(*larray), 1, LUPB_ARRAY); + larray->type = type; + } else { + lupb_MessageDef_check(L, 1); + larray = lupb_newuserdata(L, sizeof(*larray), 2, LUPB_ARRAY); + larray->type = kUpb_CType_Message; + lua_pushvalue(L, 1); + lua_setiuservalue(L, -2, LUPB_MSGDEF_INDEX); + } + + arena = lupb_Arena_pushnew(L); + lua_setiuservalue(L, -2, LUPB_ARENA_INDEX); + + larray->arr = upb_Array_New(arena, larray->type); + lupb_cacheset(L, larray->arr); + + if (arg_count > 1) { + /* Set initial fields from table. */ + int msg = arg_count + 1; + lua_pushnil(L); + while (lua_next(L, 2) != 0) { + lua_pushvalue(L, -2); /* now stack is key, val, key */ + lua_insert(L, -3); /* now stack is key, key, val */ + lua_settable(L, msg); + } + } + + return 1; +} + +/* lupb_Array_Newindex(): + * + * Handles: + * array[idx] = val + * + * idx can be within the array or one past the end to extend. + */ +static int lupb_Array_Newindex(lua_State* L) { + lupb_array* larray = lupb_array_check(L, 1); + size_t size = upb_Array_Size(larray->arr); + uint32_t n = lupb_array_checkindex(L, 2, size + 1); + upb_MessageValue msgval = lupb_tomsgval(L, larray->type, 3, 1, LUPB_COPY); + + if (n == size) { + upb_Array_Append(larray->arr, msgval, lupb_Arenaget(L, 1)); + } else { + upb_Array_Set(larray->arr, n, msgval); + } + + if (larray->type == kUpb_CType_Message) { + lupb_Arena_Fuseobjs(L, 1, 3); + } + + return 0; /* 1 for chained assignments? */ +} + +/* lupb_array_index(): + * + * Handles: + * array[idx] -> val + * + * idx must be within the array. + */ +static int lupb_array_index(lua_State* L) { + lupb_array* larray = lupb_array_check(L, 1); + size_t size = upb_Array_Size(larray->arr); + uint32_t n = lupb_array_checkindex(L, 2, size); + upb_MessageValue val = upb_Array_Get(larray->arr, n); + + lupb_pushmsgval(L, 1, larray->type, val); + + return 1; +} + +/* lupb_array_len(): + * + * Handles: + * #array -> len + */ +static int lupb_array_len(lua_State* L) { + lupb_array* larray = lupb_array_check(L, 1); + lua_pushnumber(L, upb_Array_Size(larray->arr)); + return 1; +} + +static const struct luaL_Reg lupb_array_mm[] = { + {"__index", lupb_array_index}, + {"__len", lupb_array_len}, + {"__newindex", lupb_Array_Newindex}, + {NULL, NULL}}; + +/* lupb_map *******************************************************************/ + +typedef struct { + upb_Map* map; + upb_CType key_type; + upb_CType value_type; +} lupb_map; + +#define MAP_MSGDEF_INDEX 1 + +static lupb_map* lupb_map_check(lua_State* L, int narg) { + return luaL_checkudata(L, narg, LUPB_MAP); +} + +/* lupb_map Public API */ + +/** + * lupb_Map_New + * + * Handles: + * new_map = upb.Map(key_type, value_type) + * new_map = upb.Map(key_type, value_msgdef) + */ +static int lupb_Map_New(lua_State* L) { + upb_Arena* arena; + lupb_map* lmap; + + if (lua_type(L, 2) == LUA_TNUMBER) { + lmap = lupb_newuserdata(L, sizeof(*lmap), 1, LUPB_MAP); + lmap->value_type = lupb_checkfieldtype(L, 2); + } else { + lupb_MessageDef_check(L, 2); + lmap = lupb_newuserdata(L, sizeof(*lmap), 2, LUPB_MAP); + lmap->value_type = kUpb_CType_Message; + lua_pushvalue(L, 2); + lua_setiuservalue(L, -2, MAP_MSGDEF_INDEX); + } + + arena = lupb_Arena_pushnew(L); + lua_setiuservalue(L, -2, LUPB_ARENA_INDEX); + + lmap->key_type = lupb_checkfieldtype(L, 1); + lmap->map = upb_Map_New(arena, lmap->key_type, lmap->value_type); + lupb_cacheset(L, lmap->map); + + return 1; +} + +/** + * lupb_map_index + * + * Handles: + * map[key] + */ +static int lupb_map_index(lua_State* L) { + lupb_map* lmap = lupb_map_check(L, 1); + upb_MessageValue key = lupb_tomsgval(L, lmap->key_type, 2, 1, LUPB_REF); + upb_MessageValue val; + + if (upb_Map_Get(lmap->map, key, &val)) { + lupb_pushmsgval(L, 1, lmap->value_type, val); + } else { + lua_pushnil(L); + } + + return 1; +} + +/** + * lupb_map_len + * + * Handles: + * map_len = #map + */ +static int lupb_map_len(lua_State* L) { + lupb_map* lmap = lupb_map_check(L, 1); + lua_pushnumber(L, upb_Map_Size(lmap->map)); + return 1; +} + +/** + * lupb_Map_Newindex + * + * Handles: + * map[key] = val + * map[key] = nil # to remove from map + */ +static int lupb_Map_Newindex(lua_State* L) { + lupb_map* lmap = lupb_map_check(L, 1); + upb_Map* map = lmap->map; + upb_MessageValue key = lupb_tomsgval(L, lmap->key_type, 2, 1, LUPB_REF); + + if (lua_isnil(L, 3)) { + upb_Map_Delete(map, key, NULL); + } else { + upb_MessageValue val = lupb_tomsgval(L, lmap->value_type, 3, 1, LUPB_COPY); + upb_Map_Set(map, key, val, lupb_Arenaget(L, 1)); + if (lmap->value_type == kUpb_CType_Message) { + lupb_Arena_Fuseobjs(L, 1, 3); + } + } + + return 0; +} + +static int lupb_MapIterator_Next(lua_State* L) { + int map = lua_upvalueindex(2); + size_t* iter = lua_touserdata(L, lua_upvalueindex(1)); + lupb_map* lmap = lupb_map_check(L, map); + + upb_MessageValue key, val; + if (upb_Map_Next(lmap->map, &key, &val, iter)) { + lupb_pushmsgval(L, map, lmap->key_type, key); + lupb_pushmsgval(L, map, lmap->value_type, val); + return 2; + } else { + return 0; + } +} + +/** + * lupb_map_pairs() + * + * Handles: + * pairs(map) + */ +static int lupb_map_pairs(lua_State* L) { + size_t* iter = lua_newuserdata(L, sizeof(*iter)); + lupb_map_check(L, 1); + + *iter = kUpb_Map_Begin; + lua_pushvalue(L, 1); + + /* Upvalues are [iter, lupb_map]. */ + lua_pushcclosure(L, &lupb_MapIterator_Next, 2); + + return 1; +} + +/* upb_mapiter ]]] */ + +static const struct luaL_Reg lupb_map_mm[] = {{"__index", lupb_map_index}, + {"__len", lupb_map_len}, + {"__newindex", lupb_Map_Newindex}, + {"__pairs", lupb_map_pairs}, + {NULL, NULL}}; + +/* lupb_Message + * *******************************************************************/ + +typedef struct { + upb_Message* msg; +} lupb_Message; + +/* lupb_Message helpers */ + +static upb_Message* lupb_msg_check(lua_State* L, int narg) { + lupb_Message* msg = luaL_checkudata(L, narg, LUPB_MSG); + return msg->msg; +} + +static const upb_MessageDef* lupb_Message_Getmsgdef(lua_State* L, int msg) { + lua_getiuservalue(L, msg, LUPB_MSGDEF_INDEX); + const upb_MessageDef* m = lupb_MessageDef_check(L, -1); + lua_pop(L, 1); + return m; +} + +static const upb_FieldDef* lupb_msg_tofield(lua_State* L, int msg, int field) { + size_t len; + const char* fieldname = luaL_checklstring(L, field, &len); + const upb_MessageDef* m = lupb_Message_Getmsgdef(L, msg); + return upb_MessageDef_FindFieldByNameWithSize(m, fieldname, len); +} + +static const upb_FieldDef* lupb_msg_checkfield(lua_State* L, int msg, + int field) { + const upb_FieldDef* f = lupb_msg_tofield(L, msg, field); + if (f == NULL) { + luaL_error(L, "no such field '%s'", lua_tostring(L, field)); + } + return f; +} + +upb_Message* lupb_msg_pushnew(lua_State* L, int narg) { + const upb_MessageDef* m = lupb_MessageDef_check(L, narg); + lupb_Message* lmsg = lupb_newuserdata(L, sizeof(lupb_Message), 2, LUPB_MSG); + upb_Arena* arena = lupb_Arena_pushnew(L); + + lua_setiuservalue(L, -2, LUPB_ARENA_INDEX); + lua_pushvalue(L, 1); + lua_setiuservalue(L, -2, LUPB_MSGDEF_INDEX); + + lmsg->msg = upb_Message_New(upb_MessageDef_MiniTable(m), arena); + lupb_cacheset(L, lmsg->msg); + return lmsg->msg; +} + +/** + * lupb_Message_Newmsgwrapper() + * + * Creates a new wrapper for a message, copying the arena and msgdef references + * from |narg| (which should be an array or map). + */ +static void lupb_Message_Newmsgwrapper(lua_State* L, int narg, + upb_MessageValue val) { + lupb_Message* lmsg = lupb_newuserdata(L, sizeof(*lmsg), 2, LUPB_MSG); + lmsg->msg = (upb_Message*)val.msg_val; /* XXX: cast isn't great. */ + lupb_cacheset(L, lmsg->msg); + + /* Copy both arena and msgdef into the wrapper. */ + lua_getiuservalue(L, narg, LUPB_ARENA_INDEX); + lua_setiuservalue(L, -2, LUPB_ARENA_INDEX); + lua_getiuservalue(L, narg, LUPB_MSGDEF_INDEX); + lua_setiuservalue(L, -2, LUPB_MSGDEF_INDEX); +} + +/** + * lupb_Message_Newud() + * + * Creates the Lua userdata for a new wrapper object, adding a reference to + * the msgdef if necessary. + */ +static void* lupb_Message_Newud(lua_State* L, int narg, size_t size, + const char* type, const upb_FieldDef* f) { + if (upb_FieldDef_CType(f) == kUpb_CType_Message) { + /* Wrapper needs a reference to the msgdef. */ + void* ud = lupb_newuserdata(L, size, 2, type); + lua_getiuservalue(L, narg, LUPB_MSGDEF_INDEX); + lupb_MessageDef_pushsubmsgdef(L, f); + lua_setiuservalue(L, -2, LUPB_MSGDEF_INDEX); + return ud; + } else { + return lupb_newuserdata(L, size, 1, type); + } +} + +/** + * lupb_Message_Newwrapper() + * + * Creates a new Lua wrapper object to wrap the given array, map, or message. + */ +static void lupb_Message_Newwrapper(lua_State* L, int narg, + const upb_FieldDef* f, + upb_MutableMessageValue val) { + if (upb_FieldDef_IsMap(f)) { + const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* key_f = + upb_MessageDef_FindFieldByNumber(entry, kUpb_MapEntry_KeyFieldNumber); + const upb_FieldDef* val_f = + upb_MessageDef_FindFieldByNumber(entry, kUpb_MapEntry_ValueFieldNumber); + lupb_map* lmap = + lupb_Message_Newud(L, narg, sizeof(*lmap), LUPB_MAP, val_f); + lmap->key_type = upb_FieldDef_CType(key_f); + lmap->value_type = upb_FieldDef_CType(val_f); + lmap->map = val.map; + } else if (upb_FieldDef_IsRepeated(f)) { + lupb_array* larr = + lupb_Message_Newud(L, narg, sizeof(*larr), LUPB_ARRAY, f); + larr->type = upb_FieldDef_CType(f); + larr->arr = val.array; + } else { + lupb_Message* lmsg = + lupb_Message_Newud(L, narg, sizeof(*lmsg), LUPB_MSG, f); + lmsg->msg = val.msg; + } + + /* Copy arena ref to new wrapper. This may be a different arena than the + * underlying data was originally constructed from, but if so both arenas + * must be in the same group. */ + lua_getiuservalue(L, narg, LUPB_ARENA_INDEX); + lua_setiuservalue(L, -2, LUPB_ARENA_INDEX); + + lupb_cacheset(L, val.msg); +} + +/** + * lupb_msg_typechecksubmsg() + * + * Typechecks the given array, map, or msg against this upb_FieldDef. + */ +static void lupb_msg_typechecksubmsg(lua_State* L, int narg, int msgarg, + const upb_FieldDef* f) { + /* Typecheck this map's msgdef against this message field. */ + lua_getiuservalue(L, narg, LUPB_MSGDEF_INDEX); + lua_getiuservalue(L, msgarg, LUPB_MSGDEF_INDEX); + lupb_MessageDef_pushsubmsgdef(L, f); + luaL_argcheck(L, lua_rawequal(L, -1, -2), narg, "message type mismatch"); + lua_pop(L, 2); +} + +/* lupb_Message Public API */ + +/** + * lupb_MessageDef_call + * + * Handles: + * new_msg = MessageClass() + * new_msg = MessageClass{foo = "bar", baz = 3, quux = {foo = 3}} + */ +int lupb_MessageDef_call(lua_State* L) { + int arg_count = lua_gettop(L); + lupb_msg_pushnew(L, 1); + + if (arg_count > 1) { + /* Set initial fields from table. */ + int msg = arg_count + 1; + lua_pushnil(L); + while (lua_next(L, 2) != 0) { + lua_pushvalue(L, -2); /* now stack is key, val, key */ + lua_insert(L, -3); /* now stack is key, key, val */ + lua_settable(L, msg); + } + } + + return 1; +} + +/** + * lupb_msg_index + * + * Handles: + * msg.foo + * msg["foo"] + * msg[field_descriptor] # (for extensions) (TODO) + */ +static int lupb_msg_index(lua_State* L) { + upb_Message* msg = lupb_msg_check(L, 1); + const upb_FieldDef* f = lupb_msg_checkfield(L, 1, 2); + + if (upb_FieldDef_IsRepeated(f) || upb_FieldDef_IsSubMessage(f)) { + /* Wrapped type; get or create wrapper. */ + upb_Arena* arena = upb_FieldDef_IsRepeated(f) ? lupb_Arenaget(L, 1) : NULL; + upb_MutableMessageValue val = upb_Message_Mutable(msg, f, arena); + if (!lupb_cacheget(L, val.msg)) { + lupb_Message_Newwrapper(L, 1, f, val); + } + } else { + /* Value type, just push value and return .*/ + upb_MessageValue val = upb_Message_GetFieldByDef(msg, f); + lupb_pushmsgval(L, 0, upb_FieldDef_CType(f), val); + } + + return 1; +} + +/** + * lupb_Message_Newindex() + * + * Handles: + * msg.foo = bar + * msg["foo"] = bar + * msg[field_descriptor] = bar # (for extensions) (TODO) + */ +static int lupb_Message_Newindex(lua_State* L) { + upb_Message* msg = lupb_msg_check(L, 1); + const upb_FieldDef* f = lupb_msg_checkfield(L, 1, 2); + upb_MessageValue msgval; + bool merge_arenas = true; + + if (upb_FieldDef_IsMap(f)) { + lupb_map* lmap = lupb_map_check(L, 3); + const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f); + const upb_FieldDef* key_f = + upb_MessageDef_FindFieldByNumber(entry, kUpb_MapEntry_KeyFieldNumber); + const upb_FieldDef* val_f = + upb_MessageDef_FindFieldByNumber(entry, kUpb_MapEntry_ValueFieldNumber); + upb_CType key_type = upb_FieldDef_CType(key_f); + upb_CType value_type = upb_FieldDef_CType(val_f); + luaL_argcheck(L, lmap->key_type == key_type, 3, "key type mismatch"); + luaL_argcheck(L, lmap->value_type == value_type, 3, "value type mismatch"); + if (value_type == kUpb_CType_Message) { + lupb_msg_typechecksubmsg(L, 3, 1, val_f); + } + msgval.map_val = lmap->map; + } else if (upb_FieldDef_IsRepeated(f)) { + lupb_array* larr = lupb_array_check(L, 3); + upb_CType type = upb_FieldDef_CType(f); + luaL_argcheck(L, larr->type == type, 3, "array type mismatch"); + if (type == kUpb_CType_Message) { + lupb_msg_typechecksubmsg(L, 3, 1, f); + } + msgval.array_val = larr->arr; + } else if (upb_FieldDef_IsSubMessage(f)) { + upb_Message* msg = lupb_msg_check(L, 3); + lupb_msg_typechecksubmsg(L, 3, 1, f); + msgval.msg_val = msg; + } else { + msgval = lupb_tomsgval(L, upb_FieldDef_CType(f), 3, 1, LUPB_COPY); + merge_arenas = false; + } + + if (merge_arenas) { + lupb_Arena_Fuseobjs(L, 1, 3); + } + + upb_Message_SetFieldByDef(msg, f, msgval, lupb_Arenaget(L, 1)); + + /* Return the new value for chained assignments. */ + lua_pushvalue(L, 3); + return 1; +} + +/** + * lupb_msg_tostring() + * + * Handles: + * tostring(msg) + * print(msg) + * etc. + */ +static int lupb_msg_tostring(lua_State* L) { + upb_Message* msg = lupb_msg_check(L, 1); + const upb_MessageDef* m; + char buf[1024]; + size_t size; + + lua_getiuservalue(L, 1, LUPB_MSGDEF_INDEX); + m = lupb_MessageDef_check(L, -1); + + size = upb_TextEncode(msg, m, NULL, 0, buf, sizeof(buf)); + + if (size < sizeof(buf)) { + lua_pushlstring(L, buf, size); + } else { + char* ptr = malloc(size + 1); + upb_TextEncode(msg, m, NULL, 0, ptr, size + 1); + lua_pushlstring(L, ptr, size); + free(ptr); + } + + return 1; +} + +static const struct luaL_Reg lupb_msg_mm[] = { + {"__index", lupb_msg_index}, + {"__newindex", lupb_Message_Newindex}, + {"__tostring", lupb_msg_tostring}, + {NULL, NULL}}; + +/* lupb_Message toplevel + * **********************************************************/ + +static int lupb_getoptions(lua_State* L, int narg) { + int options = 0; + if (lua_gettop(L) >= narg) { + size_t len = lua_rawlen(L, narg); + for (size_t i = 1; i <= len; i++) { + lua_rawgeti(L, narg, i); + options |= lupb_checkuint32(L, -1); + lua_pop(L, 1); + } + } + return options; +} + +/** + * lupb_decode() + * + * Handles: + * msg = upb.decode(MessageClass, bin_string) + */ +static int lupb_decode(lua_State* L) { + size_t len; + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + const char* pb = lua_tolstring(L, 2, &len); + const upb_MiniTable* layout = upb_MessageDef_MiniTable(m); + upb_Message* msg = lupb_msg_pushnew(L, 1); + upb_Arena* arena = lupb_Arenaget(L, -1); + char* buf; + + /* Copy input data to arena, message will reference it. */ + buf = upb_Arena_Malloc(arena, len); + memcpy(buf, pb, len); + + upb_DecodeStatus status = upb_Decode(buf, len, msg, layout, NULL, + kUpb_DecodeOption_AliasString, arena); + + if (status != kUpb_DecodeStatus_Ok) { + lua_pushstring(L, "Error decoding protobuf."); + return lua_error(L); + } + + return 1; +} + +/** + * lupb_Encode() + * + * Handles: + * bin_string = upb.encode(msg) + */ +static int lupb_Encode(lua_State* L) { + const upb_Message* msg = lupb_msg_check(L, 1); + const upb_MessageDef* m = lupb_Message_Getmsgdef(L, 1); + const upb_MiniTable* layout = upb_MessageDef_MiniTable(m); + int options = lupb_getoptions(L, 2); + upb_Arena* arena = lupb_Arena_pushnew(L); + char* buf; + size_t size; + upb_EncodeStatus status = + upb_Encode(msg, (const void*)layout, options, arena, &buf, &size); + if (status != kUpb_EncodeStatus_Ok) { + lua_pushstring(L, "Error encoding protobuf."); + return lua_error(L); + } + + lua_pushlstring(L, buf, size); + + return 1; +} + +/** + * lupb_jsondecode() + * + * Handles: + * text_string = upb.json_decode(MessageClass, json_str, + * {upb.JSONDEC_IGNOREUNKNOWN}) + */ +static int lupb_jsondecode(lua_State* L) { + size_t len; + const upb_MessageDef* m = lupb_MessageDef_check(L, 1); + const char* json = lua_tolstring(L, 2, &len); + int options = lupb_getoptions(L, 3); + upb_Message* msg; + upb_Arena* arena; + upb_Status status; + + msg = lupb_msg_pushnew(L, 1); + arena = lupb_Arenaget(L, -1); + upb_Status_Clear(&status); + upb_JsonDecode(json, len, msg, m, NULL, options, arena, &status); + lupb_checkstatus(L, &status); + + return 1; +} + +/** + * lupb_jsonencode() + * + * Handles: + * text_string = upb.json_encode(msg, {upb.JSONENC_EMITDEFAULTS}) + */ +static int lupb_jsonencode(lua_State* L) { + upb_Message* msg = lupb_msg_check(L, 1); + const upb_MessageDef* m = lupb_Message_Getmsgdef(L, 1); + int options = lupb_getoptions(L, 2); + char buf[1024]; + size_t size; + upb_Status status; + + upb_Status_Clear(&status); + size = upb_JsonEncode(msg, m, NULL, options, buf, sizeof(buf), &status); + lupb_checkstatus(L, &status); + + if (size < sizeof(buf)) { + lua_pushlstring(L, buf, size); + } else { + char* ptr = malloc(size + 1); + upb_JsonEncode(msg, m, NULL, options, ptr, size + 1, &status); + lupb_checkstatus(L, &status); + lua_pushlstring(L, ptr, size); + free(ptr); + } + + return 1; +} + +/** + * lupb_textencode() + * + * Handles: + * text_string = upb.text_encode(msg, {upb.TXTENC_SINGLELINE}) + */ +static int lupb_textencode(lua_State* L) { + upb_Message* msg = lupb_msg_check(L, 1); + const upb_MessageDef* m = lupb_Message_Getmsgdef(L, 1); + int options = lupb_getoptions(L, 2); + char buf[1024]; + size_t size; + + size = upb_TextEncode(msg, m, NULL, options, buf, sizeof(buf)); + + if (size < sizeof(buf)) { + lua_pushlstring(L, buf, size); + } else { + char* ptr = malloc(size + 1); + upb_TextEncode(msg, m, NULL, options, ptr, size + 1); + lua_pushlstring(L, ptr, size); + free(ptr); + } + + return 1; +} + +static void lupb_setfieldi(lua_State* L, const char* field, int i) { + lua_pushinteger(L, i); + lua_setfield(L, -2, field); +} + +static const struct luaL_Reg lupb_msg_toplevel_m[] = { + {"Array", lupb_Array_New}, {"Map", lupb_Map_New}, + {"decode", lupb_decode}, {"encode", lupb_Encode}, + {"json_decode", lupb_jsondecode}, {"json_encode", lupb_jsonencode}, + {"text_encode", lupb_textencode}, {NULL, NULL}}; + +void lupb_msg_registertypes(lua_State* L) { + lupb_setfuncs(L, lupb_msg_toplevel_m); + + lupb_register_type(L, LUPB_ARENA, NULL, lupb_Arena_mm); + lupb_register_type(L, LUPB_ARRAY, NULL, lupb_array_mm); + lupb_register_type(L, LUPB_MAP, NULL, lupb_map_mm); + lupb_register_type(L, LUPB_MSG, NULL, lupb_msg_mm); + + lupb_setfieldi(L, "TXTENC_SINGLELINE", UPB_TXTENC_SINGLELINE); + lupb_setfieldi(L, "TXTENC_SKIPUNKNOWN", UPB_TXTENC_SKIPUNKNOWN); + lupb_setfieldi(L, "TXTENC_NOSORT", UPB_TXTENC_NOSORT); + + lupb_setfieldi(L, "ENCODE_DETERMINISTIC", kUpb_EncodeOption_Deterministic); + lupb_setfieldi(L, "ENCODE_SKIPUNKNOWN", kUpb_EncodeOption_SkipUnknown); + + lupb_setfieldi(L, "JSONENC_EMITDEFAULTS", upb_JsonEncode_EmitDefaults); + lupb_setfieldi(L, "JSONENC_PROTONAMES", upb_JsonEncode_UseProtoNames); + + lupb_setfieldi(L, "JSONDEC_IGNOREUNKNOWN", upb_JsonDecode_IgnoreUnknown); + + lupb_cacheinit(L); +} diff --git a/archive/lua/test.proto b/archive/lua/test.proto new file mode 100644 index 0000000000..92bcd1c88c --- /dev/null +++ b/archive/lua/test.proto @@ -0,0 +1,98 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto2"; + +import "google/protobuf/timestamp.proto"; + +package upb_lua_test; + +message MapTest { + map map_string_double = 1; +} + +message PackedTest { + repeated bool bool_packed = 1 [packed = true]; + repeated int32 i32_packed = 2 [packed = true]; + repeated int64 i64_packed = 3 [packed = true]; + repeated fixed32 f32_packed = 4 [packed = true]; + repeated fixed64 f64_packed = 5 [packed = true]; +} + +message UnpackedTest { + repeated bool bool_packed = 1 [packed = false]; + repeated int32 i32_packed = 2 [packed = false]; + repeated int64 i64_packed = 3 [packed = false]; + repeated fixed32 f32_packed = 4 [packed = false]; + repeated fixed64 f64_packed = 5 [packed = false]; +} + +message TestLargeFieldNumber { + optional int32 i32 = 456214797; +} + +message TestTimestamp { + optional google.protobuf.Timestamp ts = 1; +} + +message HelloRequest { + optional uint32 id = 1; + optional uint32 random_name_a0 = 2; + optional uint32 random_name_a1 = 3; + optional uint32 random_name_a2 = 4; + optional uint32 random_name_a3 = 5; + optional uint32 random_name_a4 = 6; + optional uint32 random_name_a5 = 7; + optional uint32 random_name_a6 = 8; + optional uint32 random_name_a7 = 9; + optional uint32 random_name_a8 = 10; + optional uint32 random_name_a9 = 11; + optional uint32 random_name_b0 = 12; + optional uint32 random_name_b1 = 13; + optional uint32 random_name_b2 = 14; + optional uint32 random_name_b3 = 15; + optional uint32 random_name_b4 = 16; + optional uint32 random_name_b5 = 17; + optional uint32 random_name_b6 = 18; + optional uint32 random_name_b7 = 19; + optional uint32 random_name_b8 = 20; + optional uint32 random_name_b9 = 21; + optional uint32 random_name_c0 = 22; + optional uint32 random_name_c1 = 23; + optional uint32 random_name_c2 = 24; + optional uint32 random_name_c3 = 25; + optional uint32 random_name_c4 = 26; + optional uint32 random_name_c5 = 27; + optional uint32 random_name_c6 = 28; + optional uint32 random_name_c7 = 29; + optional uint32 random_name_c8 = 30; + optional uint32 random_name_c9 = 31; + optional string version = 32; +} diff --git a/tests/bindings/lua/test_upb.lua b/archive/lua/test_upb.lua similarity index 84% rename from tests/bindings/lua/test_upb.lua rename to archive/lua/test_upb.lua index e2d53450ba..f74d988895 100644 --- a/tests/bindings/lua/test_upb.lua +++ b/archive/lua/test_upb.lua @@ -1,7 +1,40 @@ +--[[-------------------------------------------------------------------------- + +Protocol Buffers - Google's data interchange format +Copyright 2023 Google LLC. All rights reserved. +https://developers.google.com/protocol-buffers/ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google 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 THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--]]-------------------------------------------------------------------------- local upb = require "lupb" local lunit = require "lunit" -local upb_test = require "tests.bindings.lua.test_pb" +local upb_test = require "lua.test_pb" local test_messages_proto3 = require "google.protobuf.test_messages_proto3_pb" local test_messages_proto2 = require "google.protobuf.test_messages_proto2_pb" local descriptor = require "google.protobuf.descriptor_pb" @@ -63,7 +96,7 @@ function test_def_readers() -- enum local e = test_messages_proto3['TestAllTypesProto3.NestedEnum'] assert_true(#e > 3 and #e < 10) - assert_equal(2, e:value("BAZ")) + assert_equal(2, e:value("BAZ"):number()) end function test_msg_map() @@ -321,6 +354,16 @@ function test_msg_array() assert_error_match("array expected", function() msg.repeated_int32 = print end) end +function test_array_append() + local arr = upb.Array(upb.TYPE_INT32) + for i=1,200000 do + arr[i] = i + end + for i=1,200000 do + assert_equal(i, arr[i]) + end +end + function test_msg_submsg() --msg = test_messages_proto3.TestAllTypesProto3() msg = test_messages_proto3['TestAllTypesProto3']() @@ -370,7 +413,7 @@ function test_finalizer() end) end) t = { - upb.SymbolTable(), + upb.DefPool(), } end collectgarbage() @@ -628,14 +671,15 @@ function test_unknown() end function test_foo() - local symtab = upb.SymbolTable() - local filename = "external/com_google_protobuf/descriptor_proto-descriptor-set.proto.bin" - local file = io.open(filename, "rb") or io.open("bazel-bin/" .. filename, "rb") + local defpool = upb.DefPool() + local filename = "external/com_google_protobuf/src/google/protobuf/descriptor_proto-descriptor-set.proto.bin" + local alternate_filename = "src/google/protobuf/descriptor_proto-descriptor-set.proto.bin" + local file = io.open(filename, "rb") or io.open("bazel-bin/" .. filename, "rb") or io.open(alternate_filename, "rb") assert_not_nil(file) local descriptor = file:read("*a") assert_true(#descriptor > 0) - symtab:add_set(descriptor) - local FileDescriptorSet = symtab:lookup_msg("google.protobuf.FileDescriptorSet") + defpool:add_set(descriptor) + local FileDescriptorSet = defpool:lookup_msg("google.protobuf.FileDescriptorSet") assert_not_nil(FileDescriptorSet) set = FileDescriptorSet() assert_equal(#set.file, 0) @@ -652,7 +696,7 @@ function test_foo() end function test_descriptor() - local symtab = upb.SymbolTable() + local defpool = upb.DefPool() local file_proto = descriptor.FileDescriptorProto { name = "test.proto", message_type = upb.Array(descriptor.DescriptorProto, { @@ -661,12 +705,12 @@ function test_descriptor() }, }) } - local file = symtab:add_file(upb.encode(file_proto)) - assert_equal(file:symtab(), symtab) + local file = defpool:add_file(upb.encode(file_proto)) + assert_equal(file:defpool(), defpool) end function test_descriptor_error() - local symtab = upb.SymbolTable() + local defpool = upb.DefPool() local file = descriptor.FileDescriptorProto() file.name = "test.proto" file.message_type[1] = descriptor.DescriptorProto{ @@ -675,8 +719,41 @@ function test_descriptor_error() file.message_type[2] = descriptor.DescriptorProto{ name = "BC." } - assert_error(function () symtab:add_file(upb.encode(file)) end) - assert_nil(symtab:lookup_msg("ABC")) + assert_error(function () defpool:add_file(upb.encode(file)) end) + assert_nil(defpool:lookup_msg("ABC")) +end + +function test_duplicate_enumval() + local defpool = upb.DefPool() + local file_proto = descriptor.FileDescriptorProto { + name = "test.proto", + message_type = upb.Array(descriptor.DescriptorProto, { + descriptor.DescriptorProto{ + name = "ABC", + }, + }), + enum_type = upb.Array(descriptor.EnumDescriptorProto, { + descriptor.EnumDescriptorProto{ + name = "MyEnum", + value = upb.Array(descriptor.EnumValueDescriptorProto, { + descriptor.EnumValueDescriptorProto{ + name = "ABC", + number = 1, + } + }), + }, + }) + } + assert_error(function () defpool:add_file(upb.encode(file_proto)) end) +end + +function test_duplicate_filename_error() + local defpool = upb.DefPool() + local file = descriptor.FileDescriptorProto() + file.name = "test.proto" + defpool:add_file(upb.encode(file)) + -- Second add with the same filename fails. + assert_error(function () defpool:add_file(upb.encode(file)) end) end function test_encode_skipunknown() @@ -700,6 +777,17 @@ function test_json_emit_defaults() local json = upb.json_encode(msg, {upb.JSONENC_EMITDEFAULTS}) end +function test_json_locale() + local msg = test_messages_proto3.TestAllTypesProto3() + msg.optional_double = 1.1 + local original_locale = os.setlocale(nil) + os.setlocale("C") + local json = upb.json_encode(msg) + os.setlocale("de_DE.utf8") + assert_equal(json, upb.json_encode(msg)) + os.setlocale(original_locale) -- Restore. +end + function test_encode_depth_limit() local msg = test_messages_proto3.TestAllTypesProto3() msg.recursive_message = msg @@ -714,6 +802,11 @@ function test_large_field_number() assert_equal(msg.i32, msg2.i32) end +function test_timestamp_minutes() + local msg = upb.json_decode(upb_test.TestTimestamp, '{"ts": "2000-01-01T00:00:00-06:59"}') + assert_equal(msg.ts.seconds, 946684800 + ((6 * 60) + 59) * 60) +end + function test_gc() local top = test_messages_proto3.TestAllTypesProto3() local n = 100 @@ -744,6 +837,14 @@ function test_gc() end end +function test_b9440() + local m = upb_test.HelloRequest() + m.id = 8 + assert_equal(8, m.id) + m.version = "1" + assert_equal(8, m.id) +end + local stats = lunit.main() if stats.failed > 0 or stats.errors > 0 then diff --git a/archive/lua/upb.c b/archive/lua/upb.c new file mode 100644 index 0000000000..4500fb4e75 --- /dev/null +++ b/archive/lua/upb.c @@ -0,0 +1,261 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* + * require("lua") -- A Lua extension for upb. + * + * Exposes only the core library + * (sub-libraries are exposed in other extensions). + * + * 64-bit woes: Lua can only represent numbers of type lua_Number (which is + * double unless the user specifically overrides this). Doubles can represent + * the entire range of 64-bit integers, but lose precision once the integers are + * greater than 2^53. + * + * Lua 5.3 is adding support for integers, which will allow for 64-bit + * integers (which can be interpreted as signed or unsigned). + * + * LuaJIT supports 64-bit signed and unsigned boxed representations + * through its "cdata" mechanism, but this is not portable to regular Lua. + * + * Hopefully Lua 5.3 will come soon enough that we can either use Lua 5.3 + * integer support or LuaJIT 64-bit cdata for users that need the entire + * domain of [u]int64 values. + */ + +#include "lua/upb.h" + +#include +#include +#include +#include +#include + +#include "lauxlib.h" +#include "upb/message/message.h" + +/* Lua compatibility code *****************************************************/ + +/* Shims for upcoming Lua 5.3 functionality. */ +static bool lua_isinteger(lua_State* L, int argn) { + LUPB_UNUSED(L); + LUPB_UNUSED(argn); + return false; +} + +/* Utility functions **********************************************************/ + +void lupb_checkstatus(lua_State* L, upb_Status* s) { + if (!upb_Status_IsOk(s)) { + lua_pushstring(L, upb_Status_ErrorMessage(s)); + lua_error(L); + } +} + +/* Pushes a new userdata with the given metatable. */ +void* lupb_newuserdata(lua_State* L, size_t size, int n, const char* type) { +#if LUA_VERSION_NUM >= 504 + void* ret = lua_newuserdatauv(L, size, n); +#else + void* ret = lua_newuserdata(L, size); + lua_createtable(L, 0, n); + lua_setuservalue(L, -2); +#endif + + /* Set metatable. */ + luaL_getmetatable(L, type); + assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ + lua_setmetatable(L, -2); + + return ret; +} + +#if LUA_VERSION_NUM < 504 +int lua_setiuservalue(lua_State* L, int index, int n) { + lua_getuservalue(L, index); + lua_insert(L, -2); + lua_rawseti(L, -2, n); + lua_pop(L, 1); + return 1; +} + +int lua_getiuservalue(lua_State* L, int index, int n) { + lua_getuservalue(L, index); + lua_rawgeti(L, -1, n); + lua_replace(L, -2); + return 1; +} +#endif + +/* We use this function as the __index metamethod when a type has both methods + * and an __index metamethod. */ +int lupb_indexmm(lua_State* L) { + /* Look up in __index table (which is a closure param). */ + lua_pushvalue(L, 2); + lua_rawget(L, lua_upvalueindex(1)); + if (!lua_isnil(L, -1)) { + return 1; + } + + /* Not found, chain to user __index metamethod. */ + lua_pushvalue(L, lua_upvalueindex(2)); + lua_pushvalue(L, 1); + lua_pushvalue(L, 2); + lua_call(L, 2, 1); + return 1; +} + +void lupb_register_type(lua_State* L, const char* name, const luaL_Reg* m, + const luaL_Reg* mm) { + luaL_newmetatable(L, name); + + if (mm) { + lupb_setfuncs(L, mm); + } + + if (m) { + lua_createtable(L, 0, 0); /* __index table */ + lupb_setfuncs(L, m); + + /* Methods go in the mt's __index slot. If the user also specified an + * __index metamethod, use our custom lupb_indexmm() that can check both. */ + lua_getfield(L, -2, "__index"); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + } else { + lua_pushcclosure(L, &lupb_indexmm, 2); + } + lua_setfield(L, -2, "__index"); + } + + lua_pop(L, 1); /* The mt. */ +} + +/* Scalar type mapping ********************************************************/ + +/* Functions that convert scalar/primitive values (numbers, strings, bool) + * between Lua and C/upb. Handles type/range checking. */ + +bool lupb_checkbool(lua_State* L, int narg) { + if (!lua_isboolean(L, narg)) { + luaL_error(L, "must be true or false"); + } + return lua_toboolean(L, narg); +} + +/* Unlike luaL_checkstring(), this does not allow implicit conversion to + * string. */ +const char* lupb_checkstring(lua_State* L, int narg, size_t* len) { + if (lua_type(L, narg) != LUA_TSTRING) { + luaL_error(L, "Expected string"); + } + + return lua_tolstring(L, narg, len); +} + +/* Unlike luaL_checkinteger, these do not implicitly convert from string or + * round an existing double value. We allow floating-point input, but only if + * the actual value is integral. */ +#define INTCHECK(type, ctype, min, max) \ + ctype lupb_check##type(lua_State* L, int narg) { \ + double n; \ + if (lua_isinteger(L, narg)) { \ + return lua_tointeger(L, narg); \ + } \ + \ + /* Prevent implicit conversion from string. */ \ + luaL_checktype(L, narg, LUA_TNUMBER); \ + n = lua_tonumber(L, narg); \ + \ + /* Check this double has no fractional part and remains in bounds. \ + * Consider INT64_MIN and INT64_MAX: \ + * 1. INT64_MIN -(2^63) is a power of 2, so this converts to a double. \ + * 2. INT64_MAX (2^63 - 1) is not a power of 2, and conversion of \ + * out-of-range integer values to a double can lead to undefined behavior. \ + * On some compilers, this conversion can return 0, but it also can return \ + * the max value. To deal with this, we can first divide by 2 to prevent \ + * the overflow, multiply it back, and add 1 to find the true limit. */ \ + double i; \ + double max_value = (((double)max / 2) * 2) + 1; \ + if ((modf(n, &i) != 0.0) || n < min || n >= max_value) { \ + luaL_error(L, "number %f was not an integer or out of range for " #type, \ + n); \ + } \ + return (ctype)n; \ + } \ + void lupb_push##type(lua_State* L, ctype val) { \ + /* TODO: push integer for Lua >= 5.3, 64-bit cdata for LuaJIT. */ \ + /* This is lossy for some [u]int64 values, which isn't great, but */ \ + /* crashing when we encounter these values seems worse. */ \ + lua_pushnumber(L, val); \ + } + +INTCHECK(int64, int64_t, INT64_MIN, INT64_MAX) +INTCHECK(int32, int32_t, INT32_MIN, INT32_MAX) +INTCHECK(uint64, uint64_t, 0, UINT64_MAX) +INTCHECK(uint32, uint32_t, 0, UINT32_MAX) + +double lupb_checkdouble(lua_State* L, int narg) { + /* If we were being really hard-nosed here, we'd check whether the input was + * an integer that has no precise double representation. But doubles aren't + * generally expected to be exact like integers are, and worse this could + * cause data-dependent runtime errors: one run of the program could work fine + * because the integer calculations happened to be exactly representable in + * double, while the next could crash because of subtly different input. */ + + luaL_checktype(L, narg, LUA_TNUMBER); /* lua_tonumber() auto-converts. */ + return lua_tonumber(L, narg); +} + +float lupb_checkfloat(lua_State* L, int narg) { + /* We don't worry about checking whether the input can be exactly converted to + * float -- see above. */ + + luaL_checktype(L, narg, LUA_TNUMBER); /* lua_tonumber() auto-converts. */ + return lua_tonumber(L, narg); +} + +void lupb_pushdouble(lua_State* L, double d) { lua_pushnumber(L, d); } + +void lupb_pushfloat(lua_State* L, float d) { lua_pushnumber(L, d); } + +/* Library entry point ********************************************************/ + +int luaopen_lupb(lua_State* L) { +#if LUA_VERSION_NUM == 501 + const struct luaL_Reg funcs[] = {{NULL, NULL}}; + luaL_register(L, "upb_c", funcs); +#else + lua_createtable(L, 0, 8); +#endif + lupb_def_registertypes(L); + lupb_msg_registertypes(L); + return 1; /* Return package table. */ +} diff --git a/archive/lua/upb.h b/archive/lua/upb.h new file mode 100644 index 0000000000..46ec9118c5 --- /dev/null +++ b/archive/lua/upb.h @@ -0,0 +1,135 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* + * Shared definitions for upb Lua modules. + */ + +#ifndef UPB_LUA_UPB_H_ +#define UPB_LUA_UPB_H_ + +#include "lauxlib.h" +#include "upb/message/message.h" +#include "upb/reflection/def.h" +#include "upb/reflection/message.h" + +/* Lua changes its API in incompatible ways in every minor release. + * This is some shim code to paper over the differences. */ + +#if LUA_VERSION_NUM == 501 +#define lua_rawlen lua_objlen +#define lua_setuservalue(L, idx) lua_setfenv(L, idx) +#define lua_getuservalue(L, idx) lua_getfenv(L, idx) +#define lupb_setfuncs(L, l) luaL_register(L, NULL, l) +#elif LUA_VERSION_NUM >= 502 && LUA_VERSION_NUM <= 504 +#define lupb_setfuncs(L, l) luaL_setfuncs(L, l, 0) +#else +#error Only Lua 5.1-5.4 are supported +#endif + +/* Create a new userdata with the given type and |n| uservals, which are popped + * from the stack to initialize the userdata. */ +void* lupb_newuserdata(lua_State* L, size_t size, int n, const char* type); + +#if LUA_VERSION_NUM < 504 +/* Polyfills for this Lua 5.4 function. Pushes userval |n| for the userdata at + * |index|. */ +int lua_setiuservalue(lua_State* L, int index, int n); +int lua_getiuservalue(lua_State* L, int index, int n); +#endif + +/* Registers a type with the given name, methods, and metamethods. */ +void lupb_register_type(lua_State* L, const char* name, const luaL_Reg* m, + const luaL_Reg* mm); + +/* Checks the given upb_Status and throws a Lua error if it is not ok. */ +void lupb_checkstatus(lua_State* L, upb_Status* s); + +int luaopen_lupb(lua_State* L); + +/* C <-> Lua value conversions. ***********************************************/ + +/* Custom check/push functions. Unlike the Lua equivalents, they are pinned to + * specific C types (instead of lua_Number, etc), and do not allow any implicit + * conversion or data loss. */ +int64_t lupb_checkint64(lua_State* L, int narg); +int32_t lupb_checkint32(lua_State* L, int narg); +uint64_t lupb_checkuint64(lua_State* L, int narg); +uint32_t lupb_checkuint32(lua_State* L, int narg); +double lupb_checkdouble(lua_State* L, int narg); +float lupb_checkfloat(lua_State* L, int narg); +bool lupb_checkbool(lua_State* L, int narg); +const char* lupb_checkstring(lua_State* L, int narg, size_t* len); +const char* lupb_checkname(lua_State* L, int narg); + +void lupb_pushint64(lua_State* L, int64_t val); +void lupb_pushint32(lua_State* L, int32_t val); +void lupb_pushuint64(lua_State* L, uint64_t val); +void lupb_pushuint32(lua_State* L, uint32_t val); + +/** From def.c. ***************************************************************/ + +const upb_MessageDef* lupb_MessageDef_check(lua_State* L, int narg); +const upb_EnumDef* lupb_EnumDef_check(lua_State* L, int narg); +const upb_FieldDef* lupb_FieldDef_check(lua_State* L, int narg); +upb_DefPool* lupb_DefPool_check(lua_State* L, int narg); +void lupb_MessageDef_pushsubmsgdef(lua_State* L, const upb_FieldDef* f); + +void lupb_def_registertypes(lua_State* L); + +/** From msg.c. ***************************************************************/ + +void lupb_pushmsgval(lua_State* L, int container, upb_CType type, + upb_MessageValue val); +int lupb_MessageDef_call(lua_State* L); +upb_Arena* lupb_Arena_pushnew(lua_State* L); + +void lupb_msg_registertypes(lua_State* L); + +#define lupb_assert(L, predicate) \ + if (!(predicate)) \ + luaL_error(L, "internal error: %s, %s:%d ", #predicate, __FILE__, __LINE__); + +#define LUPB_UNUSED(var) (void)var + +#if defined(__GNUC__) || defined(__clang__) +#define LUPB_UNREACHABLE() \ + do { \ + assert(0); \ + __builtin_unreachable(); \ + } while (0) +#else +#define LUPB_UNREACHABLE() \ + do { \ + assert(0); \ + } while (0) +#endif + +#endif /* UPB_LUA_UPB_H_ */ diff --git a/archive/lua/upb.lua b/archive/lua/upb.lua new file mode 100644 index 0000000000..35333097c6 --- /dev/null +++ b/archive/lua/upb.lua @@ -0,0 +1,58 @@ +--[[-------------------------------------------------------------------------- + + 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. + +--]]-------------------------------------------------------------------------- + +local upb = require("lupb") + +upb.generated_pool = upb.DefPool() + +local module_metatable = { + __index = function(t, k) + local package = t._filedef:package() + if package then + k = package .. "." .. k + end + local pool = upb.generated_pool + local def = pool:lookup_msg(k) or pool:lookup_enum(k) + local v = nil + if def and def:file():name() == t._filedef:name() then + v = def + t[k] = v + end + return v + end +} + +function upb._generated_module(desc_string) + local file = upb.generated_pool:add_file(desc_string) + local module = {_filedef = file} + setmetatable(module, module_metatable) + return module +end + +return upb diff --git a/upb/bindings/lua/upbc.cc b/archive/lua/upbc.cc similarity index 60% rename from upb/bindings/lua/upbc.cc rename to archive/lua/upbc.cc index d9e1b9c647..4a274f22a5 100644 --- a/upb/bindings/lua/upbc.cc +++ b/archive/lua/upbc.cc @@ -1,12 +1,41 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/descriptor.pb.h" +#include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" #include "absl/strings/substitute.h" -#include "absl/strings/str_replace.h" #include "google/protobuf/compiler/code_generator.h" +#include "google/protobuf/compiler/plugin.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/descriptor.pb.h" -#include -#include +#include "google/protobuf/io/printer.h" namespace protoc = ::google::protobuf::compiler; namespace protobuf = ::google::protobuf; @@ -15,7 +44,6 @@ class LuaGenerator : public protoc::CodeGenerator { bool Generate(const protobuf::FileDescriptor* file, const std::string& parameter, protoc::GeneratorContext* context, std::string* error) const override; - }; static std::string StripExtension(absl::string_view fname) { @@ -71,11 +99,10 @@ static void PrintString(int max_cols, absl::string_view* str, printer->Print("\'"); } -bool LuaGenerator::Generate( - const protobuf::FileDescriptor* file, - const std::string& /* parameter */, - protoc::GeneratorContext* context, - std::string* /* error */) const { +bool LuaGenerator::Generate(const protobuf::FileDescriptor* file, + const std::string& /* parameter */, + protoc::GeneratorContext* context, + std::string* /* error */) const { std::string filename = Filename(file); protobuf::io::ZeroCopyOutputStream* out = context->Open(filename); protobuf::io::Printer printer(out, '$'); diff --git a/archive/protos/BUILD b/archive/protos/BUILD new file mode 100644 index 0000000000..be9736181a --- /dev/null +++ b/archive/protos/BUILD @@ -0,0 +1,188 @@ +# 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. + +load( + "//bazel:build_defs.bzl", + "UPB_DEFAULT_CPPOPTS", +) +load( + "//protos/bazel:upb_cc_proto_library.bzl", + "upb_cc_proto_library_copts", +) + +# begin:google_only +# package(default_applicable_licenses = ["//:license"]) +# end:google_only + +licenses(["notice"]) + +cc_library( + name = "repeated_field", + hdrs = [ + "repeated_field.h", + "repeated_field_iterator.h", + ], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + ":protos", + ":protos_traits", + "//:base", + "//:collections", + "//:collections_internal", + "//:mem", + "//:message_copy", + "//:mini_table", + "//:port", + "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/strings", + ], +) + +cc_library( + name = "protos", + srcs = [ + "protos.cc", + ], + hdrs = [ + "protos.h", + ], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + ":protos_extension_lock", + "//:base", + "//:mem", + "//:message", + "//:message_copy", + "//:message_internal", + "//:message_promote", + "//:mini_table", + "//:wire", + "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + ], +) + +# Internally used type traits. +cc_library( + name = "protos_traits", + hdrs = [ + "protos_traits.h", + ], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:private"], +) + +cc_library( + name = "protos_internal", + hdrs = ["protos_internal.h"], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + ":protos", + "//:mem", + "//:message", + "//:mini_table", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings:str_format", + ], +) + +cc_library( + name = "protos_extension_lock", + srcs = ["protos_extension_lock.cc"], + hdrs = ["protos_extension_lock.h"], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + "//:message", + "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/synchronization", + ], +) + +# Common support code for C++ generated code. +cc_library( + name = "generated_protos_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + hdrs = [ + "protos_internal.h", + ], + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], + deps = [ + ":protos", + ":protos_internal", + ":repeated_field", + "//:mem", + "//:message", + ], +) + +cc_test( + name = "protos_internal_test", + srcs = ["protos_internal_test.cc"], + copts = UPB_DEFAULT_CPPOPTS, + deps = [ + ":protos_internal", + "//:mem", + "//protos_generator/tests:test_model_upb_cc_proto", + "//protos_generator/tests:test_model_upb_proto", + "@com_google_googletest//:gtest_main", + ], +) + +upb_cc_proto_library_copts( + name = "upb_cc_proto_library_copts__for_generated_code_only_do_not_use", + copts = UPB_DEFAULT_CPPOPTS, + visibility = ["//visibility:public"], +) + +cc_test( + name = "repeated_field_iterator_test", + srcs = ["repeated_field_iterator_test.cc"], + deps = [ + ":repeated_field", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "protos_extension_lock_test", + srcs = ["protos_extension_lock_test.cc"], + deps = [ + "//:mem", + "//protos", + "//protos:protos_extension_lock", + "//protos_generator/tests:test_model_upb_cc_proto", + "@com_google_absl//absl/hash", + "@com_google_absl//absl/log:absl_check", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/archive/protos/bazel/BUILD b/archive/protos/bazel/BUILD new file mode 100644 index 0000000000..e56be4c452 --- /dev/null +++ b/archive/protos/bazel/BUILD @@ -0,0 +1,43 @@ +# 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. + +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +# begin:google_only +# package(default_applicable_licenses = ["//:license"]) +# end:google_only + +licenses(["notice"]) + +bzl_library( + name = "upb_cc_proto_library_bzl", + srcs = ["upb_cc_proto_library.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_skylib//lib:paths", + "//bazel:upb_proto_library_bzl", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + ], +) diff --git a/archive/protos/bazel/upb_cc_proto_library.bzl b/archive/protos/bazel/upb_cc_proto_library.bzl new file mode 100644 index 0000000000..f109f9d247 --- /dev/null +++ b/archive/protos/bazel/upb_cc_proto_library.bzl @@ -0,0 +1,307 @@ +# 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. + +"""Public rules for using upb protos: + - upb_cc_proto_library() +""" + +load("@bazel_skylib//lib:paths.bzl", "paths") +load("//bazel:upb_proto_library.bzl", "GeneratedSrcsInfo", "UpbWrappedCcInfo", "upb_proto_library_aspect") + +# begin:google_only +# load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") +# +# end:google_only +# begin:github_only +# Compatibility code for Bazel 4.x. Remove this when we drop support for Bazel 4.x. +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") + +def use_cpp_toolchain(): + return ["@bazel_tools//tools/cpp:toolchain_type"] +# end:github_only + +# Generic support code ######################################################### + +# begin:github_only +_is_google3 = False +# end:github_only + +# begin:google_only +# _is_google3 = True +# end:google_only + +def _get_real_short_path(file): + # For some reason, files from other archives have short paths that look like: + # ../com_google_protobuf/google/protobuf/descriptor.proto + short_path = file.short_path + if short_path.startswith("../"): + second_slash = short_path.index("/", 3) + short_path = short_path[second_slash + 1:] + + # Sometimes it has another few prefixes like: + # _virtual_imports/any_proto/google/protobuf/any.proto + # benchmarks/_virtual_imports/100_msgs_proto/benchmarks/100_msgs.proto + # We want just google/protobuf/any.proto. + virtual_imports = "_virtual_imports/" + if virtual_imports in short_path: + short_path = short_path.split(virtual_imports)[1].split("/", 1)[1] + return short_path + +def _get_real_root(file): + real_short_path = _get_real_short_path(file) + return file.path[:-len(real_short_path) - 1] + +def _generate_output_file(ctx, src, extension): + real_short_path = _get_real_short_path(src) + real_short_path = paths.relativize(real_short_path, ctx.label.package) + output_filename = paths.replace_extension(real_short_path, extension) + ret = ctx.actions.declare_file(output_filename) + return ret + +def _filter_none(elems): + out = [] + for elem in elems: + if elem: + out.append(elem) + return out + +def _cc_library_func(ctx, name, hdrs, srcs, copts, dep_ccinfos): + """Like cc_library(), but callable from rules. + + Args: + ctx: Rule context. + name: Unique name used to generate output files. + hdrs: Public headers that can be #included from other rules. + srcs: C/C++ source files. + copts: Additional options for cc compilation. + dep_ccinfos: CcInfo providers of dependencies we should build/link against. + + Returns: + CcInfo provider for this compilation. + """ + + compilation_contexts = [info.compilation_context for info in dep_ccinfos] + linking_contexts = [info.linking_context for info in dep_ccinfos] + toolchain = find_cpp_toolchain(ctx) + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) + + (compilation_context, compilation_outputs) = cc_common.compile( + actions = ctx.actions, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + name = name, + srcs = srcs, + public_hdrs = hdrs, + user_compile_flags = copts, + compilation_contexts = compilation_contexts, + ) + + # buildifier: disable=unused-variable + (linking_context, linking_outputs) = cc_common.create_linking_context_from_compilation_outputs( + actions = ctx.actions, + name = name, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + compilation_outputs = compilation_outputs, + linking_contexts = linking_contexts, + ) + + return CcInfo( + compilation_context = compilation_context, + linking_context = linking_context, + ) + +# Dummy rule to expose select() copts to aspects ############################## + +UpbCcProtoLibraryCoptsInfo = provider( + "Provides copts for upb cc proto targets", + fields = { + "copts": "copts for upb_cc_proto_library()", + }, +) + +def upb_cc_proto_library_copts_impl(ctx): + return UpbCcProtoLibraryCoptsInfo(copts = ctx.attr.copts) + +upb_cc_proto_library_copts = rule( + implementation = upb_cc_proto_library_copts_impl, + attrs = {"copts": attr.string_list(default = [])}, +) + +_UpbCcWrappedCcInfo = provider("Provider for cc_info for protos", fields = ["cc_info"]) +_WrappedCcGeneratedSrcsInfo = provider("Provider for generated sources", fields = ["srcs"]) + +def _compile_upb_cc_protos(ctx, generator, proto_info, proto_sources): + if len(proto_sources) == 0: + return GeneratedSrcsInfo(srcs = [], hdrs = []) + + tool = getattr(ctx.executable, "_gen_" + generator) + srcs = [_generate_output_file(ctx, name, ".upb.proto.cc") for name in proto_sources] + hdrs = [_generate_output_file(ctx, name, ".upb.proto.h") for name in proto_sources] + hdrs += [_generate_output_file(ctx, name, ".upb.fwd.h") for name in proto_sources] + transitive_sets = proto_info.transitive_descriptor_sets.to_list() + + args = ctx.actions.args() + args.use_param_file(param_file_arg = "@%s") + args.set_param_file_format("multiline") + + args.add("--" + generator + "_out=" + _get_real_root(srcs[0])) + args.add("--plugin=protoc-gen-" + generator + "=" + tool.path) + args.add("--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets])) + args.add_all(proto_sources, map_each = _get_real_short_path) + + ctx.actions.run( + inputs = depset( + direct = [proto_info.direct_descriptor_set], + transitive = [proto_info.transitive_descriptor_sets], + ), + tools = [tool], + outputs = srcs + hdrs, + executable = ctx.executable._protoc, + arguments = [args], + progress_message = "Generating upb cc protos for :" + ctx.label.name, + ) + return GeneratedSrcsInfo(srcs = srcs, hdrs = hdrs) + +def _upb_cc_proto_rule_impl(ctx): + if len(ctx.attr.deps) != 1: + fail("only one deps dependency allowed.") + dep = ctx.attr.deps[0] + + if _WrappedCcGeneratedSrcsInfo in dep: + srcs = dep[_WrappedCcGeneratedSrcsInfo].srcs + else: + fail("proto_library rule must generate _WrappedCcGeneratedSrcsInfo (aspect should have " + + "handled this).") + + if _UpbCcWrappedCcInfo in dep: + cc_info = dep[_UpbCcWrappedCcInfo].cc_info + elif UpbWrappedCcInfo in dep: + cc_info = dep[UpbWrappedCcInfo].cc_info + else: + fail("proto_library rule must generate UpbWrappedCcInfo or " + + "_UpbCcWrappedCcInfo (aspect should have handled this).") + + lib = cc_info.linking_context.linker_inputs.to_list()[0].libraries[0] + files = _filter_none([ + lib.static_library, + lib.pic_static_library, + lib.dynamic_library, + ]) + return [ + DefaultInfo(files = depset(files + srcs.hdrs + srcs.srcs)), + srcs, + cc_info, + ] + +def _upb_cc_proto_aspect_impl(target, ctx, generator, cc_provider, file_provider): + proto_info = target[ProtoInfo] + files = _compile_upb_cc_protos(ctx, generator, proto_info, proto_info.direct_sources) + deps = ctx.rule.attr.deps + getattr(ctx.attr, "_" + generator) + dep_ccinfos = [dep[CcInfo] for dep in deps if CcInfo in dep] + dep_ccinfos += [dep[UpbWrappedCcInfo].cc_info for dep in deps if UpbWrappedCcInfo in dep] + dep_ccinfos += [dep[_UpbCcWrappedCcInfo].cc_info for dep in deps if _UpbCcWrappedCcInfo in dep] + if UpbWrappedCcInfo not in target: + fail("Target should have UpbWrappedCcInfo provider") + dep_ccinfos.append(target[UpbWrappedCcInfo].cc_info) + cc_info = _cc_library_func( + ctx = ctx, + name = ctx.rule.attr.name + "." + generator, + hdrs = files.hdrs, + srcs = files.srcs, + copts = ctx.attr._ccopts[UpbCcProtoLibraryCoptsInfo].copts, + dep_ccinfos = dep_ccinfos, + ) + return [cc_provider(cc_info = cc_info), file_provider(srcs = files)] + +def _upb_cc_proto_library_aspect_impl(target, ctx): + return _upb_cc_proto_aspect_impl(target, ctx, "upbprotos", _UpbCcWrappedCcInfo, _WrappedCcGeneratedSrcsInfo) + +_upb_cc_proto_library_aspect = aspect( + attrs = { + "_ccopts": attr.label( + default = "//protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use", + ), + "_gen_upbprotos": attr.label( + executable = True, + cfg = "exec", + default = "//protos_generator:protoc-gen-upb-protos", + ), + "_protoc": attr.label( + executable = True, + cfg = "exec", + default = "@com_google_protobuf//:protoc", + ), + "_cc_toolchain": attr.label( + default = "@bazel_tools//tools/cpp:current_cc_toolchain", + ), + "_upbprotos": attr.label_list( + default = [ + # TODO: Add dependencies for cc runtime (absl/string etc..) + "//:generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + "//protos:generated_protos_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/status:statusor", + "//protos", + "//protos:repeated_field", + ], + ), + }, + implementation = _upb_cc_proto_library_aspect_impl, + provides = [ + _UpbCcWrappedCcInfo, + _WrappedCcGeneratedSrcsInfo, + ], + required_aspect_providers = [ + UpbWrappedCcInfo, + ], + attr_aspects = ["deps"], + fragments = ["cpp"], + toolchains = use_cpp_toolchain(), + incompatible_use_toolchain_transition = True, +) + +upb_cc_proto_library = rule( + output_to_genfiles = True, + implementation = _upb_cc_proto_rule_impl, + attrs = { + "deps": attr.label_list( + aspects = [ + upb_proto_library_aspect, + _upb_cc_proto_library_aspect, + ], + allow_rules = ["proto_library"], + providers = [ProtoInfo], + ), + "_ccopts": attr.label( + default = "//protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use", + ), + }, +) diff --git a/archive/protos/protos.cc b/archive/protos/protos.cc new file mode 100644 index 0000000000..79535f5eef --- /dev/null +++ b/archive/protos/protos.cc @@ -0,0 +1,187 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "protos/protos.h" + +#include +#include + +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" +#include "protos/protos_extension_lock.h" +#include "upb/mem/arena.h" +#include "upb/message/copy.h" +#include "upb/message/internal/extension.h" +#include "upb/message/promote.h" +#include "upb/mini_table/extension.h" +#include "upb/mini_table/extension_registry.h" +#include "upb/mini_table/message.h" +#include "upb/wire/decode.h" +#include "upb/wire/encode.h" + +namespace protos { + +// begin:google_only +// absl::Status MessageAllocationError(SourceLocation loc) { +// return absl::Status(absl::StatusCode::kInternal, +// "Upb message allocation error", loc); +// } +// +// absl::Status ExtensionNotFoundError(int extension_number, SourceLocation loc) { +// return absl::Status( +// absl::StatusCode::kInternal, +// absl::StrFormat("Extension %d not found", extension_number), loc); +// } +// +// absl::Status MessageEncodeError(upb_EncodeStatus status, SourceLocation loc) { +// return absl::Status(absl::StatusCode::kInternal, +// absl::StrFormat("Upb message encoding error %d", status), +// loc +// +// ); +// } +// +// absl::Status MessageDecodeError(upb_DecodeStatus status, SourceLocation loc +// +// ) { +// return absl::Status(absl::StatusCode::kInternal, +// absl::StrFormat("Upb message parse error %d", status), loc +// +// ); +// } +// end:google_only + +// begin:github_only +absl::Status MessageAllocationError(SourceLocation loc) { + return absl::Status(absl::StatusCode::kUnknown, + "Upb message allocation error"); +} + +absl::Status ExtensionNotFoundError(int ext_number, SourceLocation loc) { + return absl::Status(absl::StatusCode::kUnknown, + absl::StrFormat("Extension %d not found", ext_number)); +} + +absl::Status MessageEncodeError(upb_EncodeStatus s, SourceLocation loc) { + return absl::Status(absl::StatusCode::kUnknown, "Encoding error"); +} + +absl::Status MessageDecodeError(upb_DecodeStatus status, SourceLocation loc + +) { + return absl::Status(absl::StatusCode::kUnknown, "Upb message parse error"); +} +// end:github_only + +namespace internal { + +upb_ExtensionRegistry* GetUpbExtensions( + const ExtensionRegistry& extension_registry) { + return extension_registry.registry_; +} + +/** + * MessageLock(msg) acquires lock on msg when constructed and releases it when + * destroyed. + */ +class MessageLock { + public: + explicit MessageLock(const upb_Message* msg) : msg_(msg) { + UpbExtensionLocker locker = + upb_extension_locker_global.load(std::memory_order_acquire); + unlocker_ = (locker != nullptr) ? locker(msg) : nullptr; + } + MessageLock(const MessageLock&) = delete; + void operator=(const MessageLock&) = delete; + ~MessageLock() { + if (unlocker_ != nullptr) { + unlocker_(msg_); + } + } + + private: + const upb_Message* msg_; + UpbExtensionUnlocker unlocker_; +}; + +bool HasExtensionOrUnknown(const upb_Message* msg, + const upb_MiniTableExtension* eid) { + MessageLock msg_lock(msg); + return _upb_Message_Getext(msg, eid) != nullptr || + upb_MiniTable_FindUnknown(msg, eid->field.number, + kUpb_WireFormat_DefaultDepthLimit) + .status == kUpb_FindUnknown_Ok; +} + +const upb_Message_Extension* GetOrPromoteExtension( + upb_Message* msg, const upb_MiniTableExtension* eid, upb_Arena* arena) { + MessageLock msg_lock(msg); + const upb_Message_Extension* ext = _upb_Message_Getext(msg, eid); + if (ext == nullptr) { + upb_GetExtension_Status ext_status = upb_MiniTable_GetOrPromoteExtension( + (upb_Message*)msg, eid, kUpb_WireFormat_DefaultDepthLimit, arena, &ext); + if (ext_status != kUpb_GetExtension_Ok) { + ext = nullptr; + } + } + return ext; +} + +absl::StatusOr Serialize(const upb_Message* message, + const upb_MiniTable* mini_table, + upb_Arena* arena, int options) { + MessageLock msg_lock(message); + size_t len; + char* ptr; + upb_EncodeStatus status = + upb_Encode(message, mini_table, options, arena, &ptr, &len); + if (status == kUpb_EncodeStatus_Ok) { + return absl::string_view(ptr, len); + } + return MessageEncodeError(status); +} + +void DeepCopy(upb_Message* target, const upb_Message* source, + const upb_MiniTable* mini_table, upb_Arena* arena) { + MessageLock msg_lock(source); + upb_Message_DeepCopy(target, source, mini_table, arena); +} + +upb_Message* DeepClone(const upb_Message* source, + const upb_MiniTable* mini_table, upb_Arena* arena) { + MessageLock msg_lock(source); + return upb_Message_DeepClone(source, mini_table, arena); +} + +} // namespace internal + +} // namespace protos diff --git a/archive/protos/protos.h b/archive/protos/protos.h new file mode 100644 index 0000000000..8d1adae462 --- /dev/null +++ b/archive/protos/protos.h @@ -0,0 +1,520 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef UPB_PROTOS_PROTOS_H_ +#define UPB_PROTOS_PROTOS_H_ + +#include +#include + +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "upb/base/status.hpp" +#include "upb/mem/arena.hpp" +#include "upb/message/copy.h" +#include "upb/message/internal/extension.h" +#include "upb/wire/decode.h" +#include "upb/wire/encode.h" + +namespace protos { + +using Arena = ::upb::Arena; +class ExtensionRegistry; + +template +using Proxy = std::conditional_t::value, + typename std::remove_const_t::CProxy, + typename T::Proxy>; + +// Provides convenient access to Proxy and CProxy message types. +// +// Using rebinding and handling of const, Ptr and Ptr +// allows copying const with T* const and avoids using non-copyable Proxy types +// directly. +template +class Ptr final { + public: + Ptr() = delete; + + // Implicit conversions + Ptr(T* m) : p_(m) {} // NOLINT + Ptr(const Proxy* p) : p_(*p) {} // NOLINT + Ptr(Proxy p) : p_(p) {} // NOLINT + Ptr(const Ptr& m) = default; + + Ptr& operator=(Ptr v) & { + Proxy::Rebind(p_, v.p_); + return *this; + } + + Proxy operator*() const { return p_; } + Proxy* operator->() const { + return const_cast*>(std::addressof(p_)); + } + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wclass-conversion" +#endif + template ::value, int> = 0> + operator Ptr() const { + Proxy p(p_); + return Ptr(&p); + } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + + private: + Ptr(void* msg, upb_Arena* arena) : p_(msg, arena) {} // NOLINT + + friend class Ptr; + friend typename T::Access; + + Proxy p_; +}; + +namespace internal { +struct PrivateAccess { + template + static auto* GetInternalMsg(T&& message) { + return message->msg(); + } +}; + +template +auto* GetInternalMsg(T&& message) { + return PrivateAccess::GetInternalMsg(std::forward(message)); +} + +} // namespace internal + +inline absl::string_view UpbStrToStringView(upb_StringView str) { + return absl::string_view(str.data, str.size); +} + +// TODO: update bzl and move to upb runtime / protos.cc. +inline upb_StringView UpbStrFromStringView(absl::string_view str, + upb_Arena* arena) { + const size_t str_size = str.size(); + char* buffer = static_cast(upb_Arena_Malloc(arena, str_size)); + memcpy(buffer, str.data(), str_size); + return upb_StringView_FromDataAndSize(buffer, str_size); +} + +template +typename T::Proxy CreateMessage(::protos::Arena& arena) { + return typename T::Proxy(upb_Message_New(T::minitable(), arena.ptr()), + arena.ptr()); +} + +// begin:github_only +// This type exists to work around an absl type that has not yet been +// released. +struct SourceLocation { + static SourceLocation current() { return {}; } + absl::string_view file_name() { return ""; } + int line() { return 0; } +}; +// end:github_only + +// begin:google_only +// using SourceLocation = absl::SourceLocation; +// end:google_only + +absl::Status MessageAllocationError( + SourceLocation loc = SourceLocation::current()); + +absl::Status ExtensionNotFoundError( + int extension_number, SourceLocation loc = SourceLocation::current()); + +absl::Status MessageDecodeError(upb_DecodeStatus status, + SourceLocation loc = SourceLocation::current()); + +absl::Status MessageEncodeError(upb_EncodeStatus status, + SourceLocation loc = SourceLocation::current()); + +namespace internal { +template +T CreateMessage() { + return T(); +} + +template +typename T::Proxy CreateMessageProxy(void* msg, upb_Arena* arena) { + return typename T::Proxy(msg, arena); +} + +template +typename T::CProxy CreateMessage(upb_Message* msg, upb_Arena* arena) { + return typename T::CProxy(msg, arena); +} + +class ExtensionMiniTableProvider { + public: + constexpr explicit ExtensionMiniTableProvider( + const upb_MiniTableExtension* mini_table_ext) + : mini_table_ext_(mini_table_ext) {} + const upb_MiniTableExtension* mini_table_ext() const { + return mini_table_ext_; + } + + private: + const upb_MiniTableExtension* mini_table_ext_; +}; + +// ------------------------------------------------------------------- +// ExtensionIdentifier +// This is the type of actual extension objects. E.g. if you have: +// extend Foo { +// optional MyExtension bar = 1234; +// } +// then "bar" will be defined in C++ as: +// ExtensionIdentifier bar(&namespace_bar_ext); +template +class ExtensionIdentifier : public ExtensionMiniTableProvider { + public: + using Extension = ExtensionType; + using Extendee = ExtendeeType; + + constexpr explicit ExtensionIdentifier( + const upb_MiniTableExtension* mini_table_ext) + : ExtensionMiniTableProvider(mini_table_ext) {} +}; + +template +upb_Arena* GetArena(Ptr message) { + return static_cast(message->GetInternalArena()); +} + +template +upb_Arena* GetArena(T* message) { + return static_cast(message->GetInternalArena()); +} + +template +const upb_MiniTable* GetMiniTable(const T*) { + return T::minitable(); +} + +template +const upb_MiniTable* GetMiniTable(Ptr) { + return T::minitable(); +} + +upb_ExtensionRegistry* GetUpbExtensions( + const ExtensionRegistry& extension_registry); + +absl::StatusOr Serialize(const upb_Message* message, + const upb_MiniTable* mini_table, + upb_Arena* arena, int options); + +bool HasExtensionOrUnknown(const upb_Message* msg, + const upb_MiniTableExtension* eid); + +const upb_Message_Extension* GetOrPromoteExtension( + upb_Message* msg, const upb_MiniTableExtension* eid, upb_Arena* arena); + +void DeepCopy(upb_Message* target, const upb_Message* source, + const upb_MiniTable* mini_table, upb_Arena* arena); + +upb_Message* DeepClone(const upb_Message* source, + const upb_MiniTable* mini_table, upb_Arena* arena); + +} // namespace internal + +template +void DeepCopy(Ptr source_message, Ptr target_message) { + static_assert(!std::is_const_v); + ::protos::internal::DeepCopy( + internal::GetInternalMsg(target_message), + internal::GetInternalMsg(source_message), T::minitable(), + static_cast(target_message->GetInternalArena())); +} + +template +typename T::Proxy CloneMessage(Ptr message, upb::Arena& arena) { + return typename T::Proxy( + ::protos::internal::DeepClone(internal::GetInternalMsg(message), + T::minitable(), arena.ptr()), + arena.ptr()); +} + +template +void DeepCopy(Ptr source_message, T* target_message) { + static_assert(!std::is_const_v); + DeepCopy(source_message, protos::Ptr(target_message)); +} + +template +void DeepCopy(const T* source_message, Ptr target_message) { + static_assert(!std::is_const_v); + DeepCopy(protos::Ptr(source_message), target_message); +} + +template +void DeepCopy(const T* source_message, T* target_message) { + static_assert(!std::is_const_v); + DeepCopy(protos::Ptr(source_message), protos::Ptr(target_message)); +} + +template +void ClearMessage(Ptr message) { + static_assert(!std::is_const_v, ""); + upb_Message_Clear(internal::GetInternalMsg(message), T::minitable()); +} + +template +void ClearMessage(T* message) { + ClearMessage(protos::Ptr(message)); +} + +class ExtensionRegistry { + public: + ExtensionRegistry( + const std::vector& + extensions, + const upb::Arena& arena) + : registry_(upb_ExtensionRegistry_New(arena.ptr())) { + if (registry_) { + for (const auto& ext_provider : extensions) { + const auto* ext = ext_provider->mini_table_ext(); + bool success = upb_ExtensionRegistry_AddArray(registry_, &ext, 1); + if (!success) { + registry_ = nullptr; + break; + } + } + } + } + + private: + friend upb_ExtensionRegistry* ::protos::internal::GetUpbExtensions( + const ExtensionRegistry& extension_registry); + upb_ExtensionRegistry* registry_; +}; + +template +using EnableIfProtosClass = std::enable_if_t< + std::is_base_of::value && + std::is_base_of::value>; + +template +using EnableIfMutableProto = std::enable_if_t::value>; + +template > +ABSL_MUST_USE_RESULT bool HasExtension( + Ptr message, + const ::protos::internal::ExtensionIdentifier& id) { + return ::protos::internal::HasExtensionOrUnknown( + ::protos::internal::GetInternalMsg(message), id.mini_table_ext()); +} + +template > +ABSL_MUST_USE_RESULT bool HasExtension( + const T* message, + const ::protos::internal::ExtensionIdentifier& id) { + return HasExtension(protos::Ptr(message), id); +} + +template , typename = EnableIfMutableProto> +void ClearExtension( + Ptr message, + const ::protos::internal::ExtensionIdentifier& id) { + static_assert(!std::is_const_v, ""); + _upb_Message_ClearExtensionField(internal::GetInternalMsg(message), + id.mini_table_ext()); +} + +template > +void ClearExtension( + T* message, + const ::protos::internal::ExtensionIdentifier& id) { + ClearExtension(::protos::Ptr(message), id); +} + +template , typename = EnableIfMutableProto> +absl::Status SetExtension( + Ptr message, + const ::protos::internal::ExtensionIdentifier& id, + Extension& value) { + static_assert(!std::is_const_v); + auto* message_arena = static_cast(message->GetInternalArena()); + upb_Message_Extension* msg_ext = _upb_Message_GetOrCreateExtension( + internal::GetInternalMsg(message), id.mini_table_ext(), message_arena); + if (!msg_ext) { + return MessageAllocationError(); + } + auto* extension_arena = static_cast(message->GetInternalArena()); + if (message_arena != extension_arena) { + upb_Arena_Fuse(message_arena, extension_arena); + } + msg_ext->data.ptr = internal::GetInternalMsg(&value); + return absl::OkStatus(); +} + +template > +absl::Status SetExtension( + T* message, + const ::protos::internal::ExtensionIdentifier& id, + Extension& value) { + return ::protos::SetExtension(::protos::Ptr(message), id, value); +} + +template > +absl::StatusOr> GetExtension( + Ptr message, + const ::protos::internal::ExtensionIdentifier& id) { + // TODO(b/294089233): Fix const correctness issues. + const upb_Message_Extension* ext = ::protos::internal::GetOrPromoteExtension( + const_cast(internal::GetInternalMsg(message)), + id.mini_table_ext(), ::protos::internal::GetArena(message)); + if (!ext) { + return ExtensionNotFoundError(id.mini_table_ext()->field.number); + } + return Ptr(::protos::internal::CreateMessage( + ext->data.ptr, ::protos::internal::GetArena(message))); +} + +template > +absl::StatusOr> GetExtension( + const T* message, + const ::protos::internal::ExtensionIdentifier& id) { + return GetExtension(protos::Ptr(message), id); +} + +template +ABSL_MUST_USE_RESULT bool Parse(Ptr message, absl::string_view bytes) { + static_assert(!std::is_const_v); + upb_Message_Clear(internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message)); + auto* arena = static_cast(message->GetInternalArena()); + return upb_Decode(bytes.data(), bytes.size(), + internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message), + /* extreg= */ nullptr, /* options= */ 0, + arena) == kUpb_DecodeStatus_Ok; +} + +template +ABSL_MUST_USE_RESULT bool Parse( + Ptr message, absl::string_view bytes, + const ::protos::ExtensionRegistry& extension_registry) { + static_assert(!std::is_const_v); + upb_Message_Clear(internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message)); + auto* arena = static_cast(message->GetInternalArena()); + return upb_Decode(bytes.data(), bytes.size(), + internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message), + /* extreg= */ + ::protos::internal::GetUpbExtensions(extension_registry), + /* options= */ 0, arena) == kUpb_DecodeStatus_Ok; +} + +template +ABSL_MUST_USE_RESULT bool Parse( + T* message, absl::string_view bytes, + const ::protos::ExtensionRegistry& extension_registry) { + static_assert(!std::is_const_v); + return Parse(protos::Ptr(message, bytes, extension_registry)); +} + +template +ABSL_MUST_USE_RESULT bool Parse(T* message, absl::string_view bytes) { + static_assert(!std::is_const_v); + upb_Message_Clear(internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message)); + auto* arena = static_cast(message->GetInternalArena()); + return upb_Decode(bytes.data(), bytes.size(), + internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message), + /* extreg= */ nullptr, /* options= */ 0, + arena) == kUpb_DecodeStatus_Ok; +} + +template +absl::StatusOr Parse(absl::string_view bytes, int options = 0) { + T message; + auto* arena = static_cast(message.GetInternalArena()); + upb_DecodeStatus status = + upb_Decode(bytes.data(), bytes.size(), message.msg(), + ::protos::internal::GetMiniTable(&message), + /* extreg= */ nullptr, /* options= */ 0, arena); + if (status == kUpb_DecodeStatus_Ok) { + return message; + } + return MessageDecodeError(status); +} + +template +absl::StatusOr Parse(absl::string_view bytes, + const ::protos::ExtensionRegistry& extension_registry, + int options = 0) { + T message; + auto* arena = static_cast(message.GetInternalArena()); + upb_DecodeStatus status = + upb_Decode(bytes.data(), bytes.size(), message.msg(), + ::protos::internal::GetMiniTable(&message), + ::protos::internal::GetUpbExtensions(extension_registry), + /* options= */ 0, arena); + if (status == kUpb_DecodeStatus_Ok) { + return message; + } + return MessageDecodeError(status); +} + +template +absl::StatusOr Serialize(const T* message, upb::Arena& arena, + int options = 0) { + return ::protos::internal::Serialize( + internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message), arena.ptr(), options); +} + +template +absl::StatusOr Serialize(Ptr message, upb::Arena& arena, + int options = 0) { + return ::protos::internal::Serialize( + internal::GetInternalMsg(message), + ::protos::internal::GetMiniTable(message), arena.ptr(), options); +} + +} // namespace protos + +#endif // UPB_PROTOS_PROTOS_H_ diff --git a/archive/protos/protos_extension_lock.cc b/archive/protos/protos_extension_lock.cc new file mode 100644 index 0000000000..dbb2fc2ed2 --- /dev/null +++ b/archive/protos/protos_extension_lock.cc @@ -0,0 +1,39 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "protos/protos_extension_lock.h" + +#include + +namespace protos::internal { + +std::atomic upb_extension_locker_global; + +} // namespace protos::internal diff --git a/archive/protos/protos_extension_lock.h b/archive/protos/protos_extension_lock.h new file mode 100644 index 0000000000..04a268d5b8 --- /dev/null +++ b/archive/protos/protos_extension_lock.h @@ -0,0 +1,54 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef UPB_PROTOS_PROTOS_EXTENSION_LOCK_H_ +#define UPB_PROTOS_PROTOS_EXTENSION_LOCK_H_ + +#include + +namespace protos::internal { + +// TODO(b/295355754): Temporary locking api for cross-language +// concurrency issue around extension api that uses lazy promotion +// from unknown data to upb_MiniTableExtension. Will be replaced by +// a core runtime solution in the future. +// +// Any api(s) using unknown or extension data (GetOrPromoteExtension, +// Serialize and others) call lock/unlock to provide a way for +// mixed language implementations to avoid race conditions) +using UpbExtensionUnlocker = void (*)(const void*); +using UpbExtensionLocker = UpbExtensionUnlocker (*)(const void*); + +// TODO(b/295355754): Expose as function instead of global. +extern std::atomic upb_extension_locker_global; + +} // namespace protos::internal + +#endif // UPB_PROTOS_PROTOS_EXTENSION_LOCK_H_ diff --git a/archive/protos/protos_extension_lock_test.cc b/archive/protos/protos_extension_lock_test.cc new file mode 100644 index 0000000000..774e4078c3 --- /dev/null +++ b/archive/protos/protos_extension_lock_test.cc @@ -0,0 +1,140 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "protos/protos_extension_lock.h" + +#include +#include +#include +#include + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "absl/hash/hash.h" +#include "absl/log/absl_check.h" +#include "protos/protos.h" +#include "protos_generator/tests/test_model.upb.proto.h" +#include "upb/mem/arena.hpp" + +#ifndef ASSERT_OK +#define ASSERT_OK(x) ASSERT_TRUE(x.ok()) +#endif // ASSERT_OK +#ifndef EXPECT_OK +#define EXPECT_OK(x) EXPECT_TRUE(x.ok()) +#endif // EXPECT_OK + +namespace protos_generator::test::protos { + +namespace { + +std::string GenerateTestData() { + TestModel model; + model.set_str1("str"); + ThemeExtension extension1; + extension1.set_ext_name("theme"); + ABSL_CHECK_OK(::protos::SetExtension(&model, theme, extension1)); + ThemeExtension extension2; + extension2.set_ext_name("theme_extension"); + ABSL_CHECK_OK(::protos::SetExtension(&model, ThemeExtension::theme_extension, + extension2)); + ::upb::Arena arena; + auto bytes = ::protos::Serialize(&model, arena); + ABSL_CHECK_OK(bytes); + return std::string(bytes->data(), bytes->size()); +} + +std::mutex m[8]; +void unlock_func(const void* msg) { m[absl::HashOf(msg) & 0x7].unlock(); } +::protos::internal::UpbExtensionUnlocker lock_func(const void* msg) { + m[absl::HashOf(msg) & 0x7].lock(); + return &unlock_func; +} + +void TestConcurrentExtensionAccess(::protos::ExtensionRegistry registry) { + ::protos::internal::upb_extension_locker_global.store( + &lock_func, std::memory_order_release); + const std::string payload = GenerateTestData(); + TestModel parsed_model = + ::protos::Parse(payload, registry).value(); + const auto test_main = [&] { EXPECT_EQ("str", parsed_model.str1()); }; + const auto test_theme = [&] { + ASSERT_TRUE(::protos::HasExtension(&parsed_model, theme)); + auto ext = ::protos::GetExtension(&parsed_model, theme); + ASSERT_OK(ext); + EXPECT_EQ((*ext)->ext_name(), "theme"); + }; + const auto test_theme_extension = [&] { + auto ext = + ::protos::GetExtension(&parsed_model, ThemeExtension::theme_extension); + ASSERT_OK(ext); + EXPECT_EQ((*ext)->ext_name(), "theme_extension"); + }; + const auto test_serialize = [&] { + ::upb::Arena arena; + EXPECT_OK(::protos::Serialize(&parsed_model, arena)); + }; + std::thread t1(test_main); + std::thread t2(test_main); + std::thread t3(test_theme); + std::thread t4(test_theme); + std::thread t5(test_theme_extension); + std::thread t6(test_theme_extension); + std::thread t7(test_serialize); + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + t6.join(); + t7.join(); + test_main(); + test_theme(); + test_theme_extension(); +} + +TEST(CppGeneratedCode, ConcurrentAccessDoesNotRaceBothLazy) { + ::upb::Arena arena; + TestConcurrentExtensionAccess({{}, arena}); +} + +TEST(CppGeneratedCode, ConcurrentAccessDoesNotRaceOneLazyOneEager) { + ::upb::Arena arena; + TestConcurrentExtensionAccess({{&theme}, arena}); + TestConcurrentExtensionAccess({{&ThemeExtension::theme_extension}, arena}); +} + +TEST(CppGeneratedCode, ConcurrentAccessDoesNotRaceBothEager) { + ::upb::Arena arena; + TestConcurrentExtensionAccess( + {{&theme, &ThemeExtension::theme_extension}, arena}); +} + +} // namespace +} // namespace protos_generator::test::protos diff --git a/archive/protos/protos_internal.h b/archive/protos/protos_internal.h new file mode 100644 index 0000000000..0a1f194d3a --- /dev/null +++ b/archive/protos/protos_internal.h @@ -0,0 +1,48 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef UPB_PROTOS_PROTOS_INTERNAL_H_ +#define UPB_PROTOS_PROTOS_INTERNAL_H_ + +#include "upb/mem/arena.h" +#include "upb/message/message.h" + +namespace protos::internal { + +// Moves ownership of a message created in a source arena. +// +// Utility function to provide a way to move ownership across languages or VMs. +template +T MoveMessage(upb_Message* msg, upb_Arena* arena) { + return T(msg, arena); +} + +} // namespace protos::internal +#endif diff --git a/archive/protos/protos_internal_test.cc b/archive/protos/protos_internal_test.cc new file mode 100644 index 0000000000..e73954aaf3 --- /dev/null +++ b/archive/protos/protos_internal_test.cc @@ -0,0 +1,60 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "protos/protos_internal.h" + +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "protos_generator/tests/test_model.upb.h" +#include "protos_generator/tests/test_model.upb.proto.h" +#include "upb/mem/arena.h" + +namespace protos::testing { +namespace { +using ::protos_generator::test::protos::TestModel; + +TEST(CppGeneratedCode, InternalMoveMessage) { + // Generate message (simulating message created in another VM/language) + upb_Arena* source_arena = upb_Arena_New(); + protos_generator_test_TestModel* message = + protos_generator_test_TestModel_new(source_arena); + ASSERT_NE(message, nullptr); + protos_generator_test_TestModel_set_int_value_with_default(message, 123); + + // Move ownership. + TestModel model = + protos::internal::MoveMessage(message, source_arena); + // Now that we have moved ownership, free original arena. + upb_Arena_Free(source_arena); + EXPECT_EQ(model.int_value_with_default(), 123); +} + +} // namespace +} // namespace protos::testing diff --git a/archive/protos/protos_traits.h b/archive/protos/protos_traits.h new file mode 100644 index 0000000000..92b9dc33b6 --- /dev/null +++ b/archive/protos/protos_traits.h @@ -0,0 +1,44 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef THIRD_PARTY_UPB_PROTOS_PROTOS_TRAITS_H_ +#define THIRD_PARTY_UPB_PROTOS_PROTOS_TRAITS_H_ + +#include + +namespace protos::internal { + +template +using add_const_if_T_is_const = + std::conditional_t, const T2, T2>; + +} // namespace protos::internal + +#endif // THIRD_PARTY_UPB_PROTOS_PROTOS_TRAITS_H_ diff --git a/archive/protos/repeated_field.h b/archive/protos/repeated_field.h new file mode 100644 index 0000000000..9d66e15e38 --- /dev/null +++ b/archive/protos/repeated_field.h @@ -0,0 +1,309 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef UPB_PROTOS_REPEATED_FIELD_H_ +#define UPB_PROTOS_REPEATED_FIELD_H_ + +#include +#include +#include + +#include "absl/base/attributes.h" +#include "absl/strings/string_view.h" +#include "protos/protos.h" +#include "protos/protos_traits.h" +#include "protos/repeated_field_iterator.h" +#include "upb/base/string_view.h" +#include "upb/collections/array.h" +#include "upb/collections/internal/array.h" +#include "upb/mem/arena.h" +#include "upb/message/copy.h" + +// Must be last: +#include "upb/port/def.inc" + +namespace protos { + +namespace internal { + +// Shared implementation of repeated fields for absl::string_view and +// message types for mutable and immutable variants. +// +// Immutable (const accessor), constructs this class with a nullptr upb_Array* +// when the underlying array in the message is empty. +// +// Mutable accessors on the other hand, will allocate a new empty non-null +// upb_Array* for the message when the RepeatedFieldProxy is constructed. +template +class RepeatedFieldProxyBase { + using Array = add_const_if_T_is_const; + + public: + explicit RepeatedFieldProxyBase(Array* arr, upb_Arena* arena) + : arr_(arr), arena_(arena) {} + + size_t size() const { return arr_ != nullptr ? upb_Array_Size(arr_) : 0; } + + bool empty() const { return size() == 0; } + + protected: + // Returns upb_Array message member. + inline upb_Message* GetMessage(size_t n) const; + + Array* arr_; + upb_Arena* arena_; +}; + +template +upb_Message* RepeatedFieldProxyBase::GetMessage(size_t n) const { + auto** messages = + static_cast(upb_Array_MutableDataPtr(this->arr_)); + return messages[n]; +} + +template +class RepeatedFieldProxyMutableBase : public RepeatedFieldProxyBase { + public: + RepeatedFieldProxyMutableBase(upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyBase(arr, arena) {} + + void clear() { upb_Array_Resize(this->arr_, 0, this->arena_); } +}; + +// RepeatedField proxy for repeated messages. +template +class RepeatedFieldProxy + : public std::conditional_t, RepeatedFieldProxyBase, + RepeatedFieldProxyMutableBase> { + static_assert(!std::is_same_v, ""); + static_assert(!std::is_same_v, ""); + static_assert(!std::is_arithmetic_v, ""); + static constexpr bool kIsConst = std::is_const_v; + + public: + explicit RepeatedFieldProxy(const upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyBase(arr, arena) {} + RepeatedFieldProxy(upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyMutableBase(arr, arena) {} + // Constructor used by ::protos::Ptr. + RepeatedFieldProxy(const RepeatedFieldProxy&) = default; + + // T::CProxy [] operator specialization. + typename T::CProxy operator[](size_t n) const { + upb_MessageValue message_value = upb_Array_Get(this->arr_, n); + return ::protos::internal::CreateMessage>( + (upb_Message*)message_value.msg_val, this->arena_); + } + + // TODO(b:/280069986) : Audit/Finalize based on Iterator Design. + // T::Proxy [] operator specialization. + template > + typename T::Proxy operator[](size_t n) { + return ::protos::internal::CreateMessageProxy(this->GetMessage(n), + this->arena_); + } + + // Mutable message reference specialization. + template > + void push_back(const T& t) { + upb_MessageValue message_value; + message_value.msg_val = upb_Message_DeepClone( + PrivateAccess::GetInternalMsg(&t), ::protos::internal::GetMiniTable(&t), + this->arena_); + upb_Array_Append(this->arr_, message_value, this->arena_); + } + + // Mutable message add using move. + template > + void push_back(T&& msg) { + upb_MessageValue message_value; + message_value.msg_val = PrivateAccess::GetInternalMsg(&msg); + upb_Arena_Fuse(GetArena(&msg), this->arena_); + upb_Array_Append(this->arr_, message_value, this->arena_); + T moved_msg = std::move(msg); + } + + private: + friend class ::protos::Ptr; +}; + +// RepeatedField proxy for repeated strings. +template +class RepeatedFieldStringProxy + : public std::conditional_t, RepeatedFieldProxyBase, + RepeatedFieldProxyMutableBase> { + static_assert(std::is_same_v || + std::is_same_v, + ""); + static constexpr bool kIsConst = std::is_const_v; + + public: + using value_type = std::remove_const_t; + using size_type = size_t; + using difference_type = ptrdiff_t; + using iterator = internal::Iterator>; + using reference = typename iterator::reference; + using pointer = typename iterator::pointer; + using reverse_iterator = std::reverse_iterator; + + // Immutable constructor. + explicit RepeatedFieldStringProxy(const upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyBase(arr, arena) {} + // Mutable constructor. + RepeatedFieldStringProxy(upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyMutableBase(arr, arena) {} + // Constructor used by ::protos::Ptr. + RepeatedFieldStringProxy(const RepeatedFieldStringProxy&) = default; + + reference operator[](size_t n) const { return begin()[n]; } + + template > + void push_back(T t) { + upb_MessageValue message_value; + // Copy string to arena. + UPB_ASSERT(this->arena_); + char* data = (char*)upb_Arena_Malloc(this->arena_, t.size()); + UPB_ASSERT(data); + memcpy(data, t.data(), t.size()); + message_value.str_val = upb_StringView_FromDataAndSize(data, t.size()); + upb_Array_Append(this->arr_, message_value, this->arena_); + } + + iterator begin() const { return iterator({this->arr_, this->arena_, 0}); } + iterator end() const { + return iterator({this->arr_, this->arena_, this->size()}); + } + reverse_iterator rbegin() const { return reverse_iterator(end()); } + reverse_iterator rend() const { return reverse_iterator(begin()); } +}; + +// RepeatedField proxy for repeated scalar types. +template +class RepeatedFieldScalarProxy + : public std::conditional_t, RepeatedFieldProxyBase, + RepeatedFieldProxyMutableBase> { + static_assert(std::is_arithmetic_v, ""); + static constexpr bool kIsConst = std::is_const_v; + + public: + using value_type = std::remove_const_t; + using size_type = size_t; + using difference_type = ptrdiff_t; + using iterator = internal::Iterator>; + using reference = typename iterator::reference; + using pointer = typename iterator::pointer; + using reverse_iterator = std::reverse_iterator; + + explicit RepeatedFieldScalarProxy(const upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyBase(arr, arena) {} + RepeatedFieldScalarProxy(upb_Array* arr, upb_Arena* arena) + : RepeatedFieldProxyMutableBase(arr, arena) {} + // Constructor used by ::protos::Ptr. + RepeatedFieldScalarProxy(const RepeatedFieldScalarProxy&) = default; + + T operator[](size_t n) const { + upb_MessageValue message_value = upb_Array_Get(this->arr_, n); + typename std::remove_const_t val; + memcpy(&val, &message_value, sizeof(T)); + return val; + } + + template > + void push_back(T t) { + upb_MessageValue message_value; + memcpy(&message_value, &t, sizeof(T)); + upb_Array_Append(this->arr_, message_value, this->arena_); + } + + iterator begin() const { return iterator({unsafe_array()}); } + iterator cbegin() const { return begin(); } + iterator end() const { return iterator({unsafe_array() + this->size()}); } + iterator cend() const { return end(); } + + // Reverse iterator support. + reverse_iterator rbegin() const { return reverse_iterator(end()); } + reverse_iterator rend() const { return reverse_iterator(begin()); } + reverse_iterator crbegin() const { return reverse_iterator(end()); } + reverse_iterator crend() const { return reverse_iterator(begin()); } + + private: + T* unsafe_array() const { + if (kIsConst) { + const void* unsafe_ptr = ::upb_Array_DataPtr(this->arr_); + return static_cast(const_cast(unsafe_ptr)); + } + if (!kIsConst) { + void* unsafe_ptr = + ::upb_Array_MutableDataPtr(const_cast(this->arr_)); + return static_cast(unsafe_ptr); + } + } +}; + +} // namespace internal + +template +class RepeatedField { + static constexpr bool kIsString = std::is_same_v; + static constexpr bool kIsScalar = std::is_arithmetic_v; + + public: + using Proxy = std::conditional_t< + kIsScalar, internal::RepeatedFieldScalarProxy, + std::conditional_t, + internal::RepeatedFieldProxy>>; + using CProxy = std::conditional_t< + kIsScalar, internal::RepeatedFieldScalarProxy, + std::conditional_t, + internal::RepeatedFieldProxy>>; + // TODO(b/286451125): T supports incomplete type from fwd.h forwarding headers + // We would like to reference T::CProxy. Validate forwarding header design. + using ValueProxy = std::conditional_t< + kIsScalar, T, + std::conditional_t>>; + using ValueCProxy = std::conditional_t< + kIsScalar, const T, + std::conditional_t>>; + using Access = std::conditional_t< + kIsScalar, internal::RepeatedFieldScalarProxy, + std::conditional_t, + internal::RepeatedFieldProxy>>; +}; + +} // namespace protos + +#include "upb/port/undef.inc" + +#endif // UPB_PROTOS_REPEATED_FIELD_H_ diff --git a/archive/protos/repeated_field_iterator.h b/archive/protos/repeated_field_iterator.h new file mode 100644 index 0000000000..66227ba45b --- /dev/null +++ b/archive/protos/repeated_field_iterator.h @@ -0,0 +1,356 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google 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 THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifndef UPB_PROTOS_REPEATED_FIELD_ITERATOR_H_ +#define UPB_PROTOS_REPEATED_FIELD_ITERATOR_H_ + +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "protos/protos.h" +#include "upb/base/string_view.h" +#include "upb/collections/array.h" +#include "upb/mem/arena.h" +#include "upb/message/copy.h" + +// Must be last: +#include "upb/port/def.inc" + +namespace protos { +namespace internal { + +// TODO(b/279086429): Implement std iterator for messages +template +class RepeatedFieldScalarProxy; +template +class RepeatedFieldStringProxy; + +struct IteratorTestPeer; + +template +class Iterator; + +template +class ReferenceProxy; + +template +class InjectedRelationalsImpl { + using RP = ReferenceProxy; + using V = typename PolicyT::value_type; + friend bool operator==(RP a, V b) { return static_cast(a) == b; } + friend bool operator==(V a, RP b) { return a == static_cast(b); } + friend bool operator==(RP a, RP b) { + return static_cast(a) == static_cast(b); + } + friend bool operator!=(RP a, V b) { return static_cast(a) != b; } + friend bool operator!=(V a, RP b) { return a != static_cast(b); } + friend bool operator!=(RP a, RP b) { + return static_cast(a) != static_cast(b); + } + friend bool operator<(RP a, V b) { return static_cast(a) < b; } + friend bool operator<(V a, RP b) { return a < static_cast(b); } + friend bool operator<(RP a, RP b) { + return static_cast(a) < static_cast(b); + } + friend bool operator<=(RP a, V b) { return static_cast(a) <= b; } + friend bool operator<=(V a, RP b) { return a <= static_cast(b); } + friend bool operator<=(RP a, RP b) { + return static_cast(a) <= static_cast(b); + } + friend bool operator>(RP a, V b) { return static_cast(a) > b; } + friend bool operator>(V a, RP b) { return a > static_cast(b); } + friend bool operator>(RP a, RP b) { + return static_cast(a) > static_cast(b); + } + friend bool operator>=(RP a, V b) { return static_cast(a) >= b; } + friend bool operator>=(V a, RP b) { return a >= static_cast(b); } + friend bool operator>=(RP a, RP b) { + return static_cast(a) >= static_cast(b); + } +}; +class NoInjectedRelationalsImpl {}; + +// We need to inject relationals for the string references because the +// relationals for string_view are templates and won't allow for implicit +// conversions from ReferenceProxy to string_view before deduction. +template +using InjectedRelationals = std::conditional_t< + std::is_same_v, + absl::string_view>, + InjectedRelationalsImpl, NoInjectedRelationalsImpl>; + +template +class ReferenceProxy : InjectedRelationals { + using value_type = typename PolicyT::value_type; + + public: + ReferenceProxy(const ReferenceProxy&) = default; + ReferenceProxy& operator=(const ReferenceProxy& other) { + // Assign through the references + // TODO(sbenza): Make this better for strings to avoid the copy. + it_.Set(other.it_.Get()); + return *this; + } + friend void swap(ReferenceProxy a, ReferenceProxy b) { a.it_.swap(b.it_); } + + operator value_type() const { return it_.Get(); } + void operator=(const value_type& value) const { it_.Set(value); } + void operator=(value_type&& value) const { it_.Set(std::move(value)); } + Iterator operator&() const { return Iterator(it_); } + + private: + friend IteratorTestPeer; + friend ReferenceProxy; + friend Iterator; + + explicit ReferenceProxy(typename PolicyT::Payload elem) : it_(elem) {} + typename PolicyT::Payload it_; +}; + +template