From 149a51d034711d74c50296f1d027f66926b9fdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristupas=20Antanavi=C4=8Dius?= Date: Fri, 2 Aug 2024 17:54:17 +0300 Subject: [PATCH] Add changes for C# 0.28.0 --- uniffi_bindgen/src/bindings/swift/mod.rs | 2 +- uniffi_bindgen/src/interface/ffi.rs | 11 ++++++----- uniffi_bindgen/src/interface/mod.rs | 20 ++++++++++---------- uniffi_bindgen/src/interface/object.rs | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/uniffi_bindgen/src/bindings/swift/mod.rs b/uniffi_bindgen/src/bindings/swift/mod.rs index 8421b93f9e..070f0441cf 100644 --- a/uniffi_bindgen/src/bindings/swift/mod.rs +++ b/uniffi_bindgen/src/bindings/swift/mod.rs @@ -41,7 +41,7 @@ pub use test::{run_script, run_test}; /// The Swift bindings generated from a [`crate::ComponentInterface`]. /// -struct Bindings { +pub struct Bindings { /// The contents of the generated `.swift` file, as a string. library: String, /// The contents of the generated `.h` file, as a string. diff --git a/uniffi_bindgen/src/interface/ffi.rs b/uniffi_bindgen/src/interface/ffi.rs index a1dc29713a..0a073325fa 100644 --- a/uniffi_bindgen/src/interface/ffi.rs +++ b/uniffi_bindgen/src/interface/ffi.rs @@ -195,9 +195,10 @@ pub struct FfiFunction { pub(super) arguments: Vec, pub(super) return_type: Option, pub(super) has_rust_call_status_arg: bool, - /// Used by C# generator to differentiate the free function and call it with void* + /// Used by C# generator to differentiate the clone function and call it with void* /// instead of C# `SafeHandle` type. See . - pub(super) is_object_free_function: bool, + /// Update 2024-08-02: changed this from `is_free` to `is_clone`. + pub(super) is_object_clone_function: bool, } impl FfiFunction { @@ -240,8 +241,8 @@ impl FfiFunction { self.has_rust_call_status_arg } - pub fn is_object_free_function(&self) -> bool { - self.is_object_free_function + pub fn is_object_clone_function(&self) -> bool { + self.is_object_clone_function } pub fn init( @@ -267,7 +268,7 @@ impl Default for FfiFunction { arguments: Vec::new(), return_type: None, has_rust_call_status_arg: true, - is_object_free_function: false, + is_object_clone_function: false, } } } diff --git a/uniffi_bindgen/src/interface/mod.rs b/uniffi_bindgen/src/interface/mod.rs index 19c2152672..72426ca9c0 100644 --- a/uniffi_bindgen/src/interface/mod.rs +++ b/uniffi_bindgen/src/interface/mod.rs @@ -423,7 +423,7 @@ impl ComponentInterface { arguments: vec![], return_type: Some(FfiType::UInt32), has_rust_call_status_arg: false, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -440,7 +440,7 @@ impl ComponentInterface { }], return_type: Some(FfiType::RustBuffer(None)), has_rust_call_status_arg: true, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -457,7 +457,7 @@ impl ComponentInterface { }], return_type: Some(FfiType::RustBuffer(None)), has_rust_call_status_arg: true, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -474,7 +474,7 @@ impl ComponentInterface { }], return_type: None, has_rust_call_status_arg: true, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -497,7 +497,7 @@ impl ComponentInterface { ], return_type: Some(FfiType::RustBuffer(None)), has_rust_call_status_arg: true, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -522,7 +522,7 @@ impl ComponentInterface { ], return_type: None, has_rust_call_status_arg: false, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -539,7 +539,7 @@ impl ComponentInterface { }], return_type: return_ffi_type, has_rust_call_status_arg: true, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -554,7 +554,7 @@ impl ComponentInterface { }], return_type: None, has_rust_call_status_arg: false, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -569,7 +569,7 @@ impl ComponentInterface { }], return_type: None, has_rust_call_status_arg: false, - is_object_free_function: false, + is_object_clone_function: false, } } @@ -805,7 +805,7 @@ impl ComponentInterface { arguments: vec![], return_type: Some(FfiType::UInt16), has_rust_call_status_arg: false, - is_object_free_function: false, + is_object_clone_function: false, }) } diff --git a/uniffi_bindgen/src/interface/object.rs b/uniffi_bindgen/src/interface/object.rs index 2b86e54a45..ef35cc3f58 100644 --- a/uniffi_bindgen/src/interface/object.rs +++ b/uniffi_bindgen/src/interface/object.rs @@ -217,12 +217,12 @@ impl Object { type_: FfiType::RustArcPtr(self.name.to_string()), }]; self.ffi_func_clone.return_type = Some(FfiType::RustArcPtr(self.name.to_string())); + self.ffi_func_clone.is_object_clone_function = true; self.ffi_func_free.arguments = vec![FfiArgument { name: "ptr".to_string(), type_: FfiType::RustArcPtr(self.name.to_string()), }]; self.ffi_func_free.return_type = None; - self.ffi_func_free.is_object_free_function = true; if self.has_callback_interface() { self.ffi_init_callback = Some(FfiFunction::callback_init( &self.module_path,