Hyprland/src/defines.hpp

40 lines
2.4 KiB
C++
Raw Normal View History

2022-03-16 20:50:55 +01:00
#include "includes.hpp"
2022-03-27 17:25:20 +02:00
#include "debug/Log.hpp"
2022-03-28 16:10:30 +02:00
#include "helpers/MiscFunctions.hpp"
2022-03-16 20:50:55 +01:00
#ifndef NDEBUG
#define ISDEBUG true
#else
#define ISDEBUG false
#endif
2022-03-16 21:37:21 +01:00
#define RIP(format, ... ) { fprintf(stderr, format "\n", ##__VA_ARGS__); exit(EXIT_FAILURE); }
2022-03-17 18:25:16 +01:00
#define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name };
2022-03-17 20:22:29 +01:00
#define DYNLISTENER(name) wl_listener listen_##name = { .notify = Events::listener_##name };
2022-03-27 17:25:20 +02:00
#define DYNMULTILISTENER(name) wl_listener listen_##name;
2022-03-17 20:22:29 +01:00
#define VECINRECT(vec, x1, y1, x2, y2) (vec.x >= (x1) && vec.x <= (x2) && vec.y >= (y1) && vec.y <= (y2))
#define interface class
2022-03-19 16:13:19 +01:00
#define STICKS(a, b) abs((a) - (b)) < 2
#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
2022-03-20 13:37:07 +01:00
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
2022-03-27 17:25:20 +02:00
#define HYPRATOM(name) {name, 0}
2022-03-28 16:10:30 +02:00
#ifndef __INTELLISENSE__
2022-03-27 22:34:02 +02:00
#define RASSERT(expr, reason) \
if (!expr) { \
Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", std::string(reason).c_str(), __LINE__, ([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
RIP("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
}
2022-03-28 16:10:30 +02:00
#else
#define RASSERT(expr, reason)
#endif
2022-03-27 17:25:20 +02:00
#define ASSERT(expr) RASSERT(expr, "?")