@@ -10,7 +10,7 @@ use std::ffi::CStr;
10
10
use crate :: builtin:: { GString , NodePath , StringName , Variant } ;
11
11
use crate :: meta:: sealed:: Sealed ;
12
12
use crate :: meta:: traits:: { GodotFfiVariant , GodotNullableFfi } ;
13
- use crate :: meta:: { CowArg , GodotType , ObjectArg , ToGodot } ;
13
+ use crate :: meta:: { CowArg , FfiArg , GodotType , ObjectArg , ToGodot } ;
14
14
use crate :: obj:: { bounds, Bounds , DynGd , Gd , GodotClass , Inherits } ;
15
15
16
16
/// Implicit conversions for arguments passed to Godot APIs.
@@ -97,13 +97,14 @@ where
97
97
98
98
/// FFI-optimized argument conversion that may use `FfiObject` when beneficial.
99
99
///
100
- /// Defaults to calling `into_arg()`, which always works, but might be an `Owned` for a conservative approach (e.g. object upcast).
100
+ /// Defaults to calling `into_arg()` and wrapping in `FfiArg::Cow()`, which always works, but might be an `Owned` for a conservative
101
+ /// approach (e.g. object upcast).
101
102
#[ doc( hidden) ]
102
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , T >
103
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , T >
103
104
where
104
105
Self : ' arg ,
105
106
{
106
- self . into_arg ( )
107
+ FfiArg :: Cow ( self . into_arg ( ) )
107
108
}
108
109
}
109
110
@@ -157,13 +158,12 @@ where
157
158
}
158
159
}
159
160
160
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , Gd < Base > >
161
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , Gd < Base > >
161
162
where
162
163
Self : ' arg ,
163
164
{
164
- // SAFETY: ObjectArg exists only during FFI call.
165
- let arg = unsafe { ObjectArg :: from_gd ( self ) } ;
166
- CowArg :: FfiObject ( arg)
165
+ let arg = ObjectArg :: from_gd ( self ) ;
166
+ FfiArg :: FfiObject ( arg)
167
167
}
168
168
}
169
169
@@ -190,13 +190,12 @@ where
190
190
}
191
191
}
192
192
193
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , DynGd < Base , D > >
193
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , DynGd < Base , D > >
194
194
where
195
195
Self : ' arg ,
196
196
{
197
- // SAFETY: ObjectArg exists only during FFI call.
198
- let arg = unsafe { ObjectArg :: from_gd ( self ) } ;
199
- CowArg :: FfiObject ( arg)
197
+ let arg = ObjectArg :: from_gd ( self ) ;
198
+ FfiArg :: FfiObject ( arg)
200
199
}
201
200
}
202
201
@@ -215,7 +214,7 @@ where
215
214
AsArg :: into_arg ( gd_ref)
216
215
}
217
216
218
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , Gd < Base > >
217
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , Gd < Base > >
219
218
where
220
219
Self : ' arg ,
221
220
{
@@ -244,13 +243,12 @@ where
244
243
}
245
244
}
246
245
247
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , Option < Gd < Base > > >
246
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , Option < Gd < Base > > >
248
247
where
249
248
Self : ' arg ,
250
249
{
251
- // SAFETY: ObjectArg exists only during FFI call.
252
- let arg = unsafe { ObjectArg :: from_option_gd ( self ) } ;
253
- CowArg :: FfiObject ( arg)
250
+ let arg = ObjectArg :: from_option_gd ( self ) ;
251
+ FfiArg :: FfiObject ( arg)
254
252
}
255
253
}
256
254
@@ -268,13 +266,12 @@ where
268
266
CowArg :: Owned ( Some ( self . clone ( ) . upcast :: < Base > ( ) ) )
269
267
}
270
268
271
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , Option < Gd < Base > > >
269
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , Option < Gd < Base > > >
272
270
where
273
271
Self : ' arg ,
274
272
{
275
- // SAFETY: ObjectArg exists only during FFI call.
276
- let arg = unsafe { ObjectArg :: from_gd ( self ) } ;
277
- CowArg :: FfiObject ( arg)
273
+ let arg = ObjectArg :: from_gd ( self ) ;
274
+ FfiArg :: FfiObject ( arg)
278
275
}
279
276
}
280
277
@@ -293,7 +290,7 @@ where
293
290
AsArg :: into_arg ( gd_ref)
294
291
}
295
292
296
- fn into_ffi_arg < ' arg > ( self ) -> CowArg < ' arg , Option < Gd < Base > > >
293
+ fn into_ffi_arg < ' arg > ( self ) -> FfiArg < ' arg , Option < Gd < Base > > >
297
294
where
298
295
Self : ' arg ,
299
296
{
@@ -614,7 +611,7 @@ impl ArgPassing for ByObject {
614
611
type Output < ' r , T : ' r > = & ' r T ;
615
612
616
613
type FfiOutput < ' f , T >
617
- = ObjectArg
614
+ = ObjectArg < ' f >
618
615
where
619
616
T : GodotType + ' f ;
620
617
@@ -627,13 +624,13 @@ impl ArgPassing for ByObject {
627
624
value. to_godot ( ) . clone ( )
628
625
}
629
626
630
- fn ref_to_ffi < T > ( value : & T ) -> ObjectArg
627
+ fn ref_to_ffi < T > ( value : & T ) -> ObjectArg < ' _ >
631
628
where
632
629
T : ToGodot < Pass = Self > ,
633
630
T :: Via : GodotType ,
634
631
{
635
632
let obj_ref: & T :: Via = value. to_godot ( ) ; // implements GodotType.
636
- unsafe { obj_ref. as_object_arg ( ) }
633
+ obj_ref. as_object_arg ( )
637
634
}
638
635
}
639
636
0 commit comments