Add Hash, Random, Uuid, Encoding, Bits, Math modules + make Testing deps optional

New header-only modules:
- Void::Hash — FNV-1a 32/64, CRC-32, DJB2, MurmurHash3-32, UDL literals
- Void::Random — Xoshiro256** PRNG, uniform_int/real, coin_flip, shuffle, random_string
- Void::Uuid — v4 (random), v5_lite (name-based), parse, RFC 4122 namespaces
- Void::Encoding — Base64 (standard + URL-safe), Hex encode/decode
- Void::Bits — popcount, bit extract/deposit, rotation, align, byteswap, masks
- Void::Math — Vec2/Vec3/Vec4, Mat4 (identity, translation, scale, rotation)

Testing module: move Stacktrace from INTERNAL_DEPS to OPTIONAL_DEPS. Added
Detail/Color.hpp shim that delegates to Stacktrace::Color when present or
provides inline ANSI fallback otherwise. All Stacktrace calls in SignalHandler,
ConsoleReporter, and Runner are gated on VOID_HAS_STACKTRACE.

Fix Repr.hpp reflect_struct to handle template specializations that lack
std::meta::identifier_of (now guarded by has_identifier check).

33/33 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 4.6 committed 2026-05-14 21:52:22 +03:00
1 parent 42268c6c35
commit a09e000f0f
65 files changed
+4959 -138

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#pragma once
#include <functional>
#include <string_view>
namespace Void::Log
{
enum class Level : unsigned char {
Trace = 0,
Debug,
Info,
Warning,
Error,
Fatal
};
/// Signature for any log consumer. Three arguments:
/// level — severity of the event
/// module — short library-internal label (e.g. "FileSystem",
/// "Concurrency") message — human-readable description
using Sink = std::function<void(
Level level, std::string_view module, std::string_view message)>;
/// Install the global sink. Any previously installed sink is replaced.
/// Pass a default-constructed (empty) Sink to silence all output.
/// Thread-safe: the new sink is visible to all threads after this returns.
void set_sink(Sink sink);
/// Emit one log event through the global sink.
/// No-op (zero allocation) if no sink is installed.
/// Thread-safe with respect to set_sink() and concurrent log() calls.
void log(Level level, std::string_view module, std::string_view message);
} // namespace Void::Log
+69
View File
@@ -0,0 +1,69 @@
#pragma once
#include <Void/Detail/Enum.hpp>
#include <Void/Log/Log.hpp>
#include <Void/Logging/Logger.hpp>
// Bridge between Void::Log (the thin emission layer used by all modules) and
// Void::Logging::Logger (the full sink implementation).
//
// Include this header only in translation units that also link Void::Logging.
// All other code that merely calls Void::Log::log() needs only Log.hpp.
//
// Example:
// #include <Void/Log/LoggingAdapter.hpp>
// #include <Void/Logging/ConsoleLogger.hpp>
//
// Void::Logging::ConsoleLogger logger;
// Void::Log::set_sink(Void::Log::make_sink(logger));
namespace Void::Log
{
/// Map a Void::Log::Level to the corresponding Void::Logging::Level.
/// Uses reflection to match by enumerator name; falls back to a
/// hand-written table for non-reflecting compilers.
[[nodiscard]] inline Void::Logging::Level
to_logging_level(Void::Log::Level level) noexcept
{
#ifdef VOID_HAS_ENUM_REFLECTION
return Void::Detail::enum_cast<Void::Logging::Level>(level);
#else
switch (level) {
case Level::Trace:
return Void::Logging::Level::Trace;
case Level::Debug:
return Void::Logging::Level::Debug;
case Level::Info:
return Void::Logging::Level::Info;
case Level::Warning:
return Void::Logging::Level::Warning;
case Level::Error:
return Void::Logging::Level::Error;
case Level::Fatal:
return Void::Logging::Level::Fatal;
}
return Void::Logging::Level::Info;
#endif
}
/// Create a Sink that routes events to a Void::Logging::Logger.
///
/// The module name is prepended to the message as "[module] " so the
/// scope/tag information survives without requiring push_scope() calls on
/// the internal logger.
///
/// Lifetime: the returned Sink holds a reference to logger; logger must
/// outlive any call made through the Sink.
[[nodiscard]] inline Sink make_sink(Void::Logging::Logger& logger)
{
return [&logger](Level level, std::string_view module,
std::string_view message) {
auto full = std::string{"["};
full += module;
full += "] ";
full += message;
logger.log(to_logging_level(level), full);
};
}
} // namespace Void::Log