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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_handler_generator.py

Issue 791923003: replace COMPILE_ASSERT with static_assert in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixups Created 5 years, 11 months 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
« no previous file with comments | « no previous file | content/browser/download/download_net_log_parameters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import sys 6 import sys
7 import string 7 import string
8 import json 8 import json
9 9
10 blink_protocol_path = sys.argv[1] 10 blink_protocol_path = sys.argv[1]
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ${fields_enum}\ 119 ${fields_enum}\
120 }; 120 };
121 121
122 ${methods}\ 122 ${methods}\
123 123
124 static scoped_refptr<${declared_name}Builder<kNoneSet>> Create() { 124 static scoped_refptr<${declared_name}Builder<kNoneSet>> Create() {
125 return new ${declared_name}Builder<kNoneSet>(); 125 return new ${declared_name}Builder<kNoneSet>();
126 } 126 }
127 127
128 scoped_ptr<base::DictionaryValue> ToValue() { 128 scoped_ptr<base::DictionaryValue> ToValue() {
129 COMPILE_ASSERT(MASK == kAllSet, required_properties_missing); 129 static_assert(MASK == kAllSet, "required properties missing");
130 return make_scoped_ptr(dict_->DeepCopy()); 130 return make_scoped_ptr(dict_->DeepCopy());
131 } 131 }
132 132
133 private: 133 private:
134 friend struct ${declared_name}Builder<0>; 134 friend struct ${declared_name}Builder<0>;
135 135
136 ${declared_name}Builder() : dict_(new base::DictionaryValue()) { 136 ${declared_name}Builder() : dict_(new base::DictionaryValue()) {
137 } 137 }
138 138
139 template<class T> T* ThisAs() { 139 template<class T> T* ThisAs() {
140 COMPILE_ASSERT(sizeof(*this) == sizeof(T), cannot_cast); 140 static_assert(sizeof(*this) == sizeof(T), "cannot cast");
141 return reinterpret_cast<T*>(this); 141 return reinterpret_cast<T*>(this);
142 } 142 }
143 143
144 scoped_ptr<base::DictionaryValue> dict_; 144 scoped_ptr<base::DictionaryValue> dict_;
145 }; 145 };
146 146
147 typedef ${declared_name}Builder<0> ${declared_name}; 147 typedef ${declared_name}Builder<0> ${declared_name};
148 148
149 } // namespace ${domain} 149 } // namespace ${domain}
150 """) 150 """)
151 151
152 tmpl_builder_setter_req = string.Template("""\ 152 tmpl_builder_setter_req = string.Template("""\
153 scoped_refptr<${declared_name}Builder<MASK & ~k${Param}>> 153 scoped_refptr<${declared_name}Builder<MASK & ~k${Param}>>
154 set_${param}(${pass_type} ${param}) { 154 set_${param}(${pass_type} ${param}) {
155 COMPILE_ASSERT(MASK & k${Param}, already_set); 155 static_assert(MASK & k${Param}, "already set");
156 dict_->Set("${proto_param}", CreateValue(${param})); 156 dict_->Set("${proto_param}", CreateValue(${param}));
157 return ThisAs<${declared_name}Builder<MASK & ~k${Param}>>(); 157 return ThisAs<${declared_name}Builder<MASK & ~k${Param}>>();
158 } 158 }
159 """) 159 """)
160 160
161 tmpl_builder_setter_opt = string.Template("""\ 161 tmpl_builder_setter_opt = string.Template("""\
162 scoped_refptr<${declared_name}Builder<MASK>> 162 scoped_refptr<${declared_name}Builder<MASK>>
163 set_${param}(${pass_type} ${param}) { 163 set_${param}(${pass_type} ${param}) {
164 dict_->Set("${proto_param}", CreateValue(${param})); 164 dict_->Set("${proto_param}", CreateValue(${param}));
165 return this; 165 return this;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 output_h_file.close() 737 output_h_file.close()
738 738
739 output_cc_file.write(template_cc.substitute({}, 739 output_cc_file.write(template_cc.substitute({},
740 major = blink_protocol["version"]["major"], 740 major = blink_protocol["version"]["major"],
741 minor = blink_protocol["version"]["minor"], 741 minor = blink_protocol["version"]["minor"],
742 includes = "".join(sorted(includes)), 742 includes = "".join(sorted(includes)),
743 fields_init = ",\n ".join(fields_init), 743 fields_init = ",\n ".join(fields_init),
744 methods = "\n".join(handler_method_impls), 744 methods = "\n".join(handler_method_impls),
745 types = "\n".join(type_impls))) 745 types = "\n".join(type_impls)))
746 output_cc_file.close() 746 output_cc_file.close()
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_net_log_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698