Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} | 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} |
| 2 | 2 |
| 3 {##############################################################################} | 3 {##############################################################################} |
| 4 {% macro attribute_getter(attribute, world_suffix) %} | 4 {% macro attribute_getter(attribute, world_suffix) %} |
| 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
| 6 {%- if attribute.is_data_type_property %} | 6 {%- if attribute.is_data_type_property %} |
| 7 const v8::PropertyCallbackInfo<v8::Value>& info | 7 const v8::PropertyCallbackInfo<v8::Value>& info |
| 8 {%- else %} | 8 {%- else %} |
| 9 const v8::FunctionCallbackInfo<v8::Value>& info | 9 const v8::FunctionCallbackInfo<v8::Value>& info |
| 10 {%- endif %}) { | 10 {%- endif %}) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 {% endif %} | 401 {% endif %} |
| 402 {{attribute.cpp_setter}}; | 402 {{attribute.cpp_setter}}; |
| 403 | 403 |
| 404 {% if attribute.cached_attribute_validation_method %} | 404 {% if attribute.cached_attribute_validation_method %} |
| 405 // [CachedAttribute] | 405 // [CachedAttribute] |
| 406 // Invalidate the cached value. | 406 // Invalidate the cached value. |
| 407 V8PrivateProperty::GetSymbol( | 407 V8PrivateProperty::GetSymbol( |
| 408 isolate, "{{cpp_class}}#{{attribute.name.capitalize()}}") | 408 isolate, "{{cpp_class}}#{{attribute.name.capitalize()}}") |
| 409 .DeleteProperty(holder, v8::Undefined(isolate)); | 409 .DeleteProperty(holder, v8::Undefined(isolate)); |
| 410 {% endif %} | 410 {% endif %} |
| 411 | |
| 412 {% if attribute.is_lazy_cached_accessor %} | |
|
haraken
2017/05/10 04:21:13
Can we factor out these changes to a later CL?
nverne
2017/05/10 05:00:54
Deleted this code.
| |
| 413 // Call cache init callback to store the correct private property. | |
| 414 {{attribute.name}}CacheInitCallback(info.GetIsolate(), holder); | |
| 415 {% endif %} | |
| 411 } | 416 } |
| 412 {% endfilter %}{# format_remove_duplicates #} | 417 {% endfilter %}{# format_remove_duplicates #} |
| 413 {% endmacro %} | 418 {% endmacro %} |
| 414 | 419 |
| 415 | 420 |
| 416 {##############################################################################} | 421 {##############################################################################} |
| 417 {% macro attribute_setter_callback(attribute, world_suffix) %} | 422 {% macro attribute_setter_callback(attribute, world_suffix) %} |
| 418 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s uffix}}( | 423 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s uffix}}( |
| 419 {%- if attribute.is_data_type_property %} | 424 {%- if attribute.is_data_type_property %} |
| 420 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf o<void>& info | 425 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf o<void>& info |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 {% elif attribute.has_cross_origin_setter %} | 467 {% elif attribute.has_cross_origin_setter %} |
| 463 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter(v8Value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Holder())); | 468 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter(v8Value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Holder())); |
| 464 {% else %} | 469 {% else %} |
| 465 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter{{world_s uffix}}(v8Value, info); | 470 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter{{world_s uffix}}(v8Value, info); |
| 466 {% endif %} | 471 {% endif %} |
| 467 } | 472 } |
| 468 {% endmacro %} | 473 {% endmacro %} |
| 469 | 474 |
| 470 | 475 |
| 471 {##############################################################################} | 476 {##############################################################################} |
| 472 {% macro attribute_configuration(attribute) %} | 477 {% macro build_attribute_or_accessor_configuration(attribute, is_attribute_confi guration) %} |
|
haraken
2017/05/10 04:21:13
For readability, avoid using a boolean type. You c
nverne
2017/05/10 05:00:53
Done
| |
| 473 {% from 'utilities.cpp.tmpl' import property_location %} | 478 {% from 'utilities.cpp.tmpl' import property_location %} |
| 474 {% if attribute.constructor_type %} | 479 {% if attribute.constructor_type %} |
| 475 {% if attribute.needs_constructor_getter_callback %} | 480 {% if attribute.needs_constructor_getter_callback %} |
| 476 {% set getter_callback = '%s::%sConstructorGetterCallback' % (v8_class_or_pa rtial, attribute.name) %} | 481 {% set getter_callback = '%s::%sConstructorGetterCallback' % (v8_class_or_pa rtial, attribute.name) %} |
| 477 {% else %} | 482 {% else %} |
| 478 {% set getter_callback = 'V8%s::NamedConstructorAttributeGetter' % (attribut e.constructor_type) | 483 {% set getter_callback = 'V8%s::NamedConstructorAttributeGetter' % (attribut e.constructor_type) |
| 479 if attribute.is_named_constructor else 'V8ConstructorAttributeGetter' %} | 484 if attribute.is_named_constructor else 'V8ConstructorAttributeGetter' %} |
| 480 {% endif %} | 485 {% endif %} |
| 481 {% set setter_callback = 'nullptr' %} | 486 {% set setter_callback = 'nullptr' %} |
| 482 {% else %}{# regular attributes #} | 487 {% else %}{# regular attributes #} |
| 483 {% set getter_callback = '%s::%sAttributeGetterCallback' % | 488 {% set getter_callback = '%s::%sAttributeGetterCallback' % |
| 484 (v8_class_or_partial, attribute.name) %} | 489 (v8_class_or_partial, attribute.name) %} |
| 485 {% set setter_callback = '%s::%sAttributeSetterCallback' % | 490 {% set setter_callback = '%s::%sAttributeSetterCallback' % |
| 486 (v8_class_or_partial, attribute.name) | 491 (v8_class_or_partial, attribute.name) |
| 487 if attribute.has_setter else 'nullptr' %} | 492 if attribute.has_setter else 'nullptr' %} |
| 488 {% endif %} | 493 {% endif %} |
| 489 {% set wrapper_type_info = | 494 {% set wrapper_type_info = |
| 490 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % attribute.constr uctor_type | 495 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % attribute.constr uctor_type |
| 491 if attribute.constructor_type else 'nullptr' %} | 496 if attribute.constructor_type else 'nullptr' %} |
| 492 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 497 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 493 ' | '.join(attribute.property_attributes) %} | 498 ' | '.join(attribute.property_attributes) %} |
| 494 {% set cached_accessor_callback = | 499 {% set cached_property_key = |
| 495 '%s::%sCachedPropertyKey' % (v8_class_or_partial, attribute.name) | 500 '%s::%sCachedPropertyKey' % (v8_class_or_partial, attribute.name) |
| 496 if attribute.is_cached_accessor else | 501 if attribute.is_cached_accessor else |
| 497 'nullptr' %} | 502 'nullptr' %} |
| 498 {% set holder_check = 'V8DOMConfiguration::kDoNotCheckHolder' | 503 {% set holder_check = 'V8DOMConfiguration::kDoNotCheckHolder' |
| 499 if attribute.is_lenient_this else 'V8DOMConfiguration::kCheckHolder' %} | 504 if attribute.is_lenient_this else 'V8DOMConfiguration::kCheckHolder' %} |
| 500 {% if attribute.is_per_world_bindings %} | 505 {% if attribute.is_per_world_bindings %} |
| 501 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} | 506 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} |
| 502 {% set setter_callback_for_main_world = | 507 {% set setter_callback_for_main_world = |
| 503 '%sForMainWorld' % setter_callback | 508 '%sForMainWorld' % setter_callback |
| 504 if attribute.has_setter else 'nullptr' %} | 509 if attribute.has_setter else 'nullptr' %} |
| 505 {"{{attribute.name}}", {{getter_callback_for_main_world}}, {{setter_callback_for _main_world}}, {{cached_accessor_callback}}, {{wrapper_type_info}}, {{property_a ttribute}}, {{property_location(attribute)}}, {{holder_check}}, V8DOMConfigurati on::kMainWorld}, | 510 {% endif %} |
| 506 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{cached_access or_callback}}, {{wrapper_type_info}}, {{property_attribute}}, {{property_locatio n(attribute)}}, {{holder_check}}, V8DOMConfiguration::kNonMainWorlds} | 511 |
| 507 {%- else %} | 512 |
| 508 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{cached_access or_callback}}, {{wrapper_type_info}}, {{property_attribute}}, {{property_locatio n(attribute)}}, {{holder_check}}, V8DOMConfiguration::kAllWorlds} | 513 {% set config_pre = { |
|
haraken
2017/05/10 04:21:13
I'd prefer simply emitting the 6 patterns here ins
nverne
2017/05/10 05:00:53
I think that's likely to be more confusing/error p
peria
2017/05/10 05:20:50
+1 to merge some duplicates, but this implementati
| |
| 509 {%- endif %} | 514 "main" : [ |
| 510 {%- endmacro %} | 515 '"%s"' % attribute.name, |
| 516 getter_callback_for_main_world, | |
| 517 setter_callback_for_main_world, | |
| 518 ], | |
| 519 "non_main" : [ | |
| 520 '"%s"' % attribute.name, | |
| 521 getter_callback, | |
| 522 setter_callback, | |
| 523 ], | |
| 524 } %} | |
| 525 | |
| 526 {% set accessor_only_fields = [] if is_attribute_configuration else [ | |
| 527 cached_property_key, | |
| 528 ] %} | |
| 529 | |
| 530 {% set config_post = [ | |
| 531 wrapper_type_info, | |
| 532 property_attribute, | |
| 533 property_location(attribute), | |
| 534 holder_check, | |
| 535 ] %} | |
| 536 | |
| 537 {% if attribute.is_per_world_bindings %} | |
| 538 {% set main_config_list = config_pre["main"] + accessor_only_fields + | |
| 539 config_post + ['V8DOMConfiguration::kMainWorld'] %} | |
| 540 {% set non_main_config_list = config_pre["non_main"] + accessor_only_fields + | |
| 541 config_post + ['V8DOMConfiguration::kNonMainWorlds'] %} | |
| 542 {# Emit for main world then non-main.#} | |
| 543 {{'{'}}{{main_config_list | join(', ')}}{{'}'}} | |
|
peria
2017/05/10 05:20:50
no indentation is needed. it'll be adjusted by ind
| |
| 544 {{','}} | |
|
peria
2017/05/10 05:20:50
keep a comma at the tail of the previous line,
and
| |
| 545 {{'{'}}{{non_main_config_list | join(', ')}}{{'}'}} | |
| 546 {% else %} | |
| 547 {% set all_worlds_config_list = config_pre["non_main"] + accessor_only_fields + | |
| 548 config_post + ['V8DOMConfiguration::kAllWorlds'] %} | |
| 549 {# Emit only for all worlds #} | |
| 550 {{'{'}}{{all_worlds_config_list | join(', ')}}{{'}'}} | |
|
peria
2017/05/10 05:20:50
no indent
| |
| 551 {% endif %} | |
| 552 {% endmacro %} | |
| 553 | |
| 554 {##############################################################################} | |
| 555 {% macro attribute_configuration(attribute) %} | |
| 556 {% set is_attribute_configuration = true %} | |
| 557 {{build_attribute_or_accessor_configuration(attribute, is_attribute_configuratio n)}} | |
| 558 {% endmacro %} | |
| 559 | |
| 560 {##############################################################################} | |
| 561 {% macro accessor_configuration(attribute) %} | |
| 562 {% set is_attribute_configuration = false %} | |
| 563 {{build_attribute_or_accessor_configuration(attribute, is_attribute_configuratio n)}} | |
| 564 {% endmacro %} | |
| 511 | 565 |
| 512 {##############################################################################} | 566 {##############################################################################} |
| 513 {% macro install_conditionally_enabled_attributes_on_prototype() %} | 567 {% macro install_conditionally_enabled_attributes_on_prototype() %} |
| 514 {% for attribute in attributes if (attribute.exposed_test or attribute.secure_co ntext_test) and attribute.on_prototype %} | 568 {% for attribute in attributes if (attribute.exposed_test or attribute.secure_co ntext_test) and attribute.on_prototype %} |
| 515 {% filter exposed(attribute.exposed_test) %} | 569 {% filter exposed(attribute.exposed_test) %} |
| 516 {% filter secure_context(attribute.secure_context_test) %} | 570 {% filter secure_context(attribute.secure_context_test) %} |
| 517 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %} | 571 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %} |
| 518 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = { | 572 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = { |
| 519 {{attribute_configuration(attribute)}} | 573 {{accessor_configuration(attribute)}} |
| 520 }; | 574 }; |
| 521 for (const auto& accessorConfig : accessorConfiguration) | 575 for (const auto& accessorConfig : accessorConfiguration) |
| 522 V8DOMConfiguration::InstallAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig); | 576 V8DOMConfiguration::InstallAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig); |
| 523 {% endfilter %}{# runtime_enabled #} | 577 {% endfilter %}{# runtime_enabled #} |
| 524 {% endfilter %}{# secure_context #} | 578 {% endfilter %}{# secure_context #} |
| 525 {% endfilter %}{# exposed #} | 579 {% endfilter %}{# exposed #} |
| 526 {% endfor %} | 580 {% endfor %} |
| 527 {% endmacro %} | 581 {% endmacro %} |
| OLD | NEW |