хочу кекать!
-
Автор темы
- #1
C++:
namespace function_detail {
template <typename Function, bool is_yielding>
struct upvalue_free_function {
typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
typedef meta::bind_traits<function_type> traits_type;
static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) {
auto udata = stack::stack_detail::get_as_upvalues<function_type*>(L);
function_type* fx = udata.first;
return call_detail::call_wrapped<void, true, false>(L, fx);
}
static int call(lua_State* L) {
int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
if (is_yielding) {
return lua_yield(L, nr);
}
else {
return nr;
}
}
int operator()(lua_State* L) {
return call(L);
}
};