MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ApplyDecl

Function ApplyDecl

extensions/select_optimization_test.cc:118–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116using MessageWrapper = CelValue::MessageWrapper;
117
118absl::Status ApplyDecl(absl::string_view decl, TypeCheckerBuilder& builder) {
119 cel::expr::Decl decl_proto;
120
121 if (!google::protobuf::TextFormat::ParseFromString(decl, &decl_proto)) {
122 return absl::InvalidArgumentError("failed to parse decl");
123 }
124 if (decl_proto.has_ident()) {
125 CEL_ASSIGN_OR_RETURN(
126 cel::VariableDecl d,
127 cel::VariableDeclFromProto(decl_proto.name(), decl_proto.ident(),
128 builder.descriptor_pool(), builder.arena()));
129 CEL_RETURN_IF_ERROR(builder.AddVariable(std::move(d)));
130 } else if (decl_proto.has_function()) {
131 CEL_ASSIGN_OR_RETURN(
132 cel::FunctionDecl d,
133 cel::FunctionDeclFromProto(decl_proto.name(), decl_proto.function(),
134 builder.descriptor_pool(), builder.arena()));
135 CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(d)));
136 } else {
137 return absl::InvalidArgumentError("decl has no ident or function");
138 }
139 return absl::OkStatus();
140}
141
142absl::StatusOr<std::unique_ptr<cel::Compiler>> NewTestCompiler() {
143 CompilerOptions options;

Callers 1

NewTestCompilerFunction · 0.85

Calls 3

AddVariableMethod · 0.80
has_functionMethod · 0.80
AddFunctionMethod · 0.45

Tested by

no test coverage detected