Skip to content

Commit 58b124e

Browse files
committed
Only provide function name to CallContext in debug
1 parent fd043d5 commit 58b124e

Some content is hidden

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

51 files changed

+415
-654
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ which = "7"
3939
# * quote: 1.0.37 allows tokenizing CStr.
4040
# * venial: 0.6.1 contains some bugfixes.
4141
heck = "0.5"
42-
litrs = { version = "1.0", features = ["proc-macro2"] }
42+
litrs = "0.4"
4343
markdown = "=1.0.0-alpha.23"
4444
nanoserde = "0.2"
4545
proc-macro2 = "1.0.80"

Changelog.md

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,12 @@ Cutting-edge API docs of the `master` branch are available [here](https://godot-
1010

1111
## Quick navigation
1212

13-
- [v0.4.0](#v040), [v0.4.1](#v041)
13+
- [v0.4.0](#v040)
1414
- [v0.3.0](#v030), [v0.3.1](#v031), [v0.3.2](#v032), [v0.3.3](#v033), [v0.3.4](#v034), [v0.3.5](#v035)
1515
- [v0.2.0](#v020), [v0.2.1](#v021), [v0.2.2](#v022), [v0.2.3](#v023), [v0.2.4](#v024)
1616
- [v0.1.1](#v011), [v0.1.2](#v012), [v0.1.3](#v013)
1717

1818

19-
## [v0.4.1](https://docs.rs/godot/0.4.1)
20-
21-
_23 October 2025_
22-
23-
### 🌻 Features
24-
25-
- Add main loop callbacks to `ExtensionLibrary` ([#1313](https://github.com/godot-rust/gdext/pull/1313), [#1380](https://github.com/godot-rust/gdext/pull/1380))
26-
- Class Docs – register docs in `#[godot_api(secondary)]`, simplify docs registration logic ([#1355](https://github.com/godot-rust/gdext/pull/1355))
27-
- Codegen: support sys types in engine APIs ([#1363](https://github.com/godot-rust/gdext/pull/1363), [#1365](https://github.com/godot-rust/gdext/pull/1365))
28-
29-
### 📈 Performance
30-
31-
- Use Rust `str` instead of `CStr` in `ClassIdSource` ([#1334](https://github.com/godot-rust/gdext/pull/1334))
32-
33-
### 🧹 Quality of life
34-
35-
- Preserve doc comments for signal ([#1353](https://github.com/godot-rust/gdext/pull/1353))
36-
- Provide error context for typed array clone check ([#1348](https://github.com/godot-rust/gdext/pull/1348))
37-
- Improve spans; use tuple type for virtual signatures ([#1370](https://github.com/godot-rust/gdext/pull/1370))
38-
- Preserve span of arguments for better compile errors ([#1373](https://github.com/godot-rust/gdext/pull/1373))
39-
- Update to litrs 1.0 ([#1377](https://github.com/godot-rust/gdext/pull/1377))
40-
- Allow opening itests in editor ([#1379](https://github.com/godot-rust/gdext/pull/1379))
41-
42-
### 🛠️ Bugfixes
43-
44-
- Ease `AsArg<Option<Gd<T>>>` bounds to make it usable with signals ([#1371](https://github.com/godot-rust/gdext/pull/1371))
45-
- Handle panic in OnReady `auto_init` ([#1351](https://github.com/godot-rust/gdext/pull/1351))
46-
- Update `GFile::read_as_gstring_entire()` after Godot removes `skip_cr` parameter ([#1349](https://github.com/godot-rust/gdext/pull/1349))
47-
- Fix `Callable::from_sync_fn` doc example using deprecated `Result<T>` return ([#1347](https://github.com/godot-rust/gdext/pull/1347))
48-
- Deprecate `#[class(no_init)]` for editor plugins ([#1378](https://github.com/godot-rust/gdext/pull/1378))
49-
- Initialize and cache proper return value for generic, typed array ([#1357](https://github.com/godot-rust/gdext/pull/1357))
50-
- Fix hot-reload crashes on macOS when the `.gdextension` file changes ([#1367](https://github.com/godot-rust/gdext/pull/1367))
51-
52-
5319
## [v0.4.0](https://docs.rs/godot/0.4.0)
5420

5521
_29 September 2025_

check.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ while [[ $# -gt 0 ]]; do
208208
--use-serde)
209209
extraCargoArgs+=("--features" "serde")
210210
;;
211+
--release)
212+
extraCargoArgs+=("--release")
213+
;;
211214
--double)
212215
extraCargoArgs+=("--features" "godot/double-precision,godot/api-custom")
213216
;;

godot-bindings/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "godot-bindings"
3-
version = "0.4.1"
3+
version = "0.4.0"
44
edition = "2021"
55
rust-version = "1.87"
66
license = "MPL-2.0"

godot-cell/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "godot-cell"
3-
version = "0.4.1"
3+
version = "0.4.0"
44
edition = "2021"
55
rust-version = "1.87"
66
license = "MPL-2.0"

godot-codegen/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "godot-codegen"
3-
version = "0.4.1"
3+
version = "0.4.0"
44
edition = "2021"
55
rust-version = "1.87"
66
license = "MPL-2.0"
@@ -22,7 +22,7 @@ experimental-godot-api = []
2222
experimental-threads = []
2323

2424
[dependencies]
25-
godot-bindings = { path = "../godot-bindings", version = "=0.4.1" }
25+
godot-bindings = { path = "../godot-bindings", version = "=0.4.0" }
2626

2727
heck = { workspace = true }
2828
nanoserde = { workspace = true }
@@ -31,7 +31,7 @@ quote = { workspace = true }
3131
regex = { workspace = true }
3232

3333
[build-dependencies]
34-
godot-bindings = { path = "../godot-bindings", version = "=0.4.1" } # emit_godot_version_cfg
34+
godot-bindings = { path = "../godot-bindings", version = "=0.4.0" } # emit_godot_version_cfg
3535

3636
# https://docs.rs/about/metadata
3737
[package.metadata.docs.rs]

godot-codegen/src/context.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use quote::{format_ident, ToTokens};
1212

1313
use crate::generator::method_tables::MethodTableKey;
1414
use crate::generator::notifications;
15+
use crate::generator::sys::SYS_PARAMS;
1516
use crate::models::domain::{ArgPassing, GodotTy, RustTy, TyName};
1617
use crate::models::json::{
1718
JsonBuiltinClass, JsonBuiltinMethod, JsonClass, JsonClassConstant, JsonClassMethod,
@@ -28,6 +29,9 @@ pub struct Context<'a> {
2829
/// Which interface traits are generated (`false` for "Godot-abstract"/final classes).
2930
classes_final: HashMap<TyName, bool>,
3031
cached_rust_types: HashMap<GodotTy, RustTy>,
32+
/// Various pointers defined in `gdextension_interface`, for example `GDExtensionInitializationFunction`.
33+
/// Used in some APIs that are not exposed to GDScript.
34+
sys_types: HashSet<&'a str>,
3135
notifications_by_class: HashMap<TyName, Vec<(Ident, i32)>>,
3236
classes_with_signals: HashSet<TyName>,
3337
notification_enum_names_by_class: HashMap<TyName, NotificationEnum>,
@@ -43,6 +47,8 @@ impl<'a> Context<'a> {
4347
ctx.singletons.insert(class.name.as_str());
4448
}
4549

50+
Self::populate_sys_types(&mut ctx);
51+
4652
ctx.builtin_types.insert("Variant"); // not part of builtin_classes
4753
for builtin in api.builtin_classes.iter() {
4854
let ty_name = builtin.name.as_str();
@@ -152,6 +158,14 @@ impl<'a> Context<'a> {
152158
ctx
153159
}
154160

161+
/// Adds Godot pointer types to [`Context`].
162+
///
163+
/// Godot pointer types, for example `GDExtensionInitializationFunction`, are defined in `gdextension_interface`
164+
/// but aren't described in `extension_api.json` – despite being used as parameters in various APIs.
165+
fn populate_sys_types(ctx: &mut Context) {
166+
ctx.sys_types.extend(SYS_PARAMS.iter().map(|p| p.type_()));
167+
}
168+
155169
fn populate_notification_constants(
156170
class_name: &TyName,
157171
constants: &[JsonClassConstant],
@@ -252,14 +266,6 @@ impl<'a> Context<'a> {
252266
.unwrap_or_else(|| panic!("did not register table index for key {key:?}"))
253267
}
254268

255-
/// Yields cached sys pointer types – various pointer types declared in `gdextension_interface`
256-
/// and used as parameters in exposed Godot APIs.
257-
pub fn cached_sys_pointer_types(&self) -> impl Iterator<Item = &RustTy> {
258-
self.cached_rust_types
259-
.values()
260-
.filter(|rust_ty| rust_ty.is_sys_pointer())
261-
}
262-
263269
/// Whether an interface trait is generated for a class.
264270
///
265271
/// False if the class is "Godot-abstract"/final, thus there are no virtual functions to inherit.
@@ -301,6 +307,10 @@ impl<'a> Context<'a> {
301307
self.native_structures_types.contains(ty_name)
302308
}
303309

310+
pub fn is_sys(&self, ty_name: &str) -> bool {
311+
self.sys_types.contains(ty_name)
312+
}
313+
304314
pub fn is_singleton(&self, class_name: &TyName) -> bool {
305315
self.singletons.contains(class_name.godot_ty.as_str())
306316
}

godot-codegen/src/conv/type_conversions.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,17 @@ fn to_rust_type_uncached(full_ty: &GodotTy, ctx: &mut Context) -> RustTy {
170170
ty = ty.replace("const ", "");
171171
}
172172

173-
// Sys pointer type defined in `gdextension_interface` and used as param for given method, e.g. `GDExtensionInitializationFunction`.
174-
// Note: we branch here to avoid clashes with actual GDExtension classes.
175-
if ty.starts_with("GDExtension") {
173+
// .trim() is necessary here, as Godot places a space between a type and the stars when representing a double pointer.
174+
// Example: "int*" but "int **".
175+
if ctx.is_sys(ty.trim()) {
176176
let ty = rustify_ty(&ty);
177177
return RustTy::RawPointer {
178-
inner: Box::new(RustTy::SysPointerType {
178+
inner: Box::new(RustTy::SysIdent {
179179
tokens: quote! { sys::#ty },
180180
}),
181181
is_const,
182182
};
183183
}
184-
185-
// .trim() is necessary here, as Godot places a space between a type and the stars when representing a double pointer.
186-
// Example: "int*" but "int **".
187184
let inner_type = to_rust_type(ty.trim(), None, ctx);
188185
return RustTy::RawPointer {
189186
inner: Box::new(inner_type),

godot-codegen/src/generator/central_files.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use quote::{format_ident, quote, ToTokens};
1010

1111
use crate::context::Context;
1212
use crate::conv;
13-
use crate::generator::sys_pointer_types::make_godotconvert_for_systypes;
13+
use crate::generator::sys::make_godotconvert_for_systypes;
1414
use crate::generator::{enums, gdext_build_struct};
1515
use crate::models::domain::ExtensionApi;
1616
use crate::util::ident;
@@ -61,7 +61,7 @@ pub fn make_core_central_code(api: &ExtensionApi, ctx: &mut Context) -> TokenStr
6161

6262
let (global_enum_defs, global_reexported_enum_defs) = make_global_enums(api);
6363
let variant_type_traits = make_variant_type_enum(api, false);
64-
let sys_types_godotconvert_impl = make_godotconvert_for_systypes(ctx);
64+
let sys_types_godotconvert_impl = make_godotconvert_for_systypes();
6565

6666
// TODO impl Clone, Debug, PartialEq, PartialOrd, Hash for VariantDispatch
6767
// TODO could use try_to().unwrap_unchecked(), since type is already verified. Also directly overload from_variant().
@@ -124,10 +124,7 @@ pub fn make_core_central_code(api: &ExtensionApi, ctx: &mut Context) -> TokenStr
124124
#( #global_reexported_enum_defs )*
125125
}
126126

127-
pub mod sys_pointer_types {
128-
use crate::sys;
129-
#( #sys_types_godotconvert_impl )*
130-
}
127+
#( #sys_types_godotconvert_impl )*
131128
}
132129
}
133130

godot-codegen/src/generator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub mod method_tables;
2828
pub mod native_structures;
2929
pub mod notifications;
3030
pub mod signals;
31-
pub mod sys_pointer_types;
31+
pub mod sys;
3232
pub mod utility_functions;
3333
pub mod virtual_definitions;
3434
pub mod virtual_traits;

0 commit comments

Comments
 (0)