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 <[email protected]>
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>,

gdnative-core/src/core_types/access.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ pub unsafe trait Guard: private::Sealed {
5050
pub unsafe trait WritePtr: Guard + private::Sealed {}
5151

5252
pub(crate) mod private {
53-
use crate::core_types::typed_array::Element;
53+
use crate::core_types::pool_array::Element;
5454

5555
pub trait Sealed {}
5656

57-
impl<'a, T: Element> Sealed for crate::core_types::typed_array::ReadGuard<'a, T> {}
58-
impl<'a, T: Element> Sealed for crate::core_types::typed_array::WriteGuard<'a, T> {}
57+
impl<'a, T: Element> Sealed for crate::core_types::pool_array::ReadGuard<'a, T> {}
58+
impl<'a, T: Element> Sealed for crate::core_types::pool_array::WriteGuard<'a, T> {}
5959
}
6060

6161
impl<G: Guard> MaybeUnaligned<G> {

gdnative-core/src/core_types/byte_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22

33
/// A reference-counted vector of `u8` that uses Godot's pool allocator.
4-
pub type ByteArray = TypedArray<u8>;
4+
pub type ByteArray = PoolArray<u8>;
55

66
godot_test!(
77
test_byte_array_access {

gdnative-core/src/core_types/color_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::core_types::Color;
2-
use crate::core_types::TypedArray;
2+
use crate::core_types::PoolArray;
33

44
/// A reference-counted vector of `Color` that uses Godot's pool allocator.
5-
pub type ColorArray = TypedArray<Color>;
5+
pub type ColorArray = PoolArray<Color>;
66

77
godot_test!(
88
test_color_array_access {

gdnative-core/src/core_types/dictionary.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ use crate::object::ownership::*;
2020
///
2121
/// This is a reference-counted collection with "interior mutability" in Rust parlance.
2222
/// To enforce that the official [thread-safety guidelines][thread-safety] are
23-
/// followed this type uses the *typestate* pattern. The typestate `Access` tracks
23+
/// followed this type uses the *typestate* pattern. The typestate `Ownership` tracks
2424
/// whether there is thread-local or unique access (where pretty much all operations are safe)
2525
/// or whether the value might be "shared", in which case not all operations are
2626
/// safe.
2727
///
2828
/// [thread-safety]: https://docs.godotengine.org/en/stable/tutorials/threads/thread_safe_apis.html
29-
pub struct Dictionary<Access: ThreadAccess = Shared> {
29+
pub struct Dictionary<Own: Ownership = Shared> {
3030
sys: sys::godot_dictionary,
3131

3232
/// Marker preventing the compiler from incorrectly deriving `Send` and `Sync`.
33-
_marker: PhantomData<Access>,
33+
_marker: PhantomData<Own>,
3434
}
3535

3636
/// Operations allowed on all Dictionaries at any point in time.
37-
impl<Access: ThreadAccess> Dictionary<Access> {
37+
impl<Own: Ownership> Dictionary<Own> {
3838
/// Returns `true` if the `Dictionary` contains no elements.
3939
#[inline]
4040
pub fn is_empty(&self) -> bool {
@@ -58,7 +58,7 @@ impl<Access: ThreadAccess> Dictionary<Access> {
5858

5959
/// Returns true if the `Dictionary` has all of the keys in the given array.
6060
#[inline]
61-
pub fn contains_all<ArrAccess: ThreadAccess>(&self, keys: &VariantArray<ArrAccess>) -> bool {
61+
pub fn contains_all<ArrayOws: Ownership>(&self, keys: &VariantArray<ArrayOws>) -> bool {
6262
unsafe { (get_api().godot_dictionary_has_all)(self.sys(), keys.sys()) }
6363
}
6464

@@ -200,7 +200,7 @@ impl<Access: ThreadAccess> Dictionary<Access> {
200200
/// Modifying the same underlying collection while observing the safety assumptions will
201201
/// not violate memory safely, but may lead to surprising behavior in the iterator.
202202
#[inline]
203-
pub fn iter(&self) -> Iter<Access> {
203+
pub fn iter(&self) -> Iter<Own> {
204204
Iter::new(self)
205205
}
206206

@@ -238,7 +238,7 @@ impl<Access: ThreadAccess> Dictionary<Access> {
238238
}
239239
}
240240

241-
unsafe fn cast_access<A: ThreadAccess>(self) -> Dictionary<A> {
241+
unsafe fn cast_access<A: Ownership>(self) -> Dictionary<A> {
242242
let sys = self.sys;
243243
std::mem::forget(self);
244244
Dictionary::from_sys(sys)
@@ -264,7 +264,7 @@ impl Dictionary<ThreadLocal> {
264264
}
265265

266266
/// Operations allowed on Dictionaries that are not unique.
267-
impl<Access: NonUniqueThreadAccess> Dictionary<Access> {
267+
impl<Own: NonUniqueOwnership> Dictionary<Own> {
268268
/// Assume that this is the only reference to this dictionary, on which
269269
/// operations that change the container size can be safely performed.
270270
///
@@ -282,7 +282,7 @@ impl<Access: NonUniqueThreadAccess> Dictionary<Access> {
282282
}
283283

284284
/// Operations allowed on Dictionaries that can only be referenced to from the current thread.
285-
impl<Access: LocalThreadAccess> Dictionary<Access> {
285+
impl<Own: LocalThreadOwnership> Dictionary<Own> {
286286
#[inline]
287287
/// Inserts or updates the value of the element corresponding to the key.
288288
pub fn insert<K, V>(&self, key: K, val: V)
@@ -340,7 +340,7 @@ impl Dictionary<Unique> {
340340
}
341341
}
342342

343-
impl<Access: ThreadAccess> Drop for Dictionary<Access> {
343+
impl<Own: Ownership> Drop for Dictionary<Own> {
344344
#[inline]
345345
fn drop(&mut self) {
346346
unsafe { (get_api().godot_dictionary_destroy)(self.sys_mut()) }
@@ -368,7 +368,7 @@ impl Default for Dictionary<ThreadLocal> {
368368
}
369369
}
370370

371-
impl<Access: NonUniqueThreadAccess> NewRef for Dictionary<Access> {
371+
impl<Own: NonUniqueOwnership> NewRef for Dictionary<Own> {
372372
#[inline]
373373
fn new_ref(&self) -> Self {
374374
unsafe {
@@ -393,15 +393,15 @@ impl From<Dictionary<Unique>> for Dictionary<ThreadLocal> {
393393
}
394394
}
395395

396-
impl<Access: ThreadAccess> fmt::Debug for Dictionary<Access> {
396+
impl<Own: Ownership> fmt::Debug for Dictionary<Own> {
397397
#[inline]
398398
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
399399
self.to_json().to_string().fmt(f)
400400
}
401401
}
402402

403-
unsafe fn iter_next<Access: ThreadAccess>(
404-
dic: &Dictionary<Access>,
403+
unsafe fn iter_next<Own: Ownership>(
404+
dic: &Dictionary<Own>,
405405
last_key: &mut Option<Variant>,
406406
) -> Option<(Variant, Variant)> {
407407
let last_ptr = last_key.as_ref().map_or(std::ptr::null(), Variant::sys);
@@ -421,22 +421,22 @@ unsafe fn iter_next<Access: ThreadAccess>(
421421
///
422422
/// This struct is created by the `iter` method on `Dictionary<Unique>`.
423423
#[derive(Debug)]
424-
pub struct Iter<'a, Access: ThreadAccess> {
425-
dic: &'a Dictionary<Access>,
424+
pub struct Iter<'a, Own: Ownership> {
425+
dic: &'a Dictionary<Own>,
426426
last_key: Option<Variant>,
427427
}
428428

429-
impl<'a, Access: ThreadAccess> Iter<'a, Access> {
429+
impl<'a, Own: Ownership> Iter<'a, Own> {
430430
/// Create an Iterator from a unique Dictionary.
431-
fn new(dic: &'a Dictionary<Access>) -> Self {
431+
fn new(dic: &'a Dictionary<Own>) -> Self {
432432
Iter {
433433
dic,
434434
last_key: None,
435435
}
436436
}
437437
}
438438

439-
impl<'a, Access: ThreadAccess> Iterator for Iter<'a, Access> {
439+
impl<'a, Own: Ownership> Iterator for Iter<'a, Own> {
440440
type Item = (Variant, Variant);
441441

442442
#[inline]
@@ -451,9 +451,9 @@ impl<'a, Access: ThreadAccess> Iterator for Iter<'a, Access> {
451451
}
452452
}
453453

454-
impl<'a, Access: ThreadAccess> IntoIterator for &'a Dictionary<Access> {
454+
impl<'a, Own: Ownership> IntoIterator for &'a Dictionary<Own> {
455455
type Item = (Variant, Variant);
456-
type IntoIter = Iter<'a, Access>;
456+
type IntoIter = Iter<'a, Own>;
457457
#[inline]
458458
fn into_iter(self) -> Self::IntoIter {
459459
self.iter()
@@ -517,7 +517,7 @@ where
517517
}
518518
}
519519

520-
impl<K, V, Access: LocalThreadAccess> Extend<(K, V)> for Dictionary<Access>
520+
impl<K, V, Own: LocalThreadOwnership> Extend<(K, V)> for Dictionary<Own>
521521
where
522522
K: ToVariantEq + OwnedToVariant,
523523
V: OwnedToVariant,

gdnative-core/src/core_types/float32_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22

33
/// A reference-counted vector of `f32` that uses Godot's pool allocator.
4-
pub type Float32Array = TypedArray<f32>;
4+
pub type Float32Array = PoolArray<f32>;
55

66
godot_test!(
77
test_float32_array_access {

gdnative-core/src/core_types/int32_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::core_types::TypedArray;
1+
use crate::core_types::PoolArray;
22

33
/// A reference-counted vector of `i32` that uses Godot's pool allocator.
4-
pub type Int32Array = TypedArray<i32>;
4+
pub type Int32Array = PoolArray<i32>;
55

66
godot_test!(
77
test_int32_array_access {

0 commit comments

Comments
 (0)