|
| 1 | +diff --git a/crates/ubrn_bindgen/src/bindings/gen_rust/mod.rs b/crates/ubrn_bindgen/src/bindings/gen_rust/mod.rs |
| 2 | +index f21884f978b3457cc67d1ba7122816dbf8b796b2..f0913aea2df850dcacf4ac6ff81c45e3d0404f41 100644 |
| 3 | +--- a/crates/ubrn_bindgen/src/bindings/gen_rust/mod.rs |
| 4 | ++++ b/crates/ubrn_bindgen/src/bindings/gen_rust/mod.rs |
| 5 | +@@ -95,8 +95,16 @@ impl FlavorParams<'_> { |
| 6 | + } |
| 7 | + } |
| 8 | + |
| 9 | +-fn callback_fn_ident() -> Ident { |
| 10 | +- ident("JsCallbackFn") |
| 11 | ++// wasm-bindgen >=0.2.114 collapses #[wasm_bindgen]-exposed structs that |
| 12 | ++// share an identical Rust ident into one JS class breaking foreign-future callbacks. |
| 13 | ++// Suffix the ident with the containing module's name so each is a distinct Rust type. |
| 14 | ++// See https://github.com/wasm-bindgen/wasm-bindgen/pull/4977 |
| 15 | ++fn callback_fn_ident(module: &Ident) -> Ident { |
| 16 | ++ use heck::ToUpperCamelCase; |
| 17 | ++ ident(&format!( |
| 18 | ++ "JsCallbackFn{}", |
| 19 | ++ module.to_string().to_upper_camel_case() |
| 20 | ++ )) |
| 21 | + } |
| 22 | + |
| 23 | + fn wasm_flavor() -> FlavorParams<'static> { |
| 24 | +@@ -305,7 +313,7 @@ impl<'a> ComponentTemplate<'a> { |
| 25 | + |
| 26 | + let module_ident = cb.module_ident(); |
| 27 | + let js_class = cb.js_module_ident(); |
| 28 | +- let callback_fn_ident = callback_fn_ident(); |
| 29 | ++ let callback_fn_ident = callback_fn_ident(&module_ident); |
| 30 | + |
| 31 | + quote! { |
| 32 | + mod #module_ident { |
| 33 | +@@ -348,7 +356,8 @@ impl<'a> ComponentTemplate<'a> { |
| 34 | + |
| 35 | + fn ffi_callback(&mut self, cb: &FfiCallbackFunction2) -> TokenStream { |
| 36 | + let uniffi_ident = self.uniffi_ident(); |
| 37 | +- let callback_fn_ident = callback_fn_ident(); |
| 38 | ++ let cb_module_ident = cb.module_ident(); |
| 39 | ++ let callback_fn_ident = callback_fn_ident(&cb_module_ident); |
| 40 | + |
| 41 | + let js_method_decl = self.js_callback_method_decl(&callback_fn_ident, cb.callback()); |
| 42 | + |
| 43 | +@@ -512,8 +521,9 @@ impl<'a> ComponentTemplate<'a> { |
| 44 | + let field_ident = ident(field_name); |
| 45 | + let js_field_ident = camel_case_ident(field_name); |
| 46 | + if st.is_callback_method(field_name) { |
| 47 | +- let callback_fn_ident = callback_fn_ident(); |
| 48 | + let alias_ident = st.method_alias_ident(field_name); |
| 49 | ++ let mod_ident = st.method_mod_ident(field_name); |
| 50 | ++ let callback_fn_ident = callback_fn_ident(&mod_ident); |
| 51 | + quote! { |
| 52 | + #[wasm_bindgen(method, getter, js_name = #js_field_ident)] |
| 53 | + fn #field_ident(this: &VTableJs) -> #alias_ident::#callback_fn_ident; |
| 54 | +@@ -737,7 +747,7 @@ impl<'a> ComponentTemplate<'a> { |
| 55 | + } |
| 56 | + FfiType::Callback(cb) => { |
| 57 | + let mod_ident = snake_case_ident(cb); |
| 58 | +- let callback_fn_ident = callback_fn_ident(); |
| 59 | ++ let callback_fn_ident = callback_fn_ident(&mod_ident); |
| 60 | + quote! { #mod_ident::#callback_fn_ident } |
| 61 | + } |
| 62 | + FfiType::Reference(_) | FfiType::MutReference(_) => { |
0 commit comments