diff --git a/uniffi_macros/src/setup_scaffolding.rs b/uniffi_macros/src/setup_scaffolding.rs index 6cc45c48b..79189b7b3 100644 --- a/uniffi_macros/src/setup_scaffolding.rs +++ b/uniffi_macros/src/setup_scaffolding.rs @@ -11,16 +11,20 @@ use uniffi_meta::UNIFFI_CONTRACT_VERSION; pub fn setup_scaffolding(namespace: String) -> Result { let module_path = mod_path()?; - let ffi_contract_version_ident = format_ident!("ffi_{module_path}_uniffi_contract_version"); + let normalized_module_path = module_path.replace("::", "__"); + let ffi_contract_version_ident = + format_ident!("ffi_{normalized_module_path}_uniffi_contract_version"); let namespace_upper = namespace.to_ascii_uppercase(); let namespace_const_ident = format_ident!("UNIFFI_META_CONST_NAMESPACE_{namespace_upper}"); let namespace_static_ident = format_ident!("UNIFFI_META_NAMESPACE_{namespace_upper}"); - let ffi_rustbuffer_alloc_ident = format_ident!("ffi_{module_path}_rustbuffer_alloc"); - let ffi_rustbuffer_from_bytes_ident = format_ident!("ffi_{module_path}_rustbuffer_from_bytes"); - let ffi_rustbuffer_free_ident = format_ident!("ffi_{module_path}_rustbuffer_free"); - let ffi_rustbuffer_reserve_ident = format_ident!("ffi_{module_path}_rustbuffer_reserve"); - let reexport_hack_ident = format_ident!("{module_path}_uniffi_reexport_hack"); - let ffi_rust_future_scaffolding_fns = rust_future_scaffolding_fns(&module_path); + let ffi_rustbuffer_alloc_ident = format_ident!("ffi_{normalized_module_path}_rustbuffer_alloc"); + let ffi_rustbuffer_from_bytes_ident = + format_ident!("ffi_{normalized_module_path}_rustbuffer_from_bytes"); + let ffi_rustbuffer_free_ident = format_ident!("ffi_{normalized_module_path}_rustbuffer_free"); + let ffi_rustbuffer_reserve_ident = + format_ident!("ffi_{normalized_module_path}_rustbuffer_reserve"); + let reexport_hack_ident = format_ident!("{normalized_module_path}_uniffi_reexport_hack"); + let ffi_rust_future_scaffolding_fns = rust_future_scaffolding_fns(&normalized_module_path); Ok(quote! { // Unit struct to parameterize the FfiConverter trait. diff --git a/uniffi_meta/src/ffi_names.rs b/uniffi_meta/src/ffi_names.rs index 56bff2c23..e7b4fc5b5 100644 --- a/uniffi_meta/src/ffi_names.rs +++ b/uniffi_meta/src/ffi_names.rs @@ -15,12 +15,14 @@ /// FFI symbol name for a top-level function pub fn fn_symbol_name(namespace: &str, name: &str) -> String { + let namespace = namespace.replace("::", "__"); let name = name.to_ascii_lowercase(); format!("uniffi_{namespace}_fn_func_{name}") } /// FFI symbol name for an object constructor pub fn constructor_symbol_name(namespace: &str, object_name: &str, name: &str) -> String { + let namespace = namespace.replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase(); format!("uniffi_{namespace}_fn_constructor_{object_name}_{name}") @@ -28,6 +30,7 @@ pub fn constructor_symbol_name(namespace: &str, object_name: &str, name: &str) - /// FFI symbol name for an object method pub fn method_symbol_name(namespace: &str, object_name: &str, name: &str) -> String { + let namespace = namespace.replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase(); format!("uniffi_{namespace}_fn_method_{object_name}_{name}") @@ -35,12 +38,14 @@ pub fn method_symbol_name(namespace: &str, object_name: &str, name: &str) -> Str /// FFI symbol name for the `clone` function for an object. pub fn clone_fn_symbol_name(namespace: &str, object_name: &str) -> String { + let namespace = namespace.replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); format!("uniffi_{namespace}_fn_clone_{object_name}") } /// FFI symbol name for the `free` function for an object. pub fn free_fn_symbol_name(namespace: &str, object_name: &str) -> String { + let namespace = namespace.replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); format!("uniffi_{namespace}_fn_free_{object_name}") } @@ -50,18 +55,21 @@ pub fn init_callback_vtable_fn_symbol_name( namespace: &str, callback_interface_name: &str, ) -> String { + let namespace = namespace.replace("::", "__"); let callback_interface_name = callback_interface_name.to_ascii_lowercase(); format!("uniffi_{namespace}_fn_init_callback_vtable_{callback_interface_name}") } /// FFI checksum symbol name for a top-level function pub fn fn_checksum_symbol_name(namespace: &str, name: &str) -> String { + let namespace = namespace.replace("::", "__"); let name = name.to_ascii_lowercase(); format!("uniffi_{namespace}_checksum_func_{name}") } /// FFI checksum symbol name for an object constructor pub fn constructor_checksum_symbol_name(namespace: &str, object_name: &str, name: &str) -> String { + let namespace = namespace.replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase(); format!("uniffi_{namespace}_checksum_constructor_{object_name}_{name}") @@ -69,6 +77,7 @@ pub fn constructor_checksum_symbol_name(namespace: &str, object_name: &str, name /// FFI checksum symbol name for an object method pub fn method_checksum_symbol_name(namespace: &str, object_name: &str, name: &str) -> String { + let namespace = namespace.replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase(); format!("uniffi_{namespace}_checksum_method_{object_name}_{name}")