From 231bf9af013def4884295796823a30556fa39aad Mon Sep 17 00:00:00 2001 From: Ben Dean-Kawamura Date: Thu, 31 Oct 2024 14:27:50 -0400 Subject: [PATCH] Add `Callable::ffi_func` All the callable types implement this, so let's add it to the trait. I want to use this eventually for the Gecko JS bindings. --- uniffi_bindgen/src/interface/function.rs | 11 +++++++++++ uniffi_bindgen/src/interface/object.rs | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/uniffi_bindgen/src/interface/function.rs b/uniffi_bindgen/src/interface/function.rs index 95df0e9f5..dc37670de 100644 --- a/uniffi_bindgen/src/interface/function.rs +++ b/uniffi_bindgen/src/interface/function.rs @@ -269,6 +269,9 @@ pub trait Callable { } } + // Scaffolding function + fn ffi_func(&self) -> &FfiFunction; + // Quick way to get the rust future scaffolding function that corresponds to our return type. fn ffi_rust_future_poll(&self, ci: &ComponentInterface) -> String { @@ -312,6 +315,10 @@ impl Callable for Function { fn is_async(&self) -> bool { self.is_async } + + fn ffi_func(&self) -> &FfiFunction { + &self.ffi_func + } } // Needed because Rinja likes to add extra refs to variables @@ -332,6 +339,10 @@ impl Callable for &T { (*self).is_async() } + fn ffi_func(&self) -> &FfiFunction { + (*self).ffi_func() + } + fn takes_self(&self) -> bool { (*self).takes_self() } diff --git a/uniffi_bindgen/src/interface/object.rs b/uniffi_bindgen/src/interface/object.rs index 2848885ab..7a1fd9e28 100644 --- a/uniffi_bindgen/src/interface/object.rs +++ b/uniffi_bindgen/src/interface/object.rs @@ -729,6 +729,10 @@ impl Callable for Constructor { fn is_async(&self) -> bool { self.is_async } + + fn ffi_func(&self) -> &FfiFunction { + &self.ffi_func + } } impl Callable for Method { @@ -751,6 +755,10 @@ impl Callable for Method { fn takes_self(&self) -> bool { true } + + fn ffi_func(&self) -> &FfiFunction { + &self.ffi_func + } } #[cfg(test)]