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

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

Issue 1079983002: Introduce SmallTypedArray IDL type and use it for bufferSubData (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updates 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, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro generate_method(method, world_suffix) %} 5 {% macro generate_method(method, world_suffix) %}
6 {% filter conditional(method.conditional_string) %} 6 {% filter conditional(method.conditional_string) %}
7 {% if method.returns_promise and method.has_exception_state %} 7 {% if method.returns_promise and method.has_exception_state %}
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e) 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e)
9 {% else %} 9 {% else %}
10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 {{v8_value_to_local_cpp_value(argument)}} 180 {{v8_value_to_local_cpp_value(argument)}}
181 {% elif argument.is_explicit_nullable %} 181 {% elif argument.is_explicit_nullable %}
182 if (!isUndefinedOrNull(info[{{argument.index}}])) { 182 if (!isUndefinedOrNull(info[{{argument.index}}])) {
183 {{v8_value_to_local_cpp_value(argument) | indent}} 183 {{v8_value_to_local_cpp_value(argument) | indent}}
184 } 184 }
185 {% else %}{# argument.is_nullable #} 185 {% else %}{# argument.is_nullable #}
186 {{v8_value_to_local_cpp_value(argument)}} 186 {{v8_value_to_local_cpp_value(argument)}}
187 {% endif %}{# argument.is_nullable #} 187 {% endif %}{# argument.is_nullable #}
188 {# Type checking, possibly throw a TypeError, per: 188 {# Type checking, possibly throw a TypeError, per:
189 http://www.w3.org/TR/WebIDL/#es-type-mapping #} 189 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
190 {% if argument.has_type_checking_interface and not argument.is_variadic_wrapper_ type %} 190 {% if (argument.has_type_checking_interface or argument.is_small_typed_array) an d not argument.is_variadic_wrapper_type %}
191 {# Type checking for wrapper interface types (if interface not implemented, 191 {# Type checking for wrapper interface types (if interface not implemented,
192 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface 192 throw a TypeError), per http://www.w3.org/TR/WebIDL/#es-interface
193 Note: for variadic arguments, the type checking is done for each matched 193 Note: for variadic arguments, the type checking is done for each matched
194 argument instead; see argument.is_variadic_wrapper_type code-path above. #} 194 argument instead; see argument.is_variadic_wrapper_type code-path above. #}
195 if (!{{argument.name}}{% if argument.is_nullable %} && !isUndefinedOrNull(info[{ {argument.index}}]){% endif %}) { 195 if (!{{argument.name}}{%if argument.is_small_typed_array %}.first{% endif %}{% i f argument.is_nullable %} && !isUndefinedOrNull(info[{{argument.index}}]){% endi f %}) {
196 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 196 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
197 (argument.index + 1, argument.idl_type)) | indent }} 197 (argument.index + 1, argument.idl_type if not arg ument.is_small_typed_array else 'ArrayBufferView\' and \'small')) | indent}}
198 } 198 }
199 {% elif argument.enum_values %} 199 {% elif argument.enum_values %}
200 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #} 200 {# Invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
201 {{declare_enum_validation_variable(argument.enum_values)}} 201 {{declare_enum_validation_variable(argument.enum_values)}}
202 if (!isValidEnum({{argument.name}}, validValues, WTF_ARRAY_LENGTH(validValues), "{{argument.enum_type}}", exceptionState)) { 202 if (!isValidEnum({{argument.name}}, validValues, WTF_ARRAY_LENGTH(validValues), "{{argument.enum_type}}", exceptionState)) {
203 exceptionState.throwIfNeeded(); 203 exceptionState.throwIfNeeded();
204 return; 204 return;
205 } 205 }
206 {% elif argument.idl_type == 'Promise' %} 206 {% elif argument.idl_type == 'Promise' %}
207 {# We require this for our implementation of promises, though not in spec: 207 {# We require this for our implementation of promises, though not in spec:
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if method.overloads else 652 if method.overloads else
653 method.runtime_enabled_function) %} 653 method.runtime_enabled_function) %}
654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument s}})->GetFunction()); 654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument s}})->GetFunction());
655 {% endfilter %}{# runtime_enabled() #} 655 {% endfilter %}{# runtime_enabled() #}
656 {% endfilter %}{# exposed() #} 656 {% endfilter %}{# exposed() #}
657 {% endfilter %}{# per_context_enabled() #} 657 {% endfilter %}{# per_context_enabled() #}
658 {% endfor %} 658 {% endfor %}
659 {% endif %} 659 {% endif %}
660 } 660 }
661 {%- endmacro %} 661 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698