-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add methods to get argument count of methods #87680
Conversation
ea98400
to
1fc6ac2
Compare
Unsure if the various methods should error instead of silently returning |
Tested the Extension side in godot-cpp, will open a PR for that too but can confirm it works with the relevant changes |
I believe the GDExtension part is ready, but would appreciate some feedback on that CC @godotengine/gdextension Ditto for C# side CC @godotengine/dotnet |
Lot of details to work out but ready for review by the relevant teams, will add tests maybe tomorrow, at least in GDScript |
This may be the first time function arguments are acknowledged with method names. It has me pondering if this should be the standard across the whole class reference ("parameter" vs "argument") |
Not the first time, see Parameters is not used for this generally here as far as I can see |
5684891
to
35e9918
Compare
Re-added the GDExtension code, with new compatibility details, works well in my testing (but haven't tested the ScriptInstance extension part as godot-cpp doesn't utilize it) The godot-cpp PR has been updated accordingly, if decided to keep both changes in this one PR for the extension part I'll re-add the details to the original post, but will await more feedback from the extension team |
19fef5a
to
5fc2f9d
Compare
const Script *scr = Object::cast_to<Script>(this); | ||
while (scr != nullptr) { | ||
bool valid = false; | ||
int ret = scr->get_script_method_argument_count(p_method, &valid); | ||
if (valid) { | ||
if (r_is_valid) { | ||
*r_is_valid = true; | ||
} | ||
return ret; | ||
} | ||
scr = scr->get_base_script().ptr(); | ||
} |
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.
Just calling it on the script itself and letting ScriptInstance
handle the attached script as is done elsewhere
5fc2f9d
to
a185594
Compare
a185594
to
937a0e4
Compare
So this adds |
Went ahead and split off the script instance part and will open a dedicated PR for it to make the review easier so we can merge this safely without timing it (Once GitHub decides to update it's database, seems things are a bit broken at the moment) |
937a0e4
to
587a29a
Compare
587a29a
to
b510fb0
Compare
I think this could now be squashed and merged? |
As long as the C# side looks good I think we're good, I'll squash tomorrow if there's no questions (I have to go to bed anyway) |
I'll squash it up soon and we can give it a spin, in my testing the c# code worked and was based on suggestions by raulsntos, so I feel confident in going forward, if there's any questions I can always split the C# off and leave the placeholders |
b510fb0
to
7b7da44
Compare
Added to: * `Callable`s * `Object`s * `ClassDB` * `Script(Instance)`s
7b7da44
to
59bcc28
Compare
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.
The C# changes look good to me, thanks!
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.
The implementation looks fine overall.
Thanks! |
Thank you! Will improve the docs and fixup the followup PR tomorrow |
Added to:
Callable
sObject
ClassDB
Script(Instance)
sTodo:
Help with how to do this in C# would be very welcome, I have some ideas but I'm not very familiar with the C# internals
To confirm the godot-cpp side, see:
Callable
s godot-cpp#1375Might split off the extension part into a separate PR if desired