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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 class CSSPropertiesWriter(in_generator.Writer): | 165 class CSSPropertiesWriter(in_generator.Writer): |
166 class_name = "CSSPropertyNames" | 166 class_name = "CSSPropertyNames" |
167 defaults = { | 167 defaults = { |
168 'alias_for': None, | 168 'alias_for': None, |
169 'condition': None, | 169 'condition': None, |
170 } | 170 } |
171 | 171 |
172 def __init__(self, file_paths, enabled_conditions): | 172 def __init__(self, file_paths, enabled_conditions): |
173 in_generator.Writer.__init__(self, file_paths, enabled_conditions) | 173 in_generator.Writer.__init__(self, file_paths, enabled_conditions) |
| 174 self._outputs = {(self.class_name + ".h"): self.generate_header, |
| 175 (self.class_name + ".cpp"): self.generate_implementatio
n, |
| 176 } |
174 | 177 |
175 all_properties = self.in_file.name_dictionaries | 178 all_properties = self.in_file.name_dictionaries |
176 self._aliases = filter(lambda property: property['alias_for'], all_prope
rties) | 179 self._aliases = filter(lambda property: property['alias_for'], all_prope
rties) |
177 for offset, property in enumerate(self._aliases): | 180 for offset, property in enumerate(self._aliases): |
178 # Aliases use the enum_name that they are an alias for. | 181 # Aliases use the enum_name that they are an alias for. |
179 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']) |
180 # Aliases do not get an enum_value. | 183 # Aliases do not get an enum_value. |
181 | 184 |
182 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) |
183 self._first_property_id = 1001 # Historical, unclear why. | 186 self._first_property_id = 1001 # Historical, unclear why. |
(...skipping 27 matching lines...) Expand all Loading... |
211 'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(
enum_name)s' % property, self._properties + self._aliases)), | 214 'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(
enum_name)s' % property, self._properties + self._aliases)), |
212 } | 215 } |
213 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 216 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
214 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] | 217 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] |
215 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) | 218 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) |
216 return gperf.communicate(gperf_input)[0] | 219 return gperf.communicate(gperf_input)[0] |
217 | 220 |
218 | 221 |
219 if __name__ == "__main__": | 222 if __name__ == "__main__": |
220 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) | 223 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) |
OLD | NEW |