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

Function GetStringFromHashOrString

engine/script/src/script_hash.cpp:310–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308 }
309
310 const char* GetStringFromHashOrString(lua_State* L, int index, char* buffer, uint32_t bufferlength)
311 {
312 dmhash_t* phash = ToHash(L, index);
313 if (phash != 0)
314 {
315 DM_HASH_REVERSE_MEM(hash_ctx, 128);
316 const char* reverse = (const char*) dmHashReverseSafe64Alloc(&hash_ctx, *phash);
317 dmStrlCpy(buffer, reverse, bufferlength);
318 }
319 else if (lua_type(L, index) == LUA_TSTRING)
320 {
321 size_t len = 0;
322 const char* s = lua_tolstring(L, index, &len);
323 dmStrlCpy(buffer, s, bufferlength);
324 }
325 else
326 {
327 dmStrlCpy(buffer, "<unknown type>", bufferlength);
328 }
329 return buffer;
330 }
331
332 static int Hash_eq(lua_State* L)
333 {

Callers 5

TEST_FFunction · 0.85
LuaAnimateFunction · 0.85
LuaDeleteTextureFunction · 0.85
LuaNewParticlefxNodeFunction · 0.85
LuaSetParticlefxFunction · 0.85

Calls 5

ToHashFunction · 0.85
dmHashReverseSafe64AllocFunction · 0.85
dmStrlCpyFunction · 0.85
lua_typeFunction · 0.85
lua_tolstringFunction · 0.85

Tested by 1

TEST_FFunction · 0.68