mirror of
https://github.com/servo/servo.git
synced 2025-06-16 04:14:29 +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):
|
def getMemberType(self, memberInfo):
|
||||||
member, info = memberInfo
|
member, info = memberInfo
|
||||||
declType = info.declType
|
declType = info.declType
|
||||||
if not member.defaultValue:
|
if member.optional and not member.defaultValue:
|
||||||
declType = CGWrapper(info.declType, pre="Option<", post=">")
|
declType = CGWrapper(info.declType, pre="Option<", post=">")
|
||||||
return declType.define()
|
return declType.define()
|
||||||
|
|
||||||
|
@ -4817,7 +4817,11 @@ class CGDictionary(CGThing):
|
||||||
conversion = "%s.get()" % conversion
|
conversion = "%s.get()" % conversion
|
||||||
|
|
||||||
assert (member.defaultValue is None) == (default is None)
|
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"
|
default = "None"
|
||||||
conversion = "Some(%s)" % conversion
|
conversion = "Some(%s)" % conversion
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
enum TestEnum { "", "foo", "bar" };
|
enum TestEnum { "", "foo", "bar" };
|
||||||
|
|
||||||
dictionary TestDictionary {
|
dictionary TestDictionary {
|
||||||
|
required boolean requiredValue;
|
||||||
boolean booleanValue;
|
boolean booleanValue;
|
||||||
byte byteValue;
|
byte byteValue;
|
||||||
octet octetValue;
|
octet octetValue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue