Skip to content

Commit

Permalink
Inline extern function calls in impl_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
equation314 committed Jan 18, 2025
1 parent c999c6f commit d3c88df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ struct HelloIfImpl;

// #[impl_interface]
impl HelloIf for HelloIfImpl {
#[inline]
fn hello(&self, name: &str, id: usize) -> String {
{
#[inline]
#[export_name = "__HelloIf_hello"]
extern "Rust" fn __HelloIf_hello(name: &str, id: usize) -> String {
let _impl: HelloIfImpl = HelloIfImpl;
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn def_interface(attr: TokenStream, item: TokenStream) -> TokenStream {
if !attr.is_empty() {
return compiler_error(Error::new(
Span::call_site(),
"expect an empty attribute: `#[crate_interface_def]`",
"expect an empty attribute: `#[def_interface]`",
));
}

Expand Down Expand Up @@ -89,7 +89,7 @@ pub fn impl_interface(attr: TokenStream, item: TokenStream) -> TokenStream {
if !attr.is_empty() {
return compiler_error(Error::new(
Span::call_site(),
"expect an empty attribute: `#[crate_interface_impl]`",
"expect an empty attribute: `#[impl_interface]`",
));
}

Expand Down Expand Up @@ -138,11 +138,13 @@ pub fn impl_interface(attr: TokenStream, item: TokenStream) -> TokenStream {
};

let item = quote! {
#[inline]
#(#attrs)*
#vis
#sig
{
{
#[inline]
#[export_name = #extern_fn_name]
extern "Rust" #new_sig {
#call_impl
Expand Down

0 comments on commit d3c88df

Please sign in to comment.