Skip to content

Commit 74b729a

Browse files
committed
Add support for typed arrays
- Rename `Array` to `TypedArray<T>` - Check/set runtime type of the underlying Godot `Array` - Make all parameters and return values `T` instead of `Variant` - Add `Array` as an alias for `TypedArray<Variant>` - Add `array!` macro and use it in tests - Add `array!` and also `dict!` in the prelude See #33 for design discussion
1 parent 17487d6 commit 74b729a

File tree

15 files changed

+913
-454
lines changed

15 files changed

+913
-454
lines changed

godot-codegen/src/class_generator.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,17 @@ fn make_builtin_class(
297297
sys_ptr: sys::GDExtensionTypePtr,
298298
}
299299
impl<'a> #inner_class<'a> {
300-
pub fn from_outer(outer: &#outer_class) -> Self {
300+
pub fn from_sys_ptr(sys_ptr: sys::GDExtensionTypePtr) -> Self {
301301
Self {
302302
_outer_lifetime: std::marker::PhantomData,
303-
sys_ptr: outer.sys(),
303+
sys_ptr,
304304
}
305305
}
306306

307+
pub fn from_outer(outer: &#outer_class) -> Self {
308+
Self::from_sys_ptr(outer.sys())
309+
}
310+
307311
#methods
308312
}
309313

godot-codegen/src/util.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream {
5151
Self { ord: self.ord | rhs.ord }
5252
}
5353
}
54+
55+
impl Default for #enum_name {
56+
fn default() -> Self {
57+
Self { ord: 0 }
58+
}
59+
}
5460
};
5561

5662
Some(tokens)

0 commit comments

Comments
 (0)