Skip to content

Commit 46f94f6

Browse files
authored
Merge pull request #478 from godot-rust/qol/rename-godot-string
Rename `GodotString` -> `GString`
2 parents 31134a7 + 5df2030 commit 46f94f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+267
-242
lines changed

examples/dodge-the-creeps/rust/src/hud.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl Hud {
1414
fn start_game();
1515

1616
#[func]
17-
pub fn show_message(&self, text: GodotString) {
17+
pub fn show_message(&self, text: GString) {
1818
let mut message_label = self.base.get_node_as::<Label>("MessageLabel");
1919
message_label.set_text(text);
2020
message_label.show();

godot-codegen/src/class_generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ fn special_virtual_methods(notification_enum_name: &Ident) -> TokenStream {
18511851
///
18521852
/// Override this method to define how the instance is represented as a string.
18531853
/// Used by `impl Display for Gd<T>`, as well as `str()` and `print()` in GDScript.
1854-
fn to_string(&self) -> crate::builtin::GodotString {
1854+
fn to_string(&self) -> crate::builtin::GString {
18551855
unimplemented!()
18561856
}
18571857

godot-codegen/src/util.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ fn to_hardcoded_rust_ident(full_ty: &GodotTy) -> Option<&str> {
558558

559559
// Others
560560
("bool", None) => "bool",
561-
("String", None) => "GodotString",
561+
("String", None) => "GString",
562562
("Array", None) => "VariantArray",
563563

564564
// Types needed for native structures mapping
@@ -832,11 +832,11 @@ fn to_rust_expr_inner(expr: &str, ty: &RustTy, is_inner: bool) -> TokenStream {
832832
} else {
833833
match ty {
834834
RustTy::BuiltinIdent(ident)
835-
if ident == "GodotString" || ident == "StringName" || ident == "NodePath" =>
835+
if ident == "GString" || ident == "StringName" || ident == "NodePath" =>
836836
{
837837
quote! { #ident::from(#expr) }
838838
}
839-
_ => quote! { GodotString::from(#expr) },
839+
_ => quote! { GString::from(#expr) },
840840
//_ => panic!("cannot map string literal \"{expr}\" to type {ty:?}"),
841841
}
842842
};
@@ -861,7 +861,7 @@ fn to_rust_expr_inner(expr: &str, ty: &RustTy, is_inner: bool) -> TokenStream {
861861

862862
let (rust_ty, ctor) = match godot_ty {
863863
"NodePath" => ("NodePath", "from"),
864-
"String" => ("GodotString", "from"),
864+
"String" => ("GString", "from"),
865865
"StringName" => ("StringName", "from"),
866866
"RID" => ("Rid", "default"),
867867
"Rect2" => ("Rect2", "from_components"),
@@ -955,7 +955,7 @@ fn gdscript_to_rust_expr() {
955955
// };
956956
// let ty_object = Some(&ty_object);
957957

958-
let ty_string = RustTy::BuiltinIdent(ident("GodotString"));
958+
let ty_string = RustTy::BuiltinIdent(ident("GString"));
959959
let ty_string = Some(&ty_string);
960960

961961
let ty_stringname = RustTy::BuiltinIdent(ident("StringName"));
@@ -1009,12 +1009,12 @@ fn gdscript_to_rust_expr() {
10091009
//("null", ty_object, quote! { None }),
10101010

10111011
// String-likes
1012-
("\" \"", None, quote! { GodotString::from(" ") }),
1013-
("\"{_}\"", None, quote! { GodotString::from("{_}") }),
1012+
("\" \"", None, quote! { GString::from(" ") }),
1013+
("\"{_}\"", None, quote! { GString::from("{_}") }),
10141014
("&\"text\"", None, quote! { StringName::from("text") }),
10151015
("^\"text\"", None, quote! { NodePath::from("text") }),
10161016

1017-
("\"text\"", ty_string, quote! { GodotString::from("text") }),
1017+
("\"text\"", ty_string, quote! { GString::from("text") }),
10181018
("\"text\"", ty_stringname, quote! { StringName::from("text") }),
10191019
("\"text\"", ty_nodepath, quote! { NodePath::from("text") }),
10201020

godot-core/src/builtin/callable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Callable {
8989
pub fn from_fn<F, S>(name: S, rust_function: F) -> Self
9090
where
9191
F: 'static + Send + Sync + FnMut(&[&Variant]) -> Result<Variant, ()>,
92-
S: Into<crate::builtin::GodotString>,
92+
S: Into<crate::builtin::GString>,
9393
{
9494
let userdata = CallableUserdata {
9595
inner: FnWrapper {
@@ -339,7 +339,7 @@ pub use custom_callable::RustCallable;
339339
#[cfg(since_api = "4.2")]
340340
mod custom_callable {
341341
use super::*;
342-
use crate::builtin::GodotString;
342+
use crate::builtin::GString;
343343
use std::hash::Hash;
344344

345345
pub struct CallableUserdata<T> {
@@ -357,7 +357,7 @@ mod custom_callable {
357357

358358
pub(crate) struct FnWrapper<F> {
359359
pub(crate) rust_function: F,
360-
pub(crate) name: GodotString,
360+
pub(crate) name: GString,
361361
}
362362

363363
/// Represents a custom callable object defined in Rust.
@@ -439,7 +439,7 @@ mod custom_callable {
439439
r_out: sys::GDExtensionStringPtr,
440440
) {
441441
let c: &T = CallableUserdata::inner_from_raw(callable_userdata);
442-
let s = crate::builtin::GodotString::from(c.to_string());
442+
let s = crate::builtin::GString::from(c.to_string());
443443

444444
s.move_string_ptr(r_out);
445445
*r_is_valid = true as sys::GDExtensionBool;

godot-core/src/builtin/color.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use crate::builtin::inner::InnerColor;
88
use crate::builtin::math::ApproxEq;
9-
use crate::builtin::GodotString;
9+
use crate::builtin::GString;
1010

1111
use godot_ffi as sys;
1212
use sys::{ffi_methods, GodotFfi};
@@ -104,7 +104,7 @@ impl Color {
104104
/// - `#RGB` and `RGB`. Equivalent to `#RRGGBBff`.
105105
///
106106
/// Returns `None` if the format is invalid.
107-
pub fn from_html<S: Into<GodotString>>(html: S) -> Option<Self> {
107+
pub fn from_html<S: Into<GString>>(html: S) -> Option<Self> {
108108
let html = html.into();
109109
InnerColor::html_is_valid(html.clone()).then(|| InnerColor::html(html))
110110
}
@@ -123,7 +123,7 @@ impl Color {
123123
///
124124
/// [color_constants]: https://docs.godotengine.org/en/latest/classes/class_color.html#constants
125125
/// [cheat_sheet]: https://raw.githubusercontent.com/godotengine/godot-docs/master/img/color_constants.png
126-
pub fn from_string<S: Into<GodotString>>(string: S) -> Option<Self> {
126+
pub fn from_string<S: Into<GString>>(string: S) -> Option<Self> {
127127
let color = InnerColor::from_string(
128128
string.into(),
129129
Self::from_rgba(f32::NAN, f32::NAN, f32::NAN, f32::NAN),
@@ -282,13 +282,13 @@ impl Color {
282282

283283
/// Returns the HTML color code representation of this color, as 8 lowercase hex digits in the
284284
/// order `RRGGBBAA`, without the `#` prefix.
285-
pub fn to_html(self) -> GodotString {
285+
pub fn to_html(self) -> GString {
286286
self.as_inner().to_html(true)
287287
}
288288

289289
/// Returns the HTML color code representation of this color, as 6 lowercase hex digits in the
290290
/// order `RRGGBB`, without the `#` prefix. The alpha channel is ignored.
291-
pub fn to_html_without_alpha(self) -> GodotString {
291+
pub fn to_html_without_alpha(self) -> GString {
292292
self.as_inner().to_html(false)
293293
}
294294

godot-core/src/builtin/meta/class_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl ClassName {
6060
self.c_str.to_str().unwrap()
6161
}
6262

63-
/// Converts the class name to a GodotString.
64-
pub fn to_godot_string(&self) -> GodotString {
63+
/// Converts the class name to a GString.
64+
pub fn to_godot_string(&self) -> GString {
6565
self.with_string_name(|s| s.into())
6666
}
6767

godot-core/src/builtin/meta/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ mod sealed {
5454
impl Sealed for Vector4i {}
5555
impl Sealed for Quaternion {}
5656
impl Sealed for Color {}
57-
impl Sealed for GodotString {}
57+
impl Sealed for GString {}
5858
impl Sealed for StringName {}
5959
impl Sealed for NodePath {}
6060
impl Sealed for PackedByteArray {}
@@ -147,7 +147,7 @@ pub trait GodotType: GodotConvert<Via = Self> + ToGodot + FromGodot + sealed::Se
147147
class_name: Self::class_name(),
148148
property_name: StringName::from(property_name),
149149
hint: global::PropertyHint::PROPERTY_HINT_NONE,
150-
hint_string: GodotString::new(),
150+
hint_string: GString::new(),
151151
usage: global::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT,
152152
}
153153
}
@@ -238,7 +238,7 @@ pub struct PropertyInfo {
238238
pub class_name: ClassName,
239239
pub property_name: StringName,
240240
pub hint: global::PropertyHint,
241-
pub hint_string: GodotString,
241+
pub hint_string: GString,
242242
pub usage: global::PropertyUsageFlags,
243243
}
244244

godot-core/src/builtin/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
*/
66

7-
//! Built-in types like `Vector2`, `GodotString` and `Variant`.
7+
//! Built-in types like `Vector2`, `GString` and `Variant`.
88
//!
99
//! # Background on the design of vector algebra types
1010
//!

godot-core/src/builtin/packed_array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ macro_rules! impl_packed_array {
9696
// SAFETY: Packed arrays are stored contiguously in memory, so we can use
9797
// pointer arithmetic instead of going through `$operator_index_const` for
9898
// every index.
99-
// Note that we do need to use `.clone()` because `GodotString` is refcounted;
99+
// Note that we do need to use `.clone()` because `GString` is refcounted;
100100
// we can't just do a memcpy.
101101
let element = unsafe { (*ptr.offset(offset)).clone() };
102102
vec.push(element);
@@ -398,7 +398,7 @@ macro_rules! impl_packed_array {
398398
for (i, element) in slice.iter().enumerate() {
399399
// SAFETY: The array contains exactly `len` elements, stored contiguously in memory.
400400
unsafe {
401-
// `GodotString` does not implement `Copy` so we have to call `.clone()`
401+
// `GString` does not implement `Copy` so we have to call `.clone()`
402402
// here.
403403
*ptr.offset(to_isize(i)) = element.clone();
404404
}
@@ -567,10 +567,10 @@ impl_packed_array!(
567567

568568
impl_packed_array!(
569569
type_name: PackedStringArray,
570-
element_type: GodotString,
570+
element_type: GString,
571571
opaque_type: OpaquePackedStringArray,
572572
inner_type: InnerPackedStringArray,
573-
argument_type: GodotString,
573+
argument_type: GString,
574574
return_type: __GdextString,
575575
from_array: packed_string_array_from_array,
576576
operator_index: packed_string_array_operator_index,

0 commit comments

Comments
 (0)