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

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

Issue 797283005: replace COMPILE_ASSERT with static_assert in bindings/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
OLDNEW
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::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 4 static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::String>, const v8::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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 {% endfor %} 43 {% endfor %}
44 {# Constants with [DeprecateAs] or [MeasureAs] #} 44 {# Constants with [DeprecateAs] or [MeasureAs] #}
45 {% for constant in special_getter_constants %} 45 {% for constant in special_getter_constants %}
46 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate , "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}ConstantGetterC allback); 46 V8DOMConfiguration::installConstant(isolate, functionTemplate, prototypeTemplate , "{{constant.name}}", {{cpp_class}}V8Internal::{{constant.name}}ConstantGetterC allback);
47 {% endfor %} 47 {% endfor %}
48 {# Check constants #} 48 {# Check constants #}
49 {% if not do_not_check_constants %} 49 {% if not do_not_check_constants %}
50 {% for constant in constants %} 50 {% for constant in constants %}
51 {% if constant.idl_type not in ('Double', 'Float', 'String') %} 51 {% if constant.idl_type not in ('Double', 'Float', 'String') %}
52 {% set constant_cpp_class = constant.cpp_class or cpp_class %} 52 {% set constant_cpp_class = constant.cpp_class or cpp_class %}
53 COMPILE_ASSERT({{constant.value}} == {{constant_cpp_class}}::{{constant.reflecte d_name}}, TheValueOf{{cpp_class}}_{{constant.reflected_name}}DoesntMatchWithImpl ementation); 53 static_assert({{constant.value}} == {{constant_cpp_class}}::{{constant.reflected _name}}, "the value of {{cpp_class}}_{{constant.reflected_name}} does not match with implementation");
54 {% endif %} 54 {% endif %}
55 {% endfor %} 55 {% endfor %}
56 {% endif %} 56 {% endif %}
57 {% endmacro %} 57 {% endmacro %}
58 58
59 59
60 {######################################} 60 {######################################}
61 {%- macro constant_configuration(constant) %} 61 {%- macro constant_configuration(constant) %}
62 {% if constant.idl_type in ('Double', 'Float') %} 62 {% if constant.idl_type in ('Double', 'Float') %}
63 {% set value = '0, %s, 0' % constant.value %} 63 {% set value = '0, %s, 0' % constant.value %}
64 {% elif constant.idl_type == 'String' %} 64 {% elif constant.idl_type == 'String' %}
65 {% set value = '0, 0, "%s"' % constant.value %} 65 {% set value = '0, 0, "%s"' % constant.value %}
66 {% else %} 66 {% else %}
67 {# 'Short', 'Long' etc. #} 67 {# 'Short', 'Long' etc. #}
68 {% set value = '%s, 0, 0' % constant.value %} 68 {% set value = '%s, 0, 0' % constant.value %}
69 {% endif %} 69 {% endif %}
70 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_ type}}} 70 {"{{constant.name}}", {{value}}, V8DOMConfiguration::ConstantType{{constant.idl_ type}}}
71 {%- endmacro %} 71 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698