1818#ifndef THIRD_PARTY_CEL_CPP_EVAL_PUBLIC_STRUCTS_LEGACY_TYPE_ADPATER_H_
1919#define THIRD_PARTY_CEL_CPP_EVAL_PUBLIC_STRUCTS_LEGACY_TYPE_ADPATER_H_
2020
21- #include < cstdint >
21+ #include < cstddef >
2222#include < vector>
2323
2424#include " absl/status/status.h"
@@ -36,54 +36,6 @@ namespace google::api::expr::runtime {
3636class DucktypedMessageAdapter ;
3737class ProtoMessageTypeAdapter ;
3838
39- // Interface for mutation apis.
40- // Note: in the new type system, a type provider represents this by returning
41- // a cel::Type and cel::ValueManager for the type.
42- class LegacyTypeMutationApis {
43- public:
44- virtual ~LegacyTypeMutationApis () = default ;
45-
46- // Return whether the type defines the given field.
47- // TODO(uncreated-issue/3): This is only used to eagerly fail during the planning
48- // phase. Check if it's safe to remove this behavior and fail at runtime.
49- virtual bool DefinesField (absl::string_view field_name) const = 0;
50-
51- // Create a new empty instance of the type.
52- // May return a status if the type is not possible to create.
53- virtual absl::StatusOr<CelValue::MessageWrapper::Builder> NewInstance (
54- cel::MemoryManagerRef memory_manager) const = 0;
55-
56- // Normalize special types to a native CEL value after building.
57- // The interpreter guarantees that instance is uniquely owned by the
58- // interpreter, and can be safely mutated.
59- virtual absl::StatusOr<CelValue> AdaptFromWellKnownType (
60- cel::MemoryManagerRef memory_manager,
61- CelValue::MessageWrapper::Builder instance) const = 0;
62-
63- // Set field on instance to value.
64- // The interpreter guarantees that instance is uniquely owned by the
65- // interpreter, and can be safely mutated.
66- virtual absl::Status SetField (
67- absl::string_view field_name, const CelValue& value,
68- cel::MemoryManagerRef memory_manager,
69- CelValue::MessageWrapper::Builder& instance) const = 0;
70-
71- virtual absl::Status SetFieldByNumber (
72- int64_t field_number [[maybe_unused]] ,
73- const CelValue& value [[maybe_unused]] ,
74- cel::MemoryManagerRef memory_manager [[maybe_unused]] ,
75- CelValue::MessageWrapper::Builder& instance [[maybe_unused]] ) const {
76- return absl::UnimplementedError (" SetFieldByNumber is not yet implemented" );
77- }
78-
79- private:
80- // This class should only be implemented by CEL. Custom structs are only
81- // supported using the cel::Value APIs.
82- friend class ProtoMessageTypeAdapter ;
83-
84- LegacyTypeMutationApis () = default ;
85- };
86-
8739// Interface for access apis.
8840// Note: in new type system this is integrated into the StructValue (via
8941// dynamic dispatch to concrete implementations).
@@ -162,9 +114,6 @@ class LegacyTypeAccessApis {
162114// Type information about a legacy Struct type.
163115// Provides methods to the interpreter for interacting with a custom type.
164116//
165- // mutation_apis() provide equivalent behavior to a cel::Type and
166- // cel::ValueManager (resolved from a type name).
167- //
168117// access_apis() provide equivalent behavior to cel::StructValue accessors
169118// (virtual dispatch to a concrete implementation for accessing underlying
170119// values).
@@ -174,21 +123,18 @@ class LegacyTypeAccessApis {
174123// the type provider that returned this object.
175124class LegacyTypeAdapter {
176125 public:
177- LegacyTypeAdapter (const LegacyTypeAccessApis* access,
178- const LegacyTypeMutationApis* mutation)
179- : access_apis_(access), mutation_apis_(mutation) {}
126+ explicit LegacyTypeAdapter (const LegacyTypeAccessApis* access)
127+ : access_apis_(access) {}
128+ // Temporary constructor to support fakes in client tests.
129+ LegacyTypeAdapter (const LegacyTypeAccessApis* access, std::nullptr_t )
130+ : access_apis_(access) {}
180131
181132 // Apis for access for the represented type.
182133 // If null, access is not supported (this is an opaque type).
183- const LegacyTypeAccessApis* access_apis () { return access_apis_; }
184-
185- // Apis for mutation for the represented type.
186- // If null, mutation is not supported (this type cannot be created).
187- const LegacyTypeMutationApis* mutation_apis () { return mutation_apis_; }
134+ const LegacyTypeAccessApis* access_apis () const { return access_apis_; }
188135
189136 private:
190137 const LegacyTypeAccessApis* access_apis_;
191- const LegacyTypeMutationApis* mutation_apis_;
192138};
193139
194140} // namespace google::api::expr::runtime
0 commit comments