-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignoring class methods with underscore prefix cause issue with some properties #64429
Comments
The |
@Splizard Thanks for the feedback I have the felling this "underscore for virtual method" is very error prone given the is no unittests preventing us to do a bad naming. So we should not rely in that to filter out methods. On top of that the comment in |
A leading underscore is typically used for one of two meanings:
|
Don't we need a dedicated flag for this kind of job ? (just like we have the virtual flag as you say) Without a specific is_private = F.name.begins_with("_") && !(F.flags & METHOD_FLAG_VIRTUAL) This seems error prone and hard to understand :/ |
We could maybe add one, yeah. This kind of check is indeed done e.g. in
Maybe |
The general rule is that, anything with starts with '_' is either private or protected. Virtual functions are protected, neither can be accessed from outside the class. If you are creating a binder, the logic should be:
|
So that's why we can't call super._process(delta) from GDScript that extends GDExtension class? But in many other engines, like Unreal, it's commonly used and can be very useful. |
No, I think that's unrelated. The problem is that we don't really have virtual methods defined in GDExtension yet, and |
Godot version
4.0-rc13
System information
n/a
Issue description
Currently the
extension_api.json
generation code consider in class methods/properties starting with an underscore as hidden and ignore it:godot/core/extension/extension_api_dump.cpp
Lines 748 to 749 in eda6800
godot/core/extension/extension_api_dump.cpp
Lines 846 to 848 in eda6800
However _ as a prefix is not always used to indicate a private method, for instance considering the
anchor_*
properties inControl
:godot/scene/gui/control.cpp
Lines 3355 to 3358 in eda6800
Those properties use
_set_anchor
as setter, this is becauseControl
also expose aset_anchor
method (this one behind higher level designed to be directly used)godot/scene/gui/control.cpp
Line 3189 in eda6800
So my guess is we should stop considering the underscore prefix as a private marker (and I'm saying this as a Python lover 😄 ) and just dump all methods/properties.
As a matter of fact I even wonder if there is such thing as class method declared in ClassDB that should be private (the whole point of GDExtension being to provide to external tools the same access GDScript have)
Steps to reproduce
n/a
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: