Skip to content

Commit 1d2b7ce

Browse files
authored
Merge pull request #586 from godot-rust/qol/string-name-ord
Add `StringName::transient_ord()`
2 parents b91dd31 + bcc1e9b commit 1d2b7ce

File tree

22 files changed

+270
-154
lines changed

22 files changed

+270
-154
lines changed

godot-codegen/src/models/domain.rs

-12
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,6 @@ pub trait Function: fmt::Display {
331331
}
332332
}
333333

334-
#[deprecated]
335-
struct FnSignature<'a> {
336-
function_name: &'a str,
337-
surrounding_class: Option<&'a TyName>, // None if global function
338-
is_private: bool,
339-
is_virtual: bool,
340-
is_vararg: bool,
341-
qualifier: FnQualifier,
342-
params: Vec<FnParam>,
343-
return_value: FnReturn,
344-
}
345-
346334
// ----------------------------------------------------------------------------------------------------------------------------------------------
347335

348336
pub struct UtilityFunction {

godot-codegen/src/models/domain_mapping.rs

-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ impl BuiltinMethod {
343343
.as_deref()
344344
.map(JsonMethodReturn::from_type_no_meta);
345345

346-
// use BuiltinMethod, but adopt values from above FnSignature expr
347346
Some(Self {
348347
common: FunctionCommon {
349348
// Fill in these fields

godot-core/src/builtin/callable.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,16 @@ impl Callable {
271271

272272
impl_builtin_traits! {
273273
for Callable {
274-
// Currently no Default::default() to encourage explicit valid initialization.
275-
//Default => callable_construct_default;
274+
// Default is absent by design, to encourage explicit valid initialization.
275+
276+
Clone => callable_construct_copy;
277+
Drop => callable_destroy;
276278

277279
// Equality for custom callables depend on the equality implementation of that custom callable.
278280
// So we cannot implement `Eq` here and be confident equality will be total for all future custom callables.
279-
// Godot does not define a less-than operator, so there is no `PartialOrd`.
280281
PartialEq => callable_operator_equal;
281-
Clone => callable_construct_copy;
282-
Drop => callable_destroy;
282+
// Godot does not define a less-than operator, so there is no `PartialOrd`.
283+
// Hash could be added, but without Eq it's not that useful; wait for actual use cases.
283284
}
284285
}
285286

godot-core/src/builtin/dictionary.rs

+3
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ impl_builtin_traits! {
297297
Default => dictionary_construct_default;
298298
Drop => dictionary_destroy;
299299
PartialEq => dictionary_operator_equal;
300+
// No < operator for dictionaries.
301+
// Hash could be added, but without Eq it's not that useful.
300302
}
301303
}
302304

@@ -305,6 +307,7 @@ impl fmt::Debug for Dictionary {
305307
write!(f, "{:?}", self.to_variant().stringify())
306308
}
307309
}
310+
308311
impl fmt::Display for Dictionary {
309312
/// Formats `Dictionary` to match Godot's string representation.
310313
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

godot-core/src/builtin/mod.rs

+35-20
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,35 @@
3636
// Re-export macros.
3737
pub use crate::{array, dict, real, reals, varray};
3838

39-
pub use aabb::*;
40-
pub use array_inner::{Array, VariantArray};
41-
pub use basis::*;
42-
pub use callable::*;
43-
pub use color::*;
44-
pub use dictionary_inner::Dictionary;
45-
pub use packed_array::*;
46-
pub use plane::*;
47-
pub use projection::*;
48-
pub use quaternion::*;
49-
pub use real_inner::*;
50-
pub use rect2::*;
51-
pub use rect2i::*;
52-
pub use rid::*;
53-
pub use signal::*;
54-
pub use string::*;
55-
pub use transform2d::*;
56-
pub use transform3d::*;
57-
pub use variant::*;
58-
pub use vectors::*;
39+
#[doc(hidden)]
40+
pub mod __prelude_reexport {
41+
use super::*;
42+
43+
pub use aabb::*;
44+
pub use array_inner::{Array, VariantArray};
45+
pub use basis::*;
46+
pub use callable::*;
47+
pub use color::*;
48+
pub use dictionary_inner::Dictionary;
49+
pub use packed_array::*;
50+
pub use plane::*;
51+
pub use projection::*;
52+
pub use quaternion::*;
53+
pub use real_inner::*;
54+
pub use rect2::*;
55+
pub use rect2i::*;
56+
pub use rid::*;
57+
pub use signal::*;
58+
pub use string::{GString, NodePath, StringName};
59+
pub use transform2d::*;
60+
pub use transform3d::*;
61+
pub use variant::*;
62+
pub use vectors::*;
63+
64+
pub use crate::{array, dict, real, reals, varray};
65+
}
66+
67+
pub use __prelude_reexport::*;
5968

6069
/// Meta-information about variant types, properties and class names.
6170
pub mod meta;
@@ -73,6 +82,11 @@ pub mod dictionary {
7382
pub use super::dictionary_inner::{Iter, Keys, TypedIter, TypedKeys};
7483
}
7584

85+
/// Specialized types related to Godot's various string implementations.
86+
pub mod strings {
87+
pub use super::string::TransientStringNameOrd;
88+
}
89+
7690
// ----------------------------------------------------------------------------------------------------------------------------------------------
7791
// Implementation
7892

@@ -145,6 +159,7 @@ pub enum RectSide {
145159
}
146160

147161
// ----------------------------------------------------------------------------------------------------------------------------------------------
162+
// #[test] utils for serde
148163

149164
#[cfg(all(test, feature = "serde"))]
150165
pub(crate) mod test_utils {

godot-core/src/builtin/plane.rs

+3
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ impl std::fmt::Display for Plane {
299299
}
300300
}
301301

302+
// ----------------------------------------------------------------------------------------------------------------------------------------------
303+
// Tests
304+
302305
#[cfg(test)]
303306
mod test {
304307
use crate::assert_eq_approx;

0 commit comments

Comments
 (0)