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

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

Issue 1047993002: bindings: Add validation for enum Sequence or Array (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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
Index: Source/bindings/templates/dictionary_v8.cpp
diff --git a/Source/bindings/templates/dictionary_v8.cpp b/Source/bindings/templates/dictionary_v8.cpp
index c6b6d1343a7b3922a93e49f78d18884ee6347a01..f5a012eb809f5f00f00984ecbdf847fb925f03b0 100644
--- a/Source/bindings/templates/dictionary_v8.cpp
+++ b/Source/bindings/templates/dictionary_v8.cpp
@@ -1,3 +1,4 @@
+{% from 'conversions.cpp' import declare_enum_validation_variable %}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -62,10 +63,10 @@ void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{
return;
}
{% endif %}
- {% 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.");
+ {% if member.enum_values %}
+ {{declare_enum_validation_variable(member.enum_values) | indent(8)}}
+ if (!isValidEnum({{member.name}}, validValues, {{member.enum_values|length}})) {
haraken 2015/03/31 06:11:17 Space around '|'?
+ exceptionState.throwTypeError("member {{member.name}} is not a valid enum value.");
return;
}
{% elif member.is_object %}

Powered by Google App Engine
This is Rietveld 408576698