MCPcopy Create free account
hub / github.com/defold/defold / SetUserType

Function SetUserType

engine/script/src/script.cpp:740–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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[])

Callers 3

RegisterUserTypeLocalFunction · 0.85
RegisterUserTypeFunction · 0.85
InitializeHashFunction · 0.85

Calls 4

lua_pushvalueFunction · 0.85
lua_pushintegerFunction · 0.85
lua_settableFunction · 0.85
dmHashBuffer32Function · 0.50

Tested by

no test coverage detected