(self)
| 419 | self.parser_body(*parser_code) |
| 420 | |
| 421 | def parse_one_arg(self) -> None: |
| 422 | self.flags = "METH_O" |
| 423 | |
| 424 | if (isinstance(self.converters[0], object_converter) and |
| 425 | self.converters[0].format_unit == 'O'): |
| 426 | meth_o_prototype = METH_O_PROTOTYPE |
| 427 | |
| 428 | if self.use_simple_return() and self.use_pyobject_self(): |
| 429 | # maps perfectly to METH_O, doesn't need a return converter. |
| 430 | # so we skip making a parse function |
| 431 | # and call directly into the impl function. |
| 432 | self.impl_prototype = '' |
| 433 | self.impl_definition = meth_o_prototype |
| 434 | else: |
| 435 | # SLIGHT HACK |
| 436 | # use impl_parameters for the parser here! |
| 437 | self.parser_prototype = meth_o_prototype |
| 438 | self.parser_body() |
| 439 | |
| 440 | else: |
| 441 | argname = 'arg' |
| 442 | if self.parameters[0].name == argname: |
| 443 | argname += '_' |
| 444 | self.parser_prototype = libclinic.normalize_snippet(""" |
| 445 | static PyObject * |
| 446 | {c_basename}({self_type}{self_name}, PyObject *%s) |
| 447 | """ % argname) |
| 448 | |
| 449 | displayname = self.parameters[0].get_displayname(0) |
| 450 | parsearg: str | None |
| 451 | parsearg = self.converters[0].parse_arg(argname, displayname, |
| 452 | limited_capi=self.limited_capi) |
| 453 | if parsearg is None: |
| 454 | self.converters[0].use_converter() |
| 455 | parsearg = """ |
| 456 | if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{ |
| 457 | goto exit; |
| 458 | }} |
| 459 | """ % argname |
| 460 | |
| 461 | parser_code = libclinic.normalize_snippet(parsearg, indent=4) |
| 462 | self.parser_body(parser_code) |
| 463 | |
| 464 | def parse_option_groups(self) -> None: |
| 465 | # positional parameters with option groups |
no test coverage detected