Skip to content

Commit

Permalink
Move all derive macros and derive macro attributes to gdnative::derive
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Oct 4, 2021
1 parent b7f26aa commit a308bc7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/array_export/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use gdnative::prelude::*;
#[register_with(Self::register)]
struct ExportsArrays;

#[gdnative::methods]
#[methods]
impl ExportsArrays {
fn new(_owner: &Node) -> Self {
ExportsArrays
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use gdnative::prelude::*;
#[inherit(Node)]
struct HelloWorld;

#[gdnative::methods]
#[methods]
impl HelloWorld {
fn new(_owner: &Node) -> Self {
HelloWorld
Expand Down
4 changes: 2 additions & 2 deletions examples/resource/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct GreetingResource {
name: String,
}

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

#[gdnative::methods]
#[methods]
impl Greeter {
fn new(_owner: &Node) -> Self {
Greeter {
Expand Down
10 changes: 5 additions & 5 deletions examples/scene_create/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub enum ManageErrs {
RootClassNotSpatial(String),
}

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

#[gdnative::methods]
#[gdnative::derive::methods]
impl SceneCreate {
fn new(_owner: &Spatial) -> Self {
SceneCreate {
Expand All @@ -33,7 +33,7 @@ impl SceneCreate {
}
}

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

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

Expand Down Expand Up @@ -77,7 +77,7 @@ impl SceneCreate {
update_panel(owner, num_children);
}

#[export]
#[gdnative::derive::export]
fn remove_one(&mut self, owner: &Spatial, str: GodotString) {
godot_print!("Called remove_one({})", str);
let num_children = owner.get_child_count();
Expand Down
4 changes: 2 additions & 2 deletions examples/spinning_cube/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use gdnative::prelude::*;

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

#[derive(gdnative::NativeClass)]
#[derive(gdnative::derive::NativeClass)]
#[inherit(MeshInstance)]
#[register_with(register_properties)]
struct RustTest {
Expand Down Expand Up @@ -36,7 +36,7 @@ fn register_properties(builder: &ClassBuilder<RustTest>) {
.done();
}

#[gdnative::methods]
#[methods]
impl RustTest {
fn new(_owner: &MeshInstance) -> Self {
RustTest {
Expand Down
2 changes: 1 addition & 1 deletion gdnative-core/src/nativescript/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ macro_rules! godot_wrap_method_inner {
struct ThisMethod;

use $crate::nativescript::{NativeClass, Instance, RefInstance, OwnerArg};
use ::gdnative::FromVarargs;
use ::gdnative::derive::FromVarargs;

#[derive(FromVarargs)]
#[allow(clippy::used_underscore_binding)]
Expand Down
2 changes: 1 addition & 1 deletion gdnative-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod variant;
/// ```
/// **Important**: Only one `impl` block per struct may be attributed with `#[methods]`.
///
/// For more context, please refer to [gdnative::NativeClass](NativeClass).
/// For more context, please refer to [gdnative::derive::NativeClass](NativeClass).
#[proc_macro_attribute]
pub fn methods(meta: TokenStream, input: TokenStream) -> TokenStream {
if syn::parse::<syn::parse::Nothing>(meta.clone()).is_err() {
Expand Down
5 changes: 3 additions & 2 deletions gdnative/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ pub use gdnative_core::{
#[doc(hidden)]
pub use gdnative_core::*;

/// Derive macros and macro attributes.
#[doc(inline)]
pub use gdnative_derive::*;
pub use gdnative_derive as derive;

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

/// Bindings for the Godot Class API.
#[doc(inline)]
#[cfg(feature = "bindings")]
/// Bindings for the Godot Class API.
pub use gdnative_bindings as api;
2 changes: 1 addition & 1 deletion test/src/test_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn test_derive_owned_to_variant() -> bool {
ok
}

#[derive(gdnative::NativeClass)]
#[derive(gdnative::derive::NativeClass)]
#[inherit(Node)]
struct PropertyHooks {
#[property(
Expand Down

0 comments on commit a308bc7

Please sign in to comment.