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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {% from 'conversions.cpp' import declare_enum_validation_variable %}
1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 4 // found in the LICENSE file.
4 5
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! 6 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6 7
7 #include "config.h" 8 #include "config.h"
8 #include "{{v8_original_class}}.h" 9 #include "{{v8_original_class}}.h"
9 10
10 {% for filename in cpp_includes if filename != '%s.h' % v8_class %} 11 {% for filename in cpp_includes if filename != '%s.h' % v8_class %}
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 {% if member.deprecate_as %} 56 {% if member.deprecate_as %}
56 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution Context(isolate), UseCounter::{{member.deprecate_as}}); 57 UseCounter::countDeprecationIfNotPrivateScript(isolate, callingExecution Context(isolate), UseCounter::{{member.deprecate_as}});
57 {% endif %} 58 {% endif %}
58 {{v8_value_to_local_cpp_value(member) | indent(8)}} 59 {{v8_value_to_local_cpp_value(member) | indent(8)}}
59 {% if member.is_interface_type %} 60 {% if member.is_interface_type %}
60 if (!{{member.name}} && !{{member.name}}Value->IsNull()) { 61 if (!{{member.name}} && !{{member.name}}Value->IsNull()) {
61 exceptionState.throwTypeError("member {{member.name}} is not of type {{member.idl_type}}."); 62 exceptionState.throwTypeError("member {{member.name}} is not of type {{member.idl_type}}.");
62 return; 63 return;
63 } 64 }
64 {% endif %} 65 {% endif %}
65 {% if member.enum_validation_expression %} 66 {% if member.enum_values %}
66 String string = {{member.name}}; 67 {{declare_enum_validation_variable(member.enum_values) | indent(8)}}
67 if (!({{member.enum_validation_expression}})) { 68 if (!isValidEnum({{member.name}}, validValues, {{member.enum_values|leng th}})) {
haraken 2015/03/31 06:11:17 Space around '|'?
68 exceptionState.throwTypeError("member {{member.name}} ('" + string + "') is not a valid enum value."); 69 exceptionState.throwTypeError("member {{member.name}} is not a valid enum value.");
69 return; 70 return;
70 } 71 }
71 {% elif member.is_object %} 72 {% elif member.is_object %}
72 if (!{{member.name}}.isObject()) { 73 if (!{{member.name}}.isObject()) {
73 exceptionState.throwTypeError("member {{member.name}} is not an obje ct."); 74 exceptionState.throwTypeError("member {{member.name}} is not an obje ct.");
74 return; 75 return;
75 } 76 }
76 {% endif %} 77 {% endif %}
77 impl.{{member.setter_name}}({{member.name}}); 78 impl.{{member.setter_name}}({{member.name}});
78 } 79 }
(...skipping 29 matching lines...) Expand all
108 } 109 }
109 110
110 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState) 111 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState)
111 { 112 {
112 {{cpp_class}} impl; 113 {{cpp_class}} impl;
113 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); 114 {{v8_class}}::toImpl(isolate, value, impl, exceptionState);
114 return impl; 115 return impl;
115 } 116 }
116 117
117 } // namespace blink 118 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698