From 4c96732077d8152055a8988403f07db1277b50a7 Mon Sep 17 00:00:00 2001 From: Tetsuharu OHZEKI Date: Wed, 25 Mar 2015 02:48:17 +0900 Subject: [PATCH] Support the conversion behavior from ECMAScript value to restricted float. This is defined by WebIDL spec: - http://heycam.github.io/webidl/#es-float - http://heycam.github.io/webidl/#es-double --- .../dom/bindings/codegen/CodegenRust.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 16544054f86..2e511e342e9 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -887,12 +887,23 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, 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):