Source code

Revision control

Copy as Markdown

Other Tools

---
source: macro/src/lib.rs
expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn from_slice(s : & [f64]) { unimplemented! () } }\n }\n }).to_token_stream().to_string())"
---
mod ffi {
#[repr(C)]
#[derive(Clone, Copy)]
struct Foo {}
impl Foo {
pub fn from_slice(s: &[f64]) {
unimplemented!()
}
}
use diplomat_runtime::*;
#[no_mangle]
extern "C" fn Foo_from_slice(s_diplomat_data: *const f64, s_diplomat_len: usize) {
Foo::from_slice(if s_diplomat_len == 0 {
&[]
} else {
unsafe { core::slice::from_raw_parts(s_diplomat_data, s_diplomat_len) }
})
}
#[no_mangle]
extern "C" fn Foo_destroy(this: Box<Foo>) {}
}