mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move more foundational types to script_bindings (#35280)
* script: Move DOMClass to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move DOMJSClass and get_dom_class to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move Castable/DerivedFrom/IDLInterface to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
eaaad757e8
commit
c0cef69108
16 changed files with 291 additions and 207 deletions
48
components/script_bindings/utils.rs
Normal file
48
components/script_bindings/utils.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 std::os::raw::c_void;
|
||||
|
||||
use malloc_size_of::MallocSizeOfOps;
|
||||
|
||||
use crate::codegen::Globals::Globals;
|
||||
use crate::codegen::InheritTypes::TopTypeId;
|
||||
use crate::codegen::PrototypeList::{self, MAX_PROTO_CHAIN_LENGTH};
|
||||
|
||||
/// The struct that holds inheritance information for DOM object reflectors.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct DOMClass {
|
||||
/// A list of interfaces that this object implements, in order of decreasing
|
||||
/// derivedness.
|
||||
pub interface_chain: [PrototypeList::ID; MAX_PROTO_CHAIN_LENGTH],
|
||||
|
||||
/// The last valid index of `interface_chain`.
|
||||
pub depth: u8,
|
||||
|
||||
/// The type ID of that interface.
|
||||
pub type_id: TopTypeId,
|
||||
|
||||
/// The MallocSizeOf function wrapper for that interface.
|
||||
pub malloc_size_of: unsafe fn(ops: &mut MallocSizeOfOps, *const c_void) -> usize,
|
||||
|
||||
/// The `Globals` flag for this global interface, if any.
|
||||
pub global: Globals,
|
||||
}
|
||||
unsafe impl Sync for DOMClass {}
|
||||
|
||||
/// The JSClass used for DOM object reflectors.
|
||||
#[derive(Copy)]
|
||||
#[repr(C)]
|
||||
pub struct DOMJSClass {
|
||||
/// The actual JSClass.
|
||||
pub base: js::jsapi::JSClass,
|
||||
/// Associated data for DOM object reflectors.
|
||||
pub dom_class: DOMClass,
|
||||
}
|
||||
impl Clone for DOMJSClass {
|
||||
fn clone(&self) -> DOMJSClass {
|
||||
*self
|
||||
}
|
||||
}
|
||||
unsafe impl Sync for DOMJSClass {}
|
Loading…
Add table
Add a link
Reference in a new issue