Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/values/parsed_json_map_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ class ParsedJsonMapValueIterator final : public ValueIterator {
private:
const google::protobuf::Message* absl_nonnull const message_;
const well_known_types::StructReflection reflection_;
google::protobuf::MapIterator begin_;
const google::protobuf::MapIterator end_;
google::protobuf::ConstMapIterator begin_;
const google::protobuf::ConstMapIterator end_;
std::string scratch_;
};

Expand Down
26 changes: 13 additions & 13 deletions common/values/parsed_map_field_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ absl::Status ParsedMapFieldValue::ListKeys(
field_->message_type()->map_key()));
auto builder = NewListValueBuilder(arena);
builder->Reserve(Size());
auto begin =
extensions::protobuf_internal::MapBegin(*reflection, *message_, *field_);
const auto end =
extensions::protobuf_internal::MapEnd(*reflection, *message_, *field_);
auto begin = extensions::protobuf_internal::ConstMapBegin(*reflection,
*message_, *field_);
const auto end = extensions::protobuf_internal::ConstMapEnd(
*reflection, *message_, *field_);
for (; begin != end; ++begin) {
Value scratch;
(*key_accessor)(begin.GetKey(), message_, arena, &scratch);
Expand Down Expand Up @@ -446,10 +446,10 @@ absl::Status ParsedMapFieldValue::ForEach(
CEL_ASSIGN_OR_RETURN(
auto value_accessor,
common_internal::MapFieldValueAccessorFor(value_field));
auto begin = extensions::protobuf_internal::MapBegin(*reflection, *message_,
*field_);
const auto end =
extensions::protobuf_internal::MapEnd(*reflection, *message_, *field_);
auto begin = extensions::protobuf_internal::ConstMapBegin(
*reflection, *message_, *field_);
const auto end = extensions::protobuf_internal::ConstMapEnd(
*reflection, *message_, *field_);
Value key_scratch;
Value value_scratch;
for (; begin != end; ++begin) {
Expand Down Expand Up @@ -479,10 +479,10 @@ class ParsedMapFieldValueIterator final : public ValueIterator {
value_field_(field->message_type()->map_value()),
key_accessor_(key_accessor),
value_accessor_(value_accessor),
begin_(extensions::protobuf_internal::MapBegin(
begin_(extensions::protobuf_internal::ConstMapBegin(
*message_->GetReflection(), *message_, *field)),
end_(extensions::protobuf_internal::MapEnd(*message_->GetReflection(),
*message_, *field)) {}
end_(extensions::protobuf_internal::ConstMapEnd(
*message_->GetReflection(), *message_, *field)) {}

bool HasNext() override { return begin_ != end_; }

Expand Down Expand Up @@ -545,8 +545,8 @@ class ParsedMapFieldValueIterator final : public ValueIterator {
const google::protobuf::FieldDescriptor* absl_nonnull const value_field_;
const absl_nonnull common_internal::MapFieldKeyAccessor key_accessor_;
const absl_nonnull common_internal::MapFieldValueAccessor value_accessor_;
google::protobuf::MapIterator begin_;
const google::protobuf::MapIterator end_;
google::protobuf::ConstMapIterator begin_;
const google::protobuf::ConstMapIterator end_;
};

} // namespace
Expand Down
42 changes: 18 additions & 24 deletions extensions/protobuf/internal/map_reflection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,16 @@ class CelMapReflectionFriend final {
return reflection.MapSize(message, &field);
}

static google::protobuf::MapIterator MapBegin(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return reflection.MapBegin(
const_cast< // NOLINT(google3-runtime-proto-const-cast)
google::protobuf::Message*>(&message),
&field);
static google::protobuf::ConstMapIterator ConstMapBegin(
const google::protobuf::Reflection& reflection, const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return reflection.ConstMapBegin(&message, &field);
}

static google::protobuf::MapIterator MapEnd(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return reflection.MapEnd(
const_cast< // NOLINT(google3-runtime-proto-const-cast)
google::protobuf::Message*>(&message),
&field);
static google::protobuf::ConstMapIterator ConstMapEnd(
const google::protobuf::Reflection& reflection, const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return reflection.ConstMapEnd(&message, &field);
}

static bool InsertOrLookupMapValue(const google::protobuf::Reflection& reflection,
Expand Down Expand Up @@ -104,18 +98,18 @@ int MapSize(const google::protobuf::Reflection& reflection,
field);
}

google::protobuf::MapIterator MapBegin(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return google::protobuf::expr::CelMapReflectionFriend::MapBegin(reflection, message,
field);
google::protobuf::ConstMapIterator ConstMapBegin(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return google::protobuf::expr::CelMapReflectionFriend::ConstMapBegin(reflection,
message, field);
}

google::protobuf::MapIterator MapEnd(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return google::protobuf::expr::CelMapReflectionFriend::MapEnd(reflection, message,
field);
google::protobuf::ConstMapIterator ConstMapEnd(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field) {
return google::protobuf::expr::CelMapReflectionFriend::ConstMapEnd(reflection, message,
field);
}

bool InsertOrLookupMapValue(const google::protobuf::Reflection& reflection,
Expand Down
12 changes: 6 additions & 6 deletions extensions/protobuf/internal/map_reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ int MapSize(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field);

google::protobuf::MapIterator MapBegin(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field);
google::protobuf::ConstMapIterator ConstMapBegin(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field);

google::protobuf::MapIterator MapEnd(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field);
google::protobuf::ConstMapIterator ConstMapEnd(const google::protobuf::Reflection& reflection,
const google::protobuf::Message& message,
const google::protobuf::FieldDescriptor& field);

bool InsertOrLookupMapValue(const google::protobuf::Reflection& reflection,
google::protobuf::Message* message,
Expand Down
10 changes: 5 additions & 5 deletions internal/json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,10 +803,10 @@ class MessageToJsonState {
const auto* value_descriptor = field->message_type()->map_value();
CEL_ASSIGN_OR_RETURN(const auto value_to_value,
GetMapFieldValueToValue(value_descriptor));
auto begin =
extensions::protobuf_internal::MapBegin(*reflection, message, *field);
const auto end =
extensions::protobuf_internal::MapEnd(*reflection, message, *field);
auto begin = extensions::protobuf_internal::ConstMapBegin(*reflection,
message, *field);
const auto end = extensions::protobuf_internal::ConstMapEnd(
*reflection, message, *field);
for (; begin != end; ++begin) {
auto key = (*key_to_string)(begin.GetKey());
CEL_RETURN_IF_ERROR((this->*value_to_value)(
Expand Down Expand Up @@ -1381,7 +1381,7 @@ class JsonMapIterator final {
using Generated =
typename google::protobuf::Map<std::string,
google::protobuf::Value>::const_iterator;
using Dynamic = google::protobuf::MapIterator;
using Dynamic = google::protobuf::ConstMapIterator;
using Value = std::pair<well_known_types::StringValue,
const google::protobuf::MessageLite* absl_nonnull>;

Expand Down
8 changes: 4 additions & 4 deletions internal/message_equality.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ namespace cel::internal {

namespace {

using ::cel::extensions::protobuf_internal::ConstMapBegin;
using ::cel::extensions::protobuf_internal::ConstMapEnd;
using ::cel::extensions::protobuf_internal::LookupMapValue;
using ::cel::extensions::protobuf_internal::MapBegin;
using ::cel::extensions::protobuf_internal::MapEnd;
using ::cel::extensions::protobuf_internal::MapSize;
using ::google::protobuf::Descriptor;
using ::google::protobuf::DescriptorPool;
Expand Down Expand Up @@ -904,8 +904,8 @@ class MessageEqualsState final {
MapSize(*rhs_reflection, rhs, *rhs_field)) {
return false;
}
auto lhs_begin = MapBegin(*lhs_reflection, lhs, *lhs_field);
const auto lhs_end = MapEnd(*lhs_reflection, lhs, *lhs_field);
auto lhs_begin = ConstMapBegin(*lhs_reflection, lhs, *lhs_field);
const auto lhs_end = ConstMapEnd(*lhs_reflection, lhs, *lhs_field);
Unique<Message> lhs_unpacked;
EquatableValue lhs_value;
Unique<Message> rhs_unpacked;
Expand Down
12 changes: 6 additions & 6 deletions internal/well_known_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1643,20 +1643,20 @@ int StructReflection::FieldsSize(const google::protobuf::Message& message) const
message, *fields_field_);
}

google::protobuf::MapIterator StructReflection::BeginFields(
google::protobuf::ConstMapIterator StructReflection::BeginFields(
const google::protobuf::Message& message) const {
ABSL_DCHECK(IsInitialized());
ABSL_DCHECK_EQ(message.GetDescriptor(), descriptor_);
return cel::extensions::protobuf_internal::MapBegin(*message.GetReflection(),
message, *fields_field_);
return cel::extensions::protobuf_internal::ConstMapBegin(
*message.GetReflection(), message, *fields_field_);
}

google::protobuf::MapIterator StructReflection::EndFields(
google::protobuf::ConstMapIterator StructReflection::EndFields(
const google::protobuf::Message& message) const {
ABSL_DCHECK(IsInitialized());
ABSL_DCHECK_EQ(message.GetDescriptor(), descriptor_);
return cel::extensions::protobuf_internal::MapEnd(*message.GetReflection(),
message, *fields_field_);
return cel::extensions::protobuf_internal::ConstMapEnd(
*message.GetReflection(), message, *fields_field_);
}

bool StructReflection::ContainsField(const google::protobuf::Message& message,
Expand Down
9 changes: 5 additions & 4 deletions internal/well_known_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,9 @@ absl::StatusOr<AnyReflection> GetAnyReflection(
const google::protobuf::Descriptor* absl_nonnull descriptor
ABSL_ATTRIBUTE_LIFETIME_BOUND);

AnyReflection GetAnyReflectionOrDie(const google::protobuf::Descriptor* absl_nonnull
descriptor ABSL_ATTRIBUTE_LIFETIME_BOUND);
AnyReflection GetAnyReflectionOrDie(
const google::protobuf::Descriptor* absl_nonnull descriptor
ABSL_ATTRIBUTE_LIFETIME_BOUND);

class DurationReflection final {
public:
Expand Down Expand Up @@ -1193,10 +1194,10 @@ class StructReflection final {

int FieldsSize(const google::protobuf::Message& message) const;

google::protobuf::MapIterator BeginFields(
google::protobuf::ConstMapIterator BeginFields(
const google::protobuf::Message& message ABSL_ATTRIBUTE_LIFETIME_BOUND) const;

google::protobuf::MapIterator EndFields(
google::protobuf::ConstMapIterator EndFields(
const google::protobuf::Message& message ABSL_ATTRIBUTE_LIFETIME_BOUND) const;

bool ContainsField(const google::protobuf::Message& message,
Expand Down