Computes the basic declaration of the variable. Used in computing the prototype declaration and the variable declaration.
(
self,
by_reference: bool = False,
*,
in_parser: bool = False
)
| 384 | # |
| 385 | |
| 386 | def simple_declaration( |
| 387 | self, |
| 388 | by_reference: bool = False, |
| 389 | *, |
| 390 | in_parser: bool = False |
| 391 | ) -> str: |
| 392 | """ |
| 393 | Computes the basic declaration of the variable. |
| 394 | Used in computing the prototype declaration and the |
| 395 | variable declaration. |
| 396 | """ |
| 397 | assert isinstance(self.type, str) |
| 398 | prototype = [self.type] |
| 399 | if by_reference or not self.type.endswith('*'): |
| 400 | prototype.append(" ") |
| 401 | if by_reference: |
| 402 | prototype.append('*') |
| 403 | if in_parser: |
| 404 | name = self.parser_name |
| 405 | else: |
| 406 | name = self.name |
| 407 | if self.unused: |
| 408 | name = f"Py_UNUSED({name})" |
| 409 | prototype.append(name) |
| 410 | return "".join(prototype) |
| 411 | |
| 412 | def declaration(self, *, in_parser: bool = False) -> str: |
| 413 | """ |