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

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

Issue 1310073003: Fix _first_enum_value usage on make_css_property_names.py (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 | « Source/build/scripts/css_properties.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 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 in_generator
8 import license 8 import license
9 9
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 'last_property_id': self._first_enum_value + len(self._properties) - 1, 196 'last_property_id': self._first_enum_value + len(self._properties) - 1,
197 'last_unresolved_property_id': max(property["enum_value"] for proper ty in self._properties_including_aliases), 197 'last_unresolved_property_id': max(property["enum_value"] for proper ty in self._properties_including_aliases),
198 'max_name_length': max(map(len, self._properties)), 198 'max_name_length': max(map(len, self._properties)),
199 } 199 }
200 200
201 def generate_implementation(self): 201 def generate_implementation(self):
202 enum_value_to_name = {property['enum_value']: property['name'] for prope rty in self._properties_including_aliases} 202 enum_value_to_name = {property['enum_value']: property['name'] for prope rty in self._properties_including_aliases}
203 property_offsets = [] 203 property_offsets = []
204 property_names = [] 204 property_names = []
205 current_offset = 0 205 current_offset = 0
206 for enum_value in range(1, max(enum_value_to_name) + 1): 206 for enum_value in range(self._first_enum_value, max(enum_value_to_name) + 1):
207 property_offsets.append(current_offset) 207 property_offsets.append(current_offset)
208 if enum_value in enum_value_to_name: 208 if enum_value in enum_value_to_name:
209 name = enum_value_to_name[enum_value] 209 name = enum_value_to_name[enum_value]
210 property_names.append(name) 210 property_names.append(name)
211 current_offset += len(name) + 1 211 current_offset += len(name) + 1
212 212
213 css_name_and_enum_pairs = [(property['name'], property['property_id']) f or property in self._properties_including_aliases] 213 css_name_and_enum_pairs = [(property['name'], property['property_id']) f or property in self._properties_including_aliases]
214 214
215 gperf_input = GPERF_TEMPLATE % { 215 gperf_input = GPERF_TEMPLATE % {
216 'license': license.license_for_generated_cpp(), 216 'license': license.license_for_generated_cpp(),
217 'class_name': self.class_name, 217 'class_name': self.class_name,
218 'property_name_strings': '\n'.join(' "%s\\0"' % name for name in property_names), 218 'property_name_strings': '\n'.join(' "%s\\0"' % name for name in property_names),
219 'property_name_offsets': '\n'.join(' %d,' % offset for offset in property_offsets), 219 'property_name_offsets': '\n'.join(' %d,' % offset for offset in property_offsets),
220 'property_to_enum_map': '\n'.join('%s, %s' % property for property i n css_name_and_enum_pairs), 220 'property_to_enum_map': '\n'.join('%s, %s' % property for property i n css_name_and_enum_pairs),
221 } 221 }
222 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output 222 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output
223 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] 223 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n']
224 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. 224 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
225 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. 225 gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
226 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) 226 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True)
227 return gperf.communicate(gperf_input)[0] 227 return gperf.communicate(gperf_input)[0]
228 228
229 229
230 if __name__ == "__main__": 230 if __name__ == "__main__":
231 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) 231 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « Source/build/scripts/css_properties.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698