@@ -274,34 +274,33 @@ impl_godot_scalar!(
274
274
// void* is used by ScriptExtension::instance_create().
275
275
// Other impls for raw pointers are generated for native structures.
276
276
277
- impl GodotConvert for * const std:: ffi:: c_void {
278
- type Via = i64 ;
279
- }
277
+ macro_rules! impl_pointer_convert {
278
+ ( $Ptr: ty) => {
279
+ impl GodotConvert for $Ptr {
280
+ type Via = i64 ;
281
+ }
280
282
281
- impl ToGodot for * const std :: ffi :: c_void {
282
- fn to_godot ( & self ) -> Self :: Via {
283
- * self as i64
284
- }
285
- }
283
+ impl ToGodot for $Ptr {
284
+ fn to_godot( & self ) -> Self :: Via {
285
+ * self as i64
286
+ }
287
+ }
286
288
287
- impl FromGodot for * const std:: ffi:: c_void {
288
- fn try_from_godot ( via : Self :: Via ) -> Result < Self , ConvertError > {
289
- Ok ( via as Self )
290
- }
289
+ impl FromGodot for $Ptr {
290
+ fn try_from_godot( via: Self :: Via ) -> Result <Self , ConvertError > {
291
+ Ok ( via as Self )
292
+ }
293
+ }
294
+ } ;
291
295
}
292
296
293
- impl GodotConvert for * mut std:: ffi:: c_void {
294
- type Via = i64 ;
295
- }
297
+ impl_pointer_convert ! ( * const std:: ffi:: c_void) ;
298
+ impl_pointer_convert ! ( * mut std:: ffi:: c_void) ;
296
299
297
- impl ToGodot for * mut std:: ffi:: c_void {
298
- fn to_godot ( & self ) -> Self :: Via {
299
- * self as i64
300
- }
301
- }
300
+ // Some other pointer types are used by various other methods, see https://github.com/godot-rust/gdext/issues/677
301
+ // TODO: Find better solution to this, this may easily break still if godot decides to add more pointer arguments.
302
302
303
- impl FromGodot for * mut std:: ffi:: c_void {
304
- fn try_from_godot ( via : Self :: Via ) -> Result < Self , ConvertError > {
305
- Ok ( via as Self )
306
- }
307
- }
303
+ impl_pointer_convert ! ( * mut * const u8 ) ;
304
+ impl_pointer_convert ! ( * mut i32 ) ;
305
+ impl_pointer_convert ! ( * mut f64 ) ;
306
+ impl_pointer_convert ! ( * mut u8 ) ;
0 commit comments