Thanks to visit codestin.com
Credit goes to github.com

Skip to content

No public description #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
5 changes: 3 additions & 2 deletions extensions/protobuf/internal/any.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "common/json.h"
#include "internal/casts.h"
#include "internal/status_macros.h"
#include "google/protobuf/message.h"

namespace cel::extensions::protobuf_internal {

Expand All @@ -51,7 +52,7 @@ absl::Status WrapDynamicAnyProto(absl::string_view type_url,
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Any::descriptor())) {
return WrapGeneratedAnyProto(
type_url, value,
cel::internal::down_cast<google::protobuf::Any&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::Any>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down Expand Up @@ -112,7 +113,7 @@ absl::StatusOr<Any> UnwrapDynamicAnyProto(const google::protobuf::Message& messa
}
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Any::descriptor())) {
return UnwrapGeneratedAnyProto(
cel::internal::down_cast<const google::protobuf::Any&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::Any>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down
6 changes: 4 additions & 2 deletions extensions/protobuf/internal/duration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "absl/time/time.h"
#include "internal/casts.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"

namespace cel::extensions::protobuf_internal {

Expand All @@ -35,7 +36,7 @@ absl::StatusOr<absl::Duration> UnwrapDynamicDurationProto(
if (desc == google::protobuf::Duration::descriptor()) {
// Fast path.
return UnwrapGeneratedDurationProto(
cel::internal::down_cast<const google::protobuf::Duration&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::Duration>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down Expand Up @@ -91,7 +92,8 @@ absl::Status WrapDynamicDurationProto(absl::Duration value,
}
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Duration::descriptor())) {
return WrapGeneratedDurationProto(
value, cel::internal::down_cast<google::protobuf::Duration&>(message));
value,
google::protobuf::DownCastToGenerated<google::protobuf::Duration>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down
3 changes: 2 additions & 1 deletion extensions/protobuf/internal/field_mask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "internal/casts.h"
#include "google/protobuf/message.h"
#include "google/protobuf/reflection.h"

namespace cel::extensions::protobuf_internal {
Expand All @@ -37,7 +38,7 @@ absl::StatusOr<JsonString> DynamicFieldMaskProtoToJsonString(
}
if (ABSL_PREDICT_TRUE(desc == google::protobuf::FieldMask::descriptor())) {
return GeneratedFieldMaskProtoToJsonString(
cel::internal::down_cast<const google::protobuf::FieldMask&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::FieldMask>(message));
}
const auto* reflection = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflection == nullptr)) {
Expand Down
14 changes: 8 additions & 6 deletions extensions/protobuf/internal/struct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "internal/status_macros.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/map_field.h"
#include "google/protobuf/message.h"
#include "google/protobuf/reflection.h"

namespace cel::extensions::protobuf_internal {
Expand Down Expand Up @@ -165,7 +166,7 @@ absl::StatusOr<Json> DynamicValueProtoToJson(const google::protobuf::Message& me
CEL_ASSIGN_OR_RETURN(const auto* desc, GetDescriptor(message));
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Value::descriptor())) {
return GeneratedValueProtoToJson(
cel::internal::down_cast<const google::protobuf::Value&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::Value>(message));
}
CEL_ASSIGN_OR_RETURN(const auto* reflection, GetReflection(message));
CEL_ASSIGN_OR_RETURN(const auto* kind_desc, FindOneofByName(desc, "kind"));
Expand Down Expand Up @@ -244,7 +245,7 @@ absl::StatusOr<Json> DynamicListValueProtoToJson(
CEL_ASSIGN_OR_RETURN(const auto* desc, GetDescriptor(message));
if (ABSL_PREDICT_TRUE(desc == google::protobuf::ListValue::descriptor())) {
return GeneratedListValueProtoToJson(
cel::internal::down_cast<const google::protobuf::ListValue&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::ListValue>(message));
}
CEL_ASSIGN_OR_RETURN(const auto* reflection, GetReflection(message));
CEL_ASSIGN_OR_RETURN(
Expand Down Expand Up @@ -280,7 +281,7 @@ absl::StatusOr<Json> DynamicStructProtoToJson(const google::protobuf::Message& m
CEL_ASSIGN_OR_RETURN(const auto* desc, GetDescriptor(message));
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Struct::descriptor())) {
return GeneratedStructProtoToJson(
cel::internal::down_cast<const google::protobuf::Struct&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::Struct>(message));
}
CEL_ASSIGN_OR_RETURN(const auto* reflection, GetReflection(message));
CEL_ASSIGN_OR_RETURN(
Expand Down Expand Up @@ -324,7 +325,7 @@ absl::Status DynamicValueProtoFromJson(const Json& json,
CEL_ASSIGN_OR_RETURN(const auto* desc, GetDescriptor(message));
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Value::descriptor())) {
return GeneratedValueProtoFromJson(
json, cel::internal::down_cast<google::protobuf::Value&>(message));
json, google::protobuf::DownCastToGenerated<google::protobuf::Value>(message));
}
CEL_ASSIGN_OR_RETURN(const auto* reflection, GetReflection(message));
return absl::visit(
Expand Down Expand Up @@ -440,7 +441,8 @@ absl::Status DynamicListValueProtoFromJson(const JsonArray& json,
CEL_ASSIGN_OR_RETURN(const auto* desc, GetDescriptor(message));
if (ABSL_PREDICT_TRUE(desc == google::protobuf::ListValue::descriptor())) {
return GeneratedListValueProtoFromJson(
json, cel::internal::down_cast<google::protobuf::ListValue&>(message));
json,
google::protobuf::DownCastToGenerated<google::protobuf::ListValue>(message));
}
CEL_ASSIGN_OR_RETURN(const auto* reflection, GetReflection(message));
CEL_ASSIGN_OR_RETURN(
Expand Down Expand Up @@ -478,7 +480,7 @@ absl::Status DynamicStructProtoFromJson(const JsonObject& json,
CEL_ASSIGN_OR_RETURN(const auto* desc, GetDescriptor(message));
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Struct::descriptor())) {
return GeneratedStructProtoFromJson(
json, cel::internal::down_cast<google::protobuf::Struct&>(message));
json, google::protobuf::DownCastToGenerated<google::protobuf::Struct>(message));
}
CEL_ASSIGN_OR_RETURN(const auto* reflection, GetReflection(message));
CEL_ASSIGN_OR_RETURN(
Expand Down
6 changes: 4 additions & 2 deletions extensions/protobuf/internal/timestamp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "absl/time/time.h"
#include "internal/casts.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"

namespace cel::extensions::protobuf_internal {

Expand All @@ -35,7 +36,7 @@ absl::StatusOr<absl::Time> UnwrapDynamicTimestampProto(
if (desc == google::protobuf::Timestamp::descriptor()) {
// Fast path.
return UnwrapGeneratedTimestampProto(
cel::internal::down_cast<const google::protobuf::Timestamp&>(message));
google::protobuf::DownCastToGenerated<google::protobuf::Timestamp>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down Expand Up @@ -92,7 +93,8 @@ absl::Status WrapDynamicTimestampProto(absl::Time value,
}
if (ABSL_PREDICT_TRUE(desc == google::protobuf::Timestamp::descriptor())) {
return WrapGeneratedTimestampProto(
value, cel::internal::down_cast<google::protobuf::Timestamp&>(message));
value,
google::protobuf::DownCastToGenerated<google::protobuf::Timestamp>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down
5 changes: 3 additions & 2 deletions extensions/protobuf/internal/wrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "absl/strings/str_cat.h"
#include "internal/casts.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"

namespace cel::extensions::protobuf_internal {

Expand Down Expand Up @@ -59,7 +60,7 @@ absl::StatusOr<P> UnwrapValueProto(const google::protobuf::Message& message,
}
if (ABSL_PREDICT_TRUE(desc == T::descriptor())) {
// Fast path.
return unwrapper(cel::internal::down_cast<const T&>(message));
return unwrapper(google::protobuf::DownCastToGenerated<T>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down Expand Up @@ -96,7 +97,7 @@ absl::Status WrapValueProto(google::protobuf::Message& message, const P& value,
}
if (ABSL_PREDICT_TRUE(desc == T::descriptor())) {
// Fast path.
return wrapper(value, cel::internal::down_cast<T&>(message));
return wrapper(value, google::protobuf::DownCastToGenerated<T>(message));
}
const auto* reflect = message.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down
29 changes: 16 additions & 13 deletions extensions/protobuf/value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "extensions/protobuf/memory_manager.h"
#include "internal/casts.h"
#include "internal/status_macros.h"
#include "google/protobuf/message.h"

namespace cel::extensions {

Expand Down Expand Up @@ -853,7 +854,7 @@ absl::StatusOr<Handle<Value>> StructMessageCopyConverter(
if (value.GetDescriptor() == google::protobuf::Struct::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::Struct&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::Struct>(value));
}
std::string serialized;
if (!value.SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -887,7 +888,8 @@ absl::StatusOr<Handle<Value>> StructMessageMoveConverter(
if (value.GetDescriptor() == google::protobuf::Struct::descriptor()) {
return ProtoValue::Create(
value_factory,
std::move(cel::internal::down_cast<google::protobuf::Struct&>(value)));
std::move(
google::protobuf::DownCastToGenerated<google::protobuf::Struct>(value)));
}
std::string serialized;
if (!value.SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -922,7 +924,7 @@ absl::StatusOr<Handle<Value>> StructMessageBorrowConverter(
if (value.GetDescriptor() == google::protobuf::Struct::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::Struct&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::Struct>(value));
}
std::string serialized;
if (!value.SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -956,7 +958,8 @@ absl::StatusOr<Handle<Value>> StructMessageOwnConverter(
if (value->GetDescriptor() == google::protobuf::Struct::descriptor()) {
return ProtoValue::Create(
value_factory,
std::move(cel::internal::down_cast<google::protobuf::Struct&>(*value)));
std::move(
google::protobuf::DownCastToGenerated<google::protobuf::Struct>(*value)));
}
std::string serialized;
if (!value->SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -991,7 +994,7 @@ absl::StatusOr<Handle<Value>> ListValueMessageCopyConverter(
if (value.GetDescriptor() == google::protobuf::ListValue::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::ListValue&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::ListValue>(value));
}
std::string serialized;
if (!value.SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -1025,7 +1028,7 @@ absl::StatusOr<Handle<Value>> ListValueMessageMoveConverter(
return ProtoValue::Create(
value_factory,
std::move(
cel::internal::down_cast<google::protobuf::ListValue&>(value)));
google::protobuf::DownCastToGenerated<google::protobuf::ListValue>(value)));
}
std::string serialized;
if (!value.SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -1059,7 +1062,7 @@ absl::StatusOr<Handle<Value>> ListValueMessageBorrowConverter(
if (value.GetDescriptor() == google::protobuf::ListValue::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::ListValue&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::ListValue>(value));
}
std::string serialized;
if (!value.SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -1093,7 +1096,7 @@ absl::StatusOr<Handle<Value>> ListValueMessageOwnConverter(
return ProtoValue::Create(
value_factory,
std::move(
cel::internal::down_cast<google::protobuf::ListValue&>(*value)));
google::protobuf::DownCastToGenerated<google::protobuf::ListValue>(*value)));
}
std::string serialized;
if (!value->SerializePartialToString(&serialized)) {
Expand Down Expand Up @@ -1128,7 +1131,7 @@ absl::StatusOr<Handle<Value>> ValueMessageCopyConverter(
if (desc == google::protobuf::Value::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::Value&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::Value>(value));
}
const auto* oneof_desc = desc->FindOneofByName("kind");
if (ABSL_PREDICT_FALSE(oneof_desc == nullptr)) {
Expand Down Expand Up @@ -1174,7 +1177,7 @@ absl::StatusOr<Handle<Value>> ValueMessageMoveConverter(
if (desc == google::protobuf::Value::descriptor()) {
return ProtoValue::Create(
value_factory,
std::move(cel::internal::down_cast<google::protobuf::Value&>(value)));
std::move(google::protobuf::DownCastToGenerated<google::protobuf::Value>(value)));
}
const auto* oneof_desc = desc->FindOneofByName("kind");
if (ABSL_PREDICT_FALSE(oneof_desc == nullptr)) {
Expand Down Expand Up @@ -1223,7 +1226,7 @@ absl::StatusOr<Handle<Value>> ValueMessageBorrowConverter(
if (desc == google::protobuf::Value::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::Value&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::Value>(value));
}
const auto* oneof_desc = desc->FindOneofByName("kind");
if (ABSL_PREDICT_FALSE(oneof_desc == nullptr)) {
Expand Down Expand Up @@ -1269,7 +1272,7 @@ absl::StatusOr<Handle<Value>> ValueMessageOwnConverter(
if (desc == google::protobuf::Value::descriptor()) {
return ProtoValue::Create(
value_factory,
absl::WrapUnique(cel::internal::down_cast<google::protobuf::Value*>(
absl::WrapUnique(google::protobuf::DownCastToGenerated<google::protobuf::Value>(
value.release())));
}
const auto* oneof_desc = desc->FindOneofByName("kind");
Expand Down Expand Up @@ -1317,7 +1320,7 @@ absl::StatusOr<Handle<Value>> AnyMessageCopyConverter(
if (descriptor == google::protobuf::Any::descriptor()) {
return ProtoValue::Create(
value_factory,
cel::internal::down_cast<const google::protobuf::Any&>(value));
google::protobuf::DownCastToGenerated<google::protobuf::Any>(value));
}
const auto* reflect = value.GetReflection();
if (ABSL_PREDICT_FALSE(reflect == nullptr)) {
Expand Down