Skip to content

Commit 22b5a5d

Browse files
committed
Move out symbols from export::{method, property}
Also flatten property::accessor::invalid
1 parent 00e7621 commit 22b5a5d

File tree

15 files changed

+42
-50
lines changed

15 files changed

+42
-50
lines changed

examples/array_export/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gdnative::nativescript::export::property::{ArrayHint, IntHint, RangeHint};
1+
use gdnative::nativescript::export::hint::{ArrayHint, IntHint, RangeHint};
22
use gdnative::prelude::*;
33

44
#[derive(NativeClass)]

examples/spinning_cube/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use gdnative::api::MeshInstance;
22
use gdnative::prelude::*;
33

4-
use gdnative::nativescript::export::property::{EnumHint, IntHint, StringHint};
4+
use gdnative::nativescript::export::hint::{EnumHint, IntHint, StringHint};
55

66
#[derive(gdnative::derive::NativeClass)]
77
#[inherit(MeshInstance)]

gdnative-async/src/rt/bridge.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use parking_lot::Mutex;
66
use gdnative_bindings::{Object, Reference};
77
use gdnative_core::core_types::{GodotError, Variant, VariantArray};
88
use gdnative_core::godot_site;
9-
use gdnative_core::nativescript::export::method::{Method, Varargs};
10-
use gdnative_core::nativescript::export::ClassBuilder;
9+
use gdnative_core::nativescript::export::{ClassBuilder, Method, Varargs};
1110
use gdnative_core::nativescript::user_data::{ArcData, Map};
1211
use gdnative_core::nativescript::{Instance, NativeClass, NativeClassMethods, RefInstance};
1312
use gdnative_core::object::{ownership::Shared, TRef};

gdnative-async/src/rt/func_state.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
use gdnative_bindings::Reference;
22
use gdnative_core::core_types::{ToVariant, Variant, VariantType};
33
use gdnative_core::godot_site;
4-
use gdnative_core::nativescript::export::method::StaticArgs;
5-
use gdnative_core::nativescript::export::method::StaticArgsMethod;
64
use gdnative_core::nativescript::export::{
7-
ClassBuilder, ExportInfo, PropertyUsage, Signal, SignalArgument,
5+
ClassBuilder, ExportInfo, PropertyUsage, Signal, SignalArgument, StaticArgs, StaticArgsMethod,
86
};
9-
use gdnative_core::nativescript::user_data::LocalCellData;
10-
use gdnative_core::nativescript::user_data::{Map, MapMut};
7+
use gdnative_core::nativescript::user_data::{LocalCellData, Map, MapMut};
118
use gdnative_core::nativescript::{Instance, NativeClass, NativeClassMethods, RefInstance};
129
use gdnative_core::object::ownership::{Shared, Unique};
1310
use gdnative_derive::FromVarargs;

gdnative-core/src/nativescript/export.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,26 @@
3333
// Temporary for unsafe method registration
3434
#![allow(deprecated)]
3535

36-
use crate::*;
37-
3836
use std::ffi::CString;
3937
use std::marker::PhantomData;
4038
use std::ptr;
4139

4240
use crate::core_types::{GodotString, ToVariant, Variant};
41+
use crate::nativescript::{class_registry, emplace};
4342
use crate::nativescript::{user_data::UserData, NativeClass, NativeClassMethods};
44-
use crate::object::{GodotObject, NewRef, TRef};
43+
use crate::object::{GodotObject, NewRef, RawObject, TRef};
4544
use crate::private::get_api;
4645

47-
use super::class_registry;
48-
use super::emplace;
46+
pub use method::*;
47+
pub use property::*;
4948

50-
pub mod method;
51-
pub mod property;
49+
mod method;
50+
mod property;
5251

53-
pub use self::method::{
54-
Method, MethodBuilder, RpcMode, ScriptMethod, ScriptMethodAttributes, ScriptMethodFn, Varargs,
55-
};
56-
pub use self::property::{ExportInfo, PropertyBuilder, Usage as PropertyUsage};
52+
//pub use self::method::{
53+
// Method, MethodBuilder, RpcMode, ScriptMethod, ScriptMethodAttributes, ScriptMethodFn, Varargs,
54+
//};
55+
//pub use self::property::{ExportInfo, PropertyBuilder, Usage as PropertyUsage};
5756

5857
/// Trait for exportable types.
5958
pub trait Export: ToVariant {
@@ -139,7 +138,7 @@ impl InitHandle {
139138
}
140139
};
141140

