@@ -15,11 +15,12 @@ use godot_cell::panicking::{InaccessibleGuard, MutGuard, RefGuard};
15
15
use godot_ffi:: out;
16
16
17
17
use crate :: obj:: script:: ScriptInstance ;
18
- use crate :: obj:: { AsDyn , Gd , GodotClass } ;
18
+ use crate :: obj:: { AsDyn , Gd , GodotClass , PassiveGd } ;
19
19
20
20
/// Immutably/shared bound reference guard for a [`Gd`][crate::obj::Gd] smart pointer.
21
21
///
22
22
/// See [`Gd::bind`][crate::obj::Gd::bind] for usage.
23
+ // GdRef could technically implement Clone, but it wasn't needed so far.
23
24
#[ derive( Debug ) ]
24
25
pub struct GdRef < ' a , T : GodotClass > {
25
26
guard : RefGuard < ' a , T > ,
@@ -45,8 +46,6 @@ impl<T: GodotClass> Drop for GdRef<'_, T> {
45
46
}
46
47
}
47
48
48
- // TODO Clone or Share
49
-
50
49
// ----------------------------------------------------------------------------------------------------------------------------------------------
51
50
52
51
/// Mutably/exclusively bound reference guard for a [`Gd`][crate::obj::Gd] smart pointer.
@@ -199,14 +198,14 @@ macro_rules! make_base_ref {
199
198
#[ doc = concat!( "This can be used to call methods on the base object of a " , $object_name, " that takes `&self` as the receiver.\n \n " ) ]
200
199
#[ doc = concat!( "See [`" , stringify!( $doc_type) , "::base()`](" , stringify!( $doc_path) , "::base()) for usage." ) ]
201
200
pub struct $ident<' a, T : $bound> {
202
- gd : Gd < T :: Base >,
201
+ passive_gd : PassiveGd < ' a , T :: Base >,
203
202
_instance: & ' a T ,
204
203
}
205
204
206
205
impl <' a, T : $bound> $ident<' a, T > {
207
- pub ( crate ) fn new( gd : Gd < T :: Base >, instance: & ' a T ) -> Self {
206
+ pub ( crate ) fn new( passive_gd : PassiveGd < ' a , T :: Base >, instance: & ' a T ) -> Self {
208
207
Self {
209
- gd ,
208
+ passive_gd ,
210
209
_instance: instance,
211
210
}
212
211
}
@@ -216,7 +215,7 @@ macro_rules! make_base_ref {
216
215
type Target = Gd <T :: Base >;
217
216
218
217
fn deref( & self ) -> & Gd <T :: Base > {
219
- & self . gd
218
+ & self . passive_gd
220
219
}
221
220
}
222
221
} ;
@@ -232,17 +231,17 @@ macro_rules! make_base_mut {
232
231
///
233
232
#[ doc = concat!( "See [`" , stringify!( $doc_type) , "::base_mut()`](" , stringify!( $doc_path) , "::base_mut()) for usage.\n " ) ]
234
233
pub struct $ident<' a, T : $bound> {
235
- gd : Gd < T :: Base >,
234
+ passive_gd : PassiveGd < ' a , T :: Base >,
236
235
_inaccessible_guard: InaccessibleGuard <' a, T >,
237
236
}
238
237
239
238
impl <' a, T : $bound> $ident<' a, T > {
240
239
pub ( crate ) fn new(
241
- gd : Gd < T :: Base >,
240
+ passive_gd : PassiveGd < ' a , T :: Base >,
242
241
inaccessible_guard: InaccessibleGuard <' a, T >,
243
242
) -> Self {
244
243
Self {
245
- gd ,
244
+ passive_gd ,
246
245
_inaccessible_guard: inaccessible_guard,
247
246
}
248
247
}
@@ -252,13 +251,13 @@ macro_rules! make_base_mut {
252
251
type Target = Gd <T :: Base >;
253
252
254
253
fn deref( & self ) -> & Gd <T :: Base > {
255
- & self . gd
254
+ & self . passive_gd
256
255
}
257
256
}
258
257
259
258
impl <T : $bound> DerefMut for $ident<' _, T > {
260
259
fn deref_mut( & mut self ) -> & mut Gd <T :: Base > {
261
- & mut self . gd
260
+ & mut self . passive_gd
262
261
}
263
262
}
264
263
} ;
0 commit comments