| 116 | using MessageWrapper = CelValue::MessageWrapper; |
| 117 | |
| 118 | absl::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 | |
| 142 | absl::StatusOr<std::unique_ptr<cel::Compiler>> NewTestCompiler() { |
| 143 | CompilerOptions options; |
no test coverage detected