diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-07 09:04:15 -0500 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-07 09:04:15 -0500 |
commit | f56848a0e8a9137f128088d1dd0f86e11fad841a (patch) | |
tree | 06023fac8cec8e18803041779bf28624f2bb722f /components/script/dom/bindings/codegen | |
parent | 6be0494287455c5c30ef6f898b511b4348efbeef (diff) | |
parent | 35298039752107e8696d1bb2be68270b572ae58a (diff) | |
download | servo-f56848a0e8a9137f128088d1dd0f86e11fad841a.tar.gz servo-f56848a0e8a9137f128088d1dd0f86e11fad841a.zip |
Auto merge of #11620 - nox:unscopable, r=Ms2ger
Implement [Unscopable] (fixes #11583)
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11620)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 0caeddb3dfa..c356a7d066c 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2494,12 +2494,13 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): properties should be a PropertyArrays instance. """ - def __init__(self, descriptor, properties): + def __init__(self, descriptor, properties, haveUnscopables): args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'global'), Argument('*mut ProtoOrIfaceArray', 'cache')] CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', 'void', args, unsafe=True) self.properties = properties + self.haveUnscopables = haveUnscopables def definition_body(self): name = self.descriptor.interface.identifier.name @@ -2530,7 +2531,10 @@ let mut prototype_proto = RootedObject::new(cx, ptr::null_mut()); %s; assert!(!prototype_proto.ptr.is_null());""" % getPrototypeProto)] - properties = {"id": name} + properties = { + "id": name, + "unscopables": "unscopable_names" if self.haveUnscopables else "&[]" + } for arrayName in self.properties.arrayNames(): array = getattr(self.properties, arrayName) if array.length(): @@ -2546,6 +2550,7 @@ create_interface_prototype_object(cx, %(methods)s, %(attrs)s, %(consts)s, + %(unscopables)s, prototype.handle_mut()); assert!(!prototype.ptr.is_null()); assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null()); @@ -5058,9 +5063,13 @@ class CGDescriptor(CGThing): descriptor.shouldHaveGetConstructorObjectMethod()): cgThings.append(CGGetConstructorObjectMethod(descriptor)) + unscopableNames = [] for m in descriptor.interface.members: if (m.isMethod() and (not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])): + if m.getExtendedAttribute("Unscopable"): + assert not m.isStatic() + unscopableNames.append(m.identifier.name) if m.isStatic(): assert descriptor.interface.hasInterfaceObject() cgThings.append(CGStaticMethod(descriptor, m)) @@ -5072,7 +5081,9 @@ class CGDescriptor(CGThing): raise TypeError("Stringifier attributes not supported yet. " "See https://github.com/servo/servo/issues/7590\n" "%s" % m.location) - + if m.getExtendedAttribute("Unscopable"): + assert not m.isStatic() + unscopableNames.append(m.identifier.name) if m.isStatic(): assert descriptor.interface.hasInterfaceObject() cgThings.append(CGStaticGetter(descriptor, m)) @@ -5106,10 +5117,6 @@ class CGDescriptor(CGThing): if not descriptor.interface.isCallback(): cgThings.append(CGPrototypeJSClass(descriptor)) - properties = PropertyArrays(descriptor) - cgThings.append(CGGeneric(str(properties))) - cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties)) - # If there are no constant members, don't make a module for constants constMembers = [m for m in descriptor.interface.members if m.isConst()] if constMembers: @@ -5156,13 +5163,25 @@ class CGDescriptor(CGThing): cgThings.append(CGWrapMethod(descriptor)) + haveUnscopables = False if not descriptor.interface.isCallback(): + if unscopableNames: + haveUnscopables = True + cgThings.append( + CGList([CGGeneric("const unscopable_names: &'static [&'static [u8]] = &["), + CGIndenter(CGList([CGGeneric(str_to_const_array(name)) for + name in unscopableNames], ",\n")), + CGGeneric("];\n")], "\n")) if descriptor.concrete or descriptor.hasDescendants(): cgThings.append(CGIDLInterface(descriptor)) cgThings.append(CGInterfaceTrait(descriptor)) if descriptor.weakReferenceable: cgThings.append(CGWeakReferenceableTrait(descriptor)) + properties = PropertyArrays(descriptor) + cgThings.append(CGGeneric(str(properties))) + cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties, haveUnscopables)) + cgThings = CGList(cgThings, "\n") # self.cgRoot = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name), # cgThings), |