use std::cell::RefCell;
use super::ForeignTypeConfig;
pub use macroforge_ts_syn::import_registry::{
GeneratedImport, ImportRegistry, SourceImport, clear_registry, install_registry, take_registry,
with_registry, with_registry_mut,
};
thread_local! {
static FOREIGN_TYPES: RefCell<Vec<ForeignTypeConfig>> = const { RefCell::new(Vec::new()) };
}
pub fn with_foreign_types<R>(f: impl FnOnce(&[ForeignTypeConfig]) -> R) -> R {
FOREIGN_TYPES.with(|ft| f(&ft.borrow()))
}
pub fn with_foreign_types_mut<R>(f: impl FnOnce(&mut Vec<ForeignTypeConfig>) -> R) -> R {
FOREIGN_TYPES.with(|ft| f(&mut ft.borrow_mut()))
}
pub fn set_foreign_types(types: Vec<ForeignTypeConfig>) {
FOREIGN_TYPES.with(|ft| {
*ft.borrow_mut() = types;
});
}
pub fn clear_foreign_types() {
FOREIGN_TYPES.with(|ft| {
ft.borrow_mut().clear();
});
}