Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: Source/bindings/templates/methods.cpp

Issue 259773008: Add support for type checking of floating point arguments as [TypeChecking=Unrestricted] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: std::isfinite Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/tests/idls/TestInterface.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 3a63b52cd350694b59b8f23901b866de5b12a4b3..d33dd102285e36b9f2b12cb76c54681e47ca47db 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -94,12 +94,21 @@ if (UNLIKELY(info.Length() <= {{argument.index}})) {
{% endif %}
{% if argument.has_type_checking_interface %}
{# Type checking for wrapper interface types (if interface not implemented,
- throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
+ throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefinedOrNull(info[{{argument.index}}]) && {% endif %}!V8{{argument.idl_type}}::hasInstance(info[{{argument.index}}], info.GetIsolate())) {
{{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
(argument.index + 1, argument.idl_type)) | indent}}
return;
}
+{% elif argument.has_type_checking_unrestricted %}
+{# Type checking for non-finite floating point values (if NaN, +Infinity or
+ −Infinity, throw TypeError), per http://heycam.github.io/webidl/#es-float
+ and http://heycam.github.io/webidl/#es-double #}
+if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefinedOrNull(info[{{argument.index}}]) && {% endif %}!std::isfinite(info[{{argument.index}}]->NumberValue())) {
Nils Barth (inactive) 2014/04/28 10:40:45 Actually it's not that bad; can just use std::isfi
fs 2014/04/28 10:58:34 But in a case like: { valueOf: function() { retur
Nils Barth (inactive) 2014/04/30 01:58:02 Good point; presumably would need to be IsSpecialD
+ {{throw_type_error(method, '"%s parameter %s is non-finite."' %
+ (argument.idl_type, argument.index + 1)) | indent}}
+ return;
+}
{% endif %}
{% if argument.is_callback_interface %}
{# FIXME: remove EventListener special case #}
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/tests/idls/TestInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698