Skip to content

Commit 30ef306

Browse files
committed
Add workaround forResourceDeepDuplicateMode being wrongly marked as an engine enum.
1 parent d1874f3 commit 30ef306

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

godot-codegen/src/conv/type_conversions.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,11 @@ fn to_rust_type_uncached(full_ty: &GodotTy, ctx: &mut Context) -> RustTy {
249249
/// I.e. just `Mesh.ArrayFormat` or `Error`.
250250
pub(crate) fn to_enum_type_uncached(enum_or_bitfield: &str, is_bitfield: bool) -> RustTy {
251251
if let Some((class, enum_)) = enum_or_bitfield.split_once('.') {
252-
// Class-local enum or bitfield.
253-
let module = ModName::from_godot(class);
254-
let enum_or_bitfield_name = conv::make_enum_name(enum_);
255-
256-
RustTy::EngineEnum {
257-
tokens: quote! { crate::classes::#module::#enum_or_bitfield_name },
258-
surrounding_class: Some(class.to_string()),
259-
is_bitfield,
260-
}
252+
to_class_enum_uncached(class, enum_, is_bitfield)
253+
} else if enum_or_bitfield == "ResourceDeepDuplicateMode" {
254+
// FIXME – in https://github.com/godotengine/godot/pull/100673#issuecomment-2916116489 `ResourceDeepDuplicateMode` has been wrongly marked as an Engine Enum.
255+
// Remove this workaround after the fix appears.
256+
to_class_enum_uncached("Resource", enum_or_bitfield, is_bitfield)
261257
} else {
262258
// Global enum or bitfield.
263259
let enum_or_bitfield_name = conv::make_enum_name(enum_or_bitfield);
@@ -270,6 +266,18 @@ pub(crate) fn to_enum_type_uncached(enum_or_bitfield: &str, is_bitfield: bool) -
270266
}
271267
}
272268

269+
fn to_class_enum_uncached(class: &str, enum_: &str, is_bitfield: bool) -> RustTy {
270+
// Class-local enum or bitfield.
271+
let module = ModName::from_godot(class);
272+
let enum_or_bitfield_name = conv::make_enum_name(enum_);
273+
274+
RustTy::EngineEnum {
275+
tokens: quote! { crate::classes::#module::#enum_or_bitfield_name },
276+
surrounding_class: Some(class.to_string()),
277+
is_bitfield,
278+
}
279+
}
280+
273281
// ----------------------------------------------------------------------------------------------------------------------------------------------
274282
// Godot -> Rust expressions
275283

0 commit comments

Comments
 (0)