| 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 all_properties = self.in_file.name_dictionaries | 178 all_properties = self.in_file.name_dictionaries |
| 179 self._aliases = filter(lambda property: property['alias_for'], all_prope
rties) | 179 self._aliases = filter(lambda property: property['alias_for'], all_prope
rties) |
| 180 for offset, property in enumerate(self._aliases): | 180 for offset, property in enumerate(self._aliases): |
| 181 # Aliases use the enum_name that they are an alias for. | 181 # Aliases use the enum_name that they are an alias for. |
| 182 property['enum_name'] = self._enum_name_from_property_name(property[
'alias_for']) | 182 property['enum_name'] = self._enum_name_from_property_name(property[
'alias_for']) |
| 183 # Aliases do not get an enum_value. | 183 # Aliases do not get an enum_value. |
| 184 | 184 |
| 185 self._properties = filter(lambda property: not property['alias_for'] and
not property['condition'] or property['condition'] in self._enabled_conditions,
all_properties) | 185 self._properties = filter(lambda property: not property['alias_for'] and
not property['condition'] or property['condition'] in self._enabled_conditions,
all_properties) |
| 186 self._first_property_id = 1001 # Historical, unclear why. | 186 if len(self._properties) > 1024: |
| 187 print "ERROR : There is more than 1024 CSS Properties, you need to u
pdate CSSProperty.h/StylePropertyMetadata m_propertyID accordingly." |
| 188 exit(1) |
| 189 self._first_property_id = 2 # We start after CSSPropertyInvalid and CSS
PropertyVariable. |
| 187 property_id = self._first_property_id | 190 property_id = self._first_property_id |
| 188 for offset, property in enumerate(self._properties): | 191 for offset, property in enumerate(self._properties): |
| 189 property['enum_name'] = self._enum_name_from_property_name(property[
'name']) | 192 property['enum_name'] = self._enum_name_from_property_name(property[
'name']) |
| 190 property['enum_value'] = self._first_property_id + offset | 193 property['enum_value'] = self._first_property_id + offset |
| 191 | 194 |
| 192 def _enum_name_from_property_name(self, property_name): | 195 def _enum_name_from_property_name(self, property_name): |
| 193 return "CSSProperty" + re.sub(r'(^[^-])|-(.)', lambda match: (match.grou
p(1) or match.group(2)).upper(), property_name) | 196 return "CSSProperty" + re.sub(r'(^[^-])|-(.)', lambda match: (match.grou
p(1) or match.group(2)).upper(), property_name) |
| 194 | 197 |
| 195 def _enum_declaration(self, property): | 198 def _enum_declaration(self, property): |
| 196 return " %(enum_name)s = %(enum_value)s," % property | 199 return " %(enum_name)s = %(enum_value)s," % property |
| (...skipping 17 matching lines...) Expand all Loading... |
| 214 'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(
enum_name)s' % property, self._properties + self._aliases)), | 217 'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(
enum_name)s' % property, self._properties + self._aliases)), |
| 215 } | 218 } |
| 216 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 219 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 217 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] | 220 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] |
| 218 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) | 221 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) |
| 219 return gperf.communicate(gperf_input)[0] | 222 return gperf.communicate(gperf_input)[0] |
| 220 | 223 |
| 221 | 224 |
| 222 if __name__ == "__main__": | 225 if __name__ == "__main__": |
| 223 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) | 226 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) |
| OLD | NEW |