зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1359269 - Part 5: Add support for attributes on types in arguments; r=bzbarsky
Depends on D19736 Differential Revision: https://phabricator.services.mozilla.com/D19737 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a3642fd081
Коммит
2df29133e8
|
@ -6436,33 +6436,50 @@ class Parser(Tokenizer):
|
|||
"""
|
||||
p[0] = []
|
||||
|
||||
def p_Argument(self, p):
|
||||
def p_ArgumentOptional(self, p):
|
||||
"""
|
||||
Argument : ExtendedAttributeList Optional Type Ellipsis ArgumentName Default
|
||||
Argument : ExtendedAttributeList OPTIONAL TypeWithExtendedAttributes Ellipsis ArgumentName Default
|
||||
"""
|
||||
t = p[3]
|
||||
assert isinstance(t, IDLType)
|
||||
identifier = IDLUnresolvedIdentifier(self.getLocation(p, 5), p[5])
|
||||
|
||||
optional = p[2]
|
||||
variadic = p[4]
|
||||
defaultValue = p[6]
|
||||
|
||||
if not optional and defaultValue:
|
||||
raise WebIDLError("Mandatory arguments can't have a default value.",
|
||||
[self.getLocation(p, 6)])
|
||||
|
||||
# We can't test t.isAny() here and give it a default value as needed,
|
||||
# since at this point t is not a fully resolved type yet (e.g. it might
|
||||
# be a typedef). We'll handle the 'any' case in IDLArgument.complete.
|
||||
|
||||
if variadic:
|
||||
if optional:
|
||||
raise WebIDLError("Variadic arguments should not be marked optional.",
|
||||
[self.getLocation(p, 2)])
|
||||
optional = variadic
|
||||
raise WebIDLError("Variadic arguments should not be marked optional.",
|
||||
[self.getLocation(p, 2)])
|
||||
|
||||
p[0] = IDLArgument(self.getLocation(p, 5), identifier, t, optional, defaultValue, variadic)
|
||||
p[0] = IDLArgument(self.getLocation(p, 5), identifier, t, True, defaultValue, variadic)
|
||||
p[0].addExtendedAttributes(p[1])
|
||||
|
||||
def p_Argument(self, p):
|
||||
"""
|
||||
Argument : ExtendedAttributeList Type Ellipsis ArgumentName Default
|
||||
"""
|
||||
t = p[2]
|
||||
assert isinstance(t, IDLType)
|
||||
identifier = IDLUnresolvedIdentifier(self.getLocation(p, 4), p[4])
|
||||
|
||||
variadic = p[3]
|
||||
defaultValue = p[5]
|
||||
|
||||
if defaultValue:
|
||||
raise WebIDLError("Mandatory arguments can't have a default value.",
|
||||
[self.getLocation(p, 5)])
|
||||
|
||||
# We can't test t.isAny() here and give it a default value as needed,
|
||||
# since at this point t is not a fully resolved type yet (e.g. it might
|
||||
# be a typedef). We'll handle the 'any' case in IDLArgument.complete.
|
||||
|
||||
# variadic implies optional
|
||||
p[0] = IDLArgument(self.getLocation(p, 4), identifier, t, variadic, defaultValue, variadic)
|
||||
p[0].addExtendedAttributes(p[1])
|
||||
|
||||
def p_ArgumentName(self, p):
|
||||
|
@ -6502,18 +6519,6 @@ class Parser(Tokenizer):
|
|||
"""
|
||||
p[0] = p[1]
|
||||
|
||||
def p_Optional(self, p):
|
||||
"""
|
||||
Optional : OPTIONAL
|
||||
"""
|
||||
p[0] = True
|
||||
|
||||
def p_OptionalEmpty(self, p):
|
||||
"""
|
||||
Optional :
|
||||
"""
|
||||
p[0] = False
|
||||
|
||||
def p_Required(self, p):
|
||||
"""
|
||||
Required : REQUIRED
|
||||
|
|
|
@ -1593,6 +1593,7 @@ class TestAttributesOnTypes : public nsISupports, public nsWrapperCache {
|
|||
void Foo(uint8_t arg);
|
||||
void Bar(uint8_t arg);
|
||||
void Baz(const nsAString& arg);
|
||||
void ArgWithAttr(uint8_t arg1, const Optional<uint8_t>& arg2);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1324,4 +1324,7 @@ interface TestAttributesOnTypes {
|
|||
void foo(OctetClamp thingy);
|
||||
void bar(OctetRange thingy);
|
||||
void baz(NullEmptyString thingy);
|
||||
void argWithAttr([Clamp] octet arg0, optional [Clamp] octet arg1);
|
||||
// There aren't any argument-only attributes that we can test here,
|
||||
// TreatNonCallableAsNull isn't compatible with Clamp-able types
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ interface WebSocket : EventTarget {
|
|||
readonly attribute DOMString protocol;
|
||||
|
||||
[Throws]
|
||||
void close([Clamp] optional unsigned short code, optional DOMString reason);
|
||||
void close(optional [Clamp] unsigned short code, optional DOMString reason);
|
||||
|
||||
// messaging
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче