move upb/hpb_generator -> protobuf/compiler/hpb

PiperOrigin-RevId: 649112245
pull/17299/head
Hong Shin 9 months ago committed by Copybara-Service
parent c3d0ffe4cf
commit 096b139192
  1. 8
      .github/workflows/test_upb.yml
  2. 6
      hpb/BUILD
  3. 4
      hpb/bazel/upb_cc_proto_library.bzl
  4. 4
      hpb/protos.h
  5. 2
      hpb/protos_extension_lock_test.cc
  6. 4
      hpb/protos_internal_test.cc
  7. 4
      hpb_generator/BUILD
  8. 6
      hpb_generator/README.md
  9. 12
      hpb_generator/gen_accessors.cc
  10. 12
      hpb_generator/gen_accessors.h
  11. 8
      hpb_generator/gen_enums.cc
  12. 10
      hpb_generator/gen_enums.h
  13. 8
      hpb_generator/gen_extensions.cc
  14. 10
      hpb_generator/gen_extensions.h
  15. 16
      hpb_generator/gen_messages.cc
  16. 10
      hpb_generator/gen_messages.h
  17. 16
      hpb_generator/gen_repeated_fields.cc
  18. 10
      hpb_generator/gen_repeated_fields.h
  19. 4
      hpb_generator/gen_utils.cc
  20. 8
      hpb_generator/gen_utils.h
  21. 4
      hpb_generator/names.cc
  22. 10
      hpb_generator/names.h
  23. 4
      hpb_generator/output.cc
  24. 6
      hpb_generator/output.h
  25. 14
      hpb_generator/protoc-gen-upb-protos.cc
  26. 8
      hpb_generator/tests/BUILD
  27. 2
      hpb_generator/tests/child_model.proto
  28. 2
      hpb_generator/tests/no_package_enum_user.proto
  29. 2
      hpb_generator/tests/test_extension.proto
  30. 6
      hpb_generator/tests/test_generated.cc
  31. 2
      hpb_generator/tests/test_model.proto
  32. 2
      protos/bazel/upb_cc_proto_library.bzl
  33. 2
      upb_generator/BUILD

@ -40,7 +40,7 @@ jobs:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize:${{ matrix.config.bazel_version || '6.3.0' }}-75f2a85ece6526cc3d54087018c0f1097d78d42b image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize:${{ matrix.config.bazel_version || '6.3.0' }}-75f2a85ece6526cc3d54087018c0f1097d78d42b
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: upb-bazel bazel-cache: upb-bazel
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //bazel/... //benchmarks/... //lua/... //hpb_generator/... //python/... //upb/... //upb_generator/... ${{ matrix.config.flags }} bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/... ${{ matrix.config.flags }}
exclude-targets: ${{ matrix.config.exclude-targets }} exclude-targets: ${{ matrix.config.exclude-targets }}
linux-gcc: linux-gcc:
@ -59,7 +59,7 @@ jobs:
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-63dd26c0c7a808d92673a3e52e848189d4ab0f17" image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-63dd26c0c7a808d92673a3e52e848189d4ab0f17"
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "upb-bazel-gcc" bazel-cache: "upb-bazel-gcc"
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //bazel/... //benchmarks/... //lua/... //hpb_generator/... //python/... //upb/... //upb_generator/... bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/...
windows: windows:
strategy: strategy:
@ -80,7 +80,7 @@ jobs:
with: with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "upb-bazel-windows" bazel-cache: "upb-bazel-windows"
bazel: test --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 //upb/... //upb_generator/... //python/... //hpb_generator/... bazel: test --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 //upb/... //upb_generator/... //python/...
version: 6.3.0 version: 6.3.0
exclude-targets: -//python:conformance_test -//upb/reflection:def_builder_test exclude-targets: -//python:conformance_test -//upb/reflection:def_builder_test
@ -107,7 +107,7 @@ jobs:
with: with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "upb-bazel-macos" bazel-cache: "upb-bazel-macos"
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //bazel/... //benchmarks/... //lua/... //hpb_generator/... //python/... //upb/... //upb_generator/... bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //bazel/... //benchmarks/... //lua/... //python/... //upb/... //upb_generator/...
version: 6.3.0 version: 6.3.0
no-python: no-python:

