replace lua Random implementation with usertype
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user