| 16467 | |
| 16468 | template <typename T> |
| 16469 | inline std::pair<T, int> get_as_upvalues_using_function(lua_State* L, int function_index = -1) { |
| 16470 | static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*); |
| 16471 | typedef std::array<void*, data_t_count> data_t; |
| 16472 | function_index = lua_absindex(L, function_index); |
| 16473 | int index = 0; |
| 16474 | data_t voiddata { {} }; |
| 16475 | for (std::size_t d = 0; d < sizeof(T); d += sizeof(void*)) { |
| 16476 | // first upvalue is nullptr to respect environment shenanigans |
| 16477 | // So +2 instead of +1 |
| 16478 | const char* upvalue_name = lua_getupvalue(L, function_index, index + 2); |
| 16479 | if (upvalue_name == nullptr) { |
| 16480 | // We should freak out here... |
| 16481 | break; |
| 16482 | } |
| 16483 | voiddata[index] = lua_touserdata(L, -1); |
| 16484 | ++index; |
| 16485 | } |
| 16486 | lua_pop(L, index); |
| 16487 | return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index); |
| 16488 | } |
| 16489 | |
| 16490 | template <bool checked, typename Handler, typename Fx, typename... Args> |
| 16491 | static decltype(auto) eval(types<>, std::index_sequence<>, lua_State*, int, Handler&&, record&, Fx&& fx, Args&&... args) { |
nothing calls this directly
no test coverage detected