Formatting and a few new constants.

This commit is contained in:
ThePhD 2016-02-27 02:49:40 -05:00
parent 95c63565a8
commit c07bbd248c
6 changed files with 26 additions and 26 deletions

View File

@ -32,21 +32,21 @@ class coroutine : public reference {
private: private:
call_status stats = call_status::yielded; call_status stats = call_status::yielded;
void luacall( std::ptrdiff_t argcount, std::ptrdiff_t ) { void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
#if SOL_LUA_VERSION < 503 #if SOL_LUA_VERSION < 502
stats = static_cast<call_status>(lua_resume(lua_state(), static_cast<int>(argcount))); stats = static_cast<call_status>(lua_resume(lua_state(), static_cast<int>(argcount)));
#else #else
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount))); stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
#endif // Lua 5.3 #endif // Lua 5.1 compat
} }
template<std::size_t... I, typename... Ret> template<std::size_t... I, typename... Ret>
auto invoke( types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n ) { auto invoke( types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n ) {
luacall(n, sizeof...(Ret)); luacall(n, sizeof...(Ret));
int stacksize = lua_gettop(lua_state()); int stacksize = lua_gettop(lua_state());
int firstreturn = std::max(1, stacksize - static_cast<int>(sizeof...(Ret)) + 1); int firstreturn = std::max(1, stacksize - static_cast<int>(sizeof...(Ret)) + 1);
auto r = stack::get<std::tuple<Ret...>>(lua_state(), firstreturn); auto r = stack::get<std::tuple<Ret...>>(lua_state(), firstreturn);
lua_pop(lua_state(), static_cast<int>(sizeof...(Ret))); lua_pop(lua_state(), static_cast<int>(sizeof...(Ret)));
return r; return r;
} }
@ -106,7 +106,7 @@ public:
template<typename... Ret, typename... Args> template<typename... Ret, typename... Args>
decltype(auto) call( Args&&... args ) { decltype(auto) call( Args&&... args ) {
push(); push();
int pushcount = stack::push_args( lua_state(), std::forward<Args>( args )... ); int pushcount = stack::push_args( lua_state(), std::forward<Args>( args )... );
return invoke( lua_state(), types<Ret...>( ), std::index_sequence_for<Ret...>(), pushcount ); return invoke( lua_state(), types<Ret...>( ), std::index_sequence_for<Ret...>(), pushcount );
} }

View File

@ -61,8 +61,8 @@ private:
protected: protected:
reference(lua_State* L, detail::global_tag) : L(L) { reference(lua_State* L, detail::global_tag) : L(L) {
lua_pushglobaltable(L); lua_pushglobaltable(L);
ref = luaL_ref(L, LUA_REGISTRYINDEX); ref = luaL_ref(L, LUA_REGISTRYINDEX);
} }
public: public:
@ -124,7 +124,7 @@ public:
} }
explicit operator bool () const { explicit operator bool () const {
return valid(); return valid();
} }
type get_type() const { type get_type() const {

View File

@ -32,7 +32,7 @@ public:
state(lua_CFunction panic = detail::atpanic) : unique_base(luaL_newstate(), lua_close), state(lua_CFunction panic = detail::atpanic) : unique_base(luaL_newstate(), lua_close),
state_view(unique_base::get()) { state_view(unique_base::get()) {
set_panic(panic); set_panic(panic);
sol::stack::luajit_exception_handler(unique_base::get()); sol::stack::luajit_exception_handler(unique_base::get());
} }
using state_view::get; using state_view::get;

View File

@ -41,7 +41,7 @@ class table_core : public reference {
-> decltype(stack::pop<std::tuple<Ret...>>(nullptr)){ -> decltype(stack::pop<std::tuple<Ret...>>(nullptr)){
auto pp = stack::push_pop<is_global<decltype(std::get<I>(keys))...>::value>(*this); auto pp = stack::push_pop<is_global<decltype(std::get<I>(keys))...>::value>(*this);
int tableindex = lua_gettop(lua_state()); int tableindex = lua_gettop(lua_state());
void(detail::swallow{ ( stack::get_field<top_level>(lua_state(), std::get<I>(keys), tableindex), 0)... }); void(detail::swallow{ ( stack::get_field<top_level>(lua_state(), std::get<I>(keys), tableindex), 0)... });
return stack::pop<std::tuple<Ret...>>( lua_state() ); return stack::pop<std::tuple<Ret...>>( lua_state() );
} }
@ -55,7 +55,7 @@ class table_core : public reference {
template<typename Pairs, std::size_t... I> template<typename Pairs, std::size_t... I>
void tuple_set( std::index_sequence<I...>, Pairs&& pairs ) { void tuple_set( std::index_sequence<I...>, Pairs&& pairs ) {
auto pp = stack::push_pop<is_global<decltype(std::get<I * 2>(pairs))...>::value>(*this); auto pp = stack::push_pop<is_global<decltype(std::get<I * 2>(pairs))...>::value>(*this);
void(detail::swallow{ (stack::set_field<top_level>(lua_state(), std::get<I * 2>(pairs), std::get<I * 2 + 1>(pairs)), 0)... }); void(detail::swallow{ (stack::set_field<top_level>(lua_state(), std::get<I * 2>(pairs), std::get<I * 2 + 1>(pairs)), 0)... });
} }
template <bool global, typename T, typename Key> template <bool global, typename T, typename Key>

View File

@ -37,17 +37,17 @@ public:
lua_State* thread_state () const { lua_State* thread_state () const {
auto pp = stack::push_pop(*this); auto pp = stack::push_pop(*this);
lua_State* lthread = lua_tothread(lua_state(), -1); lua_State* lthread = lua_tothread(lua_state(), -1);
return lthread; return lthread;
} }
thread_status status () const { thread_status status () const {
lua_State* lthread = thread_state(); lua_State* lthread = thread_state();
thread_status lstat = static_cast<thread_status>(lua_status(lthread)); thread_status lstat = static_cast<thread_status>(lua_status(lthread));
if (lstat != thread_status::normal && lua_gettop(lthread) == 0) { if (lstat != thread_status::normal && lua_gettop(lthread) == 0) {
// No thing on the thread's stack means its dead // No thing on the thread's stack means its dead
return thread_status::dead; return thread_status::dead;
} }
return lstat; return lstat;
} }
static thread create (lua_State* L) { static thread create (lua_State* L) {

View File

@ -77,13 +77,13 @@ enum class call_status : int {
}; };
enum class thread_status : int { enum class thread_status : int {
normal = LUA_OK, normal = LUA_OK,
yielded = LUA_YIELD, yielded = LUA_YIELD,
error_runtime = LUA_ERRRUN, error_runtime = LUA_ERRRUN,
error_memory = LUA_ERRMEM, error_memory = LUA_ERRMEM,
error_gc = LUA_ERRGCMM, error_gc = LUA_ERRGCMM,
error_handler = LUA_ERRERR, error_handler = LUA_ERRERR,
dead, dead,
}; };
enum class type : int { enum class type : int {