Reintroduce get_
prefixes (revert #477)
#487
Merged
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.
This reverts commit d36a144 from pull request #477.
Prepares some logic for overriding const-qualification, without yet enabling it.
Rationale:
Godot has non-typical APIs for Rust, following tradititional OOP style with lots of getters/setters.
My idea was that porting GDScript's property access to Rust might be more natural:
node.position
becomesnode.position()
. However, Godot's naming is much less consistent than I was initially assuming:size_flags_horizontal
property has{get/set}_h_size_flags
accessorsNode.get_path()
andNode.get_parent()
look like they should have properties, but don't; so.path()
and.parent()
would be a "wrong mapping".Node
bool propertyunique_name_in_owner
has{get/is}_unique_name_in_owner
.However,
{get/set}_scene_instance_load_placeholder
methods also return bool but have no property. So mapping would yieldis_unique_name_in_owner
andscene_instance_placeholder
. Stripping the "is_" for consistency would be confusing:unique_name_in_owner
sounds like it returns the name.Some
get_
methods take parameters.MeshDataTool
hasget_vertex_count()
andget_vertex_color(index)
-- the former would lose its prefix but the latter would not since it's not strictly a "getter" in the Rust sense._ex
model.Since some verbs are simultaneously nouns, this makes APIs slightly harder to understand in some cases.
scale()
queue()
(already causing a conflict)process_delta_time()
format()
modulate()
Exceptions and rules that depend on presence of properties make backwards compatibility harder.
get_
methodget_format()
which we map toformat()
, and then Godot adds another methodformat()
later, we have a conflictGetters are harder to discover.
get_
autocompletion in IDEsTLDR: There needs to be a complex ruleset, with lots of edge cases. In the end we may come up with something that looks nice and somewhat consistent when looking at the Rust part, but it will be too distant from the GDScript API, making porting between the two harder. We should probably embrace imperfections in the Godot API rather than trying to fight them.