Skip to content

Commit 43439ac

Browse files
lilizoeyBromeon
authored andcommitted
Codegen property template; ignore differences in property array when compiling for 4.1 but running in 4.2
1 parent 8b7a12f commit 43439ac

File tree

12 files changed

+291
-705
lines changed

12 files changed

+291
-705
lines changed

.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
# These are supported funding model platforms
26

37
# Up to 4 GitHub Sponsors usernames

godot-core/src/builtin/variant/impls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use sys::GodotFfi;
2121
//
2222
// Thus we can use `init` to indicate when it must be initialized in 4.0.
2323
macro_rules! impl_ffi_variant {
24-
($T:ty, $from_fn:ident, $to_fn:ident $(; $gd_ty:ident)?) => {
24+
($T:ty, $from_fn:ident, $to_fn:ident $(; $godot_type_name:ident)?) => {
2525
impl GodotFfiVariant for $T {
2626
fn ffi_to_variant(&self) -> Variant {
2727
let variant = unsafe {
@@ -74,7 +74,7 @@ macro_rules! impl_ffi_variant {
7474
Some(ffi)
7575
}
7676

77-
impl_ffi_variant!(@godot_type_name $T $(, $gd_ty)?);
77+
impl_ffi_variant!(@godot_type_name $T $(, $godot_type_name)?);
7878
}
7979
};
8080

@@ -84,9 +84,9 @@ macro_rules! impl_ffi_variant {
8484
}
8585
};
8686

87-
(@godot_type_name $T:ty, $gd_ty:ident) => {
87+
(@godot_type_name $T:ty, $godot_type_name:ident) => {
8888
fn godot_type_name() -> String {
89-
stringify!($gd_ty).into()
89+
stringify!($godot_type_name).into()
9090
}
9191
};
9292
}
@@ -108,7 +108,7 @@ mod impls {
108108
impl_ffi_variant!(Vector4, vector4_to_variant, vector4_from_variant);
109109
impl_ffi_variant!(Vector2i, vector2i_to_variant, vector2i_from_variant);
110110
impl_ffi_variant!(Vector3i, vector3i_to_variant, vector3i_from_variant);
111-
impl_ffi_variant!(Vector4i, vector3i_to_variant, vector3i_from_variant);
111+
impl_ffi_variant!(Vector4i, vector4i_to_variant, vector4i_from_variant);
112112
impl_ffi_variant!(Quaternion, quaternion_to_variant, quaternion_from_variant);
113113
impl_ffi_variant!(Color, color_to_variant, color_from_variant);
114114
impl_ffi_variant!(GodotString, string_to_variant, string_from_variant; String);

godot-core/src/property.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,12 @@ mod export_impls {
321321
use godot_ffi as sys;
322322

323323
macro_rules! impl_property_by_clone {
324-
($Ty:ty => $variant_type:ident; no_export) => {
324+
($Ty:ty => $variant_type:ident, no_export) => {
325325
impl_property_by_clone!(@property $Ty => $variant_type);
326326
impl_property_by_clone!(@type_string_hint $Ty, $variant_type);
327327
};
328328

329-
($Ty:ty => $variant_type:ident, $type_string_name:ident; no_export) => {
329+
($Ty:ty => $variant_type:ident, no_export; $type_string_name:ident) => {
330330
impl_property_by_clone!(@property $Ty => $variant_type);
331331
impl_property_by_clone!(@type_string_hint $Ty, $type_string_name);
332332
};
@@ -337,7 +337,7 @@ mod export_impls {
337337
impl_property_by_clone!(@type_string_hint $Ty, $variant_type);
338338
};
339339

340-
($Ty:ty => $variant_type:ident, $type_string_name:ident) => {
340+
($Ty:ty => $variant_type:ident; $type_string_name:ident) => {
341341
impl_property_by_clone!(@property $Ty => $variant_type);
342342
impl_property_by_clone!(@export $Ty);
343343
impl_property_by_clone!(@type_string_hint $Ty, $type_string_name);
@@ -377,7 +377,7 @@ mod export_impls {
377377
}
378378

379379
// Bounding Boxes
380-
impl_property_by_clone!(Aabb => Aabb, AABB);
380+
impl_property_by_clone!(Aabb => Aabb; AABB);
381381
impl_property_by_clone!(Rect2 => Rect2);
382382
impl_property_by_clone!(Rect2i => Rect2i);
383383

@@ -418,28 +418,28 @@ mod export_impls {
418418
impl_property_by_clone!(PackedColorArray => PackedColorArray);
419419

420420
// Primitives
421-
impl_property_by_clone!(f64 => Float, float);
422-
impl_property_by_clone!(i64 => Int, int);
423-
impl_property_by_clone!(bool => Bool, bool);
421+
impl_property_by_clone!(f64 => Float; float);
422+
impl_property_by_clone!(i64 => Int; int);
423+
impl_property_by_clone!(bool => Bool; bool);
424424

425425
// Godot uses f64 internally for floats, and if Godot tries to pass an invalid f32 into a rust property
426426
// then the property will just round the value or become inf.
427-
impl_property_by_clone!(f32 => Float, float);
427+
impl_property_by_clone!(f32 => Float; float);
428428

429429
// Godot uses i64 internally for integers, and if Godot tries to pass an invalid integer into a property
430430
// accepting one of the below values then rust will panic. In the editor this will appear as the property
431431
// failing to be set to a value and an error printed in the console. During runtime this will crash the
432432
// program and print the panic from rust stating that the property cannot store the value.
433-
impl_property_by_clone!(i32 => Int, int);
434-
impl_property_by_clone!(i16 => Int, int);
435-
impl_property_by_clone!(i8 => Int, int);
436-
impl_property_by_clone!(u32 => Int, int);
437-
impl_property_by_clone!(u16 => Int, int);
438-
impl_property_by_clone!(u8 => Int, int);
433+
impl_property_by_clone!(i32 => Int; int);
434+
impl_property_by_clone!(i16 => Int; int);
435+
impl_property_by_clone!(i8 => Int; int);
436+
impl_property_by_clone!(u32 => Int; int);
437+
impl_property_by_clone!(u16 => Int; int);
438+
impl_property_by_clone!(u8 => Int; int);
439439

440440
// Callables are useless when exported to the editor, so we only need to make them available as
441441
// properties.
442-
impl_property_by_clone!(Callable => Callable; no_export);
442+
impl_property_by_clone!(Callable => Callable, no_export);
443443

444444
// RIDs when exported act slightly weird. They are largely read-only, however you can reset them to their
445445
// default value. This seems to me very unintuitive. Since if we are storing an RID we would likely not
@@ -448,7 +448,7 @@ mod export_impls {
448448
//
449449
// Additionally, RIDs aren't persistent, and can sometimes behave a bit weirdly when passed from the
450450
// editor to the runtime.
451-
impl_property_by_clone!(Rid => Rid, RID; no_export);
451+
impl_property_by_clone!(Rid => Rid, no_export; RID);
452452

453453
// impl_property_by_clone!(Signal => Signal);
454454
}

itest/godot/.godot/global_script_class_cache.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ list=Array[Dictionary]([{
55
"language": &"GDScript",
66
"path": "res://TestRunner.gd"
77
}, {
8-
"base": &"Node",
9-
"class": &"PropertyTemplateGDScript",
10-
"icon": "",
11-
"language": &"GDScript",
12-
"path": "res://PropertyTemplate.gd"
13-
}, {
148
"base": &"RefCounted",
159
"class": &"TestStats",
1610
"icon": "",

itest/godot/PropertyTemplate.gd

Lines changed: 0 additions & 221 deletions
This file was deleted.

itest/godot/TestRunner.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ func _ready():
5353
if method_name.begins_with("test_"):
5454
gdscript_tests.push_back(await suite.run_test(suite, method_name))
5555

56-
var property_template = PropertyTemplateGDScript.new()
56+
var property_tests = load("res://gen/GenPropertyTests.gd").new()
5757

5858
var success: bool = rust_runner.run_all_tests(
5959
gdscript_tests,
6060
gdscript_suites.size(),
6161
allow_focus,
6262
self,
6363
filters,
64-
property_template
64+
property_tests
6565
)
6666

6767
if success:

0 commit comments

Comments
 (0)