Skip to content

Commit deb9dbf

Browse files
bors[bot]Bromeon
andauthored
Merge #815
815: Rename symbols for increased clarity r=Bromeon a=Bromeon Addressing the first few of the pending renames in #773. Changes are separated by commits. bors try Co-authored-by: Jan Haller <bromeon@gmail.com>
2 parents 29ddde3 + 5bfdee7 commit deb9dbf

File tree

38 files changed

+358
-337
lines changed

38 files changed

+358
-337
lines changed

bindings_generator/src/documentation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ This class is used to interact with Godot's editor."#
129129
All types in the Godot API have _interior mutability_ in Rust parlance.
130130
To enforce that the official [thread-safety guidelines][thread-safety] are
131131
followed, the typestate pattern is used in the `Ref` and `TRef` smart pointers,
132-
and the `Instance` API. The typestate `Access` in these types tracks whether the
133-
access is unique, shared, or exclusive to the current thread. For more information,
132+
and the `Instance` API. The typestate `Ownership` in these types tracks whether
133+
ownership is unique, shared, or exclusive to the current thread. For more information,
134134
see the type-level documentation on `Ref`.
135135
136136
[thread-safety]: https://docs.godotengine.org/en/stable/tutorials/threads/thread_safe_apis.html"#;

bindings_generator/src/special_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn generate_godot_object_impl(class: &GodotClass) -> TokenStream {
5252
impl gdnative_core::private::godot_object::Sealed for #class_name {}
5353

5454
unsafe impl GodotObject for #class_name {
55-
type RefKind = #memory;
55+
type Memory = #memory;
5656

5757
#[inline]
5858
fn class_name() -> &'static str {

examples/dodge_the_creeps/src/main_scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Main {
140140
/// scene as the root. For instance Spatial is used for this example.
141141
fn instance_scene<Root>(scene: &Ref<PackedScene, Shared>) -> Ref<Root, Unique>
142142
where
143-
Root: gdnative::object::GodotObject<RefKind = ManuallyManaged> + SubClass<Node>,
143+
Root: gdnative::object::GodotObject<Memory = ManuallyManaged> + SubClass<Node>,
144144
{
145145
let scene = unsafe { scene.assume_safe() };
146146

examples/native_plugin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl MyButton {
5858

5959
unsafe fn load<T>(path: &str, hint: &str) -> Option<Ref<T, Shared>>
6060
where
61-
T: GodotObject<RefKind = RefCounted> + SubClass<Resource>,
61+
T: GodotObject<Memory = RefCounted> + SubClass<Resource>,
6262
{
6363
let resource = ResourceLoader::godot_singleton().load(path, hint, false)?;
6464
let resource = resource.assume_safe().claim();

examples/scene_create/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn load_scene(path: &str) -> Option<Ref<PackedScene, ThreadLocal>> {
116116
/// scene as the root. For instance Spatial is used for this example.
117117
fn instance_scene<Root>(scene: &PackedScene) -> Result<Ref<Root, Unique>, ManageErrs>
118118
where
119-
Root: gdnative::object::GodotObject<RefKind = ManuallyManaged> + SubClass<Node>,
119+
Root: gdnative::object::GodotObject<Memory = ManuallyManaged> + SubClass<Node>,
120120
{
121121
let instance = scene
122122
.instance(PackedScene::GEN_EDIT_STATE_DISABLED)

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>,

0 commit comments

Comments
 (0)