diff --git a/extensions/protobuf/internal/json.cc b/extensions/protobuf/internal/json.cc index e0ac17757..789c23425 100644 --- a/extensions/protobuf/internal/json.cc +++ b/extensions/protobuf/internal/json.cc @@ -96,7 +96,8 @@ absl::StatusOr ProtoSingularFieldToJson( } } -absl::StatusOr ProtoMapKeyToJsonString(const google::protobuf::MapKey& key) { +absl::StatusOr ProtoMapKeyToJsonString( + const google::protobuf::MapKeyConstRef& key) { switch (key.type()) { case google::protobuf::FieldDescriptor::CPPTYPE_BOOL: return key.GetBoolValue() ? JsonString("true") : JsonString("false"); @@ -471,7 +472,7 @@ absl::StatusOr ProtoMapFieldToJsonObject( auto begin = MapBegin(*reflection, message, *field); auto end = MapEnd(*reflection, message, *field); while (begin != end) { - CEL_ASSIGN_OR_RETURN(auto key, ProtoMapKeyToJsonString(begin.GetKey())); + CEL_ASSIGN_OR_RETURN(auto key, ProtoMapKeyToJsonString(begin.GetKeyRef())); CEL_ASSIGN_OR_RETURN( auto value, ProtoMapValueToJson(converter, field->message_type()->map_value(), diff --git a/extensions/protobuf/internal/message.cc b/extensions/protobuf/internal/message.cc index 2fb0f9fd4..9d131bff4 100644 --- a/extensions/protobuf/internal/message.cc +++ b/extensions/protobuf/internal/message.cc @@ -249,10 +249,10 @@ namespace { // ----------------------------------------------------------------------------- // google::protobuf::MapKey -> cel::Value -using ProtoMapKeyToValueConverter = absl::Status (*)(const google::protobuf::MapKey&, - ValueManager&, Value&); +using ProtoMapKeyToValueConverter = + absl::Status (*)(const google::protobuf::MapKeyConstRef&, ValueManager&, Value&); -absl::Status ProtoBoolMapKeyToValueConverter(const google::protobuf::MapKey& key, +absl::Status ProtoBoolMapKeyToValueConverter(const google::protobuf::MapKeyConstRef& key, ValueManager&, Value& result) { CEL_RETURN_IF_ERROR(ProtoMapKeyTypeMismatch( google::protobuf::FieldDescriptor::CPPTYPE_BOOL, key.type())); @@ -260,7 +260,7 @@ absl::Status ProtoBoolMapKeyToValueConverter(const google::protobuf::MapKey& key return absl::OkStatus(); } -absl::Status ProtoInt32MapKeyToValueConverter(const google::protobuf::MapKey& key, +absl::Status ProtoInt32MapKeyToValueConverter(const google::protobuf::MapKeyConstRef& key, ValueManager&, Value& result) { CEL_RETURN_IF_ERROR(ProtoMapKeyTypeMismatch( google::protobuf::FieldDescriptor::CPPTYPE_INT32, key.type())); @@ -268,7 +268,7 @@ absl::Status ProtoInt32MapKeyToValueConverter(const google::protobuf::MapKey& ke return absl::OkStatus(); } -absl::Status ProtoInt64MapKeyToValueConverter(const google::protobuf::MapKey& key, +absl::Status ProtoInt64MapKeyToValueConverter(const google::protobuf::MapKeyConstRef& key, ValueManager&, Value& result) { CEL_RETURN_IF_ERROR(ProtoMapKeyTypeMismatch( google::protobuf::FieldDescriptor::CPPTYPE_INT64, key.type())); @@ -276,25 +276,25 @@ absl::Status ProtoInt64MapKeyToValueConverter(const google::protobuf::MapKey& ke return absl::OkStatus(); } -absl::Status ProtoUInt32MapKeyToValueConverter(const google::protobuf::MapKey& key, - ValueManager&, Value& result) { +absl::Status ProtoUInt32MapKeyToValueConverter( + const google::protobuf::MapKeyConstRef& key, ValueManager&, Value& result) { CEL_RETURN_IF_ERROR(ProtoMapKeyTypeMismatch( google::protobuf::FieldDescriptor::CPPTYPE_UINT32, key.type())); result = UintValue{key.GetUInt32Value()}; return absl::OkStatus(); } -absl::Status ProtoUInt64MapKeyToValueConverter(const google::protobuf::MapKey& key, - ValueManager&, Value& result) { +absl::Status ProtoUInt64MapKeyToValueConverter( + const google::protobuf::MapKeyConstRef& key, ValueManager&, Value& result) { CEL_RETURN_IF_ERROR(ProtoMapKeyTypeMismatch( google::protobuf::FieldDescriptor::CPPTYPE_UINT64, key.type())); result = UintValue{key.GetUInt64Value()}; return absl::OkStatus(); } -absl::Status ProtoStringMapKeyToValueConverter(const google::protobuf::MapKey& key, - ValueManager& value_manager, - Value& result) { +absl::Status ProtoStringMapKeyToValueConverter( + const google::protobuf::MapKeyConstRef& key, ValueManager& value_manager, + Value& result) { CEL_RETURN_IF_ERROR(ProtoMapKeyTypeMismatch( google::protobuf::FieldDescriptor::CPPTYPE_STRING, key.type())); result = StringValue{key.GetStringValue()}; @@ -1192,7 +1192,7 @@ class ParsedProtoMapKeyIterator final : public ValueIterator { absl::Status Next(ValueManager& value_manager, Value& result) override { Value scratch; CEL_RETURN_IF_ERROR( - map_key_to_value_(begin_.GetKey(), value_manager, result)); + map_key_to_value_(begin_.GetKeyRef(), value_manager, result)); ++begin_; return absl::OkStatus(); } @@ -1267,7 +1267,7 @@ class ParsedProtoMapValueInterface Value key; while (begin != end) { CEL_RETURN_IF_ERROR( - map_key_to_value_(begin.GetKey(), value_manager, key)); + map_key_to_value_(begin.GetKeyRef(), value_manager, key)); CEL_RETURN_IF_ERROR(builder->Add(std::move(key))); ++begin; } @@ -1283,7 +1283,7 @@ class ParsedProtoMapValueInterface Value value; while (begin != end) { CEL_RETURN_IF_ERROR( - map_key_to_value_(begin.GetKey(), value_manager, key)); + map_key_to_value_(begin.GetKeyRef(), value_manager, key)); CEL_RETURN_IF_ERROR(map_value_to_value_(shared_from_this(), field_, begin.GetValueRef(), value_manager, value)); diff --git a/extensions/protobuf/internal/struct.cc b/extensions/protobuf/internal/struct.cc index c9bda62c3..5cab7ea64 100644 --- a/extensions/protobuf/internal/struct.cc +++ b/extensions/protobuf/internal/struct.cc @@ -284,7 +284,7 @@ absl::StatusOr DynamicStructProtoToJson(const google::protobuf::Message& m CEL_ASSIGN_OR_RETURN( auto value, DynamicValueProtoToJson(map_begin.GetValueRef().GetMessageValue())); - builder.insert_or_assign(absl::Cord(map_begin.GetKey().GetStringValue()), + builder.insert_or_assign(absl::Cord(map_begin.GetKeyRef().GetStringValue()), std::move(value)); } return std::move(builder).Build();