Skip to content

Commit 1e52786

Browse files
committed
Clean up godot::register module
1 parent c12fdaa commit 1e52786

File tree

23 files changed

+859
-803
lines changed

23 files changed

+859
-803
lines changed

godot-core/src/builtin/collections/array.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use crate::builtin::meta::{
1414
};
1515
use crate::builtin::*;
1616
use crate::obj::EngineEnum;
17-
use crate::property::{builtin_type_string, Export, PropertyHintInfo, TypeStringHint, Var};
17+
use crate::registry::property::{
18+
builtin_type_string, Export, PropertyHintInfo, TypeStringHint, Var,
19+
};
1820
use godot_ffi as sys;
1921
use sys::{ffi_methods, interface_fn, GodotFfi};
2022

godot-core/src/builtin/collections/dictionary.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use godot_ffi as sys;
99

1010
use crate::builtin::meta::{impl_godot_as_self, FromGodot, ToGodot};
1111
use crate::builtin::{inner, Variant, VariantArray};
12-
use crate::property::{builtin_type_string, Export, PropertyHintInfo, TypeStringHint, Var};
12+
use crate::registry::property::{
13+
builtin_type_string, Export, PropertyHintInfo, TypeStringHint, Var,
14+
};
1315
use sys::types::OpaqueDictionary;
1416
use sys::{ffi_methods, interface_fn, GodotFfi};
1517

