Names.exported_fn() - take an &Ident, not a &str

Also, introduce Names.exported_fn_from_str() to take that case into account.
parent bd55e89b
Pipeline #14675 failed with stages
in 4 minutes and 4 seconds
......@@ -74,7 +74,7 @@ impl<'ast> ClassContext<'ast> {
}
pub fn imp_new_fn_name(&self) -> Ident {
self.names.exported_fn("new")
self.names.exported_fn_from_str("new")
}
pub fn register_instance_private(&self) -> TokenStream {
......
......@@ -198,7 +198,7 @@ pub fn extern_methods<'ast>(names: &Names, slots: &[Slot<'ast>]) -> Vec<TokenStr
ref sig,
..
}) => {
let ffi_name = names.exported_fn(sig.name.as_ref());
let ffi_name = names.exported_fn(&sig.name);
let method_impl_name = names.slot_impl(&sig.name);
let inputs = sig.input_args_with_glib_types();
let args = sig.input_args_from_glib_types();
......@@ -221,7 +221,7 @@ pub fn extern_methods<'ast>(names: &Names, slots: &[Slot<'ast>]) -> Vec<TokenStr
Slot::VirtualMethod(VirtualMethod { ref sig, .. }) => {
let name = sig.name;
let ffi_name = names.exported_fn(sig.name.as_ref());
let ffi_name = names.exported_fn(&sig.name);
let inputs = sig.input_args_with_glib_types();
let args = sig.input_arg_names();
let output = sig.output_glib_type();
......
......@@ -67,7 +67,7 @@ pub fn slot_trait_impls<'ast>(names: &Names, slots: &[Slot<'ast>]) -> Vec<TokenS
})
| Slot::VirtualMethod(VirtualMethod { ref sig, .. }) => {
let name = sig.name;
let ffi_name = names.exported_fn(name.as_ref());
let ffi_name = names.exported_fn(&name);
let arg_names = sig.input_args_to_glib_types();
let value = quote_cs! {
unsafe {
......
......@@ -78,17 +78,29 @@ impl Names {
/// If the `Names` was created with an instance name of "FooBar",
/// and `method_name` is `frob`, this generates the identifier
/// `foo_bar_frob`.
pub fn exported_fn(&self, method_name: &str) -> Ident {
pub fn exported_fn(&self, method_name: &Ident) -> Ident {
Ident::from(format!(
"{}_{}",
lower_case_instance_name(self.instance.as_ref()),
lower_case_instance_name(self.instance),
method_name
))
}
/// Returns the name of a C-callable function name for a method
///
/// Similar to `exported_fn()`, but takes a `&str` for the method
/// name instead of an `&Ident`.
pub fn exported_fn_from_str(&self, method_name: &str) -> Ident {
Ident::from(format!(
"{}_{}",
lower_case_instance_name(self.instance),
method_name
))
}
/// Returns the name of the `foo_get_type()` function for GType
pub fn get_type_fn(&self) -> Ident {
self.exported_fn("get_type")
self.exported_fn_from_str("get_type")
}
/// Given a slot name (method or signal), returns its trampoline name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment