-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Make mutable Script Instance functions reentrant #671
Make mutable Script Instance functions reentrant #671
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-671 |
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 the multiple iterations on this design! This looks quite clean for the user side 🧹 I'll already give some feedback, but will need to look at this deeper next time.
Not yet sure on the name SiMut
. It somehow makes sense if you look at GdMut
, however is it really equivalent? The former is never explicitly passed to user functions, it's always &mut T
.
Please avoid links to issues/PRs inside commit messages, as they create new backreferences in the mentioned issue on every iteration and clutter the conversation. Just mention "Closes #554" once in the PR description (not its title).
ad99845
to
41b6cb9
Compare
Rebased to fix #669, CI still red due to changes in this PR though. |
41b6cb9
to
dd2f0a1
Compare
dd2f0a1
to
898c5a5
Compare
After some discussion with @lilizoey, we were thinking it would be nice to avoid introducing a new Instead, we'd propose separate structs: // Existing:
struct BaseRef<'a, T: GodotClass> { ... }
struct BaseMut<'a, T: GodotClass> { ... }
// New (added by this PR):
struct ScriptBaseRef<'a, T: ScriptInstance> { ... }
struct ScriptBaseMut<'a, T: ScriptInstance> { ... } We were also thinking about type aliases, but they have the problem to be leaky abstractions (i.e. error messages still contain the raw types, you cannot specify bounds on aliases, etc). So distinct types are better, since it's very unlikely that the user wants to abstract over both. Distinct types also make the relations To avoid the duplication, you could use a declarative macro which substitutes some variables ( Also, |
@Bromeon thanks for this feedback. I will see that I incorporate it into the PR. |
582f56a
to
6b3c3c9
Compare
@Bromeon I updated the |
e9185cc
to
f5c1fdd
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 a lot for the update!
f5c1fdd
to
674c823
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 a lot! From my side only minor things left.
Here's btw the direct link to SiMut
docs from this PR:
https://godot-rust.github.io/docs/gdext/pr-671/godot/engine/struct.SiMut.html
b9244fd
to
4a55fc4
Compare
4a55fc4
to
e0b81d1
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 a lot for yet another great pull request that enhances ScriptInstance
functionality! 👍
Closes #554
Adds a ref guard around a
&mut T where T: ScriptInstance
for theScriptInstance
trait. This guard exposes an API to access the script instance base object, through which reentrant calls can be achieved.This also switches the script instance internals from a
RefCell
to aGdCell
and introduces a newWithBase
trait that can be shared betweenGodotClass
andScriptInstance
.I'm open to factor the
WithBase
introduction into a seperate PR if that is preferred.