Skip to content

Commit 757788a

Browse files
committed
the destructor lock is private yeah right oops
1 parent ecec236 commit 757788a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

codegen/src/SourceGen.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ std::unordered_map<void*, bool>& cocos2d::CCDestructor::destructorLock() {{
1616
static thread_local std::unordered_map<void*, bool> s_lock;
1717
return s_lock;
1818
}}
19+
20+
bool& cocos2d::CCDestructor::lock(void* self) {{
21+
return destructorLock()[self];
22+
}}
1923
#endif
2024
2125
auto wrapFunction(uintptr_t address, tulip::hook::WrapperMetadata const& metadata) {
@@ -69,7 +73,7 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na
6973
#ifdef GEODE_USE_NEW_DESTRUCTOR_LOCK
7074
if (!geode::DestructorLock::isLocked(this)) {{
7175
#else
72-
if (!cocos2d::CCDestructor::destructorLock().count(this)) {{
76+
if (!cocos2d::CCDestructor::lock(this)) {{
7377
#endif
7478
using FunctionType = void(*)({class_name}*{parameter_comma}{parameter_types});
7579
static auto func = wrapFunction({address_inline}, tulip::hook::WrapperMetadata{{
@@ -84,7 +88,7 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na
8488
#ifdef GEODE_USE_NEW_DESTRUCTOR_LOCK
8589
geode::DestructorLock::addLock(this);
8690
#else
87-
cocos2d::CCDestructor::destructorLock().insert({{(void*)this, true}});
91+
cocos2d::CCDestructor::lock(this) = true;
8892
#endif
8993
}}
9094
}}
@@ -99,7 +103,7 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na
99103
#ifdef GEODE_USE_NEW_DESTRUCTOR_LOCK
100104
if (!geode::DestructorLock::isLocked(this)) {{
101105
#else
102-
if (!cocos2d::CCDestructor::destructorLock().count(this)) {{
106+
if (!cocos2d::CCDestructor::lock(this)) {{
103107
#endif
104108
using FunctionType = void(*)({class_name}*{parameter_comma}{parameter_types});
105109
static auto func = wrapFunction({address_inline}, tulip::hook::WrapperMetadata{{
@@ -112,7 +116,7 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na
112116
#ifdef GEODE_USE_NEW_DESTRUCTOR_LOCK
113117
geode::DestructorLock::removeLock(this);
114118
#else
115-
cocos2d::CCDestructor::destructorLock().erase(this);
119+
cocos2d::CCDestructor::lock(this) = false;
116120
#endif
117121
}}
118122
}}
@@ -128,7 +132,7 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na
128132
#ifdef GEODE_USE_NEW_DESTRUCTOR_LOCK
129133
geode::DestructorLock::addLock(this);
130134
#else
131-
cocos2d::CCDestructor::destructorLock().insert({{(void*)this, true}});
135+
cocos2d::CCDestructor::lock(this) = true;
132136
#endif
133137
{class_name}::~{unqualified_class_name}();
134138

test/members/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ if (WIN32)
121121
endif()
122122

123123
target_sources(${PROJECT_NAME} PRIVATE ${GEODE_MEMBER_TEST_CODEGEN_PATH}/Geode/GeneratedSource.cpp)
124+
target_compile_definitions(${PROJECT_NAME} PRIVATE GEODE_USE_NEW_DESTRUCTOR_LOCK=1)
124125

125126
message(STATUS "Fetching Geode nightly Git hash")
126127

0 commit comments

Comments
 (0)