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

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

Issue 53483004: IDL compiler: [Clamp] for arguments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comment changes Created 7 years, 2 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/unstable/v8_methods.py ('k') | Source/bindings/tests/idls/TestObjectPython.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 c2381da54f8d37c4aeebbf800f8ce08a4e6f6db6..7ea9ce8092fa7242a1229419e3ec68cc4b320d80 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -16,7 +16,15 @@ static void {{method.name}}Method(const v8::FunctionCallbackInfo<v8::Value>& arg
return;
}
{% endif %}
- {% if argument.idl_type == 'SerializedScriptValue' %}
+ {% if argument.is_clamp %}
+ {# FIXME: use C++ type for local variable #}
+ {{argument.idl_type}} {{argument.name}} = 0;
+ V8TRYCATCH_VOID(double, {{argument.name}}NativeValue, args[{{argument.index}}]->NumberValue());
+ if (!std::isnan({{argument.name}}NativeValue))
+ {# IDL type is used for clamping - to get the right bounds - since
+ different IDL types have same internal C++ type (int or unsigned) #}
+ {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeValue);
+ {% elif argument.idl_type == 'SerializedScriptValue' %}
bool {{argument.name}}DidThrow = false;
{{argument.cpp_type}} {{argument.name}} = SerializedScriptValue::create(args[{{argument.index}}], 0, 0, {{argument.name}}DidThrow, args.GetIsolate());
if ({{argument.name}}DidThrow)
« no previous file with comments | « Source/bindings/scripts/unstable/v8_methods.py ('k') | Source/bindings/tests/idls/TestObjectPython.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698