godot-core/src/builtin/collections/packed_array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,16 @@ macro_rules! impl_packed_array {
509509

510510
$crate::builtin::meta::impl_godot_as_self!($PackedArray);
511511

512-
impl $crate::property::Export for $PackedArray {
513-
fn default_export_info() -> $crate::property::PropertyHintInfo {
512+
impl $crate::registry::property::Export for $PackedArray {
513+
fn default_export_info() -> $crate::registry::property::PropertyHintInfo {
514514
// In 4.3 Godot can (and does) use type hint strings for packed arrays, see https://github.com/godotengine/godot/pull/82952.
515515
if sys::GdextBuild::since_api("4.3") {
516-
$crate::property::PropertyHintInfo {
516+
$crate::registry::property::PropertyHintInfo {
517517
hint: $crate::global::PropertyHint::TYPE_STRING,
518-
hint_string: <$Element as $crate::property::TypeStringHint>::type_string().into(),
518+
hint_string: <$Element as $crate::registry::property::TypeStringHint>::type_string().into(),
519519
}
520520
} else {
521-
$crate::property::PropertyHintInfo::with_hint_none(
521+
$crate::registry::property::PropertyHintInfo::with_hint_none(
522522
<$PackedArray as $crate::builtin::meta::GodotType>::godot_type_name()
523523
)
524524
}

godot-core/src/builtin/meta/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8-
pub mod registration;
9-
108
mod call_error;
119
mod class_name;
1210
mod godot_convert;
@@ -22,10 +20,9 @@ pub(crate) use godot_convert::convert_error::*;
2220

2321
use crate::builtin::*;
2422
use crate::global::{self, PropertyHint, PropertyUsageFlags};
25-
use crate::property::Var;
26-
use crate::property::{Export, PropertyHintInfo};
23+
use crate::registry::method::MethodParamOrReturnInfo;
24+
use crate::registry::property::{Export, PropertyHintInfo, Var};
2725
use godot_ffi as sys;
28-
use registration::method::MethodParamOrReturnInfo;
2926
use sys::{GodotFfi, GodotNullableFfi};
3027

3128
#[cfg(feature = "trace")]
@@ -318,7 +315,7 @@ impl PropertyInfo {
318315

319316
/// Change the `hint` and `hint_string` to be the given `hint_info`.
320317
///
321-
/// See [`export_info_functions`](crate::property::export_info_functions) for functions that return appropriate `PropertyHintInfo`s for
318+
/// See [`export_info_functions`](crate::registry::property::export_info_functions) for functions that return appropriate `PropertyHintInfo`s for
322319
/// various Godot annotations.
323320
///
324321
/// # Examples

godot-core/src/builtin/meta/registration/mod.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

godot-core/src/engine/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8-
#![deprecated = "Module has been split into `godot::classes`, `godot::global` and `godot::tools`."]
9-
108
#[deprecated = "Classes have been moved to `godot::classes`."]
119
pub use crate::classes::*;
1210

godot-core/src/init/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ fn gdext_on_level_init(level: InitLevel) {
139139
sys::load_class_method_table(sys::ClassApiLevel::Editor);
140140
}
141141
}
142-
crate::auto_register_classes(level);
142+
crate::registry::class::auto_register_classes(level);
143143
}
144144
}
145145

146146
/// Tasks needed to be done by gdext internally upon unloading an initialization level. Called after user code.
147147
fn gdext_on_level_deinit(level: InitLevel) {
148-
crate::unregister_classes(level);
148+
crate::registry::class::unregister_classes(level);
149149

150150
if level == InitLevel::Core {
151151
// If lowest level is unloaded, call global deinitialization.

godot-core/src/lib.rs

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,22 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8-
mod registry;
9-
mod storage;
10-
8+
// Note that a lot of those are public, but the godot crate still has the final say on what it wants to re-export.
9+
// Doing fine-grained visibility restrictions on every level is a useless maintenance chore.
1110
pub mod builder;
1211
pub mod builtin;
1312
pub mod classes;
1413
pub mod global;
1514
pub mod init;
1615
pub mod obj;
16+
pub mod registry;
17+
pub mod tools;
1718

18-
#[deprecated = "Print macros have been moved to `godot::global`."]
19-
pub mod log {
20-
pub use crate::global::{
21-
godot_error, godot_print, godot_print_rich, godot_script_error, godot_warn,
22-
};
23-
}
24-
25-
#[doc(hidden)]
26-
#[path = "deprecated.rs"]
27-
pub mod __deprecated;
28-
#[doc(hidden)]
29-
pub mod private;
30-
19+
mod storage;
3120
pub use godot_ffi as sys;
32-
#[doc(hidden)]
33-
pub use godot_ffi::out;
34-
pub use registry::*;
35-
pub mod engine;
3621

37-
/// Higher-level additions to the Godot engine API.
38-
///
39-
/// Contains functionality that extends existing Godot classes and functions, to make them more versatile
40-
/// or better integrated with Rust.
41-
pub mod tools;
22+
// ----------------------------------------------------------------------------------------------------------------------------------------------
23+
// Generated code
4224

4325
// Output of generated code. Mimics the file structure, symbols are re-exported.
4426
#[rustfmt::skip]
@@ -52,6 +34,9 @@ mod gen {
5234
include!(concat!(env!("OUT_DIR"), "/mod.rs"));
5335
}
5436

37+
// ----------------------------------------------------------------------------------------------------------------------------------------------
38+
// API version check
39+
5540
macro_rules! generate_gdextension_api_version {
5641
(
5742
$(
@@ -89,3 +74,32 @@ generate_gdextension_api_version!(
8974
"4.1",
9075
},
9176
);
77+
78+
// ----------------------------------------------------------------------------------------------------------------------------------------------
79+
// Hidden but accessible symbols
80+
81+
/// Module which is used for deprecated warnings. It stays even if there is nothing currently deprecated.
82+
#[doc(hidden)]
83+
#[path = "deprecated.rs"]
84+
pub mod __deprecated;
85+
86+
/// All internal machinery that is accessed by various gdext tools (e.g. proc macros).
87+
#[doc(hidden)]
88+
pub mod private;
89+
90+
/// Re-export logging macro.
91+
#[doc(hidden)]
92+
pub use godot_ffi::out;
93+
94+
// ----------------------------------------------------------------------------------------------------------------------------------------------
95+
// Deprecated modules
96+
97+
#[deprecated = "Module has been split into `godot::classes`, `godot::global` and `godot::tools`."]
98+
pub mod engine;
99+
100+
#[deprecated = "Print macros have been moved to `godot::global`."]
101+
pub mod log {
102+
pub use crate::global::{
103+
godot_error, godot_print, godot_print_rich, godot_script_error, godot_warn,
104+
};
105+
}

godot-core/src/obj/bounds.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
4949
use crate::obj::cap::GodotDefault;
5050
use crate::obj::{Bounds, Gd, GodotClass, RawGd};
51+
use crate::registry::callbacks;
5152
use crate::storage::Storage;
52-
use crate::{callbacks, out, sys};
53+
use crate::{out, sys};
5354
use private::Sealed;
5455

5556
// ----------------------------------------------------------------------------------------------------------------------------------------------

godot-core/src/obj/gd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::obj::{
2323
bounds, cap, Bounds, EngineEnum, GdDerefTarget, GdMut, GdRef, GodotClass, Inherits, InstanceId,
2424
};
2525
use crate::private::callbacks;
26-
use crate::property::{Export, PropertyHintInfo, TypeStringHint, Var};
26+
use crate::registry::property::{Export, PropertyHintInfo, TypeStringHint, Var};
2727
use crate::{classes, out};
2828

2929
/// Smart pointer to objects owned by the Godot engine.

0 commit comments

Comments
 (0)