| 112 | |
| 113 | template <typename T> |
| 114 | inline std::pair<T, int> get_as_upvalues(lua_State* L, int index = 2) { |
| 115 | static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*); |
| 116 | typedef std::array<void*, data_t_count> data_t; |
| 117 | data_t voiddata { {} }; |
| 118 | for (std::size_t i = 0, d = 0; d < sizeof(T); ++i, d += sizeof(void*)) { |
| 119 | voiddata[i] = lua_touserdata(L, upvalue_index(index++)); |
| 120 | } |
| 121 | return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index); |
| 122 | } |
| 123 | |
| 124 | template <typename T> |
| 125 | inline std::pair<T, int> get_as_upvalues_using_function(lua_State* L, int function_index = -1) { |
nothing calls this directly
no test coverage detected