diff options
Diffstat (limited to 'src/utils.h')
| -rw-r--r-- | src/utils.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/utils.h b/src/utils.h index a4467d3..deba95f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,9 +1,9 @@ #pragma once -#include <stdint.h> #include <wayland-client.h> -#include <wayland-egl-core.h> +#include <wayland-egl.h> +#include <cstdint> #include <cstdio> #include <cstdlib> @@ -63,3 +63,29 @@ static inline u32 wayc_min(u32 a, u32 b) { return a > b ? a : b; } } while (0) #define wayc_notnull(expr) wayc_assert(expr != NULL) + +#define WAYC_CONCAT_IMPL(a, b) a##b +#define WAYC_CONCAT(a, b) WAYC_CONCAT_IMPL(a, b) + +#define WAYC_UNIQUE(base) WAYC_CONCAT(base, WAYC_CONCAT(__LINE__, __COUNTER__)) + +template <typename A, typename B> +struct is_same { + static constexpr bool value = false; +}; + +template <typename A> +struct is_same<A, A> { + static constexpr bool value = true; +}; + +template <typename Func> +struct defer_s { + Func func; + + defer_s(Func func) : func(func) {} + + ~defer_s() { func(); } +}; + +#define wayc_defer(func) auto WAYC_UNIQUE(_defer_) = defer_s([&]() { func; })
\ No newline at end of file |
