use cxxrtl::{CxxrtlHandle, _cxxrtl_toplevel};

pub fn get_handle(lib: &str) -> CxxrtlHandle {
    unsafe {
        let lib = libloading::Library::new(lib).unwrap();
        let func: libloading::Symbol<unsafe extern "C" fn() -> *mut _cxxrtl_toplevel> =
            lib.get(b"cxxrtl_design_create").unwrap();
        let top = func();
        std::mem::forget(lib);
        CxxrtlHandle::new(top)
    }
}