Created
July 15, 2015 13:25
-
-
Save SammyJames/cade7381c6d35a496a5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template< typename T > | |
struct TLuaFunction | |
{ | |
public: | |
using ArgType = typename TFunctionArgs< T >::Type; | |
using ResultType = typename TFunctionResult< T >::Type; | |
static ArgType Unwind( lua_State* L ) | |
{ | |
return Helper( L, std::make_index_sequence< std::tuple_size< ArgType >::value >{} ); | |
} | |
private: | |
template< typename U > | |
static std::tuple< U > Work( int32& Index, lua_State* L ) | |
{ | |
return std::make_tuple( TLuaRead< U >::Read( L, Index++ ) ); | |
} | |
template< typename U1, typename U2, typename... US > | |
static std::tuple< U1, U2, US... > Work( int32& Index, lua_State* L ) | |
{ | |
std::tuple< U1 > Start = Work< U1 >( Index, L ); | |
return std::tuple_cat( Start, Work< U2, US... >( Index, L ) ); | |
} | |
template< size_t... Index > | |
static ArgType Helper( lua_State* L, std::index_sequence< Index... > ) | |
{ | |
int32 IndexHelper = 1; | |
return Work< std::tuple_element_t< Index, ArgType >... >( IndexHelper, L ); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment