Skip to content

Add common types into definitions#23

Open
JoltedJon wants to merge 2 commits into
Redot-Engine:masterfrom
JoltedJon:common-defs
Open

Add common types into definitions#23
JoltedJon wants to merge 2 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 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cefc9fa5-a696-40bd-b170-b63a420a4aca

📥 Commits

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

📒 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 as they are similar to previous changes (4)
  • engine/native/core/math/constants.cppm
  • engine/native/core/definitions/version.cppm
  • engine/native/core/definitions/stdtypes.cppm
  • engine/native/core/definitions/definitions.cppm

📝 Walkthrough

Walkthrough

Adds a new exported module core.stdtypes defining draco type aliases and updates core modules (definitions, version, math constants) to include/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
Adds an explicit <cstdint> include and inserts the exported alias block into the draco namespace; moves the namespace closing brace accordingly.
Version struct typed with aliases
engine/native/core/definitions/version.cppm
Restructures module preamble to module; + export module core.version;, imports core.stdtypes, and changes draco::Version fields to u16 while keeping VERSION values and the formatter unchanged.
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.

Sequence Diagram(s)

sequenceDiagram
  participant ComponentA
  participant ComponentB
  ComponentA->>ComponentB: observable interaction
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mcdubhghlas
  • Arctis-Fireblight
  • OldDev78

Poem

I am a rabbit, tidy and spry,
I hop through typedefs under sky,
i8 to u64, f32 in tune,
u32 rune hums to the moon,
Happy aliases—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' accurately captures the main objective of the PR: introducing a set of type aliases (i8, u32, f64, isize, rune, etc.) into the definitions module to reduce header dependencies.
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

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 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

@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

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.

4 participants