| 420 | } |
| 421 | |
| 422 | bool GjsCallbackTrampoline::callback_closure_inner( |
| 423 | JSContext* cx, JS::HandleObject this_object, GObject* gobject, |
| 424 | JS::MutableHandleValue rval, GIArgument** args, |
| 425 | const GI::TypeInfo& ret_type, unsigned n_args, unsigned c_args_offset, |
| 426 | void* result) { |
| 427 | unsigned n_outargs = 0; |
| 428 | JS::RootedValueVector jsargs{cx}; |
| 429 | |
| 430 | if (!jsargs.reserve(n_args)) |
| 431 | g_error("Unable to reserve space for vector"); |
| 432 | |
| 433 | GITypeTag ret_tag = ret_type.tag(); |
| 434 | bool ret_type_is_void = ret_tag == GI_TYPE_TAG_VOID; |
| 435 | bool in_args_to_cleanup = false; |
| 436 | |
| 437 | for (unsigned i = 0, n_jsargs = 0; i < n_args; i++) { |
| 438 | GI::StackArgInfo arg_info; |
| 439 | GI::StackTypeInfo type_info; |
| 440 | |
| 441 | m_info.load_arg(i, &arg_info); |
| 442 | arg_info.load_type(&type_info); |
| 443 | |
| 444 | // Skip void* arguments |
| 445 | if (type_info.tag() == GI_TYPE_TAG_VOID) |
| 446 | continue; |
| 447 | |
| 448 | if (arg_info.direction() == GI_DIRECTION_OUT) { |
| 449 | n_outargs++; |
| 450 | continue; |
| 451 | } |
| 452 | |
| 453 | if (arg_info.direction() == GI_DIRECTION_INOUT) |
| 454 | n_outargs++; |
| 455 | |
| 456 | if (arg_info.ownership_transfer() != GI_TRANSFER_NOTHING) |
| 457 | in_args_to_cleanup = m_scope != GI_SCOPE_TYPE_FOREVER; |
| 458 | |
| 459 | GjsParamType param_type = m_param_types[i]; |
| 460 | |
| 461 | switch (param_type) { |
| 462 | case PARAM_SKIPPED: |
| 463 | continue; |
| 464 | case PARAM_ARRAY: { |
| 465 | // In initialize(), we already don't store PARAM_ARRAY for non- |
| 466 | // fixed-size arrays |
| 467 | unsigned array_length_pos = |
| 468 | type_info.array_length_index().value(); |
| 469 | |
| 470 | GI::StackArgInfo array_length_arg; |
| 471 | GI::StackTypeInfo arg_type_info; |
| 472 | |
| 473 | m_info.load_arg(array_length_pos, &array_length_arg); |
| 474 | array_length_arg.load_type(&arg_type_info); |
| 475 | size_t length = gjs_gi_argument_get_array_length( |
| 476 | arg_type_info.tag(), |
| 477 | args[array_length_pos + c_args_offset]); |
| 478 | |
| 479 | if (!jsargs.growBy(1)) |
nothing calls this directly
no test coverage detected