2023-08-07 13:35:19 +02:00
# pragma once
# include "helpers/MiscFunctions.hpp"
2023-08-07 18:48:08 +02:00
# include "debug/Log.hpp"
2023-08-07 13:35:19 +02:00
# include <cmath>
2023-08-31 22:52:02 +02:00
# include <csignal>
2023-08-07 13:35:19 +02:00
# include <utility>
# ifndef NDEBUG
# ifdef HYPRLAND_DEBUG
# define ISDEBUG true
# else
# define ISDEBUG false
# endif
# else
# define ISDEBUG false
# endif
// git stuff
# ifndef GIT_COMMIT_HASH
# define GIT_COMMIT_HASH "?"
# endif
# ifndef GIT_BRANCH
# define GIT_BRANCH "?"
# endif
# ifndef GIT_COMMIT_MESSAGE
# define GIT_COMMIT_MESSAGE "?"
# endif
# ifndef GIT_DIRTY
# define GIT_DIRTY "?"
# endif
# ifndef GIT_TAG
# define GIT_TAG "?"
# endif
# define SPECIAL_WORKSPACE_START (-99)
# define PI 3.14159265358979
2023-09-12 17:46:22 +02:00
# define STRVAL_EMPTY "[[EMPTY]]"
2023-08-07 13:35:19 +02:00
# define LISTENER(name) \
void listener_ # # name ( wl_listener * , void * ) ; \
inline wl_listener listen_ # # name = { . notify = listener_ # # name }
# define DYNLISTENFUNC(name) void listener_##name(void*, void*)
# define DYNLISTENER(name) CHyprWLListener hyprListener_##name
# define DYNMULTILISTENER(name) wl_listener listen_##name
# define VECINRECT(vec, x1, y1, x2, y2) ((vec).x >= (x1) && (vec).x <= (x2) && (vec).y >= (y1) && (vec).y <= (y2))
# define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < (delta))
# define STICKS(a, b) abs((a) - (b)) < 2
# define HYPRATOM(name) \
{ name , 0 }
# define RASSERT(expr, reason, ...) \
if ( ! ( expr ) ) { \
2023-09-06 12:51:36 +02:00
Debug : : log ( CRIT , " \n ========================================================================================== \n ASSERTION FAILED! \n \n {} \n \n at: line {} in {} " , \
2023-09-20 09:26:20 +02:00
std : : format ( reason , # # __VA_ARGS__ ) , __LINE__ , \
( [ ] ( ) constexpr - > std : : string { return std : : string ( __FILE__ ) . substr ( std : : string ( __FILE__ ) . find_last_of ( ' / ' ) + 1 ) ; } ) ( ) ) ; \
2023-08-07 13:35:19 +02:00
printf ( " Assertion failed! See the log in /tmp/hypr/hyprland.log for more info. " ) ; \
2023-08-31 22:52:02 +02:00
raise ( SIGABRT ) ; \
2023-08-07 13:35:19 +02:00
}
# define ASSERT(expr) RASSERT(expr, "?")
# if ISDEBUG
# define UNREACHABLE() \
{ \
Debug : : log ( CRIT , " \n \n MEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!) " ) ; \
2023-08-31 22:52:02 +02:00
raise ( SIGABRT ) ; \
2023-08-07 13:35:19 +02:00
}
# else
# define UNREACHABLE() std::unreachable();
# endif