summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-21 14:20:16 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-21 14:20:16 +0200
commit7a38c6c434e03256d9e9fbff87516b3ad1e3958a (patch)
tree2cb34a9613fc7f50a6bd7dc0d03eca448e3f5567
parent9a0d8a428b21a77272380009d97436b0a5f20d8c (diff)
macro shenanigans
-rw-r--r--anim-crop-tool/main.cpp2
-rw-r--r--compat/assert.hpp8
-rw-r--r--compat/defs.hpp30
-rw-r--r--main/editor.hpp2
-rw-r--r--main/keyboard.cpp2
-rw-r--r--src/chunk.hpp2
-rw-r--r--src/tile.hpp2
-rw-r--r--src/world.hpp2
8 files changed, 37 insertions, 13 deletions
diff --git a/anim-crop-tool/main.cpp b/anim-crop-tool/main.cpp
index 126c3aa3..353a6be1 100644
--- a/anim-crop-tool/main.cpp
+++ b/anim-crop-tool/main.cpp
@@ -64,7 +64,7 @@ static std::tuple<cv::Vec2i, cv::Vec2i, bool> find_image_bounds(const cv::Mat4b&
[[nodiscard]]
static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const path& filename)
{
- auto mat = progn(
+ auto mat = fm_begin(
cv::Mat mat = cv::imread(filename.string(), cv::IMREAD_UNCHANGED);
if (mat.empty() || mat.type() != CV_8UC4)
{
diff --git a/compat/assert.hpp b/compat/assert.hpp
index 44b401fa..c91dd785 100644
--- a/compat/assert.hpp
+++ b/compat/assert.hpp
@@ -47,6 +47,14 @@
#define fm_log(...) fm_EMIT_DEBUG("", __VA_ARGS__)
#define fm_debug(...) fm_EMIT_DEBUG("", __VA_ARGS__)
+#define fm_warn_once(...) do { \
+ static bool _fm_once_flag = false; \
+ if (!_fm_once_flag) { \
+ _fm_once_flag = true; \
+ fm_warn(__VA_ARGS__); \
+ } \
+ } while (false)
+
#ifdef __GNUG__
# pragma GCC diagnostic pop
#endif
diff --git a/compat/defs.hpp b/compat/defs.hpp
index 632bafe5..1bd0f181 100644
--- a/compat/defs.hpp
+++ b/compat/defs.hpp
@@ -1,19 +1,33 @@
#pragma once
#ifdef _MSC_VER
-# define FUNCTION_NAME __FUNCSIG__
+# define fm_FUNCTION_NAME __FUNCSIG__
#else
-# define FUNCTION_NAME __PRETTY_FUNCTION__
+# define fm_FUNCTION_NAME __PRETTY_FUNCTION__
#endif
-#define progn(...) [&]{__VA_ARGS__;}()
+#define fm_begin(...) [&]{__VA_ARGS__}()
-#define DECLARE_DEPRECATED_COPY_ASSIGNMENT(type) \
- [[deprecated]] type(const type&) = default; \
- [[deprecated]] type& operator=(const type&) = default
+#define fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(type) \
+ [[deprecated]] type(const type&) noexcept = default; \
+ [[deprecated]] type& operator=(const type&) noexcept = default
-#define DECLARE_DELETED_COPY_ASSIGNMENT(type) \
- type(const type&) = delete; \
+#define fm_DECLARE_DEFAULT_COPY_ASSIGNMENT(type) \
+ constexpr type(const type&) noexcept = default; \
+ constexpr type& operator=(const type&) noexcept = default
+
+#define fm_DECLARE_DELETED_COPY_ASSIGNMENT(type) \
+ type(const type&) = delete; \
type& operator=(const type&) = delete
+#define fm_DECLARE_DELETED_MOVE_ASSIGNMENT(type) \
+ [[deprecated]] type(type&&) = delete; \
+ [[deprecated]] type& operator=(type&&) = delete
+
+#define fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT(type) \
+ constexpr type(type&&) noexcept = default; \
+ constexpr type& operator=(type&&) noexcept = default
+#define fm_DECLARE_DEFAULT_MOVE_COPY_ASSIGNMENTS(type) \
+ fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT(type); \
+ fm_DECLARE_DEFAULT_COPY_ASSIGNMENT(type)
diff --git a/main/editor.hpp b/main/editor.hpp
index 88740b35..4214ec5e 100644
--- a/main/editor.hpp
+++ b/main/editor.hpp
@@ -75,7 +75,7 @@ struct editor final
editor();
editor(editor&&) noexcept = default;
editor& operator=(editor&&) noexcept = default;
- DECLARE_DELETED_COPY_ASSIGNMENT(editor);
+ fm_DECLARE_DELETED_COPY_ASSIGNMENT(editor);
private:
tile_type _floor{editor_mode::floor, "floor"};
diff --git a/main/keyboard.cpp b/main/keyboard.cpp
index 267971b2..90be44e2 100644
--- a/main/keyboard.cpp
+++ b/main/keyboard.cpp
@@ -9,7 +9,7 @@ void app::do_key(KeyEvent::Key k, KeyEvent::Modifiers m, bool pressed, bool repe
(void)m;
(void)repeated;
- const key x = progn(switch (k) {
+ const key x = fm_begin(switch (k) {
using enum KeyEvent::Key;
using enum key;
diff --git a/src/chunk.hpp b/src/chunk.hpp
index 9e41c5fb..5e4f5392 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -37,7 +37,7 @@ struct chunk final
chunk() = default;
chunk(chunk&&) = default;
chunk& operator=(chunk&&) = default;
- DECLARE_DELETED_COPY_ASSIGNMENT(chunk);
+ fm_DECLARE_DELETED_COPY_ASSIGNMENT(chunk);
private:
std::array<tile, TILE_COUNT> _tiles = {};
diff --git a/src/tile.hpp b/src/tile.hpp
index a58d129a..067df3c7 100644
--- a/src/tile.hpp
+++ b/src/tile.hpp
@@ -28,7 +28,7 @@ struct tile final
constexpr tile() = default;
tile(tile&&) = default;
- DECLARE_DEPRECATED_COPY_ASSIGNMENT(tile);
+ fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(tile);
};
} //namespace floormat
diff --git a/src/world.hpp b/src/world.hpp
index 7c256efc..89bc4feb 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -19,6 +19,8 @@ struct world final
void clear();
void collect();
+ fm_DECLARE_DELETED_COPY_ASSIGNMENT(world);
+
private:
void maybe_collect();