MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / register_object_in_pool

Method register_object_in_pool

src/Chain/libraries/glua/thinkyoung_lua_api.cpp:374–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372 }
373
374 intptr_t GluaChainApi::register_object_in_pool(lua_State *L, intptr_t object_addr, GluaOutsideObjectTypes type)
375 {
376 auto node = thinkyoung::lua::lib::get_lua_state_value_node(L, GLUA_OUTSIDE_OBJECT_POOLS_KEY);
377 // Map<type, Map<object_key, object_addr>>
378 std::map<GluaOutsideObjectTypes, std::shared_ptr<std::map<intptr_t, intptr_t>>> *object_pools = nullptr;
379 if (node.type == GluaStateValueType::LUA_STATE_VALUE_nullptr)
380 {
381 node.type = GluaStateValueType::LUA_STATE_VALUE_POINTER;
382 object_pools = new std::map<GluaOutsideObjectTypes, std::shared_ptr<std::map<intptr_t, intptr_t>>>();
383 node.value.pointer_value = (void*)object_pools;
384 thinkyoung::lua::lib::set_lua_state_value(L, GLUA_OUTSIDE_OBJECT_POOLS_KEY, node.value, node.type);
385 }
386 else
387 {
388 object_pools = (std::map<GluaOutsideObjectTypes, std::shared_ptr<std::map<intptr_t, intptr_t>>> *) node.value.pointer_value;
389 }
390 if (object_pools->find(type) == object_pools->end())
391 {
392 object_pools->emplace(std::make_pair(type, std::make_shared<std::map<intptr_t, intptr_t>>()));
393 }
394 auto pool = (*object_pools)[type];
395 auto object_key = object_addr;
396 (*pool)[object_key] = object_addr;
397 return object_key;
398 }
399
400 intptr_t GluaChainApi::is_object_in_pool(lua_State *L, intptr_t object_key, GluaOutsideObjectTypes type)
401 {

Callers 1

glua_core_lib_StreamFunction · 0.45

Calls 6

get_lua_state_value_nodeFunction · 0.85
set_lua_state_valueFunction · 0.85
make_pairClass · 0.50
findMethod · 0.45
endMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected