Generate a wrapper for native __ipow__. Since __ipow__ fills a ternary slot, but almost no one defines __ipow__ to take three arguments, the wrapper needs to tweaked to force it to accept three arguments.
(cl: ClassIR, fn: FuncIR, emitter: Emitter)
| 302 | |
| 303 | |
| 304 | def generate_ipow_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: |
| 305 | """Generate a wrapper for native __ipow__. |
| 306 | |
| 307 | Since __ipow__ fills a ternary slot, but almost no one defines __ipow__ to take three |
| 308 | arguments, the wrapper needs to tweaked to force it to accept three arguments. |
| 309 | """ |
| 310 | gen = WrapperGenerator(cl, emitter) |
| 311 | gen.set_target(fn) |
| 312 | assert len(fn.args) in (2, 3), "__ipow__ should only take 2 or 3 arguments" |
| 313 | gen.arg_names = ["self", "exp", "mod"] |
| 314 | gen.emit_header() |
| 315 | gen.emit_arg_processing() |
| 316 | handle_third_pow_argument( |
| 317 | fn, |
| 318 | emitter, |
| 319 | gen, |
| 320 | if_unsupported=[ |
| 321 | 'PyErr_SetString(PyExc_TypeError, "__ipow__ takes 2 positional arguments but 3 were given");', |
| 322 | "return NULL;", |
| 323 | ], |
| 324 | ) |
| 325 | gen.emit_call() |
| 326 | gen.finish() |
| 327 | return gen.wrapper_name() |
| 328 | |
| 329 | |
| 330 | def generate_bin_op_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str: |
nothing calls this directly
no test coverage detected
searching dependent graphs…