Support Namespace const in webidl (#30492)

* Add TestNS with const

* Implement namespace const in codegen
This commit is contained in:
Samson 2023-10-04 13:29:54 +02:00 committed by GitHub
parent a31e2ea576
commit 8436002383
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 74 additions and 8 deletions

View file

@ -9,6 +9,7 @@ use std::ptr;
use js::jsapi::{JSClass, JSFunctionSpec};
use js::rust::{HandleObject, MutableHandleObject};
use super::constant::ConstantSpec;
use crate::dom::bindings::guard::Guard;
use crate::dom::bindings::interface::{create_object, define_on_global_object};
use crate::script_runtime::JSContext;
@ -40,9 +41,10 @@ pub fn create_namespace_object(
proto: HandleObject,
class: &'static NamespaceObjectClass,
methods: &[Guard<&'static [JSFunctionSpec]>],
constants: &[Guard<&'static [ConstantSpec]>],
name: &[u8],
rval: MutableHandleObject,
) {
create_object(cx, global, proto, &class.0, methods, &[], &[], rval);
create_object(cx, global, proto, &class.0, methods, &[], constants, rval);
define_on_global_object(cx, global, name, rval.handle());
}