File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
itest/rust/src/engine_tests Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -803,9 +803,14 @@ fn validate_enum_replacements(
803803
804804impl NativeStructure {
805805 pub fn from_json ( json : & JsonNativeStructure ) -> Self {
806+ // Some native-struct definitions are incorrect in earlier Godot versions; this backports corrections.
807+ let format = special_cases:: get_native_struct_definition ( & json. name )
808+ . map ( |s| s. to_string ( ) )
809+ . unwrap_or_else ( || json. format . clone ( ) ) ;
810+
806811 Self {
807812 name : json. name . clone ( ) ,
808- format : json . format . clone ( ) ,
813+ format,
809814 }
810815 }
811816}
Original file line number Diff line number Diff line change @@ -97,6 +97,22 @@ pub fn is_native_struct_excluded(ty: &str) -> bool {
9797 codegen_special_cases:: is_native_struct_excluded ( ty)
9898}
9999
100+ /// Overrides the definition string for native structures, if they have incorrect definitions in the JSON.
101+ #[ rustfmt:: skip]
102+ pub fn get_native_struct_definition ( struct_name : & str ) -> Option < & ' static str > {
103+ match struct_name {
104+ // Glyph struct definition was corrected in Godot 4.6 to include missing `span_index` field.
105+ // See https://github.com/godotengine/godot/pull/108369.
106+ // #[cfg(before_api = "4.6")] // TODO(v0.5): enable this once upstream PR is merged.
107+ "Glyph" => Some (
108+ "int start = -1;int end = -1;uint8_t count = 0;uint8_t repeat = 1;uint16_t flags = 0;float x_off = 0.f;float y_off = 0.f;\
109+ float advance = 0.f;RID font_rid;int font_size = 0;int32_t index = 0;int span_index = -1"
110+ ) ,
111+
112+ _ => None ,
113+ }
114+ }
115+
100116#[ rustfmt:: skip]
101117pub fn is_godot_type_deleted ( godot_ty : & str ) -> bool {
102118 // Note: parameter can be a class or builtin name, but also something like "enum::AESContext.Mode".
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ pub fn sample_glyph(start: i32) -> Glyph {
2626 font_rid : Rid :: new ( 1024 ) ,
2727 font_size : 1025 ,
2828 index : 1026 ,
29+ span_index : -1 ,
2930 }
3031}
3132
@@ -48,6 +49,7 @@ fn native_structure_codegen() {
4849 font_rid : Rid :: new ( 0 ) ,
4950 font_size : 0 ,
5051 index : 0 ,
52+ span_index : -1 ,
5153 } ;
5254}
5355
You can’t perform that action at this time.
0 commit comments