Future modifications should consider refactoring to reduce complexity. * The McCabe cyclomatiic complexity is currently 67 vs 10 recommended. * There are currently 79 branches vs 12 recommended. * There are currently 195 statements vs 50 recommended. To revalidate these numbers, run `ruff
(class_name, func_name, sigs, return_type, non_pointer, # noqa: C901, PLR0912, PLR0915
copy, operator, constructor, is_static, func_scope,
call_content=None, const=False, array_attribute=False,
bind_to=None)
| 396 | |
| 397 | |
| 398 | def render_function(class_name, func_name, sigs, return_type, non_pointer, # noqa: C901, PLR0912, PLR0915 |
| 399 | copy, operator, constructor, is_static, func_scope, |
| 400 | call_content=None, const=False, array_attribute=False, |
| 401 | bind_to=None): |
| 402 | """Future modifications should consider refactoring to reduce complexity. |
| 403 | |
| 404 | * The McCabe cyclomatiic complexity is currently 67 vs 10 recommended. |
| 405 | * There are currently 79 branches vs 12 recommended. |
| 406 | * There are currently 195 statements vs 50 recommended. |
| 407 | |
| 408 | To revalidate these numbers, run `ruff check --select=C901,PLR091`. |
| 409 | """ |
| 410 | legacy_mode = CHECKS not in {'ALL', 'FAST'} |
| 411 | all_checks = CHECKS == 'ALL' |
| 412 | |
| 413 | bindings_name = class_name + '_' + func_name |
| 414 | min_args = min(sigs.keys()) |
| 415 | max_args = max(sigs.keys()) |
| 416 | |
| 417 | all_args = sigs.get(max_args) |
| 418 | |
| 419 | if DEBUG: |
| 420 | dbg('renderfunc', class_name, func_name, list(sigs.keys()), return_type, constructor) |
| 421 | for i, a in enumerate(all_args): |
| 422 | if isinstance(a, WebIDL.IDLArgument): |
| 423 | dbg(' ', a.identifier.name, a.identifier, a.type, a.optional) |
| 424 | else: |
| 425 | dbg(' arg%d (%s)' % (i, a)) |
| 426 | |
| 427 | # JS |
| 428 | |
| 429 | cache = ('getCache(%s)[this.ptr] = this;' % class_name) if constructor else '' |
| 430 | call_prefix = '' |
| 431 | if constructor: |
| 432 | call_prefix += 'this.ptr = ' |
| 433 | call_postfix = '' |
| 434 | if return_type != 'Void' and not constructor: |
| 435 | call_prefix = 'return ' |
| 436 | |
| 437 | ptr_rtn = constructor or return_type in interfaces or return_type == 'String' |
| 438 | if options.wasm64 and ptr_rtn: |
| 439 | call_postfix += ')' |
| 440 | |
| 441 | if not constructor: |
| 442 | if return_type in interfaces: |
| 443 | call_prefix += 'wrapPointer(' |
| 444 | call_postfix += ', ' + return_type + ')' |
| 445 | elif return_type == 'String': |
| 446 | call_prefix += 'UTF8ToString(' |
| 447 | call_postfix += ')' |
| 448 | elif return_type == 'Boolean': |
| 449 | call_prefix += '!!(' |
| 450 | call_postfix += ')' |
| 451 | |
| 452 | if options.wasm64 and ptr_rtn: |
| 453 | call_prefix += 'Number(' |
| 454 | |
| 455 | args = [(all_args[i].identifier.name if isinstance(all_args[i], WebIDL.IDLArgument) else ('arg%d' % i)) for i in range(max_args)] |
no test coverage detected