Skip to content

Commit a34e43f

Browse files
bors[bot]Bromeon
andauthored
Merge #888
888: NativeClass: mark internal methods with potential naming conflicts for renaming r=Bromeon a=Bromeon Fixes #885. Co-authored-by: Jan Haller <[email protected]>
2 parents 99751fa + 8a1e065 commit a34e43f

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

examples/spinning-cube/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use gdnative::export::hint::{EnumHint, IntHint, StringHint};
55

66
#[derive(gdnative::derive::NativeClass)]
77
#[inherit(MeshInstance)]
8-
#[register_with(register_properties)]
8+
#[register_with(register_members)]
99
struct RustTest {
1010
start: Vector3,
1111
time: f32,
1212
#[property(path = "base/rotate_speed")]
1313
rotate_speed: f64,
1414
}
1515

16-
fn register_properties(builder: &ClassBuilder<RustTest>) {
16+
fn register_members(builder: &ClassBuilder<RustTest>) {
1717
builder
1818
.property::<String>("test/test_enum")
1919
.with_hint(StringHint::Enum(EnumHint::new(vec![

gdnative-bindings/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn format_file_if_needed(output_rs: &Path) {
144144
.arg("run")
145145
.arg("stable")
146146
.arg("rustfmt")
147-
.arg("--edition=2018")
147+
.arg("--edition=2021")
148148
.arg(output_rs)
149149
.output();
150150

gdnative-core/src/core_types/variant/serialize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct DictionaryDispatchEntry {
111111
value: VariantDispatch,
112112
}
113113

114-
impl<'d> Serialize for DictionaryDispatch {
114+
impl Serialize for DictionaryDispatch {
115115
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
116116
where
117117
S: Serializer,

gdnative-core/src/export/class.rs

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ pub trait NativeClass: Sized + 'static {
4343
/// See module-level documentation on `user_data` for more info.
4444
type UserData: UserData<Target = Self>;
4545

46+
// TODO(0.11) bugfix for https://github.com/godot-rust/godot-rust/issues/885
47+
// * Rename init, register_properties, register by prefixing them with "nativeclass_"
48+
// * Mark them as #[doc(hidden)]
49+
// * Discourage manual NativeClass and NativeClassMethod impls
50+
4651
/// Function that creates a value of `Self`, used for the script-instance. The default
4752
/// implementation simply panics.
4853
///
@@ -53,6 +58,7 @@ pub trait NativeClass: Sized + 'static {
5358
/// of such scripts can only be created from Rust using `Instance::emplace`. See
5459
/// documentation on `Instance::emplace` for an example.
5560
#[inline]
61+
#[deprecated = "This method will be removed from the public API."]
5662
fn init(_owner: TRef<'_, Self::Base, Shared>) -> Self {
5763
panic!(
5864
"{} does not have a zero-argument constructor",
@@ -62,6 +68,7 @@ pub trait NativeClass: Sized + 'static {
6268

6369
/// Register any exported properties to Godot.
6470
#[inline]
71+
#[deprecated = "This method will be removed from the public API."]
6572
fn register_properties(_builder: &ClassBuilder<Self>) {}
6673

6774
/// Convenience method to create an `Instance<Self, Unique>`. This is a new `Self::Base`
@@ -111,6 +118,9 @@ pub trait StaticallyNamed: NativeClass {
111118
/// Trait used to provide information of Godot-exposed methods of a script class.
112119
pub trait NativeClassMethods: NativeClass {
113120
/// Function that registers all exposed methods to Godot.
121+
///
122+
// TODO see comment in NativeClass
123+
#[deprecated = "This method will be removed from the public API."]
114124
fn register(builder: &ClassBuilder<Self>);
115125
}
116126

gdnative-core/src/init/init_handle.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct InitHandle {
1818
handle: *mut libc::c_void,
1919
}
2020

21+
#[allow(deprecated)] // Remove once init(), register_properties() and register() have been renamed
2122
impl InitHandle {
2223
#[doc(hidden)]
2324
#[inline]

gdnative-core/src/object/as_arg.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mod private {
4444
}
4545

4646
// Null
47-
impl<'a, T> private::Sealed for Null<T> {}
47+
impl<T> private::Sealed for Null<T> {}
4848

4949
// Temporary references (shared ownership)
5050
impl<'a, T: GodotObject> private::Sealed for TRef<'a, T, Shared> {}
@@ -59,14 +59,14 @@ impl<T: NativeClass, Own: Ownership> private::Sealed for Instance<T, Own> {}
5959
// ----------------------------------------------------------------------------------------------------------------------------------------------
6060
// Null
6161

62-
impl<'a, T: GodotObject> AsArg<T> for Null<T> {
62+
impl<T: GodotObject> AsArg<T> for Null<T> {
6363
#[inline]
6464
fn as_arg_ptr(&self) -> *mut sys::godot_object {
6565
std::ptr::null_mut()
6666
}
6767
}
6868

69-
impl<'a, T: GodotObject> AsVariant for Null<T> {
69+
impl<T: GodotObject> AsVariant for Null<T> {
7070
type Target = T;
7171
}
7272

0 commit comments

Comments
 (0)