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
1 change: 0 additions & 1 deletion common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ cc_library(
"//internal:string_pool",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:no_destructor",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
Expand Down
47 changes: 47 additions & 0 deletions common/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,53 @@ Type LegacyRuntimeType(absl::string_view name) {
if (name == kCelTypeTypeName) {
return TypeType{};
}
if (cel::IsWellKnownMessageType(name)) {
if (name == "google.protobuf.Any") {
return AnyType();
}
if (name == "google.protobuf.BoolValue") {
return BoolWrapperType();
}
if (name == "google.protobuf.BytesValue") {
return BytesWrapperType();
}
if (name == "google.protobuf.DoubleValue") {
return DoubleWrapperType();
}
if (name == "google.protobuf.Duration") {
return DurationType();
}
if (name == "google.protobuf.FloatValue") {
return DoubleWrapperType();
}
if (name == "google.protobuf.Int32Value") {
return IntWrapperType();
}
if (name == "google.protobuf.Int64Value") {
return IntWrapperType();
}
if (name == "google.protobuf.ListValue") {
return ListType();
}
if (name == "google.protobuf.StringValue") {
return StringWrapperType();
}
if (name == "google.protobuf.Struct") {
return JsonMapType();
}
if (name == "google.protobuf.Timestamp") {
return TimestampType();
}
if (name == "google.protobuf.UInt32Value") {
return UintWrapperType();
}
if (name == "google.protobuf.UInt64Value") {
return UintWrapperType();
}
if (name == "google.protobuf.Value") {
return DynType();
}
}
return common_internal::MakeBasicStructType(name);
}

Expand Down
34 changes: 34 additions & 0 deletions common/type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,5 +638,39 @@ TEST(Type, Wrap) {
EXPECT_EQ(Type(AnyType()).Wrap(), AnyType());
}

TEST(Type, LegacyRuntimeType) {
EXPECT_EQ(common_internal::LegacyRuntimeType("bool"), BoolType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Any"),
AnyType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.BoolValue"),
BoolWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.BytesValue"),
BytesWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.DoubleValue"),
DoubleWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Duration"),
DurationType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.FloatValue"),
DoubleWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Int32Value"),
IntWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Int64Value"),
IntWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.ListValue"),
ListType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.StringValue"),
StringWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Struct"),
JsonMapType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Timestamp"),
TimestampType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.UInt32Value"),
UintWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.UInt64Value"),
UintWrapperType());
EXPECT_EQ(common_internal::LegacyRuntimeType("google.protobuf.Value"),
DynType());
}

} // namespace
} // namespace cel