mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 07:00:10 +01:00
wrap cast aliases in namespace
This commit is contained in:
parent
fe5ee8a3a5
commit
ec78bdf704
8 changed files with 34 additions and 28 deletions
|
|
@ -20,7 +20,7 @@ namespace Hyprutils::Math {
|
|||
|
||||
CEdges() = default;
|
||||
CEdges(eEdges edges) : m_edges(edges) {}
|
||||
CEdges(uint8_t edges) : m_edges(sc<eEdges>(edges)) {}
|
||||
CEdges(uint8_t edges) : m_edges(Memory::sc<eEdges>(edges)) {}
|
||||
|
||||
bool operator==(const CEdges& other) {
|
||||
return m_edges == other.m_edges;
|
||||
|
|
@ -82,28 +82,28 @@ namespace Hyprutils::Math {
|
|||
* @param top The state the top edge should be set to.
|
||||
*/
|
||||
void setTop(bool top) {
|
||||
m_edges = sc<eEdges>((m_edges & ~TOP) | (TOP * top));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~TOP) | (TOP * top));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param left The state the left edge should be set to.
|
||||
*/
|
||||
void setLeft(bool left) {
|
||||
m_edges = sc<eEdges>((m_edges & ~LEFT) | (LEFT * left));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~LEFT) | (LEFT * left));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bottom The state the bottom edge should be set to.
|
||||
*/
|
||||
void setBottom(bool bottom) {
|
||||
m_edges = sc<eEdges>((m_edges & ~BOTTOM) | (BOTTOM * bottom));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~BOTTOM) | (BOTTOM * bottom));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param right The state the right edge should be set to.
|
||||
*/
|
||||
void setRight(bool right) {
|
||||
m_edges = sc<eEdges>((m_edges & ~RIGHT) | (RIGHT * right));
|
||||
m_edges = Memory::sc<eEdges>((m_edges & ~RIGHT) | (RIGHT * right));
|
||||
}
|
||||
|
||||
eEdges m_edges = NONE;
|
||||
|
|
|
|||
|
|
@ -1,28 +1,29 @@
|
|||
#pragma once
|
||||
#include <bit>
|
||||
#include <utility>
|
||||
namespace Hyprutils::Memory {
|
||||
template <typename To, typename From>
|
||||
constexpr To sc(From&& from) noexcept {
|
||||
return static_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To sc(From&& from) noexcept {
|
||||
return static_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
template <typename To, typename From>
|
||||
constexpr To cc(From&& from) noexcept {
|
||||
return const_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To cc(From&& from) noexcept {
|
||||
return const_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
template <typename To, typename From>
|
||||
constexpr To rc(From&& from) noexcept {
|
||||
return reinterpret_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To rc(From&& from) noexcept {
|
||||
return reinterpret_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
template <typename To, typename From>
|
||||
constexpr To dc(From&& from) {
|
||||
return dynamic_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To dc(From&& from) {
|
||||
return dynamic_cast<To>(std::forward<From>(from));
|
||||
}
|
||||
|
||||
template <typename To, typename From>
|
||||
constexpr To bc(const From& from) noexcept {
|
||||
return std::bit_cast<To>(from);
|
||||
template <typename To, typename From>
|
||||
constexpr To bc(const From& from) noexcept {
|
||||
return std::bit_cast<To>(from);
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ namespace Hyprutils {
|
|||
|
||||
if constexpr (sizeof...(Args) == 1)
|
||||
// NOLINTNEXTLINE: const is reapplied by handler invocation if required
|
||||
emitInternal(cc<void*>(sc<const void*>(&std::get<0>(argsTuple))));
|
||||
emitInternal(Memory::cc<void*>(Memory::sc<const void*>(&std::get<0>(argsTuple))));
|
||||
else
|
||||
emitInternal(&argsTuple);
|
||||
}
|
||||
|
|
@ -94,9 +94,9 @@ namespace Hyprutils {
|
|||
if constexpr (sizeof...(Args) == 0)
|
||||
handler();
|
||||
else if constexpr (sizeof...(Args) == 1)
|
||||
handler(*sc<std::remove_reference_t<std::tuple_element_t<0, std::tuple<RefArg<Args>...>>>*>(args));
|
||||
handler(*Memory::sc<std::remove_reference_t<std::tuple_element_t<0, std::tuple<RefArg<Args>...>>>*>(args));
|
||||
else
|
||||
std::apply(handler, *sc<std::tuple<RefArg<Args>...>*>(args));
|
||||
std::apply(handler, *Memory::sc<std::tuple<RefArg<Args>...>*>(args));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
using namespace Hyprutils::Animation;
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
void CBezierCurve::setup(const std::array<Vector2D, 2>& pVec) {
|
||||
// Avoid reallocations by reserving enough memory upfront
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <format>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
static std::unordered_map<eTransform, Mat3x3> transforms = {
|
||||
{HYPRUTILS_TRANSFORM_NORMAL, std::array<float, 9>{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <cmath>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
constexpr const int64_t MAX_REGION_SIDE = 10000000;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <cmath>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
Hyprutils::Math::Vector2D::Vector2D(double xx, double yy) : x(xx), y(yy) {
|
||||
;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <hyprutils/os/Process.hpp>
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
using namespace Hyprutils::OS;
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue