| 639 | } |
| 640 | |
| 641 | void* 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 | |
| 668 | void* check_unknown(lua_State *L, int index, std::string_view tid) |
| 669 | { |
no test coverage detected