Generates the core part of a wrapper function for a native function. This expects each argument as a PyObject * named obj_{arg} as a precondition. It converts the PyObject *s to the necessary types, checking and unboxing if necessary, makes the call, then boxes the result if necessary a
(
fn: FuncIR,
emitter: Emitter,
optional_args: list[RuntimeArg] | None = None,
arg_names: list[str] | None = None,
cleanups: list[str] | None = None,
traceback_code: str | None = None,
)
| 742 | |
| 743 | |
| 744 | def generate_wrapper_core( |
| 745 | fn: FuncIR, |
| 746 | emitter: Emitter, |
| 747 | optional_args: list[RuntimeArg] | None = None, |
| 748 | arg_names: list[str] | None = None, |
| 749 | cleanups: list[str] | None = None, |
| 750 | traceback_code: str | None = None, |
| 751 | ) -> None: |
| 752 | """Generates the core part of a wrapper function for a native function. |
| 753 | |
| 754 | This expects each argument as a PyObject * named obj_{arg} as a precondition. |
| 755 | It converts the PyObject *s to the necessary types, checking and unboxing if necessary, |
| 756 | makes the call, then boxes the result if necessary and returns it. |
| 757 | """ |
| 758 | gen = WrapperGenerator(None, emitter) |
| 759 | gen.set_target(fn) |
| 760 | if arg_names: |
| 761 | gen.arg_names = arg_names |
| 762 | gen.cleanups = cleanups or [] |
| 763 | gen.optional_args = optional_args or [] |
| 764 | gen.traceback_code = traceback_code or "" |
| 765 | |
| 766 | error = ReturnHandler("NULL") if not gen.use_goto() else GotoHandler("fail") |
| 767 | gen.emit_arg_processing(error=error) |
| 768 | gen.emit_call() |
| 769 | gen.emit_error_handling() |
| 770 | |
| 771 | |
| 772 | def generate_arg_check( |
no test coverage detected
searching dependent graphs…