auto merge of #1851 : Ms2ger/servo/optional-jsval, r=jdm

Right now, we silently default to null, which is somewhat fishy.
This commit is contained in:
bors-servo 2014-03-07 11:07:29 -05:00
commit 810699c47d
4 changed files with 21 additions and 3 deletions

View file

@ -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