Skip to content

Commit 17892b7

Browse files
committed
Rename RefInstance -> TInstance
1 parent 29ddde3 commit 17892b7

File tree

12 files changed

+48
-41
lines changed

12 files changed

+48
-41
lines changed

gdnative-async/src/method.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use gdnative_core::core_types::{ToVariant, Variant};
88
use gdnative_core::export::{Method, NativeClass, Varargs};
99
use gdnative_core::log::{self, Site};
1010
use gdnative_core::object::ownership::Shared;
11-
use gdnative_core::object::RefInstance;
11+
use gdnative_core::object::TInstance;
1212

1313
use crate::rt::Context;
1414

@@ -41,7 +41,7 @@ pub trait AsyncMethod<C: NativeClass>: Send + Sync + 'static {
4141
pub struct Spawner<'a, C: NativeClass> {
4242
sp: &'static dyn LocalSpawn,
4343
ctx: Context,
44-
this: RefInstance<'a, C, Shared>,
44+
this: TInstance<'a, C, Shared>,
4545
args: Varargs<'a>,
4646
result: &'a mut Option<Result<(), SpawnError>>,
4747
/// Remove Send and Sync
@@ -54,7 +54,7 @@ impl<'a, C: NativeClass> Spawner<'a, C> {
5454
/// future types.
5555
pub fn spawn<F, R>(self, f: F)
5656
where
57-
F: FnOnce(Arc<Context>, RefInstance<'_, C, Shared>, Varargs<'_>) -> R,
57+
F: FnOnce(Arc<Context>, TInstance<'_, C, Shared>, Varargs<'_>) -> R,
5858
R: Future<Output = Variant> + 'static,
5959
{
6060
let ctx = Arc::new(self.ctx);
@@ -84,7 +84,7 @@ impl<F> Async<F> {
8484
}
8585

8686
impl<C: NativeClass, F: AsyncMethod<C>> Method<C> for Async<F> {
87-
fn call(&self, this: RefInstance<'_, C, Shared>, args: Varargs<'_>) -> Variant {
87+
fn call(&self, this: TInstance<'_, C, Shared>, args: Varargs<'_>) -> Variant {
8888
if let Some(sp) = crate::executor::local_spawn() {
8989
let ctx = Context::new();
9090
let func_state = ctx.func_state();

gdnative-async/src/rt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use gdnative_bindings::Object;
55
use gdnative_core::core_types::{GodotError, Variant};
66
use gdnative_core::init::InitHandle;
77
use gdnative_core::object::ownership::Shared;
8-
use gdnative_core::object::{Instance, RefInstance, SubClass, TRef};
8+
use gdnative_core::object::{Instance, SubClass, TInstance, TRef};
99

1010
use crate::future;
1111

@@ -31,7 +31,7 @@ impl Context {
3131
self.func_state.clone()
3232
}
3333

34-
fn safe_func_state(&self) -> RefInstance<'_, FuncState, Shared> {
34+
fn safe_func_state(&self) -> TInstance<'_, FuncState, Shared> {
3535
// SAFETY: FuncState objects are bound to their origin threads in Rust, and
3636
// Context is !Send, so this is safe to call within this type.
3737
// Non-Rust code is expected to be following the official guidelines as per

gdnative-async/src/rt/bridge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use gdnative_core::export::user_data::{ArcData, Map};
99
use gdnative_core::export::{ClassBuilder, Method, NativeClass, NativeClassMethods, Varargs};
1010
use gdnative_core::godot_site;
1111
use gdnative_core::object::ownership::Shared;
12-
use gdnative_core::object::{Instance, RefInstance, TRef};
12+
use gdnative_core::object::{Instance, TInstance, TRef};
1313

1414
use crate::future::Resume;
1515

@@ -97,7 +97,7 @@ impl SignalBridge {
9797
struct OnSignalFn;
9898

9999
impl Method<SignalBridge> for OnSignalFn {
100-
fn call(&self, this: RefInstance<'_, SignalBridge, Shared>, args: Varargs<'_>) -> Variant {
100+
fn call(&self, this: TInstance<'_, SignalBridge, Shared>, args: Varargs<'_>) -> Variant {
101101
let args = args.cloned().collect();
102102

103103
let this_persist = this.clone().claim();

gdnative-async/src/rt/func_state.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gdnative_core::export::{
77
};
88
use gdnative_core::godot_site;
99
use gdnative_core::object::ownership::{Shared, Unique};
10-
use gdnative_core::object::{Instance, RefInstance};
10+
use gdnative_core::object::{Instance, TInstance};
1111
use gdnative_derive::FromVarargs;
1212

1313
use crate::future::Resume;
@@ -57,7 +57,7 @@ impl FuncState {
5757
}
5858
}
5959

60-
pub(super) fn resolve(this: RefInstance<'_, FuncState, Shared>, value: Variant) {
60+
pub(super) fn resolve(this: TInstance<'_, FuncState, Shared>, value: Variant) {
6161
this.script()
6262
.map_mut(|s| {
6363
match s.kind {
@@ -80,7 +80,7 @@ pub(super) fn resolve(this: RefInstance<'_, FuncState, Shared>, value: Variant)
8080
this.base().emit_signal("completed", &[value]);
8181
}
8282

83-
pub(super) fn make_resumable(this: RefInstance<'_, FuncState, Shared>, resume: Resume<Variant>) {
83+
pub(super) fn make_resumable(this: TInstance<'_, FuncState, Shared>, resume: Resume<Variant>) {
8484
let kind = this
8585
.script()
8686
.map_mut(|s| std::mem::replace(&mut s.kind, Kind::Resumable(resume)))
@@ -113,7 +113,7 @@ struct IsValidArgs {
113113

114114
impl StaticArgsMethod<FuncState> for IsValidFn {
115115
type Args = IsValidArgs;
116-
fn call(&self, this: RefInstance<'_, FuncState, Shared>, args: Self::Args) -> Variant {
116+
fn call(&self, this: TInstance<'_, FuncState, Shared>, args: Self::Args) -> Variant {
117117
if args.extended_check.is_some() {
118118
gdnative_core::log::warn(
119119
Self::site().unwrap(),
@@ -145,7 +145,7 @@ struct ResumeArgs {
145145

146146
impl StaticArgsMethod<FuncState> for ResumeFn {
147147
type Args = ResumeArgs;
148-
fn call(&self, this: RefInstance<'_, FuncState, Shared>, args: Self::Args) -> Variant {
148+
fn call(&self, this: TInstance<'_, FuncState, Shared>, args: Self::Args) -> Variant {
149149
this.map_mut(
150150
|s, owner| match std::mem::replace(&mut s.kind, Kind::Pending) {
151151
Kind::Resumable(resume) => {

gdnative-bindings/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use gdnative_core::export::NativeClass;
44
use gdnative_core::object::ownership::Shared;
5-
use gdnative_core::object::{RefInstance, SubClass, TRef};
5+
use gdnative_core::object::{SubClass, TInstance, TRef};
66

77
use super::generated::{Engine, Node, SceneTree};
88

@@ -58,7 +58,7 @@ pub trait NodeExt {
5858
/// invariants must be observed for the resulting node during `'a`, if any.
5959
///
6060
/// [thread-safety]: https://docs.godotengine.org/en/stable/tutorials/threads/thread_safe_apis.html
61-
unsafe fn get_node_as_instance<'a, T>(&self, path: &str) -> Option<RefInstance<'a, T, Shared>>
61+
unsafe fn get_node_as_instance<'a, T>(&self, path: &str) -> Option<TInstance<'a, T, Shared>>
6262
where
6363
T: NativeClass,
6464
T::Base: SubClass<Node>,

gdnative-core/src/export/class_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<C: NativeClass> ClassBuilder<C> {
140140
/// // Now, wrap the method (this can do anything and does not need to actually call a method)
141141
/// struct MyMethod;
142142
/// impl Method<MyType> for MyMethod {
143-
/// fn call(&self, this: RefInstance<'_, MyType, Shared>, _args: Varargs<'_>) -> Variant {
143+
/// fn call(&self, this: TInstance<'_, MyType, Shared>, _args: Varargs<'_>) -> Variant {
144144
/// this.map(|obj: &MyType, _| {
145145
/// let result = obj.my_method();
146146
/// Variant::from_i64(result)

gdnative-core/src/export/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! godot_wrap_method_inner {
2929
struct ThisMethod;
3030

3131
use $crate::export::{NativeClass, OwnerArg};
32-
use $crate::object::{Instance, RefInstance};
32+
use $crate::object::{Instance, TInstance};
3333
use ::gdnative::derive::FromVarargs;
3434

3535
#[derive(FromVarargs)]
@@ -44,7 +44,7 @@ macro_rules! godot_wrap_method_inner {
4444
type Args = Args;
4545
fn call(
4646
&self,
47-
this: RefInstance<'_, $type_name, $crate::object::ownership::Shared>,
47+
this: TInstance<'_, $type_name, $crate::object::ownership::Shared>,
4848
Args { $($pname,)* $($opt_pname,)* }: Args,
4949
) -> $crate::core_types::Variant {
5050
this

gdnative-core/src/export/method.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::export::class::NativeClass;
1212
use crate::export::ClassBuilder;
1313
use crate::log::Site;
1414
use crate::object::ownership::Shared;
15-
use crate::object::{Ref, RefInstance, TRef};
15+
use crate::object::{Ref, TInstance, TRef};
1616

1717
/// Builder type used to register a method on a `NativeClass`.
1818
pub struct MethodBuilder<'a, C, F> {
@@ -140,7 +140,7 @@ pub struct ScriptMethod<'l> {
140140
/// Safe low-level trait for stateful, variadic methods that can be called on a native script type.
141141
pub trait Method<C: NativeClass>: Send + Sync + 'static {
142142
/// Calls the method on `this` with `args`.
143-
fn call(&self, this: RefInstance<'_, C, Shared>, args: Varargs<'_>) -> Variant;
143+
fn call(&self, this: TInstance<'_, C, Shared>, args: Varargs<'_>) -> Variant;
144144

145145
/// Returns an optional site where this method is defined. Used for logging errors in FFI wrappers.
146146
///
@@ -157,7 +157,7 @@ struct Stateless<F> {
157157
}
158158

159159
impl<C: NativeClass, F: Method<C> + Copy + Default> Method<C> for Stateless<F> {
160-
fn call(&self, this: RefInstance<'_, C, Shared>, args: Varargs<'_>) -> Variant {
160+
fn call(&self, this: TInstance<'_, C, Shared>, args: Varargs<'_>) -> Variant {
161161
let f = F::default();
162162
f.call(this, args)
163163
}
@@ -182,7 +182,7 @@ impl<F> StaticArgs<F> {
182182
/// "static method".
183183
pub trait StaticArgsMethod<C: NativeClass>: Send + Sync + 'static {
184184
type Args: FromVarargs;
185-
fn call(&self, this: RefInstance<'_, C, Shared>, args: Self::Args) -> Variant;
185+
fn call(&self, this: TInstance<'_, C, Shared>, args: Self::Args) -> Variant;
186186

187187
/// Returns an optional site where this method is defined. Used for logging errors in FFI wrappers.
188188
///
@@ -195,7 +195,7 @@ pub trait StaticArgsMethod<C: NativeClass>: Send + Sync + 'static {
195195

196196
impl<C: NativeClass, F: StaticArgsMethod<C>> Method<C> for StaticArgs<F> {
197197
#[inline]
198-
fn call(&self, this: RefInstance<'_, C, Shared>, mut args: Varargs<'_>) -> Variant {
198+
fn call(&self, this: TInstance<'_, C, Shared>, mut args: Varargs<'_>) -> Variant {
199199
match args.read_many::<F::Args>() {
200200
Ok(parsed) => {
201201
if let Err(err) = args.done() {
@@ -583,7 +583,7 @@ unsafe extern "C" fn method_wrapper<C: NativeClass, F: Method<C>>(
583583

584584
let this: Ref<C::Base, Shared> = Ref::from_sys(this);
585585
let this: TRef<'_, C::Base, _> = this.assume_safe_unchecked();
586-
let this: RefInstance<'_, C, _> = RefInstance::from_raw_unchecked(this, user_data);
586+
let this: TInstance<'_, C, _> = TInstance::from_raw_unchecked(this, user_data);
587587

588588
let args = Varargs::from_sys(num_args, args);
589589

gdnative-core/src/object/instance.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::private::{get_api, ReferenceCountedClassPlaceholder};
1616
/// A persistent reference to a GodotObject with a rust NativeClass attached.
1717
///
1818
/// `Instance`s can be worked on directly using `map` and `map_mut` if the base object is
19-
/// reference-counted. Otherwise, use `assume_safe` to obtain a temporary `RefInstance`.
19+
/// reference-counted. Otherwise, use `assume_safe` to obtain a temporary `TInstance`.
2020
///
2121
/// See the type-level documentation on `Ref` for more information on typed thread accesses.
2222
#[derive(Debug)]
@@ -30,7 +30,7 @@ pub struct Instance<T: NativeClass, Access: ThreadAccess> {
3030
///
3131
/// See the type-level documentation on `Ref` for more information on typed thread accesses.
3232
#[derive(Debug)]
33-
pub struct RefInstance<'a, T: NativeClass, Access: ThreadAccess> {
33+
pub struct TInstance<'a, T: NativeClass, Access: ThreadAccess> {
3434
owner: TRef<'a, T::Base, Access>,
3535
script: T::UserData,
3636
}
@@ -312,11 +312,11 @@ impl<T: NativeClass> Instance<T, Shared> {
312312
/// It's safe to call `assume_safe` only if the constraints of `Ref::assume_safe`
313313
/// are satisfied for the base object.
314314
#[inline]
315-
pub unsafe fn assume_safe<'a, 'r>(&'r self) -> RefInstance<'a, T, Shared>
315+
pub unsafe fn assume_safe<'a, 'r>(&'r self) -> TInstance<'a, T, Shared>
316316
where
317317
AssumeSafeLifetime<'a, 'r>: LifetimeConstraint<<T::Base as GodotObject>::RefKind>,
318318
{
319-
RefInstance {
319+
TInstance {
320320
owner: self.owner.assume_safe(),
321321
script: self.script.clone(),
322322
}
@@ -434,7 +434,7 @@ where
434434
}
435435
}
436436

437-
impl<'a, T: NativeClass, Access: ThreadAccess> RefInstance<'a, T, Access> {
437+
impl<'a, T: NativeClass, Access: ThreadAccess> TInstance<'a, T, Access> {
438438
/// Returns a reference to the base object with the same lifetime.
439439
#[inline]
440440
pub fn base(&self) -> TRef<'a, T::Base, Access> {
@@ -447,7 +447,7 @@ impl<'a, T: NativeClass, Access: ThreadAccess> RefInstance<'a, T, Access> {
447447
&self.script
448448
}
449449

450-
/// Try to downcast `TRef<'a, T::Base, Access>` to `RefInstance<T>`.
450+
/// Try to downcast `TRef<'a, T::Base, Access>` to `TInstance<T>`.
451451
#[inline]
452452
pub fn try_from_base(owner: TRef<'a, T::Base, Access>) -> Option<Self> {
453453
let user_data = try_get_user_data_ptr::<T>(owner.as_raw())?;
@@ -462,11 +462,11 @@ impl<'a, T: NativeClass, Access: ThreadAccess> RefInstance<'a, T, Access> {
462462
user_data: *mut libc::c_void,
463463
) -> Self {
464464
let script = T::UserData::clone_from_user_data_unchecked(user_data);
465-
RefInstance { owner, script }
465+
TInstance { owner, script }
466466
}
467467
}
468468

469-
impl<'a, T: NativeClass, Access: NonUniqueThreadAccess> RefInstance<'a, T, Access> {
469+
impl<'a, T: NativeClass, Access: NonUniqueThreadAccess> TInstance<'a, T, Access> {
470470
/// Persists this into a persistent `Instance` with the same thread access, without cloning
471471
/// the userdata wrapper.
472472
///
@@ -481,7 +481,7 @@ impl<'a, T: NativeClass, Access: NonUniqueThreadAccess> RefInstance<'a, T, Acces
481481
}
482482

483483
/// Methods for instances with reference-counted base classes.
484-
impl<'a, T: NativeClass, Access: ThreadAccess> RefInstance<'a, T, Access>
484+
impl<'a, T: NativeClass, Access: ThreadAccess> TInstance<'a, T, Access>
485485
where
486486
T::Base: GodotObject,
487487
{
@@ -533,13 +533,13 @@ where
533533
}
534534
}
535535

536-
impl<'a, T, Access: ThreadAccess> Clone for RefInstance<'a, T, Access>
536+
impl<'a, T, Access: ThreadAccess> Clone for TInstance<'a, T, Access>
537537
where
538538
T: NativeClass,
539539
{
540540
#[inline]
541541
fn clone(&self) -> Self {
542-
RefInstance {
542+
TInstance {
543543
owner: self.owner,
544544
script: self.script.clone(),
545545
}

gdnative-core/src/object/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,13 +933,13 @@ impl<'a, T: GodotObject, Access: ThreadAccess> TRef<'a, T, Access> {
933933
TRef::new(self.obj.upcast())
934934
}
935935

936-
/// Convenience method to downcast to `RefInstance` where `self` is the base object.
936+
/// Convenience method to downcast to `TInstance` where `self` is the base object.
937937
#[inline]
938-
pub fn cast_instance<C>(self) -> Option<RefInstance<'a, C, Access>>
938+
pub fn cast_instance<C>(self) -> Option<TInstance<'a, C, Access>>
939939
where
940940
C: NativeClass<Base = T>,
941941
{
942-
RefInstance::try_from_base(self)
942+
TInstance::try_from_base(self)
943943
}
944944
}
945945

0 commit comments

Comments
 (0)