mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Rewrite the enumeration unwrapping to return an expression.
This commit is contained in:
parent
2b9d1d6bc1
commit
c5bf011d1e
1 changed files with 3 additions and 3 deletions
|
@ -723,7 +723,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
" Ok(None) => { %(handleInvalidEnumValueCode)s },\n"
|
" Ok(None) => { %(handleInvalidEnumValueCode)s },\n"
|
||||||
" Ok(Some(index)) => {\n"
|
" Ok(Some(index)) => {\n"
|
||||||
" //XXXjdm need some range checks up in here.\n"
|
" //XXXjdm need some range checks up in here.\n"
|
||||||
" ${declName} = cast::transmute(index);\n"
|
" cast::transmute(index)\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
"}" % { "values" : enum + "Values::strings",
|
"}" % { "values" : enum + "Values::strings",
|
||||||
"exceptionCode" : exceptionCode,
|
"exceptionCode" : exceptionCode,
|
||||||
|
@ -732,11 +732,11 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
if defaultValue is not None:
|
if defaultValue is not None:
|
||||||
assert(defaultValue.type.tag() == IDLType.Tags.domstring)
|
assert(defaultValue.type.tag() == IDLType.Tags.domstring)
|
||||||
template = handleDefault(template,
|
template = handleDefault(template,
|
||||||
("${declName} = %sValues::%s;" %
|
("%sValues::%s" %
|
||||||
(enum,
|
(enum,
|
||||||
getEnumValueName(defaultValue.value))))
|
getEnumValueName(defaultValue.value))))
|
||||||
|
|
||||||
return (template, CGGeneric(enum), None, isOptional, None)
|
return ("${declName} = " + template + ";", CGGeneric(enum), None, isOptional, None)
|
||||||
|
|
||||||
if type.isCallback():
|
if type.isCallback():
|
||||||
assert not isEnforceRange and not isClamp
|
assert not isEnforceRange and not isClamp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue