OLD | NEW |
1 {##############################################################################} | 1 {##############################################################################} |
2 {% macro constant_getter_callback(constant) %} | 2 {% macro constant_getter_callback(constant) %} |
3 {% filter conditional(constant.conditional_string) %} | 3 {% filter conditional(constant.conditional_string) %} |
4 static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::Name>, const v
8::PropertyCallbackInfo<v8::Value>& info) | 4 static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::Name>, const v
8::PropertyCallbackInfo<v8::Value>& info) |
5 { | 5 { |
6 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); | 6 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
7 {% if constant.deprecate_as %} | 7 {% if constant.deprecate_as %} |
8 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), callingExe
cutionContext(info.GetIsolate()), UseCounter::{{constant.deprecate_as}}); | 8 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), callingExe
cutionContext(info.GetIsolate()), UseCounter::{{constant.deprecate_as}}); |
9 {% endif %} | 9 {% endif %} |
10 {% if constant.measure_as %} | 10 {% if constant.measure_as %} |
(...skipping 16 matching lines...) Expand all Loading... |
27 {% macro install_constants() %} | 27 {% macro install_constants() %} |
28 {% if constant_configuration_constants %} | 28 {% if constant_configuration_constants %} |
29 {# Normal constants #} | 29 {# Normal constants #} |
30 const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { | 30 const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { |
31 {% for constant in constant_configuration_constants %} | 31 {% for constant in constant_configuration_constants %} |
32 {{constant_configuration(constant)}}, | 32 {{constant_configuration(constant)}}, |
33 {% endfor %} | 33 {% endfor %} |
34 }; | 34 }; |
35 V8DOMConfiguration::installConstants(isolate, functionTemplate, prototypeTemplat
e, {{v8_class}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants)); | 35 V8DOMConfiguration::installConstants(isolate, functionTemplate, prototypeTemplat
e, {{v8_class}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants)); |
36 {% endif %} | 36 {% endif %} |
| 37 ExecutionContext* ec = currentExecutionContext(isolate); |
| 38 ALLOW_UNUSED_LOCAL(ec); |
37 {# Runtime-enabled constants #} | 39 {# Runtime-enabled constants #} |
38 {% for constant_tuple in runtime_enabled_constants %} | 40 {% for constant_tuple in runtime_enabled_constants %} |
39 {% filter runtime_enabled(constant_tuple[0]) %} | 41 {% filter runtime_enabled(constant_tuple[0]) %} |
40 {% for constant in constant_tuple[1] %} | 42 {% for constant in constant_tuple[1] %} |
41 {% set constant_name = constant.name.title().replace('_', '') %} | 43 {% set constant_name = constant.name.title().replace('_', '') %} |
| 44 {% if constant.name in experimental_enabled_constants %} |
| 45 if (Experiments::isApiEnabledWithoutMessage(ec, "{{experimental_enabled_constant
s.get(constant.name)}}")) { |
| 46 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con
figuration = {{constant_configuration(constant)}}; |
| 47 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemp
late, constant{{constant_name}}Configuration); |
| 48 } |
| 49 {% else %} |
42 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu
ration = {{constant_configuration(constant)}}; | 50 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu
ration = {{constant_configuration(constant)}}; |
43 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate
, constant{{constant_name}}Configuration); | 51 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate
, constant{{constant_name}}Configuration); |
| 52 {% endif %} |
44 {% endfor %} | 53 {% endfor %} |
45 {% endfilter %} | 54 {% endfilter %} |
46 {% endfor %} | 55 {% endfor %} |
47 {# Constants with [DeprecateAs] or [MeasureAs] #} | 56 {# Constants with [DeprecateAs] or [MeasureAs] #} |
48 {% for constant in special_getter_constants %} | 57 {% for constant in special_getter_constants %} |
49 V8DOMConfiguration::installConstantWithGetter(isolate, functionTemplate, prototy
peTemplate, "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}Const
antGetterCallback); | 58 V8DOMConfiguration::installConstantWithGetter(isolate, functionTemplate, prototy
peTemplate, "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}Const
antGetterCallback); |
50 {% endfor %} | 59 {% endfor %} |
| 60 {# Constants with [ExperimentEnabled] only #} |
| 61 {% for constant in experimental_only_constants %} |
| 62 if (Experiments::isApiEnabledWithoutMessage(ec, "{{constant['api_experiment_name
']}}")) { |
| 63 const V8DOMConfiguration::ConstantConfiguration constant{{constant.name}}Con
figuration = {{constant_configuration(constant)}}; |
| 64 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemp
late, constant{{constant.name}}Configuration); |
| 65 } |
| 66 {% endfor %} |
51 {# Check constants #} | 67 {# Check constants #} |
52 {% if not do_not_check_constants %} | 68 {% if not do_not_check_constants %} |
53 {% for constant in constants %} | 69 {% for constant in constants %} |
54 {% if constant.idl_type not in ('Double', 'Float', 'String') %} | 70 {% if constant.idl_type not in ('Double', 'Float', 'String') %} |
55 {% set constant_cpp_class = constant.cpp_class or cpp_class %} | 71 {% set constant_cpp_class = constant.cpp_class or cpp_class %} |
56 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected
_name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match
with implementation"); | 72 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected
_name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match
with implementation"); |
57 {% endif %} | 73 {% endif %} |
58 {% endfor %} | 74 {% endfor %} |
59 {% endif %} | 75 {% endif %} |
60 {% endmacro %} | 76 {% endmacro %} |
61 | 77 |
62 | 78 |
63 {######################################} | 79 {######################################} |
64 {%- macro constant_configuration(constant) %} | 80 {%- macro constant_configuration(constant) %} |
65 {% if constant.idl_type in ('Double', 'Float') %} | 81 {% if constant.idl_type in ('Double', 'Float') %} |
66 {% set value = '0, %s' % constant.value %} | 82 {% set value = '0, %s' % constant.value %} |
67 {% else %} | 83 {% else %} |
68 {# 'Short', 'Long' etc. #} | 84 {# 'Short', 'Long' etc. #} |
69 {% set value = '%s, 0' % constant.value %} | 85 {% set value = '%s, 0' % constant.value %} |
70 {% endif %} | 86 {% endif %} |
71 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_
type}}} | 87 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_
type}}} |
72 {%- endmacro %} | 88 {%- endmacro %} |
OLD | NEW |