Skip to content

Commit 3295c67

Browse files
committed
Move all derive macros and derive macro attributes to gdnative::derive
1 parent b7f26aa commit 3295c67

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

examples/array_export/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use gdnative::prelude::*;
66
#[register_with(Self::register)]
77
struct ExportsArrays;
88

9-
#[gdnative::methods]
9+
#[methods]
1010
impl ExportsArrays {
1111
fn new(_owner: &Node) -> Self {
1212
ExportsArrays

examples/hello_world/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gdnative::prelude::*;
44
#[inherit(Node)]
55
struct HelloWorld;
66

7-
#[gdnative::methods]
7+
#[methods]
88
impl HelloWorld {
99
fn new(_owner: &Node) -> Self {
1010
HelloWorld

examples/resource/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct GreetingResource {
88
name: String,
99
}
1010

11-
#[gdnative::methods]
11+
#[methods]
1212
impl GreetingResource {
1313
fn new(_owner: &Resource) -> Self {
1414
Self { name: "".into() }
@@ -29,7 +29,7 @@ struct Greeter {
2929
greeting_resource: Option<Instance<GreetingResource, Shared>>,
3030
}
3131

32-
#[gdnative::methods]
32+
#[methods]
3333
impl Greeter {
3434
fn new(_owner: &Node) -> Self {
3535
Greeter {

examples/scene_create/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub enum ManageErrs {
66
RootClassNotSpatial(String),
77
}
88

9-
#[derive(gdnative::NativeClass)]
9+
#[derive(gdnative::derive::NativeClass)]
1010
#[inherit(Spatial)]
1111
struct SceneCreate {
1212
// Store the loaded scene for a very slight performance boost but mostly to show you how.
@@ -24,7 +24,7 @@ struct SceneCreate {
2424
// Note, the same mechanism which is used to call from panel into spawn_one and remove_one can be
2525
// used to call other GDNative classes here in rust.
2626

27-
#[gdnative::methods]
27+
#[gdnative::derive::methods]
2828
impl SceneCreate {
2929
fn new(_owner: &Spatial) -> Self {
3030
SceneCreate {
@@ -33,7 +33,7 @@ impl SceneCreate {
3333
}
3434
}
3535

36-
#[export]
36+
#[gdnative::derive::export]
3737
fn _ready(&mut self, _owner: &Spatial) {
3838
self.template = load_scene("res://Child_scene.tscn");
3939
match &self.template {
@@ -42,7 +42,7 @@ impl SceneCreate {
4242
}
4343
}
4444

45-
#[export]
45+
#[gdnative::derive::export]
4646
fn spawn_one(&mut self, owner: &Spatial, message: GodotString) {
4747
godot_print!("Called spawn_one({})", message.to_string());
4848

@@ -77,7 +77,7 @@ impl SceneCreate {
7777
update_panel(owner, num_children);
7878
}
7979

80-
#[export]
80+
#[gdnative::derive::export]
8181
fn remove_one(&mut self, owner: &Spatial, str: GodotString) {
8282
godot_print!("Called remove_one({})", str);
8383
let num_children = owner.get_child_count();

examples/spinning_cube/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use gdnative::prelude::*;
33

44
use gdnative::nativescript::init::property::{EnumHint, IntHint, StringHint};
55

6-
#[derive(gdnative::NativeClass)]
6+
#[derive(gdnative::derive::NativeClass)]
77
#[inherit(MeshInstance)]
88
#[register_with(register_properties)]
99
struct RustTest {
@@ -36,7 +36,7 @@ fn register_properties(builder: &ClassBuilder<RustTest>) {
3636
.done();
3737
}
3838

39-
#[gdnative::methods]
39+
#[methods]
4040
impl RustTest {
4141
fn new(_owner: &MeshInstance) -> Self {
4242
RustTest {

gdnative-core/src/nativescript/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ macro_rules! godot_wrap_method_inner {
9898
struct ThisMethod;
9999

100100
use $crate::nativescript::{NativeClass, Instance, RefInstance, OwnerArg};
101-
use ::gdnative::FromVarargs;
101+
use ::gdnative::derive::FromVarargs;
102102

103103
#[derive(FromVarargs)]
104104
#[allow(clippy::used_underscore_binding)]

gdnative-derive/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
///! Derive macros and macro attributes.
12
extern crate proc_macro;
23
extern crate proc_macro2;
34
#[macro_use]
@@ -63,7 +64,7 @@ mod variant;
6364
/// ```
6465
/// **Important**: Only one `impl` block per struct may be attributed with `#[methods]`.
6566
///
66-
/// For more context, please refer to [gdnative::NativeClass](NativeClass).
67+
/// For more context, please refer to [gdnative::derive::NativeClass](NativeClass).
6768
#[proc_macro_attribute]
6869
pub fn methods(meta: TokenStream, input: TokenStream) -> TokenStream {
6970
if syn::parse::<syn::parse::Nothing>(meta.clone()).is_err() {

gdnative/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ pub use gdnative_core::{
6666
#[doc(hidden)]
6767
pub use gdnative_core::*;
6868

69-
#[doc(inline)]
70-
pub use gdnative_derive::*;
69+
pub use gdnative_derive as derive;
7170

7271
/// Curated re-exports of common items.
7372
pub mod prelude;

test/src/test_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn test_derive_owned_to_variant() -> bool {
173173
ok
174174
}
175175

176-
#[derive(gdnative::NativeClass)]
176+
#[derive(gdnative::derive::NativeClass)]
177177
#[inherit(Node)]
178178
struct PropertyHooks {
179179
#[property(

0 commit comments

Comments
 (0)