Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #} |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 {% else %} | 404 {% else %} |
| 405 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); | 405 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); |
| 406 {% endif %} | 406 {% endif %} |
| 407 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 407 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 408 } | 408 } |
| 409 {% endfilter %} | 409 {% endfilter %} |
| 410 {% endmacro %} | 410 {% endmacro %} |
| 411 | 411 |
| 412 | 412 |
| 413 {##############################################################################} | 413 {##############################################################################} |
| 414 {% macro method_length(method) %} | |
| 415 {% if method.overloads %} | |
| 416 {{method.overloads.minarg}} | |
|
Jens Widell
2014/06/02 08:46:43
This is of course possibly incorrect if the "short
Nils Barth (inactive)
2014/06/04 07:22:02
Good catch!
I assume this can't be fixed without g
Jens Widell
2014/06/04 07:38:36
I guess we could generate a simple per-method help
Nils Barth (inactive)
2014/06/04 08:12:01
More seriously, the issue of implementing JS prope
| |
| 417 {%- else %} | |
| 418 {{method.number_of_required_or_variadic_arguments}} | |
|
Jens Widell
2014/05/27 12:11:21
This value is actually wrong per spec. It counts a
jsbell
2014/05/27 18:10:50
IMHO, we might as well fix it. (If not, we should
| |
| 419 {%- endif %} | |
| 420 {% endmacro %} | |
| 421 | |
| 422 | |
| 423 {##############################################################################} | |
| 414 {% macro origin_safe_method_getter(method, world_suffix) %} | 424 {% macro origin_safe_method_getter(method, world_suffix) %} |
| 415 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) | 425 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) |
| 416 { | 426 { |
| 417 {% set signature = 'v8::Local<v8::Signature>()' | 427 {% set signature = 'v8::Local<v8::Signature>()' |
| 418 if method.is_do_not_check_signature else | 428 if method.is_do_not_check_signature else |
| 419 'v8::Signature::New(isolate, %s::domTemplate(isolate))' % v8_class %} | 429 'v8::Signature::New(isolate, %s::domTemplate(isolate))' % v8_class %} |
| 420 v8::Isolate* isolate = info.GetIsolate(); | 430 v8::Isolate* isolate = info.GetIsolate(); |
| 421 static int domTemplateKey; // This address is used for a key to look up the dom template. | 431 static int domTemplateKey; // This address is used for a key to look up the dom template. |
| 422 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 432 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 423 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} | 433 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} |
| 424 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method.number_of_required_or_variadic_argument s}}); | 434 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method_length(method)}}); |
| 425 | 435 |
| 426 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), isolate); | 436 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), isolate); |
| 427 if (holder.IsEmpty()) { | 437 if (holder.IsEmpty()) { |
| 428 // This is only reachable via |object.__proto__.func|, in which case it | 438 // This is only reachable via |object.__proto__.func|, in which case it |
| 429 // has already passed the same origin security check | 439 // has already passed the same origin security check |
| 430 v8SetReturnValue(info, privateTemplate->GetFunction()); | 440 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 431 return; | 441 return; |
| 432 } | 442 } |
| 433 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); | 443 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); |
| 434 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNot ReportSecurityError)) { | 444 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNot ReportSecurityError)) { |
| 435 static int sharedTemplateKey; // This address is used for a key to look up the dom template. | 445 static int sharedTemplateKey; // This address is used for a key to look up the dom template. |
| 436 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method.number_of_required_or_variadic_ar guments}}); | 446 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method_length(method)}}); |
| 437 v8SetReturnValue(info, sharedTemplate->GetFunction()); | 447 v8SetReturnValue(info, sharedTemplate->GetFunction()); |
| 438 return; | 448 return; |
| 439 } | 449 } |
| 440 | 450 |
| 441 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #} | 451 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #} |
| 442 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(isolate, "{{method.name}}")); | 452 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(isolate, "{{method.name}}")); |
| 443 if (!hiddenValue.IsEmpty()) { | 453 if (!hiddenValue.IsEmpty()) { |
| 444 v8SetReturnValue(info, hiddenValue); | 454 v8SetReturnValue(info, hiddenValue); |
| 445 return; | 455 return; |
| 446 } | 456 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 {% endif %} | 554 {% endif %} |
| 545 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); | 555 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); |
| 546 {% if is_constructor_raises_exception %} | 556 {% if is_constructor_raises_exception %} |
| 547 if (exceptionState.throwIfNeeded()) | 557 if (exceptionState.throwIfNeeded()) |
| 548 return; | 558 return; |
| 549 {% endif %} | 559 {% endif %} |
| 550 | 560 |
| 551 {{generate_constructor_wrapper(constructor) | indent}} | 561 {{generate_constructor_wrapper(constructor) | indent}} |
| 552 } | 562 } |
| 553 {% endmacro %} | 563 {% endmacro %} |
| OLD | NEW |