mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
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
This commit is contained in:
parent
f3e32a5317
commit
cf1371f408
1 changed files with 30 additions and 0 deletions
|
@ -123,6 +123,12 @@ namespace geode::modifier {
|
||||||
|
|
||||||
namespace geode {
|
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 Derived, class Base>
|
template <class Derived, class Base>
|
||||||
class Modify : public Base {
|
class Modify : public Base {
|
||||||
private:
|
private:
|
||||||
|
@ -150,6 +156,16 @@ namespace geode {
|
||||||
|
|
||||||
static void onModify(auto& self) {}
|
static void onModify(auto& self) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template <class Derived, class Base>
|
||||||
|
class Modify : public Base {
|
||||||
|
public:
|
||||||
|
Derived* m_fields;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,6 +186,8 @@ namespace geode {
|
||||||
* I am bad at this stuff
|
* I am bad at this stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if __INTELLISENSE__ != 1
|
||||||
|
|
||||||
#define GEODE_MODIFY_DECLARE_ANONYMOUS(base, derived) \
|
#define GEODE_MODIFY_DECLARE_ANONYMOUS(base, derived) \
|
||||||
derived##Dummy; \
|
derived##Dummy; \
|
||||||
template <class> \
|
template <class> \
|
||||||
|
@ -184,6 +202,18 @@ namespace geode {
|
||||||
derived##Dummy; \
|
derived##Dummy; \
|
||||||
struct GEODE_HIDDEN derived : geode::Modify<derived, base>
|
struct GEODE_HIDDEN derived : geode::Modify<derived, base>
|
||||||
|
|
||||||
|
#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<derived, base>
|
||||||
|
|
||||||
|
#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_REDIRECT4(base, derived) GEODE_MODIFY_DECLARE(base, derived)
|
||||||
#define GEODE_MODIFY_REDIRECT3(base, derived) GEODE_MODIFY_DECLARE_ANONYMOUS(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__))
|
#define GEODE_MODIFY_REDIRECT2(base) GEODE_MODIFY_REDIRECT3(base, GEODE_CONCAT(hook, __LINE__))
|
||||||
|
|
Loading…
Reference in a new issue