forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cel-cpp.patch
159 lines (143 loc) · 6.38 KB
/
cel-cpp.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
diff --git a/base/memory.h b/base/memory.h
index 3552e19..0fbe618 100644
--- a/base/memory.h
+++ b/base/memory.h
@@ -166,8 +166,8 @@ std::enable_if_t<IsDerivedHeapDataV<F>, Handle<T>> HandleFactory<T>::Make(
#if defined(__cpp_lib_is_pointer_interconvertible) && \
__cpp_lib_is_pointer_interconvertible >= 201907L
// Only available in C++20.
- static_assert(std::is_pointer_interconvertible_base_of_v<Data, F>,
- "F must be pointer interconvertible to Data");
+// static_assert(std::is_pointer_interconvertible_base_of_v<Data, F>,
+// "F must be pointer interconvertible to Data");
#endif
if (memory_manager.memory_management() == MemoryManagement::kPooling) {
void* addr;
diff --git a/eval/internal/interop.cc b/eval/internal/interop.cc
index 3acde6c..20f8ea3 100644
--- a/eval/internal/interop.cc
+++ b/eval/internal/interop.cc
@@ -729,13 +729,14 @@ absl::StatusOr<CelValue> ToLegacyValue(google::protobuf::Arena* arena,
return CelValue::CreateMessageWrapper(
MessageWrapperAccess::Make(message, type_info));
}
- if (ProtoStructValueToMessageWrapper) {
+ // This weak symbol is never defined in Envoy, and checking it causes linker failures on macOS
+ /*if (ProtoStructValueToMessageWrapper) {
auto maybe_message_wrapper = ProtoStructValueToMessageWrapper(*value);
if (maybe_message_wrapper.has_value()) {
return CelValue::CreateMessageWrapper(
std::move(maybe_message_wrapper).value());
}
- }
+ }*/
return absl::UnimplementedError(
"only legacy struct types and values can be used for interop");
}
diff --git a/eval/public/cel_value.cc b/eval/public/cel_value.cc
index 6aeff6d..c43864c 100644
--- a/eval/public/cel_value.cc
+++ b/eval/public/cel_value.cc
@@ -107,7 +107,7 @@ struct DebugStringVisitor {
} // namespace
-const absl::string_view kPayloadUrlMissingAttributePath =
+ABSL_CONST_INIT const absl::string_view kPayloadUrlMissingAttributePath =
cel::runtime_internal::kPayloadUrlMissingAttributePath;
CelValue CelValue::CreateDuration(absl::Duration value) {
diff --git a/eval/public/containers/container_backed_map_impl.h b/eval/public/containers/container_backed_map_impl.h
index 6092eef..7548bbf 100644
--- a/eval/public/containers/container_backed_map_impl.h
+++ b/eval/public/containers/container_backed_map_impl.h
@@ -30,6 +30,7 @@ class CelMapBuilder : public CelMap {
return values_map_.contains(cel_key);
}
+ using CelMap::ListKeys;
absl::StatusOr<const CelList*> ListKeys() const override {
return &key_list_;
}
diff --git a/eval/public/containers/internal_field_backed_map_impl.h b/eval/public/containers/internal_field_backed_map_impl.h
index ec773d9..caa2f3a 100644
--- a/eval/public/containers/internal_field_backed_map_impl.h
+++ b/eval/public/containers/internal_field_backed_map_impl.h
@@ -43,6 +43,7 @@ class FieldBackedMapImpl : public CelMap {
// Presence test function.
absl::StatusOr<bool> Has(const CelValue& key) const override;
+ using CelMap::ListKeys;
absl::StatusOr<const CelList*> ListKeys() const override;
protected:
diff --git a/eval/public/structs/cel_proto_lite_wrap_util.cc b/eval/public/structs/cel_proto_lite_wrap_util.cc
index 4cb21e5..35fdf7f 100644
--- a/eval/public/structs/cel_proto_lite_wrap_util.cc
+++ b/eval/public/structs/cel_proto_lite_wrap_util.cc
@@ -172,6 +172,7 @@ class DynamicMap : public CelMap {
int size() const override { return values_->fields_size(); }
+ using CelMap::ListKeys;
absl::StatusOr<const CelList*> ListKeys() const override {
return &key_list_;
}
diff --git a/eval/public/structs/cel_proto_wrap_util.cc b/eval/public/structs/cel_proto_wrap_util.cc
index fabb594..86a314c 100644
--- a/eval/public/structs/cel_proto_wrap_util.cc
+++ b/eval/public/structs/cel_proto_wrap_util.cc
@@ -137,6 +137,7 @@ class DynamicMap : public CelMap {
int size() const override { return values_->fields_size(); }
+ using CelMap::ListKeys;
absl::StatusOr<const CelList*> ListKeys() const override {
return &key_list_;
}
diff --git a/internal/strings.cc b/internal/strings.cc
index dc5a118..24457ab 100644
--- a/internal/strings.cc
+++ b/internal/strings.cc
@@ -53,12 +53,12 @@ bool CheckForClosingString(absl::string_view source,
if (closing_str.empty()) return true;
const char* p = source.data();
- const char* end = source.end();
+ const char* end = p + source.size();
bool is_closed = false;
while (p + closing_str.length() <= end) {
if (*p != '\\') {
- size_t cur_pos = p - source.begin();
+ size_t cur_pos = p - source.data();
bool is_closing =
absl::StartsWith(absl::ClippedSubstr(source, cur_pos), closing_str);
if (is_closing && p + closing_str.length() < end) {
@@ -132,7 +132,7 @@ bool UnescapeInternal(absl::string_view source, absl::string_view closing_str,
dest->reserve(source.size());
const char* p = source.data();
- const char* end = source.end();
+ const char* end = p + source.size();
const char* last_byte = end - 1;
while (p < end) {
@@ -446,7 +446,9 @@ std::string EscapeInternal(absl::string_view src, bool escape_all_bytes,
// byte.
dest.reserve(src.size() * 4);
bool last_hex_escape = false; // true if last output char was \xNN.
- for (const char* p = src.begin(); p < src.end(); ++p) {
+ const char* p = src.data();
+ const char* end = p + src.size();
+ for (; p < end; ++p) {
unsigned char c = static_cast<unsigned char>(*p);
bool is_hex_escape = false;
switch (c) {
@@ -552,7 +554,9 @@ std::string EscapeString(absl::string_view str) {
std::string EscapeBytes(absl::string_view str, bool escape_all_bytes,
char escape_quote_char) {
std::string escaped_bytes;
- for (const char* p = str.begin(); p < str.end(); ++p) {
+ const char* p = str.data();
+ const char* end = p + str.size();
+ for (; p < end; ++p) {
unsigned char c = *p;
if (escape_all_bytes || !absl::ascii_isprint(c)) {
escaped_bytes += "\\x";
diff --git a/tools/flatbuffers_backed_impl.cc b/tools/flatbuffers_backed_impl.cc
index 10c0b1c..45ba72f 100644
--- a/tools/flatbuffers_backed_impl.cc
+++ b/tools/flatbuffers_backed_impl.cc
@@ -130,6 +130,7 @@ class ObjectStringIndexedMapImpl : public CelMap {
return absl::nullopt;
}
+ using CelMap::ListKeys;
absl::StatusOr<const CelList*> ListKeys() const override { return &keys_; }
private: