summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/objc.rs28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/ir/objc.rs b/src/ir/objc.rs
index 1b2bd5de..cfbf3dd0 100644
--- a/src/ir/objc.rs
+++ b/src/ir/objc.rs
@@ -226,11 +226,16 @@ impl ObjCMethod {
/// Formats the method call
pub fn format_method_call(&self, args: &[TokenStream]) -> TokenStream {
- let split_name: Vec<_> = self
+ let split_name: Vec<Option<Ident>> = self
.name
.split(':')
- .filter(|p| !p.is_empty())
- .map(|name| Ident::new(name, Span::call_site()))
+ .map(|name| {
+ if name.is_empty() {
+ None
+ } else {
+ Some(Ident::new(name, Span::call_site()))
+ }
+ })
.collect();
// No arguments
@@ -242,11 +247,11 @@ impl ObjCMethod {
}
// Check right amount of arguments
- if args.len() != split_name.len() {
+ if args.len() != split_name.len() - 1 {
panic!(
"Incorrect method name or arguments for objc method, {:?} vs {:?}",
args,
- split_name
+ split_name,
);
}
@@ -259,10 +264,15 @@ impl ObjCMethod {
args_without_types.push(Ident::new(name, Span::call_site()))
}
- let args = split_name
- .into_iter()
- .zip(args_without_types)
- .map(|(arg, arg_val)| quote! { #arg : #arg_val });
+ let args = split_name.into_iter().zip(args_without_types).map(
+ |(arg, arg_val)| {
+ if let Some(arg) = arg {
+ quote! { #arg: #arg_val }
+ } else {
+ quote! { #arg_val: #arg_val }
+ }
+ },
+ );
quote! {
#( #args )*