Chromium Code Reviews| 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); | |
| 39 String constantsErrorMessage; | |
|
haraken
2015/12/16 02:16:41
What is the constantsErrorMessage for?
Daniel Nishi
2015/12/16 21:42:03
Removed.
| |
| 40 ALLOW_UNUSED_LOCAL(constantsErrorMessage); | |
| 37 {# Runtime-enabled constants #} | 41 {# Runtime-enabled constants #} |
| 38 {% for constant_tuple in runtime_enabled_constants %} | 42 {% for constant_tuple in runtime_enabled_constants %} |
| 39 {% filter runtime_enabled(constant_tuple[0]) %} | 43 {% filter runtime_enabled(constant_tuple[0]) %} |
| 40 {% for constant in constant_tuple[1] %} | 44 {% for constant in constant_tuple[1] %} |
| 41 {% set constant_name = constant.name.title().replace('_', '') %} | 45 {% set constant_name = constant.name.title().replace('_', '') %} |
| 46 {% if constant.name in experimental_enabled_constants %} | |
| 47 if (Experiments::isApiEnabled(ec, "{{experimental_enabled_constants.get(constant .name)}}", constantsErrorMessage)) { | |
| 48 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}}; | |
| 49 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemp late, constant{{constant_name}}Configuration); | |
| 50 } | |
| 51 {% else %} | |
| 42 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu ration = {{constant_configuration(constant)}}; | 52 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configu ration = {{constant_configuration(constant)}}; |
| 43 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate , constant{{constant_name}}Configuration); | 53 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate , constant{{constant_name}}Configuration); |
| 54 {% endif %} | |
| 44 {% endfor %} | 55 {% endfor %} |
| 45 {% endfilter %} | 56 {% endfilter %} |
| 46 {% endfor %} | 57 {% endfor %} |
| 47 {# Constants with [DeprecateAs] or [MeasureAs] #} | 58 {# Constants with [DeprecateAs] or [MeasureAs] #} |
| 48 {% for constant in special_getter_constants %} | 59 {% for constant in special_getter_constants %} |
| 49 V8DOMConfiguration::installConstantWithGetter(isolate, functionTemplate, prototy peTemplate, "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}Const antGetterCallback); | 60 V8DOMConfiguration::installConstantWithGetter(isolate, functionTemplate, prototy peTemplate, "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}Const antGetterCallback); |
| 50 {% endfor %} | 61 {% endfor %} |
| 62 {# Constants with [ExperimentEnabled] only #} | |
| 63 {% for constant in experimental_only_constants %} | |
|
haraken
2015/12/16 02:16:42
Why do we need to distinguish experimental_only_co
Daniel Nishi
2015/12/16 21:42:03
Yes. This is being done so that they interact prop
| |
| 64 if (Experiments::isApiEnabled(ec, "{{constant['experimental_api_name']}}", const antsErrorMessage)) { | |
| 65 const V8DOMConfiguration::ConstantConfiguration constant{{constant.name}}Con figuration = {{constant_configuration(constant)}}; | |
| 66 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemp late, constant{{constant.name}}Configuration); | |
| 67 } | |
| 68 {% endfor %} | |
| 51 {# Check constants #} | 69 {# Check constants #} |
| 52 {% if not do_not_check_constants %} | 70 {% if not do_not_check_constants %} |
| 53 {% for constant in constants %} | 71 {% for constant in constants %} |
| 54 {% if constant.idl_type not in ('Double', 'Float', 'String') %} | 72 {% if constant.idl_type not in ('Double', 'Float', 'String') %} |
| 55 {% set constant_cpp_class = constant.cpp_class or cpp_class %} | 73 {% 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"); | 74 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 %} | 75 {% endif %} |
| 58 {% endfor %} | 76 {% endfor %} |
| 59 {% endif %} | 77 {% endif %} |
| 60 {% endmacro %} | 78 {% endmacro %} |
| 61 | 79 |
| 62 | 80 |
| 63 {######################################} | 81 {######################################} |
| 64 {%- macro constant_configuration(constant) %} | 82 {%- macro constant_configuration(constant) %} |
| 65 {% if constant.idl_type in ('Double', 'Float') %} | 83 {% if constant.idl_type in ('Double', 'Float') %} |
| 66 {% set value = '0, %s' % constant.value %} | 84 {% set value = '0, %s' % constant.value %} |
| 67 {% else %} | 85 {% else %} |
| 68 {# 'Short', 'Long' etc. #} | 86 {# 'Short', 'Long' etc. #} |
| 69 {% set value = '%s, 0' % constant.value %} | 87 {% set value = '%s, 0' % constant.value %} |
| 70 {% endif %} | 88 {% endif %} |
| 71 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_ type}}} | 89 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_ type}}} |
| 72 {%- endmacro %} | 90 {%- endmacro %} |
| OLD | NEW |