Skip to content

Commit c5b6ba2

Browse files
committed
Update all usages to #[init(val = ...)] syntax
1 parent ba20a8b commit c5b6ba2

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

godot-core/src/obj/onready.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ use std::mem;
8787
/// base: Base<Node>,
8888
/// #[init(node = "ChildPath")]
8989
/// auto: OnReady<Gd<Node2D>>,
90-
/// #[init(default = OnReady::manual())]
90+
/// #[init(val = OnReady::manual())]
9191
/// manual: OnReady<i32>,
9292
/// }
9393
///

godot-macros/src/class/derive_godot_class.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ fn parse_fields(
433433
field.default_val = Some(default);
434434
}
435435

436-
// #[init(default = expr)]
436+
// Deprecated #[init(default = expr)]
437437
if let Some(default) = parser.handle_expr("default")? {
438438
if field.default_val.is_some() {
439439
return bail!(
@@ -454,7 +454,7 @@ fn parse_fields(
454454
parser.span(),
455455
"The key `node` in attribute #[init] requires field of type `OnReady<T>`\n\
456456
Help: The syntax #[init(node = \"NodePath\")] is equivalent to \
457-
#[init(default = OnReady::node(\"NodePath\"))], \
457+
#[init(val = OnReady::node(\"NodePath\"))], \
458458
which can only be assigned to fields of type `OnReady<T>`"
459459
);
460460
}
@@ -464,7 +464,7 @@ fn parse_fields(
464464
parser.span(),
465465
"The key `node` in attribute #[init] is mutually exclusive with the key `default`\n\
466466
Help: The syntax #[init(node = \"NodePath\")] is equivalent to \
467-
#[init(default = OnReady::node(\"NodePath\"))], \
467+
#[init(val = OnReady::node(\"NodePath\"))], \
468468
both aren't allowed since they would override each other"
469469
);
470470
}

godot-macros/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ use crate::util::ident;
6767
/// ```
6868
///
6969
/// The generated `init` function will initialize each struct field (except the field of type `Base<T>`, if any)
70-
/// using `Default::default()`. To assign some other value, annotate the field with `#[init(default = ...)]`:
70+
/// using `Default::default()`. To assign some other value, annotate the field with `#[init(val = ...)]`:
7171
///
7272
/// ```
7373
/// # use godot_macros::GodotClass;
7474
/// #[derive(GodotClass)]
7575
/// #[class(init)]
7676
/// struct MyStruct {
77-
/// #[init(default = 42)]
77+
/// #[init(val = 42)]
7878
/// my_field: i64
7979
/// }
8080
/// ```
@@ -91,7 +91,7 @@ use crate::util::ident;
9191
/// # #[derive(GodotClass)]
9292
/// # #[class(init)]
9393
/// # struct MyStruct {
94-
/// #[init(default = (HashMap::<i64, i64>::new()))]
94+
/// #[init(val = (HashMap::<i64, i64>::new()))]
9595
/// // ^ parentheses needed due to this comma
9696
/// my_field: HashMap<i64, i64>,
9797
/// # }
@@ -544,7 +544,7 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
544544
///
545545
/// ## Generated `init`
546546
///
547-
/// This initializes the `Base<T>` field, and every other field with either `Default::default()` or the value specified in `#[init(default = ...)]`.
547+
/// This initializes the `Base<T>` field, and every other field with either `Default::default()` or the value specified in `#[init(val = ...)]`.
548548
///
549549
/// ```no_run
550550
/// # use godot::prelude::*;
@@ -553,7 +553,7 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
553553
/// pub struct MyNode {
554554
/// base: Base<Node>,
555555
///
556-
/// #[init(default = 42)]
556+
/// #[init(val = 42)]
557557
/// some_integer: i64,
558558
/// }
559559
/// ```

itest/rust/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn generate_property_template(inputs: &[Input]) -> PropertyTests {
421421

422422
let initializer = initializer
423423
.as_ref()
424-
.map(|init| quote! { #[init(default = #init)] });
424+
.map(|init| quote! { #[init(val = #init)] });
425425

426426
rust.extend([
427427
quote! {

itest/rust/src/object_tests/onready_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ struct InitWithNodeOrBase {
273273
base: Base<Node>,
274274
#[init(node = "child")]
275275
node: OnReady<Gd<Node>>,
276-
#[init(default = OnReady::from_base_fn(|b| b.get_name().to_string()))]
276+
#[init(val = OnReady::from_base_fn(|b| b.get_name().to_string()))]
277277
self_name: OnReady<String>,
278278
}
279279

itest/rust/src/register_tests/var_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ struct WithInitDefaults {
1414
default_int: i64,
1515

1616
#[var(get)]
17-
#[init(default = 42)]
17+
#[init(val = 42)]
1818
literal_int: i64,
1919

2020
#[var(get)]
21-
#[init(default = -42)]
21+
#[init(val = -42)]
2222
expr_int: i64,
2323
}

0 commit comments

Comments
 (0)