replace protos namespace from {repeated_field, repeated_field_iterator} with hpb

PiperOrigin-RevId: 659995152
pull/17660/head
Hong Shin 4 months ago committed by Copybara-Service
parent d794139f09
commit 090edb7a77
  1. 4
      hpb/repeated_field.h
  2. 4
      hpb/repeated_field_iterator.h
  3. 4
      hpb/repeated_field_iterator_test.cc
  4. 38
      hpb_generator/gen_repeated_fields.cc
  5. 7
      hpb_generator/tests/test_generated.cc
  6. 3
      protos/repeated_field.h

@ -24,7 +24,7 @@
#include "upb/message/copy.h"
#include "upb/message/message.h"
namespace protos {
namespace hpb {
namespace internal {
// Shared implementation of repeated fields for absl::string_view and
@ -296,6 +296,6 @@ class RepeatedField {
internal::RepeatedFieldProxy<T>>>;
};
} // namespace protos
} // namespace hpb
#endif // PROTOBUF_HPB_REPEATED_FIELD_H_

@ -20,7 +20,7 @@
#include "upb/message/array.h"
#include "upb/message/message.h"
namespace protos {
namespace hpb {
namespace internal {
// TODO: Implement std iterator for messages
@ -365,6 +365,6 @@ struct MessageIteratorPolicy {
};
} // namespace internal
} // namespace protos
} // namespace hpb
#endif // PROTOBUF_HPB_REPEATED_FIELD_ITERATOR_H_

@ -23,7 +23,7 @@
using ::testing::ElementsAre;
namespace protos {
namespace hpb {
namespace internal {
template <typename T>
@ -455,4 +455,4 @@ TEST(StringIteratorTest, IteratorBasedAlgorithmsWork) {
} // namespace
} // namespace internal
} // namespace protos
} // namespace hpb

@ -12,13 +12,13 @@
#include "google/protobuf/descriptor.pb.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/compiler/hpb/gen_accessors.h"
#include "google/protobuf/compiler/hpb/gen_enums.h"
#include "google/protobuf/compiler/hpb/gen_extensions.h"
#include "google/protobuf/compiler/hpb/gen_utils.h"
#include "google/protobuf/compiler/hpb/names.h"
#include "google/protobuf/compiler/hpb/output.h"
#include "google/protobuf/descriptor.h"
#include "upb_generator/common.h"
#include "upb_generator/file_layout.h"
#include "upb_generator/names.h"
@ -86,8 +86,8 @@ void WriteRepeatedFieldsInMessageHeader(const protobuf::Descriptor* desc,
output(
R"cc(
$1 $2(size_t index) const;
const ::protos::RepeatedField<const $4>::CProxy $2() const;
::hpb::Ptr<::protos::RepeatedField<$4>> mutable_$2();
const ::hpb::RepeatedField<const $4>::CProxy $2() const;
::hpb::Ptr<::hpb::RepeatedField<$4>> mutable_$2();
absl::StatusOr<$0> add_$2();
$0 mutable_$2(size_t index) const;
)cc",
@ -101,8 +101,8 @@ void WriteRepeatedFieldsInMessageHeader(const protobuf::Descriptor* desc,
output(
R"cc(
$0 $1(size_t index) const;
const ::protos::RepeatedField<$0>::CProxy $1() const;
::hpb::Ptr<::protos::RepeatedField<$0>> mutable_$1();
const ::hpb::RepeatedField<$0>::CProxy $1() const;
::hpb::Ptr<::hpb::RepeatedField<$0>> mutable_$1();
bool add_$1($0 val);
void set_$1(size_t index, $0 val);
bool resize_$1(size_t len);
@ -112,8 +112,8 @@ void WriteRepeatedFieldsInMessageHeader(const protobuf::Descriptor* desc,
output(
R"cc(
$0 $1(size_t index) const;
const ::protos::RepeatedField<$0>::CProxy $1() const;
::hpb::Ptr<::protos::RepeatedField<$0>> mutable_$1();
const ::hpb::RepeatedField<$0>::CProxy $1() const;
::hpb::Ptr<::hpb::RepeatedField<$0>> mutable_$1();
bool add_$1($0 val);
void set_$1(size_t index, $0 val);
bool resize_$1(size_t len);
@ -172,15 +172,15 @@ void WriteRepeatedMessageAccessor(const protobuf::Descriptor* message,
upbc_name);
output(
R"cc(
const ::protos::RepeatedField<const $1>::CProxy $0::$2() const {
const ::hpb::RepeatedField<const $1>::CProxy $0::$2() const {
size_t size;
const upb_Array* arr = _$3_$4_$5(msg_, &size);
return ::protos::RepeatedField<const $1>::CProxy(arr, arena_);
return ::hpb::RepeatedField<const $1>::CProxy(arr, arena_);
};
::hpb::Ptr<::protos::RepeatedField<$1>> $0::mutable_$2() {
::hpb::Ptr<::hpb::RepeatedField<$1>> $0::mutable_$2() {
size_t size;
upb_Array* arr = _$3_$4_$6(msg_, &size, arena_);
return ::protos::RepeatedField<$1>::Proxy(arr, arena_);
return ::hpb::RepeatedField<$1>::Proxy(arr, arena_);
}
)cc",
class_name, // $0
@ -238,15 +238,15 @@ void WriteRepeatedStringAccessor(const protobuf::Descriptor* message,
MessageName(message), upbc_name);
output(
R"cc(
const ::protos::RepeatedField<$1>::CProxy $0::$2() const {
const ::hpb::RepeatedField<$1>::CProxy $0::$2() const {
size_t size;
const upb_Array* arr = _$3_$4_$5(msg_, &size);
return ::protos::RepeatedField<$1>::CProxy(arr, arena_);
return ::hpb::RepeatedField<$1>::CProxy(arr, arena_);
};
::hpb::Ptr<::protos::RepeatedField<$1>> $0::mutable_$2() {
::hpb::Ptr<::hpb::RepeatedField<$1>> $0::mutable_$2() {
size_t size;
upb_Array* arr = _$3_$4_$6(msg_, &size, arena_);
return ::protos::RepeatedField<$1>::Proxy(arr, arena_);
return ::hpb::RepeatedField<$1>::Proxy(arr, arena_);
}
)cc",
class_name, // $0
@ -302,15 +302,15 @@ void WriteRepeatedScalarAccessor(const protobuf::Descriptor* message,
MessageName(message), upbc_name);
output(
R"cc(
const ::protos::RepeatedField<$1>::CProxy $0::$2() const {
const ::hpb::RepeatedField<$1>::CProxy $0::$2() const {
size_t size;
const upb_Array* arr = _$3_$4_$5(msg_, &size);
return ::protos::RepeatedField<$1>::CProxy(arr, arena_);
return ::hpb::RepeatedField<$1>::CProxy(arr, arena_);
};
::hpb::Ptr<::protos::RepeatedField<$1>> $0::mutable_$2() {
::hpb::Ptr<::hpb::RepeatedField<$1>> $0::mutable_$2() {
size_t size;
upb_Array* arr = _$3_$4_$6(msg_, &size, arena_);
return ::protos::RepeatedField<$1>::Proxy(arr, arena_);
return ::hpb::RepeatedField<$1>::Proxy(arr, arena_);
}
)cc",
class_name, // $0

@ -433,8 +433,7 @@ TEST(CppGeneratedCode, RepeatedScalarIterator) {
test_model.mutable_value_array()->push_back(27);
int sum = 0;
// Access by value.
const ::protos::RepeatedField<int32_t>::CProxy rep1 =
test_model.value_array();
const ::hpb::RepeatedField<int32_t>::CProxy rep1 = test_model.value_array();
for (auto i : rep1) {
sum += i;
}
@ -479,13 +478,13 @@ TEST(CppGeneratedCode, RepeatedScalarIterator) {
EXPECT_EQ(it[2], 27);
// ValueProxy.
sum = 0;
for (::protos::RepeatedField<int32_t>::ValueCProxy c :
for (::hpb::RepeatedField<int32_t>::ValueCProxy c :
test_model.value_array()) {
sum += c;
}
EXPECT_EQ(sum, 5 + 16 + 27);
sum = 0;
for (::protos::RepeatedField<int32_t>::ValueProxy c :
for (::hpb::RepeatedField<int32_t>::ValueProxy c :
*test_model.mutable_value_array()) {
sum += c;
}

@ -8,4 +8,7 @@
#ifndef UPB_PROTOS_REPEATED_FIELD_H_
#define UPB_PROTOS_REPEATED_FIELD_H_
#include "google/protobuf/hpb/repeated_field.h"
namespace protos {
using hpb::RepeatedField;
}
#endif

Loading…
Cancel
Save