Skip to content

Commit 00de032

Browse files
committed
Rename OnReady::node(...) -> from_node(...)
Also rename internal module files.
1 parent ab08cd2 commit 00de032

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

godot-core/src/obj/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ mod dyn_gd;
1616
mod gd;
1717
mod guards;
1818
mod instance_id;
19-
mod oneditor;
20-
mod onready;
19+
mod on_editor;
20+
mod on_ready;
2121
mod raw_gd;
2222
mod traits;
2323

@@ -28,8 +28,8 @@ pub use dyn_gd::DynGd;
2828
pub use gd::*;
2929
pub use guards::{BaseMut, BaseRef, DynGdMut, DynGdRef, GdMut, GdRef};
3030
pub use instance_id::*;
31-
pub use oneditor::*;
32-
pub use onready::*;
31+
pub use on_editor::*;
32+
pub use on_ready::*;
3333
pub use raw_gd::*;
3434
pub use traits::*;
3535

godot-core/src/obj/oneditor.rs renamed to godot-core/src/obj/on_editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::registry::property::{BuiltinExport, Export, Var};
2121
/// `OnEditor<T>` should always be used as a property, preferably in tandem with an `#[export]` or `#[var]`.
2222
/// Initializing `OnEditor` values via code before the first use is supported but should be limited to use cases involving builder or factory patterns.
2323
///
24-
/// [`Option<Gd<T>>`](std::option) and [`OnReady<Gd<T>>`](crate::obj::onready::OnReady) should be used for any other late initialization logic.
24+
/// [`Option<Gd<T>>`](std::option) and [`OnReady<Gd<T>>`](crate::obj::on_ready::OnReady) should be used for any other late initialization logic.
2525
///
2626
/// # Using `OnEditor<T>` with `Gd<T>` and `DynGd<T, D>`
2727
///

godot-core/src/obj/onready.rs renamed to godot-core/src/obj/on_ready.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::mem;
2222
/// `OnReady<T>` should always be used as a field. There are two modes to use it:
2323
///
2424
/// 1. **Automatic mode, using [`new()`](OnReady::new), [`from_base_fn()`](OnReady::from_base_fn) or
25-
/// [`node()`](OnReady::<Gd<T>>::node).**<br>
25+
/// [`node()`](OnReady::<Gd<T>>::from_node).**<br>
2626
/// Before `ready()` is called, all `OnReady` fields constructed with the above methods are automatically initialized,
2727
/// in the order of declaration. This means that you can safely access them in `ready()`.<br><br>
2828
/// 2. **Manual mode, using [`manual()`](Self::manual).**<br>
@@ -86,8 +86,10 @@ use std::mem;
8686
/// #[class(init, base = Node)]
8787
/// struct MyClass {
8888
/// base: Base<Node>,
89+
///
8990
/// #[init(node = "ChildPath")]
9091
/// auto: OnReady<Gd<Node2D>>,
92+
///
9193
/// #[init(val = OnReady::manual())]
9294
/// manual: OnReady<i32>,
9395
/// }
@@ -119,11 +121,16 @@ impl<T: GodotClass + Inherits<Node>> OnReady<Gd<T>> {
119121
///
120122
/// Note that the panic will only happen if and when the node enters the SceneTree for the first time
121123
/// (i.e.: it receives the `READY` notification).
122-
pub fn node(path: impl AsArg<NodePath>) -> Self {
124+
pub fn from_node(path: impl AsArg<NodePath>) -> Self {
123125
arg_into_owned!(path);
124126

125127
Self::from_base_fn(move |base| base.get_node_as(&path))
126128
}
129+
130+
#[deprecated = "Renamed to `from_node`."]
131+
pub fn node(path: impl AsArg<NodePath>) -> Self {
132+
Self::from_node(path)
133+
}
127134
}
128135

129136
impl<T> OnReady<T> {

godot-macros/src/class/derive_godot_class.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ fn parse_fields(
563563
errors.push(error!(
564564
parser.span(),
565565
"The key `node` in attribute #[init] requires field of type `OnReady<T>`\n\
566-
Help: The syntax #[init(node = \"NodePath\")] is equivalent to \
567-
#[init(val = OnReady::node(\"NodePath\"))], \
566+
Hint: the syntax #[init(node = \"NodePath\")] is equivalent to \
567+
#[init(val = OnReady::from_node(\"NodePath\"))], \
568568
which can only be assigned to fields of type `OnReady<T>`"
569569
));
570570
}
@@ -574,14 +574,14 @@ fn parse_fields(
574574
errors.push(error!(
575575
parser.span(),
576576
"The key `node` in attribute #[init] is mutually exclusive with the keys `default` and `val`\n\
577-
Help: The syntax #[init(node = \"NodePath\")] is equivalent to \
578-
#[init(val = OnReady::node(\"NodePath\"))], \
577+
Hint: the syntax #[init(node = \"NodePath\")] is equivalent to \
578+
#[init(val = OnReady::from_node(\"NodePath\"))], \
579579
both aren't allowed since they would override each other"
580580
));
581581
}
582582

583583
let default_val = if is_well_formed {
584-
quote! { OnReady::node(#node_path) }
584+
quote! { OnReady::from_node(#node_path) }
585585
} else {
586586
quote! { todo!() }
587587
};
@@ -607,7 +607,7 @@ fn parse_fields(
607607
is_well_formed = false;
608608
errors.push(error!(
609609
parser.span(),
610-
"The key `sentinel` in attribute #[init] is mutually exclusive with the keys `default` and `val`"
610+
"The key `sentinel` in attribute #[init] is mutually exclusive with the key `val`"
611611
));
612612
}
613613

0 commit comments

Comments
 (0)