Skip to content

Commit 3605f0f

Browse files
authored
Merge pull request #482 from Esption/32bits
Fixed some missed aligns for 32-bit support
2 parents 3e28201 + f4bd3fc commit 3605f0f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

godot-core/src/builtin/packed_array.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ use sys::{ffi_methods, interface_fn, GodotFfi};
1515
// FIXME remove dependency on these types
1616
use sys::{__GdextString, __GdextType};
1717

18+
// TODO(bromeon): ensure and test that all element types can be packed.
19+
// Many builtin types don't have a #[repr] themselves, but they are used in packed arrays, which assumes certain size and alignment.
20+
// This is mostly a problem for as_slice(), which reinterprets the FFI representation into the "frontend" type like GString.
21+
1822
/// Defines and implements a single packed array type. This macro is not hygienic and is meant to
1923
/// be used only in the current module.
2024
macro_rules! impl_packed_array {

godot-core/src/builtin/string/gstring.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ pub type GodotString = GString;
5353
///
5454
/// Godot also provides two separate string classes with slightly different semantics: [`StringName`] and [`NodePath`].
5555
#[doc(alias = "String")]
56-
#[repr(C, align(8))]
56+
// #[repr] is needed on GString itself rather than the opaque field, because PackedStringArray::as_slice() relies on a packed representation.
57+
#[repr(transparent)]
5758
pub struct GString {
5859
opaque: OpaqueString,
5960
}

0 commit comments

Comments
 (0)