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

Function GetUserType

engine/script/src/script.cpp:803–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

801 }
802
803 uint32_t GetUserType(lua_State* L, int user_data_index)
804 {
805 DM_LUA_STACK_CHECK(L, 0);
806 lua_pushvalue(L, user_data_index);
807 // [-1] user data
808 lua_Integer type_hash = 0;
809 if (lua_type(L, -1) == LUA_TUSERDATA)
810 {
811 if (lua_getmetatable(L, -1))
812 {
813 // [-1] meta table
814 // [-2] user data
815
816 lua_pushinteger(L, SCRIPT_METATABLE_TYPE_HASH_KEY);
817 // [-1] SCRIPT_METATABLE_TYPE_HASH_KEY
818 // [-2] meta table
819 // [-3] user data
820
821 lua_rawget(L, -2);
822 // [-1] type hash
823 // [-2] meta table
824 // [-3] user data
825
826 type_hash = lua_tointeger(L, -1);
827 lua_pop(L, 2);
828 // [-1] user data
829 }
830 }
831 lua_pop(L, 1);
832 return (uint32_t)type_hash;
833 }
834
835 void* ToUserType(lua_State* L, int user_data_index, uint32_t type_hash)
836 {

Callers 10

IsURLFunction · 0.85
ToUserTypeFunction · 0.85
IsVectorFunction · 0.85
IsVector3Function · 0.85
IsVector4Function · 0.85
IsQuatFunction · 0.85
IsMatrix4Function · 0.85
TEST_FFunction · 0.85
IsStreamFunction · 0.85
IsBufferFunction · 0.85

Calls 6

lua_pushvalueFunction · 0.85
lua_typeFunction · 0.85
lua_getmetatableFunction · 0.85
lua_pushintegerFunction · 0.85
lua_rawgetFunction · 0.85
lua_tointegerFunction · 0.85

Tested by 1

TEST_FFunction · 0.68