Skip to content

Commit d005e7e

Browse files
committed
function_registered_name => func_name
1 parent 74fab79 commit d005e7e

File tree

5 files changed

+29
-39
lines changed

5 files changed

+29
-39
lines changed

godot-macros/src/class/data_models/field_var.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::class::{
1212
into_signature_info, make_existence_check, make_method_registration, Field, FieldHint,
1313
FuncDefinition,
1414
};
15-
use crate::util::make_function_registered_name_constant;
15+
use crate::util::make_func_name_constant;
1616
use crate::util::KvParser;
1717
use crate::{util, ParseResult};
1818

@@ -167,7 +167,7 @@ pub struct GetterSetterImpl {
167167
pub function_name: Ident,
168168
pub function_impl: TokenStream,
169169
pub export_token: TokenStream,
170-
pub func_registered_name_const: TokenStream,
170+
pub func_name_const: TokenStream,
171171
}
172172

173173
impl GetterSetterImpl {
@@ -208,8 +208,7 @@ impl GetterSetterImpl {
208208
}
209209
};
210210

211-
let func_registered_name_const =
212-
make_function_registered_name_constant(class_name, &function_name, None, &[]);
211+
let func_name_const = make_func_name_constant(class_name, &function_name, None, &[]);
213212

214213
let signature = util::parse_signature(signature);
215214
let export_token = make_method_registration(
@@ -234,7 +233,7 @@ impl GetterSetterImpl {
234233
function_name,
235234
function_impl,
236235
export_token,
237-
func_registered_name_const,
236+
func_name_const,
238237
}
239238
}
240239

@@ -243,7 +242,7 @@ impl GetterSetterImpl {
243242
function_name: function_name.clone(),
244243
function_impl: TokenStream::new(),
245244
export_token: make_existence_check(function_name),
246-
func_registered_name_const: TokenStream::new(),
245+
func_name_const: TokenStream::new(),
247246
}
248247
}
249248
}

godot-macros/src/class/data_models/inherent_impl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::class::{
1111
SignatureInfo, TransferMode,
1212
};
1313
use crate::util::{
14-
bail, c_str, error_fn, format_function_registered_name_struct_name, ident,
15-
make_function_registered_name_constants, replace_class_in_path, require_api_version, KvParser,
14+
bail, c_str, error_fn, format_func_name_struct_name, ident, make_func_name_constants,
15+
replace_class_in_path, require_api_version, KvParser,
1616
};
1717
use crate::{handle_mutually_exclusive_keys, util, ParseResult};
1818

