From df682c483d92610b41d2ac3c5b5d4b90025d2651 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Tue, 9 Sep 2014 15:19:09 +0200 Subject: [PATCH] Bug 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, calculate parent prototype names in one place. r=bz. --HG-- extra : rebase_source : c3ffbba076fed4ef2157ca8bb430a0d9cbaedd61 --- dom/bindings/Codegen.py | 20 +++++++------------- dom/bindings/Configuration.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 7372668b941..d315227686a 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -298,9 +298,9 @@ class CGNativePropertyHooks(CGThing): prototypeID += self.descriptor.name else: prototypeID += "_ID_Count" - parent = self.descriptor.interface.parent - parentHooks = (toBindingNamespace(parent.identifier.name) + "::sNativePropertyHooks" - if parent else 'nullptr') + parentProtoName = self.descriptor.parentPrototypeName + parentHooks = (toBindingNamespace(parentProtoName) + "::sNativePropertyHooks" + if parentProtoName else 'nullptr') return fill( """ @@ -327,10 +327,7 @@ def NativePropertyHooks(descriptor): def DOMClass(descriptor): - def make_name(d): - return "%s%s" % (d.interface.identifier.name, '_workers' if d.workers else '') - - protoList = ['prototypes::id::' + make_name(descriptor.getDescriptor(proto)) for proto in descriptor.prototypeChain] + protoList = ['prototypes::id::' + proto for proto in descriptor.prototypeNameChain] # Pad out the list to the right length with _ID_Count so we # guarantee that all the lists are the same length. _ID_Count # is never the ID of any prototype, so it's safe to use as @@ -2582,7 +2579,8 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): self.properties = properties def definition_body(self): - if len(self.descriptor.prototypeChain) == 1: + parentProtoName = self.descriptor.parentPrototypeName + if parentProtoName is None: parentProtoType = "Rooted" if self.descriptor.interface.getExtendedAttribute("ArrayClass"): getParentProto = "aCx, JS_GetArrayPrototype(aCx, aGlobal)" @@ -2591,13 +2589,9 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): else: getParentProto = "aCx, JS_GetObjectPrototype(aCx, aGlobal)" else: - parentProtoName = self.descriptor.prototypeChain[-2] - parentDesc = self.descriptor.getDescriptor(parentProtoName) - if parentDesc.workers: - parentProtoName += '_workers' + parentProtoType = "Handle" getParentProto = ("%s::GetProtoObject(aCx, aGlobal)" % toBindingNamespace(parentProtoName)) - parentProtoType = "Handle" parentWithInterfaceObject = self.descriptor.interface.parent while (parentWithInterfaceObject and diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index 0722ce29bb7..7fd5f0c54d3 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -513,6 +513,16 @@ class Descriptor(DescriptorProvider): def binaryNameFor(self, name): return self._binaryNames.get(name, name) + @property + def prototypeNameChain(self): + return map(lambda p: self.getDescriptor(p).name, self.prototypeChain) + + @property + def parentPrototypeName(self): + if len(self.prototypeChain) == 1: + return None + return self.getDescriptor(self.prototypeChain[-2]).name + def hasInterfaceOrInterfacePrototypeObject(self): # Forward-declared interfaces don't need either interface object or