| OLD | NEW |
| 1 {##############################################################################} | 1 {##############################################################################} |
| 2 {% macro constant_getter_callback(constant) %} | 2 {% macro constant_getter_callback(constant) %} |
| 3 void {{v8_class_or_partial}}::{{constant.name}}ConstantGetterCallback(v8::Local<
v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) { | 3 void {{v8_class_or_partial}}::{{constant.name}}ConstantGetterCallback(v8::Local<
v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 4 {% if constant.deprecate_as %} | 4 {% if constant.deprecate_as %} |
| 5 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC
ounter::{{constant.deprecate_as}}); | 5 Deprecation::CountDeprecation(CurrentExecutionContext(info.GetIsolate()), UseC
ounter::k{{constant.deprecate_as}}); |
| 6 {% endif %} | 6 {% endif %} |
| 7 {% if constant.measure_as %} | 7 {% if constant.measure_as %} |
| 8 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{co
nstant.measure_as('ConstantGetter')}}); | 8 UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), UseCounter::k{{c
onstant.measure_as('ConstantGetter')}}); |
| 9 {% endif %} | 9 {% endif %} |
| 10 {% if constant.idl_type in ('Double', 'Float') %} | 10 {% if constant.idl_type in ('Double', 'Float') %} |
| 11 v8SetReturnValue(info, {{constant.value}}); | 11 V8SetReturnValue(info, {{constant.value}}); |
| 12 {% elif constant.idl_type == 'String' %} | 12 {% elif constant.idl_type == 'String' %} |
| 13 v8SetReturnValueString(info, "{{constant.value}}"); | 13 V8SetReturnValueString(info, "{{constant.value}}"); |
| 14 {% else %} | 14 {% else %} |
| 15 v8SetReturnValueInt(info, {{constant.value}}); | 15 V8SetReturnValueInt(info, {{constant.value}}); |
| 16 {% endif %} | 16 {% endif %} |
| 17 } | 17 } |
| 18 {% endmacro %} | 18 {% endmacro %} |
| 19 | 19 |
| 20 | 20 |
| 21 {######################################} | 21 {######################################} |
| 22 {% macro install_constants() %} | 22 {% macro install_constants() %} |
| 23 {% if constants | has_constant_configuration %} | 23 {% if constants | has_constant_configuration %} |
| 24 {# Normal constants #} | 24 {# Normal constants #} |
| 25 const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { | 25 const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { |
| 26 {% for constant in constants | has_constant_configuration %} | 26 {% for constant in constants | has_constant_configuration %} |
| 27 {{constant_configuration(constant)}}, | 27 {{constant_configuration(constant)}}, |
| 28 {% endfor %} | 28 {% endfor %} |
| 29 }; | 29 }; |
| 30 V8DOMConfiguration::installConstants(isolate, interfaceTemplate, prototypeTempla
te, {{v8_class}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants)); | 30 V8DOMConfiguration::InstallConstants(isolate, interfaceTemplate, prototypeTempla
te, {{v8_class}}Constants, WTF_ARRAY_LENGTH({{v8_class}}Constants)); |
| 31 {% endif %} | 31 {% endif %} |
| 32 {# Runtime-enabled constants #} | 32 {# Runtime-enabled constants #} |
| 33 {% for group in constants | runtime_enabled_constants | groupby('runtime_enabled
_feature_name') %} | 33 {% for group in constants | runtime_enabled_constants | groupby('runtime_enabled
_feature_name') %} |
| 34 {% filter runtime_enabled(group.list[0].runtime_enabled_feature_name) %} | 34 {% filter runtime_enabled(group.list[0].runtime_enabled_feature_name) %} |
| 35 {% for constant in group.list %} | 35 {% for constant in group.list %} |
| 36 {% set constant_name = constant.name.title().replace('_', '') %} | 36 {% set constant_name = constant.name.title().replace('_', '') %} |
| 37 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu
ration = {{constant_configuration(constant)}}; | 37 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu
ration = {{constant_configuration(constant)}}; |
| 38 V8DOMConfiguration::installConstant(isolate, interfaceTemplate, prototypeTemplat
e, constant{{constant_name}}Configuration); | 38 V8DOMConfiguration::InstallConstant(isolate, interfaceTemplate, prototypeTemplat
e, constant{{constant_name}}Configuration); |
| 39 {% endfor %} | 39 {% endfor %} |
| 40 {% endfilter %} | 40 {% endfilter %} |
| 41 {% endfor %} | 41 {% endfor %} |
| 42 {# Constants with [DeprecateAs] or [MeasureAs] #} | 42 {# Constants with [DeprecateAs] or [MeasureAs] #} |
| 43 {% for constant in constants | has_special_getter %} | 43 {% for constant in constants | has_special_getter %} |
| 44 V8DOMConfiguration::installConstantWithGetter(isolate, interfaceTemplate, protot
ypeTemplate, "{{constant.name}}", {{v8_class_or_partial}}::{{constant.name}}Cons
tantGetterCallback); | 44 V8DOMConfiguration::InstallConstantWithGetter(isolate, interfaceTemplate, protot
ypeTemplate, "{{constant.name}}", {{v8_class_or_partial}}::{{constant.name}}Cons
tantGetterCallback); |
| 45 {% endfor %} | 45 {% endfor %} |
| 46 {# Check constants #} | 46 {# Check constants #} |
| 47 {% if not do_not_check_constants %} | 47 {% if not do_not_check_constants %} |
| 48 {% for constant in constants %} | 48 {% for constant in constants %} |
| 49 {% if constant.idl_type not in ('Double', 'Float', 'String') %} | 49 {% if constant.idl_type not in ('Double', 'Float', 'String') %} |
| 50 {% set constant_cpp_class = constant.cpp_class or cpp_class %} | 50 {% set constant_cpp_class = constant.cpp_class or cpp_class %} |
| 51 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected
_name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match
with implementation"); | 51 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected
_name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match
with implementation"); |
| 52 {% endif %} | 52 {% endif %} |
| 53 {% endfor %} | 53 {% endfor %} |
| 54 {% endif %} | 54 {% endif %} |
| 55 {% endmacro %} | 55 {% endmacro %} |
| 56 | 56 |
| 57 | 57 |
| 58 {######################################} | 58 {######################################} |
| 59 {%- macro constant_configuration(constant) %} | 59 {%- macro constant_configuration(constant) %} |
| 60 {% if constant.idl_type in ('Double', 'Float') %} | 60 {% if constant.idl_type in ('Double', 'Float') %} |
| 61 {% set value = '0, %s' % constant.value %} | 61 {% set value = '0, %s' % constant.value %} |
| 62 {% else %} | 62 {% else %} |
| 63 {# 'Short', 'Long' etc. #} | 63 {# 'Short', 'Long' etc. #} |
| 64 {% set value = '%s, 0' % constant.value %} | 64 {% set value = '%s, 0' % constant.value %} |
| 65 {% endif %} | 65 {% endif %} |
| 66 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_
type}}} | 66 {"{{constant.name}}", {{value}}, V8DOMConfiguration::kConstantType{{constant.idl
_type}}} |
| 67 {%- endmacro %} | 67 {%- endmacro %} |
| OLD | NEW |