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

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

Issue 577303002: IDL: Support [DeprecateAs] and [MeasureAs] on constants (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adjusted encrypted-media-constants-expected.txt 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
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/interface_base.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 {##############################################################################}
2 {% macro constant_getter_callback(constant) %}
3 {% filter conditional(constant.conditional_string) %}
4 static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
5 {
6 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
7 {% if constant.deprecate_as %}
8 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use Counter::{{constant.deprecate_as}});
9 {% endif %}
10 {% if constant.measure_as %}
11 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{ constant.measure_as}});
12 {% endif %}
13 {% if constant.idl_type in ('Double', 'Float') %}
14 v8SetReturnValue(info, {{constant.value}});
15 {% elif constant.idl_type == 'String' %}
16 v8SetReturnValueString(info, "{{constant.value}}");
17 {% else %}
18 v8SetReturnValueInt(info, {{constant.value}});
19 {% endif %}
20 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
21 }
22 {% endfilter %}
23 {% endmacro %}
24
25
1 {######################################} 26 {######################################}
2 {% macro install_constants() %} 27 {% macro install_constants() %}
3 {% if has_constant_configuration %} 28 {% if constant_configuration_constants %}
4 {# Normal constants #} 29 {# Normal constants #}
5 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { 30 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = {
6 {% for constant in constants if not constant.runtime_enabled_function %} 31 {% for constant in constant_configuration_constants %}
7 {% if constant.idl_type in ('Double', 'Float') %} 32 {{constant_configuration(constant)}},
8 {% set value = '0, %s, 0' % constant.value %}
9 {% elif constant.idl_type == 'String' %}
10 {% set value = '0, 0, %s' % constant.value %}
11 {% else %}
12 {# 'Short', 'Long' etc. #}
13 {% set value = '%s, 0, 0' % constant.value %}
14 {% endif %}
15 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant. idl_type}}},
16 {% endfor %} 33 {% endfor %}
17 }; 34 };
18 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, {{v8_c lass}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants), isolate); 35 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, {{v8_c lass}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants), isolate);
19 {% endif %} 36 {% endif %}
20 {# Runtime-enabled constants #} 37 {# Runtime-enabled constants #}
21 {% for constant in constants if constant.runtime_enabled_function %} 38 {% for constant in runtime_enabled_constants %}
22 if ({{constant.runtime_enabled_function}}()) { 39 {% filter runtime_enabled(constant.runtime_enabled_function) %}
23 {% if constant.idl_type in ('Double', 'Float') %} 40 static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = { {constant_configuration(constant)}};
24 {% set value = '0, %s, 0' % constant.value %} 41 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, &const antConfiguration, 1, isolate);
25 {% elif constant.idl_type == 'String' %} 42 {% endfilter %}
26 {% set value = '0, 0, %s' % constant.value %} 43 {% endfor %}
27 {% else %} 44 {# Constants with [DeprecateAs] or [MeasureAs] #}
28 {# 'Short', 'Long' etc. #} 45 {% for constant in special_getter_constants %}
29 {% set value = '%s, 0, 0' % constant.value %} 46 V8DOMConfiguration::installConstant(functionTemplate, prototypeTemplate, "{{cons tant.name}}", {{cpp_class}}V8Internal::{{constant.name}}ConstantGetterCallback, isolate);
30 {% endif %}
31 static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.i dl_type}}};
32 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, &c onstantConfiguration, 1, isolate);
33 }
34 {% endfor %} 47 {% endfor %}
35 {# Check constants #} 48 {# Check constants #}
36 {% if not do_not_check_constants %} 49 {% if not do_not_check_constants %}
37 {% for constant in constants %} 50 {% for constant in constants %}
38 {% if constant.idl_type not in ('Double', 'Float', 'String') %} 51 {% if constant.idl_type not in ('Double', 'Float', 'String') %}
39 {% set constant_cpp_class = constant.cpp_class or cpp_class %} 52 {% set constant_cpp_class = constant.cpp_class or cpp_class %}
40 COMPILE_ASSERT({{constant.value}} == {{constant_cpp_class}}::{{constant.reflecte d_name}}, TheValueOf{{cpp_class}}_{{constant.reflected_name}}DoesntMatchWithImpl ementation); 53 COMPILE_ASSERT({{constant.value}} == {{constant_cpp_class}}::{{constant.reflecte d_name}}, TheValueOf{{cpp_class}}_{{constant.reflected_name}}DoesntMatchWithImpl ementation);
41 {% endif %} 54 {% endif %}
42 {% endfor %} 55 {% endfor %}
43 {% endif %} 56 {% endif %}
44 {% endmacro %} 57 {% endmacro %}
58
59
60 {######################################}
61 {%- macro constant_configuration(constant) %}
62 {% if constant.idl_type in ('Double', 'Float') %}
63 {% set value = '0, %s, 0' % constant.value %}
64 {% elif constant.idl_type == 'String' %}
65 {% set value = '0, 0, "%s"' % constant.value %}
66 {% else %}
67 {# 'Short', 'Long' etc. #}
68 {% set value = '%s, 0, 0' % constant.value %}
69 {% endif %}
70 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_ type}}}
71 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698