Skip to content

Commit

Permalink
Automated rollback of commit 694d793.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 707309375
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 18, 2024
1 parent 5d24a80 commit 5944662
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/google/protobuf/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class MutableRepeatedFieldRef<
}
void Add(const T& value) const { accessor_->template Add<T>(data_, value); }
void RemoveLast() const { accessor_->RemoveLast(data_); }
// TODO: Remove.
ABSL_DEPRECATED("Do not use. Will be removed in a future release.")
void Reserve(int size) const { accessor_->Reserve(data_, size); }
void SwapElements(int index1, int index2) const {
accessor_->SwapElements(data_, index1, index2);
}
Expand Down Expand Up @@ -215,6 +218,9 @@ class MutableRepeatedFieldRef<
}
void Add(const T& value) const { accessor_->Add(data_, &value); }
void RemoveLast() const { accessor_->RemoveLast(data_); }
// TODO: Remove.
ABSL_DEPRECATED("Do not use. Will be removed in a future release.")
void Reserve(int size) const { accessor_->Reserve(data_, size); }
void SwapElements(int index1, int index2) const {
accessor_->SwapElements(data_, index1, index2);
}
Expand Down Expand Up @@ -302,6 +308,9 @@ class PROTOBUF_EXPORT RepeatedFieldAccessor {
virtual void Set(Field* data, int index, const Value* value) const = 0;
virtual void Add(Field* data, const Value* value) const = 0;
virtual void RemoveLast(Field* data) const = 0;
// TODO: Remove.
ABSL_DEPRECATED("Do not use. Will be removed in a future release.")
virtual void Reserve(Field* data, int size) const = 0;
virtual void SwapElements(Field* data, int index1, int index2) const = 0;
virtual void Swap(Field* data, const RepeatedFieldAccessor* other_mutator,
Field* other_data) const = 0;
Expand Down
11 changes: 11 additions & 0 deletions src/google/protobuf/reflection_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class RepeatedFieldWrapper : public RandomAccessRepeatedFieldAccessor {
void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
// TODO: Remove.
void Reserve(Field* data, int size) const override {
MutableRepeatedField(data)->Reserve(size);
}
void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
Expand Down Expand Up @@ -149,6 +153,10 @@ class RepeatedPtrFieldWrapper : public RandomAccessRepeatedFieldAccessor {
void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
// TODO: Remove.
void Reserve(Field* data, int size) const override {
MutableRepeatedField(data)->Reserve(size);
}
void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
Expand Down Expand Up @@ -212,6 +220,9 @@ class MapFieldAccessor final : public RandomAccessRepeatedFieldAccessor {
void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
void Reserve(Field* data, int size) const override {
MutableRepeatedField(data)->Reserve(size);
}
void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
Expand Down
6 changes: 6 additions & 0 deletions src/google/protobuf/repeated_field_reflection_unittest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ TEST(REFLECTION_TEST, RepeatedFieldRefForRegularFields) {
}
EXPECT_EQ(10, index);

// Test MutableRepeatedFieldRef::Reserve()
mrf_int32.Reserve(mrf_int32.size() + 1);
mrf_double.Reserve(mrf_double.size() + 1);
mrf_string.Reserve(mrf_string.size() + 1);
mrf_foreign_message.Reserve(mrf_foreign_message.size() + 1);

// Test MutableRepeatedFieldRef::Add()
mrf_int32.Add(1234);
mrf_double.Add(1234.0);
Expand Down

0 comments on commit 5944662

Please sign in to comment.