Skip to content

Commit 246e5f2

Browse files
committed
Deprecate specialized pool array aliases
1 parent 2207b6d commit 246e5f2

File tree

10 files changed

+49
-39
lines changed

10 files changed

+49
-39
lines changed

gdnative-core/src/core_types/byte_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use crate::core_types::PoolArray;
33
/// A reference-counted vector of `u8` that uses Godot's pool allocator.
44
///
55
/// See [`PoolByteArray`](https://docs.godotengine.org/en/stable/classes/class_poolbytearray.html) in Godot.
6+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
67
pub type ByteArray = PoolArray<u8>;
78

89
godot_test!(
910
test_byte_array_access {
1011
use crate::object::NewRef as _;
1112

12-
let arr = (0..8).collect::<ByteArray>();
13+
let arr = (0..8).collect::<PoolArray<u8>>();
1314

1415
let original_read = {
1516
let read = arr.read();
@@ -48,7 +49,7 @@ godot_test!(
4849

4950
godot_test!(
5051
test_byte_array_debug {
51-
let arr = (0..8).collect::<ByteArray>();
52+
let arr = (0..8).collect::<PoolArray<u8>>();
5253
assert_eq!(format!("{arr:?}"), "[0, 1, 2, 3, 4, 5, 6, 7]");
5354
}
5455
);

gdnative-core/src/core_types/color_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::core_types::PoolArray;
44
/// A reference-counted vector of `Color` that uses Godot's pool allocator.
55
///
66
/// See [`PoolColorArray`](https://docs.godotengine.org/en/stable/classes/class_poolcolorarray.html) in Godot.
7+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
78
pub type ColorArray = PoolArray<Color>;
89

910
godot_test!(
1011
test_color_array_access {
1112
use crate::object::NewRef as _;
1213

13-
let arr = ColorArray::from_vec(vec![
14+
let arr = PoolArray::from_vec(vec![
1415
Color::from_rgb(1.0, 0.0, 0.0),
1516
Color::from_rgb(0.0, 1.0, 0.0),
1617
Color::from_rgb(0.0, 0.0, 1.0),
@@ -51,7 +52,7 @@ godot_test!(
5152

5253
godot_test!(
5354
test_color_array_debug {
54-
let arr = ColorArray::from_vec(vec![
55+
let arr = PoolArray::from_vec(vec![
5556
Color::from_rgb(1.0, 0.0, 0.0),
5657
Color::from_rgb(0.0, 1.0, 0.0),
5758
Color::from_rgb(0.0, 0.0, 1.0),

gdnative-core/src/core_types/float32_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use crate::core_types::PoolArray;
33
/// A reference-counted vector of `f32` that uses Godot's pool allocator.
44
///
55
/// See [`PoolRealArray`](https://docs.godotengine.org/en/stable/classes/class_poolrealarray.html) in Godot.
6+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
67
pub type Float32Array = PoolArray<f32>;
78

89
godot_test!(
910
test_float32_array_access {
1011
use crate::object::NewRef as _;
1112

12-
let arr = (0..8).map(|i| i as f32).collect::<Float32Array>();
13+
let arr = (0..8).map(|i| i as f32).collect::<PoolArray<f32>>();
1314

1415
let original_read = {
1516
let read = arr.read();
@@ -42,7 +43,7 @@ godot_test!(
4243

4344
godot_test!(
4445
test_float32_array_debug {
45-
let arr = (0..8).map(|i| i as f32).collect::<Float32Array>();
46+
let arr = (0..8).map(|i| i as f32).collect::<PoolArray<f32>>();
4647
assert_eq!(format!("{arr:?}"), "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]");
4748
}
4849
);

gdnative-core/src/core_types/int32_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use crate::core_types::PoolArray;
33
/// A reference-counted vector of `i32` that uses Godot's pool allocator.
44
///
55
/// See [`PoolIntArray`](https://docs.godotengine.org/en/stable/classes/class_poolintarray.html) in Godot.
6+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
67
pub type Int32Array = PoolArray<i32>;
78

89
godot_test!(
910
test_int32_array_access {
1011
use crate::object::NewRef as _;
1112

12-
let arr = (0..8).collect::<Int32Array>();
13+
let arr = (0..8).collect::<PoolArray<i32>>();
1314

1415
let original_read = {
1516
let read = arr.read();
@@ -38,7 +39,7 @@ godot_test!(
3839

3940
godot_test!(
4041
test_int32_array_debug {
41-
let arr = (0..8).collect::<Int32Array>();
42+
let arr = (0..8).collect::<PoolArray<i32>>();
4243
assert_eq!(format!("{arr:?}"), "[0, 1, 2, 3, 4, 5, 6, 7]");
4344
}
4445
);

gdnative-core/src/core_types/string_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::core_types::PoolArray;
44
/// A reference-counted vector of `GodotString` that uses Godot's pool allocator.
55
///
66
/// See [`PoolStringArray`](https://docs.godotengine.org/en/stable/classes/class_poolstringarray.html) in Godot.
7+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
78
pub type StringArray = PoolArray<GodotString>;
89

910
godot_test!(
1011
test_string_array_access {
1112
use crate::object::NewRef as _;
1213

13-
let arr = StringArray::from_vec(vec![
14+
let arr = PoolArray::from_vec(vec![
1415
GodotString::from("foo"),
1516
GodotString::from("bar"),
1617
GodotString::from("baz"),
@@ -51,7 +52,7 @@ godot_test!(
5152

5253
godot_test!(
5354
test_string_array_debug {
54-
let arr = StringArray::from_vec(vec![
55+
let arr = PoolArray::from_vec(vec![
5556
GodotString::from("foo"),
5657
GodotString::from("bar"),
5758
GodotString::from("baz"),

gdnative-core/src/core_types/variant.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ decl_variant_type!(
155155
Object(Variant) = sys::godot_variant_type_GODOT_VARIANT_TYPE_OBJECT,
156156
Dictionary(Dictionary) = sys::godot_variant_type_GODOT_VARIANT_TYPE_DICTIONARY,
157157
VariantArray(VariantArray) = sys::godot_variant_type_GODOT_VARIANT_TYPE_ARRAY,
158-
ByteArray(ByteArray) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_BYTE_ARRAY,
159-
Int32Array(Int32Array) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_INT_ARRAY,
160-
Float32Array(Float32Array) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_REAL_ARRAY,
161-
StringArray(StringArray) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_STRING_ARRAY,
162-
Vector2Array(Vector2Array) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY,
163-
Vector3Array(Vector3Array) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY,
164-
ColorArray(ColorArray) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY,
158+
ByteArray(PoolArray<u8>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_BYTE_ARRAY,
159+
Int32Array(PoolArray<i32>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_INT_ARRAY,
160+
Float32Array(PoolArray<f32>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_REAL_ARRAY,
161+
StringArray(PoolArray<GodotString>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_STRING_ARRAY,
162+
Vector2Array(PoolArray<Vector2>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY,
163+
Vector3Array(PoolArray<Vector3>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY,
164+
ColorArray(PoolArray<Color>) = sys::godot_variant_type_GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY,
165165
}
166166
);
167167

@@ -598,13 +598,13 @@ impl_coerce_from_variant!(
598598
impl CoerceFromVariant for GodotString = from_sys(godot_variant_as_string);
599599
impl CoerceFromVariant for Rid = from_sys(godot_variant_as_rid);
600600
impl CoerceFromVariant for VariantArray<Shared> = from_sys(godot_variant_as_array);
601-
impl CoerceFromVariant for ByteArray = from_sys(godot_variant_as_pool_byte_array);
602-
impl CoerceFromVariant for Int32Array = from_sys(godot_variant_as_pool_int_array);
603-
impl CoerceFromVariant for Float32Array = from_sys(godot_variant_as_pool_real_array);
604-
impl CoerceFromVariant for StringArray = from_sys(godot_variant_as_pool_string_array);
605-
impl CoerceFromVariant for Vector2Array = from_sys(godot_variant_as_pool_vector2_array);
606-
impl CoerceFromVariant for Vector3Array = from_sys(godot_variant_as_pool_vector3_array);
607-
impl CoerceFromVariant for ColorArray = from_sys(godot_variant_as_pool_color_array);
601+
impl CoerceFromVariant for PoolArray<u8> = from_sys(godot_variant_as_pool_byte_array);
602+
impl CoerceFromVariant for PoolArray<i32> = from_sys(godot_variant_as_pool_int_array);
603+
impl CoerceFromVariant for PoolArray<f32> = from_sys(godot_variant_as_pool_real_array);
604+
impl CoerceFromVariant for PoolArray<GodotString> = from_sys(godot_variant_as_pool_string_array);
605+
impl CoerceFromVariant for PoolArray<Vector2> = from_sys(godot_variant_as_pool_vector2_array);
606+
impl CoerceFromVariant for PoolArray<Vector3> = from_sys(godot_variant_as_pool_vector3_array);
607+
impl CoerceFromVariant for PoolArray<Color> = from_sys(godot_variant_as_pool_color_array);
608608
impl CoerceFromVariant for Dictionary<Shared> = from_sys(godot_variant_as_dictionary);
609609
);
610610

gdnative-core/src/core_types/vector2_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::core_types::Vector2;
44
/// A reference-counted vector of `Vector2` that uses Godot's pool allocator.
55
///
66
/// See [`PoolVector2Array`](https://docs.godotengine.org/en/stable/classes/class_poolvector2array.html) in Godot.
7+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
78
pub type Vector2Array = PoolArray<Vector2>;
89

910
godot_test!(
1011
test_vector2_array_access {
1112
use crate::object::NewRef as _;
1213

13-
let arr = Vector2Array::from_vec(vec![
14+
let arr = PoolArray::from_vec(vec![
1415
Vector2::new(1.0, 2.0),
1516
Vector2::new(3.0, 4.0),
1617
Vector2::new(5.0, 6.0),
@@ -51,7 +52,7 @@ godot_test!(
5152

5253
godot_test!(
5354
test_vector2_array_debug {
54-
let arr = Vector2Array::from_vec(vec![
55+
let arr = PoolArray::from_vec(vec![
5556
Vector2::new(1.0, 2.0),
5657
Vector2::new(3.0, 4.0),
5758
Vector2::new(5.0, 6.0),

gdnative-core/src/core_types/vector3_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::core_types::Vector3;
44
/// A reference-counted vector of `Vector3` that uses Godot's pool allocator.
55
///
66
/// See [`PoolVector3Array`](https://docs.godotengine.org/en/stable/classes/class_poolvector3array.html) in Godot.
7+
#[deprecated = "Specialized pool array aliases will be removed in a future godot-rust version. Use PoolArray<T> instead."]
78
pub type Vector3Array = PoolArray<Vector3>;
89

910
godot_test!(
1011
test_vector3_array_access {
1112
use crate::object::NewRef as _;
1213

13-
let arr = Vector3Array::from_vec(vec![
14+
let arr = PoolArray::from_vec(vec![
1415
Vector3::new(1.0, 2.0, 3.0),
1516
Vector3::new(3.0, 4.0, 5.0),
1617
Vector3::new(5.0, 6.0, 7.0),
@@ -52,7 +53,7 @@ godot_test!(
5253

5354
godot_test!(
5455
test_vector3_array_debug {
55-
let arr = Vector3Array::from_vec(vec![
56+
let arr = PoolArray::from_vec(vec![
5657
Vector3::new(1.0, 2.0, 3.0),
5758
Vector3::new(3.0, 4.0, 5.0),
5859
Vector3::new(5.0, 6.0, 7.0),

gdnative-core/src/export/property.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,13 @@ mod impl_export {
537537
impl_export_for_core_type_without_hint!(NodePath);
538538
impl_export_for_core_type_without_hint!(Rid);
539539
impl_export_for_core_type_without_hint!(Dictionary);
540-
impl_export_for_core_type_without_hint!(ByteArray);
541-
impl_export_for_core_type_without_hint!(Int32Array);
542-
impl_export_for_core_type_without_hint!(Float32Array);
543-
impl_export_for_core_type_without_hint!(StringArray);
544-
impl_export_for_core_type_without_hint!(Vector2Array);
545-
impl_export_for_core_type_without_hint!(Vector3Array);
546-
impl_export_for_core_type_without_hint!(ColorArray);
540+
impl_export_for_core_type_without_hint!(PoolArray<u8>: ByteArray);
541+
impl_export_for_core_type_without_hint!(PoolArray<i32>: Int32Array);
542+
impl_export_for_core_type_without_hint!(PoolArray<f32>: Float32Array);
543+
impl_export_for_core_type_without_hint!(PoolArray<GodotString>: StringArray);
544+
impl_export_for_core_type_without_hint!(PoolArray<Vector2>: Vector2Array);
545+
impl_export_for_core_type_without_hint!(PoolArray<Vector3>: Vector3Array);
546+
impl_export_for_core_type_without_hint!(PoolArray<Color>: ColorArray);
547547

548548
impl Export for Color {
549549
type Hint = hint::ColorHint;

gdnative/src/prelude.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ pub use gdnative_bindings::{
55
ResourceLoader, SceneTree, Shader, Spatial, Sprite, Texture, Timer, Tween, Viewport,
66
};
77
pub use gdnative_core::core_types::{
8-
Aabb, Basis, ByteArray, Color, ColorArray, Dictionary, Float32Array, GodotError, GodotString,
9-
Int32Array, NodePath, Plane, PoolArray, Quat, Rect2, Rid, StringArray, StringName, Transform,
10-
Transform2D, Variant, VariantArray, VariantDispatch, VariantOperator, VariantType, Vector2,
11-
Vector2Array, Vector3, Vector3Array,
8+
Aabb, Basis, Color, Dictionary, GodotError, GodotString, NodePath, Plane, PoolArray, Quat,
9+
Rect2, Rid, StringName, Transform, Transform2D, Variant, VariantArray, VariantDispatch,
10+
VariantOperator, VariantType, Vector2, Vector3,
11+
};
12+
#[allow(deprecated)]
13+
pub use gdnative_core::core_types::{
14+
ByteArray, ColorArray, Float32Array, Int32Array, StringArray, Vector2Array, Vector3Array,
1215
};
1316
pub use gdnative_core::core_types::{
1417
FromVariant, FromVariantError, OwnedToVariant, ToVariant, ToVariantEq,

0 commit comments

Comments
 (0)