@@ -95,7 +95,7 @@ pub fn transform_inherent_impl(
9595

9696
// This is the container struct that holds the names of all registered #[func]s.
9797
// (The struct is declared by the macro derive_godot_class.)
98-
let class_functions_name = format_function_registered_name_struct_name(&class_name);
98+
let class_functions_name = format_func_name_struct_name(&class_name);
9999
// As the impl block could be of the form "path::class", and we add a second impl block below, we need the full path, not just the class name.
100100
let this_class_full_path = impl_block.self_ty.as_path().ok_or(error_fn(
101101
"unexpected: the function already checked 'as_path' above in validate_impl",
@@ -104,7 +104,7 @@ pub fn transform_inherent_impl(
104104
let class_functions_path: Path =
105105
replace_class_in_path(this_class_full_path, class_functions_name);
106106
// For each #[func] in this impl block, we create one constant.
107-
let func_name_constants = make_function_registered_name_constants(&funcs, &class_name);
107+
let func_name_constants = make_func_name_constants(&funcs, &class_name);
108108

109109
let signal_registrations = make_signal_registrations(signals, &class_name_obj);
110110

godot-macros/src/class/data_models/property.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
//! Parsing the `var` and `export` attributes on fields.
99
1010
use crate::class::{Field, FieldVar, Fields, GetSet, GetterSetterImpl, UsageFlags};
11-
use crate::util::{
12-
format_function_registered_name_constant_name, format_function_registered_name_struct_name,
13-
ident,
14-
};
11+
use crate::util::{format_func_name_constant_name, format_func_name_struct_name, ident};
1512
use proc_macro2::{Ident, TokenStream};
1613
use quote::quote;
1714

@@ -42,7 +39,7 @@ impl FieldHint {
4239

4340
pub fn make_property_impl(class_name: &Ident, fields: &Fields) -> TokenStream {
4441
let mut getter_setter_impls = Vec::new();
45-
let mut func_registered_name_consts = Vec::new();
42+
let mut func_name_consts = Vec::new();
4643
let mut export_tokens = Vec::new();
4744

4845
for field in &fields.all_fields {
@@ -144,14 +141,14 @@ pub fn make_property_impl(class_name: &Ident, fields: &Fields) -> TokenStream {
144141
let getter_tokens = make_getter_setter(
145142
getter.to_impl(class_name, GetSet::Get, field),
146143
&mut getter_setter_impls,
147-
&mut func_registered_name_consts,
144+
&mut func_name_consts,
148145
&mut export_tokens,
149146
class_name,
150147
);
151148
let setter_tokens = make_getter_setter(
152149
setter.to_impl(class_name, GetSet::Set, field),
153150
&mut getter_setter_impls,
154-
&mut func_registered_name_consts,
151+
&mut func_name_consts,
155152
&mut export_tokens,
156153
class_name,
157154
);
@@ -169,15 +166,15 @@ pub fn make_property_impl(class_name: &Ident, fields: &Fields) -> TokenStream {
169166

170167
// For each generated #[func], add a const.
171168
// This is the name of the container struct, which is declared by the derive macro GodotClass.
172-
let class_functions_name = format_function_registered_name_struct_name(class_name);
169+
let class_functions_name = format_func_name_struct_name(class_name);
173170

174171
quote! {
175172
impl #class_name {
176173
#(#getter_setter_impls)*
177174
}
178175

179176
impl #class_functions_name {
180-
#(#func_registered_name_consts)*
177+
#(#func_name_consts)*
181178
}
182179

183180
impl ::godot::obj::cap::ImplementsGodotExports for #class_name {
@@ -195,7 +192,7 @@ pub fn make_property_impl(class_name: &Ident, fields: &Fields) -> TokenStream {
195192
fn make_getter_setter(
196193
getter_setter_impl: Option<GetterSetterImpl>,
197194
getter_setter_impls: &mut Vec<TokenStream>,
198-
func_registered_name_consts: &mut Vec<TokenStream>,
195+
func_name_consts: &mut Vec<TokenStream>,
199196
export_tokens: &mut Vec<TokenStream>,
200197
class_name: &Ident,
201198
) -> TokenStream {
@@ -204,19 +201,19 @@ fn make_getter_setter(
204201
function_name,
205202
function_impl,
206203
export_token,
207-
func_registered_name_const,
204+
func_name_const,
208205
} = getter_impl;
209206

210207
getter_setter_impls.push(function_impl);
211-
func_registered_name_consts.push(func_registered_name_const);
208+
func_name_consts.push(func_name_const);
212209
export_tokens.push(export_token);
213210

214211
let getter_setter_name = function_name.to_string();
215212

216-
let class_functions_name = format_function_registered_name_struct_name(class_name);
213+
let class_functions_name = format_func_name_struct_name(class_name);
217214

218215
let getter_setter_fn_const =
219-
format_function_registered_name_constant_name(class_name, &ident(&getter_setter_name));
216+
format_func_name_constant_name(class_name, &ident(&getter_setter_name));
220217
quote! { #class_functions_name::#getter_setter_fn_const }
221218
} else {
222219
quote! { "" }

godot-macros/src/class/derive_godot_class.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::class::{
1313
FieldVar, Fields, SignatureInfo,
1414
};
1515
use crate::util::{
16-
bail, error, format_function_registered_name_struct_name, ident, path_ends_with_complex,
17-
require_api_version, KvParser,
16+
bail, error, format_func_name_struct_name, ident, path_ends_with_complex, require_api_version,
17+
KvParser,
1818
};
1919
use crate::{handle_mutually_exclusive_keys, util, ParseResult};
2020

@@ -138,7 +138,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
138138
}
139139

140140
// Declares a dummy struct that, for each #[func], holds a constant that maps the rust name to the name under which it is registered in godot.
141-
let class_functions_name = format_function_registered_name_struct_name(class_name);
141+
let class_functions_name = format_func_name_struct_name(class_name);
142142
let class_functions_struct = quote! {
143143
#[doc(hidden)]
144144
pub struct #class_functions_name { }

godot-macros/src/util/mod.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,7 @@ pub fn venial_parse_meta(
320320

321321
// util functions for handling #[func]s and #[var(get=f, set=f)]
322322

323-
pub fn make_function_registered_name_constants(
324-
funcs: &[FuncDefinition],
325-
class_name: &Ident,
326-
) -> Vec<TokenStream> {
323+
pub fn make_func_name_constants(funcs: &[FuncDefinition], class_name: &Ident) -> Vec<TokenStream> {
327324
funcs
328325
.iter()
329326
.map(|func| {
@@ -332,7 +329,7 @@ pub fn make_function_registered_name_constants(
332329
.into_iter()
333330
.collect::<Vec<_>>();
334331

335-
make_function_registered_name_constant(
332+
make_func_name_constant(
336333
class_name,
337334
&func.signature_info.method_name,
338335
func.registered_name.as_ref(),
@@ -344,13 +341,13 @@ pub fn make_function_registered_name_constants(
344341

345342
/// Funcs can be renamed with `#[func(rename=new_name) fn f();`.
346343
/// To be able to access the renamed function name at a later point, it is saved in a string constant.
347-
pub fn make_function_registered_name_constant(
344+
pub fn make_func_name_constant(
348345
class_name: &Ident,
349346
func_name: &Ident,
350347
registered_name: Option<&String>,
351348
attributes: &[&Attribute],
352349
) -> TokenStream {
353-
let const_name = format_function_registered_name_constant_name(class_name, func_name);
350+
let const_name = format_func_name_constant_name(class_name, func_name);
354351
let const_value = match &registered_name {
355352
Some(renamed) => renamed.to_string(),
356353
None => func_name.to_string(),
@@ -399,14 +396,11 @@ pub fn replace_class_in_path(path: Path, new_class: Ident) -> Path {
399396
}
400397

401398
/// Returns the name of the constant that will be autogenerated.
402-
pub fn format_function_registered_name_constant_name(
403-
_class_name: &Ident,
404-
func_name: &Ident,
405-
) -> Ident {
399+
pub fn format_func_name_constant_name(_class_name: &Ident, func_name: &Ident) -> Ident {
406400
format_ident!("{func_name}")
407401
}
408402

409403
/// Returns the name of the dummy struct that's used as container for all function name constants.
410-
pub fn format_function_registered_name_struct_name(class_name: &Ident) -> Ident {
404+
pub fn format_func_name_struct_name(class_name: &Ident) -> Ident {
411405
format_ident!("__gdext_{class_name}_Functions")
412406
}

0 commit comments

Comments
 (0)