1 #[cxx::bridge(namespace = "tests")] 2 pub mod ffi { 3 struct Job { 4 raw: u32, 5 } 6 7 unsafe extern "C++" { 8 include!("tests/ffi/tests.h"); 9 10 type C = crate::ffi::C; 11 c_take_unique_ptr(c: UniquePtr<C>)12 fn c_take_unique_ptr(c: UniquePtr<C>); 13 } 14 15 impl Vec<Job> {} 16 } 17 18 #[cxx::bridge(namespace = "tests")] 19 pub mod ffi2 { 20 unsafe extern "C++" { 21 include!("tests/ffi/tests.h"); 22 23 type D = crate::other::D; 24 type E = crate::other::E; 25 #[namespace = "F"] 26 type F = crate::other::f::F; 27 #[namespace = "G"] 28 type G = crate::other::G; 29 30 #[namespace = "H"] 31 type H; 32 c_take_trivial_ptr(d: UniquePtr<D>)33 fn c_take_trivial_ptr(d: UniquePtr<D>); c_take_trivial_ref(d: &D)34 fn c_take_trivial_ref(d: &D); c_take_trivial_mut_ref(d: &mut D)35 fn c_take_trivial_mut_ref(d: &mut D); c_take_trivial_pin_ref(d: Pin<&D>)36 fn c_take_trivial_pin_ref(d: Pin<&D>); c_take_trivial_pin_mut_ref(d: Pin<&mut D>)37 fn c_take_trivial_pin_mut_ref(d: Pin<&mut D>); c_take_trivial_ref_method(self: &D)38 fn c_take_trivial_ref_method(self: &D); c_take_trivial_mut_ref_method(self: &mut D)39 fn c_take_trivial_mut_ref_method(self: &mut D); c_take_trivial(d: D)40 fn c_take_trivial(d: D); c_take_trivial_ns_ptr(g: UniquePtr<G>)41 fn c_take_trivial_ns_ptr(g: UniquePtr<G>); c_take_trivial_ns_ref(g: &G)42 fn c_take_trivial_ns_ref(g: &G); c_take_trivial_ns(g: G)43 fn c_take_trivial_ns(g: G); c_take_opaque_ptr(e: UniquePtr<E>)44 fn c_take_opaque_ptr(e: UniquePtr<E>); c_take_opaque_ref(e: &E)45 fn c_take_opaque_ref(e: &E); c_take_opaque_ref_method(self: &E)46 fn c_take_opaque_ref_method(self: &E); c_take_opaque_mut_ref_method(self: Pin<&mut E>)47 fn c_take_opaque_mut_ref_method(self: Pin<&mut E>); c_take_opaque_ns_ptr(e: UniquePtr<F>)48 fn c_take_opaque_ns_ptr(e: UniquePtr<F>); c_take_opaque_ns_ref(e: &F)49 fn c_take_opaque_ns_ref(e: &F); c_return_trivial_ptr() -> UniquePtr<D>50 fn c_return_trivial_ptr() -> UniquePtr<D>; c_return_trivial() -> D51 fn c_return_trivial() -> D; c_return_trivial_ns_ptr() -> UniquePtr<G>52 fn c_return_trivial_ns_ptr() -> UniquePtr<G>; c_return_trivial_ns() -> G53 fn c_return_trivial_ns() -> G; c_return_opaque_ptr() -> UniquePtr<E>54 fn c_return_opaque_ptr() -> UniquePtr<E>; c_return_opaque_mut_pin(e: Pin<&mut E>) -> Pin<&mut E>55 fn c_return_opaque_mut_pin(e: Pin<&mut E>) -> Pin<&mut E>; c_return_ns_opaque_ptr() -> UniquePtr<F>56 fn c_return_ns_opaque_ptr() -> UniquePtr<F>; c_return_ns_unique_ptr() -> UniquePtr<H>57 fn c_return_ns_unique_ptr() -> UniquePtr<H>; c_take_ref_ns_c(h: &H)58 fn c_take_ref_ns_c(h: &H); 59 60 #[namespace = "other"] ns_c_take_trivial(d: D)61 fn ns_c_take_trivial(d: D); 62 #[namespace = "other"] ns_c_return_trivial() -> D63 fn ns_c_return_trivial() -> D; 64 65 #[namespace = "I"] 66 type I; 67 get(self: &I) -> u3268 fn get(self: &I) -> u32; 69 70 #[namespace = "I"] ns_c_return_unique_ptr_ns() -> UniquePtr<I>71 fn ns_c_return_unique_ptr_ns() -> UniquePtr<I>; 72 } 73 74 impl UniquePtr<D> {} 75 impl UniquePtr<E> {} 76 impl UniquePtr<F> {} 77 impl UniquePtr<G> {} 78 } 79