Coverage Report

Created: 2026-11-12 06:42

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 "base/attribute_matcher.h"
24
#include "common/value.h"
25
#include "eval/public/base_activation.h"
26
#include "runtime/activation_interface.h"
27
#include "runtime/function_overload_reference.h"
28
#include "google/protobuf/arena.h"
29
#include "google/protobuf/descriptor.h"
30
#include "google/protobuf/message.h"
31
32
namespace cel::interop_internal {
33
34
// An Activation implementation that adapts the legacy version (based on
35
// expr::CelValue) to the new cel::Handle based version. This implementation
36
// must be scoped to an evaluation.
37
class AdapterActivationImpl : public ActivationInterface {
38
 public:
39
  explicit AdapterActivationImpl(
40
      const google::api::expr::runtime::BaseActivation& legacy_activation)
41
18.9k
      : legacy_activation_(legacy_activation) {}
42
43
  absl::StatusOr<bool> FindVariable(
44
      absl::string_view name,
45
      const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
46
      google::protobuf::MessageFactory* absl_nonnull message_factory,
47
      google::protobuf::Arena* absl_nonnull arena,
48
      Value* absl_nonnull result) const override;
49
50
  std::vector<FunctionOverloadReference> FindFunctionOverloads(
51
      absl::string_view name) const override;
52
53
0
  const AttributeMatcher& GetUnknownAttributeMatcher() const override {
54
0
    return legacy_activation_.GetUnknownAttributeMatcher();
55
0
  }
56
57
0
  const AttributeMatcher& GetKnownAttributeMatcher() const override {
58
0
    return legacy_activation_.GetKnownAttributeMatcher();
59
0
  }
60
61
0
  const AttributeMatcher& GetMissingAttributeMatcher() const override {
62
0
    return legacy_activation_.GetMissingAttributeMatcher();
63
0
  }
64
65
 private:
66
  const google::api::expr::runtime::BaseActivation& legacy_activation_;
67
};
68
69
}  // namespace cel::interop_internal
70
71
#endif  // THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ADAPTER_ACTIVATION_IMPL_H_