wdext 0.1.0

A DbgEng wrapper framework
// SPDX-FileCopyrightText: 2026 takubokudori
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{
    DbgModelResult, b2w, dbgeng::WinResult, dbgmodel::ModelObject,
    error::DbgModelError, impl_debug_interface,
};
use windows::Win32::{
    Foundation::E_BOUNDS,
    System::Diagnostics::Debug::Extensions::{IRawEnumerator, SymbolKind},
};
use windy::WString;

impl_debug_interface!(RawEnumerator, RawEnumeratorRef, IRawEnumerator);

pub type RawData = (WString, SymbolKind, ModelObject);

impl RawEnumerator {
    pub fn reset(&self) -> WinResult<()> { unsafe { self.0.Reset() } }

    pub fn get_next(&self) -> Option<DbgModelResult<RawData>> {
        let mut kind = SymbolKind::default();
        let mut value = None;
        unsafe {
            let mut name = std::mem::zeroed();
            match self.0.GetNext(
                Some(&mut name),
                Some(&mut kind),
                Some(&mut value),
            ) {
                Ok(_) => Some(Ok((b2w!(name), kind, value.unwrap().into()))),
                Err(e) if e.code() == E_BOUNDS => None,
                Err(e) => Some(Err(DbgModelError::new(e, value))),
            }
        }
    }
}