| 120 | } |
| 121 | |
| 122 | absl::Status ConfigureNetworkFunctions(cel::TypeCheckerBuilder& builder) { |
| 123 | // Type identifiers |
| 124 | CEL_RETURN_IF_ERROR(builder.AddVariable( |
| 125 | MakeVariableDecl("net.Address", TypeOfAddressType()))); |
| 126 | CEL_RETURN_IF_ERROR(builder.AddVariable( |
| 127 | MakeVariableDecl("net.AddressMatcher", TypeOfAddressMatcherType()))); |
| 128 | CEL_RETURN_IF_ERROR(builder.AddVariable( |
| 129 | MakeVariableDecl("net.addressZeroValue", AddressType()))); |
| 130 | |
| 131 | // net.parseAddress(string) -> net.Address |
| 132 | CEL_ASSIGN_OR_RETURN( |
| 133 | auto decl, |
| 134 | MakeFunctionDecl("net.parseAddress", |
| 135 | MakeOverloadDecl("net_parseAddress_string", |
| 136 | AddressType(), cel::StringType()))); |
| 137 | |
| 138 | CEL_RETURN_IF_ERROR(builder.AddFunction(decl)); |
| 139 | // net.parseAddressOrZero(string) -> net.Address |
| 140 | CEL_ASSIGN_OR_RETURN( |
| 141 | decl, |
| 142 | MakeFunctionDecl("net.parseAddressOrZero", |
| 143 | MakeOverloadDecl("net_parseAddressOrZero_string", |
| 144 | AddressType(), cel::StringType()))); |
| 145 | CEL_RETURN_IF_ERROR(builder.AddFunction(decl)); |
| 146 | |
| 147 | // net.parseAddressMatcher(string) -> net.AddressMatcher |
| 148 | CEL_ASSIGN_OR_RETURN( |
| 149 | decl, MakeFunctionDecl( |
| 150 | "net.parseAddressMatcher", |
| 151 | MakeOverloadDecl("net_parseAddressMatcher_string", |
| 152 | AddressMatcherType(), cel::StringType()))); |
| 153 | CEL_RETURN_IF_ERROR(builder.AddFunction(decl)); |
| 154 | |
| 155 | // (net.AddressMatcher).containsAddress(net.Address) -> bool |
| 156 | CEL_ASSIGN_OR_RETURN( |
| 157 | decl, MakeFunctionDecl( |
| 158 | "containsAddress", |
| 159 | MakeMemberOverloadDecl( |
| 160 | "net_AddressMatcher_containsAddress_net_Address", |
| 161 | cel::BoolType(), AddressMatcherType(), AddressType()), |
| 162 | MakeMemberOverloadDecl( |
| 163 | "net_AddressMatcher_containsAddress_string", |
| 164 | cel::BoolType(), AddressMatcherType(), cel::StringType()))); |
| 165 | CEL_RETURN_IF_ERROR(builder.AddFunction(decl)); |
| 166 | |
| 167 | return absl::OkStatus(); |
| 168 | } |
| 169 | |
| 170 | // ============================================================================= |
| 171 | // Opaque Value type implementations for NetworkAddressRep. |
nothing calls this directly
no test coverage detected