Skip to content

Commit 6d8e021

Browse files
authored
Try #788:
2 parents 976ca46 + 4a3aec4 commit 6d8e021

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+726
-624
lines changed

bindings_generator/src/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl Ty {
422422
Ty::Bool => syn::parse_quote! { bool },
423423
Ty::Vector2 => syn::parse_quote! { Vector2 },
424424
Ty::Vector3 => syn::parse_quote! { Vector3 },
425-
Ty::Vector3Axis => syn::parse_quote! { vector3::Axis },
425+
Ty::Vector3Axis => syn::parse_quote! { Axis },
426426
Ty::Quat => syn::parse_quote! { Quat },
427427
Ty::Transform => syn::parse_quote! { Transform },
428428
Ty::Transform2D => syn::parse_quote! { Transform2D },
@@ -448,7 +448,7 @@ impl Ty {
448448
Ty::VariantOperator => syn::parse_quote! { VariantOperator },
449449
Ty::Enum(path) => syn::parse_quote! { #path },
450450
Ty::Object(path) => {
451-
syn::parse_quote! { Option<Ref<#path, thread_access::Shared>> }
451+
syn::parse_quote! { Option<Ref<#path, ownership::Shared>> }
452452
}
453453
}
454454
}
@@ -597,7 +597,7 @@ impl Ty {
597597
Ty::Object(ref path) => {
598598
quote! {
599599
ptr::NonNull::new(ret)
600-
.map(|sys| <Ref<#path, thread_access::Shared>>::move_from_sys(sys))
600+
.map(|sys| <Ref<#path, ownership::Shared>>::move_from_sys(sys))
601601
}
602602
}
603603
Ty::Result => {

bindings_generator/src/special_methods.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ destroying the object) or destroyed manually using `Ref::free`, or preferably
2626
quote! {
2727
#[doc=#documentation]
2828
#[inline]
29-
pub fn new() -> Ref<Self, thread_access::Unique> {
29+
pub fn new() -> Ref<Self, ownership::Unique> {
3030
unsafe {
3131
let gd_api = get_api();
3232
let ctor = #method_table::get(gd_api).class_constructor.unwrap();
@@ -42,17 +42,17 @@ pub fn generate_godot_object_impl(class: &GodotClass) -> TokenStream {
4242
let name = &class.name;
4343
let class_name = format_ident!("{}", class.name);
4444

45-
let ref_kind = if class.is_refcounted() {
46-
quote! { ref_kind::RefCounted }
45+
let memory = if class.is_refcounted() {
46+
quote! { memory::RefCounted }
4747
} else {
48-
quote! { ref_kind::ManuallyManaged }
48+
quote! { memory::ManuallyManaged }
4949
};
5050

5151
quote! {
5252
impl gdnative_core::private::godot_object::Sealed for #class_name {}
5353

5454
unsafe impl GodotObject for #class_name {
55-
type RefKind = #ref_kind;
55+
type RefKind = #memory;
5656

5757
#[inline]
5858
fn class_name() -> &'static str {
@@ -69,7 +69,7 @@ pub fn generate_instantiable_impl(class: &GodotClass) -> TokenStream {
6969
quote! {
7070
impl Instanciable for #class_name {
7171
#[inline]
72-
fn construct() -> Ref<Self, thread_access::Unique> {
72+
fn construct() -> Ref<Self, ownership::Unique> {
7373
#class_name::new()
7474
}
7575
}

examples/array_export/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use gdnative::nativescript::init::property::hint::{ArrayHint, IntHint, RangeHint};
1+
use gdnative::nativescript::export::property::hint::{ArrayHint, IntHint, RangeHint};
22
use gdnative::prelude::*;
33

44
#[derive(NativeClass)]
55
#[inherit(Node)]
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/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::GodotObject<RefKind = ManuallyManaged> + SubClass<Node>,
143+
Root: gdnative::object::GodotObject<RefKind = ManuallyManaged> + SubClass<Node>,
144144
{
145145
let scene = unsafe { scene.assume_safe() };
146146

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: 6 additions & 6 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();
@@ -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::GodotObject<RefKind = ManuallyManaged> + SubClass<Node>,
119+
Root: gdnative::object::GodotObject<RefKind = ManuallyManaged> + SubClass<Node>,
120120
{
121121
let instance = scene
122122
.instance(PackedScene::GEN_EDIT_STATE_DISABLED)

examples/spinning_cube/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use gdnative::api::MeshInstance;
22
use gdnative::prelude::*;
33

4-
use gdnative::nativescript::init::property::{EnumHint, IntHint, StringHint};
4+
use gdnative::nativescript::export::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-bindings/src/generated.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ use std::sync::Once;
88

99
use gdnative_core::core_types::*;
1010
use gdnative_core::object::*;
11+
use gdnative_core::object::{memory, ownership};
1112
use gdnative_core::private::get_api;
1213
use gdnative_core::sys;
1314
use gdnative_core::sys::GodotApi;
14-
use gdnative_core::thread_access;
15-
use gdnative_core::{ref_kind, GodotResult};
1615

1716
include!(concat!(env!("OUT_DIR"), "/generated.rs"));

gdnative-bindings/src/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
33
use super::generated::{Engine, Node, SceneTree};
44
use gdnative_core::nativescript::{NativeClass, RefInstance};
5-
use gdnative_core::object::SubClass;
6-
use gdnative_core::thread_access::Shared;
7-
use gdnative_core::TRef;
5+
use gdnative_core::object::ownership::Shared;
6+
use gdnative_core::object::{SubClass, TRef};
87

98
/// Convenience method to obtain a reference to an "auto-load" node, that is a child of the root
109
/// node. Returns `None` if the node does not exist or is not of the correct type.

0 commit comments

Comments
 (0)