Skip to content

Commit 8a1e065

Browse files
committed
NativeClass::{init, register_properties}, NativeClassMethods::register: plan rename/hide
Also change example to avoid potential naming collision
1 parent c81faa7 commit 8a1e065

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

examples/spinning-cube/src/lib.rs

Lines changed: 2 additions & 2 deletions
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-core/src/export/class.rs

Lines changed: 10 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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]

0 commit comments

Comments
 (0)