Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% from 'conversions.cpp' import v8_value_to_local_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) |
| 11 {% endif %} | 11 {% endif %} |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 and 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_nullable %} && !isUndefinedOrNull(info[{ {argument.index}}]){% endif %}) { |
| 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)) | indent }} |
| 198 } | 198 } |
| 199 {% elif argument.enum_validation_expression %} | 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 String string = {{argument.name}}; | 201 {{declare_enum_validation_variable(argument.enum_values)}} |
| 202 if (!({{argument.enum_validation_expression}})) { | 202 if (!isValidEnum({{argument.name}}, validValues, {{argument.enum_values|length}} )) { |
|
haraken
2015/03/31 06:11:17
Space around '|'?
| |
| 203 {{throw_type_error(method, | 203 {{throw_type_error(method, |
| 204 '"parameter %s (\'" + string + "\') is not a valid enum value."' % | 204 '"parameter %s is not a valid enum value."' % |
| 205 (argument.index + 1)) | indent}} | 205 (argument.index + 1)) | indent}} |
| 206 } | 206 } |
| 207 {% elif argument.idl_type == 'Promise' %} | 207 {% elif argument.idl_type == 'Promise' %} |
| 208 {# We require this for our implementation of promises, though not in spec: | 208 {# We require this for our implementation of promises, though not in spec: |
| 209 http://heycam.github.io/webidl/#es-promise #} | 209 http://heycam.github.io/webidl/#es-promise #} |
| 210 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { | 210 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { |
| 211 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % | 211 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % |
| 212 (argument.index + 1, argument.name)) | indent}} | 212 (argument.index + 1, argument.name)) | indent}} |
| 213 } | 213 } |
| 214 {% endif %} | 214 {% endif %} |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 if method.overloads else | 653 if method.overloads else |
| 654 method.runtime_enabled_function) %} | 654 method.runtime_enabled_function) %} |
| 655 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 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()); |
| 656 {% endfilter %}{# runtime_enabled() #} | 656 {% endfilter %}{# runtime_enabled() #} |
| 657 {% endfilter %}{# exposed() #} | 657 {% endfilter %}{# exposed() #} |
| 658 {% endfilter %}{# per_context_enabled() #} | 658 {% endfilter %}{# per_context_enabled() #} |
| 659 {% endfor %} | 659 {% endfor %} |
| 660 {% endif %} | 660 {% endif %} |
| 661 } | 661 } |
| 662 {%- endmacro %} | 662 {%- endmacro %} |
| OLD | NEW |