aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2014-08-19 19:38:09 +0530
committerManish Goregaokar <manishsmail@gmail.com>2014-08-19 19:38:09 +0530
commit30c66debb05cfc84cb8b0d53b6b174ce0af10879 (patch)
treecb45b8a56733eb088d8bb9da629ec7c4df1f16bd /src/components/script/dom/bindings/codegen
parentbbcd62397e12f1eed8b2b61102342c047c53dfdb (diff)
parentea3c2c243cf869b1c5d0f7f2ef67c52ba6ba176a (diff)
downloadservo-30c66debb05cfc84cb8b0d53b6b174ce0af10879.tar.gz
servo-30c66debb05cfc84cb8b0d53b6b174ce0af10879.zip
Merge pull request #3112 from Ms2ger/hasInterfacePrototypeObject
Replace hasInterfacePrototypeObject checks by isCallback checks in codegen.
Diffstat (limited to 'src/components/script/dom/bindings/codegen')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py106
-rw-r--r--src/components/script/dom/bindings/codegen/Configuration.py7
2 files changed, 49 insertions, 64 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 6ff4eb8efc4..d546d9d63ff 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1788,7 +1788,7 @@ JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
class CGWrapMethod(CGAbstractMethod):
def __init__(self, descriptor):
- assert descriptor.interface.hasInterfacePrototypeObject()
+ assert not descriptor.interface.isCallback()
if not descriptor.createGlobal:
args = [Argument('*mut JSContext', 'aCx'), Argument('&GlobalRef', 'aScope'),
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)]
@@ -1920,6 +1920,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
properties should be a PropertyArrays instance.
"""
def __init__(self, descriptor, properties):
+ assert not descriptor.interface.isCallback()
args = [Argument('*mut JSContext', 'aCx'), Argument('*mut JSObject', 'aGlobal'),
Argument('*mut JSObject', 'aReceiver')]
CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', '*mut JSObject', args)
@@ -1933,12 +1934,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
getParentProto = ("%s::GetProtoObject(aCx, aGlobal, aReceiver)" %
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"
"assert!(parentProto.is_not_null());\n") % getParentProto
@@ -1950,7 +1945,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else:
domClass = "ptr::null()"
- if needInterfaceObject:
+ if self.descriptor.interface.hasInterfaceObject():
if self.descriptor.interface.ctor():
constructHook = CONSTRUCT_HOOK_NAME
constructArgs = methodLength(self.descriptor.interface.ctor())
@@ -4049,62 +4044,60 @@ class CGDescriptor(CGThing):
def __init__(self, descriptor):
CGThing.__init__(self)
- assert not descriptor.concrete or descriptor.interface.hasInterfacePrototypeObject()
+ assert not descriptor.interface.isCallback()
cgThings = []
- if descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGGetProtoObjectMethod(descriptor))
+ cgThings.append(CGGetProtoObjectMethod(descriptor))
if descriptor.interface.hasInterfaceObject():
# https://github.com/mozilla/servo/issues/2665
# cgThings.append(CGGetConstructorObjectMethod(descriptor))
pass
- if descriptor.interface.hasInterfacePrototypeObject():
- (hasMethod, hasGetter, hasLenientGetter,
- hasSetter, hasLenientSetter) = False, False, False, False, False
- for m in descriptor.interface.members:
- if m.isMethod() and not m.isIdentifierLess():
- if m.isStatic():
- assert descriptor.interface.hasInterfaceObject()
- cgThings.append(CGStaticMethod(descriptor, m))
- elif descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGSpecializedMethod(descriptor, m))
- cgThings.append(CGMemberJITInfo(descriptor, m))
- hasMethod = True
- elif m.isAttr():
+ (hasMethod, hasGetter, hasLenientGetter,
+ hasSetter, hasLenientSetter) = False, False, False, False, False
+ for m in descriptor.interface.members:
+ if m.isMethod() and not m.isIdentifierLess():
+ if m.isStatic():
+ assert descriptor.interface.hasInterfaceObject()
+ cgThings.append(CGStaticMethod(descriptor, m))
+ else:
+ cgThings.append(CGSpecializedMethod(descriptor, m))
+ cgThings.append(CGMemberJITInfo(descriptor, m))
+ hasMethod = True
+ elif m.isAttr():
+ if m.isStatic():
+ assert descriptor.interface.hasInterfaceObject()
+ cgThings.append(CGStaticGetter(descriptor, m))
+ else:
+ cgThings.append(CGSpecializedGetter(descriptor, m))
+ if m.hasLenientThis():
+ hasLenientGetter = True
+ else:
+ hasGetter = True
+
+ if not m.readonly:
if m.isStatic():
assert descriptor.interface.hasInterfaceObject()
- cgThings.append(CGStaticGetter(descriptor, m))
- elif descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGSpecializedGetter(descriptor, m))
+ cgThings.append(CGStaticSetter(descriptor, m))
+ else:
+ cgThings.append(CGSpecializedSetter(descriptor, m))
if m.hasLenientThis():
- hasLenientGetter = True
+ hasLenientSetter = True
else:
- hasGetter = True
-
- if not m.readonly:
- if m.isStatic():
- assert descriptor.interface.hasInterfaceObject()
- cgThings.append(CGStaticSetter(descriptor, m))
- elif descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGSpecializedSetter(descriptor, m))
- if m.hasLenientThis():
- hasLenientSetter = True
- else:
- hasSetter = True
-
- if not m.isStatic() and descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGMemberJITInfo(descriptor, m))
- if hasMethod:
- cgThings.append(CGGenericMethod(descriptor))
- if hasGetter:
- cgThings.append(CGGenericGetter(descriptor))
- if hasLenientGetter:
- pass
- if hasSetter:
- cgThings.append(CGGenericSetter(descriptor))
- if hasLenientSetter:
- pass
+ hasSetter = True
+
+ if not m.isStatic():
+ cgThings.append(CGMemberJITInfo(descriptor, m))
+ if hasMethod:
+ cgThings.append(CGGenericMethod(descriptor))
+ if hasGetter:
+ cgThings.append(CGGenericGetter(descriptor))
+ if hasLenientGetter:
+ pass
+ if hasSetter:
+ cgThings.append(CGGenericSetter(descriptor))
+ if hasLenientSetter:
+ pass
if descriptor.concrete:
cgThings.append(CGClassFinalizeHook(descriptor))
@@ -4114,8 +4107,7 @@ class CGDescriptor(CGThing):
cgThings.append(CGClassConstructHook(descriptor))
cgThings.append(CGInterfaceObjectJSClass(descriptor))
- if descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGPrototypeJSClass(descriptor))
+ cgThings.append(CGPrototypeJSClass(descriptor))
properties = PropertyArrays(descriptor)
cgThings.append(CGGeneric(str(properties)))
@@ -4415,7 +4407,7 @@ class CGBindingRoot(CGThing):
"""
def __init__(self, config, prefix, webIDLFile):
descriptors = config.getDescriptors(webIDLFile=webIDLFile,
- hasInterfaceOrInterfacePrototypeObject=True)
+ isCallback=False)
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
cgthings = []
@@ -5383,7 +5375,7 @@ class GlobalGenRoots():
@staticmethod
def PrototypeList(config):
# 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)]
return CGList([
diff --git a/src/components/script/dom/bindings/codegen/Configuration.py b/src/components/script/dom/bindings/codegen/Configuration.py
index b9e521ed175..ea193d18d7a 100644
--- a/src/components/script/dom/bindings/codegen/Configuration.py
+++ b/src/components/script/dom/bindings/codegen/Configuration.py
@@ -72,10 +72,6 @@ class Configuration:
getter = lambda x: x.interface.filename()
elif key == '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':
getter = lambda x: x.interface.isCallback()
elif key == 'isJSImplemented':
@@ -258,9 +254,6 @@ class Descriptor(DescriptorProvider):
config.maxProtoChainLength = max(config.maxProtoChainLength,
len(self.prototypeChain))
- def hasInterfaceOrInterfacePrototypeObject(self):
- return self.interface.hasInterfaceObject() or self.interface.hasInterfacePrototypeObject()
-
def getExtendedAttributes(self, member, getter=False, setter=False):
def maybeAppendInfallibleToAttrs(attrs, throws):
if throws is None: