mirror of
https://github.com/servo/servo.git
synced 2025-06-15 03:44:30 +00:00
Pass Option<JSVal> for optional JSVals.
This commit is contained in:
parent
134d1f6fe3
commit
971a4c58bb
4 changed files with 21 additions and 3 deletions
|
@ -1162,10 +1162,18 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
if isMember:
|
||||
raise TypeError("Can't handle member 'any'; need to sort out "
|
||||
"rooting issues")
|
||||
templateBody = "${declName} = ${val};"
|
||||
|
||||
declType = CGGeneric("JSVal")
|
||||
value = CGGeneric("${val}")
|
||||
if isOptional:
|
||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||
value = CGWrapper(value, pre="Some(", post=")")
|
||||
|
||||
templateBody = "${declName} = %s;" % value.define()
|
||||
templateBody = handleDefaultNull(templateBody,
|
||||
"${declName} = JSVAL_NULL")
|
||||
return (templateBody, CGGeneric("JSVal"), None, isOptional, "JSVAL_NULL")
|
||||
|
||||
return (templateBody, declType, None, isOptional, "None" if isOptional else None)
|
||||
|
||||
if type.isObject():
|
||||
assert not isEnforceRange and not isClamp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue