mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add AsHandleValue trait to Heap<Value> and make Heap values rooted (#38024)
Encapsulates the unsafe conversion from Heap<Value> to HandleValue<'a>, and reducing repetitive unsafe code at call. fix #37258
This commit is contained in:
parent
9416251cab
commit
04ec710e60
17 changed files with 204 additions and 146 deletions
|
@ -88,16 +88,15 @@ fn gen_type_error(global: &GlobalScope, string: String, can_gc: CanGc) -> Rethro
|
|||
}
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
pub(crate) struct ModuleObject(Box<Heap<*mut JSObject>>);
|
||||
pub(crate) struct ModuleObject(RootedTraceableBox<Heap<*mut JSObject>>);
|
||||
|
||||
impl ModuleObject {
|
||||
fn new(obj: RustHandleObject) -> ModuleObject {
|
||||
ModuleObject(Heap::boxed(obj.get()))
|
||||
ModuleObject(RootedTraceableBox::from_box(Heap::boxed(obj.get())))
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn handle(&self) -> HandleObject {
|
||||
unsafe { self.0.handle() }
|
||||
self.0.handle().into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue