Objective-c header from CAMediaTimingFunction panics. · Issue #1703 · rust-lang/rust-bindgen (original) (raw)
If you try to make bindgen work for all of the UIKit iOS Framework one of the issues that comes up is the reference to initWithControlPoints.
It seems that thesplit_name
logic in
let split_name: Vec<_> = self |
---|
. self.name
here is initWithControlPoints::::
, and the .filter(|p| !p.is_empty())
removes the empty parameters.
Input C/C++ Header
@interface CAMediaTimingFunction
- (instancetype)initWithControlPoints:(float)c1x :(float)c1y :(float)c2x :(float)c2y;
@end
Bindgen Invocation
$ bindgen input.h -- -x objective-c
Actual Results
$ RUST_BACKTRACE=1 bindgen input.h -- -x objective-c
cargo:warning=couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable
thread 'main' panicked at 'Incorrect method name or arguments for objc method, [TokenStream [Ident { sym: c1x }, Punct { op: ':', spacing: Alone }, Ident { sym: f32 }], TokenStream [Ident { sym: c1y }, Punct { op: ':', spacing: Alone }, Ident { sym: f32 }], TokenStream [Ident { sym: c2x }, Punct { op: ':', spacing: Alone }, Ident { sym: f32 }], TokenStream [Ident { sym: c2y }, Punct { op: ':', spacing: Alone }, Ident { sym: f32 }]] vs [Ident(initWithControlPoints)]', /Users/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.51.1/src/ir/objc.rs:232:13
stack backtrace:
0: std::panicking::default_hook::{{closure}}
1: std::panicking::default_hook
2: std::panicking::rust_panic_with_hook
3: std::panicking::continue_panic_fmt
4: std::panicking::begin_panic_fmt
5: bindgen::ir::objc::ObjCMethod::format_method_call
6: bindgen::codegen::objc_method_codegen
7: <bindgen::ir::objc::ObjCInterface as bindgen::codegen::CodeGenerator>::codegen
8: <bindgen::ir::ty::Type as bindgen::codegen::CodeGenerator>::codegen
9: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
10: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
11: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
12: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
13: bindgen::ir::context::BindgenContext::gen
14: bindgen::Builder::generate
15: std::panicking::try::do_call
16: __rust_maybe_catch_panic
17: bindgen::main
18: std::rt::lang_start::{{closure}}
19: std::panicking::try::do_call
20: __rust_maybe_catch_panic
21: std::rt::lang_start_internal
22: main
Expected Results
To not panic?
From what I can tell it should produce:
use objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
pub trait CAMediaTimingFunction {
unsafe fn initWithControlPoints____(
self,
c1x: f32,
c1y: f32,
c2x: f32,
c2y: f32,
) -> instancetype;
}
impl CAMediaTimingFunction for id {
unsafe fn initWithControlPoints____(
self,
c1x: f32,
c1y: f32,
c2x: f32,
c2y: f32,
) -> instancetype {
msg_send!(self, initWithControlPoints: c1x:c1x c1y:c1y c2x:c2x c2y:c2y)
}
}
pub type instancetype = id;