Skip to content

ObjectiveC generics are not type erased properly #1259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jrmuizel opened this issue Feb 18, 2018 · 1 comment · Fixed by #1702
Closed

ObjectiveC generics are not type erased properly #1259

jrmuizel opened this issue Feb 18, 2018 · 1 comment · Fixed by #1702

Comments

@jrmuizel
Copy link
Contributor

Input C/C++ Header

@interface Base
@end

@interface NSArray<ObjectType> : Base
-(ObjectType)getit;
@end

Bindgen Invocation

bindgen --objc-extern-crate generics.m -- -x objective-c

Actual Results

/* automatically generated by rust-bindgen */

#[macro_use]
extern crate objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
pub trait Base {}
impl Base for id {}
pub trait Bar {
    unsafe fn getit(self) -> *mut ObjectType;
}
impl Bar for id {
    unsafe fn getit(self) -> *mut ObjectType {
        msg_send!(self, getit)
    }
}

Expected Results

At a minimum we should erase the generics. Even better we could convert them to rust generics.

Proper support for this is needed for running bindgen on the mac system headers.

@emilio
Copy link
Contributor

emilio commented Feb 19, 2018

Objc support is known-WIP. But type-erasing this or generating the generics should be easy, it'd be just a matter of figuring out how clang exposes them on the AST and hooking them up to the rest of template parameter infrastructure we have in src/ir/analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants