2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Use static assert instead of sys error where possible

This commit is contained in:
asmodai 2017-10-06 13:55:54 +03:00
parent 0af5713b86
commit ab359ab320

View File

@ -50,13 +50,10 @@ inline AType getApiType(T *) { return ATYPE_INTEGER; }
inline bool hasStringArgs() { return false; }
extern void __declspec(noreturn) UTIL_SysError(const char *fmt, ...);
template <typename T, typename ...f_args>
bool hasStringArgs(T, f_args... args)
{
if (sizeof(T) > sizeof(int))
UTIL_SysError("%s: invalid hookchain argument size (%i > %i)", __FUNCTION__, sizeof(T), sizeof(int));
static_assert(sizeof(T) <= sizeof(int), "invalid hookchain argument size > sizeof(int)");
if (getApiType(T()) == ATYPE_STRING)
return true;
@ -273,9 +270,7 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, volat
template <typename R, typename original_t, typename ...f_args>
R callForward(size_t func, original_t original, f_args... args)
{
if (sizeof(R) > sizeof(int)) {
UTIL_SysError("%s: invalid return type size (%i > %i)", __FUNCTION__, sizeof(R), sizeof(int));
}
static_assert(sizeof(R) <= sizeof(int), "invalid hookchain return type size > sizeof(int)");
hookctx_t hookCtx(sizeof...(args), args...);
hookctx_t* save = g_hookCtx;