aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/namespace.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2025-04-04 02:45:08 -0400
committerGitHub <noreply@github.com>2025-04-04 06:45:08 +0000
commitb4079b3ff33a3f7e2b35ac3aacc4467f8da42242 (patch)
treeaf6ae87af10c1383a3a3fcdb28b1d2544bc2fc45 /components/script/dom/bindings/namespace.rs
parent277c0b82dd4411798b461a4e3a782e7869ae5740 (diff)
downloadservo-b4079b3ff33a3f7e2b35ac3aacc4467f8da42242.tar.gz
servo-b4079b3ff33a3f7e2b35ac3aacc4467f8da42242.zip
Move generated bindings to script_bindings (#36323)
This is the final step of #1799, where the majority of the generated code for the JS bindings is now compiled as part of the script_bindings build step. The remaining pieces in script must live there because they refer to concrete DOM types; all code in script_bindings is generic over the [DomTypes](https://doc.servo.org/script/dom/bindings/codegen/DomTypes/trait.DomTypes.html) trait. My testing with incremental builds shows me a 12 second reduction in build times on my 2024 M4 Macbook Pro when modifying code in the script crate after these changes. Before this PR those changes took 20 seconds to rebuild Servo, and now they take 8 seconds. Testing: Existing WPT tests ensure no regressions. Fixes: #1799 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/bindings/namespace.rs')
-rw-r--r--components/script/dom/bindings/namespace.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/components/script/dom/bindings/namespace.rs b/components/script/dom/bindings/namespace.rs
deleted file mode 100644
index ad0a5801519..00000000000
--- a/components/script/dom/bindings/namespace.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-/* 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/. */
-
-//! Machinery to initialise namespace objects.
-
-use std::ffi::CStr;
-use std::ptr;
-
-use js::jsapi::{JSClass, JSFunctionSpec};
-use js::rust::{HandleObject, MutableHandleObject};
-use script_bindings::constant::ConstantSpec;
-
-use crate::DomTypes;
-use crate::dom::bindings::guard::Guard;
-use crate::dom::bindings::interface::{create_object, define_on_global_object};
-use crate::script_runtime::JSContext;
-
-/// The class of a namespace object.
-#[derive(Clone, Copy)]
-pub(crate) struct NamespaceObjectClass(JSClass);
-
-unsafe impl Sync for NamespaceObjectClass {}
-
-impl NamespaceObjectClass {
- /// Create a new `NamespaceObjectClass` structure.
- pub(crate) const unsafe fn new(name: &'static CStr) -> Self {
- NamespaceObjectClass(JSClass {
- name: name.as_ptr(),
- flags: 0,
- cOps: 0 as *mut _,
- spec: ptr::null(),
- ext: ptr::null(),
- oOps: ptr::null(),
- })
- }
-}
-
-/// Create a new namespace object.
-#[allow(clippy::too_many_arguments)]
-pub(crate) fn create_namespace_object<D: DomTypes>(
- cx: JSContext,
- global: HandleObject,
- proto: HandleObject,
- class: &'static NamespaceObjectClass,
- methods: &[Guard<&'static [JSFunctionSpec]>],
- constants: &[Guard<&'static [ConstantSpec]>],
- name: &CStr,
- mut rval: MutableHandleObject,
-) {
- create_object::<D>(
- cx,
- global,
- proto,
- &class.0,
- methods,
- &[],
- constants,
- rval.reborrow(),
- );
- define_on_global_object(cx, global, name, rval.handle());
-}