@ -138,8 +138,8 @@ cc_test(
copts = UPB_DEFAULT_CPPOPTS, copts = UPB_DEFAULT_CPPOPTS,
deps = [ deps = [
":protos_internal", ":protos_internal",
"//hpb_generator/tests:test_model_upb_cc_proto", "//src/google/protobuf/compiler/hpb/tests:test_model_upb_cc_proto",
"//hpb_generator/tests:test_model_upb_proto", "//src/google/protobuf/compiler/hpb/tests:test_model_upb_proto",
"//upb:mem", "//upb:mem",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
@ -168,7 +168,7 @@ cc_test(
deps = [ deps = [
"//hpb", "//hpb",
"//hpb:protos_extension_lock", "//hpb:protos_extension_lock",
"//hpb_generator/tests:test_model_upb_cc_proto", "//src/google/protobuf/compiler/hpb/tests:test_model_upb_cc_proto",
"//upb:mem", "//upb:mem",
"@com_google_absl//absl/hash", "@com_google_absl//absl/hash",
"@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/log:absl_check",

@ -235,12 +235,12 @@ def _upb_cc_proto_library_aspect_impl(target, ctx):
_upb_cc_proto_library_aspect = aspect( _upb_cc_proto_library_aspect = aspect(
attrs = { attrs = {
"_ccopts": attr.label( "_ccopts": attr.label(
default = "//protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use", default = "//hpb:upb_cc_proto_library_copts__for_generated_code_only_do_not_use",
), ),
"_gen_upbprotos": attr.label( "_gen_upbprotos": attr.label(
executable = True, executable = True,
cfg = "exec", cfg = "exec",
default = "//hpb_generator:protoc-gen-upb-protos", default = "//src/google/protobuf/compiler/hpb:protoc-gen-upb-protos",
), ),
"_protoc": attr.label( "_protoc": attr.label(
executable = True, executable = True,

@ -78,6 +78,10 @@ class Ptr final {
Proxy<T> p_; Proxy<T> p_;
}; };
// Suppress -Wctad-maybe-unsupported with our manual deduction guide
template <typename T>
Ptr(T* m) -> Ptr<T>;
inline absl::string_view UpbStrToStringView(upb_StringView str) { inline absl::string_view UpbStrToStringView(upb_StringView str) {
return absl::string_view(str.data, str.size); return absl::string_view(str.data, str.size);
} }

@ -16,7 +16,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/hash/hash.h" #include "absl/hash/hash.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "hpb_generator/tests/test_model.upb.proto.h" #include "google/protobuf/compiler/hpb/tests/test_model.upb.proto.h"
#include "google/protobuf/hpb/protos.h" #include "google/protobuf/hpb/protos.h"
#include "upb/mem/arena.hpp" #include "upb/mem/arena.hpp"

@ -9,8 +9,8 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "hpb_generator/tests/test_model.upb.h" #include "google/protobuf/compiler/hpb/tests/test_model.upb.h"
#include "hpb_generator/tests/test_model.upb.proto.h" #include "google/protobuf/compiler/hpb/tests/test_model.upb.proto.h"
#include "upb/mem/arena.h" #include "upb/mem/arena.h"
namespace protos::testing { namespace protos::testing {

@ -29,7 +29,9 @@ cc_binary(
":names", ":names",
":output", ":output",
"//:protobuf", "//:protobuf",
"//src/google/protobuf",
"//src/google/protobuf/compiler:code_generator", "//src/google/protobuf/compiler:code_generator",
"//src/google/protobuf/compiler:plugin",
"//upb_generator:file_layout", "//upb_generator:file_layout",
], ],
) )
@ -56,6 +58,7 @@ cc_library(
":names", ":names",
":output", ":output",
"//:protobuf", "//:protobuf",
"//src/google/protobuf",
"//upb_generator:common", "//upb_generator:common",
"//upb_generator:file_layout", "//upb_generator:file_layout",
"//upb_generator:keywords", "//upb_generator:keywords",
@ -85,6 +88,7 @@ cc_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//:protobuf", "//:protobuf",
"//src/google/protobuf",
"//src/google/protobuf/compiler:code_generator", "//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
], ],

@ -1,8 +1,8 @@
`protos` Generator hpb Generator
================== ==================
This directory contains the generator for the [`protos` This directory contains the generator for the [`hpb`
API](https://github.com/protocolbuffers/protobuf/tree/main/protos), an API](https://github.com/protocolbuffers/protobuf/tree/main/hpb), an
experimental C++ protobuf implementation. Most users should use the standard experimental C++ protobuf implementation. Most users should use the standard
C++ implementation C++ implementation
[here](https://github.com/protocolbuffers/protobuf/tree/main/src). [here](https://github.com/protocolbuffers/protobuf/tree/main/src).

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/gen_accessors.h" #include "google/protobuf/compiler/hpb/gen_accessors.h"
#include <string> #include <string>
@ -14,17 +14,17 @@
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/gen_repeated_fields.h" #include "google/protobuf/compiler/hpb/gen_repeated_fields.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
#include "upb_generator/common.h" #include "upb_generator/common.h"
#include "upb_generator/keywords.h" #include "upb_generator/keywords.h"
#include "upb_generator/names.h" #include "upb_generator/names.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
using NameToFieldDescriptorMap = using NameToFieldDescriptorMap =
absl::flat_hash_map<absl::string_view, const protobuf::FieldDescriptor*>; absl::flat_hash_map<absl::string_view, const protobuf::FieldDescriptor*>;

@ -5,16 +5,16 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_ACCESSORS_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_ACCESSORS_H_
#define UPB_PROTOS_GENERATOR_ACCESSORS_H_ #define PROTOBUF_COMPILER_HBP_GEN_ACCESSORS_H_
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
void WriteFieldAccessorsInHeader(const protobuf::Descriptor* desc, void WriteFieldAccessorsInHeader(const protobuf::Descriptor* desc,
Output& output); Output& output);
@ -25,4 +25,4 @@ void WriteOneofAccessorsInHeader(const protobuf::Descriptor* desc,
Output& output); Output& output);
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_ACCESSORS_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_ACCESSORS_H_

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/gen_enums.h" #include "google/protobuf/compiler/hpb/gen_enums.h"
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
@ -14,12 +14,12 @@
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
// Convert enum value to C++ literal. // Convert enum value to C++ literal.
// //

@ -5,15 +5,15 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_ENUMS_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_ENUMS_H_
#define UPB_PROTOS_GENERATOR_ENUMS_H_ #define PROTOBUF_COMPILER_HBP_GEN_ENUMS_H_
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
std::string EnumTypeName(const protobuf::EnumDescriptor* enum_descriptor); std::string EnumTypeName(const protobuf::EnumDescriptor* enum_descriptor);
std::string EnumValueSymbolInNameSpace( std::string EnumValueSymbolInNameSpace(
@ -26,4 +26,4 @@ void WriteEnumDeclarations(
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_ENUMS_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_ENUMS_H_

@ -5,15 +5,15 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/gen_extensions.h" #include "google/protobuf/compiler/hpb/gen_extensions.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
std::string ExtensionIdentifierBase(const protobuf::FieldDescriptor* ext) { std::string ExtensionIdentifierBase(const protobuf::FieldDescriptor* ext) {
assert(ext->is_extension()); assert(ext->is_extension());

@ -5,15 +5,15 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_GEN_EXTENSIONS_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_EXTENSIONS_H_
#define UPB_PROTOS_GENERATOR_GEN_EXTENSIONS_H_ #define PROTOBUF_COMPILER_HBP_GEN_EXTENSIONS_H_
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
void WriteExtensionIdentifiersHeader( void WriteExtensionIdentifiersHeader(
const std::vector<const protobuf::FieldDescriptor*>& extensions, const std::vector<const protobuf::FieldDescriptor*>& extensions,
@ -28,4 +28,4 @@ void WriteExtensionIdentifier(const protobuf::FieldDescriptor* ext,
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_GEN_EXTENSIONS_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_EXTENSIONS_H_

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/gen_messages.h" #include "google/protobuf/compiler/hpb/gen_messages.h"
#include <cstddef> #include <cstddef>
#include <string> #include <string>
@ -16,18 +16,18 @@
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/gen_accessors.h" #include "google/protobuf/compiler/hpb/gen_accessors.h"
#include "hpb_generator/gen_enums.h" #include "google/protobuf/compiler/hpb/gen_enums.h"
#include "hpb_generator/gen_extensions.h" #include "google/protobuf/compiler/hpb/gen_extensions.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
#include "upb_generator/common.h" #include "upb_generator/common.h"
#include "upb_generator/file_layout.h" #include "upb_generator/file_layout.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
void WriteModelAccessDeclaration(const protobuf::Descriptor* descriptor, void WriteModelAccessDeclaration(const protobuf::Descriptor* descriptor,
Output& output); Output& output);

@ -5,14 +5,14 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_GEN_MESSAGES_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_MESSAGES_H_
#define UPB_PROTOS_GENERATOR_GEN_MESSAGES_H_ #define PROTOBUF_COMPILER_HBP_GEN_MESSAGES_H_
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
void WriteMessageClassDeclarations( void WriteMessageClassDeclarations(
const protobuf::Descriptor* descriptor, const protobuf::Descriptor* descriptor,
@ -25,4 +25,4 @@ void WriteMessageImplementation(
Output& output); Output& output);
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_GEN_MESSAGES_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_MESSAGES_H_

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/gen_repeated_fields.h" #include "google/protobuf/compiler/hpb/gen_repeated_fields.h"
#include <string> #include <string>
#include <vector> #include <vector>
@ -13,18 +13,18 @@
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/gen_accessors.h" #include "google/protobuf/compiler/hpb/gen_accessors.h"
#include "hpb_generator/gen_enums.h" #include "google/protobuf/compiler/hpb/gen_enums.h"
#include "hpb_generator/gen_extensions.h" #include "google/protobuf/compiler/hpb/gen_extensions.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
#include "upb_generator/common.h" #include "upb_generator/common.h"
#include "upb_generator/file_layout.h" #include "upb_generator/file_layout.h"
#include "upb_generator/names.h" #include "upb_generator/names.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
// Adds using accessors to reuse base Access class members from a Proxy/CProxy. // Adds using accessors to reuse base Access class members from a Proxy/CProxy.
void WriteRepeatedFieldUsingAccessors(const protobuf::FieldDescriptor* field, void WriteRepeatedFieldUsingAccessors(const protobuf::FieldDescriptor* field,

@ -5,15 +5,15 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef THIRD_PARTY_UPB_PROTOS_GENERATOR_GEN_REPEATED_FIELDS_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_REPEATED_FIELDS_H_
#define THIRD_PARTY_UPB_PROTOS_GENERATOR_GEN_REPEATED_FIELDS_H_ #define PROTOBUF_COMPILER_HBP_GEN_REPEATED_FIELDS_H_
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
void WriteRepeatedFieldUsingAccessors(const protobuf::FieldDescriptor* field, void WriteRepeatedFieldUsingAccessors(const protobuf::FieldDescriptor* field,
absl::string_view class_name, absl::string_view class_name,
@ -43,4 +43,4 @@ void WriteRepeatedScalarAccessor(const protobuf::Descriptor* message,
} // namespace protos_generator } // namespace protos_generator
#endif // THIRD_PARTY_UPB_PROTOS_GENERATOR_GEN_REPEATED_FIELDS_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_REPEATED_FIELDS_H_

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include <algorithm> #include <algorithm>
#include <string> #include <string>
@ -15,7 +15,7 @@
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
void AddEnums(const protobuf::Descriptor* message, void AddEnums(const protobuf::Descriptor* message,
std::vector<const protobuf::EnumDescriptor*>* enums) { std::vector<const protobuf::EnumDescriptor*>* enums) {

@ -5,8 +5,8 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_GEN_UTILS_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_UTILS_H_
#define UPB_PROTOS_GENERATOR_GEN_UTILS_H_ #define PROTOBUF_COMPILER_HBP_GEN_UTILS_H_
#include <string> #include <string>
#include <vector> #include <vector>
@ -17,7 +17,7 @@
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
enum class MessageClassType { enum class MessageClassType {
kMessage, kMessage,
@ -42,4 +42,4 @@ std::string ToCamelCase(const std::string& input, bool lower_first);
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_GEN_UTILS_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_UTILS_H_

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
#include <string> #include <string>
@ -13,7 +13,7 @@
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
namespace { namespace {

@ -5,17 +5,17 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_NAMES_H_ #ifndef PROTOBUF_COMPILER_HBP_GEN_NAMES_H_
#define UPB_PROTOS_GENERATOR_NAMES_H_ #define PROTOBUF_COMPILER_HBP_GEN_NAMES_H_
#include <string> #include <string>
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
inline constexpr absl::string_view kNoPackageNamePrefix = "protos_"; inline constexpr absl::string_view kNoPackageNamePrefix = "protos_";
@ -47,4 +47,4 @@ std::string MessageProxyType(const protobuf::FieldDescriptor* field,
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_NAMES_H_ #endif // PROTOBUF_COMPILER_HBP_GEN_NAMES_H_

@ -5,7 +5,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
#include <string> #include <string>
@ -14,7 +14,7 @@
namespace protos_generator { namespace protos_generator {
namespace { namespace {
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
} // namespace } // namespace

@ -5,8 +5,8 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#ifndef UPB_PROTOS_GENERATOR_OUTPUT_H #ifndef PROTOBUF_COMPILER_HBP_OUTPUT_H_
#define UPB_PROTOS_GENERATOR_OUTPUT_H #define PROTOBUF_COMPILER_HBP_OUTPUT_H_
#include <vector> #include <vector>
@ -148,4 +148,4 @@ std::string CSourceFilename(const google::protobuf::FileDescriptor* file);
} // namespace protos_generator } // namespace protos_generator
#endif // UPB_PROTOS_GENERATOR_OUTPUT_H #endif // PROTOBUF_COMPILER_HBP_OUTPUT_H_

@ -15,18 +15,18 @@
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/plugin.h" #include "google/protobuf/compiler/plugin.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "hpb_generator/gen_enums.h" #include "google/protobuf/compiler/hpb/gen_enums.h"
#include "hpb_generator/gen_extensions.h" #include "google/protobuf/compiler/hpb/gen_extensions.h"
#include "hpb_generator/gen_messages.h" #include "google/protobuf/compiler/hpb/gen_messages.h"
#include "hpb_generator/gen_utils.h" #include "google/protobuf/compiler/hpb/gen_utils.h"
#include "hpb_generator/names.h" #include "google/protobuf/compiler/hpb/names.h"
#include "hpb_generator/output.h" #include "google/protobuf/compiler/hpb/output.h"
namespace protos_generator { namespace protos_generator {
namespace { namespace {
namespace protoc = ::google::protobuf::compiler; namespace protoc = ::google::protobuf::compiler;
namespace protobuf = ::google::protobuf; namespace protobuf = ::proto2;
using FileDescriptor = ::google::protobuf::FileDescriptor; using FileDescriptor = ::google::protobuf::FileDescriptor;
using google::protobuf::Edition; using google::protobuf::Edition;

@ -12,12 +12,12 @@
# "cc_proto_library", # "cc_proto_library",
# ) # )
# load( # load(
# "//bazel:upb_proto_library.bzl", # "//hpb/bazel:upb_cc_proto_library.bzl",
# "upb_c_proto_library", # "upb_cc_proto_library",
# ) # )
# load( # load(
# "//protos/bazel:upb_cc_proto_library.bzl", # "//bazel:upb_proto_library.bzl",
# "upb_cc_proto_library", # "upb_c_proto_library",
# ) # )
# load( # load(
# "//upb/bazel:build_defs.bzl", # "//upb/bazel:build_defs.bzl",

@ -9,7 +9,7 @@ syntax = "proto3";
package protos_generator.test; package protos_generator.test;
import public "hpb_generator/tests/test_enum.proto"; import public "google/protobuf/compiler/hpb/tests/test_enum.proto";
message ChildModel1 { message ChildModel1 {
optional bool child_b1 = 44; optional bool child_b1 = 44;

@ -9,7 +9,7 @@ syntax = "proto2";
package protos_generator.tests; package protos_generator.tests;
import "hpb_generator/tests/no_package.proto"; import "google/protobuf/compiler/hpb/tests/no_package.proto";
// option java_multiple_files = true; // option java_multiple_files = true;

@ -9,7 +9,7 @@ syntax = "proto2";
package protos_generator.test.someotherpackage; package protos_generator.test.someotherpackage;
import "hpb_generator/tests/test_model.proto"; import "google/protobuf/compiler/hpb/tests/test_model.proto";
// Define extension that is extending proto outside this package with a type // Define extension that is extending proto outside this package with a type
// defined in different file. // defined in different file.

@ -18,9 +18,9 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "hpb_generator/tests/child_model.upb.proto.h" #include "google/protobuf/compiler/hpb/tests/child_model.upb.proto.h"
#include "hpb_generator/tests/no_package.upb.proto.h" #include "google/protobuf/compiler/hpb/tests/no_package.upb.proto.h"
#include "hpb_generator/tests/test_model.upb.proto.h" #include "google/protobuf/compiler/hpb/tests/test_model.upb.proto.h"
#include "protos/protos.h" #include "protos/protos.h"
#include "protos/repeated_field.h" #include "protos/repeated_field.h"
#include "protos/repeated_field_iterator.h" #include "protos/repeated_field_iterator.h"

@ -9,7 +9,7 @@ syntax = "proto2";
package protos_generator.test; package protos_generator.test;
import "hpb_generator/tests/child_model.proto"; import "google/protobuf/compiler/hpb/tests/child_model.proto";
message TestModelContainer { message TestModelContainer {
repeated TestModel models = 1; repeated TestModel models = 1;

@ -240,7 +240,7 @@ _upb_cc_proto_library_aspect = aspect(
"_gen_upbprotos": attr.label( "_gen_upbprotos": attr.label(
executable = True, executable = True,
cfg = "exec", cfg = "exec",
default = "//hpb_generator:protoc-gen-upb-protos", default = "//src/google/protobuf/compiler/hpb:protoc-gen-upb-protos",
), ),
"_protoc": attr.label( "_protoc": attr.label(
executable = True, executable = True,

@ -143,7 +143,7 @@ cc_library(
"keywords.h", "keywords.h",
], ],
copts = UPB_DEFAULT_CPPOPTS, copts = UPB_DEFAULT_CPPOPTS,
visibility = ["//hpb_generator:__pkg__"], visibility = ["//src/google/protobuf/compiler/hpb:__pkg__"],
) )
bootstrap_cc_library( bootstrap_cc_library(

Loading…
Cancel
Save