| 90 | } // namespace |
| 91 | |
| 92 | std::vector<Macro> proto_macros() { |
| 93 | absl::StatusOr<Macro> getExt = Macro::Receiver( |
| 94 | kGetExt, 2, |
| 95 | [](MacroExprFactory& factory, Expr& target, |
| 96 | absl::Span<Expr> arguments) -> absl::optional<Expr> { |
| 97 | if (!IsExtensionCall(target)) { |
| 98 | return absl::nullopt; |
| 99 | } |
| 100 | auto extFieldName = GetExtensionFieldName(arguments[1]); |
| 101 | if (!extFieldName.has_value()) { |
| 102 | return factory.ReportErrorAt(arguments[1], "invalid extension field"); |
| 103 | } |
| 104 | return factory.NewSelect(std::move(arguments[0]), |
| 105 | std::move(*extFieldName)); |
| 106 | }); |
| 107 | absl::StatusOr<Macro> hasExt = Macro::Receiver( |
| 108 | kHasExt, 2, |
| 109 | [](MacroExprFactory& factory, Expr& target, |
| 110 | absl::Span<Expr> arguments) -> absl::optional<Expr> { |
| 111 | if (!IsExtensionCall(target)) { |
| 112 | return absl::nullopt; |
| 113 | } |
| 114 | auto extFieldName = GetExtensionFieldName(arguments[1]); |
| 115 | if (!extFieldName.has_value()) { |
| 116 | return factory.ReportErrorAt(arguments[1], "invalid extension field"); |
| 117 | } |
| 118 | return factory.NewPresenceTest(std::move(arguments[0]), |
| 119 | std::move(*extFieldName)); |
| 120 | }); |
| 121 | return {*hasExt, *getExt}; |
| 122 | } |
| 123 | |
| 124 | CompilerLibrary ProtoExtCompilerLibrary() { |
| 125 | return CompilerLibrary("cel.lib.ext.proto", ConfigureParser); |
no test coverage detected