replace lua Random implementation with usertype

This commit is contained in:
MihailRis
2025-09-25 23:53:11 +03:00
parent 3a40162f1e
commit 088bf63f3f
7 changed files with 115 additions and 38 deletions
+9
View File
@@ -275,6 +275,15 @@ namespace lua {
}
return nullptr;
}
template <class T>
inline T& require_userdata(lua::State* L, int idx) {
if (void* rawptr = lua_touserdata(L, idx)) {
return *static_cast<T*>(rawptr);
}
throw std::runtime_error("invalid 'self' value");
}
template <class T, typename... Args>
inline int newuserdata(lua::State* L, Args&&... args) {
const auto& found = usertypeNames.find(typeid(T));