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

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

Issue 2972193002: Use unique variable names in gperf generated code (Closed)
Patch Set: fixup better gperf variable name Created 3 years, 5 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 | « third_party/WebKit/Source/build/scripts/make_css_property_names.py ('k') | no next file » | 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 2
3 import os.path 3 import os.path
4 import re 4 import re
5 import subprocess 5 import subprocess
6 import sys 6 import sys
7 7
8 from name_utilities import enum_for_css_keyword 8 from name_utilities import enum_for_css_keyword
9 from name_utilities import upper_first_letter 9 from name_utilities import upper_first_letter
10 import json5_generator 10 import json5_generator
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 'value_keyword_strings': '\n'.join(' "%(name)s\\0"' % keyword for keyword in self._value_keywords), 167 'value_keyword_strings': '\n'.join(' "%(name)s\\0"' % keyword for keyword in self._value_keywords),
168 'value_keyword_offsets': '\n'.join(' %d,' % offset for offset in ke yword_offsets), 168 'value_keyword_offsets': '\n'.join(' %d,' % offset for offset in ke yword_offsets),
169 'value_keyword_to_enum_map': '\n'.join('%(lower_name)s, %(enum_name) s' % keyword for keyword in self._value_keywords), 169 'value_keyword_to_enum_map': '\n'.join('%(lower_name)s, %(enum_name) s' % keyword for keyword in self._value_keywords),
170 'ua_sheet_mode_values_keywords': '\n '.join(map(self._case_va lue_keyword, self._value_keywords_with_mode('UASheet'))), 170 'ua_sheet_mode_values_keywords': '\n '.join(map(self._case_va lue_keyword, self._value_keywords_with_mode('UASheet'))),
171 'quirks_mode_or_ua_sheet_mode_values_keywords': '\n '.join(map(se lf._case_value_keyword, self._value_keywords_with_mode('QuirksOrUASheet'))), 171 'quirks_mode_or_ua_sheet_mode_values_keywords': '\n '.join(map(se lf._case_value_keyword, self._value_keywords_with_mode('QuirksOrUASheet'))),
172 } 172 }
173 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output 173 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output
174 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] 174 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n']
175 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. 175 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
176 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. 176 gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
177 gperf_args.extend(['-Q', 'CSSValueStringPool']) # Unique var names.
177 178
178 # If gperf isn't in the path we get an OSError. We don't want to use 179 # If gperf isn't in the path we get an OSError. We don't want to use
179 # the normal solution of shell=True (as this has to run on many 180 # the normal solution of shell=True (as this has to run on many
180 # platforms), so instead we catch the error and raise a 181 # platforms), so instead we catch the error and raise a
181 # CalledProcessError like subprocess would do when shell=True is set. 182 # CalledProcessError like subprocess would do when shell=True is set.
182 try: 183 try:
183 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s ubprocess.PIPE, universal_newlines=True) 184 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s ubprocess.PIPE, universal_newlines=True)
184 return gperf.communicate(gperf_input)[0] 185 return gperf.communicate(gperf_input)[0]
185 except OSError: 186 except OSError:
186 raise subprocess.CalledProcessError(127, gperf_args, output='Command not found.') 187 raise subprocess.CalledProcessError(127, gperf_args, output='Command not found.')
187 188
188 189
189 if __name__ == "__main__": 190 if __name__ == "__main__":
190 json5_generator.Maker(CSSValueKeywordsWriter).main() 191 json5_generator.Maker(CSSValueKeywordsWriter).main()
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/build/scripts/make_css_property_names.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698