-
-
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 functions for non-ptr style virtual calls in GDExtension #80671
Add functions for non-ptr style virtual calls in GDExtension #80671
Conversation
74e2c62
to
34cadca
Compare
Implementation to test godotengine/godot#80671 Fixes #11
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.
Thanks! Overall, I personally think this is a good approach.
This is something that will definitely need a bunch of discussion, though, perhaps at a meeting. It'd also be really great if we could get folks working on different language bindings (particularly those that were having trouble with the old way) to see if it would work for them.
46cd3b0
to
c5c0f40
Compare
Thanks, this is looking good! There's some CI failures from build errors in unrelated code. Rebasing on the latest |
42845da
to
7f6aedb
Compare
113f155
to
54f6e9d
Compare
This should now be ready. I've moved the new members into the GDExtensionClassCreationInfo2 struct. @AThousandShips I think I fixed the uninitialized ptr return variable. Can you take another look and see if it makes sense to you? |
Will take a look! |
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.
This is looking great to me! I only have the one naming related note.
I think this should get some more feedback from other GDExtension team members, though, perhaps discussing it at the next meeting.
Also, the CI is failing on building godot-cpp, but I don't think that we can fix that. :-/ It's a circular dependency: godot-cpp will need to be updated for this change, but godot-cpp depends on the Godot change.
I think this will come up again as we make further changes to the new structs before Godot 4.2. I'm not sure what we can do about that? We could maybe have the Godot CI use the 4.1
branch of godot-cpp instead of master
?
I think the code paths look good now and the CI errors have gone away |
54f6e9d
to
5e96819
Compare
Renamed the var, squashed and rebased on master. Should be good for review pending a decision on the godot-cpp build errors. |
PR #81238 should fix the CI. If/when it's merged, this one will just need a rebase. |
5e96819
to
db219b7
Compare
Rebased -- not sure if the CI error is something on my end? |
Renamed variables and rebased onto master. |
Ah, thanks for sharing how you're using this in your Dart bindings! If you're able to take advantage of the API in order to cache pointers to the underlying Dart functions, I think that's a solid justification for this approach. It allows calls to virtual functions defined in Dart to avoid a lookup on every call, just like with the C++ binding. (Personally, I don't want any language bindings forced to be "second class citizens" just because they can't easily generate new functions with C linkage)
Thanks! The suggestion from the meeting was to also rename the |
👍 I can do that, I was thinking it would be better to keep these changes localized to virtuals but I can change it in this PR if we want. |
254c1af
to
53553f0
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.
Thanks! This is looking great to me :-)
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.
Few things to change, mostly clarify the semantics a bit and guide the user to choose between old vs. new approach.
505bfed
to
95a3260
Compare
45d43b6
to
22db719
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.
Looking good to me!
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.
Two smaller things, see comments.
Side note, the names get_virtual_call_data
and call_virtual_with_data
are a bit difficult to memorize due to different order of the terms. Something like get_virtual_data
and call_virtual_data
might be a bit easier, although possibly less expressive. It's a tiny issue though and hardly relevant in practice, so if others are OK with the current naming, I won't bikeshed here 🙂
Yeah, while easier, it's not actually descriptive of what's happening. Although harder to memorize with the reordering, I do think the parallelism of "get_call_data" -> "call_with_data" is helpful. I'll rename the structure member to be more in line. |
22db719
to
cf87988
Compare
@Bromeon Took one more stab at the documentation. Let me know if that's clearer. |
Mostly good, this is a tiny bit ambiguous due to unclear "precedence":
Probably a comma would help a lot:
Other than that, good from my side, thanks for the adaptations! |
cf87988
to
ca506db
Compare
This adds two functions to `GDExtensionClassCreationInfo` that allow for developers to supply a generic virtual call function along with user data to be sent to that call. If `get_virutal_call_data_func` is not null, extensions call this function to get user data to pass to a supplied `call_virtual_with_data_func`. Both must be provided is one is provided. If `get_virtual_call_data_func` is null, Godot falls back to the old `get_virtual_func` logic. Fixes godotengine#63275 Co-authored-by: David Snopek <dsnopek@gmail.com>
ca506db
to
60851af
Compare
Comma added. Rebased on master. |
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.
Thanks a lot for your work! 👍
There seems to be a memory corruption in the Edit: re-running made it work. A bit flaky tests, but looks unrelated to this. |
Thanks! |
This adds two functions to
GDExtensionClassCreationInfo2
that allow for developers to supply a generic virtual call function along with user data to be sent to that call.If
get_virutal_call_data_func
is not null, extensions call this function to get user data to pass to a suppliedcall_virtual_func
. Both must be provided is one is provided.If
get_virtual_call_data_func
is null, Godot falls back to the oldget_virtual_func
logic.Fixes #63275