2021-09-09 21:21:51 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace ui_scripting
|
|
|
|
{
|
2022-04-28 16:41:29 -04:00
|
|
|
template <class... Args, std::size_t... I>
|
|
|
|
auto wrap_function(const std::function<void(Args...)>& f, std::index_sequence<I...>)
|
|
|
|
{
|
|
|
|
return [f](const function_arguments& args)
|
|
|
|
{
|
|
|
|
f(args[I]...);
|
|
|
|
return arguments{{}};
|
|
|
|
};
|
|
|
|
}
|
2021-10-02 12:30:21 -04:00
|
|
|
|
2022-04-28 16:41:29 -04:00
|
|
|
template <class... Args, std::size_t... I>
|
|
|
|
auto wrap_function(const std::function<arguments(Args...)>& f, std::index_sequence<I...>)
|
|
|
|
{
|
|
|
|
return [f](const function_arguments& args)
|
|
|
|
{
|
|
|
|
return f(args[I]...);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename R, class... Args, std::size_t... I>
|
|
|
|
auto wrap_function(const std::function<R(Args...)>& f, std::index_sequence<I...>)
|
|
|
|
{
|
|
|
|
return [f](const function_arguments& args)
|
|
|
|
{
|
|
|
|
return arguments{f(args[I]...)};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename R, class... Args>
|
|
|
|
auto wrap_function(const std::function<R(Args...)>& f)
|
|
|
|
{
|
|
|
|
return wrap_function(f, std::index_sequence_for<Args...>{});
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class F>
|
|
|
|
auto wrap_function(F f)
|
|
|
|
{
|
2022-04-29 16:48:13 -04:00
|
|
|
return wrap_function(std::function(f));
|
2022-04-28 16:41:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename F>
|
|
|
|
game::hks::cclosure* convert_function(F f);
|
2021-09-09 21:21:51 -04:00
|
|
|
}
|