godot-core 0.5.1

Internal crate used by godot-rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/*
 * Copyright (c) godot-rust; Bromeon and contributors.
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

use sys::{GodotFfi, SysPtr, interface_fn};

use crate::builtin::PackedArray;
use crate::builtin::collections::extend_buffer::{ExtendBuffer, ExtendBufferTrait};
use crate::meta::signed_range::SignedRange;
use crate::meta::{CowArg, FromGodot, GodotType, ToGodot};
use crate::{builtin, sys};

/// Marker trait to identify types that can be stored in [`PackedArray<T>`][crate::builtin::PackedArray].
#[diagnostic::on_unimplemented(
    message = "`PackedArray<T>` can only store element types supported in Godot packed arrays.",
    label = "has invalid element type"
)]
// FromGodot isn't used, but can come in handy as an implied bound.
// ToGodot is needed for AsArg<T>.
pub trait PackedElement: GodotType + Clone + ToGodot + FromGodot {
    /// Element variant type.
    #[doc(hidden)]
    const VARIANT_TYPE: sys::VariantType;

    /// Code-generated inner type, e.g. `InnerPackedStringArray`.
    #[doc(hidden)]
    type Inner<'a>;

    /// The type used for function arguments when passing elements, e.g. `&'a GString` or `i64`.
    #[doc(hidden)]
    type Arg<'a>;

    /// The pointee type returned from FFI index operations, e.g. `i64` or `sys::__GdextString` (opaque type behind `GDExtensionTypePtr`).
    #[doc(hidden)]
    type Indexed;

    /// ExtendBuffer type with appropriate capacity `N` for this element type.
    #[doc(hidden)]
    type ExtendBuffer: Default + ExtendBufferTrait<Self>;

    // ----------------------------------------------------------------------------------------------------------------------------------------------
    // FFI operations

    #[doc(hidden)]
    unsafe fn ffi_to_variant(
        type_ptr: sys::GDExtensionConstTypePtr,
        variant_ptr: sys::GDExtensionVariantPtr,
    );

    #[doc(hidden)]
    unsafe fn ffi_from_variant(
        variant_ptr: sys::GDExtensionConstVariantPtr,
        type_ptr: sys::GDExtensionTypePtr,
    );

    #[doc(hidden)]
    unsafe fn ffi_to_array(
        from_packed: sys::GDExtensionConstTypePtr,
        to_uninit_array: sys::GDExtensionUninitializedTypePtr,
    );

    #[doc(hidden)]
    unsafe fn ffi_from_array(
        from_array: sys::GDExtensionConstTypePtr,
        to_uninit_packed: sys::GDExtensionUninitializedTypePtr,
    );

    #[doc(hidden)]
    unsafe fn ffi_default(type_ptr: sys::GDExtensionTypePtr);

    #[doc(hidden)]
    unsafe fn ffi_copy(src_ptr: sys::GDExtensionConstTypePtr, dst_ptr: sys::GDExtensionTypePtr);

    #[doc(hidden)]
    unsafe fn ffi_destroy(type_ptr: sys::GDExtensionTypePtr);

    #[doc(hidden)]
    unsafe fn ffi_equals(
        left_ptr: sys::GDExtensionConstTypePtr,
        right_ptr: sys::GDExtensionConstTypePtr,
    ) -> bool;

    #[doc(hidden)]
    unsafe fn ffi_index_const(
        type_ptr: sys::GDExtensionConstTypePtr,
        index: i64,
    ) -> *const Self::Indexed;

    #[doc(hidden)]
    unsafe fn ffi_index_mut(type_ptr: sys::GDExtensionTypePtr, index: i64) -> *mut Self::Indexed;

    // ----------------------------------------------------------------------------------------------------------------------------------------------
    // Delegates to inner Packed*Array API

    #[doc(hidden)]
    fn op_has(inner: Self::Inner<'_>, value: CowArg<'_, Self>) -> bool;

    #[doc(hidden)]
    fn op_count(inner: Self::Inner<'_>, value: CowArg<'_, Self>) -> i64;

    #[doc(hidden)]
    fn op_size(inner: Self::Inner<'_>) -> i64;

    #[doc(hidden)]
    fn op_is_empty(inner: Self::Inner<'_>) -> bool;

    #[doc(hidden)]
    fn op_clear(inner: Self::Inner<'_>);

    #[doc(hidden)]
    fn op_push_back(inner: Self::Inner<'_>, value: CowArg<'_, Self>);

    #[doc(hidden)]
    fn op_insert(inner: Self::Inner<'_>, index: i64, value: CowArg<'_, Self>);

    #[doc(hidden)]
    fn op_remove_at(inner: Self::Inner<'_>, index: i64);

    #[doc(hidden)]
    fn op_fill(inner: Self::Inner<'_>, value: CowArg<'_, Self>);

    #[doc(hidden)]
    fn op_resize(inner: Self::Inner<'_>, size: i64);

    #[doc(hidden)]
    fn op_append_array(inner: Self::Inner<'_>, other: &PackedArray<Self>);

    #[doc(hidden)]
    fn op_slice(inner: Self::Inner<'_>, range: impl SignedRange) -> PackedArray<Self>;

    #[doc(hidden)]
    fn op_find(inner: Self::Inner<'_>, value: CowArg<'_, Self>, from: i64) -> i64;

    #[doc(hidden)]
    fn op_rfind(inner: Self::Inner<'_>, value: CowArg<'_, Self>, from: i64) -> i64;

    #[doc(hidden)]
    fn op_bsearch(inner: Self::Inner<'_>, value: CowArg<'_, Self>, before: bool) -> i64;

    #[doc(hidden)]
    fn op_reverse(inner: Self::Inner<'_>);

    #[doc(hidden)]
    fn op_sort(inner: Self::Inner<'_>);

    #[doc(hidden)]
    fn inner<'a>(array: &PackedArray<Self>) -> Self::Inner<'a>;

    /// Call inner function with an element-type argument.
    ///
    /// Has this functional design for a reason: to pass `CowArg` as either value or ref, it needs to be consumed. However we can then not
    /// return a reference, as the `CowArg` would be dropped inside the function.
    #[doc(hidden)]
    fn with_arg<F, R>(value: CowArg<'_, Self>, f: F) -> R
    where
        F: FnOnce(Self::Arg<'_>) -> R;
}

/// Helper because `usize::max()` is not const.
const fn const_max(a: usize, b: usize) -> usize {
    if a > b { a } else { b }
}

// ----------------------------------------------------------------------------------------------------------------------------------------------
// Macro to implement the spec for a concrete element type

macro_rules! impl_packed_array_element {
    (
        element_type: $Element:ty,
        argument_type: $Arg:ty,
        argument_pass: $ArgPass:ident,
        indexed_type: $IndexRetType:ty,
        variant_type: $VariantType:ident,
        inner_type: $Inner:ident,
        default_fn: $default_fn:ident,
        copy_fn: $copy_fn:ident,
        destroy_fn: $destroy_fn:ident,
        to_variant_fn: $to_variant_fn:ident,
        from_variant_fn: $from_variant_fn:ident,
        to_array_fn: $to_array_fn:ident,
        from_array_fn: $from_array_fn:ident,
        equals_fn: $equals_fn:ident,
        index_mut_fn: $index_mut_fn:ident,
        index_const_fn: $index_const_fn:ident,
    ) => {
        impl PackedElement for $Element {
            const VARIANT_TYPE: sys::VariantType = sys::VariantType::$VariantType;

            type Inner<'a> = crate::builtin::inner::$Inner<'a>;
            type Arg<'a> = $Arg;
            type Indexed = $IndexRetType;
            type ExtendBuffer = ExtendBuffer<$Element, {
                const_max(1, 2048 / std::mem::size_of::<$Element>())
            }>;

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_default(type_ptr: sys::GDExtensionTypePtr) {
                let constructor = sys::builtin_fn!($default_fn);
                constructor(SysPtr::as_uninit(type_ptr), std::ptr::null_mut());
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_copy(src_ptr: sys::GDExtensionConstTypePtr, dst_ptr: sys::GDExtensionTypePtr) {
                let constructor = sys::builtin_fn!($copy_fn);
                let args = [src_ptr];
                constructor(SysPtr::as_uninit(dst_ptr), args.as_ptr());
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_destroy(type_ptr: sys::GDExtensionTypePtr) {
                let destructor = sys::builtin_fn!($destroy_fn @1);
                destructor(type_ptr);
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_to_variant(type_ptr: sys::GDExtensionConstTypePtr, variant_ptr: sys::GDExtensionVariantPtr) {
                let converter = sys::builtin_fn!($to_variant_fn);
                converter(SysPtr::as_uninit(variant_ptr), SysPtr::force_mut(type_ptr));
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_from_variant(variant_ptr: sys::GDExtensionConstVariantPtr, type_ptr: sys::GDExtensionTypePtr) {
                let converter = sys::builtin_fn!($from_variant_fn);
                converter(SysPtr::as_uninit(type_ptr), SysPtr::force_mut(variant_ptr));
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_to_array(from_packed: sys::GDExtensionConstTypePtr, to_uninit_array: sys::GDExtensionUninitializedTypePtr) {
                let converter = sys::builtin_fn!($to_array_fn);
                let args = [from_packed];
                converter(to_uninit_array, args.as_ptr())
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_from_array(from_array: sys::GDExtensionConstTypePtr, to_uninit_packed: sys::GDExtensionUninitializedTypePtr) {
                let converter = sys::builtin_fn!($from_array_fn);
                let args = [from_array];
                converter(to_uninit_packed, args.as_ptr())
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_equals(left_ptr: sys::GDExtensionConstTypePtr, right_ptr: sys::GDExtensionConstTypePtr) -> bool {
                let mut result = false;
                sys::builtin_call! {
                    $equals_fn(left_ptr, right_ptr, result.sys_mut())
                };
                result
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_index_const(type_ptr: sys::GDExtensionConstTypePtr, index: i64) -> *const Self::Indexed {
                interface_fn!($index_const_fn)(type_ptr, index)
            }

            #[allow(unsafe_op_in_unsafe_fn)] // Pointer validity asserted by Godot.
            unsafe fn ffi_index_mut(type_ptr: sys::GDExtensionTypePtr, index: i64) -> *mut Self::Indexed {
                interface_fn!($index_mut_fn)(type_ptr, index)
            }

            fn op_has(inner: Self::Inner<'_>, value: CowArg<'_, Self>) -> bool {
                Self::with_arg(value, |arg| inner.has(arg))
            }

            fn op_count(inner: Self::Inner<'_>, value: CowArg<'_, Self>) -> i64 {
                Self::with_arg(value, |arg| inner.count(arg))
            }

            fn op_size(inner: Self::Inner<'_>) -> i64 {
                inner.size()
            }

            fn op_is_empty(inner: Self::Inner<'_>) -> bool {
                inner.is_empty()
            }

            fn op_clear(mut inner: Self::Inner<'_>) {
                inner.clear();
            }

            fn op_push_back(mut inner: Self::Inner<'_>, value: CowArg<'_, Self>) {
                Self::with_arg(value, |arg| inner.push_back(arg));
            }

            fn op_insert(mut inner: Self::Inner<'_>, index: i64, value: CowArg<'_, Self>) {
                Self::with_arg(value, |arg| inner.insert(index, arg));
            }

            fn op_remove_at(mut inner: Self::Inner<'_>, index: i64) {
                inner.remove_at(index);
            }

            fn op_fill(mut inner: Self::Inner<'_>, value: CowArg<'_, Self>) {
                Self::with_arg(value, |arg| inner.fill(arg));
            }

            fn op_resize(mut inner: Self::Inner<'_>, size: i64) {
                inner.resize(size);
            }

            fn op_append_array(mut inner: Self::Inner<'_>, other: &PackedArray<Self>) {
                inner.append_array(other);
            }

            fn op_slice(inner: Self::Inner<'_>, range: impl $crate::meta::signed_range::SignedRange) -> PackedArray<Self> {
                let (begin, end) = range.signed();
                inner.slice(begin, end.unwrap_or(i32::MAX as i64))
            }

            fn op_find(inner: Self::Inner<'_>, value: CowArg<'_, Self>, from: i64) -> i64 {
                Self::with_arg(value, |arg| inner.find(arg, from))
            }

            fn op_rfind(inner: Self::Inner<'_>, value: CowArg<'_, Self>, from: i64) -> i64 {
                Self::with_arg(value, |arg| inner.rfind(arg, from))
            }

            #[allow(unused_mut)] // Generated bsearch() needs &mut before 4.6, but not anymore afterwards.
            fn op_bsearch(mut inner: Self::Inner<'_>, value: CowArg<'_, Self>, before: bool) -> i64 {
                Self::with_arg(value, |arg| inner.bsearch(arg, before))
            }

            fn op_reverse(mut inner: Self::Inner<'_>) {
                inner.reverse()
            }

            fn op_sort(mut inner: Self::Inner<'_>) {
                inner.sort()
            }

            fn inner<'a>(array: &PackedArray<$Element>) -> Self::Inner<'a> {
                crate::builtin::inner::$Inner::from_outer(array)
            }

            impl_packed_array_element!(@with_arg $ArgPass);
        }
    };

    // Specialization for by-value/by-ref passing (only GString).
    (@with_arg ByValue) => {
        fn with_arg<F, R>(value: CowArg<'_, Self>, f: F) -> R
        where
            F: FnOnce(Self::Arg<'_>) -> R,
        {
            // into() allows conversions from u8|i32 -> i64 (Godot APIs take i64 even for Packed{Byte,Int32}Array).
            f(value.cow_into_owned().into())
        }
    };

    (@with_arg ByRef) => {
        fn with_arg<F, R>(value: CowArg<'_, Self>, f: F) -> R
        where
            F: FnOnce(Self::Arg<'_>) -> R,
        {
            f(value.cow_as_ref())
        }
    };
}

// ----------------------------------------------------------------------------------------------------------------------------------------------
// Concrete impls for different element types

impl_packed_array_element!(
    element_type: u8,
    argument_type: i64,
    argument_pass: ByValue,
    indexed_type: u8,
    variant_type: PACKED_BYTE_ARRAY,
    inner_type: InnerPackedByteArray,
    default_fn: packed_byte_array_construct_default,
    copy_fn: packed_byte_array_construct_copy,
    destroy_fn: packed_byte_array_destroy,
    to_variant_fn: packed_byte_array_to_variant,
    from_variant_fn: packed_byte_array_from_variant,
    to_array_fn: array_from_packed_byte_array,
    from_array_fn: packed_byte_array_from_array,
    equals_fn: packed_byte_array_operator_equal,
    index_mut_fn: packed_byte_array_operator_index,
    index_const_fn: packed_byte_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: i32,
    argument_type: i64,
    argument_pass: ByValue,
    indexed_type: i32,
    variant_type: PACKED_INT32_ARRAY,
    inner_type: InnerPackedInt32Array,
    default_fn: packed_int32_array_construct_default,
    copy_fn: packed_int32_array_construct_copy,
    destroy_fn: packed_int32_array_destroy,
    to_variant_fn: packed_int32_array_to_variant,
    from_variant_fn: packed_int32_array_from_variant,
    to_array_fn: array_from_packed_int32_array,
    from_array_fn: packed_int32_array_from_array,
    equals_fn: packed_int32_array_operator_equal,
    index_mut_fn: packed_int32_array_operator_index,
    index_const_fn: packed_int32_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: i64,
    argument_type: i64,
    argument_pass: ByValue,
    indexed_type: i64,
    variant_type: PACKED_INT64_ARRAY,
    inner_type: InnerPackedInt64Array,
    default_fn: packed_int64_array_construct_default,
    copy_fn: packed_int64_array_construct_copy,
    destroy_fn: packed_int64_array_destroy,
    to_variant_fn: packed_int64_array_to_variant,
    from_variant_fn: packed_int64_array_from_variant,
    to_array_fn: array_from_packed_int64_array,
    from_array_fn: packed_int64_array_from_array,
    equals_fn: packed_int64_array_operator_equal,
    index_mut_fn: packed_int64_array_operator_index,
    index_const_fn: packed_int64_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: f32,
    argument_type: f64,
    argument_pass: ByValue,
    indexed_type: f32,
    variant_type: PACKED_FLOAT32_ARRAY,
    inner_type: InnerPackedFloat32Array,
    default_fn: packed_float32_array_construct_default,
    copy_fn: packed_float32_array_construct_copy,
    destroy_fn: packed_float32_array_destroy,
    to_variant_fn: packed_float32_array_to_variant,
    from_variant_fn: packed_float32_array_from_variant,
    to_array_fn: array_from_packed_float32_array,
    from_array_fn: packed_float32_array_from_array,
    equals_fn: packed_float32_array_operator_equal,
    index_mut_fn: packed_float32_array_operator_index,
    index_const_fn: packed_float32_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: f64,
    argument_type: f64,
    argument_pass: ByValue,
    indexed_type: f64,
    variant_type: PACKED_FLOAT64_ARRAY,
    inner_type: InnerPackedFloat64Array,
    default_fn: packed_float64_array_construct_default,
    copy_fn: packed_float64_array_construct_copy,
    destroy_fn: packed_float64_array_destroy,
    to_variant_fn: packed_float64_array_to_variant,
    from_variant_fn: packed_float64_array_from_variant,
    to_array_fn: array_from_packed_float64_array,
    from_array_fn: packed_float64_array_from_array,
    equals_fn: packed_float64_array_operator_equal,
    index_mut_fn: packed_float64_array_operator_index,
    index_const_fn: packed_float64_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: builtin::Vector2,
    argument_type: builtin::Vector2,
    argument_pass: ByValue,
    indexed_type: sys::__GdextType,
    variant_type: PACKED_VECTOR2_ARRAY,
    inner_type: InnerPackedVector2Array,
    default_fn: packed_vector2_array_construct_default,
    copy_fn: packed_vector2_array_construct_copy,
    destroy_fn: packed_vector2_array_destroy,
    to_variant_fn: packed_vector2_array_to_variant,
    from_variant_fn: packed_vector2_array_from_variant,
    to_array_fn: array_from_packed_vector2_array,
    from_array_fn: packed_vector2_array_from_array,
    equals_fn: packed_vector2_array_operator_equal,
    index_mut_fn: packed_vector2_array_operator_index,
    index_const_fn: packed_vector2_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: builtin::Vector3,
    argument_type: builtin::Vector3,
    argument_pass: ByValue,
    indexed_type: sys::__GdextType,
    variant_type: PACKED_VECTOR3_ARRAY,
    inner_type: InnerPackedVector3Array,
    default_fn: packed_vector3_array_construct_default,
    copy_fn: packed_vector3_array_construct_copy,
    destroy_fn: packed_vector3_array_destroy,
    to_variant_fn: packed_vector3_array_to_variant,
    from_variant_fn: packed_vector3_array_from_variant,
    to_array_fn: array_from_packed_vector3_array,
    from_array_fn: packed_vector3_array_from_array,
    equals_fn: packed_vector3_array_operator_equal,
    index_mut_fn: packed_vector3_array_operator_index,
    index_const_fn: packed_vector3_array_operator_index_const,
);

#[cfg(since_api = "4.3")] #[cfg_attr(published_docs, doc(cfg(since_api = "4.3")))]
impl_packed_array_element!(
    element_type: builtin::Vector4,
    argument_type: builtin::Vector4,
    argument_pass: ByValue,
    indexed_type: sys::__GdextType,
    variant_type: PACKED_VECTOR4_ARRAY,
    inner_type: InnerPackedVector4Array,
    default_fn: packed_vector4_array_construct_default,
    copy_fn: packed_vector4_array_construct_copy,
    destroy_fn: packed_vector4_array_destroy,
    to_variant_fn: packed_vector4_array_to_variant,
    from_variant_fn: packed_vector4_array_from_variant,
    to_array_fn: array_from_packed_vector4_array,
    from_array_fn: packed_vector4_array_from_array,
    equals_fn: packed_vector4_array_operator_equal,
    index_mut_fn: packed_vector4_array_operator_index,
    index_const_fn: packed_vector4_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: builtin::Color,
    argument_type: builtin::Color,
    argument_pass: ByValue,
    indexed_type: sys::__GdextType,
    variant_type: PACKED_COLOR_ARRAY,
    inner_type: InnerPackedColorArray,
    default_fn: packed_color_array_construct_default,
    copy_fn: packed_color_array_construct_copy,
    destroy_fn: packed_color_array_destroy,
    to_variant_fn: packed_color_array_to_variant,
    from_variant_fn: packed_color_array_from_variant,
    to_array_fn: array_from_packed_color_array,
    from_array_fn: packed_color_array_from_array,
    equals_fn: packed_color_array_operator_equal,
    index_mut_fn: packed_color_array_operator_index,
    index_const_fn: packed_color_array_operator_index_const,
);

impl_packed_array_element!(
    element_type: builtin::GString,
    argument_type: &'a builtin::GString,
    argument_pass: ByRef,
    indexed_type: sys::__GdextString,
    variant_type: PACKED_STRING_ARRAY,
    inner_type: InnerPackedStringArray,
    default_fn: packed_string_array_construct_default,
    copy_fn: packed_string_array_construct_copy,
    destroy_fn: packed_string_array_destroy,
    to_variant_fn: packed_string_array_to_variant,
    from_variant_fn: packed_string_array_from_variant,
    to_array_fn: array_from_packed_string_array,
    from_array_fn: packed_string_array_from_array,
    equals_fn: packed_string_array_operator_equal,
    index_mut_fn: packed_string_array_operator_index,
    index_const_fn: packed_string_array_operator_index_const,
);