MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / skr_check_unknown

Function skr_check_unknown

modules/engine/lua/src/build.skr_lua.cpp:641–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641void* skr_check_unknown(lua_State *L, int index, std::string_view tid, std::string_view unknown)
642{
643 void *p = lua_touserdata(L, index);
644 if (p != NULL) { /* value is a userdata? */
645 if (lua_getmetatable(L, index)) { /* does it have a metatable? */
646 luaL_getmetatable(L, tid.data()); /* get correct metatable */
647 if (!lua_rawequal(L, -1, -2)) /* not the same? */
648 {
649 if(!unknown.empty()) /* check again */
650 {
651 luaL_getmetatable(L, unknown.data());
652 if (!lua_rawequal(L, -1, -3)) /* not the same? */
653 p = NULL; /* value is a userdata with wrong metatable */
654 lua_pop(L, 1);
655 }
656 else if(!lua_isnil(L, -1))
657 {
658 p = NULL;
659 }
660 }
661 lua_pop(L, 2); /* remove both metatables */
662 }
663 }
664 luaL_argexpected(L, p != 0, index, tid.data());
665 return p;
666}
667
668void* check_unknown(lua_State *L, int index, std::string_view tid)
669{

Callers 3

check_unknownFunction · 0.85
check_sptrFunction · 0.85
check_sobjectptrFunction · 0.85

Calls 5

lua_touserdataFunction · 0.50
lua_getmetatableFunction · 0.50
lua_rawequalFunction · 0.50
dataMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected