| 386 | } // namespace |
| 387 | |
| 388 | Status Function::Validate() const { |
| 389 | if (!doc_.summary.empty()) { |
| 390 | // Documentation given, check its contents |
| 391 | int arg_count = static_cast<int>(doc_.arg_names.size()); |
| 392 | // Some varargs functions allow 0 vararg, others expect at least 1, |
| 393 | // hence the two possible values below. |
| 394 | bool arg_count_match = (arg_count == arity_.num_args) || |
| 395 | (arity_.is_varargs && arg_count == arity_.num_args + 1); |
| 396 | if (!arg_count_match) { |
| 397 | return Status::Invalid( |
| 398 | "In function '", name_, |
| 399 | "': ", "number of argument names for function documentation != function arity"); |
| 400 | } |
| 401 | Status st = ValidateFunctionSummary(doc_.summary); |
| 402 | if (st.ok()) { |
| 403 | st &= ValidateFunctionDescription(doc_.description); |
| 404 | } |
| 405 | if (!st.ok()) { |
| 406 | return st.WithMessage("In function '", name_, "': ", st.message()); |
| 407 | } |
| 408 | } |
| 409 | return Status::OK(); |
| 410 | } |
| 411 | |
| 412 | Status ScalarFunction::AddKernel(std::vector<InputType> in_types, OutputType out_type, |
| 413 | ArrayKernelExec exec, KernelInit init, |
no test coverage detected