mirror of
https://github.com/servo/servo
synced 2026-04-28 10:27:40 +02:00
When converting a non-finite float, throw the TypeError from the FromJSValConvertible implementation.
This removes some unnecessary custom code in the codegen and makes this implementation follow the convention of having thrown an exception when returning Err() from FromJSValConvertible.
This commit is contained in:
@@ -887,23 +887,12 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
if type.nullable():
|
||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||
|
||||
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)
|
||||
#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):
|
||||
|
||||
Reference in New Issue
Block a user