From cf1371f408a962c280d4ec2bde86539bf0d65c65 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Sun, 12 Mar 2023 18:13:00 -0300 Subject: [PATCH 1/2] Simplify modify when __INTELLISENSE__ is set This should greatly help anyone using C++ intellisense by getting rid of the phantom "incomplete type is not allowed" errors --- loader/include/Geode/modify/Modify.hpp | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/loader/include/Geode/modify/Modify.hpp b/loader/include/Geode/modify/Modify.hpp index e5cd1dd1..9ea42f81 100644 --- a/loader/include/Geode/modify/Modify.hpp +++ b/loader/include/Geode/modify/Modify.hpp @@ -123,6 +123,12 @@ namespace geode::modifier { namespace geode { +// The intellisense compiler is quite dumb, and will very often error on modify classes +// with an error of "incomplete type is not allowed", despite not being an issue in actual compilation. +// So as a workaround use the compiler defined "__INTELLISENSE__" macro, which gets set to 1 on the intellisense pass. +// See https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170#microsoft-specific-predefined-macros +#if __INTELLISENSE__ != 1 + template class Modify : public Base { private: @@ -150,6 +156,16 @@ namespace geode { static void onModify(auto& self) {} }; + +#else + + template + class Modify : public Base { + public: + Derived* m_fields; + }; + +#endif } /** @@ -170,6 +186,8 @@ namespace geode { * I am bad at this stuff */ +#if __INTELLISENSE__ != 1 + #define GEODE_MODIFY_DECLARE_ANONYMOUS(base, derived) \ derived##Dummy; \ template \ @@ -184,6 +202,18 @@ namespace geode { derived##Dummy; \ struct GEODE_HIDDEN derived : geode::Modify +#else + +// Simplify the modify macro for intellisense, to hopefully help perfomance a bit + +#define GEODE_MODIFY_DECLARE(base, derived) \ + derived##Dummy; \ + struct derived : geode::Modify + +#define GEODE_MODIFY_DECLARE_ANONYMOUS(base, derived) GEODE_MODIFY_DECLARE(base, derived) + +#endif + #define GEODE_MODIFY_REDIRECT4(base, derived) GEODE_MODIFY_DECLARE(base, derived) #define GEODE_MODIFY_REDIRECT3(base, derived) GEODE_MODIFY_DECLARE_ANONYMOUS(base, derived) #define GEODE_MODIFY_REDIRECT2(base) GEODE_MODIFY_REDIRECT3(base, GEODE_CONCAT(hook, __LINE__)) From c1900ac45ca88a45b0e2333556a08ec88869d1c9 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Sun, 12 Mar 2023 18:20:56 -0300 Subject: [PATCH 2/2] use FieldIntermediate instead of plain Derived* m_fields contains a .self() method, which would be missing in the intellisense pass --- loader/include/Geode/modify/Modify.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/include/Geode/modify/Modify.hpp b/loader/include/Geode/modify/Modify.hpp index 9ea42f81..f0affb59 100644 --- a/loader/include/Geode/modify/Modify.hpp +++ b/loader/include/Geode/modify/Modify.hpp @@ -162,7 +162,7 @@ namespace geode { template class Modify : public Base { public: - Derived* m_fields; + modifier::FieldIntermediate m_fields; }; #endif