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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_css_property_names.py

Issue 2633223003: Convert CSSProperties.in to JSON5 format (Closed)
Patch Set: Fix test_converter_unittest Created 3 years, 10 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import subprocess 3 import subprocess
4 import sys 4 import sys
5 5
6 import css_properties 6 import css_properties
7 import in_generator 7 import json5_generator
8 import license 8 import license
9 9
10 10
11 HEADER_TEMPLATE = """ 11 HEADER_TEMPLATE = """
12 %(license)s 12 %(license)s
13 13
14 #ifndef %(class_name)s_h 14 #ifndef %(class_name)s_h
15 #define %(class_name)s_h 15 #define %(class_name)s_h
16 16
17 #include "core/CoreExport.h" 17 #include "core/CoreExport.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return resolveCSSPropertyID(unresolvedCSSPropertyID(string)); 177 return resolveCSSPropertyID(unresolvedCSSPropertyID(string));
178 } 178 }
179 179
180 } // namespace blink 180 } // namespace blink
181 """ 181 """
182 182
183 183
184 class CSSPropertyNamesWriter(css_properties.CSSProperties): 184 class CSSPropertyNamesWriter(css_properties.CSSProperties):
185 class_name = "CSSPropertyNames" 185 class_name = "CSSPropertyNames"
186 186
187 def __init__(self, in_file_path): 187 def __init__(self, json5_file_path):
188 super(CSSPropertyNamesWriter, self).__init__(in_file_path) 188 super(CSSPropertyNamesWriter, self).__init__(json5_file_path)
189 self._outputs = {(self.class_name + ".h"): self.generate_header, 189 self._outputs = {(self.class_name + ".h"): self.generate_header,
190 (self.class_name + ".cpp"): self.generate_implementatio n, 190 (self.class_name + ".cpp"): self.generate_implementatio n,
191 } 191 }
192 192
193 def _enum_declaration(self, property): 193 def _enum_declaration(self, property):
194 return " %(property_id)s = %(enum_value)s," % property 194 return " %(property_id)s = %(enum_value)s," % property
195 195
196 def generate_header(self): 196 def generate_header(self):
197 return HEADER_TEMPLATE % { 197 return HEADER_TEMPLATE % {
198 'license': license.license_for_generated_cpp(), 198 'license': license.license_for_generated_cpp(),
(...skipping 29 matching lines...) Expand all
228 } 228 }
229 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output 229 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output
230 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] 230 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n']
231 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. 231 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
232 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. 232 gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
233 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) 233 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True)
234 return gperf.communicate(gperf_input)[0] 234 return gperf.communicate(gperf_input)[0]
235 235
236 236
237 if __name__ == "__main__": 237 if __name__ == "__main__":
238 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) 238 json5_generator.Maker(CSSPropertyNamesWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698