mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
auto merge of #1848 : Ms2ger/servo/refactor-primitive-fromjsval, r=jdm
Probably best read commit-by-commit.
This commit is contained in:
commit
bdb551638e
1 changed files with 24 additions and 40 deletions
|
@ -1238,7 +1238,6 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||||
if failureCode is None:
|
if failureCode is None:
|
||||||
failureCode = 'return 0'
|
failureCode = 'return 0'
|
||||||
|
|
||||||
if type.nullable():
|
|
||||||
successVal = "v"
|
successVal = "v"
|
||||||
if preSuccess or postSuccess:
|
if preSuccess or postSuccess:
|
||||||
successVal = preSuccess + successVal + postSuccess
|
successVal = preSuccess + successVal + postSuccess
|
||||||
|
@ -1249,31 +1248,16 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||||
" Err(_) => %s\n"
|
" Err(_) => %s\n"
|
||||||
"}" % (successVal, failureCode))
|
"}" % (successVal, failureCode))
|
||||||
|
|
||||||
if defaultValue is not None and isinstance(defaultValue, IDLNullValue):
|
if type.nullable():
|
||||||
template = CGWrapper(CGIndenter(CGGeneric(template)),
|
|
||||||
pre="if ${haveValue} {\n",
|
|
||||||
post=("\n"
|
|
||||||
"} else {\n"
|
|
||||||
" ${declName} = None;\n"
|
|
||||||
"}")).define()
|
|
||||||
|
|
||||||
declType = CGGeneric("Option<" + typeName + ">")
|
declType = CGGeneric("Option<" + typeName + ">")
|
||||||
else:
|
else:
|
||||||
assert(defaultValue is None or
|
|
||||||
not isinstance(defaultValue, IDLNullValue))
|
|
||||||
#XXXjdm conversionBehavior should be used
|
|
||||||
successVal = "v"
|
|
||||||
if preSuccess or postSuccess:
|
|
||||||
successVal = preSuccess + successVal + postSuccess
|
|
||||||
template = (
|
|
||||||
"match JSValConvertible::from_jsval(cx, ${val}) {\n"
|
|
||||||
" Err(_) => %s,\n"
|
|
||||||
" Ok(v) => ${declName} = %s\n"
|
|
||||||
"}" % (failureCode, successVal))
|
|
||||||
declType = CGGeneric(typeName)
|
declType = CGGeneric(typeName)
|
||||||
if (defaultValue is not None and
|
|
||||||
# We already handled IDLNullValue, so just deal with the other ones
|
if defaultValue is not None:
|
||||||
not isinstance(defaultValue, IDLNullValue)):
|
if isinstance(defaultValue, IDLNullValue):
|
||||||
|
assert type.nullable()
|
||||||
|
defaultStr = "None"
|
||||||
|
else:
|
||||||
tag = defaultValue.type.tag()
|
tag = defaultValue.type.tag()
|
||||||
if tag in numericTags:
|
if tag in numericTags:
|
||||||
defaultStr = defaultValue.value
|
defaultStr = defaultValue.value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue