forked from mozilla/uniffi-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the uniffi_forward_scaffolding macro
This can be used to work around [rust-lang#50007](rust-lang/rust#50007), which is getting to be more and more of an issue on the desktop JS project.
- Loading branch information
Showing
4 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
uniffi_bindgen/src/scaffolding/templates/ForwardUniFFIScaffolding.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Create a macro that can be used by a dependent create to forward all of the scaffolding | ||
// functions defined here. This is used in 2 ways: | ||
// | ||
// - Building libraries that contain multiple UniFFI components (megazord, libxul). The combined | ||
// library can depend on each component then call uniffi_forward_scaffolding!() for each one. | ||
// - Test fixtures. Each binding generator needs to test against the test fixtures. To allow | ||
// this, they call uniffi_forward_scaffolding!() for the test fixture in their test module. | ||
#[macro_export] | ||
macro_rules! uniffi_forward_scaffolding { | ||
() => { | ||
{%- for ffi_func in ci.iter_ffi_function_definitions() %} | ||
pub extern "C" fn {{ ffi_func.name() }}( | ||
{%- call rs::arg_list_ffi_decl(ffi_func) %} | ||
) {% call rs::return_signature_ffi(ffi_func) %} { | ||
$crate::{{ ffi_func.name() }}({% for arg in ffi_func.arguments() %}{{ arg.name() }}, {% endfor %}callStatus) | ||
} | ||
{% endfor -%} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters