Skip to content

Commit

Permalink
Merge pull request #699 from godot-rust/feature/packed-vector4-array
Browse files Browse the repository at this point in the history
Add `PackedVector4Array`
  • Loading branch information
Bromeon authored May 4, 2024
2 parents cadec6b + bc6d380 commit ed88b6f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions godot-core/src/builtin/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ impl_builtin_froms!(VariantArray;
PackedVector3Array => array_from_packed_vector3_array,
);

#[cfg(since_api = "4.3")]
impl_builtin_froms!(VariantArray;
PackedVector4Array => array_from_packed_vector4_array,
);

impl<T: ArrayElement> Array<T> {
fn from_opaque(opaque: sys::types::OpaqueArray) -> Self {
// Note: type is not yet checked at this point, because array has not yet been initialized!
Expand Down
2 changes: 2 additions & 0 deletions godot-core/src/builtin/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ mod sealed {
impl Sealed for PackedStringArray {}
impl Sealed for PackedVector2Array {}
impl Sealed for PackedVector3Array {}
#[cfg(since_api = "4.3")]
impl Sealed for PackedVector4Array {}
impl Sealed for PackedColorArray {}
impl Sealed for Plane {}
impl Sealed for Projection {}
Expand Down
22 changes: 19 additions & 3 deletions godot-core/src/builtin/packed_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,6 @@ macro_rules! impl_specific_packed_array_functions {
};
}

// TODO implement
pub type PackedVector4Array = PackedVector2Array;

impl_packed_array!(
type_name: PackedByteArray,
element_type: u8,
Expand Down Expand Up @@ -690,6 +687,25 @@ impl_packed_array!(
},
);

#[cfg(since_api = "4.3")]
impl_packed_array!(
type_name: PackedVector4Array,
element_type: Vector4,
opaque_type: OpaquePackedVector4Array,
inner_type: InnerPackedVector4Array,
argument_type: Vector4,
return_type: __GdextType,
from_array: packed_vector4_array_from_array,
operator_index: packed_vector4_array_operator_index,
operator_index_const: packed_vector4_array_operator_index_const,
trait_impls: {
Default => packed_vector4_array_construct_default;
Clone => packed_vector4_array_construct_copy;
Drop => packed_vector4_array_destroy;
PartialEq => packed_vector4_array_operator_equal;
},
);

impl_packed_array!(
type_name: PackedColorArray,
element_type: Color,
Expand Down
2 changes: 2 additions & 0 deletions godot-core/src/builtin/variant/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ mod impls {
impl_ffi_variant!(PackedStringArray, packed_string_array_to_variant, packed_string_array_from_variant);
impl_ffi_variant!(PackedVector2Array, packed_vector2_array_to_variant, packed_vector2_array_from_variant);
impl_ffi_variant!(PackedVector3Array, packed_vector3_array_to_variant, packed_vector3_array_from_variant);
#[cfg(since_api = "4.3")]
impl_ffi_variant!(PackedVector4Array, packed_vector4_array_to_variant, packed_vector4_array_from_variant);
impl_ffi_variant!(PackedColorArray, packed_color_array_to_variant, packed_color_array_from_variant);
impl_ffi_variant!(Plane, plane_to_variant, plane_from_variant);
impl_ffi_variant!(Projection, projection_to_variant, projection_from_variant);
Expand Down
4 changes: 3 additions & 1 deletion godot-core/src/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod export_impls {
(@type_string_hint $Ty:ty) => {
impl TypeStringHint for $Ty {
fn type_string() -> String {
use sys::GodotFfi;
use sys::GodotFfi as _;
let variant_type = <$Ty as $crate::builtin::meta::GodotType>::Ffi::variant_type();
let type_name = <$Ty as $crate::builtin::meta::GodotType>::godot_type_name();
format!("{}:{}", variant_type as i32, type_name)
Expand Down Expand Up @@ -414,6 +414,8 @@ mod export_impls {
impl_property_by_godot_convert!(PackedStringArray, no_export);
impl_property_by_godot_convert!(PackedVector2Array, no_export);
impl_property_by_godot_convert!(PackedVector3Array, no_export);
#[cfg(since_api = "4.3")]
impl_property_by_godot_convert!(PackedVector4Array, no_export);
impl_property_by_godot_convert!(PackedColorArray, no_export);

// Primitives
Expand Down
2 changes: 2 additions & 0 deletions itest/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ fn collect_inputs() -> Vec<Input> {
push!(inputs; PackedStringArray, PackedStringArray, PackedStringArray(), PackedStringArray::new());
push!(inputs; PackedVector2Array, PackedVector2Array, PackedVector2Array(), PackedVector2Array::new());
push!(inputs; PackedVector3Array, PackedVector3Array, PackedVector3Array(), PackedVector3Array::new());
#[cfg(since_api = "4.3")]
push!(inputs; PackedVector4Array, PackedVector4Array, PackedVector4Array(), PackedVector4Array::new());
push!(inputs; PackedColorArray, PackedColorArray, PackedColorArray(), PackedColorArray::new());

push_newtype!(inputs; int, NewI64(i64), -922337203685477580);
Expand Down

0 comments on commit ed88b6f

Please sign in to comment.