geode/loader/test/members/Common.hpp
matcool 09b127527b Add CI for member tests, fix PlayerObject
also adds some offsets for windows
2022-12-31 09:09:39 -03:00

24 lines
792 B
C++

#pragma once
#include <Geode/Bindings.hpp>
template <auto... Values>
struct False {
static constexpr auto value = false;
};
template<int Difference, class Class, class Member, bool Predicate>
struct MemberIsOffsetBy {
static_assert(False<Difference>::value, "Member is offset by this value");
};
template<int Difference, class Class, class Member>
struct MemberIsOffsetBy<Difference, Class, Member, true> {
};
template <class Member, class Class, int Offset, int Expected>
struct SingleChecker {
using IsOffsetBy = MemberIsOffsetBy<Offset - Expected, Class, Member, Expected == Offset>;
};
#define GEODE_MEMBER_CHECK(Class_, Member_, Offset_) class Member_; SingleChecker<Member_, Class_, offsetof(Class_, Member_), Offset_>::IsOffsetBy GEODE_CONCAT(OffsetBy, __LINE__)