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

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

Issue 1008353002: bindings: Reduces the binary size by reducing # of callback functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 5 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
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/templates/interface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %} 1 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_getter(attribute, world_suffix) %} 5 {% macro attribute_getter(attribute, world_suffix) %}
6 {% filter conditional(attribute.conditional_string) %} 6 {% filter conditional(attribute.conditional_string) %}
7 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 7 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
8 {%- if attribute.is_expose_js_accessors %} 8 {%- if attribute.is_expose_js_accessors %}
9 const v8::FunctionCallbackInfo<v8::Value>& info 9 const v8::FunctionCallbackInfo<v8::Value>& info
10 {%- else %} 10 {%- else %}
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info 191 v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info
192 {%- endif %}) 192 {%- endif %})
193 { 193 {
194 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 194 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
195 {% if attribute.deprecate_as %} 195 {% if attribute.deprecate_as %}
196 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), callingExe cutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 196 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), callingExe cutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
197 {% endif %} 197 {% endif %}
198 {% if attribute.measure_as %} 198 {% if attribute.measure_as %}
199 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} ); 199 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} );
200 {% endif %} 200 {% endif %}
201 {% if attribute.is_expose_js_accessors %} 201 v8ConstructorAttributeGetter(property, info);
202 v8ConstructorAttributeGetterAsAccessor(info);
203 {% else %}
204 v8ConstructorAttributeGetterAsProperty(property, info);
205 {% endif %}
206 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 202 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
207 } 203 }
208 {% endfilter %} 204 {% endfilter %}
209 {% endmacro %} 205 {% endmacro %}
210 206
211 207
212 {##############################################################################} 208 {##############################################################################}
213 {% macro attribute_setter(attribute, world_suffix) %} 209 {% macro attribute_setter(attribute, world_suffix) %}
214 {% filter conditional(attribute.conditional_string) %} 210 {% filter conditional(attribute.conditional_string) %}
215 static void {{attribute.name}}AttributeSetter{{world_suffix}}( 211 static void {{attribute.name}}AttributeSetter{{world_suffix}}(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 394 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
399 395
400 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 396 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
401 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}}); 397 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}});
402 } 398 }
403 {% endmacro %} 399 {% endmacro %}
404 400
405 401
406 {##############################################################################} 402 {##############################################################################}
407 {% macro attribute_configuration(attribute) %} 403 {% macro attribute_configuration(attribute) %}
404 {% if attribute.constructor_type %}
408 {% set getter_callback = 405 {% set getter_callback =
409 '%sV8Internal::%sAttributeGetterCallback' % 406 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr ibute.name)
410 (cpp_class_or_partial, attribute.name) 407 if attribute.needs_constructor_getter_callback else
411 if not attribute.constructor_type else ( 408 'v8ConstructorAttributeGetter' %}
412 '%sV8Internal::%sConstructorGetterCallback' %
413 (cpp_class_or_partial, attribute.name)
414 if attribute.needs_constructor_getter_callback else (
415 'v8ConstructorAttributeGetterAsAccessor'
416 if attribute.is_expose_js_accessors else (
417 'v8ConstructorAttributeGetterAsProperty'))) %}
418 {% set getter_callback_for_main_world =
419 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' %
420 (cpp_class_or_partial, attribute.name)
421 if attribute.is_per_world_bindings else '0' %}
422 {% set setter_callback = 409 {% set setter_callback =
423 '%sV8Internal::%sAttributeSetterCallback' % 410 '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_or_partial, attrib ute.name)
411 if attribute.needs_constructor_setter_callback else
412 '%sV8Internal::%sConstructorAttributeSetterCallback' % (cpp_class_or_part ial, cpp_class) %}
413 {% else %}{# regular attributes #}
414 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
415 (cpp_class_or_partial, attribute.name) %}
416 {% set setter_callback = '%sV8Internal::%sAttributeSetterCallback' %
424 (cpp_class_or_partial, attribute.name) 417 (cpp_class_or_partial, attribute.name)
425 if attribute.has_setter else '0' %} 418 if attribute.has_setter else '0' %}
419 {% endif %}
420 {% set getter_callback_for_main_world =
421 '%sForMainWorld' % getter_callback
422 if attribute.is_per_world_bindings else '0' %}
426 {% set setter_callback_for_main_world = 423 {% set setter_callback_for_main_world =
427 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % 424 '%sForMainWorld' % setter_callback
428 (cpp_class_or_partial, attribute.name)
429 if attribute.is_per_world_bindings and attribute.has_setter else '0' %} 425 if attribute.is_per_world_bindings and attribute.has_setter else '0' %}
430 {% set wrapper_type_info = 426 {% set wrapper_type_info =
431 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % 427 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' %
432 attribute.constructor_type 428 attribute.constructor_type
433 if attribute.constructor_type else '0' %} 429 if attribute.constructor_type else '0' %}
434 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % 430 {% set access_control = 'static_cast<v8::AccessControl>(%s)' %
435 ' | '.join(attribute.access_control_list) %} 431 ' | '.join(attribute.access_control_list) %}
436 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 432 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
437 ' | '.join(attribute.property_attributes) %} 433 ' | '.join(attribute.property_attributes) %}
438 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if attribute.only_exposed_to_private_script else 'V8DOMConfiguration::E xposedToAllScripts' %} 434 {% set only_exposed_to_private_script =
435 'V8DOMConfiguration::OnlyExposedToPrivateScript'
436 if attribute.only_exposed_to_private_script else
437 'V8DOMConfiguration::ExposedToAllScripts' %}
439 {% set on_prototype = 'V8DOMConfiguration::OnPrototype' 438 {% set on_prototype = 'V8DOMConfiguration::OnPrototype'
440 if interface_name == 'Window' and attribute.idl_type == 'EventHandler' 439 if interface_name == 'Window' and attribute.idl_type == 'EventHandler'
441 else 'V8DOMConfiguration::OnInstance' %} 440 else 'V8DOMConfiguration::OnInstance' %}
442 {% set attribute_configuration_list = [ 441 {% set attribute_configuration_list = [
443 '"%s"' % attribute.name, 442 '"%s"' % attribute.name,
444 getter_callback, 443 getter_callback,
445 setter_callback, 444 setter_callback,
446 getter_callback_for_main_world, 445 getter_callback_for_main_world,
447 setter_callback_for_main_world, 446 setter_callback_for_main_world,
448 wrapper_type_info, 447 wrapper_type_info,
449 access_control, 448 access_control,
450 property_attribute, 449 property_attribute,
451 only_exposed_to_private_script, 450 only_exposed_to_private_script,
452 ] %} 451 ] %}
453 {% if not attribute.is_expose_js_accessors %} 452 {% if not attribute.is_expose_js_accessors %}
454 {% set attribute_configuration_list = attribute_configuration_list 453 {% set attribute_configuration_list = attribute_configuration_list
455 + [on_prototype] %} 454 + [on_prototype] %}
456 {% endif %} 455 {% endif %}
457 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 456 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
458 {%- endmacro %} 457 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/templates/interface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698