use std::collections::HashMap;
use syn::Ident;
use crate::conversion::api::ApiName;
use crate::types::Namespace;
use crate::{conversion::api::Api, known_types::known_types, types::QualifiedName};
use super::fun::FnPhase;
pub(crate) fn append_ctype_information(apis: &mut Vec<Api<FnPhase>>) {
let ctypes: HashMap<Ident, QualifiedName> = apis
.iter()
.map(|api| api.deps())
.flatten()
.filter(|ty| known_types().is_ctype(ty))
.map(|ty| (ty.get_final_ident(), ty.clone()))
.collect();
for (id, typename) in ctypes {
apis.push(Api::CType {
name: ApiName::new(&Namespace::new(), id),
typename,
});
}
}