Skip to content

Commit

Permalink
Added Traceable for PropertyDescriptor (#430)
Browse files Browse the repository at this point in the history
* Added Traceable for PropertyDescriptor

* Fixed Traceable for PropertyDescriptor

* Fixed Descriptor Field Access

* Formatted Code
  • Loading branch information
Redfire75369 authored Dec 3, 2023
1 parent c0ce4a8 commit c7fb1b8
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion mozjs/src/gc/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use crate::glue::{
CallBigIntTracer, CallFunctionTracer, CallIdTracer, CallObjectTracer, CallScriptTracer,
CallStringTracer, CallSymbolTracer, CallValueTracer,
};
use crate::jsapi::{jsid, JSFunction, JSObject, JSScript, JSString, JSTracer, Value};
use crate::jsapi::{
jsid, JSFunction, JSObject, JSScript, JSString, JSTracer, PropertyDescriptor, Value,
};
use mozjs_sys::jsapi::js::TraceValueArray;
use mozjs_sys::jsapi::JS::{BigInt, JobQueue, Symbol};
use mozjs_sys::jsgc::{Heap, ValueArray};
Expand Down Expand Up @@ -115,6 +117,32 @@ unsafe impl Traceable for Heap<jsid> {
}
}

unsafe impl Traceable for Heap<PropertyDescriptor> {
#[inline]
unsafe fn trace(&self, trc: *mut JSTracer) {
let desc = &*self.get_unsafe();
CallValueTracer(
trc,
&desc.value_ as *const _ as *mut Heap<Value>,
c_str!("PropertyDescriptor::value"),
);
if !desc.getter_.is_null() {
CallObjectTracer(
trc,
&desc.getter_ as *const _ as *mut Heap<*mut JSObject>,
c_str!("PropertyDescriptor::getter"),
);
}
if !desc.setter_.is_null() {
CallObjectTracer(
trc,
&desc.setter_ as *const _ as *mut Heap<*mut JSObject>,
c_str!("PropertyDescriptor::setter"),
);
}
}
}

unsafe impl<T: Traceable> Traceable for Rc<T> {
#[inline]
unsafe fn trace(&self, trc: *mut JSTracer) {
Expand Down

0 comments on commit c7fb1b8

Please sign in to comment.