@@ -12,21 +12,22 @@ use crate::engine::global::PropertyHint;
1212
1313/// Trait implemented for types that can be used as `#[var]` fields. This creates a copy of the
1414/// value, for some type-specific definition of "copy". For example, `Array`, `Dictionary` and `Gd` are
15- /// returned via `Share::share()` instead of copying the actual data.
15+ /// returned by shared reference instead of copying the actual data.
1616pub trait Property {
1717 type Intermediate ;
1818
19- fn property_hint ( ) -> ExportInfo {
20- ExportInfo :: with_hint_none ( )
21- }
2219 fn get_property ( & self ) -> Self :: Intermediate ;
2320 fn set_property ( & mut self , value : Self :: Intermediate ) ;
21+
22+ fn property_hint ( ) -> PropertyHintInfo {
23+ PropertyHintInfo :: with_hint_none ( "" )
24+ }
2425}
2526
2627/// Trait implemented for types that can be used as `#[export]` fields.
2728pub trait Export : Property {
2829 /// The export info to use for an exported field of this type, if no other export info is specified.
29- fn default_export_info ( ) -> ExportInfo ;
30+ fn default_export_info ( ) -> PropertyHintInfo ;
3031}
3132
3233/// Trait for types that can be represented as a type string for use with
@@ -77,7 +78,7 @@ impl<T> Export for Option<T>
7778where
7879 T : Export + From < <T as Property >:: Intermediate > ,
7980{
80- fn default_export_info ( ) -> ExportInfo {
81+ fn default_export_info ( ) -> PropertyHintInfo {
8182 T :: default_export_info ( )
8283 }
8384}
@@ -87,18 +88,20 @@ where
8788
8889/// Info needed for godot to understand how to export a type to the editor.
8990#[ derive( Clone , Eq , PartialEq , Debug ) ]
90- pub struct ExportInfo {
91+ pub struct PropertyHintInfo {
9192 pub hint : PropertyHint ,
9293 pub hint_string : GodotString ,
9394}
9495
95- impl ExportInfo {
96- /// Create a new `ExportInfo ` with a property hint of
96+ impl PropertyHintInfo {
97+ /// Create a new `PropertyHintInfo ` with a property hint of
9798 /// [`PROPERTY_HINT_NONE`](PropertyHint::PROPERTY_HINT_NONE).
98- pub fn with_hint_none ( ) -> Self {
99+ ///
100+ /// Usually Godot expects this to be combined with a `hint_string` containing the name of the type.
101+ pub fn with_hint_none < S : Into < GodotString > > ( type_name : S ) -> Self {
99102 Self {
100103 hint : PropertyHint :: PROPERTY_HINT_NONE ,
101- hint_string : GodotString :: new ( ) ,
104+ hint_string : type_name . into ( ) ,
102105 }
103106 }
104107}
@@ -125,7 +128,7 @@ pub mod export_info_functions {
125128 use crate :: builtin:: GodotString ;
126129 use crate :: engine:: global:: PropertyHint ;
127130
128- use super :: ExportInfo ;
131+ use super :: PropertyHintInfo ;
129132
130133 /// Turn a list of variables into a comma separated string containing only the identifiers corresponding
131134 /// to a true boolean variable.
@@ -156,7 +159,7 @@ pub mod export_info_functions {
156159 radians : bool ,
157160 degrees : bool ,
158161 hide_slider : bool ,
159- ) -> ExportInfo {
162+ ) -> PropertyHintInfo {
160163 let min_max = format ! ( "{},{}" , min, max) ;
161164
162165 let rest =
@@ -168,7 +171,7 @@ pub mod export_info_functions {
168171 format ! ( "{min_max},{rest}" )
169172 } ;
170173
171- ExportInfo {
174+ PropertyHintInfo {
172175 hint : PropertyHint :: PROPERTY_HINT_RANGE ,
173176 hint_string : hint_string. into ( ) ,
174177 }
@@ -217,64 +220,64 @@ pub mod export_info_functions {
217220
218221 type EnumVariant = ExportValueWithKey < i64 > ;
219222
220- pub fn export_enum < T > ( variants : & [ T ] ) -> ExportInfo
223+ pub fn export_enum < T > ( variants : & [ T ] ) -> PropertyHintInfo
221224 where
222225 for < ' a > & ' a T : Into < EnumVariant > ,
223226 {
224227 let hint_string: String = EnumVariant :: slice_as_hint_string ( variants) ;
225228
226- ExportInfo {
229+ PropertyHintInfo {
227230 hint : PropertyHint :: PROPERTY_HINT_ENUM ,
228231 hint_string : hint_string. into ( ) ,
229232 }
230233 }
231234
232- pub fn export_exp_easing ( attenuation : bool , positive_only : bool ) -> ExportInfo {
235+ pub fn export_exp_easing ( attenuation : bool , positive_only : bool ) -> PropertyHintInfo {
233236 let hint_string = comma_separate_boolean_idents ! ( attenuation, positive_only) ;
234237
235- ExportInfo {
238+ PropertyHintInfo {
236239 hint : PropertyHint :: PROPERTY_HINT_EXP_EASING ,
237240 hint_string : hint_string. into ( ) ,
238241 }
239242 }
240243
241244 type BitFlag = ExportValueWithKey < u32 > ;
242245
243- pub fn export_flags < T > ( bits : & [ T ] ) -> ExportInfo
246+ pub fn export_flags < T > ( bits : & [ T ] ) -> PropertyHintInfo
244247 where
245248 for < ' a > & ' a T : Into < BitFlag > ,
246249 {
247250 let hint_string = BitFlag :: slice_as_hint_string ( bits) ;
248251
249- ExportInfo {
252+ PropertyHintInfo {
250253 hint : PropertyHint :: PROPERTY_HINT_FLAGS ,
251254 hint_string : hint_string. into ( ) ,
252255 }
253256 }
254257
255- pub fn export_file < S : AsRef < str > > ( filter : S ) -> ExportInfo {
258+ pub fn export_file < S : AsRef < str > > ( filter : S ) -> PropertyHintInfo {
256259 export_file_inner ( false , filter)
257260 }
258261
259- pub fn export_global_file < S : AsRef < str > > ( filter : S ) -> ExportInfo {
262+ pub fn export_global_file < S : AsRef < str > > ( filter : S ) -> PropertyHintInfo {
260263 export_file_inner ( true , filter)
261264 }
262265
263- pub fn export_file_inner < S : AsRef < str > > ( global : bool , filter : S ) -> ExportInfo {
266+ pub fn export_file_inner < S : AsRef < str > > ( global : bool , filter : S ) -> PropertyHintInfo {
264267 let hint = if global {
265- PropertyHint :: PROPERTY_HINT_FILE
266- } else {
267268 PropertyHint :: PROPERTY_HINT_GLOBAL_FILE
269+ } else {
270+ PropertyHint :: PROPERTY_HINT_FILE
268271 } ;
269272
270- ExportInfo {
273+ PropertyHintInfo {
271274 hint,
272275 hint_string : filter. as_ref ( ) . into ( ) ,
273276 }
274277 }
275278
276- pub fn export_placeholder < S : AsRef < str > > ( placeholder : S ) -> ExportInfo {
277- ExportInfo {
279+ pub fn export_placeholder < S : AsRef < str > > ( placeholder : S ) -> PropertyHintInfo {
280+ PropertyHintInfo {
278281 hint : PropertyHint :: PROPERTY_HINT_PLACEHOLDER_TEXT ,
279282 hint_string : placeholder. as_ref ( ) . into ( ) ,
280283 }
@@ -285,8 +288,8 @@ pub mod export_info_functions {
285288 $( $function_name: ident => $property_hint: ident, ) *
286289 ) => {
287290 $(
288- pub fn $function_name( ) -> ExportInfo {
289- ExportInfo {
291+ pub fn $function_name( ) -> PropertyHintInfo {
292+ PropertyHintInfo {
290293 hint: PropertyHint :: $property_hint,
291294 hint_string: GodotString :: new( )
292295 }
@@ -356,8 +359,8 @@ mod export_impls {
356359
357360 ( @export $Ty: ty) => {
358361 impl Export for $Ty {
359- fn default_export_info( ) -> ExportInfo {
360- ExportInfo :: with_hint_none( )
362+ fn default_export_info( ) -> PropertyHintInfo {
363+ PropertyHintInfo :: with_hint_none( <$Ty as $crate :: builtin :: meta :: GodotType > :: godot_type_name ( ) )
361364 }
362365 }
363366 } ;
0 commit comments