From c644b434687f6c05528a6658f9aa883d175c7963 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 26 Jan 2023 16:10:11 +0300 Subject: [PATCH] fix cross compiling for clang windowsgit status uwugit status --- .../cocos/platform/win32/CCApplication.h | 1 + .../include/Geode/modify/AsStaticFunction.hpp | 4 +- loader/include/Geode/modify/Modify.hpp | 62 ++++++++++--------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/loader/include/Geode/cocos/platform/win32/CCApplication.h b/loader/include/Geode/cocos/platform/win32/CCApplication.h index c135ffb0..6e0c9922 100644 --- a/loader/include/Geode/cocos/platform/win32/CCApplication.h +++ b/loader/include/Geode/cocos/platform/win32/CCApplication.h @@ -15,6 +15,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: + GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); virtual ~CCApplication(); diff --git a/loader/include/Geode/modify/AsStaticFunction.hpp b/loader/include/Geode/modify/AsStaticFunction.hpp index cbd00afd..e47e1f9a 100644 --- a/loader/include/Geode/modify/AsStaticFunction.hpp +++ b/loader/include/Geode/modify/AsStaticFunction.hpp @@ -8,7 +8,7 @@ namespace geode::modifier { * A helper struct that generates a static function that calls the given function. */ #define GEODE_AS_STATIC_FUNCTION(FunctionName_) \ - template \ + template \ struct AsStaticFunction_##FunctionName_ { \ template \ struct Impl {}; \ @@ -36,7 +36,7 @@ namespace geode::modifier { return self2->Class2::FunctionName_(params...); \ } \ }; \ - static constexpr auto value = &Impl::function; \ + static constexpr auto value = &Impl::function; \ }; GEODE_AS_STATIC_FUNCTION(constructor) diff --git a/loader/include/Geode/modify/Modify.hpp b/loader/include/Geode/modify/Modify.hpp index 0e2444a3..ca00ef48 100644 --- a/loader/include/Geode/modify/Modify.hpp +++ b/loader/include/Geode/modify/Modify.hpp @@ -10,13 +10,15 @@ #define GEODE_APPLY_MODIFY_FOR_FUNCTION(AddressIndex_, Convention_, ClassName_, FunctionName_, ...) \ do { \ - constexpr auto b = Resolve<__VA_ARGS__>::func(&Base::FunctionName_); \ - constexpr auto d = Resolve<__VA_ARGS__>::func(&Derived::FunctionName_); \ - if constexpr (Unique::different()) { \ + if constexpr (Unique::different< \ + Resolve<__VA_ARGS__>::func(&Base::FunctionName_), \ + Resolve<__VA_ARGS__>::func(&Derived::FunctionName_)>()) { \ auto hook = Hook::create( \ Mod::get(), \ reinterpret_cast(address()), \ - AsStaticFunction_##FunctionName_::value, \ + AsStaticFunction_##FunctionName_< \ + Derived, \ + decltype(Resolve<__VA_ARGS__>::func(&Derived::FunctionName_))>::value, \ #ClassName_ "::" #FunctionName_, \ tulip::hook::TulipConvention::Convention_ \ ); \ @@ -24,34 +26,34 @@ } \ } while (0); -#define GEODE_APPLY_MODIFY_FOR_CONSTRUCTOR(AddressIndex_, Convention_, ClassName_, ...) \ - do { \ - if constexpr (HasConstructor) { \ - constexpr auto d = Resolve<__VA_ARGS__>::func(&Derived::constructor); \ - auto hook = Hook::create( \ - Mod::get(), \ - reinterpret_cast(address()), \ - AsStaticFunction_##constructor::value, \ - #ClassName_ "::" #ClassName_, \ - tulip::hook::TulipConvention::Convention_ \ - ); \ - this->m_hooks[#ClassName_ "::" #ClassName_] = hook; \ - } \ +#define GEODE_APPLY_MODIFY_FOR_CONSTRUCTOR(AddressIndex_, Convention_, ClassName_, ...) \ + do { \ + if constexpr (HasConstructor) { \ + auto hook = Hook::create( \ + Mod::get(), \ + reinterpret_cast(address()), \ + AsStaticFunction_##constructor< \ + Derived, \ + decltype(Resolve<__VA_ARGS__>::func(&Derived::constructor))>::value, \ + #ClassName_ "::" #ClassName_, \ + tulip::hook::TulipConvention::Convention_ \ + ); \ + this->m_hooks[#ClassName_ "::" #ClassName_] = hook; \ + } \ } while (0); -#define GEODE_APPLY_MODIFY_FOR_DESTRUCTOR(AddressIndex_, Convention_, ClassName_) \ - do { \ - if constexpr (HasDestructor) { \ - constexpr auto d = Resolve<>::func(&Derived::destructor); \ - auto hook = Hook::create( \ - Mod::get(), \ - reinterpret_cast(address()), \ - AsStaticFunction_##destructor::value, \ - #ClassName_ "::" #ClassName_, \ - tulip::hook::TulipConvention::Convention_ \ - ); \ - this->m_hooks[#ClassName_ "::" #ClassName_] = hook; \ - } \ +#define GEODE_APPLY_MODIFY_FOR_DESTRUCTOR(AddressIndex_, Convention_, ClassName_) \ + do { \ + if constexpr (HasDestructor) { \ + auto hook = Hook::create( \ + Mod::get(), \ + reinterpret_cast(address()), \ + AsStaticFunction_##destructor::func(&Derived::destructor))>::value, \ + #ClassName_ "::" #ClassName_, \ + tulip::hook::TulipConvention::Convention_ \ + ); \ + this->m_hooks[#ClassName_ "::" #ClassName_] = hook; \ + } \ } while (0); namespace geode::modifier {