Skip to content

Commit 9a8b79d

Browse files
jckingcopybara-github
authored andcommitted
Remove more cruft
PiperOrigin-RevId: 718055885
1 parent 3aef50a commit 9a8b79d

13 files changed

+0
-213
lines changed

common/type_reflector.cc

-18
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include "absl/base/no_destructor.h"
1818
#include "absl/base/nullability.h"
1919
#include "absl/status/statusor.h"
20-
#include "absl/strings/cord.h"
2120
#include "absl/strings/string_view.h"
22-
#include "absl/types/optional.h"
2321
#include "common/memory.h"
2422
#include "common/type.h"
2523
#include "common/value.h"
@@ -33,28 +31,12 @@ absl::StatusOr<absl::Nullable<ValueBuilderPtr>> TypeReflector::NewValueBuilder(
3331
return nullptr;
3432
}
3533

36-
absl::StatusOr<absl::optional<Value>> TypeReflector::DeserializeValue(
37-
ValueFactory& value_factory, absl::string_view type_url,
38-
const absl::Cord& value) const {
39-
return DeserializeValueImpl(value_factory, type_url, value);
40-
}
41-
42-
absl::StatusOr<absl::optional<Value>> TypeReflector::DeserializeValueImpl(
43-
ValueFactory&, absl::string_view, const absl::Cord&) const {
44-
return absl::nullopt;
45-
}
46-
4734
absl::StatusOr<absl::Nullable<StructValueBuilderPtr>>
4835
TypeReflector::NewStructValueBuilder(ValueFactory& value_factory,
4936
const StructType& type) const {
5037
return nullptr;
5138
}
5239

53-
absl::StatusOr<bool> TypeReflector::FindValue(ValueFactory&, absl::string_view,
54-
Value&) const {
55-
return false;
56-
}
57-
5840
TypeReflector& TypeReflector::Builtin() {
5941
static absl::NoDestructor<TypeReflector> instance;
6042
return *instance;

common/type_reflector.h

-17
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,10 @@ class TypeReflector : public virtual TypeIntrospector {
6565
virtual absl::StatusOr<absl::Nullable<ValueBuilderPtr>> NewValueBuilder(
6666
ValueFactory& value_factory, absl::string_view name) const;
6767

68-
// `FindValue` returns a new `Value` for the corresponding name `name`. This
69-
// can be used to translate enum names to numeric values.
70-
virtual absl::StatusOr<bool> FindValue(ValueFactory& value_factory,
71-
absl::string_view name,
72-
Value& result) const;
73-
74-
// `DeserializeValue` deserializes the bytes of `value` according to
75-
// `type_url`. Returns `NOT_FOUND` if `type_url` is unrecognized.
76-
virtual absl::StatusOr<absl::optional<Value>> DeserializeValue(
77-
ValueFactory& value_factory, absl::string_view type_url,
78-
const absl::Cord& value) const;
79-
8068
virtual absl::Nullable<const google::protobuf::DescriptorPool*> descriptor_pool()
8169
const {
8270
return nullptr;
8371
}
84-
85-
protected:
86-
virtual absl::StatusOr<absl::optional<Value>> DeserializeValueImpl(
87-
ValueFactory& value_factory, absl::string_view type_url,
88-
const absl::Cord& value) const;
8972
};
9073

9174
Shared<TypeReflector> NewThreadCompatibleTypeReflector(

common/value_manager.h

-13
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
#include "absl/base/nullability.h"
1919
#include "absl/status/statusor.h"
20-
#include "absl/strings/cord.h"
2120
#include "absl/strings/string_view.h"
22-
#include "absl/types/optional.h"
2321
#include "common/json.h"
2422
#include "common/memory.h"
2523
#include "common/type.h"
@@ -63,17 +61,6 @@ class ValueManager : public virtual ValueFactory,
6361
return GetTypeReflector().NewValueBuilder(*this, name);
6462
}
6563

66-
// See `TypeReflector::FindValue`.
67-
absl::StatusOr<bool> FindValue(absl::string_view name, Value& result) {
68-
return GetTypeReflector().FindValue(*this, name, result);
69-
}
70-
71-
// See `TypeReflector::DeserializeValue`.
72-
absl::StatusOr<absl::optional<Value>> DeserializeValue(
73-
absl::string_view type_url, const absl::Cord& value) {
74-
return GetTypeReflector().DeserializeValue(*this, type_url, value);
75-
}
76-
7764
absl::Nullable<google::protobuf::MessageFactory*> message_factory() const override = 0;
7865

7966
protected:

common/values/struct_value_builder.cc

-31
Original file line numberDiff line numberDiff line change
@@ -145,37 +145,6 @@ class CompatTypeReflector final : public TypeReflector {
145145
name);
146146
}
147147

148-
absl::StatusOr<absl::optional<Value>> DeserializeValue(
149-
ValueFactory& value_factory, absl::string_view type_url,
150-
const absl::Cord& value) const override {
151-
const auto* descriptor_pool = this->descriptor_pool();
152-
auto* message_factory = value_factory.message_factory();
153-
if (message_factory == nullptr) {
154-
return absl::nullopt;
155-
}
156-
absl::string_view type_name;
157-
if (!ParseTypeUrl(type_url, &type_name)) {
158-
return absl::InvalidArgumentError("invalid type URL");
159-
}
160-
const auto* descriptor = descriptor_pool->FindMessageTypeByName(type_name);
161-
if (descriptor == nullptr) {
162-
return absl::nullopt;
163-
}
164-
const auto* prototype = message_factory->GetPrototype(descriptor);
165-
if (prototype == nullptr) {
166-
return absl::nullopt;
167-
}
168-
absl::Nullable<google::protobuf::Arena*> arena =
169-
value_factory.GetMemoryManager().arena();
170-
auto message = WrapShared(prototype->New(arena), arena);
171-
if (!message->ParsePartialFromCord(value)) {
172-
return absl::InvalidArgumentError(
173-
absl::StrCat("failed to parse `", type_url, "`"));
174-
}
175-
return Value::Message(WrapShared(prototype->New(arena), arena),
176-
descriptor_pool, message_factory);
177-
}
178-
179148
private:
180149
const google::protobuf::DescriptorPool* const pool_;
181150
};

common/values/thread_compatible_type_reflector.cc

-9
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
#include "absl/base/nullability.h"
1818
#include "absl/status/statusor.h"
19-
#include "absl/strings/string_view.h"
20-
#include "absl/types/optional.h"
21-
#include "common/memory.h"
2219
#include "common/type.h"
2320
#include "common/value.h"
2421

@@ -30,10 +27,4 @@ ThreadCompatibleTypeReflector::NewStructValueBuilder(ValueFactory&,
3027
return nullptr;
3128
}
3229

33-
absl::StatusOr<bool> ThreadCompatibleTypeReflector::FindValue(ValueFactory&,
34-
absl::string_view,
35-
Value&) const {
36-
return false;
37-
}
38-
3930
} // namespace cel::common_internal

common/values/thread_compatible_type_reflector.h

-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "absl/base/nullability.h"
2121
#include "absl/status/statusor.h"
22-
#include "absl/strings/string_view.h"
2322
#include "common/type.h"
2423
#include "common/type_reflector.h"
2524
#include "common/types/thread_compatible_type_introspector.h"
@@ -38,10 +37,6 @@ class ThreadCompatibleTypeReflector : public ThreadCompatibleTypeIntrospector,
3837

3938
absl::StatusOr<absl::Nullable<StructValueBuilderPtr>> NewStructValueBuilder(
4039
ValueFactory& value_factory, const StructType& type) const override;
41-
42-
absl::StatusOr<bool> FindValue(ValueFactory& value_factory,
43-
absl::string_view name,
44-
Value& result) const override;
4540
};
4641

4742
} // namespace common_internal

eval/public/structs/legacy_type_provider.cc

-36
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
#include "absl/base/nullability.h"
2222
#include "absl/status/status.h"
2323
#include "absl/status/statusor.h"
24-
#include "absl/strings/cord.h"
2524
#include "absl/strings/str_cat.h"
2625
#include "absl/strings/string_view.h"
27-
#include "absl/strings/strip.h"
2826
#include "absl/types/optional.h"
29-
#include "common/any.h"
3027
#include "common/legacy_value.h"
3128
#include "common/memory.h"
3229
#include "common/type.h"
@@ -173,39 +170,6 @@ LegacyTypeProvider::NewStructValueBuilder(cel::ValueFactory& value_factory,
173170
return nullptr;
174171
}
175172

