mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Support required dictionary members (fixes #7216)
This commit is contained in:
parent
efe982392e
commit
44aabbe64d
2 changed files with 7 additions and 2 deletions
|
@ -4800,7 +4800,7 @@ class CGDictionary(CGThing):
|
|||
def getMemberType(self, memberInfo):
|
||||
member, info = memberInfo
|
||||
declType = info.declType
|
||||
if not member.defaultValue:
|
||||
if member.optional and not member.defaultValue:
|
||||
declType = CGWrapper(info.declType, pre="Option<", post=">")
|
||||
return declType.define()
|
||||
|
||||
|
@ -4817,7 +4817,11 @@ class CGDictionary(CGThing):
|
|||
conversion = "%s.get()" % conversion
|
||||
|
||||
assert (member.defaultValue is None) == (default is None)
|
||||
if not default:
|
||||
if not member.optional:
|
||||
assert default is None
|
||||
default = ("throw_type_error(cx, \"Missing required member \\\"%s\\\".\");\n"
|
||||
"return Err(());") % member.identifier.name
|
||||
elif not default:
|
||||
default = "None"
|
||||
conversion = "Some(%s)" % conversion
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
enum TestEnum { "", "foo", "bar" };
|
||||
|
||||
dictionary TestDictionary {
|
||||
required boolean requiredValue;
|
||||
boolean booleanValue;
|
||||
byte byteValue;
|
||||
octet octetValue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue