refactor: update gin_helper/function_template (#41683)

* refactor: update gin_helper/function_template

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: crash in Node.js Worker threads

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2024-03-25 14:39:25 +01:00 committed by GitHub
parent f585a4ef37
commit 83777ac83f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 271 additions and 114 deletions

View file

@ -132,8 +132,9 @@ template <typename ReturnType, typename... ArgTypes>
struct NativeFunctionInvoker<ReturnType(ArgTypes...)> {
static void Go(base::RepeatingCallback<ReturnType(ArgTypes...)> val,
gin::Arguments* args) {
using Indices = typename IndicesGenerator<sizeof...(ArgTypes)>::type;
Invoker<Indices, ArgTypes...> invoker(args, 0);
using Indices = std::index_sequence_for<ArgTypes...>;
Invoker<Indices, ArgTypes...> invoker(args,
{.holder_is_first_argument = false});
if (invoker.IsOK())
invoker.DispatchToCallback(val);
}