Debian Codegraph @

third_party/rust/uniffi_bindgen/src/scaffolding/templates/ReexportUniFFIScaffolding.rs

raw
1 // Code to re-export the UniFFI scaffolding functions.
2 //
3 // Rust won't always re-export the functions from dependencies
4 // ([rust-lang#50007](https://github.com/rust-lang/rust/issues/50007))
5 //
6 // A workaround for this is to have the dependent crate reference a function from its dependency in
7 // an extern "C" function. This is clearly hacky and brittle, but at least we have some unittests
8 // that check if this works (fixtures/reexport-scaffolding-macro).
9 //
10 // The main way we use this macro is for that contain multiple UniFFI components (libxul,
11 // megazord). The combined library has a cargo dependency for each component and calls
12 // uniffi_reexport_scaffolding!() for each one.
13
14 #[allow(missing_docs)]
15 #[doc(hidden)]
16 pub const fn uniffi_reexport_hack() {}
17
18 #[doc(hidden)]
19 #[macro_export]
20 macro_rules! uniffi_reexport_scaffolding {
21 () => {
22 #[doc(hidden)]
23 #[unsafe(no_mangle)]
24 pub extern "C" fn {{ ci.namespace() }}_uniffi_reexport_hack() {
25 $crate::uniffi_reexport_hack()
26 }
27 };
28 }