зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1057541 part 1. Change the IDL parser to allow an optional "required" on dictionary members. r=khuey
This commit is contained in:
Родитель
bad296b02c
Коммит
360bc9ab4d
|
@ -4141,8 +4141,8 @@ class Tokenizer(object):
|
|||
"long": "LONG",
|
||||
"object": "OBJECT",
|
||||
"octet": "OCTET",
|
||||
"optional": "OPTIONAL",
|
||||
"Promise": "PROMISE",
|
||||
"required": "REQUIRED",
|
||||
"sequence": "SEQUENCE",
|
||||
"MozMap": "MOZMAP",
|
||||
"short": "SHORT",
|
||||
|
@ -4427,15 +4427,21 @@ class Parser(Tokenizer):
|
|||
|
||||
def p_DictionaryMember(self, p):
|
||||
"""
|
||||
DictionaryMember : Type IDENTIFIER Default SEMICOLON
|
||||
DictionaryMember : Required Type IDENTIFIER Default SEMICOLON
|
||||
"""
|
||||
# These quack a lot like optional arguments, so just treat them that way.
|
||||
t = p[1]
|
||||
t = p[2]
|
||||
assert isinstance(t, IDLType)
|
||||
identifier = IDLUnresolvedIdentifier(self.getLocation(p, 2), p[2])
|
||||
defaultValue = p[3]
|
||||
identifier = IDLUnresolvedIdentifier(self.getLocation(p, 3), p[3])
|
||||
defaultValue = p[4]
|
||||
optional = not p[1]
|
||||
|
||||
p[0] = IDLArgument(self.getLocation(p, 2), identifier, t, optional=True,
|
||||
if not optional and defaultValue:
|
||||
raise WebIDLError("Required dictionary members can't have a default value.",
|
||||
[self.getLocation(p, 4)])
|
||||
|
||||
p[0] = IDLArgument(self.getLocation(p, 3), identifier, t,
|
||||
optional=optional,
|
||||
defaultValue=defaultValue, variadic=False,
|
||||
dictionaryMember=True)
|
||||
|
||||
|
@ -4633,7 +4639,7 @@ class Parser(Tokenizer):
|
|||
|
||||
def p_AttributeRest(self, p):
|
||||
"""
|
||||
AttributeRest : ReadOnly ATTRIBUTE Type IDENTIFIER SEMICOLON
|
||||
AttributeRest : ReadOnly ATTRIBUTE Type AttributeName SEMICOLON
|
||||
"""
|
||||
location = self.getLocation(p, 2)
|
||||
readonly = p[1]
|
||||
|
@ -4962,6 +4968,7 @@ class Parser(Tokenizer):
|
|||
| INTERFACE
|
||||
| LEGACYCALLER
|
||||
| PARTIAL
|
||||
| REQUIRED
|
||||
| SERIALIZER
|
||||
| SETTER
|
||||
| STATIC
|
||||
|
@ -4972,6 +4979,13 @@ class Parser(Tokenizer):
|
|||
"""
|
||||
p[0] = p[1]
|
||||
|
||||
def p_AttributeName(self, p):
|
||||
"""
|
||||
AttributeName : IDENTIFIER
|
||||
| REQUIRED
|
||||
"""
|
||||
p[0] = p[1]
|
||||
|
||||
def p_Optional(self, p):
|
||||
"""
|
||||
Optional : OPTIONAL
|
||||
|
@ -4984,6 +4998,18 @@ class Parser(Tokenizer):
|
|||
"""
|
||||
p[0] = False
|
||||
|
||||
def p_Required(self, p):
|
||||
"""
|
||||
Required : REQUIRED
|
||||
"""
|
||||
p[0] = True
|
||||
|
||||
def p_RequiredEmpty(self, p):
|
||||
"""
|
||||
Required :
|
||||
"""
|
||||
p[0] = False
|
||||
|
||||
def p_Ellipsis(self, p):
|
||||
"""
|
||||
Ellipsis : ELLIPSIS
|
||||
|
|
Загрузка…
Ссылка в новой задаче