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

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

Issue 561633003: IDL: Enumerations support in dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove parens Created 6 years, 3 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/templates/dictionary_v8.h ('k') | Source/bindings/tests/idls/core/TestDictionary.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/dictionary_v8.cpp
diff --git a/Source/bindings/templates/dictionary_v8.cpp b/Source/bindings/templates/dictionary_v8.cpp
index 82c6e9accf1d60a42ae7ed24b8c2baf9d2235c02..77a6b3c6820616bc3cdd2b7bfdd68fdf3753957f 100644
--- a/Source/bindings/templates/dictionary_v8.cpp
+++ b/Source/bindings/templates/dictionary_v8.cpp
@@ -13,7 +13,7 @@
namespace blink {
-{{cpp_class}}* {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value)
+{{cpp_class}}* {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, ExceptionState& exceptionState)
{
{{cpp_class}}* impl = {{cpp_class}}::create();
// FIXME: Do not use Dictionary and DictionaryHelper
@@ -21,8 +21,16 @@ namespace blink {
Dictionary dictionary(v8Value, isolate);
{% for member in members %}
{{member.cpp_type}} {{member.name}};
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name}}", {{member.name}}))
+ if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "{{member.name}}", {{member.name}})) {
+ {% if member.enum_validation_expression %}
+ String string = {{member.name}};
+ if (!({{member.enum_validation_expression}})) {
+ exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value.");
+ return 0;
+ }
+ {% endif %}
impl->{{member.setter_name}}({{member.name}});
+ }
{% endfor %}
return impl;
}
« no previous file with comments | « Source/bindings/templates/dictionary_v8.h ('k') | Source/bindings/tests/idls/core/TestDictionary.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698