Skip to content

Conversation

@Ivorforce
Copy link
Member

@Ivorforce Ivorforce commented Dec 4, 2025

Now it's starting to get interesting :)
This PR is the first step towards replacing ClassDB (for the purposes of type capabilities), as proposed in godotengine/godot-proposals#12323.

Explanation

The PR makes a few important decisions:

  • GDType gets init_state which protects against changes after the type gets its first subtype. This should be compatible with all GDExtensions, at least if they use the extension APIs as expected (with something like Godot's own _bind_methods called immediately after registration).
  • constant_map and enum_map are cached (like name_hierarchy) from constants and enums across all supertypes. This avoids the expensive walk through parents on lookup that ClassDB is doing in master.
    • self_constant_map and self_enum_map keep track of the declarations on the type itself, which is also sometimes relevant.
  • All maps are exposed as their actual type (const AHashMap &). ClassDB opted for a more verbose function-based interface, which I think is reinventing the wheel for interacting with hash maps. Internally, exposing the hash maps should give us more powerful tools for introspection.
  • EnumInfo is exposed, for similar reasons.
  • initialize_class is slightly better protected against multi-threaded shenanigans (with BinaryMutex). We don't expect more threads to access it, but it won't hurt to be sure about it.
  • constant_order is removed. It only existed in DEBUG (making the builds differ in behavior) and was duplicating entries in the return List.

@Ivorforce Ivorforce requested review from a team as code owners December 4, 2025 20:18
@Ivorforce Ivorforce requested a review from dsnopek December 4, 2025 20:18
@Ivorforce Ivorforce added this to the 4.x milestone Dec 4, 2025
@Ivorforce Ivorforce requested a review from a team as a code owner December 4, 2025 21:04
@Ivorforce Ivorforce force-pushed the gdtype-noms-enums branch 4 times, most recently from 419c717 to 4cdaa06 Compare December 4, 2025 22:12
Create caches across supertypes for faster lookup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants