fix luajit::MatchMetaName()

This commit is contained in:
falsycat 2022-07-10 13:02:57 +09:00
parent 4625cad8cc
commit f39de1a8d5
3 changed files with 7 additions and 3 deletions

View File

@ -44,7 +44,8 @@ void PushGlobalTable(lua_State* L) noexcept {
PushMutableVector(L, std::vector<uint8_t> {*mut});
return 1;
}
return luaL_error(L, "expected nf7::Value::MutableVector or nf7::Value::Vector");
PushMutableVector(L, {});
return 1;
});
lua_setfield(L, -2, "nf7_MutableVector");
}
@ -165,6 +166,7 @@ void PushMutableVector(lua_State* L, std::vector<uint8_t>&& v) noexcept {
});
lua_setfield(L, -2, "__gc");
}
lua_setmetatable(L, -2);
}
std::optional<nf7::Value> ToValue(lua_State* L, int idx) noexcept {

View File

@ -36,7 +36,9 @@ inline void PushWeakPtrDeleter(lua_State* L, const std::weak_ptr<T>& = {}) noexc
}
inline bool MatchMetaName(lua_State* L, int idx, const char* type) noexcept {
lua_getmetatable(L, idx);
if (0 == lua_getmetatable(L, idx)) {
return false;
}
luaL_getmetatable(L, type);
const bool ret = lua_rawequal(L, -1, -2);
lua_pop(L, 2);

View File

@ -167,7 +167,7 @@ target_sources(linalg.h
FetchContent_Declare(
luajit
URL "https://github.com/LuaJIT/LuaJIT/archive/1d7b5029c5ba36870d25c67524034d452b761d27.zip"
URL "https://github.com/LuaJIT/LuaJIT/archive/e3bae12fc0461cfa7e4bef3dfed2dad372e5da8d.zip"
)
FetchContent_Populate(luajit)