(ptrobj: number, jsargs: any[], kwargs: any)
| 523 | // defined in pyproxy.c in JavaScript functions. |
| 524 | |
| 525 | function callPyObjectKwargs(ptrobj: number, jsargs: any[], kwargs: any) { |
| 526 | // We don't do any checking for kwargs, checks are in PyProxy.callKwargs |
| 527 | // which only is used when the keyword arguments come from the user. |
| 528 | const num_pos_args = jsargs.length; |
| 529 | const kwargs_names = Object.keys(kwargs); |
| 530 | const kwargs_values = Object.values(kwargs); |
| 531 | const num_kwargs = kwargs_names.length; |
| 532 | jsargs.push(...kwargs_values); |
| 533 | |
| 534 | let result; |
| 535 | try { |
| 536 | Py_ENTER(); |
| 537 | result = __pyproxy_apply( |
| 538 | ptrobj, |
| 539 | jsargs, |
| 540 | num_pos_args, |
| 541 | kwargs_names, |
| 542 | num_kwargs, |
| 543 | ); |
| 544 | Py_EXIT(); |
| 545 | } catch (e) { |
| 546 | API.maybe_fatal_error(e); |
| 547 | return; |
| 548 | } |
| 549 | if (result === Module.error) { |
| 550 | _pythonexc2js(); |
| 551 | } |
| 552 | // Automatically schedule coroutines |
| 553 | if (result && result.type === "coroutine" && result._ensure_future) { |
| 554 | Py_ENTER(); |
| 555 | const is_coroutine = __iscoroutinefunction(ptrobj); |
| 556 | Py_EXIT(); |
| 557 | if (is_coroutine) { |
| 558 | result._ensure_future(); |
| 559 | } |
| 560 | } |
| 561 | return result; |
| 562 | } |
| 563 | |
| 564 | /** |
| 565 | * A version of callPyObjectKwargs that supports the JSPI. |
no test coverage detected
searching dependent graphs…