Skip to content

Commit 796a07f

Browse files
committed
Rename TypedArray -> PoolArray
1 parent 17892b7 commit 796a07f

File tree

14 files changed

+58
-52
lines changed

14 files changed

+58
-52
lines changed

gdnative-core/src/core_types/access.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ pub unsafe trait Guard: private::Sealed {
5050
pub unsafe trait WritePtr: Guard + private::Sealed {}
5151

5252
pub(crate) mod private {
53-
use crate::core_types::typed_array::Element;
53+
use crate::core_types::pool_array::Element;
5454

5555
pub trait Sealed {}
5656

57-
impl<'a, T: Element> Sealed for crate::core_types::typed_array::ReadGuard<'a, T> {}
58-
impl<'a, T: Element> Sealed for crate::core_types::typed_array::WriteGuard<'a, T> {}
57+
impl<'a, T: Element> Sealed for crate::core_types::pool_array::ReadGuard<'a, T> {}
58+
impl<'a, T: Element> Sealed for crate::core_types::pool_array::WriteGuard<'a, T> {}
5959
}
6060

6161
impl<G: Guard> MaybeUnaligned<G> {

gdnative-core/src/core_types/byte_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22

33
/// A reference-counted vector of `u8` that uses Godot's pool allocator.
4-
pub type ByteArray = TypedArray<u8>;
4+
pub type ByteArray = PoolArray<u8>;
55

66
godot_test!(
77
test_byte_array_access {

gdnative-core/src/core_types/color_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::core_types::Color;
2-
use crate::core_types::TypedArray;
2+
use crate::core_types::PoolArray;
33

44
/// A reference-counted vector of `Color` that uses Godot's pool allocator.
5-
pub type ColorArray = TypedArray<Color>;
5+
pub type ColorArray = PoolArray<Color>;
66

77
godot_test!(
88
test_color_array_access {

gdnative-core/src/core_types/float32_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22

33
/// A reference-counted vector of `f32` that uses Godot's pool allocator.
4-
pub type Float32Array = TypedArray<f32>;
4+
pub type Float32Array = PoolArray<f32>;
55

66
godot_test!(
77
test_float32_array_access {

gdnative-core/src/core_types/int32_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22

33
/// A reference-counted vector of `i32` that uses Godot's pool allocator.
4-
pub type Int32Array = TypedArray<i32>;
4+
pub type Int32Array = PoolArray<i32>;
55

66
godot_test!(
77
test_int32_array_access {

gdnative-core/src/core_types/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ mod error;
1616
mod float32_array;
1717
mod int32_array;
1818
mod node_path;
19+
mod pool_array;
1920
mod quat;
2021
mod rect2;
2122
mod rid;
2223
mod string;
2324
mod string_array;
2425
mod transform2d;
25-
mod typed_array;
2626
mod variant;
2727
mod variant_array;
2828
mod vector2;
@@ -40,13 +40,13 @@ pub use float32_array::*;
4040
pub use geom::*;
4141
pub use int32_array::*;
4242
pub use node_path::*;
43+
pub use pool_array::*; // TODO rename Element to something more specific
4344
pub use quat::*;
4445
pub use rect2::*;
4546
pub use rid::*;
4647
pub use string::*;
4748
pub use string_array::*;
4849
pub use transform2d::*;
49-
pub use typed_array::*; // TODO rename Element to something more specific
5050
pub use variant::*;
5151
pub use variant_array::*;
5252
pub use vector2::*;

gdnative-core/src/core_types/typed_array.rs renamed to gdnative-core/src/core_types/pool_array.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::private::get_api;
1212
/// A reference-counted CoW typed vector using Godot's pool allocator, generic over possible
1313
/// element types.
1414
///
15-
/// `TypedArray` unifies all the different `Pool*Array` types exported by Godot. It can be used
15+
/// `PoolArray` unifies all the different `Pool*Array` types exported by Godot. It can be used
1616
/// in exported Rust methods as parameter and return types, as well as in exported properties.
1717
/// However, it is limited to the element types, for which a `Pool*Array` exists in GDScript,
1818
/// i.e. it cannot contain user-defined types.
@@ -25,7 +25,7 @@ use crate::private::get_api;
2525
/// When using this type, it's generally better to perform mutations in batch using `write`,
2626
/// or the `append` methods, as opposed to `push` or `set`, because the latter ones trigger
2727
/// CoW behavior each time they are called.
28-
pub struct TypedArray<T: Element> {
28+
pub struct PoolArray<T: Element> {
2929
inner: T::SysArray,
3030
}
3131

@@ -36,7 +36,7 @@ pub type Read<'a, T> = Aligned<ReadGuard<'a, T>>;
3636
/// as opposed to every time with methods like `push`.
3737
pub type Write<'a, T> = Aligned<WriteGuard<'a, T>>;
3838

39-
impl<T: Element> Drop for TypedArray<T> {
39+
impl<T: Element> Drop for PoolArray<T> {
4040
#[inline]
4141
fn drop(&mut self) {
4242
unsafe {
@@ -45,47 +45,47 @@ impl<T: Element> Drop for TypedArray<T> {
4545
}
4646
}
4747

48-
impl<T: Element> Default for TypedArray<T> {
48+
impl<T: Element> Default for PoolArray<T> {
4949
#[inline]
5050
fn default() -> Self {
51-
TypedArray::new()
51+
PoolArray::new()
5252
}
5353
}
5454

55-
impl<T: Element + fmt::Debug> fmt::Debug for TypedArray<T> {
55+
impl<T: Element + fmt::Debug> fmt::Debug for PoolArray<T> {
5656
#[inline]
5757
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5858
f.debug_list().entries(self.read().iter()).finish()
5959
}
6060
}
6161

62-
impl<T: Element> Clone for TypedArray<T> {
62+
impl<T: Element> Clone for PoolArray<T> {
6363
#[inline]
6464
fn clone(&self) -> Self {
6565
self.new_ref()
6666
}
6767
}
6868

69-
impl<T: Element> NewRef for TypedArray<T> {
69+
impl<T: Element> NewRef for PoolArray<T> {
7070
/// Creates a new reference to this reference-counted instance.
7171
#[inline]
7272
fn new_ref(&self) -> Self {
7373
unsafe {
7474
let mut inner = T::SysArray::default();
7575
(T::new_copy_fn(get_api()))(&mut inner, self.sys());
76-
TypedArray { inner }
76+
PoolArray { inner }
7777
}
7878
}
7979
}
8080

81-
impl<T: Element> TypedArray<T> {
81+
impl<T: Element> PoolArray<T> {
8282
/// Creates an empty array.
8383
#[inline]
8484
pub fn new() -> Self {
8585
unsafe {
8686
let mut inner = T::SysArray::default();
8787
(T::new_fn(get_api()))(&mut inner);
88-
TypedArray { inner }
88+
PoolArray { inner }
8989
}
9090
}
9191

@@ -95,11 +95,11 @@ impl<T: Element> TypedArray<T> {
9595
unsafe {
9696
let mut inner = T::SysArray::default();
9797
(T::new_with_array_fn(get_api()))(&mut inner, array.sys());
98-
TypedArray { inner }
98+
PoolArray { inner }
9999
}
100100
}
101101

102-
/// Creates a `TypedArray` moving elements from `src`.
102+
/// Creates a `PoolArray` moving elements from `src`.
103103
#[inline]
104104
pub fn from_vec(mut src: Vec<T>) -> Self {
105105
let mut arr = Self::new();
@@ -261,12 +261,12 @@ impl<T: Element> TypedArray<T> {
261261
#[doc(hidden)]
262262
#[inline]
263263
pub fn from_sys(sys: T::SysArray) -> Self {
264-
TypedArray { inner: sys }
264+
PoolArray { inner: sys }
265265
}
266266
}
267267

268-
impl<T: Element + Copy> TypedArray<T> {
269-
/// Creates a new `TypedArray` by copying from `src`.
268+
impl<T: Element + Copy> PoolArray<T> {
269+
/// Creates a new `PoolArray` by copying from `src`.
270270
///
271271
/// # Panics
272272
///
@@ -297,23 +297,23 @@ impl<T: Element + Copy> TypedArray<T> {
297297
// `FromIterator` and `Extend` implementations collect into `Vec` first, because Rust `Vec`s
298298
// are better at handling unknown lengths than the Godot arrays (`push` CoWs every time!)
299299

300-
impl<T: Element> FromIterator<T> for TypedArray<T> {
300+
impl<T: Element> FromIterator<T> for PoolArray<T> {
301301
#[inline]
302302
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
303303
let vec = iter.into_iter().collect::<Vec<_>>();
304304
Self::from_vec(vec)
305305
}
306306
}
307307

308-
impl<T: Element> Extend<T> for TypedArray<T> {
308+
impl<T: Element> Extend<T> for PoolArray<T> {
309309
#[inline]
310310
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
311311
let mut vec = iter.into_iter().collect::<Vec<_>>();
312312
self.append_vec(&mut vec);
313313
}
314314
}
315315

316-
impl<T: Element + PartialEq> PartialEq for TypedArray<T> {
316+
impl<T: Element + PartialEq> PartialEq for PoolArray<T> {
317317
#[inline]
318318
fn eq(&self, other: &Self) -> bool {
319319
if self.len() != other.len() {
@@ -326,7 +326,7 @@ impl<T: Element + PartialEq> PartialEq for TypedArray<T> {
326326
left.as_slice() == right.as_slice()
327327
}
328328
}
329-
impl<T: Element + Eq> Eq for TypedArray<T> {}
329+
impl<T: Element + Eq> Eq for PoolArray<T> {}
330330

331331
/// RAII read guard.
332332
pub struct ReadGuard<'a, T: Element> {
@@ -437,7 +437,7 @@ impl<'a, T: Element> Drop for WriteGuard<'a, T> {
437437
}
438438

439439
macros::decl_typed_array_element! {
440-
/// Trait for element types that can be contained in `TypedArray`. This trait is sealed
440+
/// Trait for element types that can be contained in `PoolArray`. This trait is sealed
441441
/// and has no public interface.
442442
pub trait Element: private::Sealed { .. }
443443
}
@@ -495,7 +495,7 @@ mod serialize {
495495
use std::fmt::Formatter;
496496
use std::marker::PhantomData;
497497

498-
impl<T: Serialize + Element> Serialize for TypedArray<T> {
498+
impl<T: Serialize + Element> Serialize for PoolArray<T> {
499499
#[inline]
500500
fn serialize<S>(&self, ser: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
501501
where
@@ -510,15 +510,15 @@ mod serialize {
510510
}
511511
}
512512

513-
impl<'de, T: Deserialize<'de> + Element> Deserialize<'de> for TypedArray<T> {
513+
impl<'de, T: Deserialize<'de> + Element> Deserialize<'de> for PoolArray<T> {
514514
#[inline]
515515
fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
516516
where
517517
D: Deserializer<'de>,
518518
{
519519
struct TypedArrayVisitor<T>(PhantomData<T>);
520520
impl<'de, T: Deserialize<'de> + Element> Visitor<'de> for TypedArrayVisitor<T> {
521-
type Value = TypedArray<T>;
521+
type Value = PoolArray<T>;
522522

523523
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
524524
formatter.write_str(std::any::type_name::<Self::Value>())

gdnative-core/src/core_types/string_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::core_types::GodotString;
2-
use crate::core_types::TypedArray;
2+
use crate::core_types::PoolArray;
33

44
/// A reference-counted vector of `GodotString` that uses Godot's pool allocator.
5-
pub type StringArray = TypedArray<GodotString>;
5+
pub type StringArray = PoolArray<GodotString>;
66

77
godot_test!(
88
test_string_array_access {

gdnative-core/src/core_types/variant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ pub trait OwnedToVariant {
10721072
///
10731073
/// This means that for all values `a` and `b`, `a == b` is equivalent to
10741074
/// `a.to_variant() == b.to_variant()`. Most of the time, this means that `to_variant` must
1075-
/// return a "value" type, such as a primitive `i32`, a `GodotString`, or a `TypedArray`.
1075+
/// return a "value" type, such as a primitive `i32`, a `GodotString`, or a `PoolArray`.
10761076
///
10771077
/// This is mostly useful as a bound for `Dictionary` keys, where the difference between Rust's
10781078
/// structural equality and Godot's referential equality semantics can lead to surprising
@@ -1597,7 +1597,7 @@ from_variant_from_sys!(
15971597
impl FromVariant for Dictionary<Shared> as Dictionary : godot_variant_as_dictionary;
15981598
);
15991599

1600-
impl<T: crate::core_types::typed_array::Element> ToVariant for TypedArray<T> {
1600+
impl<T: crate::core_types::pool_array::Element> ToVariant for PoolArray<T> {
16011601
#[inline]
16021602
fn to_variant(&self) -> Variant {
16031603
unsafe {
@@ -1608,9 +1608,9 @@ impl<T: crate::core_types::typed_array::Element> ToVariant for TypedArray<T> {
16081608
}
16091609
}
16101610
}
1611-
impl<T: crate::core_types::typed_array::Element + Eq> ToVariantEq for TypedArray<T> {}
1611+
impl<T: crate::core_types::pool_array::Element + Eq> ToVariantEq for PoolArray<T> {}
16121612

1613-
impl<T: crate::core_types::typed_array::Element> FromVariant for TypedArray<T> {
1613+
impl<T: crate::core_types::pool_array::Element> FromVariant for PoolArray<T> {
16141614
#[inline]
16151615
fn from_variant(variant: &Variant) -> Result<Self, FromVariantError> {
16161616
unsafe {

gdnative-core/src/core_types/vector2_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22
use crate::core_types::Vector2;
33

44
/// A reference-counted vector of `Vector2` that uses Godot's pool allocator.
5-
pub type Vector2Array = TypedArray<Vector2>;
5+
pub type Vector2Array = PoolArray<Vector2>;
66

77
godot_test!(
88
test_vector2_array_access {

0 commit comments

Comments
 (0)