Skip to content

Add common types into definitions#23

Merged
mcdubhghlas merged 8 commits into
Redot-Engine:masterfrom
JoltedJon:common-defs
May 21, 2026
Merged

Add common types into definitions#23
mcdubhghlas merged 8 commits into
Redot-Engine:masterfrom
JoltedJon:common-defs

Conversation

@JoltedJon
Copy link
Copy Markdown
Contributor

@JoltedJon JoltedJon commented May 18, 2026

Proposal for common types that we will use to limit including more headers for these types.

I am open to changing the names I just went with Odin default typenames

Summary by CodeRabbit

  • Chores
    • Added a shared standard-types module providing consistent integer, float, size and pointer aliases.
    • Updated core version representation to use those new standard types (public version constant and displayed formatting unchanged).
    • Adjusted math constants to rely on the new standard types for consistent numeric limits.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@JoltedJon has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 53 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7eb8ee93-6adb-45b0-8220-63870088906e

📥 Commits

Reviewing files that changed from the base of the PR and between 531ffab and af6dc32.

📒 Files selected for processing (19)
  • engine/native/core/CMakeLists.txt
  • engine/native/core/definitions/definitions.cppm
  • engine/native/core/math/constants.cppm
  • engine/native/core/math/functions.cppm
  • engine/native/core/math/math.cppm
  • engine/native/core/math/math.test.cpp
  • engine/native/core/math/types_common.cppm
  • engine/native/core/math/vector2.cppm
  • engine/native/core/math/vector3.cppm
  • engine/native/core/math/vector4.cppm
  • engine/native/core/memory/allocator.cpp
  • engine/native/core/memory/allocator.cppm
  • engine/native/core/memory/bumpAllocator.cpp
  • engine/native/core/memory/bumpAllocator.cppm
  • engine/native/core/memory/fixedAllocator.cpp
  • engine/native/core/memory/fixedAllocator.cppm
  • engine/native/core/memory/pageAllocator.cpp
  • engine/native/core/memory/pageAllocator.cppm
  • engine/native/core/memory/slice.cppm
📝 Walkthrough

Walkthrough

Adds an exported module core.stdtypes that defines draco fixed-width and utility type aliases, and updates definitions, version, and math constants modules to import and use those aliases.

Changes

Type aliases definition and adoption

Layer / File(s) Summary
New exported module core.stdtypes
engine/native/core/definitions/stdtypes.cppm
Adds export module core.stdtypes; and defines exported draco aliases for fixed-width integers (i8i64, u8u64), uint, f32/f64, isize/usize, rawptr/uintptr/ptrdiff, and rune.
Embed aliases in existing definitions
engine/native/core/definitions/definitions.cppm
Inserts the exported alias block into the draco namespace and moves the namespace closing brace accordingly.
Version struct typed with aliases
engine/native/core/definitions/version.cppm
Reworks module preamble to module; + export module core.version;, imports core.stdtypes, and changes draco::Version fields to u16 while preserving VERSION values and the formatter behavior.
Constants module adopts aliases
engine/native/core/math/constants.cppm
Imports core.stdtypes and updates draco::math::UINT32_MAX_F to use std::numeric_limits<u32>::max() instead of uint32_t.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mcdubhghlas
  • OldDev78
  • Arctis-Fireblight

Poem

I am a rabbit, tidy and spry,
I hop through aliases, numbers high,
i8 to u64, f32 in tune,
u32 rune greets the moon,
Hooray for types — hoppity hop! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add common types into definitions' directly summarizes the main change: adding type aliases to the definitions module, which is the primary focus across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
engine/native/core/definitions/definitions.cppm (1)

26-26: Consider consistency: isize should match usize semantics.

The isize type is hardcoded to int64_t, while usize is defined as std::size_t. Since the project explicitly targets 64-bit platforms (as evidenced by x86_64-only SIMD configuration in cmake/Compiler.cmake and C++23 requirements), the fixed 64-bit size is intentional. However, for semantic consistency with Rust's isize/usize pairing where both are pointer-sized, consider using std::intptr_t for isize to match usize's pointer-awareness, even if the project currently targets only 64-bit systems.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@engine/native/core/definitions/definitions.cppm` at line 26, The alias isize
is currently fixed to int64_t which mismatches the pointer-sized semantics of
usize; change the isize typedef/using to use a pointer-sized integer type
(std::intptr_t) instead of int64_t so isize mirrors usize's pointer-awareness;
update the using declaration for isize to std::intptr_t and ensure the header
includes <cstdint> (or already provides intptr_t) so the symbol is available.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@engine/native/core/definitions/definitions.cppm`:
- Line 4: The code uses std::size_t in definitions.cppm (around the use on line
27) but only includes <cstdint>; add the missing header <cstddef> to the
includes at the top of definitions.cppm so std::size_t is defined portably;
update the include list (near the existing `#include` <cstdint>) to also include
<cstddef> so any use of std::size_t in functions or types in this module is
standard-compliant.

