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

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 568703002: IDL: Values for dictionaries should be a object, null or undefined (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove assertion and added a guard 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 unified diff | Download patch
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method, world_suffix) %} 2 {% macro generate_method(method, world_suffix) %}
3 {% filter conditional(method.conditional_string) %} 3 {% filter conditional(method.conditional_string) %}
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
5 { 5 {
6 {# Local variables #} 6 {# Local variables #}
7 {% if method.has_exception_state %} 7 {% if method.has_exception_state %}
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
9 {% endif %} 9 {% endif %}
10 {# Overloaded methods have length checked during overload resolution #} 10 {# Overloaded methods have length checked during overload resolution #}
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 {% elif argument.enum_validation_expression %} 191 {% elif argument.enum_validation_expression %}
192 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} 192 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
193 String string = {{argument.name}}; 193 String string = {{argument.name}};
194 if (!({{argument.enum_validation_expression}})) { 194 if (!({{argument.enum_validation_expression}})) {
195 {{throw_type_error(method, 195 {{throw_type_error(method,
196 '"parameter %s (\'" + string + "\') is not a valid enum value."' % 196 '"parameter %s (\'" + string + "\') is not a valid enum value."' %
197 (argument.index + 1)) | indent}} 197 (argument.index + 1)) | indent}}
198 return; 198 return;
199 } 199 }
200 {% elif argument.idl_type in ['Dictionary', 'Promise'] %} 200 {% elif argument.is_dictionary or argument.idl_type == 'Dictionary' %}
Jens Widell 2014/09/12 09:13:53 It would make sense to have this check before we c
bashi 2014/09/12 10:00:49 Done, and now I can change if -> ASSERT() in toImp
201 {# Dictionaries must have type Undefined, Null or Object: 201 {# Dictionaries must have type Undefined, Null or Object:
202 http://heycam.github.io/webidl/#es-dictionary 202 http://heycam.github.io/webidl/#es-dictionary
203 We also require this for our implementation of promises, though not in spec: 203 FIXME: Remove generic 'Dictionary' special-casing. #}
204 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I sObject()) {
205 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' %
206 (argument.index + 1, argument.name)) | indent}}
207 return;
208 }
209 {% elif argument.idl_type == 'Promise' %}
210 {# We also require this for our implementation of promises, though not in spec:
204 http://heycam.github.io/webidl/#es-promise #} 211 http://heycam.github.io/webidl/#es-promise #}
205 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { 212 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) {
206 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % 213 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' %
207 (argument.index + 1, argument.name)) | indent}} 214 (argument.index + 1, argument.name)) | indent}}
208 return; 215 return;
209 } 216 }
210 {% endif %} 217 {% endif %}
211 {% endmacro %} 218 {% endmacro %}
212 219
213 220
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 if method.is_per_world_bindings else '0' %} 637 if method.is_per_world_bindings else '0' %}
631 {% set property_attribute = 638 {% set property_attribute =
632 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) 639 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es)
633 if method.property_attributes else 'v8::None' %} 640 if method.property_attributes else 'v8::None' %}
634 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} 641 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %}
635 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { 642 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = {
636 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}}, 643 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}},
637 }; 644 };
638 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); 645 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate);
639 {%- endmacro %} 646 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/dictionary_v8.cpp ('k') | Source/bindings/tests/results/core/V8TestDictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698