forked from AbleOS/ableos
29 lines
504 B
Rust
29 lines
504 B
Rust
use crate::sys;
|
|
|
|
pub struct Object{
|
|
pub id: i64
|
|
}
|
|
|
|
impl Drop for Object{
|
|
fn drop(&mut self) {
|
|
unsafe{
|
|
sys::drop_object(self.id);
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Object{
|
|
fn to_global(self) -> [u64; 4]{
|
|
let b = unsafe {
|
|
sys::make_global(self.id).into()
|
|
};
|
|
core::mem::forget(self);
|
|
return b;
|
|
}
|
|
|
|
fn from_global(a: [u64; 4]) -> Object{
|
|
return Object{id: unsafe {
|
|
sys::take_global(a.into())
|
|
}};
|
|
}
|
|
} |