use crate::RawHandle;
pub struct VpiIter(Option<RawHandle>);
impl VpiIter {
pub unsafe fn new(t: crate::vpi_user::PLI_INT32, handle: crate::vpi_user::vpiHandle) -> Self {
let args_iter = crate::vpi_user::vpi_iterate(t, handle);
Self(RawHandle::new(args_iter))
}
}
impl Iterator for VpiIter {
type Item = crate::RawHandle;
fn next(&mut self) -> Option<Self::Item> {
crate::RawHandle::new(unsafe { crate::vpi_user::vpi_scan(self.0?.as_ptr()) })
}
}
impl Drop for VpiIter {
fn drop(&mut self) {
if let Some(p) = self.0 {
unsafe { crate::vpi_user::vpi_free_object(p.as_ptr()) };
}
}
}