From b2548ba4ce295fcd94a50123fb543fac2ef2bc33 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 14 Nov 2024 14:46:23 -0500 Subject: add pk.h and major pkmem refactor Completely replaces the memory module with pkmem pkmem is a newer implementation of the same bucket memory structure. Also includes replacing pkstr.h with pk.h's pkstr --- src/macros.hpp | 117 --------------------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 src/macros.hpp (limited to 'src/macros.hpp') diff --git a/src/macros.hpp b/src/macros.hpp deleted file mode 100644 index 5fc7f3b..0000000 --- a/src/macros.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef PKE_MACROS_HPP -#define PKE_MACROS_HPP - -#define Q(x) #x -#define QUOTE(x) Q(x) -#define CONCAT2(x, y) x##y -#define CONCAT(x, y) CONCAT2(x, y) - -#define CAFE_BABE(T) reinterpret_cast(0xCAFEBABE) - -#define NULL_CHAR_ARR(v, len) char v[len]; v[0] = '\0'; v[len-1] = '\0'; - -#define IS_CONSTRUCTIBLE(T) constexpr(std::is_default_constructible::value && !std::is_integral::value && !std::is_floating_point::value) -#define IS_DESTRUCTIBLE(T) constexpr(std::is_destructible::value && !std::is_integral::value && !std::is_floating_point::value && !std::is_array::value) - -#define TypeSafeInt2_H(TypeName, Type, Max, TypeName_T, TypeName_MAX, TypeName_T_MAX)\ - using TypeName_T = Type; \ - enum class TypeName : TypeName_T; \ - constexpr TypeName_T TypeName_T_MAX = TypeName_T{Max}; \ - constexpr TypeName TypeName_MAX = TypeName{TypeName_T_MAX}; \ - TypeName operator+(const TypeName &a, const TypeName_T &i); \ - TypeName operator-(const TypeName &a, const TypeName_T &i); \ - TypeName operator+(const TypeName &a, const TypeName &b); \ - TypeName operator-(const TypeName &a, const TypeName &b); \ - TypeName operator&(const TypeName &a, const TypeName &b); \ - TypeName operator|(const TypeName &a, const TypeName &b); \ - TypeName operator^(const TypeName &a, const TypeName &b); \ - TypeName &operator++(TypeName &a); \ - TypeName &operator--(TypeName &a); \ - TypeName operator<<(const TypeName &a, const TypeName &b); \ - TypeName operator>>(const TypeName &a, const TypeName &b); -#define TypeSafeInt2_B(TypeName, TypeName_T) \ - inline TypeName operator+(const TypeName &a, const TypeName_T &i) { \ - return TypeName(static_cast(a) + i); \ - } \ - inline TypeName operator-(const TypeName &a, const TypeName_T &i) { \ - return TypeName(static_cast(a) - i); \ - } \ - inline TypeName operator+(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) + static_cast(b)); \ - } \ - inline TypeName operator-(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) - static_cast(b)); \ - } \ - inline TypeName operator&(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) & static_cast(b)); \ - } \ - inline TypeName operator|(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) | static_cast(b)); \ - } \ - inline TypeName operator^(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) ^ static_cast(b)); \ - } \ - inline TypeName &operator++(TypeName &a) { \ - a = a + 1; \ - return a; \ - } \ - inline TypeName &operator--(TypeName &a) { \ - a = a - 1; \ - return a; \ - }; \ - inline TypeName operator<<(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) << static_cast(b)); \ - }; \ - inline TypeName operator>>(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) >> static_cast(b)); \ - }; -#define TypeSafeInt_H(TypeName, Type, Max) \ - TypeSafeInt2_H(TypeName, Type, Max, CONCAT(TypeName, _T), CONCAT(TypeName, _MAX), CONCAT(TypeName, _T_MAX)) -#define TypeSafeInt_B(TypeName) \ - TypeSafeInt2_B(TypeName, CONCAT(TypeName, _T)) - -#define TypeSafeInt2_H_constexpr(TypeName, Type, Max, TypeName_T, TypeName_MAX, TypeName_T_MAX)\ - using TypeName_T = Type; \ - enum class TypeName : TypeName_T; \ - constexpr TypeName_T TypeName_T_MAX = TypeName_T{Max}; \ - constexpr TypeName TypeName_MAX = TypeName{TypeName_T_MAX}; \ - constexpr TypeName operator+(const TypeName &a, const TypeName_T &b) { \ - return TypeName(static_cast(a) + static_cast(b)); \ - } \ - constexpr TypeName operator-(const TypeName &a, const TypeName_T &b) { \ - return TypeName(static_cast(a) - static_cast(b)); \ - } \ - constexpr TypeName operator+(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) + static_cast(b)); \ - } \ - constexpr TypeName operator-(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) - static_cast(b)); \ - } \ - constexpr TypeName operator&(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) & static_cast(b)); \ - } \ - constexpr TypeName operator|(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) | static_cast(b)); \ - } \ - constexpr TypeName operator^(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) ^ static_cast(b)); \ - } \ - constexpr TypeName &operator++(TypeName &a) { \ - a = a + TypeName(1); \ - return a; \ - } \ - constexpr TypeName &operator--(TypeName &a) { \ - a = a - TypeName{1}; \ - return a; \ - }; \ - constexpr TypeName operator<<(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) << static_cast(b)); \ - }; \ - constexpr TypeName operator>>(const TypeName &a, const TypeName &b) { \ - return TypeName(static_cast(a) >> static_cast(b)); \ - }; -#define TypeSafeInt_Const_Expr(TypeName, Type, Max) \ - TypeSafeInt2_H_constexpr(TypeName, Type, Max, CONCAT(TypeName, _T), CONCAT(TypeName, _MAX), CONCAT(TypeName, _T_MAX)) - - -#endif /* PKE_MACROS_HPP */ -- cgit v1.2.3