Move enum registration from ClassDB / ClassInfo to GDType.
#113586
+194
−201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GDTypeto cover GDExtension types as well #106016Objecttypes, replacing (most of)ClassDBgodot-proposals#12323Now 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:
GDTypegetsinit_statewhich 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_methodscalled immediately after registration).constant_mapandenum_mapare cached (likename_hierarchy) from constants and enums across all supertypes. This avoids the expensive walk through parents on lookup thatClassDBis doing inmaster.self_constant_mapandself_enum_mapkeep track of the declarations on the type itself, which is also sometimes relevant.const AHashMap &).ClassDBopted 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.EnumInfois exposed, for similar reasons.initialize_classis slightly better protected against multi-threaded shenanigans (withBinaryMutex). We don't expect more threads to access it, but it won't hurt to be sure about it.constant_orderis removed. It only existed inDEBUG(making the builds differ in behavior) and was duplicating entries in the returnList.