@@ -10,6 +10,7 @@ use crate::global::{PropertyHint, PropertyUsageFlags};
10
10
use crate :: meta:: {
11
11
element_godot_type_name, ArrayElement , ClassName , GodotType , PackedArrayElement ,
12
12
} ;
13
+ use crate :: obj:: { EngineBitfield , EngineEnum } ;
13
14
use crate :: registry:: property:: { Export , Var } ;
14
15
use crate :: sys;
15
16
use godot_ffi:: VariantType ;
@@ -179,6 +180,54 @@ impl PropertyInfo {
179
180
}
180
181
}
181
182
183
+ /// Consumes self, moving the values into `sys::GDExtensionPropertyInfo` pointer.
184
+ ///
185
+ /// # Safety
186
+ ///
187
+ /// * `property_info_ptr` must be valid.
188
+ pub ( crate ) unsafe fn move_into_property_info_ptr (
189
+ self ,
190
+ property_info_ptr : * mut sys:: GDExtensionPropertyInfo ,
191
+ ) {
192
+ ( * property_info_ptr) . type_ = self . variant_type . sys ( ) ;
193
+ ( * property_info_ptr) . hint = u32:: try_from ( self . hint_info . hint . ord ( ) ) . expect ( "hint.ord()" ) ;
194
+
195
+ self . hint_info
196
+ . hint_string
197
+ . move_into_string_ptr ( ( * property_info_ptr) . hint_string ) ;
198
+ self . property_name
199
+ . move_into_string_ptr ( ( * property_info_ptr) . name ) ;
200
+
201
+ ( * property_info_ptr) . usage = u32:: try_from ( self . usage . ord ( ) ) . expect ( "usage.ord()" ) ;
202
+
203
+ if self . class_name != ClassName :: none ( ) {
204
+ ( * property_info_ptr) . class_name = sys:: SysPtr :: force_mut ( self . class_name . string_sys ( ) ) ;
205
+ }
206
+ }
207
+
208
+ /// Creates copy of given `sys::GDExtensionPropertyInfo`.
209
+ ///
210
+ /// # Safety
211
+ ///
212
+ /// * `property_info_ptr` must be valid.
213
+ pub ( crate ) unsafe fn new_from_sys (
214
+ property_info_ptr : * mut sys:: GDExtensionPropertyInfo ,
215
+ ) -> Self {
216
+ let variant_type = VariantType :: from_sys ( ( * property_info_ptr) . type_ ) ;
217
+ let property_name = StringName :: new_from_string_sys ( ( * property_info_ptr) . name ) ;
218
+ let hint_string = GString :: new_from_string_sys ( ( * property_info_ptr) . hint_string ) ;
219
+ let hint = PropertyHint :: from_ord ( ( * property_info_ptr) . hint . to_owned ( ) as i32 ) ;
220
+ let usage = PropertyUsageFlags :: from_ord ( ( * property_info_ptr) . usage as u64 ) ;
221
+
222
+ Self {
223
+ variant_type,
224
+ class_name : ClassName :: none ( ) ,
225
+ property_name,
226
+ hint_info : PropertyHintInfo { hint, hint_string } ,
227
+ usage,
228
+ }
229
+ }
230
+
182
231
/// Properly frees a `sys::GDExtensionPropertyInfo` created by [`into_owned_property_sys`](Self::into_owned_property_sys).
183
232
///
184
233
/// # Safety
0 commit comments