| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace WebCore | 103 } // namespace WebCore |
| 104 """ | 104 """ |
| 105 | 105 |
| 106 | 106 |
| 107 class CSSValueKeywordsWriter(in_generator.Writer): | 107 class CSSValueKeywordsWriter(in_generator.Writer): |
| 108 class_name = "CSSValueKeywords" | 108 class_name = "CSSValueKeywords" |
| 109 defaults = { | 109 defaults = { |
| 110 'condition': None, | |
| 111 'mode': None, | 110 'mode': None, |
| 112 } | 111 } |
| 113 | 112 |
| 114 def __init__(self, file_paths, enabled_conditions): | 113 def __init__(self, file_paths): |
| 115 in_generator.Writer.__init__(self, file_paths, enabled_conditions) | 114 in_generator.Writer.__init__(self, file_paths) |
| 116 self._outputs = {(self.class_name + ".h"): self.generate_header, | 115 self._outputs = {(self.class_name + ".h"): self.generate_header, |
| 117 (self.class_name + ".cpp"): self.generate_implementatio
n, | 116 (self.class_name + ".cpp"): self.generate_implementatio
n, |
| 118 } | 117 } |
| 119 | 118 |
| 120 all_properties = self.in_file.name_dictionaries | 119 self._value_keywords = self.in_file.name_dictionaries |
| 121 self._value_keywords = filter(lambda property: not property['condition']
or property['condition'] in self._enabled_conditions, all_properties) | |
| 122 first_property_id = 1 | 120 first_property_id = 1 |
| 123 for offset, property in enumerate(self._value_keywords): | 121 for offset, property in enumerate(self._value_keywords): |
| 124 property['name'] = property['name'].lower() | 122 property['name'] = property['name'].lower() |
| 125 property['enum_name'] = self._enum_name_from_value_keyword(property[
'name']) | 123 property['enum_name'] = self._enum_name_from_value_keyword(property[
'name']) |
| 126 property['enum_value'] = first_property_id + offset | 124 property['enum_value'] = first_property_id + offset |
| 127 if property['name'].startswith('-internal-'): | 125 if property['name'].startswith('-internal-'): |
| 128 assert property['mode'] is None, 'Can\'t specify mode for value
keywords with the prefix "-internal-".' | 126 assert property['mode'] is None, 'Can\'t specify mode for value
keywords with the prefix "-internal-".' |
| 129 property['mode'] = 'UASheet' | 127 property['mode'] = 'UASheet' |
| 130 else: | 128 else: |
| 131 assert property['mode'] != 'UASheet', 'UASheet mode only value k
eywords should have the prefix "-internal-".' | 129 assert property['mode'] != 'UASheet', 'UASheet mode only value k
eywords should have the prefix "-internal-".' |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 'quirks_mode_or_ua_sheet_mode_values_keywords': '\n '.join(map(se
lf._case_value_keyword, self._value_keywords_with_mode('QuirksOrUASheet'))), | 168 'quirks_mode_or_ua_sheet_mode_values_keywords': '\n '.join(map(se
lf._case_value_keyword, self._value_keywords_with_mode('QuirksOrUASheet'))), |
| 171 } | 169 } |
| 172 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 170 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 173 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] | 171 gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2'] |
| 174 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) | 172 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE) |
| 175 return gperf.communicate(gperf_input)[0] | 173 return gperf.communicate(gperf_input)[0] |
| 176 | 174 |
| 177 | 175 |
| 178 if __name__ == "__main__": | 176 if __name__ == "__main__": |
| 179 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) | 177 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) |
| OLD | NEW |