Skip to content

Commit

Permalink
refactor: Rename rivets:initalize!() to rivets:finalize!()
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Aug 12, 2024
1 parent fb8e6e8 commit b2c6467
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions rivets-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ pub fn detour(attr: TokenStream, item: TokenStream) -> TokenStream {
result.into()
}

/// A procedural macro for initializing the rivets library.
/// A procedural macro for finalizing the rivets library.
/// This macro should be called once at the end of the `main.rs` file.
/// It will initialize the rivets library and inject all of the detours.
/// It will finalize the rivets library and inject all of the detours.
#[proc_macro]
pub fn initialize(_: TokenStream) -> TokenStream {
pub fn finalize(_: TokenStream) -> TokenStream {
let injects = unsafe { MANGLED_NAMES.clone() };
let injects = injects.iter().map(|(mangled_name, name)| {
let name = Ident::new(name, proc_macro2::Span::call_site());
Expand All @@ -185,7 +185,7 @@ pub fn initialize(_: TokenStream) -> TokenStream {

quote! {
#[rivets::abi_stable::sabi_extern_fn]
pub extern "C" fn rivets_initialize() -> #vec<rivets::RivetsHook> {
pub extern "C" fn rivets_finalize() -> #vec<rivets::RivetsHook> {
let mut hooks: #vec<rivets::RivetsHook> = #vec::new();
#(#injects)*
hooks
Expand Down
2 changes: 1 addition & 1 deletion rivets-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ pub struct RivetsHook {

#[repr(C)]
#[derive(StableAbi)]
pub struct RivetsInitializeABI {
pub struct RivetsFinalizeABI {
pub get_hooks: extern "C" fn() -> RVec<RivetsHook>,
}

0 comments on commit b2c6467

Please sign in to comment.