Skip to content

Commit 515cf48

Browse files
seirlcopybara-github
authored andcommitted
Implement the 'lists' extension for the C++ runtime.
This implements the following functions of the lists extension: - lists.range() - .distinct() - .flatten() - .reverse() - .sort() - .@sortByAssociatedKeys() [only used to implement sortBy()] as well as the .sortBy() macro. These functions are all documented in the Go reference implementation: https://github.com/google/cel-go/blob/master/ext/README.md#lists PiperOrigin-RevId: 713373486
1 parent d393dd0 commit 515cf48

File tree

4 files changed

+892
-0
lines changed

4 files changed

+892
-0
lines changed

extensions/BUILD

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,63 @@ cc_library(
314314
],
315315
)
316316

317+
cc_library(
318+
name = "lists_functions",
319+
srcs = ["lists_functions.cc"],
320+
hdrs = ["lists_functions.h"],
321+
deps = [
322+
"//common:expr",
323+
"//common:operators",
324+
"//common:type",
325+
"//common:value",
326+
"//common:value_kind",
327+
"//internal:status_macros",
328+
"//parser:macro",
329+
"//parser:macro_expr_factory",
330+
"//parser:macro_registry",
331+
"//parser:options",
332+
"//runtime:function_adapter",
333+
"//runtime:function_registry",
334+
"//runtime:runtime_options",
335+
"@com_google_absl//absl/base:core_headers",
336+
"@com_google_absl//absl/container:flat_hash_set",
337+
"@com_google_absl//absl/status",
338+
"@com_google_absl//absl/status:statusor",
339+
"@com_google_absl//absl/strings:str_format",
340+
"@com_google_absl//absl/strings:string_view",
341+
"@com_google_absl//absl/types:optional",
342+
"@com_google_absl//absl/types:span",
343+
],
344+
)
345+
346+
cc_test(
347+
name = "lists_functions_test",
348+
srcs = ["lists_functions_test.cc"],
349+
deps = [
350+
":lists_functions",
351+
"//common:source",
352+
"//common:value",
353+
"//common:value_testing",
354+
"//extensions/protobuf:runtime_adapter",
355+
"//internal:testing",
356+
"//internal:testing_descriptor_pool",
357+
"//parser",
358+
"//parser:macro_registry",
359+
"//parser:options",
360+
"//parser:standard_macros",
361+
"//runtime",
362+
"//runtime:activation",
363+
"//runtime:reference_resolver",
364+
"//runtime:runtime_builder",
365+
"//runtime:runtime_options",
366+
"//runtime:standard_runtime_builder_factory",
367+
"@com_google_absl//absl/status",
368+
"@com_google_absl//absl/status:status_matchers",
369+
"@com_google_cel_spec//proto/cel/expr:syntax_cc_proto",
370+
"@com_google_protobuf//:protobuf",
371+
],
372+
)
373+
317374
cc_library(
318375
name = "sets_functions",
319376
srcs = ["sets_functions.cc"],

0 commit comments

Comments
 (0)