Coverage Report

Created: 2026-05-27 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/eval/internal/adapter_activation_impl.h
Line
Count
Source
1
// Copyright 2022 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ADAPTER_ACTIVATION_IMPL_H_
16
#define THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ADAPTER_ACTIVATION_IMPL_H_
17
18
#include <vector>
19
20
#include "absl/base/nullability.h"
21
#include "absl/status/statusor.h"
22
#include "absl/strings/string_view.h"
23
#include "absl/types/span.h"
24
#include "base/attribute.h"
25
#include "common/value.h"
26
#include "eval/public/base_activation.h"
27
#include "runtime/activation_interface.h"
28
#include "runtime/function_overload_reference.h"
29
#include "runtime/internal/attribute_matcher.h"
30
#include "google/protobuf/arena.h"
31
#include "google/protobuf/descriptor.h"
32
#include "google/protobuf/message.h"
33
34
namespace cel::interop_internal {
35
36
// An Activation implementation that adapts the legacy version (based on
37
// expr::CelValue) to the new cel::Handle based version. This implementation
38
// must be scoped to an evaluation.
39
class AdapterActivationImpl : public ActivationInterface {
40
 public:
41
  explicit AdapterActivationImpl(
42
      const google::api::expr::runtime::BaseActivation& legacy_activation)
43
9.92k
      : legacy_activation_(legacy_activation) {}
44
45
  absl::StatusOr<bool> FindVariable(
46
      absl::string_view name,
47
      const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
48
      google::protobuf::MessageFactory* absl_nonnull message_factory,
49
      google::protobuf::Arena* absl_nonnull arena,
50
      Value* absl_nonnull result) const override;
51
52
  std::vector<FunctionOverloadReference> FindFunctionOverloads(
53
      absl::string_view name) const override;
54
55
  absl::Span<const cel::AttributePattern> GetUnknownAttributes() const override;
56
57
  absl::Span<const cel::AttributePattern> GetMissingAttributes() const override;
58
59
 private:
60
  const runtime_internal::AttributeMatcher* absl_nullable GetAttributeMatcher()
61
      const override;
62
63
  const google::api::expr::runtime::BaseActivation& legacy_activation_;
64
};
65
66
}  // namespace cel::interop_internal
67
68
#endif  // THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ADAPTER_ACTIVATION_IMPL_H_