142-
let owner = match object::RawObject::<C::Base>::try_from_sys_ref(this) {
141+
let owner = match RawObject::<C::Base>::try_from_sys_ref(this) {
143142
Some(owner) => owner,
144143
None => {
145144
godot_error!(

gdnative-core/src/nativescript/export/property.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Property registration.
22
3+
use accessor::{Getter, RawGetter, RawSetter, Setter};
4+
use invalid_accessor::{InvalidGetter, InvalidSetter};
5+
36
use crate::core_types::*;
47
use crate::nativescript::{Instance, NativeClass};
58
use crate::object::ownership::Shared;
@@ -8,12 +11,11 @@ use crate::object::Ref;
811
use crate::private::get_api;
912

1013
use super::{ClassBuilder, Export};
11-
use accessor::{Getter, InvalidGetter, InvalidSetter, RawGetter, RawSetter, Setter};
1214

1315
mod accessor;
14-
mod hint;
16+
mod invalid_accessor;
1517

16-
pub use hint::*;
18+
pub mod hint;
1719

1820
/// Metadata about the exported property.
1921
#[derive(Debug)]
@@ -57,7 +59,7 @@ pub struct PropertyBuilder<'a, C, T: Export, S = InvalidSetter<'a>, G = InvalidG
5759
getter: G,
5860
default: Option<T>,
5961
hint: Option<T::Hint>,
60-
usage: Usage,
62+
usage: PropertyUsage,
6163
class_builder: &'a ClassBuilder<C>,
6264
}
6365

@@ -75,7 +77,7 @@ where
7577
getter: InvalidGetter::new(name),
7678
default: None,
7779
hint: None,
78-
usage: Usage::DEFAULT,
80+
usage: PropertyUsage::DEFAULT,
7981
class_builder,
8082
}
8183
}
@@ -267,14 +269,14 @@ where
267269

268270
/// Sets a property usage.
269271
#[inline]
270-
pub fn with_usage(mut self, usage: Usage) -> Self {
272+
pub fn with_usage(mut self, usage: PropertyUsage) -> Self {
271273
self.usage = usage;
272274
self
273275
}
274276
}
275277

276278
bitflags::bitflags! {
277-
pub struct Usage: u32 {
279+
pub struct PropertyUsage: u32 {
278280
const STORAGE = sys::godot_property_usage_flags_GODOT_PROPERTY_USAGE_STORAGE as u32;
279281
const EDITOR = sys::godot_property_usage_flags_GODOT_PROPERTY_USAGE_EDITOR as u32;
280282
const NETWORK = sys::godot_property_usage_flags_GODOT_PROPERTY_USAGE_NETWORK as u32;
@@ -299,7 +301,7 @@ bitflags::bitflags! {
299301
}
300302
}
301303

302-
impl Usage {
304+
impl PropertyUsage {
303305
#[inline]
304306
pub fn to_sys(self) -> sys::godot_property_usage_flags {
305307
self.bits() as sys::godot_property_usage_flags
@@ -458,7 +460,7 @@ mod impl_export {
458460
}
459461

460462
impl Export for VariantArray<Shared> {
461-
type Hint = ArrayHint;
463+
type Hint = hint::ArrayHint;
462464

463465
#[inline]
464466
fn export_info(hint: Option<Self::Hint>) -> ExportInfo {

gdnative-core/src/nativescript/export/property/accessor.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ use crate::nativescript::user_data::{Map, MapMut, UserData};
88
use crate::nativescript::NativeClass;
99
use crate::object::{GodotObject, RawObject, TRef};
1010

11-
mod invalid;
12-
13-
pub use self::invalid::{InvalidGetter, InvalidSetter};
14-
1511
/// Trait for raw property setters.
1612
///
1713
/// This is an internal interface. User code should not use this directly.

gdnative-core/src/nativescript/export/property/hint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::{Export, ExportInfo};
1616
/// Basic usage:
1717
///
1818
/// ```rust
19-
/// use gdnative_core::nativescript::export::property::RangeHint;
19+
/// use gdnative_core::nativescript::export::hint::RangeHint;
2020
///
2121
/// let hint: RangeHint<f64> = RangeHint::new(0.0, 20.0).or_greater();
2222
/// ```
@@ -110,7 +110,7 @@ where
110110
/// Basic usage:
111111
///
112112
/// ```rust
113-
/// use gdnative_core::nativescript::export::property::EnumHint;
113+
/// use gdnative_core::nativescript::export::hint::EnumHint;
114114
///
115115
/// let hint = EnumHint::new(vec!["Foo".into(), "Bar".into(), "Baz".into()]);
116116
/// ```

gdnative-core/src/nativescript/export/property/accessor/invalid.rs renamed to gdnative-core/src/nativescript/export/property/invalid_accessor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use std::mem;
44

55
use crate::core_types::{FromVariant, ToVariant, Variant};
66
use crate::nativescript::NativeClass;
7-
use crate::*;
87

9-
use super::{RawGetter, RawSetter};
8+
use super::accessor::{RawGetter, RawSetter};
109

1110
/// Default setter used for a new property indicating that no valid setter is present. Outputs errors when invoked.
1211
#[derive(Debug)]

gdnative-core/src/nativescript/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ macro_rules! godot_wrap_method_inner {
108108
}
109109

110110
#[allow(unused_variables, unused_assignments, unused_mut)]
111-
impl $crate::nativescript::export::method::StaticArgsMethod<$type_name> for ThisMethod {
111+
impl $crate::nativescript::export::StaticArgsMethod<$type_name> for ThisMethod {
112112
type Args = Args;
113113
fn call(
114114
&self,
@@ -139,7 +139,7 @@ macro_rules! godot_wrap_method_inner {
139139
}
140140
}
141141

142-
$crate::nativescript::export::method::StaticArgs::new(ThisMethod)
142+
$crate::nativescript::export::StaticArgs::new(ThisMethod)
143143
}
144144
};
145145
}

0 commit comments

Comments
 (0)