mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move more bindings code to script_bindings (#35578)
* Move JSContext wrapper to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move webidl constant bindings to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move CanGc to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move Dom<T> and Root<T> types to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Extra docs for new traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
54286229ea
commit
35f21e426b
23 changed files with 788 additions and 641 deletions
|
@ -2,8 +2,37 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use js::glue::CallObjectTracer;
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
||||
|
||||
use crate::reflector::Reflector;
|
||||
use crate::str::{DOMString, USVString};
|
||||
|
||||
/// Trace the `JSObject` held by `reflector`.
|
||||
///
|
||||
/// # Safety
|
||||
/// tracer must point to a valid, non-null JS tracer.
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub unsafe fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
|
||||
trace!("tracing reflector {}", description);
|
||||
trace_object(tracer, description, reflector.rootable())
|
||||
}
|
||||
|
||||
/// Trace a `JSObject`.
|
||||
///
|
||||
/// # Safety
|
||||
/// tracer must point to a valid, non-null JS tracer.
|
||||
pub unsafe fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JSObject>) {
|
||||
unsafe {
|
||||
trace!("tracing {}", description);
|
||||
CallObjectTracer(
|
||||
tracer,
|
||||
obj.ptr.get() as *mut _,
|
||||
GCTraceKindToAscii(TraceKind::Object),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// For use on non-jsmanaged types
|
||||
/// Use #[derive(JSTraceable)] on JS managed types
|
||||
macro_rules! unsafe_no_jsmanaged_fields(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue