Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 {% endfilter %} | 63 {% endfilter %} |
| 64 {% endmacro %} | 64 {% endmacro %} |
| 65 | 65 |
| 66 | 66 |
| 67 {######################################} | 67 {######################################} |
| 68 {% macro generate_arguments(method, world_suffix) %} | 68 {% macro generate_arguments(method, world_suffix) %} |
| 69 {% for argument in method.arguments %} | 69 {% for argument in method.arguments %} |
| 70 {{generate_argument_var_declaration(argument)}}; | 70 {{generate_argument_var_declaration(argument)}}; |
| 71 {% endfor %} | 71 {% endfor %} |
| 72 { | 72 { |
| 73 {% if method.has_optional_argument_without_default_value %} | |
| 74 {# Count the effective number of arguments. (arg1, arg2, undefined) is | |
| 75 interpreted as two arguments are passed and (arg1, undefined, arg3) is | |
| 76 interpreted as three arguments are passed. #} | |
| 77 int numArgsPassed = info.Length(); | |
| 78 while (numArgsPassed > 0) { | |
| 79 if (!info[numArgsPassed - 1]->IsUndefined()) | |
| 80 break; | |
| 81 --numArgsPassed; | |
| 82 } | |
| 83 {% endif %} | |
| 73 {% for argument in method.arguments %} | 84 {% for argument in method.arguments %} |
| 74 {% if argument.set_default_value %} | 85 {% if argument.set_default_value %} |
| 75 if (!info[{{argument.index}}]->IsUndefined()) { | 86 if (!info[{{argument.index}}]->IsUndefined()) { |
| 76 {{generate_argument(method, argument, world_suffix) | indent(8)}} | 87 {{generate_argument(method, argument, world_suffix) | indent(8)}} |
| 77 } else { | 88 } else { |
| 78 {{argument.set_default_value}}; | 89 {{argument.set_default_value}}; |
| 79 } | 90 } |
| 80 {% else %} | 91 {% else %} |
| 81 {{generate_argument(method, argument, world_suffix) | indent}} | 92 {{generate_argument(method, argument, world_suffix) | indent}} |
| 82 {% endif %} | 93 {% endif %} |
| 83 {% endfor %} | 94 {% endfor %} |
| 84 } | 95 } |
| 85 {% endmacro %} | 96 {% endmacro %} |
| 86 | 97 |
| 87 | 98 |
| 88 {######################################} | 99 {######################################} |
| 89 {% macro generate_argument_var_declaration(argument) %} | 100 {% macro generate_argument_var_declaration(argument) %} |
| 90 {# FIXME: remove EventListener special case #} | 101 {# FIXME: remove EventListener special case #} |
| 91 {% if argument.idl_type == 'EventListener' %} | 102 {% if argument.idl_type == 'EventListener' %} |
| 92 RefPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}} | 103 RefPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}} |
| 93 {%- else %} | 104 {%- else %} |
| 94 {{argument.cpp_type}} {{argument.name}} | 105 {{argument.cpp_type}} {{argument.name}} |
| 95 {%- endif %}{# argument.idl_type == 'EventListener' #} | 106 {%- endif %}{# argument.idl_type == 'EventListener' #} |
| 96 {% endmacro %} | 107 {% endmacro %} |
| 97 | 108 |
| 98 | 109 |
| 99 {######################################} | 110 {######################################} |
| 100 {% macro generate_argument(method, argument, world_suffix) %} | 111 {% macro generate_argument(method, argument, world_suffix) %} |
| 101 {% if argument.is_optional and not argument.has_default and | 112 {% if argument.is_optional and not argument.has_default and |
|
bashi
2015/11/26 23:37:18
{% if method.has_optional_argument_without_default
Yuki
2015/11/30 06:53:23
It's not |method|, but done.
| |
| 102 not argument.is_dictionary and | 113 not argument.is_dictionary and |
| 103 not argument.is_callback_interface %} | 114 not argument.is_callback_interface %} |
| 104 {# Optional arguments without a default value generate an early call with | 115 {# Optional arguments without a default value generate an early call with |
| 105 fewer arguments if they are omitted. | 116 fewer arguments if they are omitted. |
| 106 Optional Dictionary arguments default to empty dictionary. #} | 117 Optional Dictionary arguments default to empty dictionary. #} |
| 107 if (UNLIKELY(info.Length() <= {{argument.index}})) { | 118 if (UNLIKELY(numArgsPassed <= {{argument.index}})) { |
| 108 {% if world_suffix %} | 119 {% if world_suffix %} |
| 109 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} | 120 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} |
| 110 {% else %} | 121 {% else %} |
| 111 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} | 122 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} |
| 112 {% endif %} | 123 {% endif %} |
| 113 {% if argument.has_event_listener_argument %} | 124 {% if argument.has_event_listener_argument %} |
| 114 {{hidden_dependency_action(method.name) | indent}} | 125 {{hidden_dependency_action(method.name) | indent}} |
| 115 {% endif %} | 126 {% endif %} |
| 116 return; | 127 return; |
| 117 } | 128 } |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all | 690 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all |
| 680 if method.overloads else | 691 if method.overloads else |
| 681 method.runtime_enabled_function) %} | 692 method.runtime_enabled_function) %} |
| 682 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; | 693 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; |
| 683 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); | 694 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); |
| 684 {% endfilter %}{# runtime_enabled() #} | 695 {% endfilter %}{# runtime_enabled() #} |
| 685 {% endfilter %}{# exposed() #} | 696 {% endfilter %}{# exposed() #} |
| 686 {% endfor %} | 697 {% endfor %} |
| 687 {% endif %} | 698 {% endif %} |
| 688 {%- endmacro %} | 699 {%- endmacro %} |
| OLD | NEW |