Improve to_string() and add it to Resource#94047
Conversation
scene/main/node.cpp
Outdated
There was a problem hiding this comment.
I wonder why this exists. No other class has a guard in this method.
There was a problem hiding this comment.
In all likelihood Reduz copied and pasted it back when he wanted to make Nodes as thread-safe as possible when implementing Thread Groups.
fire
left a comment
There was a problem hiding this comment.
I think this is a good idea to unify and let everything have a human readable string instead of to string fallback.
44f8367 to
a828dc9
Compare
|
Always have been iffy on the overly verbose numerical value appended to Object. So seeing this overly extended result for |
|
Thanks! This PR would also help to solve a problem in GDExtension, where if you make a class that descends from any class that has a This needs a rebase, but otherwise looks good to me! |
f418344 to
a3b5c9f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
a3b5c9f to
e6783db
Compare
Alex2782
left a comment
There was a problem hiding this comment.
The changes in the platform/android/ files look OK to me; shouldn't be critical (not tested).
dsnopek
left a comment
There was a problem hiding this comment.
Thanks! This looks good to me :-)
There was a problem hiding this comment.
Makes sense to me. This matches other virtual implementations that scripts and extensions can override.
I think what @dsnopek said should also apply to scripts; this should allow scripts to override to_string(), even when they don't inherit from Object or Node.
The only change in behavior I'm seeing is that Node::to_string will no longer use a thread guard until the call is deferred to Node::_to_string. However, I don't think this is a huge problem since it's mostly a guard to protect the user from themselves. But let me know if you disagree!
|
Thanks! |
Object and Node had some duplicate code in
to_string()method. I unified it by renaming the virtualto_string()to_to_string(). The base method runs the repeated code and falls back to the new method.This means that anything can now override the default
to_string()in its script. tbh the code looks like something that should be handled by GDVirtual.I also added custom
_to_string()to Resource, which returnsResource Name (path):Object, e.g.It allows to identify stringified resources.