OLD | NEW |
1 {% from 'utilities.cpp' import check_api_experiment %} | 1 {% from 'utilities.cpp' import check_origin_trial %} |
2 | 2 |
3 {##############################################################################} | 3 {##############################################################################} |
4 {% macro constant_getter_callback(constant) %} | 4 {% macro constant_getter_callback(constant) %} |
5 static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::Name>, const v
8::PropertyCallbackInfo<v8::Value>& info) | 5 static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::Name>, const v
8::PropertyCallbackInfo<v8::Value>& info) |
6 { | 6 { |
7 {% if constant.deprecate_as %} | 7 {% if constant.deprecate_as %} |
8 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExe
cutionContext(info.GetIsolate()), UseCounter::{{constant.deprecate_as}}); | 8 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExe
cutionContext(info.GetIsolate()), UseCounter::{{constant.deprecate_as}}); |
9 {% endif %} | 9 {% endif %} |
10 {% if constant.measure_as %} | 10 {% if constant.measure_as %} |
11 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte
xt(info.GetIsolate()), UseCounter::{{constant.measure_as('ConstantGetter')}}); | 11 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte
xt(info.GetIsolate()), UseCounter::{{constant.measure_as('ConstantGetter')}}); |
12 {% endif %} | 12 {% endif %} |
13 {% if constant.is_api_experiment_enabled %} | 13 {% if constant.is_origin_trial_enabled %} |
14 {{check_api_experiment(constant) | indent}} | 14 {{check_origin_trial(constant) | indent}} |
15 {% endif %} | 15 {% endif %} |
16 {% if constant.idl_type in ('Double', 'Float') %} | 16 {% if constant.idl_type in ('Double', 'Float') %} |
17 v8SetReturnValue(info, {{constant.value}}); | 17 v8SetReturnValue(info, {{constant.value}}); |
18 {% elif constant.idl_type == 'String' %} | 18 {% elif constant.idl_type == 'String' %} |
19 v8SetReturnValueString(info, "{{constant.value}}"); | 19 v8SetReturnValueString(info, "{{constant.value}}"); |
20 {% else %} | 20 {% else %} |
21 v8SetReturnValueInt(info, {{constant.value}}); | 21 v8SetReturnValueInt(info, {{constant.value}}); |
22 {% endif %} | 22 {% endif %} |
23 } | 23 } |
24 {% endmacro %} | 24 {% endmacro %} |
(...skipping 13 matching lines...) Expand all Loading... |
38 {# Runtime-enabled constants #} | 38 {# Runtime-enabled constants #} |
39 {% for constant_tuple in runtime_enabled_constants %} | 39 {% for constant_tuple in runtime_enabled_constants %} |
40 {% filter runtime_enabled(constant_tuple[0]) %} | 40 {% filter runtime_enabled(constant_tuple[0]) %} |
41 {% for constant in constant_tuple[1] %} | 41 {% for constant in constant_tuple[1] %} |
42 {% set constant_name = constant.name.title().replace('_', '') %} | 42 {% set constant_name = constant.name.title().replace('_', '') %} |
43 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu
ration = {{constant_configuration(constant)}}; | 43 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu
ration = {{constant_configuration(constant)}}; |
44 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate
, constant{{constant_name}}Configuration); | 44 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate
, constant{{constant_name}}Configuration); |
45 {% endfor %} | 45 {% endfor %} |
46 {% endfilter %} | 46 {% endfilter %} |
47 {% endfor %} | 47 {% endfor %} |
48 {# Constants with [DeprecateAs] or [MeasureAs] or [APIExperimentEnabled] #} | 48 {# Constants with [DeprecateAs] or [MeasureAs] or [OriginTrialEnabled] #} |
49 {% for constant in special_getter_constants %} | 49 {% for constant in special_getter_constants %} |
50 V8DOMConfiguration::installConstantWithGetter(isolate, functionTemplate, prototy
peTemplate, "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}Const
antGetterCallback); | 50 V8DOMConfiguration::installConstantWithGetter(isolate, functionTemplate, prototy
peTemplate, "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}Const
antGetterCallback); |
51 {% endfor %} | 51 {% endfor %} |
52 {# Check constants #} | 52 {# Check constants #} |
53 {% if not do_not_check_constants %} | 53 {% if not do_not_check_constants %} |
54 {% for constant in constants %} | 54 {% for constant in constants %} |
55 {% if constant.idl_type not in ('Double', 'Float', 'String') %} | 55 {% if constant.idl_type not in ('Double', 'Float', 'String') %} |
56 {% set constant_cpp_class = constant.cpp_class or cpp_class %} | 56 {% set constant_cpp_class = constant.cpp_class or cpp_class %} |
57 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected
_name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match
with implementation"); | 57 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected
_name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match
with implementation"); |
58 {% endif %} | 58 {% endif %} |
59 {% endfor %} | 59 {% endfor %} |
60 {% endif %} | 60 {% endif %} |
61 {% endmacro %} | 61 {% endmacro %} |
62 | 62 |
63 | 63 |
64 {######################################} | 64 {######################################} |
65 {%- macro constant_configuration(constant) %} | 65 {%- macro constant_configuration(constant) %} |
66 {% if constant.idl_type in ('Double', 'Float') %} | 66 {% if constant.idl_type in ('Double', 'Float') %} |
67 {% set value = '0, %s' % constant.value %} | 67 {% set value = '0, %s' % constant.value %} |
68 {% else %} | 68 {% else %} |
69 {# 'Short', 'Long' etc. #} | 69 {# 'Short', 'Long' etc. #} |
70 {% set value = '%s, 0' % constant.value %} | 70 {% set value = '%s, 0' % constant.value %} |
71 {% endif %} | 71 {% endif %} |
72 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_
type}}} | 72 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_
type}}} |
73 {%- endmacro %} | 73 {%- endmacro %} |
OLD | NEW |