From 3b5fab8849f9a7cd3fa6469d3bec04b78784b3ff Mon Sep 17 00:00:00 2001 From: untodesu Date: Sun, 29 Jun 2025 12:04:58 +0500 Subject: Update core/macros.hh --- core/CMakeLists.txt | 1 + core/aabb.hh | 2 +- core/buffer.hh | 5 +++-- core/config.hh | 3 ++- core/macros.hh | 16 +++++++++++++--- game/shared/chunk_aabb.hh | 4 +++- game/shared/feature.hh | 4 +++- game/shared/ray_dda.hh | 4 +++- 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7bac586..c2d5289 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(core STATIC "${CMAKE_CURRENT_LIST_DIR}/floathacks.hh" "${CMAKE_CURRENT_LIST_DIR}/image.cc" "${CMAKE_CURRENT_LIST_DIR}/image.hh" + "${CMAKE_CURRENT_LIST_DIR}/macros.hh" "${CMAKE_CURRENT_LIST_DIR}/pch.hh" "${CMAKE_CURRENT_LIST_DIR}/resource.hh" "${CMAKE_CURRENT_LIST_DIR}/strtools.cc" diff --git a/core/aabb.hh b/core/aabb.hh index 127f90f..fe07060 100644 --- a/core/aabb.hh +++ b/core/aabb.hh @@ -6,7 +6,7 @@ class AABB final { public: - DECLARE_DEFAULT_CTOR(AABB); + DECLARE_DEFAULT_CONSTRUCTOR(AABB); explicit AABB(const glm::fvec3& min, const glm::fvec3& max); virtual ~AABB(void) = default; diff --git a/core/buffer.hh b/core/buffer.hh index b63d0f5..1397e16 100644 --- a/core/buffer.hh +++ b/core/buffer.hh @@ -2,10 +2,11 @@ #define CORE_BUFFER_HH 1 #include "core/floathacks.hh" +#include "core/macros.hh" class ReadBuffer final { public: - explicit ReadBuffer(void) = default; + DECLARE_DEFAULT_CONSTRUCTOR(ReadBuffer); explicit ReadBuffer(const void* data, std::size_t size); explicit ReadBuffer(const ENetPacket* packet); explicit ReadBuffer(PHYSFS_File* file); @@ -48,7 +49,7 @@ private: class WriteBuffer final { public: - explicit WriteBuffer(void) = default; + DECLARE_DEFAULT_CONSTRUCTOR(WriteBuffer); virtual ~WriteBuffer(void) = default; std::size_t size(void) const; diff --git a/core/config.hh b/core/config.hh index efb2ef0..a7f8500 100644 --- a/core/config.hh +++ b/core/config.hh @@ -3,6 +3,7 @@ #pragma once #include "core/concepts.hh" +#include "core/macros.hh" class IConfigValue { public: @@ -94,7 +95,7 @@ private: class Config final { public: - explicit Config(void) = default; + DECLARE_DEFAULT_CONSTRUCTOR(Config); virtual ~Config(void) = default; void load_cmdline(void); diff --git a/core/macros.hh b/core/macros.hh index 9042f49..9a76109 100644 --- a/core/macros.hh +++ b/core/macros.hh @@ -2,8 +2,18 @@ #define CORE_MACROS_HH 1 #pragma once -#define DECLARE_DEFAULT_CTOR(type) \ -public: \ - type(void) = default +#define DISABLE_COPY_OPERATORS(class_name) \ +public: \ + explicit class_name(const class_name& other) = delete; \ + class_name& operator=(const class_name& other) = delete + +#define DISABLE_MOVE_OPERATORS(class_name) \ +public: \ + explicit class_name(class_name&& other) = delete; \ + class_name& operator=(class_name&& other) = delete + +#define DECLARE_DEFAULT_CONSTRUCTOR(class_name) \ +public: \ + class_name(void) = default #endif /* CORE_MACROS_HH */ diff --git a/game/shared/chunk_aabb.hh b/game/shared/chunk_aabb.hh index e215f9a..7a35dd4 100644 --- a/game/shared/chunk_aabb.hh +++ b/game/shared/chunk_aabb.hh @@ -2,11 +2,13 @@ #define SHARED_CHUNK_AABB 1 #pragma once +#include "core/macros.hh" + #include "shared/types.hh" class ChunkAABB final { public: - explicit ChunkAABB(void) = default; + DECLARE_DEFAULT_CONSTRUCTOR(ChunkAABB); virtual ~ChunkAABB(void) = default; void set_bounds(const chunk_pos& min, const chunk_pos& max); diff --git a/game/shared/feature.hh b/game/shared/feature.hh index 306841e..04f38e8 100644 --- a/game/shared/feature.hh +++ b/game/shared/feature.hh @@ -2,6 +2,8 @@ #define SHARED_FEATURE_HH 1 #pragma once +#include "core/macros.hh" + #include "shared/types.hh" class Dimension; @@ -9,7 +11,7 @@ class VoxelStorage; class Feature final : public std::vector> { public: - explicit Feature(void) = default; + DECLARE_DEFAULT_CONSTRUCTOR(Feature); virtual ~Feature(void) = default; public: diff --git a/game/shared/ray_dda.hh b/game/shared/ray_dda.hh index 5378680..91eb462 100644 --- a/game/shared/ray_dda.hh +++ b/game/shared/ray_dda.hh @@ -2,13 +2,15 @@ #define SHARED_RAY_DDA 1 #pragma once +#include "core/macros.hh" + #include "shared/types.hh" class Dimension; class RayDDA final { public: - explicit RayDDA(void) = default; + DECLARE_DEFAULT_CONSTRUCTOR(RayDDA); explicit RayDDA(const Dimension* dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos, const glm::fvec3& direction); explicit RayDDA(const Dimension& dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos, const glm::fvec3& direction); -- cgit