| 395 | }; |
| 396 | |
| 397 | static int Hash_gc(lua_State* L) |
| 398 | { |
| 399 | dmhash_t hash = *(dmhash_t*)lua_touserdata(L, 1); |
| 400 | HContext context = dmScript::GetScriptContext(L); |
| 401 | if (context) |
| 402 | { |
| 403 | int* refp = context->m_HashInstances.Get(hash); |
| 404 | if (refp && context->m_ContextWeakTableRef != LUA_NOREF) |
| 405 | { |
| 406 | lua_rawgeti(L, LUA_REGISTRYINDEX, context->m_ContextWeakTableRef); |
| 407 | // [-1] weak_table |
| 408 | PushHashWeakTableKey(L, hash); |
| 409 | // [-2] weak_table |
| 410 | // [-1] key |
| 411 | lua_rawget(L, -2); |
| 412 | // [-2] weak_table |
| 413 | // [-1] value or nil |
| 414 | if (lua_isnil(L, -1)) |
| 415 | { |
| 416 | context->m_HashInstances.Erase(hash); |
| 417 | dmHashReverseErase64(hash); |
| 418 | } |
| 419 | lua_pop(L, 2); |
| 420 | } |
| 421 | } |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | void InitializeHash(lua_State* L) |
| 426 | { |
nothing calls this directly
no test coverage detected