MCPcopy Create free account
hub / github.com/Snapchat/Valdi / tsn_call

Function tsn_call

tsn/src/tsn/tsn.cpp:1647–1671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1645}
1646
1647tsn_value tsn_call(tsn_vm* ctx, tsn_value_const func_obj, tsn_value_const this_obj, int argc, tsn_value_const* argv) {
1648 tsn_value retval;
1649
1650 auto* closure = tsn_get_closure_from_func(func_obj);
1651 if (closure != nullptr) {
1652 // Fast path for calls to TSN functions
1653 retval = call_closure_callable(ctx, func_obj, this_obj, argc, argv, closure);
1654 } else {
1655 // We must retain-release the arguments ourselves as QuickJS
1656 // might mutate the argv array in place, potentially setting up
1657 // different variables. It expects us to release the array after
1658 // a JS call is made.
1659 for (int i = 0; i < argc; i++) {
1660 tsn_retain(ctx, argv[i]);
1661 }
1662
1663 retval = JS_CallInternal_tsn(ctx, func_obj, this_obj, JS_UNDEFINED, argc, argv, 0);
1664
1665 for (int i = 0; i < argc; i++) {
1666 tsn_release(ctx, argv[i]);
1667 }
1668 }
1669
1670 return retval;
1671}
1672
1673tsn_value tsn_call_vargs(tsn_vm* ctx, tsn_value_const func_obj, tsn_value_const this_obj, tsn_value_const args) {
1674 uint32_t len;

Callers 4

evaluateCompiledTestMethod · 0.85
tsn_handle_timersFunction · 0.85
tsn_call_vargsFunction · 0.85
tsn_call_fargsFunction · 0.85

Calls 3

call_closure_callableFunction · 0.85
tsn_retainFunction · 0.85
tsn_releaseFunction · 0.85

Tested by

no test coverage detected