diff options
author | Samson <16504129+sagudev@users.noreply.github.com> | 2023-10-04 13:29:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-04 11:29:54 +0000 |
commit | 8436002383fc17a0572e02aa5a1409505bb10e91 (patch) | |
tree | 4090d4eb0c7490d24a429475bd3807b2208978fb /components/script/dom/bindings/codegen | |
parent | a31e2ea57627bf5cdf8de81c6646d4f2fe25092b (diff) | |
download | servo-8436002383fc17a0572e02aa5a1409505bb10e91.tar.gz servo-8436002383fc17a0572e02aa5a1409505bb10e91.zip |
Support Namespace const in webidl (#30492)
* Add TestNS with const
* Implement namespace const in codegen
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index eff03384447..471c152040b 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3281,19 +3281,24 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): methods = self.properties.static_methods.variableName() else: methods = "&[]" - return CGGeneric("""\ -rooted!(in(*cx) let proto = %(proto)s); + if self.descriptor.interface.hasConstants(): + constants = "sConstants" + else: + constants = "&[]" + id = MakeNativeName(name) + return CGGeneric(f"""\ +rooted!(in(*cx) let proto = {proto}); assert!(!proto.is_null()); rooted!(in(*cx) let mut namespace = ptr::null_mut::<JSObject>()); create_namespace_object(cx, global, proto.handle(), &NAMESPACE_OBJECT_CLASS, - %(methods)s, %(name)s, namespace.handle_mut()); + {methods}, {constants}, {str_to_const_array(name)}, namespace.handle_mut()); assert!(!namespace.is_null()); -assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null()); -(*cache)[PrototypeList::Constructor::%(id)s as usize] = namespace.get(); -<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::%(id)s as isize), +assert!((*cache)[PrototypeList::Constructor::{id} as usize].is_null()); +(*cache)[PrototypeList::Constructor::{id} as usize] = namespace.get(); +<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::{id} as isize), ptr::null_mut(), namespace.get()); -""" % {"id": MakeNativeName(name), "methods": methods, "name": str_to_const_array(name), "proto": proto}) +""") if self.descriptor.interface.isCallback(): assert not self.descriptor.interface.ctor() and self.descriptor.interface.hasConstants() return CGGeneric("""\ |