Auto merge of #8055 - nox:rm-webidl-patches, r=Ms2ger

Remove all our patches to the WebIDL parser

All the tweaks we need can just be made through Configuration.py.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8055)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-12-16 15:19:25 +05:30
commit 9c4ca39ebe
6 changed files with 432 additions and 407 deletions

View file

@ -23,6 +23,7 @@ from WebIDL import (
from Configuration import ( from Configuration import (
MemberIsUnforgeable, MemberIsUnforgeable,
getModuleFromObject,
getTypesFromCallback, getTypesFromCallback,
getTypesFromDescriptor, getTypesFromDescriptor,
getTypesFromDictionary, getTypesFromDictionary,
@ -920,7 +921,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
assert not type.treatNonObjectAsNull() or not type.treatNonCallableAsNull() assert not type.treatNonObjectAsNull() or not type.treatNonCallableAsNull()
callback = type.unroll().callback callback = type.unroll().callback
declType = CGGeneric('%s::%s' % (callback.module(), callback.identifier.name)) declType = CGGeneric('%s::%s' % (getModuleFromObject(callback), callback.identifier.name))
finalDeclType = CGTemplatedType("Rc", declType) finalDeclType = CGTemplatedType("Rc", declType)
conversion = CGCallbackTempRoot(declType.define()) conversion = CGCallbackTempRoot(declType.define())
@ -1281,7 +1282,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
return result return result
if returnType.isCallback(): if returnType.isCallback():
callback = returnType.unroll().callback callback = returnType.unroll().callback
result = CGGeneric('Rc<%s::%s>' % (callback.module(), callback.identifier.name)) result = CGGeneric('Rc<%s::%s>' % (getModuleFromObject(callback), callback.identifier.name))
if returnType.nullable(): if returnType.nullable():
result = CGWrapper(result, pre="Option<", post=">") result = CGWrapper(result, pre="Option<", post=">")
return result return result
@ -5134,7 +5135,7 @@ class CGDictionary(CGThing):
@staticmethod @staticmethod
def makeModuleName(dictionary): def makeModuleName(dictionary):
return dictionary.module() return getModuleFromObject(dictionary)
def getMemberType(self, memberInfo): def getMemberType(self, memberInfo):
member, info = memberInfo member, info = memberInfo
@ -6033,8 +6034,8 @@ class GlobalGenRoots():
def Bindings(config): def Bindings(config):
descriptors = (set(d.name + "Binding" for d in config.getDescriptors(register=True)) | descriptors = (set(d.name + "Binding" for d in config.getDescriptors(register=True)) |
set(d.module() for d in config.callbacks) | set(getModuleFromObject(d) for d in config.callbacks) |
set(d.module() for d in config.getDictionaries())) set(getModuleFromObject(d) for d in config.getDictionaries()))
curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)]) curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)])
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
return curr return curr

View file

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from WebIDL import IDLInterface from WebIDL import IDLExternalInterface, IDLInterface, WebIDLError
class Configuration: class Configuration:
@ -23,6 +23,11 @@ class Configuration:
self.interfaces = {} self.interfaces = {}
self.maxProtoChainLength = 0 self.maxProtoChainLength = 0
for thing in parseData: for thing in parseData:
# Servo does not support external interfaces.
if isinstance(thing, IDLExternalInterface):
raise WebIDLError("Servo does not support external interfaces.",
[thing.location])
# Some toplevel things are sadly types, and those have an # Some toplevel things are sadly types, and those have an
# isInterface that doesn't mean the same thing as IDLObject's # isInterface that doesn't mean the same thing as IDLObject's
# isInterface()... # isInterface()...
@ -345,6 +350,10 @@ class Descriptor(DescriptorProvider):
# Some utility methods # Some utility methods
def getModuleFromObject(object):
return object.location.filename().split('/')[-1].split('.webidl')[0] + 'Binding'
def getTypesFromDescriptor(descriptor): def getTypesFromDescriptor(descriptor):
""" """
Get all argument and return types for all members of the descriptor Get all argument and return types for all members of the descriptor

File diff suppressed because it is too large Load diff

View file

@ -1,51 +0,0 @@
--- WebIDL.py
+++ WebIDL.py
@@ -505,46 +505,8 @@ class IDLExposureMixins():
class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
def __init__(self, location, parentScope, identifier):
- assert isinstance(identifier, IDLUnresolvedIdentifier)
- assert isinstance(parentScope, IDLScope)
- self.parent = None
- IDLObjectWithIdentifier.__init__(self, location, parentScope, identifier)
- IDLExposureMixins.__init__(self, location)
- IDLObjectWithIdentifier.resolve(self, parentScope)
-
- def finish(self, scope):
- IDLExposureMixins.finish(self, scope)
- pass
-
- def validate(self):
- pass
-
- def isExternal(self):
- return True
-
- def isInterface(self):
- return True
-
- def isConsequential(self):
- return False
-
- def addExtendedAttributes(self, attrs):
- assert len(attrs) == 0
-
- def resolve(self, parentScope):
- pass
-
- def getJSImplementation(self):
- return None
-
- def isJSImplemented(self):
- return False
-
- def getNavigatorProperty(self):
- return None
-
- def _getDependentObjects(self):
- return set()
+ raise WebIDLError("Servo does not support external interfaces.",
+ [self.location])
class IDLPartialInterface(IDLObject):
def __init__(self, location, name, members, nonPartialInterface):

View file

@ -1,22 +0,0 @@
--- WebIDL.py
+++ WebIDL.py
@@ -1506,6 +1506,9 @@ class IDLDictionary(IDLObjectWithScope):
self.identifier.name,
[member.location] + locations)
+ def module(self):
+ return self.location.filename().split('/')[-1].split('.webidl')[0] + 'Binding'
+
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
@@ -3574,6 +3577,9 @@ class IDLCallbackType(IDLType, IDLObjectWithScope):
self._treatNonCallableAsNull = False
self._treatNonObjectAsNull = False
+ def module(self):
+ return self.location.filename().split('/')[-1].split('.webidl')[0] + 'Binding'
+
def isCallback(self):
return True

View file

@ -1,4 +1,2 @@
wget https://mxr.mozilla.org/mozilla-central/source/dom/bindings/parser/WebIDL.py?raw=1 -O WebIDL.py wget https://mxr.mozilla.org/mozilla-central/source/dom/bindings/parser/WebIDL.py?raw=1 -O WebIDL.py
patch < external.patch
patch < module.patch
patch < abstract.patch patch < abstract.patch