Skip to content

Commit e3644a0

Browse files
authored
Merge pull request #555 from godot-rust/qol/rename-register
Rename `bind` -> `register`; improve docs
2 parents b8f6f15 + 4c51ed4 commit e3644a0

38 files changed

+181
-135
lines changed

godot-core/src/builtin/aabb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl Aabb {
385385
impl std::fmt::Display for Aabb {
386386
/// Formats `Aabb` to match godot's display style.
387387
///
388-
/// Example:
388+
/// # Example
389389
/// ```
390390
/// use godot::prelude::*;
391391
/// let aabb = Aabb::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0));

godot-core/src/builtin/array.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use godot_ffi as sys;
99

1010
use crate::builtin::*;
11-
use crate::property::{Export, Property, PropertyHintInfo, TypeStringHint};
11+
use crate::property::{Export, PropertyHintInfo, TypeStringHint, Var};
1212
use std::fmt;
1313
use std::marker::PhantomData;
1414
use sys::{ffi_methods, interface_fn, GodotFfi};
@@ -677,7 +677,7 @@ impl<T: GodotType> fmt::Debug for Array<T> {
677677
impl<T: GodotType + fmt::Display> fmt::Display for Array<T> {
678678
/// Formats `Array` to match Godot's string representation.
679679
///
680-
/// Example:
680+
/// # Example
681681
/// ```no_run
682682
/// # use godot::prelude::*;
683683
/// let a = array![1,2,3,4];
@@ -729,7 +729,7 @@ impl TypeStringHint for VariantArray {
729729
}
730730
}
731731

732-
impl<T: GodotType> Property for Array<T> {
732+
impl<T: GodotType> Var for Array<T> {
733733
type Intermediate = Self;
734734

735735
fn get_property(&self) -> Self::Intermediate {
@@ -985,13 +985,16 @@ impl<T: GodotType> PartialOrd for Array<T> {
985985
///
986986
/// The type of the array is inferred from the arguments.
987987
///
988-
/// Example:
988+
/// # Example
989989
/// ```no_run
990990
/// # use godot::prelude::*;
991991
/// let arr = array![3, 1, 4]; // Array<i32>
992992
/// ```
993993
///
994+
/// # See also
994995
/// To create an `Array` of variants, see the [`varray!`] macro.
996+
///
997+
/// For dictionaries, a similar macro [`dict!`] exists.
995998
#[macro_export]
996999
macro_rules! array {
9971000
($($elements:expr),* $(,)?) => {
@@ -1007,15 +1010,18 @@ macro_rules! array {
10071010

10081011
/// Constructs [`VariantArray`] literals, similar to Rust's standard `vec!` macro.
10091012
///
1010-
/// The type of the array is always [`Variant`].
1013+
/// The type of the array elements is always [`Variant`].
10111014
///
1012-
/// Example:
1015+
/// # Example
10131016
/// ```no_run
10141017
/// # use godot::prelude::*;
10151018
/// let arr: VariantArray = varray![42_i64, "hello", true];
10161019
/// ```
10171020
///
1021+
/// # See also
10181022
/// To create a typed `Array` with a single element type, see the [`array!`] macro.
1023+
///
1024+
/// For dictionaries, a similar macro [`dict!`] exists.
10191025
#[macro_export]
10201026
macro_rules! varray {
10211027
// Note: use to_variant() and not Variant::from(), as that works with both references and values

godot-core/src/builtin/color.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ fn to_be_words(mut u: u64) -> [u16; 4] {
520520
impl std::fmt::Display for Color {
521521
/// Formats `Color` to match Godot's string representation.
522522
///
523-
/// Example:
523+
/// # Example
524524
/// ```
525525
/// use godot::prelude::*;
526526
/// let color = Color::from_rgba(1.0,1.0,1.0,1.0);

godot-core/src/builtin/dictionary.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
use godot_ffi as sys;
99

1010
use crate::builtin::meta::{FromGodot, ToGodot};
11-
use crate::builtin::{inner, Variant};
12-
use crate::property::{Export, Property, PropertyHintInfo, TypeStringHint};
13-
use std::fmt;
11+
use crate::builtin::{inner, Variant, VariantArray};
12+
use crate::property::{Export, PropertyHintInfo, TypeStringHint, Var};
1413
use std::marker::PhantomData;
15-
use std::ptr::addr_of_mut;
14+
use std::{fmt, ptr};
1615
use sys::types::OpaqueDictionary;
17-
use sys::{ffi_methods, interface_fn, AsUninit, GodotFfi, VariantType};
16+
use sys::{ffi_methods, interface_fn, AsUninit, GodotFfi};
1817

1918
use super::meta::impl_godot_as_self;
20-
use super::VariantArray;
2119

2220
/// Godot's `Dictionary` type.
2321
///
@@ -339,7 +337,7 @@ impl Clone for Dictionary {
339337
}
340338
}
341339

342-
impl Property for Dictionary {
340+
impl Var for Dictionary {
343341
type Intermediate = Self;
344342

345343
fn get_property(&self) -> Self::Intermediate {
@@ -353,7 +351,7 @@ impl Property for Dictionary {
353351

354352
impl TypeStringHint for Dictionary {
355353
fn type_string() -> String {
356-
format!("{}:Dictionary", VariantType::Dictionary as i32)
354+
format!("{}:Dictionary", sys::VariantType::Dictionary as i32)
357355
}
358356
}
359357

@@ -484,7 +482,7 @@ impl<'a> DictionaryIter<'a> {
484482
iter_fn(
485483
dictionary.var_sys(),
486484
next_value.var_sys(),
487-
addr_of_mut!(valid_u8),
485+
ptr::addr_of_mut!(valid_u8),
488486
)
489487
};
490488
let valid = super::u8_to_bool(valid_u8);
@@ -634,7 +632,7 @@ impl<'a, K: FromGodot> Iterator for TypedKeys<'a, K> {
634632
/// Any value can be used as a key, but to use an expression you need to surround it
635633
/// in `()` or `{}`.
636634
///
637-
/// Example:
635+
/// # Example
638636
/// ```no_run
639637
/// use godot::builtin::{dict, Variant};
640638
///
@@ -646,6 +644,10 @@ impl<'a, K: FromGodot> Iterator for TypedKeys<'a, K> {
646644
/// (1 + 2): "final",
647645
/// };
648646
/// ```
647+
///
648+
/// # See also
649+
///
650+
/// For arrays, similar macros [`array!`][macro@crate::builtin::array] and [`varray!`][macro@crate::builtin::varray] exist.
649651
#[macro_export]
650652
macro_rules! dict {
651653
($($key:tt: $value:expr),* $(,)?) => {

godot-core/src/builtin/plane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl ApproxEq for Plane {
288288
impl std::fmt::Display for Plane {
289289
/// Formats `Plane` to match Godot's string representation.
290290
///
291-
/// Example:
291+
/// # Example
292292
/// ```
293293
/// use godot::prelude::*;
294294
/// let plane = Plane::new(Vector3::new(1.0, 0.0, 0.0), 1.0);

godot-core/src/builtin/projection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ pub enum ProjectionEye {
581581
impl std::fmt::Display for Projection {
582582
/// Formats `Projection` to match Godot's string representation.
583583
///
584-
/// Example:
584+
/// # Example
585585
/// ```
586586
/// use godot::prelude::*;
587587
/// let proj = Projection::new([

godot-core/src/builtin/real.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8+
/// Convenience conversion between `real` and `f32`/`f64`.
9+
///
810
/// Clippy often complains if you do `f as f64` when `f` is already an `f64`. This trait exists to make it easy to
911
/// convert between the different reals and floats without a lot of allowing clippy lints for your code.
1012
pub trait RealConv {
@@ -200,6 +202,8 @@ macro_rules! real {
200202

201203
/// Array of reals.
202204
///
205+
/// The expression has type `[real; N]` where `N` is the number of elements in the array.
206+
///
203207
/// # Example
204208
/// ```
205209
/// use godot_core::builtin::{real, reals};

godot-core/src/builtin/rect2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl ApproxEq for Rect2 {
278278
impl std::fmt::Display for Rect2 {
279279
/// Formats `Rect2` to match Godot's string representation.
280280
///
281-
/// Example:
281+
/// # Example
282282
/// ```
283283
/// use godot::prelude::*;
284284
/// let rect = Rect2::new(Vector2::new(0.0, 0.0), Vector2::new(1.0, 1.0));

godot-core/src/builtin/rect2i.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl_godot_as_self!(Rect2i);
279279
impl std::fmt::Display for Rect2i {
280280
/// Formats `Rect2i` to match Godot's string representation.
281281
///
282-
/// Example:
282+
/// # Example
283283
/// ```
284284
/// use godot::prelude::*;
285285
/// let rect = Rect2i::new(Vector2i::new(0, 0), Vector2i::new(1, 1));

godot-core/src/builtin/rid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Rid {
101101
impl std::fmt::Display for Rid {
102102
/// Formats `Rid` to match Godot's string representation.
103103
///
104-
/// Example:
104+
/// # Example
105105
/// ```
106106
/// use godot::prelude::*;
107107
/// let id = Rid::new(1);

godot-core/src/log.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8+
//! Printing and logging functionality.
9+
810
#[macro_export]
911
#[doc(hidden)]
1012
macro_rules! inner_godot_msg {
@@ -33,7 +35,7 @@ macro_rules! inner_godot_msg {
3335

3436
/// Pushes a warning message to Godot's built-in debugger and to the OS terminal.
3537
///
36-
/// _Godot equivalent: @GlobalScope.push_warning()_
38+
/// _Godot equivalent: [`@GlobalScope.push_warning()`](https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-push-warning)_.
3739
#[macro_export]
3840
macro_rules! godot_warn {
3941
($fmt:literal $(, $args:expr)* $(,)?) => {
@@ -43,14 +45,15 @@ macro_rules! godot_warn {
4345

4446
/// Pushes an error message to Godot's built-in debugger and to the OS terminal.
4547
///
46-
/// _Godot equivalent: @GlobalScope.push_error()_
48+
/// _Godot equivalent: [`@GlobalScope.push_error()`](https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-push-error)_.
4749
#[macro_export]
4850
macro_rules! godot_error {
4951
($fmt:literal $(, $args:expr)* $(,)?) => {
5052
$crate::inner_godot_msg!(print_error; $fmt $(, $args)*);
5153
};
5254
}
5355

56+
/// Logs a script error to Godot's built-in debugger and to the OS terminal.
5457
#[macro_export]
5558
macro_rules! godot_script_error {
5659
($fmt:literal $(, $args:expr)* $(,)?) => {
@@ -60,7 +63,7 @@ macro_rules! godot_script_error {
6063

6164
/// Prints to the Godot console.
6265
///
63-
/// _Godot equivalent: @GlobalScope.print()_
66+
/// _Godot equivalent: [`@GlobalScope.print()`](https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-print)_.
6467
#[macro_export]
6568
macro_rules! godot_print {
6669
($fmt:literal $(, $args:expr)* $(,)?) => {
@@ -79,7 +82,7 @@ pub use crate::{godot_error, godot_print, godot_script_error, godot_warn};
7982
use crate::builtin::{StringName, Variant};
8083
use crate::sys::{self, GodotFfi};
8184

82-
/// Prints to the Godot console, used by the godot_print! macro.
85+
/// Prints to the Godot console, used by the [`godot_print!`] macro.
8386
pub fn print(varargs: &[Variant]) {
8487
unsafe {
8588
let method_name = StringName::from("print");

godot-core/src/obj/gd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::builtin::{Callable, StringName};
1919
use crate::obj::Bounds;
2020
use crate::obj::{bounds, cap, EngineEnum, GdDerefTarget, GodotClass, Inherits};
2121
use crate::obj::{GdMut, GdRef, InstanceId};
22-
use crate::property::{Export, Property, PropertyHintInfo, TypeStringHint};
22+
use crate::property::{Export, PropertyHintInfo, TypeStringHint, Var};
2323
use crate::{callbacks, engine, out};
2424

2525
use super::RawGd;
@@ -113,7 +113,7 @@ where
113113
/// The `init` function provides you with a `Base<T::Base>` object that you can use inside your `T`, which
114114
/// is then wrapped in a `Gd<T>`.
115115
///
116-
/// Example:
116+
/// # Example
117117
/// ```no_run
118118
/// # use godot::prelude::*;
119119
/// #[derive(GodotClass)]
@@ -615,7 +615,7 @@ impl<T: GodotClass> TypeStringHint for Gd<T> {
615615
}
616616
}
617617

618-
impl<T: GodotClass> Property for Gd<T> {
618+
impl<T: GodotClass> Var for Gd<T> {
619619
type Intermediate = Self;
620620

621621
fn get_property(&self) -> Self {

godot-core/src/obj/onready.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8-
use crate::property::{Export, Property, PropertyHintInfo};
8+
use crate::property::{Export, PropertyHintInfo, Var};
99
use std::mem;
1010

1111
/// Ergonomic late-initialization container with `ready()` support.
@@ -187,7 +187,7 @@ impl<T> std::ops::DerefMut for OnReady<T> {
187187
}
188188
}
189189

190-
impl<T: Property> Property for OnReady<T> {
190+
impl<T: Var> Var for OnReady<T> {
191191
type Intermediate = T::Intermediate;
192192

193193
fn get_property(&self) -> Self::Intermediate {

0 commit comments

Comments
 (0)