Skip to content

Commit

Permalink
Support the conversion behavior from ECMAScript value to restricted f…
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsuharuohzeki committed Mar 25, 2015
1 parent f7fd34c commit 4c96732
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -887,12 +887,23 @@ def wrapObjectTemplate(templateBody, isDefinitelyObject, type,
if type.nullable():
declType = CGWrapper(declType, pre="Option<", post=">")

#XXXjdm support conversionBehavior here
template = (
"match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
" Ok(v) => v,\n"
" Err(_) => { %s }\n"
"}" % exceptionCode)
template = ""
if type.isFloat() and not type.isUnrestricted():
template = (
"match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
" Ok(v) => v,\n"
" Err(_) => {\n"
" throw_type_error(cx, \"this argument is not a finite floating-point value\");\n"
" %s\n"
" }\n"
"}" % exceptionCode)
else:
#XXXjdm support conversionBehavior here
template = (
"match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
" Ok(v) => v,\n"
" Err(_) => { %s }\n"
"}" % exceptionCode)

if defaultValue is not None:
if isinstance(defaultValue, IDLNullValue):
Expand Down

0 comments on commit 4c96732

Please sign in to comment.