| OLD | NEW |
| 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 in_file import InFile | 8 from in_file import InFile |
| 9 import in_generator | 9 import in_generator |
| 10 import license | 10 import license |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace WebCore | 178 } // namespace WebCore |
| 179 """ | 179 """ |
| 180 | 180 |
| 181 | 181 |
| 182 class CSSPropertiesWriter(in_generator.Writer): | 182 class CSSPropertiesWriter(in_generator.Writer): |
| 183 class_name = "CSSPropertyNames" | 183 class_name = "CSSPropertyNames" |
| 184 defaults = { | 184 defaults = { |
| 185 'alias_for': None, | 185 'alias_for': None, |
| 186 'condition': None, | |
| 187 'is_internal': False, | 186 'is_internal': False, |
| 188 } | 187 } |
| 189 | 188 |
| 190 def __init__(self, file_paths, enabled_conditions): | 189 def __init__(self, file_paths): |
| 191 in_generator.Writer.__init__(self, file_paths, enabled_conditions) | 190 in_generator.Writer.__init__(self, file_paths) |
| 192 self._outputs = {(self.class_name + ".h"): self.generate_header, | 191 self._outputs = {(self.class_name + ".h"): self.generate_header, |
| 193 (self.class_name + ".cpp"): self.generate_implementatio
n, | 192 (self.class_name + ".cpp"): self.generate_implementatio
n, |
| 194 } | 193 } |
| 195 | 194 |
| 196 all_properties = self.in_file.name_dictionaries | 195 self._aliases = filter(lambda property: property['alias_for'], self.in_f
ile.name_dictionaries) |
| 197 self._aliases = filter(lambda property: property['alias_for'], all_prope
rties) | |
| 198 for offset, property in enumerate(self._aliases): | 196 for offset, property in enumerate(self._aliases): |
| 199 # Aliases use the enum_name that they are an alias for. | 197 # Aliases use the enum_name that they are an alias for. |
| 200 property['enum_name'] = self._enum_name_from_property_name(property[
'alias_for']) | 198 property['enum_name'] = self._enum_name_from_property_name(property[
'alias_for']) |
| 201 # Aliases do not get an enum_value. | 199 # Aliases do not get an enum_value. |
| 202 | 200 |
| 203 self._properties = filter(lambda property: not property['alias_for'] and
not property['condition'] or property['condition'] in self._enabled_conditions,
all_properties) | 201 self._properties = filter(lambda property: not property['alias_for'], se
lf.in_file.name_dictionaries) |
| 204 if len(self._properties) > 1024: | 202 if len(self._properties) > 1024: |
| 205 print "ERROR : There is more than 1024 CSS Properties, you need to u
pdate CSSProperty.h/StylePropertyMetadata m_propertyID accordingly." | 203 print "ERROR : There is more than 1024 CSS Properties, you need to u
pdate CSSProperty.h/StylePropertyMetadata m_propertyID accordingly." |
| 206 exit(1) | 204 exit(1) |
| 207 self._first_property_id = 2 # We start after CSSPropertyInvalid and CSS
PropertyVariable. | 205 self._first_property_id = 2 # We start after CSSPropertyInvalid and CSS
PropertyVariable. |
| 208 property_id = self._first_property_id | 206 property_id = self._first_property_id |
| 209 for offset, property in enumerate(self._properties): | 207 for offset, property in enumerate(self._properties): |
| 210 property['enum_name'] = self._enum_name_from_property_name(property[
'name']) | 208 property['enum_name'] = self._enum_name_from_property_name(property[
'name']) |
| 211 property['enum_value'] = self._first_property_id + offset | 209 property['enum_value'] = self._first_property_id + offset |
| 212 if property['name'].startswith('-internal-'): | 210 if property['name'].startswith('-internal-'): |
| 213 property['is_internal'] = True | 211 property['is_internal'] = True |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 'internal_properties': '\n'.join(map(self._case_properties, filter(l
ambda property: property['is_internal'], self._properties))), | 246 'internal_properties': '\n'.join(map(self._case_properties, filter(l
ambda property: property['is_internal'], self._properties))), |
| 249 } | 247 } |
| 250 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 248 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 251 gperf_args = ['gperf', '--key-positions=*', '-P', '-D', '-n', '-s', '2'] | 249 gperf_args = ['gperf', '--key-positions=*', '-P', '-D', '-n', '-s', '2'] |
| 252 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) | 250 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) |
| 253 return gperf.communicate(gperf_input)[0] | 251 return gperf.communicate(gperf_input)[0] |
| 254 | 252 |
| 255 | 253 |
| 256 if __name__ == "__main__": | 254 if __name__ == "__main__": |
| 257 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) | 255 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) |
| OLD | NEW |