Parcourir la Source

Allow State* to be read from stack

Ole il y a 9 ans
Parent
commit
42f034eefd
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9 0
      lib/luwra/types.hpp

+ 9 - 0
lib/luwra/types.hpp

@@ -51,6 +51,15 @@ struct Value<std::nullptr_t> {
 	}
 };
 
+template <>
+struct Value<State*> {
+	static inline
+	State* read(State* state, int n) {
+		luaL_checktype(state, n, LUA_TTHREAD);
+		return lua_tothread(state, n);
+	}
+};
+
 /**
  * Convenient wrapped for [Value<T>::push](@ref Value<T>::push).
  */