|
9 | 9 |
|
10 | 10 | use godot_ffi as sys; |
11 | 11 |
|
12 | | -use crate::builtin::meta::{FromGodot, GodotConvert, ToGodot}; |
| 12 | +use crate::builtin::meta::{FromGodot, GodotConvert, GodotType, ToGodot}; |
13 | 13 | use crate::builtin::GString; |
14 | 14 | use crate::engine::global::PropertyHint; |
15 | 15 |
|
@@ -336,7 +336,6 @@ pub mod export_info_functions { |
336 | 336 | mod export_impls { |
337 | 337 | use super::*; |
338 | 338 | use crate::builtin::*; |
339 | | - use godot_ffi as sys; |
340 | 339 |
|
341 | 340 | macro_rules! impl_property_by_godot_convert { |
342 | 341 | ($Ty:ty, no_export) => { |
@@ -373,15 +372,7 @@ mod export_impls { |
373 | 372 | (@type_string_hint $Ty:ty) => { |
374 | 373 | impl TypeStringHint for $Ty { |
375 | 374 | fn type_string() -> String { |
376 | | - use sys::GodotFfi as _; |
377 | | - let variant_type = <$Ty as $crate::builtin::meta::GodotType>::Ffi::variant_type(); |
378 | | - |
379 | | - if sys::GdextBuild::since_api("4.3") { |
380 | | - format!("{}:", variant_type as i32) |
381 | | - } else { |
382 | | - let type_name = <$Ty as $crate::builtin::meta::GodotType>::godot_type_name(); |
383 | | - format!("{}:{}", variant_type as i32, type_name) |
384 | | - } |
| 375 | + builtin_type_string::<$Ty>() |
385 | 376 | } |
386 | 377 | } |
387 | 378 | } |
@@ -467,3 +458,19 @@ mod export_impls { |
467 | 458 |
|
468 | 459 | // impl_property_by_godot_convert!(Signal); |
469 | 460 | } |
| 461 | + |
| 462 | +// ---------------------------------------------------------------------------------------------------------------------------------------------- |
| 463 | +// Crate-local utilities |
| 464 | + |
| 465 | +pub(crate) fn builtin_type_string<T: GodotType>() -> String { |
| 466 | + use sys::GodotFfi as _; |
| 467 | + |
| 468 | + let variant_type = T::Ffi::variant_type(); |
| 469 | + |
| 470 | + // Godot 4.3 changed representation for type hints, see https://github.com/godotengine/godot/pull/90716. |
| 471 | + if sys::GdextBuild::since_api("4.3") { |
| 472 | + format!("{}:", variant_type.sys()) |
| 473 | + } else { |
| 474 | + format!("{}:{}", variant_type.sys(), T::godot_type_name()) |
| 475 | + } |
| 476 | +} |
0 commit comments