| 428 | } |
| 429 | |
| 430 | Lua::ObjectClass Lua::IsDFObject(lua_State *state, int val_index) |
| 431 | { |
| 432 | if (lua_isnil(state, val_index)) |
| 433 | return Lua::OBJ_NULL; |
| 434 | if (lua_islightuserdata(state, val_index)) |
| 435 | return lua_touserdata(state, val_index) ? Lua::OBJ_VOIDPTR : OBJ_NULL; |
| 436 | |
| 437 | Lua::ObjectClass cls; |
| 438 | |
| 439 | if (lua_istable(state, val_index)) |
| 440 | { |
| 441 | cls = Lua::OBJ_TYPE; |
| 442 | lua_pushvalue(state, val_index); |
| 443 | LookupInTable(state, &DFHACK_TYPEID_TABLE_TOKEN); |
| 444 | } |
| 445 | else if (lua_isuserdata(state, val_index)) |
| 446 | { |
| 447 | if (!lua_getmetatable(state, val_index)) |
| 448 | return Lua::OBJ_INVALID; |
| 449 | cls = Lua::OBJ_REF; |
| 450 | LookupInTable(state, &DFHACK_TYPETABLE_TOKEN); |
| 451 | } |
| 452 | else |
| 453 | return Lua::OBJ_INVALID; |
| 454 | |
| 455 | bool ok = !lua_isnil(state, -1); |
| 456 | lua_pop(state, 1); |
| 457 | |
| 458 | return ok ? cls : Lua::OBJ_INVALID; |
| 459 | } |
| 460 | |
| 461 | static const char *const primitive_types[] = { |
| 462 | "string", |
nothing calls this directly
no test coverage detected