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

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

Issue 537403002: bindings: Renames from/toInternalPointer, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. 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 | Annotate | Revision Log
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 #}
11 {% if method.number_of_required_arguments and not method.overload_index %} 11 {% if method.number_of_required_arguments and not method.overload_index %}
12 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { 12 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) {
13 {{throw_minimum_arity_type_error(method, method.number_of_required_argum ents) | indent(8)}} 13 {{throw_minimum_arity_type_error(method, method.number_of_required_argum ents) | indent(8)}}
14 return; 14 return;
15 } 15 }
16 {% endif %} 16 {% endif %}
17 {% if not method.is_static %} 17 {% if not method.is_static %}
18 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); 18 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
19 {% endif %} 19 {% endif %}
20 {% if method.is_custom_element_callbacks %} 20 {% if method.is_custom_element_callbacks %}
21 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 21 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
22 {% endif %} 22 {% endif %}
23 {# Security checks #} 23 {# Security checks #}
24 {% if method.is_check_security_for_window %} 24 {% if method.is_check_security_for_window %}
25 if (LocalDOMWindow* window = impl->toDOMWindow()) { 25 if (LocalDOMWindow* window = impl->toDOMWindow()) {
26 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window ->frame(), exceptionState)) { 26 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window ->frame(), exceptionState)) {
27 {{throw_from_exception_state(method)}}; 27 {{throw_from_exception_state(method)}};
28 return; 28 return;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 {{throw_from_exception_state(method)}}; 180 {{throw_from_exception_state(method)}};
181 return; 181 return;
182 } 182 }
183 {% elif argument.is_variadic_wrapper_type %} 183 {% elif argument.is_variadic_wrapper_type %}
184 for (int i = {{argument.index}}; i < info.Length(); ++i) { 184 for (int i = {{argument.index}}; i < info.Length(); ++i) {
185 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { 185 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) {
186 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 186 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
187 (argument.index + 1, argument.idl_type)) | in dent(8)}} 187 (argument.index + 1, argument.idl_type)) | in dent(8)}}
188 return; 188 return;
189 } 189 }
190 {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Ob ject>::Cast(info[i]))); 190 {{argument.name}}.append(V8{{argument.idl_type}}::toImpl(v8::Handle<v8::Obje ct>::Cast(info[i])));
191 } 191 }
192 {% else %}{# argument.is_nullable #} 192 {% else %}{# argument.is_nullable #}
193 {{argument.v8_value_to_local_cpp_value}}; 193 {{argument.v8_value_to_local_cpp_value}};
194 {% endif %}{# argument.is_nullable #} 194 {% endif %}{# argument.is_nullable #}
195 {# Type checking, possibly throw a TypeError, per: 195 {# Type checking, possibly throw a TypeError, per:
196 http://www.w3.org/TR/WebIDL/#es-type-mapping #} 196 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
197 {% if argument.has_type_checking_unrestricted %} 197 {% if argument.has_type_checking_unrestricted %}
198 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: 198 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per:
199 http://heycam.github.io/webidl/#es-float 199 http://heycam.github.io/webidl/#es-float
200 http://heycam.github.io/webidl/#es-double #} 200 http://heycam.github.io/webidl/#es-double #}
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 {% endif %} 451 {% endif %}
452 {% endif %}{# not method.overloads #} 452 {% endif %}{# not method.overloads #}
453 {% if world_suffix in method.activity_logging_world_list %} 453 {% if world_suffix in method.activity_logging_world_list %}
454 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo ntext()); 454 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo ntext());
455 V8PerContextData* contextData = scriptState->perContextData(); 455 V8PerContextData* contextData = scriptState->perContextData();
456 {% if method.activity_logging_world_check %} 456 {% if method.activity_logging_world_check %}
457 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) 457 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger())
458 {% else %} 458 {% else %}
459 if (contextData && contextData->activityLogger()) { 459 if (contextData && contextData->activityLogger()) {
460 {% endif %} 460 {% endif %}
461 Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle <v8::Value> >(info, 0); 461 Vector<v8::Handle<v8::Value> > loggerArgs = toImplArguments<v8::Handle<v 8::Value> >(info, 0);
462 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na me}}", info.Length(), loggerArgs.data()); 462 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na me}}", info.Length(), loggerArgs.data());
463 } 463 }
464 {% endif %} 464 {% endif %}
465 {% if method.is_custom %} 465 {% if method.is_custom %}
466 {{v8_class}}::{{method.name}}MethodCustom(info); 466 {{v8_class}}::{{method.name}}MethodCustom(info);
467 {% else %} 467 {% else %}
468 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); 468 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
469 {% endif %} 469 {% endif %}
470 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 470 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
471 } 471 }
(...skipping 13 matching lines...) Expand all
485 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} 485 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
486 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method.length}}); 486 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method.length}});
487 487
488 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), info.GetIsolate()); 488 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), info.GetIsolate());
489 if (holder.IsEmpty()) { 489 if (holder.IsEmpty()) {
490 // This is only reachable via |object.__proto__.func|, in which case it 490 // This is only reachable via |object.__proto__.func|, in which case it
491 // has already passed the same origin security check 491 // has already passed the same origin security check
492 v8SetReturnValue(info, privateTemplate->GetFunction()); 492 v8SetReturnValue(info, privateTemplate->GetFunction());
493 return; 493 return;
494 } 494 }
495 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); 495 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
496 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) { 496 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
497 static int sharedTemplateKey; // This address is used for a key to look up the dom template. 497 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
498 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method.length}}); 498 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method.length}});
499 v8SetReturnValue(info, sharedTemplate->GetFunction()); 499 v8SetReturnValue(info, sharedTemplate->GetFunction());
500 return; 500 return;
501 } 501 }
502 502
503 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #} 503 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #}
504 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "{{method.name}}")); 504 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "{{method.name}}"));
505 if (!hiddenValue.IsEmpty()) { 505 if (!hiddenValue.IsEmpty()) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 if method.is_per_world_bindings else '0' %} 641 if method.is_per_world_bindings else '0' %}
642 {% set property_attribute = 642 {% set property_attribute =
643 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) 643 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es)
644 if method.property_attributes else 'v8::None' %} 644 if method.property_attributes else 'v8::None' %}
645 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} 645 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %}
646 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { 646 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = {
647 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}}, 647 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}},
648 }; 648 };
649 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); 649 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate);
650 {%- endmacro %} 650 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.cpp ('k') | Source/bindings/tests/results/V8SVGTestInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698