use crate::engine::{FnAny, IteratorFn};
use crate::stdlib::{any::TypeId, boxed::Box, collections::HashMap, rc::Rc, sync::Arc};
mod arithmetic;
mod array_basic;
mod iter_basic;
mod logic;
mod map_basic;
mod math_basic;
mod pkg_core;
mod pkg_std;
mod string_basic;
mod string_more;
mod time_basic;
mod utils;
pub use arithmetic::ArithmeticPackage;
#[cfg(not(feature = "no_index"))]
pub use array_basic::BasicArrayPackage;
pub use iter_basic::BasicIteratorPackage;
pub use logic::LogicPackage;
#[cfg(not(feature = "no_object"))]
pub use map_basic::BasicMapPackage;
pub use math_basic::BasicMathPackage;
pub use pkg_core::CorePackage;
pub use pkg_std::StandardPackage;
pub use string_basic::BasicStringPackage;
pub use string_more::MoreStringPackage;
#[cfg(not(feature = "no_std"))]
pub use time_basic::BasicTimePackage;
pub use utils::*;
pub trait Package {
fn new() -> Self;
fn init(lib: &mut PackageStore);
fn get(&self) -> PackageLibrary;
}
pub struct PackageStore {
pub functions: HashMap<u64, Box<FnAny>>,
pub type_iterators: HashMap<TypeId, Box<IteratorFn>>,
}
impl PackageStore {
pub fn new() -> Self {
Self {
functions: HashMap::new(),
type_iterators: HashMap::new(),
}
}
}
#[cfg(not(feature = "sync"))]
pub type PackageLibrary = Rc<PackageStore>;
#[cfg(feature = "sync")]
pub type PackageLibrary = Arc<PackageStore>;