Skip to content

Commit f0a393a

Browse files
jckingcopybara-github
authored andcommitted
Delete cel::common_internal::DataInterface
PiperOrigin-RevId: 728771855
1 parent cc72dd8 commit f0a393a

File tree

5 files changed

+36
-143
lines changed

5 files changed

+36
-143
lines changed

common/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ cc_library(
601601
"//base:attributes",
602602
"//base/internal:message_wrapper",
603603
"//common/internal:arena_string",
604-
"//common/internal:data_interface",
605604
"//common/internal:reference_count",
606605
"//common/internal:shared_byte_string",
607606
"//eval/internal:cel_value_equal",

common/internal/BUILD

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,6 @@ cc_library(
3333
],
3434
)
3535

36-
cc_library(
37-
name = "data_interface",
38-
hdrs = ["data_interface.h"],
39-
deps = [
40-
"//common:native_type",
41-
"@com_google_absl//absl/base:core_headers",
42-
],
43-
)
44-
45-
cc_test(
46-
name = "data_interface_test",
47-
srcs = ["data_interface_test.cc"],
48-
deps = [
49-
":data_interface",
50-
"//common:native_type",
51-
"//internal:testing",
52-
],
53-
)
54-
5536
cc_library(
5637
name = "reference_count",
5738
srcs = ["reference_count.cc"],

common/internal/data_interface.h

Lines changed: 0 additions & 77 deletions
This file was deleted.

common/internal/data_interface_test.cc

Lines changed: 0 additions & 43 deletions
This file was deleted.

common/values/custom_value_interface.h

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
#define THIRD_PARTY_CEL_CPP_COMMON_VALUES_CUSTOM_VALUE_INTERFACE_H_
2020

2121
#include <string>
22+
#include <type_traits>
2223

2324
#include "absl/base/nullability.h"
2425
#include "absl/status/status.h"
2526
#include "absl/strings/cord.h"
2627
#include "absl/strings/string_view.h"
27-
#include "common/internal/data_interface.h"
28+
#include "common/native_type.h"
2829
#include "common/value_kind.h"
2930
#include "google/protobuf/arena.h"
3031
#include "google/protobuf/descriptor.h"
@@ -34,9 +35,15 @@ namespace cel {
3435

3536
class Value;
3637

37-
class CustomValueInterface : public common_internal::DataInterface {
38+
class CustomValueInterface {
3839
public:
39-
using DataInterface::DataInterface;
40+
CustomValueInterface(const CustomValueInterface&) = delete;
41+
CustomValueInterface(CustomValueInterface&&) = delete;
42+
43+
virtual ~CustomValueInterface() = default;
44+
45+
CustomValueInterface& operator=(const CustomValueInterface&) = delete;
46+
CustomValueInterface& operator=(CustomValueInterface&&) = delete;
4047

4148
virtual ValueKind kind() const = 0;
4249

@@ -74,6 +81,32 @@ class CustomValueInterface : public common_internal::DataInterface {
7481
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
7582
absl::Nonnull<google::protobuf::Arena*> arena,
7683
absl::Nonnull<Value*> result) const = 0;
84+
85+
protected:
86+
CustomValueInterface() = default;
87+
88+
private:
89+
friend struct NativeTypeTraits<CustomValueInterface>;
90+
91+
virtual NativeTypeId GetNativeTypeId() const = 0;
92+
};
93+
94+
template <>
95+
struct NativeTypeTraits<CustomValueInterface> final {
96+
static NativeTypeId Id(const CustomValueInterface& custom_value_interface) {
97+
return custom_value_interface.GetNativeTypeId();
98+
}
99+
};
100+
101+
template <typename T>
102+
struct NativeTypeTraits<
103+
T, std::enable_if_t<std::conjunction_v<
104+
std::is_base_of<CustomValueInterface, T>,
105+
std::negation<std::is_same<T, CustomValueInterface>>>>>
106+
final {
107+
static NativeTypeId Id(const CustomValueInterface& custom_value_interface) {
108+
return NativeTypeTraits<CustomValueInterface>::Id(custom_value_interface);
109+
}
77110
};
78111

79112
} // namespace cel

0 commit comments

Comments
 (0)