mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-13 03:21:33 +00:00
[WIP] Add support for unstable WebIDL (#1997)
* Re-enable WebGPU WebIDL as experimental * Add `web_sys_unstable_apis` attribute * Add test for unstable WebIDL * Include unstable WebIDL in docs.rs builds * Add docs and doc comment for unstable APIs * Add unstable API checks to CI
This commit is contained in:
@ -113,10 +113,12 @@ pub fn ident_ty(ident: Ident) -> syn::Type {
|
||||
}
|
||||
|
||||
pub fn wrap_import_function(function: ast::ImportFunction) -> ast::Import {
|
||||
let unstable_api = function.unstable_api;
|
||||
ast::Import {
|
||||
module: ast::ImportModule::None,
|
||||
js_namespace: None,
|
||||
kind: ast::ImportKind::Function(function),
|
||||
unstable_api,
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,3 +156,20 @@ impl<T: Hash> fmt::Display for ShortHash<T> {
|
||||
write!(f, "{:016x}", h.finish())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Create syn attribute for `#[cfg(web_sys_unstable_apis)]` and a doc comment.
|
||||
pub fn unstable_api_attrs() -> proc_macro2::TokenStream {
|
||||
quote::quote!(
|
||||
#[cfg(web_sys_unstable_apis)]
|
||||
#[doc = "\n\n*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as [described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
|
||||
)
|
||||
}
|
||||
|
||||
pub fn maybe_unstable_api_attr(unstable_api: bool) -> Option<proc_macro2::TokenStream> {
|
||||
if unstable_api {
|
||||
Some(unstable_api_attrs())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user