@@ -9,10 +9,7 @@ use godot_ffi::VariantType;
9
9
use std:: fmt:: Debug ;
10
10
11
11
#[ doc( hidden) ]
12
- pub trait SignatureTuple {
13
- type Params ;
14
- type Ret ;
15
-
12
+ pub trait VarcallSignatureTuple : PtrcallSignatureTuple {
16
13
fn variant_type ( index : i32 ) -> VariantType ;
17
14
fn property_info ( index : i32 , param_name : & str ) -> PropertyInfo ;
18
15
fn param_metadata ( index : i32 ) -> sys:: GDExtensionClassMethodArgumentMetadata ;
@@ -25,6 +22,12 @@ pub trait SignatureTuple {
25
22
func : fn ( sys:: GDExtensionClassInstancePtr , Self :: Params ) -> Self :: Ret ,
26
23
method_name : & str ,
27
24
) ;
25
+ }
26
+
27
+ #[ doc( hidden) ]
28
+ pub trait PtrcallSignatureTuple {
29
+ type Params ;
30
+ type Ret ;
28
31
29
32
// Note: this method imposes extra bounds on GodotFfi, which may not be implemented for user types.
30
33
// We could fall back to varcalls in such cases, and not require GodotFfi categorically.
@@ -58,19 +61,16 @@ use crate::builtin::meta::*;
58
61
use crate :: builtin:: { FromVariant , ToVariant , Variant } ;
59
62
use crate :: obj:: GodotClass ;
60
63
61
- macro_rules! impl_signature_for_tuple {
64
+ macro_rules! impl_varcall_signature_for_tuple {
62
65
(
63
66
$R: ident
64
67
$( , $Pn: ident : $n: literal) *
65
68
) => {
66
69
#[ allow( unused_variables) ]
67
- impl <$R, $( $Pn, ) * > SignatureTuple for ( $R, $( $Pn, ) * )
70
+ impl <$R, $( $Pn, ) * > VarcallSignatureTuple for ( $R, $( $Pn, ) * )
68
71
where $R: VariantMetadata + ToVariant + sys:: GodotFuncMarshal + Debug ,
69
72
$( $Pn: VariantMetadata + FromVariant + sys:: GodotFuncMarshal + Debug , ) *
70
73
{
71
- type Params = ( $( $Pn, ) * ) ;
72
- type Ret = $R;
73
-
74
74
#[ inline]
75
75
fn variant_type( index: i32 ) -> sys:: VariantType {
76
76
match index {
@@ -122,8 +122,23 @@ macro_rules! impl_signature_for_tuple {
122
122
123
123
varcall_return:: <$R>( func( instance_ptr, args) , ret, err)
124
124
}
125
+ }
126
+ } ;
127
+ }
128
+
129
+ macro_rules! impl_ptrcall_signature_for_tuple {
130
+ (
131
+ $R: ident
132
+ $( , $Pn: ident : $n: literal) *
133
+ ) => {
134
+ #[ allow( unused_variables) ]
135
+ impl <$R, $( $Pn, ) * > PtrcallSignatureTuple for ( $R, $( $Pn, ) * )
136
+ where $R: sys:: GodotFuncMarshal + Debug ,
137
+ $( $Pn: sys:: GodotFuncMarshal + Debug , ) *
138
+ {
139
+ type Params = ( $( $Pn, ) * ) ;
140
+ type Ret = $R;
125
141
126
- #[ inline]
127
142
unsafe fn ptrcall<C : GodotClass >(
128
143
instance_ptr: sys:: GDExtensionClassInstancePtr ,
129
144
args_ptr: * const sys:: GDExtensionConstTypePtr ,
@@ -219,14 +234,25 @@ fn return_error<R>(method_name: &str, arg: &impl Debug) -> ! {
219
234
panic ! ( "{method_name}: return type {return_ty} is unable to store value {arg:?}" , ) ;
220
235
}
221
236
222
- impl_signature_for_tuple ! ( R ) ;
223
- impl_signature_for_tuple ! ( R , P0 : 0 ) ;
224
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 ) ;
225
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 ) ;
226
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 ) ;
227
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 ) ;
228
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 ) ;
229
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 ) ;
230
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 ) ;
231
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 , P8 : 8 ) ;
232
- impl_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 , P8 : 8 , P9 : 9 ) ;
237
+ impl_varcall_signature_for_tuple ! ( R ) ;
238
+ impl_ptrcall_signature_for_tuple ! ( R ) ;
239
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 ) ;
240
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 ) ;
241
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 ) ;
242
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 ) ;
243
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 ) ;
244
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 ) ;
245
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 ) ;
246
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 ) ;
247
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 ) ;
248
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 ) ;
249
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 ) ;
250
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 ) ;
251
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 ) ;
252
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 ) ;
253
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 ) ;
254
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 ) ;
255
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 , P8 : 8 ) ;
256
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 , P8 : 8 ) ;
257
+ impl_varcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 , P8 : 8 , P9 : 9 ) ;
258
+ impl_ptrcall_signature_for_tuple ! ( R , P0 : 0 , P1 : 1 , P2 : 2 , P3 : 3 , P4 : 4 , P5 : 5 , P6 : 6 , P7 : 7 , P8 : 8 , P9 : 9 ) ;
0 commit comments