Skip to content

Commit 27007af

Browse files
committed
Move engine::global, engine::utilities, log -> global
1 parent 4c06b58 commit 27007af

File tree

15 files changed

+88
-42
lines changed

15 files changed

+88
-42
lines changed

godot-codegen/src/generator/central_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn make_core_central_code(api: &ExtensionApi, ctx: &mut Context) -> TokenStr
113113
/// For global built-in functions, check out the [`utilities` module][crate::engine::utilities].
114114
///
115115
/// See also [Godot docs for `@GlobalScope`](https://docs.godotengine.org/en/stable/classes/class_@globalscope.html#enumerations).
116-
pub mod global {
116+
pub mod global_enums {
117117
use crate::sys;
118118
#( #global_enum_defs )*
119119
}

godot-codegen/src/generator/utility_functions.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ pub(crate) fn generate_utilities_file(
2727
let imports = util::make_imports();
2828

2929
let tokens = quote! {
30-
//! Global utility functions.
31-
//!
32-
//! A list of global-scope built-in functions.
33-
//! For global enums and constants, check out the [`global` module][crate::engine::global].
34-
//!
35-
//! See also [Godot docs for `@GlobalScope`](https://docs.godotengine.org/en/stable/classes/class_@globalscope.html#methods).
36-
3730
#imports
3831

3932
#(#utility_fn_defs)*

godot-codegen/src/special_cases/special_cases.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn is_class_method_deleted(class_name: &TyName, method: &JsonClassMethod, ct
3737
}
3838

3939
match (class_name.godot_ty.as_str(), method.name.as_str()) {
40-
// Already covered by manual APIs
40+
// Already covered by manual APIs.
4141
//| ("Object", "to_string")
4242
| ("Object", "get_instance_id")
4343

@@ -280,8 +280,19 @@ pub fn is_builtin_type_scalar(name: &str) -> bool {
280280
name.chars().next().unwrap().is_ascii_lowercase()
281281
}
282282

283+
#[rustfmt::skip]
283284
pub fn is_utility_function_deleted(function: &JsonUtilityFunction, ctx: &mut Context) -> bool {
284-
codegen_special_cases::is_utility_function_excluded(function, ctx)
285+
let hardcoded = match function.name.as_str() {
286+
// We have prints manually defined, with (&[Variant]) instead of (Variant, &[Variant]) signature.
287+
| "print"
288+
| "print_rich"
289+
// Should we map str, printt, prints, printerr, printraw manually as well?
290+
291+
=> true, _ => false
292+
};
293+
294+
295+
hardcoded || codegen_special_cases::is_utility_function_excluded(function, ctx)
285296
}
286297

287298
pub fn maybe_rename_class_method<'m>(class_name: &TyName, godot_method_name: &'m str) -> &'m str {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub use signature::*;
2121
pub(crate) use godot_convert::convert_error::*;
2222

2323
use crate::builtin::*;
24-
use crate::engine::global::{self, PropertyHint, PropertyUsageFlags};
24+
use crate::global::{self, PropertyHint, PropertyUsageFlags};
2525
use crate::property::Var;
2626
use crate::property::{Export, PropertyHintInfo};
2727
use godot_ffi as sys;

godot-core/src/builtin/variant/impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::builtin::meta::{
1010
ArrayElement, FromVariantError, GodotFfiVariant, GodotType, PropertyInfo,
1111
};
1212
use crate::builtin::*;
13-
use crate::engine::global;
13+
use crate::global;
1414
use godot_ffi as sys;
1515

1616
// For godot-cpp, see https://github.com/godotengine/godot-cpp/blob/master/include/godot_cpp/core/type_info.hpp.

godot-core/src/engine/io/gfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
use crate::builtin::{real, GString, PackedByteArray, PackedStringArray, Variant};
99
use crate::engine::file_access::{CompressionMode, ModeFlags};
10-
use crate::gen::central::global::Error;
1110
use crate::gen::classes::FileAccess;
11+
use crate::global::Error;
1212
use crate::obj::Gd;
1313

1414
use crate::engine::io::IoError;

godot-core/src/engine/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ use crate::builtin::GString;
1111
use crate::obj::{bounds, Bounds, Gd, GodotClass, InstanceId};
1212

1313
// Re-exports of generated symbols
14-
pub use crate::gen::central::global;
14+
15+
#[deprecated = "Enums have been moved to `godot::global`."]
16+
pub mod global {
17+
pub use crate::global::*;
18+
}
19+
20+
#[deprecated = "Utility functions have been moved to `godot::global`."]
21+
pub mod utilities {
22+
pub use crate::global::*;
23+
}
24+
1525
pub use crate::gen::classes::*;
16-
pub use crate::gen::utilities;
1726
pub use io::*;
1827
pub use script_instance::{create_script_instance, ScriptInstance, SiMut};
1928

godot-core/src/global/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) godot-rust; Bromeon and contributors.
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
//! Godot global enums, constants and utility functions.
9+
//!
10+
//! See also [Godot docs for `@GlobalScope`](https://docs.godotengine.org/en/stable/classes/class_@globalscope.html#methods).
11+
12+
pub(crate) mod print;
13+
14+
pub use crate::gen::central::global_enums::*;
15+
pub use crate::gen::utilities::*;
16+
17+
pub use print::*;

godot-core/src/log.rs renamed to godot-core/src/global/print.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ macro_rules! godot_script_error {
8282
#[macro_export]
8383
macro_rules! godot_print {
8484
($fmt:literal $(, $args:expr)* $(,)?) => {
85-
$crate::log::print(&[
85+
$crate::global::print(&[
8686
$crate::builtin::Variant::from(
8787
format!($fmt $(, $args)*)
8888
)
@@ -98,7 +98,7 @@ macro_rules! godot_print {
9898
#[macro_export]
9999
macro_rules! godot_print_rich {
100100
($fmt:literal $(, $args:expr)* $(,)?) => {
101-
$crate::log::print_rich(&[
101+
$crate::global::print_rich(&[
102102
$crate::builtin::Variant::from(
103103
format!($fmt $(, $args)*)
104104
)
@@ -111,8 +111,9 @@ pub use crate::{godot_error, godot_print, godot_print_rich, godot_script_error,
111111
use crate::builtin::{StringName, Variant};
112112
use crate::sys::{self, GodotFfi};
113113

114-
#[doc(hidden)]
115-
/// Prints to the Godot console, used by the [`godot_print!`] macro.
114+
/// Prints to the Godot console (raw variant args).
115+
///
116+
/// Typically, you'd want to use the [`godot_print!`] macro instead, which uses this function internally.
116117
pub fn print(varargs: &[Variant]) {
117118
unsafe {
118119
let method_name = StringName::from("print");
@@ -135,8 +136,9 @@ pub fn print(varargs: &[Variant]) {
135136
// crate::engine::utilities::print(head, rest);
136137
}
137138

138-
#[doc(hidden)]
139-
/// Prints to the Godot console, used by the [`godot_print_rich!`] macro.
139+
/// Prints rich text to the Godot console (raw variant args).
140+
///
141+
/// Typically, you'd want to use the [`godot_print_rich!`] macro instead, which uses this function internally.
140142
pub fn print_rich(varargs: &[Variant]) {
141143
unsafe {
142144
let method_name = StringName::from("print_rich");

godot-core/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ mod storage;
1010

1111
pub mod builder;
1212
pub mod builtin;
13+
pub mod global;
1314
pub mod init;
14-
pub mod log;
1515
pub mod obj;
1616

17+
#[deprecated = "Print macros have been moved to `godot::global`."]
18+
pub mod log {
19+
pub use crate::global::print::*;
20+
}
21+
1722
#[doc(hidden)]
1823
#[path = "deprecated.rs"]
1924
pub mod __deprecated;

0 commit comments

Comments
 (0)