akern-gkgoat-fork/kernel/src/interp/objects.rs

36 lines
731 B
Rust

use alloc::{vec, vec::Vec};
use spin::{Lazy, Mutex};
pub enum Object{
Raw(xml::XMLElement)
}
pub fn dump(o: Object) -> xml::XMLElement{
match o{
Object::Raw(x) => {
let mut e = xml::XMLElement::new("akern-internal-raw");
e.children.push(x);
return e;
}
}
}
pub fn rest(x: xml::XMLElement) -> Option<Object>{
let s: &str = &x.name;
match s{
"akern-internal-raw" => {
let f = x.children.get(0)?;
return Some(Object::Raw(f.clone()))
}
_ => None
}
}
pub type HostObjects = Vec<Option<Object>>;
pub const OBJECTS: Lazy<Mutex<HostObjects>> = Lazy::new(|| {
let mut obj = vec![];
Mutex::new(obj)
});