rust-bindgen
rust-bindgen copied to clipboard
Objective-C method fragment needs keyword escape
Input C/C++ Header
@interface A
-(void)f:(int)arg1 as:(int)arg2;
@end
Bindgen Invocation
$ bindgen objc_escape.m
Actual Results
/* automatically generated by rust-bindgen 0.60.1 */
use objc::{self, class, msg_send, sel, sel_impl};
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
#[repr(transparent)]
#[derive(Debug, Copy, Clone)]
pub struct A(pub id);
impl std::ops::Deref for A {
type Target = objc::runtime::Object;
fn deref(&self) -> &Self::Target {
unsafe { &*self.0 }
}
}
unsafe impl objc::Message for A {}
impl A {
pub fn alloc() -> Self {
Self(unsafe { msg_send!(class!(A), alloc) })
}
}
impl IA for A {}
pub trait IA: Sized + std::ops::Deref {
unsafe fn f_as_(&self, arg1: ::std::os::raw::c_int, arg2: ::std::os::raw::c_int)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
msg_send ! (* self , f : arg1 as : arg2)
}
}
as part in msg_send! will be keyword error.
Expected Results
use objc::{self, class, msg_send, sel, sel_impl};
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
#[repr(transparent)]
#[derive(Debug, Copy, Clone)]
pub struct A(pub id);
impl std::ops::Deref for A {
type Target = objc::runtime::Object;
fn deref(&self) -> &Self::Target {
unsafe { &*self.0 }
}
}
unsafe impl objc::Message for A {}
impl A {
pub fn alloc() -> Self {
Self(unsafe { msg_send!(class!(A), alloc) })
}
}
impl IA for A {}
pub trait IA: Sized + std::ops::Deref {
unsafe fn f_as_(&self, arg1: ::std::os::raw::c_int, arg2: ::std::os::raw::c_int)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
msg_send ! (* self , f : arg1 r#as : arg2)
}
}
escaping with r#as will fix compile error
Should be trivial-ish to do this I think, thanks for the report!