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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 | 84 |
85 class CSSValueKeywordsWriter(in_generator.Writer): | 85 class CSSValueKeywordsWriter(in_generator.Writer): |
86 class_name = "CSSValueKeywords" | 86 class_name = "CSSValueKeywords" |
87 defaults = { | 87 defaults = { |
88 'condition': None, | 88 'condition': None, |
89 } | 89 } |
90 | 90 |
91 def __init__(self, file_paths, enabled_conditions): | 91 def __init__(self, file_paths, enabled_conditions): |
92 in_generator.Writer.__init__(self, file_paths, enabled_conditions) | 92 in_generator.Writer.__init__(self, file_paths, enabled_conditions) |
| 93 self._outputs = {(self.class_name + ".h"): self.generate_header, |
| 94 (self.class_name + ".cpp"): self.generate_implementatio
n, |
| 95 } |
93 | 96 |
94 all_properties = self.in_file.name_dictionaries | 97 all_properties = self.in_file.name_dictionaries |
95 self._value_keywords = filter(lambda property: not property['condition']
or property['condition'] in self._enabled_conditions, all_properties) | 98 self._value_keywords = filter(lambda property: not property['condition']
or property['condition'] in self._enabled_conditions, all_properties) |
96 first_property_id = 1 | 99 first_property_id = 1 |
97 for offset, property in enumerate(self._value_keywords): | 100 for offset, property in enumerate(self._value_keywords): |
98 property['name'] = property['name'].lower() | 101 property['name'] = property['name'].lower() |
99 property['enum_name'] = self._enum_name_from_value_keyword(property[
'name']) | 102 property['enum_name'] = self._enum_name_from_value_keyword(property[
'name']) |
100 property['enum_value'] = first_property_id + offset | 103 property['enum_value'] = first_property_id + offset |
101 | 104 |
102 def _enum_name_from_value_keyword(self, value_keyword): | 105 def _enum_name_from_value_keyword(self, value_keyword): |
(...skipping 19 matching lines...) Expand all Loading... |
122 'value_keyword_to_enum_map': '\n'.join(map(lambda property: '%(name)
s, %(enum_name)s' % property, self._value_keywords)), | 125 'value_keyword_to_enum_map': '\n'.join(map(lambda property: '%(name)
s, %(enum_name)s' % property, self._value_keywords)), |
123 } | 126 } |
124 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 127 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
125 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] | 128 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] |
126 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) | 129 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) |
127 return gperf.communicate(gperf_input)[0] | 130 return gperf.communicate(gperf_input)[0] |
128 | 131 |
129 | 132 |
130 if __name__ == "__main__": | 133 if __name__ == "__main__": |
131 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) | 134 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) |
OLD | NEW |