176-
absl::StatusOr<absl::optional<cel::Value>>
177-
LegacyTypeProvider::DeserializeValueImpl(cel::ValueFactory& value_factory,
178-
absl::string_view type_url,
179-
const absl::Cord& value) const {
180-
auto type_name = absl::StripPrefix(type_url, cel::kTypeGoogleApisComPrefix);
181-
if (auto type_info = ProvideLegacyTypeInfo(type_name);
182-
type_info.has_value()) {
183-
if (auto type_adapter = ProvideLegacyType(type_name);
184-
type_adapter.has_value()) {
185-
const auto* mutation_apis = type_adapter->mutation_apis();
186-
if (mutation_apis == nullptr) {
187-
return absl::FailedPreconditionError(absl::StrCat(
188-
"LegacyTypeMutationApis missing for type: ", type_name));
189-
}
190-
CEL_ASSIGN_OR_RETURN(auto builder, mutation_apis->NewInstance(
191-
value_factory.GetMemoryManager()));
192-
if (!builder.message_ptr()->ParsePartialFromCord(value)) {
193-
return absl::UnknownError("failed to parse protocol buffer message");
194-
}
195-
CEL_ASSIGN_OR_RETURN(
196-
auto legacy_value,
197-
mutation_apis->AdaptFromWellKnownType(
198-
value_factory.GetMemoryManager(), std::move(builder)));
199-
cel::Value modern_value;
200-
CEL_RETURN_IF_ERROR(ModernValue(cel::extensions::ProtoMemoryManagerArena(
201-
value_factory.GetMemoryManager()),
202-
legacy_value, modern_value));
203-
return modern_value;
204-
}
205-
}
206-
return absl::nullopt;
207-
}
208-
209173
absl::StatusOr<absl::optional<cel::Type>> LegacyTypeProvider::FindTypeImpl(
210174
absl::string_view name) const {
211175
if (auto type_info = ProvideLegacyTypeInfo(name); type_info.has_value()) {

eval/public/structs/legacy_type_provider.h

-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "absl/base/attributes.h"
1919
#include "absl/base/nullability.h"
2020
#include "absl/status/statusor.h"
21-
#include "absl/strings/cord.h"
2221
#include "absl/strings/string_view.h"
2322
#include "absl/types/optional.h"
2423
#include "common/type.h"
@@ -68,10 +67,6 @@ class LegacyTypeProvider : public cel::TypeReflector {
6867
const cel::StructType& type) const final;
6968

7069
protected:
71-
absl::StatusOr<absl::optional<cel::Value>> DeserializeValueImpl(
72-
cel::ValueFactory& value_factory, absl::string_view type_url,
73-
const absl::Cord& value) const final;
74-
7570
absl::StatusOr<absl::optional<cel::Type>> FindTypeImpl(
7671
absl::string_view name) const final;
7772

extensions/protobuf/BUILD

-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ cc_test(
157157

158158
cc_library(
159159
name = "value",
160-
srcs = [
161-
"type_reflector.cc",
162-
],
163160
hdrs = [
164161
"type_reflector.h",
165162
"value.h",

extensions/protobuf/type_reflector.cc

-34
This file was deleted.

extensions/protobuf/type_reflector.h

-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ class ProtoTypeReflector : public TypeReflector, public ProtoTypeIntrospector {
4141
const override {
4242
return ProtoTypeIntrospector::descriptor_pool();
4343
}
44-
45-
private:
46-
absl::StatusOr<absl::optional<Value>> DeserializeValueImpl(
47-
ValueFactory& value_factory, absl::string_view type_url,
48-
const absl::Cord& value) const final;
4944
};
5045

5146
} // namespace cel::extensions

runtime/internal/runtime_type_provider.cc

-31
Original file line numberDiff line numberDiff line change
@@ -127,35 +127,4 @@ RuntimeTypeProvider::NewValueBuilder(ValueFactory& value_factory,
127127
name);
128128
}
129129

130-
absl::StatusOr<absl::optional<Value>> RuntimeTypeProvider::DeserializeValue(
131-
ValueFactory& value_factory, absl::string_view type_url,
132-
const absl::Cord& value) const {
133-
const auto* descriptor_pool = this->descriptor_pool();
134-
auto* message_factory = value_factory.message_factory();
135-
if (message_factory == nullptr) {
136-
return absl::nullopt;
137-
}
138-
absl::string_view type_name;
139-
if (!ParseTypeUrl(type_url, &type_name)) {
140-
return absl::InvalidArgumentError("invalid type URL");
141-
}
142-
const auto* descriptor = descriptor_pool->FindMessageTypeByName(type_name);
143-
if (descriptor == nullptr) {
144-
return absl::nullopt;
145-
}
146-
const auto* prototype = message_factory->GetPrototype(descriptor);
147-
if (prototype == nullptr) {
148-
return absl::nullopt;
149-
}
150-
absl::Nullable<google::protobuf::Arena*> arena =
151-
value_factory.GetMemoryManager().arena();
152-
auto message = WrapShared(prototype->New(arena), arena);
153-
if (!message->ParsePartialFromCord(value)) {
154-
return absl::InvalidArgumentError(
155-
absl::StrCat("failed to parse `", type_url, "`"));
156-
}
157-
return Value::Message(WrapShared(prototype->New(arena), arena),
158-
descriptor_pool, message_factory);
159-
}
160-
161130
} // namespace cel::runtime_internal

runtime/internal/runtime_type_provider.h

-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ class RuntimeTypeProvider final : public TypeReflector {
4444
absl::StatusOr<absl::Nullable<ValueBuilderPtr>> NewValueBuilder(
4545
ValueFactory& value_factory, absl::string_view name) const override;
4646

47-
// `DeserializeValue` deserializes the bytes of `value` according to
48-
// `type_url`. Returns `NOT_FOUND` if `type_url` is unrecognized.
49-
absl::StatusOr<absl::optional<Value>> DeserializeValue(
50-
ValueFactory& value_factory, absl::string_view type_url,
51-
const absl::Cord& value) const override;
52-
5347
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool()
5448
const override {
5549
return descriptor_pool_;

0 commit comments

Comments
 (0)