-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Allow resizing Strings from GDExtension #79156
Allow resizing Strings from GDExtension #79156
Conversation
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.
Is it necessary to expose it directly, adding bind_string_method(resize, sarray("size"), varray());
to the variant_call.cpp
to expose existing method should work. The other string functions are in the interface due to pointer arguments, but in this case it's only int
size.
Why? It's exposed for the |
Ah, that's a good point! When I get a chance, I'll make a new PR that exposes it normally... |
I've open PR #79177 which exposes Given that |
As discussed in #79177 this seems to be the better way to handle this, assuming it doesn't suffer from the same mutability issues |
6bce190
to
136218d
Compare
Discussed at the GDExtension meeting, and we think it makes sense to add this, however, it would be good to add some additional warnings in the documentation about this being a potentially dangerous operation. |
136218d
to
e879009
Compare
Do you mean the online documentation? Or is there something you still want to add to the class references (and therefore need to update this PR)? |
We were talking about the docs in the comments in * Warning: This is an error-prone operation - only use it if there's no other
* efficient way to accomplish your goal. |
Thanks! |
This adds a new function to
gdextension_interface.h
to allow us to implementString::resize()
in godot-cpp per issue godotengine/godot-cpp#1141This is added to
gdextension_inteface.h
rather thanClassDB
, because we don't want scripting to have access to it.String::resize()
only makes sense if you can accessString::ptrw()
and directly modify the data at the pointer, which would be impossible from GDScript.This originally came up when trying to compile the text_server_adv module in Godot as a GDExtension. See: #77532