-
-
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
Fix property/method filtering in extension_api_dump.cpp #64825
base: master
Are you sure you want to change the base?
Conversation
24c7976
to
7b1b4d5
Compare
7b1b4d5
to
e87725d
Compare
e87725d
to
b25e912
Compare
14204d1
to
a4d148f
Compare
rebased ;-) |
a4d148f
to
f0ee3de
Compare
BIND_ENUM_CONSTANT(LAYOUT_MODE_POSITION); | ||
BIND_ENUM_CONSTANT(LAYOUT_MODE_ANCHORS); | ||
BIND_ENUM_CONSTANT(LAYOUT_MODE_CONTAINER); | ||
BIND_ENUM_CONSTANT(LAYOUT_MODE_UNCONTROLLED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't be exposed, they have no use in scripting.
In principle, this makes sense to me! However, testing this and looking at the extension_api.json, I'm a little worried we'll end up with a messier API than we'd like. For example, looking at
Before unleashing all these new methods on the GDExtension bindings, I think we need to make sure they have the tools to do something nice with them. Or, maybe even clean-up the names of some of them? Or, remove some? (Like in the case of |
List of private methods used as property accessors as of
|
Yeah, I think exposing a targeted set of accessors (in a way that produces a friendly API) is a good way to go. |
I've rebased this PR and modified it to only expose the methods that are used as property accessors of non-hidden properties, as discussed in the comments above. I have also dropped commit f0ee3de since it doesn't seem wanted (#64825 (comment)). However, this means we now expose members like the GDExtension language bindings can workaround this by using godot/modules/mono/editor/bindings_generator.cpp Lines 3355 to 3358 in 6cd2876
Unfortunately, this means that if we ever expose the enum it could be a breaking change and I don't think our current compat checks handle this scenario. It's also weird to have members in The rebased branch can be found on cbb151a. And here's the before and after of the generated @touilleMan Are you able to continue working on this PR? Otherwise I'd be willing to take over for you. Footnotes
|
I'm not convinced that we should remove the filtering out of functions that start with an underscore. If there are functions that start with an underscore that we really want to be exposed, let's renamed them so they don't start with an underscore, and make sure that we like those functions being part of the public API, because:
But if we do decide to remove the filtering, at the very least, we're going to need some other way to bind a method that isn't exposed, because that is a use-case we still have. For example, with |
Can't the godot-cpp bindings generator generate these methods as private/protected? Or just not generate them (moving the filter to godot-cpp) since we have no use for them. My intention with "removing the filter" was just so that language bindings that need those methods to implement properties can use them. I didn't mean for these methods to be exposed in public API. That is to say, language bindings should probably avoid exposing methods that start with an underscore (thus moving the filter from Godot to the language bindings generator). For example, in the C# GDExtension bindings I have no intention of exposing these methods, I'll only use them to implement the properties that need them.
Right, but it's used by the That said, the |
Sure, it could. However, godot-cpp does actually need these methods too. We don't need them in order to make properties, because we don't have a good way to do properties in C++, but these filtered methods mean there are properties on the Godot side that godot-cpp can't set, and we should have the ability to set any property that any other language binding can set. So, what I really think we need to do, is go through the methods that start with an underscore, and determine which really should be part of the public API, and rename those. Then godot-cpp will have access to them under nice friendly names, and so will all the bindings that are going to use them as setters and getters for properties.
Yeah, I think this needs to be evaluated on a case-by-case basis, to determine which should really be public. |
Discussed at the GDExtension meeting and we agreed that the filtering should not be removed because there are cases that we don't want to expose the methods. If we want to expose some specific ones we should remove the underscore. Otherwise we would have to create another filter to remove the ones that we really don't want to expose. |
Doesn't this mean we should expose all of them? For example,
My intention is not to remove the filtering entirely, only for property accessors. I was also thinking that keeping the underscore could be used as a convention for language bindings to treat these methods as internal and avoid exposing them (only use them for property accessors). I thought this would be a good compromise for now, until we get around to decide whether to expose these methods properly or not. But since the team decided against it, let me take a look at the list of methods again and I'll see if I can find some low hanging fruits. |
Hm, exposing @vnen Should properties with For godot-cpp: We want all the property accessor methods to be available as normal public methods, except for the ones for internal properties that only exist for storage or the editor. So, almost all of them. :-) But if they're going to be normal public methods that we want folks to call, they shouldn't start with an underscore. |
That's what I thought you'd say, so here's the list: List
In some of these, the internal method seems to only exist to workaround the lack of overload support in ClassDB. For example, a method It's also worth noting that making a method a property accessor seems to hide it. For example, in In the case of And then, for some of these the corresponding property may have been intended to be internal (e.g.: |
fix #64429
Commit 24c79760e712b388a7bb12535f0e94db54742448 add a
is_property_accessor
attribute toextension_api.json
in order to simplify the "don't expose the property accessors in your binding" rule @reduz was talking about