Coverage Report

Created: 2026-09-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/extensions/protobuf/internal/map_reflection.cc
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
#include "extensions/protobuf/internal/map_reflection.h"
16
17
#include "absl/base/nullability.h"
18
#include "google/protobuf/descriptor.h"
19
#include "google/protobuf/map_field.h"
20
#include "google/protobuf/message.h"
21
22
namespace google::protobuf::expr {
23
24
class CelMapReflectionFriend final {
25
 public:
26
  static bool LookupMapValue(const Reflection& reflection,
27
                             const Message& message,
28
                             const FieldDescriptor& field, const MapKey& key,
29
1.21k
                             MapValueConstRef* value) {
30
1.21k
    return reflection.LookupMapValue(message, &field, key, value);
31
1.21k
  }
32
33
  static bool ContainsMapKey(const Reflection& reflection,
34
                             const Message& message,
35
0
                             const FieldDescriptor& field, const MapKey& key) {
36
0
    return reflection.ContainsMapKey(message, &field, key);
37
0
  }
38
39
  static int MapSize(const google::protobuf::Reflection& reflection,
40
                     const google::protobuf::Message& message,
41
1.27k
                     const google::protobuf::FieldDescriptor& field) {
42
1.27k
    return reflection.MapSize(message, &field);
43
1.27k
  }
44
45
  static google::protobuf::ConstMapIterator ConstMapBegin(
46
      const google::protobuf::Reflection& reflection, const google::protobuf::Message& message,
47
1.26k
      const google::protobuf::FieldDescriptor& field) {
48
1.26k
    return reflection.ConstMapBegin(&message, &field);
49
1.26k
  }
50
51
  static google::protobuf::ConstMapIterator ConstMapEnd(
52
      const google::protobuf::Reflection& reflection, const google::protobuf::Message& message,
53
1.26k
      const google::protobuf::FieldDescriptor& field) {
54
1.26k
    return reflection.ConstMapEnd(&message, &field);
55
1.26k
  }
56
57
  static bool InsertOrLookupMapValue(const google::protobuf::Reflection& reflection,
58
                                     google::protobuf::Message* message,
59
                                     const google::protobuf::FieldDescriptor& field,
60
                                     const google::protobuf::MapKey& key,
61
54.1k
                                     google::protobuf::MapValueRef* value) {
62
54.1k
    return reflection.InsertOrLookupMapValue(message, &field, key, value);
63
54.1k
  }
64
65
  static bool DeleteMapValue(const google::protobuf::Reflection* absl_nonnull reflection,
66
                             google::protobuf::Message* absl_nonnull message,
67
                             const google::protobuf::FieldDescriptor* absl_nonnull field,
68
0
                             const google::protobuf::MapKey& key) {
69
0
    return reflection->DeleteMapValue(message, field, key);
70
0
  }
71
};
72
73
}  // namespace google::protobuf::expr
74
75
namespace cel::extensions::protobuf_internal {
76
77
bool LookupMapValue(const google::protobuf::Reflection& reflection,
78
                    const google::protobuf::Message& message,
79
                    const google::protobuf::FieldDescriptor& field,
80
                    const google::protobuf::MapKey& key,
81
1.21k
                    google::protobuf::MapValueConstRef* value) {
82
1.21k
  return google::protobuf::expr::CelMapReflectionFriend::LookupMapValue(
83
1.21k
      reflection, message, field, key, value);
84
1.21k
}
85
86
bool ContainsMapKey(const google::protobuf::Reflection& reflection,
87
                    const google::protobuf::Message& message,
88
                    const google::protobuf::FieldDescriptor& field,
89
0
                    const google::protobuf::MapKey& key) {
90
0
  return google::protobuf::expr::CelMapReflectionFriend::ContainsMapKey(
91
0
      reflection, message, field, key);
92
0
}
93
94
int MapSize(const google::protobuf::Reflection& reflection,
95
            const google::protobuf::Message& message,
96
1.27k
            const google::protobuf::FieldDescriptor& field) {
97
1.27k
  return google::protobuf::expr::CelMapReflectionFriend::MapSize(reflection, message,
98
1.27k
                                                       field);
99
1.27k
}
100
101
google::protobuf::ConstMapIterator ConstMapBegin(const google::protobuf::Reflection& reflection,
102
                                       const google::protobuf::Message& message,
103
1.26k
                                       const google::protobuf::FieldDescriptor& field) {
104
1.26k
  return google::protobuf::expr::CelMapReflectionFriend::ConstMapBegin(reflection,
105
1.26k
                                                             message, field);
106
1.26k
}
107
108
google::protobuf::ConstMapIterator ConstMapEnd(const google::protobuf::Reflection& reflection,
109
                                     const google::protobuf::Message& message,
110
1.26k
                                     const google::protobuf::FieldDescriptor& field) {
111
1.26k
  return google::protobuf::expr::CelMapReflectionFriend::ConstMapEnd(reflection, message,
112
1.26k
                                                           field);
113
1.26k
}
114
115
bool InsertOrLookupMapValue(const google::protobuf::Reflection& reflection,
116
                            google::protobuf::Message* message,
117
                            const google::protobuf::FieldDescriptor& field,
118
                            const google::protobuf::MapKey& key,
119
54.1k
                            google::protobuf::MapValueRef* value) {
120
54.1k
  return google::protobuf::expr::CelMapReflectionFriend::InsertOrLookupMapValue(
121
54.1k
      reflection, message, field, key, value);
122
54.1k
}
123
124
bool DeleteMapValue(const google::protobuf::Reflection* absl_nonnull reflection,
125
                    google::protobuf::Message* absl_nonnull message,
126
                    const google::protobuf::FieldDescriptor* absl_nonnull field,
127
0
                    const google::protobuf::MapKey& key) {
128
0
  return google::protobuf::expr::CelMapReflectionFriend::DeleteMapValue(
129
0
      reflection, message, field, key);
130
0
}
131
132
}  // namespace cel::extensions::protobuf_internal