| 738 | } |
| 739 | |
| 740 | uint32_t SetUserType(lua_State* L, int meta_table_index, const char* name) |
| 741 | { |
| 742 | DM_LUA_STACK_CHECK(L, 0); |
| 743 | |
| 744 | uint32_t type_hash = dmHashBuffer32(name, strlen(name)); |
| 745 | |
| 746 | lua_pushvalue(L, meta_table_index); |
| 747 | // [-1] meta table |
| 748 | |
| 749 | lua_pushinteger(L, SCRIPT_METATABLE_TYPE_HASH_KEY); |
| 750 | // [-1] SCRIPT_METATABLE_TYPE_HASH_KEY |
| 751 | // [-2] meta table |
| 752 | |
| 753 | lua_pushinteger(L, (lua_Integer)type_hash); |
| 754 | // [-1] type_hash |
| 755 | // [-2] SCRIPT_METATABLE_TYPE_HASH_KEY |
| 756 | // [-3] meta table |
| 757 | |
| 758 | lua_settable(L, -3); |
| 759 | // [-1] meta table |
| 760 | |
| 761 | lua_pop(L, 1); |
| 762 | |
| 763 | return type_hash; |
| 764 | } |
| 765 | |
| 766 | |
| 767 | uint32_t RegisterUserTypeLocal(lua_State* L, const char* name, const luaL_reg meta[]) |
no test coverage detected