Skip to content

Commit 06110f9

Browse files
bors[bot]mivort
andauthored
Merge #812
812: Extend safe name filter to support Godot 3.4 API r=Bromeon a=lufterc This PR adds 'enum' keyword to rust_safe_name filter and also makes use of this filter for rusty_method_name variable in bindings generator. It allows to build godot-rust with latest stable Godot 3.4 API. A bit of context: when trying to build bindings for latest stable Godot API, the following errors are produced: ``` error: expected expression, found keyword `enum` 1972 | ..., self . this . sys () . as_ptr () , class . into () , enum . into () , no_inheritance) ; StringArray :: from_sys (ret) } } # [doc = "... | ^^^^ expected expression error: expected identifier, found keyword `type` 2302 | ... } # [doc = ""] # [doc = ""] # [inline] pub fn type (& self) -> GodotString { unsafe { let method_bind : * mut sys :: godot_method_bin... | ^^^^ expected identifier, found keyword ``` It seems that newer API version introduces more keyword collisions which this patch aims to fix. Co-authored-by: lufterc <[email protected]>
2 parents cc96860 + d64f175 commit 06110f9

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

bindings_generator/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ fn rust_safe_name(name: &str) -> proc_macro2::Ident {
166166
"in" => format_ident!("_in"),
167167
"override" => format_ident!("_override"),
168168
"where" => format_ident!("_where"),
169+
"enum" => format_ident!("_enum"),
169170
name => format_ident!("{}", name),
170171
}
171172
}

bindings_generator/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub(crate) fn generate_methods(
346346

347347
icalls.insert(icall_name.clone(), method_sig);
348348

349-
let rusty_name = format_ident!("{}", rusty_method_name);
349+
let rusty_name = rust_safe_name(rusty_method_name);
350350

351351
let maybe_unsafe: TokenStream;
352352
let maybe_unsafe_reason: &str;

0 commit comments

Comments
 (0)