Merge pull request #846 from MihailRis/fixes

fixes
This commit is contained in:
MihailRis 2026-06-03 21:02:41 +03:00 • committed by GitHub
commit 34cc778f0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 44 additions and 32 deletions

View file

@ -80,6 +80,10 @@ int lua::pushwstring(State* L, const std::wstring& str) {
return pushstring(L, util::wstr2str_utf8(str));
}
static std::string to_ptr_string(State* L, int idx) {
return std::to_string(reinterpret_cast<ptrdiff_t>(lua_topointer(L, idx)));
}
dv::value lua::tovalue(State* L, int idx) {
using dv::value_type;
auto type = lua::type(L, idx);
@ -99,11 +103,16 @@ dv::value lua::tovalue(State* L, int idx) {
}
}
case LUA_TFUNCTION:
return "<function " +
std::to_string(
reinterpret_cast<ptrdiff_t>(lua_topointer(L, idx))
) +
">";
return "<function " + to_ptr_string(L, idx) + ">";
case LUA_TTHREAD:
return "<thread " + to_ptr_string(L, idx) + ">";
case LUA_TUSERDATA:
if (auto userdata = touserdata<Userdata>(L, idx)) {
return "<userdata:" + userdata->getTypeName() + " " + to_ptr_string(L, idx) + ">";
}
return "<userdata " + to_ptr_string(L, idx) + ">";
case LUA_TLIGHTUSERDATA:
return "<lightuserdata " + to_ptr_string(L, idx) + ">";
case LUA_TSTRING:
return std::string(tostring(L, idx));
case LUA_TTABLE: {