зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1015318 - Factor out the common code from IDLNullableType, IDLSequenceType, and IDLMozMapType into a new superclass, IDLParameterizedType. r=bzbarsky
MozReview-Commit-ID: 20darfFam9f
This commit is contained in:
Родитель
056fb20060
Коммит
b122e889a9
|
@ -2117,7 +2117,30 @@ class IDLUnresolvedType(IDLType):
|
||||||
"distinguishable from other things")
|
"distinguishable from other things")
|
||||||
|
|
||||||
|
|
||||||
class IDLNullableType(IDLType):
|
class IDLParameterizedType(IDLType):
|
||||||
|
def __init__(self, location, name, innerType):
|
||||||
|
IDLType.__init__(self, location, name)
|
||||||
|
self.builtin = False
|
||||||
|
self.inner = innerType
|
||||||
|
|
||||||
|
def includesRestrictedFloat(self):
|
||||||
|
return self.inner.includesRestrictedFloat()
|
||||||
|
|
||||||
|
def resolveType(self, parentScope):
|
||||||
|
assert isinstance(parentScope, IDLScope)
|
||||||
|
self.inner.resolveType(parentScope)
|
||||||
|
|
||||||
|
def isComplete(self):
|
||||||
|
return self.inner.isComplete()
|
||||||
|
|
||||||
|
def unroll(self):
|
||||||
|
return self.inner.unroll()
|
||||||
|
|
||||||
|
def _getDependentObjects(self):
|
||||||
|
return self.inner._getDependentObjects()
|
||||||
|
|
||||||
|
|
||||||
|
class IDLNullableType(IDLParameterizedType):
|
||||||
def __init__(self, location, innerType):
|
def __init__(self, location, innerType):
|
||||||
assert not innerType.isVoid()
|
assert not innerType.isVoid()
|
||||||
assert not innerType == BuiltinTypes[IDLBuiltinType.Types.any]
|
assert not innerType == BuiltinTypes[IDLBuiltinType.Types.any]
|
||||||
|
@ -2125,9 +2148,7 @@ class IDLNullableType(IDLType):
|
||||||
name = innerType.name
|
name = innerType.name
|
||||||
if innerType.isComplete():
|
if innerType.isComplete():
|
||||||
name += "OrNull"
|
name += "OrNull"
|
||||||
IDLType.__init__(self, location, name)
|
IDLParameterizedType.__init__(self, location, name, innerType)
|
||||||
self.inner = innerType
|
|
||||||
self.builtin = False
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return isinstance(other, IDLNullableType) and self.inner == other.inner
|
return isinstance(other, IDLNullableType) and self.inner == other.inner
|
||||||
|
@ -2168,9 +2189,6 @@ class IDLNullableType(IDLType):
|
||||||
def isUnrestricted(self):
|
def isUnrestricted(self):
|
||||||
return self.inner.isUnrestricted()
|
return self.inner.isUnrestricted()
|
||||||
|
|
||||||
def includesRestrictedFloat(self):
|
|
||||||
return self.inner.includesRestrictedFloat()
|
|
||||||
|
|
||||||
def isInteger(self):
|
def isInteger(self):
|
||||||
return self.inner.isInteger()
|
return self.inner.isInteger()
|
||||||
|
|
||||||
|
@ -2225,13 +2243,6 @@ class IDLNullableType(IDLType):
|
||||||
def tag(self):
|
def tag(self):
|
||||||
return self.inner.tag()
|
return self.inner.tag()
|
||||||
|
|
||||||
def resolveType(self, parentScope):
|
|
||||||
assert isinstance(parentScope, IDLScope)
|
|
||||||
self.inner.resolveType(parentScope)
|
|
||||||
|
|
||||||
def isComplete(self):
|
|
||||||
return self.inner.isComplete()
|
|
||||||
|
|
||||||
def complete(self, scope):
|
def complete(self, scope):
|
||||||
self.inner = self.inner.complete(scope)
|
self.inner = self.inner.complete(scope)
|
||||||
if self.inner.nullable():
|
if self.inner.nullable():
|
||||||
|
@ -2247,9 +2258,6 @@ class IDLNullableType(IDLType):
|
||||||
self.name = self.inner.name + "OrNull"
|
self.name = self.inner.name + "OrNull"
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def unroll(self):
|
|
||||||
return self.inner.unroll()
|
|
||||||
|
|
||||||
def isDistinguishableFrom(self, other):
|
def isDistinguishableFrom(self, other):
|
||||||
if (other.nullable() or (other.isUnion() and other.hasNullableType) or
|
if (other.nullable() or (other.isUnion() and other.hasNullableType) or
|
||||||
other.isDictionary()):
|
other.isDictionary()):
|
||||||
|
@ -2257,17 +2265,12 @@ class IDLNullableType(IDLType):
|
||||||
return False
|
return False
|
||||||
return self.inner.isDistinguishableFrom(other)
|
return self.inner.isDistinguishableFrom(other)
|
||||||
|
|
||||||
def _getDependentObjects(self):
|
|
||||||
return self.inner._getDependentObjects()
|
|
||||||
|
|
||||||
|
class IDLSequenceType(IDLParameterizedType):
|
||||||
class IDLSequenceType(IDLType):
|
|
||||||
def __init__(self, location, parameterType):
|
def __init__(self, location, parameterType):
|
||||||
assert not parameterType.isVoid()
|
assert not parameterType.isVoid()
|
||||||
|
|
||||||
IDLType.__init__(self, location, parameterType.name)
|
IDLParameterizedType.__init__(self, location, parameterType.name, parameterType)
|
||||||
self.inner = parameterType
|
|
||||||
self.builtin = False
|
|
||||||
# Need to set self.name up front if our inner type is already complete,
|
# Need to set self.name up front if our inner type is already complete,
|
||||||
# since in that case our .complete() won't be called.
|
# since in that case our .complete() won't be called.
|
||||||
if self.inner.isComplete():
|
if self.inner.isComplete():
|
||||||
|
@ -2318,27 +2321,14 @@ class IDLSequenceType(IDLType):
|
||||||
def isSerializable(self):
|
def isSerializable(self):
|
||||||
return self.inner.isSerializable()
|
return self.inner.isSerializable()
|
||||||
|
|
||||||
def includesRestrictedFloat(self):
|
|
||||||
return self.inner.includesRestrictedFloat()
|
|
||||||
|
|
||||||
def tag(self):
|
def tag(self):
|
||||||
return IDLType.Tags.sequence
|
return IDLType.Tags.sequence
|
||||||
|
|
||||||
def resolveType(self, parentScope):
|
|
||||||
assert isinstance(parentScope, IDLScope)
|
|
||||||
self.inner.resolveType(parentScope)
|
|
||||||
|
|
||||||
def isComplete(self):
|
|
||||||
return self.inner.isComplete()
|
|
||||||
|
|
||||||
def complete(self, scope):
|
def complete(self, scope):
|
||||||
self.inner = self.inner.complete(scope)
|
self.inner = self.inner.complete(scope)
|
||||||
self.name = self.inner.name + "Sequence"
|
self.name = self.inner.name + "Sequence"
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def unroll(self):
|
|
||||||
return self.inner.unroll()
|
|
||||||
|
|
||||||
def isDistinguishableFrom(self, other):
|
def isDistinguishableFrom(self, other):
|
||||||
if other.isPromise():
|
if other.isPromise():
|
||||||
return False
|
return False
|
||||||
|
@ -2350,20 +2340,12 @@ class IDLSequenceType(IDLType):
|
||||||
other.isDictionary() or
|
other.isDictionary() or
|
||||||
other.isCallback() or other.isMozMap())
|
other.isCallback() or other.isMozMap())
|
||||||
|
|
||||||
def _getDependentObjects(self):
|
|
||||||
return self.inner._getDependentObjects()
|
|
||||||
|
|
||||||
|
class IDLMozMapType(IDLParameterizedType):
|
||||||
class IDLMozMapType(IDLType):
|
|
||||||
# XXXbz This is pretty similar to IDLSequenceType in various ways.
|
|
||||||
# And maybe to IDLNullableType. Should we have a superclass for
|
|
||||||
# "type containing this other type"? Bug 1015318.
|
|
||||||
def __init__(self, location, parameterType):
|
def __init__(self, location, parameterType):
|
||||||
assert not parameterType.isVoid()
|
assert not parameterType.isVoid()
|
||||||
|
|
||||||
IDLType.__init__(self, location, parameterType.name)
|
IDLParameterizedType.__init__(self, location, parameterType.name, parameterType)
|
||||||
self.inner = parameterType
|
|
||||||
self.builtin = False
|
|
||||||
# Need to set self.name up front if our inner type is already complete,
|
# Need to set self.name up front if our inner type is already complete,
|
||||||
# since in that case our .complete() won't be called.
|
# since in that case our .complete() won't be called.
|
||||||
if self.inner.isComplete():
|
if self.inner.isComplete():
|
||||||
|
@ -2378,19 +2360,9 @@ class IDLMozMapType(IDLType):
|
||||||
def isMozMap(self):
|
def isMozMap(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def includesRestrictedFloat(self):
|
|
||||||
return self.inner.includesRestrictedFloat()
|
|
||||||
|
|
||||||
def tag(self):
|
def tag(self):
|
||||||
return IDLType.Tags.mozmap
|
return IDLType.Tags.mozmap
|
||||||
|
|
||||||
def resolveType(self, parentScope):
|
|
||||||
assert isinstance(parentScope, IDLScope)
|
|
||||||
self.inner.resolveType(parentScope)
|
|
||||||
|
|
||||||
def isComplete(self):
|
|
||||||
return self.inner.isComplete()
|
|
||||||
|
|
||||||
def complete(self, scope):
|
def complete(self, scope):
|
||||||
self.inner = self.inner.complete(scope)
|
self.inner = self.inner.complete(scope)
|
||||||
self.name = self.inner.name + "MozMap"
|
self.name = self.inner.name + "MozMap"
|
||||||
|
@ -2414,9 +2386,6 @@ class IDLMozMapType(IDLType):
|
||||||
def isExposedInAllOf(self, exposureSet):
|
def isExposedInAllOf(self, exposureSet):
|
||||||
return self.inner.unroll().isExposedInAllOf(exposureSet)
|
return self.inner.unroll().isExposedInAllOf(exposureSet)
|
||||||
|
|
||||||
def _getDependentObjects(self):
|
|
||||||
return self.inner._getDependentObjects()
|
|
||||||
|
|
||||||
|
|
||||||
class IDLUnionType(IDLType):
|
class IDLUnionType(IDLType):
|
||||||
def __init__(self, location, memberTypes):
|
def __init__(self, location, memberTypes):
|
||||||
|
|
Загрузка…
Ссылка в новой задаче