зеркало из https://github.com/mozilla/gecko-dev.git
Bug 742206 part 2. Implement WebIDL parser support for Date. r=smaug,khuey
This commit is contained in:
Родитель
2a01c9680b
Коммит
c61b432072
|
@ -3782,7 +3782,7 @@ if (!returnArray) {
|
|||
wrapCode = wrapCode % { "result": result }
|
||||
return wrapCode, False
|
||||
|
||||
if type.tag() == IDLType.Tags.any:
|
||||
if type.isAny():
|
||||
# See comments in WrapNewBindingObject explaining why we need
|
||||
# to wrap here.
|
||||
# NB: setValue(..., True) calls JS_WrapValue(), so is fallible
|
||||
|
|
|
@ -1211,7 +1211,9 @@ class IDLType(IDLObject):
|
|||
'dictionary',
|
||||
'enum',
|
||||
'callback',
|
||||
'union'
|
||||
'union',
|
||||
'sequence',
|
||||
'array'
|
||||
)
|
||||
|
||||
def __init__(self, location, name):
|
||||
|
@ -1286,7 +1288,7 @@ class IDLType(IDLObject):
|
|||
return False
|
||||
|
||||
def isAny(self):
|
||||
return self.tag() == IDLType.Tags.any and not self.isSequence()
|
||||
return self.tag() == IDLType.Tags.any
|
||||
|
||||
def isDate(self):
|
||||
return self.tag() == IDLType.Tags.date
|
||||
|
@ -1519,8 +1521,7 @@ class IDLSequenceType(IDLType):
|
|||
return self.inner.includesRestrictedFloat()
|
||||
|
||||
def tag(self):
|
||||
# XXXkhuey this is probably wrong.
|
||||
return self.inner.tag()
|
||||
return IDLType.Tags.sequence
|
||||
|
||||
def resolveType(self, parentScope):
|
||||
assert isinstance(parentScope, IDLScope)
|
||||
|
@ -1703,8 +1704,7 @@ class IDLArrayType(IDLType):
|
|||
return False
|
||||
|
||||
def tag(self):
|
||||
# XXXkhuey this is probably wrong.
|
||||
return self.inner.tag()
|
||||
return IDLType.Tags.array
|
||||
|
||||
def resolveType(self, parentScope):
|
||||
assert isinstance(parentScope, IDLScope)
|
||||
|
@ -4264,8 +4264,8 @@ class Parser(Tokenizer):
|
|||
"""
|
||||
NonAnyType : DATE TypeSuffix
|
||||
"""
|
||||
assert False
|
||||
pass
|
||||
p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.date],
|
||||
p[2])
|
||||
|
||||
def p_ConstType(self, p):
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
def WebIDLTest(parser, harness):
|
||||
parser.parse("""
|
||||
interface WithDates {
|
||||
attribute Date foo;
|
||||
void bar(Date arg);
|
||||
void baz(sequence<Date> arg);
|
||||
};
|
||||
""")
|
||||
|
||||
results = parser.finish()
|
||||
harness.ok(results[0].members[0].type.isDate(), "Should have Date")
|
||||
harness.ok(results[0].members[1].signatures()[0][1][0].type.isDate(),
|
||||
"Should have Date argument")
|
||||
harness.ok(not results[0].members[2].signatures()[0][1][0].type.isDate(),
|
||||
"Should have non-Date argument")
|
|
@ -157,7 +157,7 @@ def WebIDLTest(parser, harness):
|
|||
"CallbackInterface?", "CallbackInterface2",
|
||||
"object", "Callback", "Callback2", "optional Dict",
|
||||
"optional Dict2", "sequence<long>", "sequence<short>",
|
||||
"long[]", "short[]" ]
|
||||
"long[]", "short[]", "Date", "Date?" ]
|
||||
# When we can parse Date and RegExp, we need to add them here.
|
||||
|
||||
# Try to categorize things a bit to keep list lengths down
|
||||
|
@ -169,10 +169,11 @@ def WebIDLTest(parser, harness):
|
|||
interfaces = [ "Interface", "Interface?", "AncestorInterface",
|
||||
"UnrelatedInterface", "ImplementedInterface" ]
|
||||
nullables = ["long?", "short?", "Interface?", "CallbackInterface?",
|
||||
"optional Dict", "optional Dict2"]
|
||||
nonUserObjects = primitives + interfaces
|
||||
"optional Dict", "optional Dict2", "Date?"]
|
||||
dates = [ "Date", "Date?" ]
|
||||
nonUserObjects = primitives + interfaces + dates
|
||||
otherObjects = allBut(argTypes, nonUserObjects + ["object"])
|
||||
notRelatedInterfaces = primitives + ["UnrelatedInterface"] + otherObjects
|
||||
notRelatedInterfaces = primitives + ["UnrelatedInterface"] + otherObjects + dates
|
||||
|
||||
# Build a representation of the distinguishability table as a dict
|
||||
# of dicts, holding True values where needed, holes elsewhere.
|
||||
|
@ -208,6 +209,8 @@ def WebIDLTest(parser, harness):
|
|||
setDistinguishable("sequence<short>", nonUserObjects)
|
||||
setDistinguishable("long[]", nonUserObjects)
|
||||
setDistinguishable("short[]", nonUserObjects)
|
||||
setDistinguishable("Date", allBut(argTypes, dates + ["object"]))
|
||||
setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"]))
|
||||
|
||||
def areDistinguishable(type1, type2):
|
||||
return data[type1].get(type2, False)
|
||||
|
|
Загрузка…
Ссылка в новой задаче