Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions engine/native/core/definitions/definitions.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export import core.version;
static_assert(__cplusplus >= 202207L, "Minimum of C++23 required. Consider upgrading your compiler.");

export namespace draco {

template<typename T>
concept arithmetic = std::is_arithmetic_v<T>;

Expand All @@ -26,4 +25,4 @@ export namespace draco {

template <typename T>
concept zero_constructible = is_zero_constructible_v<T>;
}
}
33 changes: 33 additions & 0 deletions engine/native/core/definitions/stdtypes.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module;

#include <cstddef>
#include <cstdint>

export module core.stdtypes;

export namespace draco {
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using uint = unsigned int;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

using isize = int64_t;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if ssize would be a better name (like std::ssize_t), but that's not terribly important.
Not worth going back and renaming everything for this.

using usize = std::size_t;

using rawptr = void *;
using uintptr = uintptr_t;
using ptrdiff = ptrdiff_t;

// UTF-32 type
using rune = u32;

} // namespace draco
34 changes: 17 additions & 17 deletions engine/native/core/definitions/version.cppm
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
module;

#include <cstdint>
#include <format>

export module core.version;
import core.stdtypes;

export namespace draco {

struct Version {
std::uint16_t major;
std::uint16_t minor;
std::uint16_t patch;
};
struct Version {
u16 major;
u16 minor;
u16 patch;
};

constexpr Version VERSION { .major = 2026, .minor = 0, .patch = 0 };
}
constexpr Version VERSION{.major = 2026, .minor = 0, .patch = 0};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} // namespace draco

export namespace std {
template<> struct formatter<draco::Version> {
constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); // Accept any format spec (or parse custom ones)
}
template <> struct formatter<draco::Version> {
constexpr auto parse(std::format_parse_context &ctx) {
return ctx.begin(); // Accept any format spec (or parse custom ones)
}
Comment thread
OldDev78 marked this conversation as resolved.

auto format(const draco::Version& v, std::format_context& ctx) const {
return std::format_to(ctx.out(), "{}.{}.{}", v.major, v.minor, v.patch);
}
};
}
auto format(const draco::Version &v, std::format_context &ctx) const {
return std::format_to(ctx.out(), "{}.{}.{}", v.major, v.minor, v.patch);
}
};
} // namespace std
3 changes: 2 additions & 1 deletion engine/native/core/math/constants.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module;

export module core.math.constants;
import core.defs;
import core.stdtypes;

export namespace draco::math {
// Limit the depth of recursive algorithms
Expand All @@ -24,7 +25,7 @@ export namespace draco::math {
constexpr float NaN = std::numeric_limits<float>::quiet_NaN();
constexpr float DB_CONVERSION_GAIN = 8.6858896380650365530225783783321;
constexpr float GAIN_CONVERSION_DB = 0.11512925464970228420089957273422;
constexpr float UINT32_MAX_F = 1.f / std::numeric_limits<uint32_t>::max();
constexpr float UINT32_MAX_F = 1.f / std::numeric_limits<u32>::max();
constexpr float DECIMAL_LIMIT_F = 8388608.0f;

constexpr float CMP_EPSILON = 0.000001f;
Expand Down