summaryrefslogtreecommitdiff
path: root/src/macros.hpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-08-07 13:35:19 +0200
committervaxerski <vaxry@vaxry.net>2023-08-07 13:36:14 +0200
commit261c3307f70d14e5bbc7d4113b4ee6dac9e4b627 (patch)
tree4e1f5aa70bd571c4f5bc90724f2de2c7b566ddbe /src/macros.hpp
parent6e53c47e68c1d15032b755270568eb5485f2c684 (diff)
internal: cleanup headers in helpers/
Diffstat (limited to 'src/macros.hpp')
-rw-r--r--src/macros.hpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/macros.hpp b/src/macros.hpp
new file mode 100644
index 00000000..334ada80
--- /dev/null
+++ b/src/macros.hpp
@@ -0,0 +1,77 @@
+#pragma once
+
+#include "helpers/MiscFunctions.hpp"
+#include <cmath>
+#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
+
+#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 }
+
+#ifndef __INTELLISENSE__
+#define RASSERT(expr, reason, ...) \
+ if (!(expr)) { \
+ Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", \
+ getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, \
+ ([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
+ printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
+ *((int*)nullptr) = 1; /* so that we crash and get a coredump */ \
+ }
+#else
+#define RASSERT(expr, reason, ...)
+#endif
+
+#define ASSERT(expr) RASSERT(expr, "?")
+
+#if ISDEBUG
+#define UNREACHABLE() \
+ { \
+ Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \
+ *((int*)nullptr) = 1; \
+ }
+#else
+#define UNREACHABLE() std::unreachable();
+#endif \ No newline at end of file