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

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

Issue 210663003: Use |isolate| local variable in bindings, clean up comments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update extension Created 6 years, 9 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 {% if method.number_of_required_arguments %} 10 {% if method.number_of_required_arguments %}
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 {% endmacro %} 314 {% endmacro %}
315 315
316 316
317 {##############################################################################} 317 {##############################################################################}
318 {% macro origin_safe_method_getter(method, world_suffix) %} 318 {% macro origin_safe_method_getter(method, world_suffix) %}
319 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) 319 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info)
320 { 320 {
321 {% set signature = 'v8::Local<v8::Signature>()' 321 {% set signature = 'v8::Local<v8::Signature>()'
322 if method.is_do_not_check_signature else 322 if method.is_do_not_check_signature else
323 'v8::Signature::New(info.GetIsolate(), %s::domTemplate(in fo.GetIsolate()))' % v8_class %} 323 'v8::Signature::New(info.GetIsolate(), %s::domTemplate(in fo.GetIsolate()))' % v8_class %}
324 {# FIXME: don't call GetIsolate() so often #} 324 v8::Isolate* isolate = info.GetIsolate();
325 static int domTemplateKey; // This address is used for a key to look up the dom template. 325 static int domTemplateKey; // This address is used for a key to look up the dom template.
326 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 326 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
327 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} 327 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
328 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}}); 328 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}});
329 329
330 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), info.GetIsolate()); 330 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), isolate);
331 if (holder.IsEmpty()) { 331 if (holder.IsEmpty()) {
332 // This is only reachable via |object.__proto__.func|, in which case it 332 // This is only reachable via |object.__proto__.func|, in which case it
333 // has already passed the same origin security check 333 // has already passed the same origin security check
334 v8SetReturnValue(info, privateTemplate->GetFunction()); 334 v8SetReturnValue(info, privateTemplate->GetFunction());
335 return; 335 return;
336 } 336 }
337 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); 337 {{cpp_class}}* impl = {{v8_class}}::toNative(holder);
338 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) { 338 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNot ReportSecurityError)) {
339 static int sharedTemplateKey; // This address is used for a key to look up the dom template. 339 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
340 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}}); 340 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}});
341 v8SetReturnValue(info, sharedTemplate->GetFunction()); 341 v8SetReturnValue(info, sharedTemplate->GetFunction());
342 return; 342 return;
343 } 343 }
344 344
345 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicStrin g(info.GetIsolate(), "{{method.name}}")); 345 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicStrin g(isolate, "{{method.name}}"));
346 if (!hiddenValue.IsEmpty()) { 346 if (!hiddenValue.IsEmpty()) {
347 v8SetReturnValue(info, hiddenValue); 347 v8SetReturnValue(info, hiddenValue);
348 return; 348 return;
349 } 349 }
350 350
351 v8SetReturnValue(info, privateTemplate->GetFunction()); 351 v8SetReturnValue(info, privateTemplate->GetFunction());
352 } 352 }
353 353
354 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 354 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
355 { 355 {
356 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 356 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
357 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info); 357 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info);
358 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 358 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
359 } 359 }
360 {% endmacro %} 360 {% endmacro %}
361 361
362 362
363 {##############################################################################} 363 {##############################################################################}
364 {% macro generate_constructor(constructor) %} 364 {% macro generate_constructor(constructor) %}
365 static void constructor{{constructor.overload_index}}(const v8::FunctionCallback Info<v8::Value>& info) 365 static void constructor{{constructor.overload_index}}(const v8::FunctionCallback Info<v8::Value>& info)
366 { 366 {
367 v8::Isolate* isolate = info.GetIsolate();
367 {% if constructor.has_exception_state %} 368 {% if constructor.has_exception_state %}
368 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), info.GetIsolate()); 369 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), isolate);
369 {% endif %} 370 {% endif %}
370 {% if interface_length and not constructor.overload_index %} 371 {% if interface_length and not constructor.overload_index %}
371 {# FIXME: remove UNLIKELY: constructors are expensive, so no difference. #} 372 {# FIXME: remove UNLIKELY: constructors are expensive, so no difference. #}
372 if (UNLIKELY(info.Length() < {{interface_length}})) { 373 if (UNLIKELY(info.Length() < {{interface_length}})) {
373 {{throw_type_error(constructor, 374 {{throw_type_error(constructor,
374 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % 375 'ExceptionMessages::notEnoughArguments(%s, info.Length())' %
375 interface_length) | indent(8)}} 376 interface_length) | indent(8)}}
376 return; 377 return;
377 } 378 }
378 {% endif %} 379 {% endif %}
379 {% for argument in constructor.arguments %} 380 {% for argument in constructor.arguments %}
380 {{generate_argument(constructor, argument) | indent}} 381 {{generate_argument(constructor, argument) | indent}}
381 {% endfor %} 382 {% endfor %}
382 {% if is_constructor_call_with_execution_context %} 383 {% if is_constructor_call_with_execution_context %}
383 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); 384 ExecutionContext* context = currentExecutionContext(isolate);
384 {% endif %} 385 {% endif %}
385 {% if is_constructor_call_with_document %} 386 {% if is_constructor_call_with_document %}
386 Document& document = *toDocument(currentExecutionContext(info.GetIsolate())) ; 387 Document& document = *toDocument(currentExecutionContext(isolate));
387 {% endif %} 388 {% endif %}
388 {{ref_ptr}}<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor.argume nt_list | join(', ')}}); 389 {{ref_ptr}}<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor.argume nt_list | join(', ')}});
389 {% if is_constructor_raises_exception %} 390 {% if is_constructor_raises_exception %}
390 if (exceptionState.throwIfNeeded()) 391 if (exceptionState.throwIfNeeded())
391 return; 392 return;
392 {% endif %} 393 {% endif %}
393 394
394 {% if has_custom_wrap %} 395 {% if has_custom_wrap %}
395 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late()); 396 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate);
396 {% else %} 397 {% else %}
397 v8::Handle<v8::Object> wrapper = info.Holder(); 398 v8::Handle<v8::Object> wrapper = info.Holder();
398 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configuration}} ); 399 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}});
399 {% endif %} 400 {% endif %}
400 v8SetReturnValue(info, wrapper); 401 v8SetReturnValue(info, wrapper);
401 } 402 }
402 {% endmacro %} 403 {% endmacro %}
403 404
404 405
405 {##############################################################################} 406 {##############################################################################}
406 {% macro named_constructor_callback(constructor) %} 407 {% macro named_constructor_callback(constructor) %}
407 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info) 408 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info)
408 { 409 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 446
446 {% if has_custom_wrap %} 447 {% if has_custom_wrap %}
447 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late()); 448 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late());
448 {% else %} 449 {% else %}
449 v8::Handle<v8::Object> wrapper = info.Holder(); 450 v8::Handle<v8::Object> wrapper = info.Holder();
450 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_conf iguration}}); 451 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_conf iguration}});
451 {% endif %} 452 {% endif %}
452 v8SetReturnValue(info, wrapper); 453 v8SetReturnValue(info, wrapper);
453 } 454 }
454 {% endmacro %} 455 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/results/V8SVGTestInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698