simplified object enum, added xml conversion
This commit is contained in:
parent
4c2e52c9bb
commit
4f1e82e70a
|
@ -34,7 +34,7 @@ pub fn host_register_idt_handler(
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::interp::{Handle, objects::{Object, ObjectHeader, ObjectSpecial}};
|
use crate::interp::{objects::Object, Handle};
|
||||||
|
|
||||||
pub fn host_make_object(
|
pub fn host_make_object(
|
||||||
mut caller: Caller<'_, HostState>,
|
mut caller: Caller<'_, HostState>,
|
||||||
|
@ -59,12 +59,7 @@ pub fn host_make_object(
|
||||||
let hand = Handle::new(olock.len());
|
let hand = Handle::new(olock.len());
|
||||||
let obj = xml::XMLElement::new(name);
|
let obj = xml::XMLElement::new(name);
|
||||||
|
|
||||||
olock.push(Some(Object{
|
olock.push(Some(Object::Raw(obj)));
|
||||||
header: ObjectHeader{
|
|
||||||
|
|
||||||
},
|
|
||||||
special: ObjectSpecial::Xml(obj)
|
|
||||||
}));
|
|
||||||
caller.data_mut().handles.push(hand);
|
caller.data_mut().handles.push(hand);
|
||||||
// hand.into()
|
// hand.into()
|
||||||
hand.as_u64().try_into().unwrap()
|
hand.as_u64().try_into().unwrap()
|
||||||
|
|
|
@ -2,15 +2,29 @@ use alloc::{vec, vec::Vec};
|
||||||
|
|
||||||
use spin::{Lazy, Mutex};
|
use spin::{Lazy, Mutex};
|
||||||
|
|
||||||
pub struct Object {
|
pub enum Object{
|
||||||
pub header: ObjectHeader,
|
Raw(xml::XMLElement)
|
||||||
pub special: ObjectSpecial,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ObjectHeader {}
|
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 enum ObjectSpecial {
|
pub fn rest(x: xml::XMLElement) -> Option<Object>{
|
||||||
Xml(xml::XMLElement),
|
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 type HostObjects = Vec<Option<Object>>;
|
||||||
|
|
Loading…
Reference in a new issue