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

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

Issue 101443002: IDL compiler: remove redundant '_name' from template parameters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {% if method.name in ['addEventListener', 'removeEventListener'] %} 6 {% if method.name in ['addEventListener', 'removeEventListener'] %}
7 {{add_remove_event_listener_method(method.name) | indent}} 7 {{add_remove_event_listener_method(method.name) | indent}}
8 {% else %} 8 {% else %}
9 {% if method.number_of_required_arguments %} 9 {% if method.number_of_required_arguments %}
10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { 10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) {
11 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ ired_arguments}}, info.Length())), info.GetIsolate()); 11 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ ired_arguments}}, info.Length())), info.GetIsolate());
12 return; 12 return;
13 } 13 }
14 {% endif %} 14 {% endif %}
15 {% if not method.is_static %} 15 {% if not method.is_static %}
16 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); 16 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder());
17 {% endif %} 17 {% endif %}
18 {% if method.is_custom_element_callbacks %} 18 {% if method.is_custom_element_callbacks %}
19 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; 19 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
20 {% endif %} 20 {% endif %}
21 {% if method.is_raises_exception or method.is_check_security_for_frame %} 21 {% if method.is_raises_exception or method.is_check_security_for_frame %}
22 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 22 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
23 {% endif %} 23 {% endif %}
24 {% if method.is_check_security_for_frame %} 24 {% if method.is_check_security_for_frame %}
25 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 25 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
26 exceptionState.throwIfNeeded(); 26 exceptionState.throwIfNeeded();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 102
103 {######################################} 103 {######################################}
104 {% macro add_remove_event_listener_method(method_name) %} 104 {% macro add_remove_event_listener_method(method_name) %}
105 {# Set template values for addEventListener vs. removeEventListener #} 105 {# Set template values for addEventListener vs. removeEventListener #}
106 {% set listener_lookup_type, listener, hidden_dependency_action = 106 {% set listener_lookup_type, listener, hidden_dependency_action =
107 ('ListenerFindOrCreate', 'listener', 'createHiddenDependency') 107 ('ListenerFindOrCreate', 'listener', 'createHiddenDependency')
108 if method_name == 'addEventListener' else 108 if method_name == 'addEventListener' else
109 ('ListenerFindOnly', 'listener.get()', 'removeHiddenDependency') 109 ('ListenerFindOnly', 'listener.get()', 'removeHiddenDependency')
110 %} 110 %}
111 EventTarget* impl = {{v8_class_name}}::toNative(info.Holder()); 111 EventTarget* impl = {{v8_class}}::toNative(info.Holder());
112 if (DOMWindow* window = impl->toDOMWindow()) { 112 if (DOMWindow* window = impl->toDOMWindow()) {
113 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 113 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
114 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptionSta te)) { 114 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptionSta te)) {
115 exceptionState.throwIfNeeded(); 115 exceptionState.throwIfNeeded();
116 return; 116 return;
117 } 117 }
118 if (!window->document()) 118 if (!window->document())
119 return; 119 return;
120 } 120 }
121 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}}); 121 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}});
122 if (listener) { 122 if (listener) {
123 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN ame, info[0]); 123 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN ame, info[0]);
124 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); 124 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue());
125 if (!impl->toNode()) 125 if (!impl->toNode())
126 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class_name}}:: eventListenerCacheIndex, info.GetIsolate()); 126 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event ListenerCacheIndex, info.GetIsolate());
127 } 127 }
128 {% endmacro %} 128 {% endmacro %}
129 129
130 130
131 {######################################} 131 {######################################}
132 {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %} 132 {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %}
133 {% if method.is_call_with_script_state %} 133 {% if method.is_call_with_script_state %}
134 ScriptState* currentState = ScriptState::current(); 134 ScriptState* currentState = ScriptState::current();
135 if (!currentState) 135 if (!currentState)
136 return; 136 return;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 {% if world_suffix in method.activity_logging_world_list %} 200 {% if world_suffix in method.activity_logging_world_list %}
201 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge tCurrentContext()); 201 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge tCurrentContext());
202 if (contextData && contextData->activityLogger()) { 202 if (contextData && contextData->activityLogger()) {
203 {# FIXME: replace toVectorOfArguments with toNativeArguments(info, 0) 203 {# FIXME: replace toVectorOfArguments with toNativeArguments(info, 0)
204 and delete toVectorOfArguments #} 204 and delete toVectorOfArguments #}
205 Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle <v8::Value> >(info, 0); 205 Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle <v8::Value> >(info, 0);
206 contextData->activityLogger()->log("{{interface_name}}.{{method.name}}", info.Length(), loggerArgs.data(), "Method"); 206 contextData->activityLogger()->log("{{interface_name}}.{{method.name}}", info.Length(), loggerArgs.data(), "Method");
207 } 207 }
208 {% endif %} 208 {% endif %}
209 {% if method.is_custom %} 209 {% if method.is_custom %}
210 {{v8_class_name}}::{{method.name}}MethodCustom(info); 210 {{v8_class}}::{{method.name}}MethodCustom(info);
211 {% else %} 211 {% else %}
212 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info); 212 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
213 {% endif %} 213 {% endif %}
214 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 214 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
215 } 215 }
216 {% endfilter %} 216 {% endfilter %}
217 {% endmacro %} 217 {% endmacro %}
218 218
219 219
220 {##############################################################################} 220 {##############################################################################}
221 {% macro origin_safe_method_getter(method, world_suffix) %} 221 {% macro origin_safe_method_getter(method, world_suffix) %}
222 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) 222 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info)
223 { 223 {
224 {# FIXME: don't call GetIsolate() so often #} 224 {# FIXME: don't call GetIsolate() so often #}
225 // This is only for getting a unique pointer which we can pass to privateTem plate. 225 // This is only for getting a unique pointer which we can pass to privateTem plate.
226 static int privateTemplateUniqueKey; 226 static int privateTemplateUniqueKey;
227 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 227 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
228 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 228 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
229 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} 229 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
230 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, {{cpp_class_name}}V8Internal::{{method .name}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(info.Ge tIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class_n ame}}::wrapperTypeInfo, currentWorldType)), {{method.number_of_required_or_varia dic_arguments}}); 230 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, {{cpp_class}}V8Internal::{{method.name }}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(info.GetIsol ate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class}}::wra pperTypeInfo, currentWorldType)), {{method.number_of_required_or_variadic_argume nts}});
231 231
232 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), currentWorldType)); 232 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class}}::GetTemplate(info.GetIsolate(), currentWorldType));
233 if (holder.IsEmpty()) { 233 if (holder.IsEmpty()) {
234 // This is only reachable via |object.__proto__.func|, in which case it 234 // This is only reachable via |object.__proto__.func|, in which case it
235 // has already passed the same origin security check 235 // has already passed the same origin security check
236 v8SetReturnValue(info, privateTemplate->GetFunction()); 236 v8SetReturnValue(info, privateTemplate->GetFunction());
237 return; 237 return;
238 } 238 }
239 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); 239 {{cpp_class}}* imp = {{v8_class}}::toNative(holder);
240 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) { 240 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
241 static int sharedTemplateUniqueKey; 241 static int sharedTemplateUniqueKey;
242 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, {{cpp_class_name}}V8Internal::{{meth od.name}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(info. GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class _name}}::wrapperTypeInfo, currentWorldType)), {{method.number_of_required_or_var iadic_arguments}}); 242 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, {{cpp_class}}V8Internal::{{method.na me}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(info.GetIs olate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class}}::w rapperTypeInfo, currentWorldType)), {{method.number_of_required_or_variadic_argu ments}});
243 v8SetReturnValue(info, sharedTemplate->GetFunction()); 243 v8SetReturnValue(info, sharedTemplate->GetFunction());
244 return; 244 return;
245 } 245 }
246 246
247 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "{{method.name}}", v8::String::kInternalizedString )); 247 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "{{method.name}}", v8::String::kInternalizedString ));
248 if (!hiddenValue.IsEmpty()) { 248 if (!hiddenValue.IsEmpty()) {
249 v8SetReturnValue(info, hiddenValue); 249 v8SetReturnValue(info, hiddenValue);
250 return; 250 return;
251 } 251 }
252 252
253 v8SetReturnValue(info, privateTemplate->GetFunction()); 253 v8SetReturnValue(info, privateTemplate->GetFunction());
254 } 254 }
255 255
256 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 256 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
257 { 257 {
258 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 258 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
259 {{cpp_class_name}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_s uffix}}(info); 259 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info);
260 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 260 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
261 } 261 }
262 {% endmacro %} 262 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698