---

Nitpick comments:
In `@engine/native/core/definitions/definitions.cppm`:
- Line 26: The alias isize is currently fixed to int64_t which mismatches the
pointer-sized semantics of usize; change the isize typedef/using to use a
pointer-sized integer type (std::intptr_t) instead of int64_t so isize mirrors
usize's pointer-awareness; update the using declaration for isize to
std::intptr_t and ensure the header includes <cstdint> (or already provides
intptr_t) so the symbol is available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 50a41540-2054-44d9-b008-3792246df415

📥 Commits

Reviewing files that changed from the base of the PR and between b826b17 and 41202d4.

📒 Files selected for processing (1)
  • engine/native/core/definitions/definitions.cppm

Comment thread engine/native/core/definitions/definitions.cppm Outdated
Comment on lines +13 to +35
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;
using usize = std::size_t;

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

// UTF-32 type
using rune = u32;
Copy link
Copy Markdown
Contributor

@OldDev78 OldDev78 May 18, 2026

Choose a reason for hiding this comment

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

core.version also depends on the common types, would you mind moving these declarations to a core.stdtypes module?

Conversely, maybe core.version can also import this and move up instead...

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@engine/native/core/definitions/version.cppm`:
- Around line 10-16: The Version struct and its fields (struct Version, members
major, minor, patch) currently use signed i16 which allows negative values and
halves the positive range; change the types of major, minor, and patch to the
unsigned 16-bit alias (u16 or std::uint16_t per project aliases) so the exported
contract preserves the full positive range, and keep the constexpr VERSION
initialization unchanged to use the new unsigned fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8229fb21-61f1-483e-9444-2ac81cd32a08

📥 Commits

Reviewing files that changed from the base of the PR and between 41202d4 and a54b315.

📒 Files selected for processing (4)
  • engine/native/core/definitions/definitions.cppm
  • engine/native/core/definitions/stdtypes.cppm
  • engine/native/core/definitions/version.cppm
  • engine/native/core/math/constants.cppm
✅ Files skipped from review due to trivial changes (1)
  • engine/native/core/definitions/stdtypes.cppm
🚧 Files skipped from review as they are similar to previous changes (1)
  • engine/native/core/definitions/definitions.cppm

Comment thread engine/native/core/definitions/version.cppm
Copy link
Copy Markdown
Contributor

@AR-DEV-1 AR-DEV-1 left a comment

Choose a reason for hiding this comment

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

LGTM & is definitely a good change

OldDev78
OldDev78 previously approved these changes May 19, 2026
Copy link
Copy Markdown
Contributor

@OldDev78 OldDev78 left a comment

Choose a reason for hiding this comment

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

Thanks for bringing this back. The import std remove PR had something similar until people asked to just use std, but now I think I will bring back the homebrewn type traits and concepts as well.

Copy link
Copy Markdown
Contributor

@VictorSohier VictorSohier left a comment

Choose a reason for hiding this comment

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

LGTM

@JoltedJon JoltedJon dismissed stale reviews from OldDev78 and Arctis-Fireblight via af6dc32 May 20, 2026 17:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@engine/native/core/definitions/version.cppm`:
- Around line 21-23: The parse implementation for formatter::parse currently
returns ctx.begin() unconditionally; update the parse(std::format_parse_context
&ctx) in version.cppm to validate the format-spec range: if ctx.begin() ==
ctx.end() return ctx.begin() (or ctx.end()) to accept an empty spec, otherwise
consume/validate allowed specifiers or throw std::format_error for any
non-empty/unsupported spec; ensure you use std::format_error and return the
appropriate iterator as required by C++23.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a31df24b-8c22-478a-aaf5-7263fdf302e3

📥 Commits

Reviewing files that changed from the base of the PR and between d002743 and 531ffab.

📒 Files selected for processing (4)
  • engine/native/core/definitions/definitions.cppm
  • engine/native/core/definitions/stdtypes.cppm
  • engine/native/core/definitions/version.cppm
  • engine/native/core/math/constants.cppm

Comment thread engine/native/core/definitions/version.cppm
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.

@mcdubhghlas mcdubhghlas merged commit bb8efd3 into Redot-Engine:master May 21, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants