Skip to content

Format bitfields in Debug impl#1496

Merged
Bromeon merged 1 commit intomasterfrom
feature/bitfield-debug
Feb 6, 2026
Merged

Format bitfields in Debug impl#1496
Bromeon merged 1 commit intomasterfrom
feature/bitfield-debug

Conversation

@Bromeon
Copy link
Copy Markdown
Member

@Bromeon Bromeon commented Feb 6, 2026

Makes the Debug impl for bitfields more useful.

Godot often uses a combination of patterns in bitfields:

  • Individual bits
  • Masks covering multiple bits
  • Constants representing zero (no bit set)
  • Values outside known range (or from future Godot versions)

The algorithm tries to be smart about printing the most relevant information.
Example outputs:

// Individual bits
KeyModifierMask { SHIFT | ALT | CTRL }
PropertyUsageFlags { EDITOR | READ_ONLY }

// Zero bits
PropertyUsageFlags { NONE }

// Multiple bits
PropertyUsageFlags { STORAGE | EDITOR | DEFAULT | NO_EDITOR }

// Bits not covered by constants
PropertyUsageFlags { EDITOR | READ_ONLY | Unknown(0x80000000) }

@Bromeon Bromeon added this to the 0.5 milestone Feb 6, 2026
@Bromeon Bromeon added feature Adds functionality to the library c: engine Godot classes (nodes, resources, ...) labels Feb 6, 2026
Comment on lines +220 to +221
use std::fmt::Write;
write!(flags, "Unknown(0x{remaining_bits:X})")?;
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.

Inline import looks silly, move it to the top of the module

@Bromeon Bromeon force-pushed the feature/bitfield-debug branch 2 times, most recently from aab28c0 to 9260aca Compare February 6, 2026 22:15
@Bromeon Bromeon force-pushed the feature/bitfield-debug branch from 9260aca to 54e489d Compare February 6, 2026 22:18
@Bromeon Bromeon added this pull request to the merge queue Feb 6, 2026
Merged via the queue into master with commit 8854ed8 Feb 6, 2026
23 checks passed
@Bromeon Bromeon deleted the feature/bitfield-debug branch February 6, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: engine Godot classes (nodes, resources, ...) feature Adds functionality to the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants