mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Replace hasInterfacePrototypeObject checks by isCallback checks in codegen.
Checking for callbacks directly makes it a lot clearer what's going on, and we don't intend to take hasConcreteDescendant into consideration. See also <https://bugzilla.mozilla.org/show_bug.cgi?id=1026720>.
This commit is contained in:
parent
3f17a49564
commit
ea3c2c243c
2 changed files with 48 additions and 63 deletions
|
@ -1788,7 +1788,7 @@ JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
||||||
|
|
||||||
class CGWrapMethod(CGAbstractMethod):
|
class CGWrapMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert descriptor.interface.hasInterfacePrototypeObject()
|
assert not descriptor.interface.isCallback()
|
||||||
if not descriptor.createGlobal:
|
if not descriptor.createGlobal:
|
||||||
args = [Argument('*mut JSContext', 'aCx'), Argument('&GlobalRef', 'aScope'),
|
args = [Argument('*mut JSContext', 'aCx'), Argument('&GlobalRef', 'aScope'),
|
||||||
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)]
|
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)]
|
||||||
|
@ -1920,6 +1920,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
properties should be a PropertyArrays instance.
|
properties should be a PropertyArrays instance.
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, properties):
|
def __init__(self, descriptor, properties):
|
||||||
|
assert not descriptor.interface.isCallback()
|
||||||
args = [Argument('*mut JSContext', 'aCx'), Argument('*mut JSObject', 'aGlobal'),
|
args = [Argument('*mut JSContext', 'aCx'), Argument('*mut JSObject', 'aGlobal'),
|
||||||
Argument('*mut JSObject', 'aReceiver')]
|
Argument('*mut JSObject', 'aReceiver')]
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', '*mut JSObject', args)
|
CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', '*mut JSObject', args)
|
||||||
|
@ -1933,12 +1934,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
getParentProto = ("%s::GetProtoObject(aCx, aGlobal, aReceiver)" %
|
getParentProto = ("%s::GetProtoObject(aCx, aGlobal, aReceiver)" %
|
||||||
toBindingNamespace(parentProtoName))
|
toBindingNamespace(parentProtoName))
|
||||||
|
|
||||||
needInterfaceObject = self.descriptor.interface.hasInterfaceObject()
|
|
||||||
needInterfacePrototypeObject = self.descriptor.interface.hasInterfacePrototypeObject()
|
|
||||||
|
|
||||||
# if we don't need to create anything, why are we generating this?
|
|
||||||
assert needInterfaceObject or needInterfacePrototypeObject
|
|
||||||
|
|
||||||
getParentProto = ("let parentProto: *mut JSObject = %s;\n"
|
getParentProto = ("let parentProto: *mut JSObject = %s;\n"
|
||||||
"assert!(parentProto.is_not_null());\n") % getParentProto
|
"assert!(parentProto.is_not_null());\n") % getParentProto
|
||||||
|
|
||||||
|
@ -1950,7 +1945,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
else:
|
else:
|
||||||
domClass = "ptr::null()"
|
domClass = "ptr::null()"
|
||||||
|
|
||||||
if needInterfaceObject:
|
if self.descriptor.interface.hasInterfaceObject():
|
||||||
if self.descriptor.interface.ctor():
|
if self.descriptor.interface.ctor():
|
||||||
constructHook = CONSTRUCT_HOOK_NAME
|
constructHook = CONSTRUCT_HOOK_NAME
|
||||||
constructArgs = methodLength(self.descriptor.interface.ctor())
|
constructArgs = methodLength(self.descriptor.interface.ctor())
|
||||||
|
@ -4049,17 +4044,15 @@ class CGDescriptor(CGThing):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
CGThing.__init__(self)
|
CGThing.__init__(self)
|
||||||
|
|
||||||
assert not descriptor.concrete or descriptor.interface.hasInterfacePrototypeObject()
|
assert not descriptor.interface.isCallback()
|
||||||
|
|
||||||
cgThings = []
|
cgThings = []
|
||||||
if descriptor.interface.hasInterfacePrototypeObject():
|
|
||||||
cgThings.append(CGGetProtoObjectMethod(descriptor))
|
cgThings.append(CGGetProtoObjectMethod(descriptor))
|
||||||
if descriptor.interface.hasInterfaceObject():
|
if descriptor.interface.hasInterfaceObject():
|
||||||
# https://github.com/mozilla/servo/issues/2665
|
# https://github.com/mozilla/servo/issues/2665
|
||||||
# cgThings.append(CGGetConstructorObjectMethod(descriptor))
|
# cgThings.append(CGGetConstructorObjectMethod(descriptor))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if descriptor.interface.hasInterfacePrototypeObject():
|
|
||||||
(hasMethod, hasGetter, hasLenientGetter,
|
(hasMethod, hasGetter, hasLenientGetter,
|
||||||
hasSetter, hasLenientSetter) = False, False, False, False, False
|
hasSetter, hasLenientSetter) = False, False, False, False, False
|
||||||
for m in descriptor.interface.members:
|
for m in descriptor.interface.members:
|
||||||
|
@ -4067,7 +4060,7 @@ class CGDescriptor(CGThing):
|
||||||
if m.isStatic():
|
if m.isStatic():
|
||||||
assert descriptor.interface.hasInterfaceObject()
|
assert descriptor.interface.hasInterfaceObject()
|
||||||
cgThings.append(CGStaticMethod(descriptor, m))
|
cgThings.append(CGStaticMethod(descriptor, m))
|
||||||
elif descriptor.interface.hasInterfacePrototypeObject():
|
else:
|
||||||
cgThings.append(CGSpecializedMethod(descriptor, m))
|
cgThings.append(CGSpecializedMethod(descriptor, m))
|
||||||
cgThings.append(CGMemberJITInfo(descriptor, m))
|
cgThings.append(CGMemberJITInfo(descriptor, m))
|
||||||
hasMethod = True
|
hasMethod = True
|
||||||
|
@ -4075,7 +4068,7 @@ class CGDescriptor(CGThing):
|
||||||
if m.isStatic():
|
if m.isStatic():
|
||||||
assert descriptor.interface.hasInterfaceObject()
|
assert descriptor.interface.hasInterfaceObject()
|
||||||
cgThings.append(CGStaticGetter(descriptor, m))
|
cgThings.append(CGStaticGetter(descriptor, m))
|
||||||
elif descriptor.interface.hasInterfacePrototypeObject():
|
else:
|
||||||
cgThings.append(CGSpecializedGetter(descriptor, m))
|
cgThings.append(CGSpecializedGetter(descriptor, m))
|
||||||
if m.hasLenientThis():
|
if m.hasLenientThis():
|
||||||
hasLenientGetter = True
|
hasLenientGetter = True
|
||||||
|
@ -4086,14 +4079,14 @@ class CGDescriptor(CGThing):
|
||||||
if m.isStatic():
|
if m.isStatic():
|
||||||
assert descriptor.interface.hasInterfaceObject()
|
assert descriptor.interface.hasInterfaceObject()
|
||||||
cgThings.append(CGStaticSetter(descriptor, m))
|
cgThings.append(CGStaticSetter(descriptor, m))
|
||||||
elif descriptor.interface.hasInterfacePrototypeObject():
|
else:
|
||||||
cgThings.append(CGSpecializedSetter(descriptor, m))
|
cgThings.append(CGSpecializedSetter(descriptor, m))
|
||||||
if m.hasLenientThis():
|
if m.hasLenientThis():
|
||||||
hasLenientSetter = True
|
hasLenientSetter = True
|
||||||
else:
|
else:
|
||||||
hasSetter = True
|
hasSetter = True
|
||||||
|
|
||||||
if not m.isStatic() and descriptor.interface.hasInterfacePrototypeObject():
|
if not m.isStatic():
|
||||||
cgThings.append(CGMemberJITInfo(descriptor, m))
|
cgThings.append(CGMemberJITInfo(descriptor, m))
|
||||||
if hasMethod:
|
if hasMethod:
|
||||||
cgThings.append(CGGenericMethod(descriptor))
|
cgThings.append(CGGenericMethod(descriptor))
|
||||||
|
@ -4114,7 +4107,6 @@ class CGDescriptor(CGThing):
|
||||||
cgThings.append(CGClassConstructHook(descriptor))
|
cgThings.append(CGClassConstructHook(descriptor))
|
||||||
cgThings.append(CGInterfaceObjectJSClass(descriptor))
|
cgThings.append(CGInterfaceObjectJSClass(descriptor))
|
||||||
|
|
||||||
if descriptor.interface.hasInterfacePrototypeObject():
|
|
||||||
cgThings.append(CGPrototypeJSClass(descriptor))
|
cgThings.append(CGPrototypeJSClass(descriptor))
|
||||||
|
|
||||||
properties = PropertyArrays(descriptor)
|
properties = PropertyArrays(descriptor)
|
||||||
|
@ -4415,7 +4407,7 @@ class CGBindingRoot(CGThing):
|
||||||
"""
|
"""
|
||||||
def __init__(self, config, prefix, webIDLFile):
|
def __init__(self, config, prefix, webIDLFile):
|
||||||
descriptors = config.getDescriptors(webIDLFile=webIDLFile,
|
descriptors = config.getDescriptors(webIDLFile=webIDLFile,
|
||||||
hasInterfaceOrInterfacePrototypeObject=True)
|
isCallback=False)
|
||||||
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
|
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
|
||||||
|
|
||||||
cgthings = []
|
cgthings = []
|
||||||
|
@ -5383,7 +5375,7 @@ class GlobalGenRoots():
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def PrototypeList(config):
|
def PrototypeList(config):
|
||||||
# Prototype ID enum.
|
# Prototype ID enum.
|
||||||
protos = [d.name for d in config.getDescriptors(hasInterfacePrototypeObject=True)]
|
protos = [d.name for d in config.getDescriptors(isCallback=False)]
|
||||||
proxies = [d.name for d in config.getDescriptors(proxy=True)]
|
proxies = [d.name for d in config.getDescriptors(proxy=True)]
|
||||||
|
|
||||||
return CGList([
|
return CGList([
|
||||||
|
|
|
@ -72,10 +72,6 @@ class Configuration:
|
||||||
getter = lambda x: x.interface.filename()
|
getter = lambda x: x.interface.filename()
|
||||||
elif key == 'hasInterfaceObject':
|
elif key == 'hasInterfaceObject':
|
||||||
getter = lambda x: x.interface.hasInterfaceObject()
|
getter = lambda x: x.interface.hasInterfaceObject()
|
||||||
elif key == 'hasInterfacePrototypeObject':
|
|
||||||
getter = lambda x: x.interface.hasInterfacePrototypeObject()
|
|
||||||
elif key == 'hasInterfaceOrInterfacePrototypeObject':
|
|
||||||
getter = lambda x: x.hasInterfaceOrInterfacePrototypeObject()
|
|
||||||
elif key == 'isCallback':
|
elif key == 'isCallback':
|
||||||
getter = lambda x: x.interface.isCallback()
|
getter = lambda x: x.interface.isCallback()
|
||||||
elif key == 'isJSImplemented':
|
elif key == 'isJSImplemented':
|
||||||
|
@ -258,9 +254,6 @@ class Descriptor(DescriptorProvider):
|
||||||
config.maxProtoChainLength = max(config.maxProtoChainLength,
|
config.maxProtoChainLength = max(config.maxProtoChainLength,
|
||||||
len(self.prototypeChain))
|
len(self.prototypeChain))
|
||||||
|
|
||||||
def hasInterfaceOrInterfacePrototypeObject(self):
|
|
||||||
return self.interface.hasInterfaceObject() or self.interface.hasInterfacePrototypeObject()
|
|
||||||
|
|
||||||
def getExtendedAttributes(self, member, getter=False, setter=False):
|
def getExtendedAttributes(self, member, getter=False, setter=False):
|
||||||
def maybeAppendInfallibleToAttrs(attrs, throws):
|
def maybeAppendInfallibleToAttrs(attrs, throws):
|
||||||
if throws is None:
|
if throws is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue