yutannihilation / savvy

A simple R extension interface using Rust

Home Page:https://yutannihilation.github.io/savvy/guide/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A convention for initialization function on loading the DLL

yutannihilation opened this issue · comments

Related to #206 and #177

If such function exists in Rust code:

#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn savvy_init_foo(dll_info: *mut DllInfo) {
  ...
}

savvy-cli update should generate

// NEW
void run_all_savvy_initialization(DllInfo *dll) {
  savvy_init_foo(dll);
  ...
}


void R_init_savvyPkg(DllInfo *dll) {
  run_all_savvy_initialization(dll);  // NEW
  R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
  R_useDynamicSymbols(dll, FALSE);
}