Skip to content

Commit c7fb1b8

Browse files
authored
Added Traceable for PropertyDescriptor (#430)
* Added Traceable for PropertyDescriptor * Fixed Traceable for PropertyDescriptor * Fixed Descriptor Field Access * Formatted Code
1 parent c0ce4a8 commit c7fb1b8

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

mozjs/src/gc/trace.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use crate::glue::{
33
CallBigIntTracer, CallFunctionTracer, CallIdTracer, CallObjectTracer, CallScriptTracer,
44
CallStringTracer, CallSymbolTracer, CallValueTracer,
55
};
6-
use crate::jsapi::{jsid, JSFunction, JSObject, JSScript, JSString, JSTracer, Value};
6+
use crate::jsapi::{
7+
jsid, JSFunction, JSObject, JSScript, JSString, JSTracer, PropertyDescriptor, Value,
8+
};
79
use mozjs_sys::jsapi::js::TraceValueArray;
810
use mozjs_sys::jsapi::JS::{BigInt, JobQueue, Symbol};
911
use mozjs_sys::jsgc::{Heap, ValueArray};
@@ -115,6 +117,32 @@ unsafe impl Traceable for Heap<jsid> {
115117
}
116118
}
117119

120+
unsafe impl Traceable for Heap<PropertyDescriptor> {
121+
#[inline]
122+
unsafe fn trace(&self, trc: *mut JSTracer) {
123+
let desc = &*self.get_unsafe();
124+
CallValueTracer(
125+
trc,
126+
&desc.value_ as *const _ as *mut Heap<Value>,
127+
c_str!("PropertyDescriptor::value"),
128+
);
129+
if !desc.getter_.is_null() {
130+
CallObjectTracer(
131+
trc,
132+
&desc.getter_ as *const _ as *mut Heap<*mut JSObject>,
133+
c_str!("PropertyDescriptor::getter"),
134+
);
135+
}
136+
if !desc.setter_.is_null() {
137+
CallObjectTracer(
138+
trc,
139+
&desc.setter_ as *const _ as *mut Heap<*mut JSObject>,
140+
c_str!("PropertyDescriptor::setter"),
141+
);
142+
}
143+
}
144+
}
145+
118146
unsafe impl<T: Traceable> Traceable for Rc<T> {
119147
#[inline]
120148
unsafe fn trace(&self, trc: *mut JSTracer) {

0 commit comments

Comments
 (0)