Chromium Code Reviews| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 | 79 |
| 80 const char* getValueName(unsigned short id) | 80 const char* getValueName(unsigned short id) |
| 81 { | 81 { |
| 82 if (id >= numCSSValueKeywords || id <= 0) | 82 if (id >= numCSSValueKeywords || id <= 0) |
| 83 return 0; | 83 return 0; |
| 84 return valueListStringPool + valueListStringOffsets[id]; | 84 return valueListStringPool + valueListStringOffsets[id]; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode) | 87 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode) |
| 88 { | 88 { |
| 89 // FIXME: Investigate whether we can deprecate the former | |
| 90 // two as only QuirksOrUASheet is used in CSSValueKeyword.in | |
|
Peter Kasting
2014/03/18 17:40:47
(ua_sheet_mode_values_keywords cannot be removed a
| |
| 91 switch (id) { | 89 switch (id) { |
| 92 %(ua_sheet_mode_values_keywords)s | 90 %(ua_sheet_mode_values_keywords)s |
| 93 return isUASheetBehavior(mode); | 91 return isUASheetBehavior(mode); |
| 94 %(quirks_mode_values_keywords)s | |
| 95 return isQuirksModeBehavior(mode); | |
|
Nico
2014/03/18 17:47:51
I don't understand this part. Is this always dead?
Peter Kasting
2014/03/18 20:58:04
No keywords in CSSValueKeyword.in use it, and noth
Nico
2014/03/19 10:20:05
Ah, now I understand your comment about lines 89,9
| |
| 96 %(quirks_mode_or_ua_sheet_mode_values_keywords)s | 92 %(quirks_mode_or_ua_sheet_mode_values_keywords)s |
| 97 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); | 93 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); |
| 98 default: | 94 default: |
| 99 return true; | 95 return true; |
| 100 } | 96 } |
| 101 } | 97 } |
| 102 | 98 |
| 103 } // namespace WebCore | 99 } // namespace WebCore |
| 104 """ | 100 """ |
| 105 | 101 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 keyword_offsets.append(current_offset) | 153 keyword_offsets.append(current_offset) |
| 158 current_offset += len(keyword["name"]) + 1 | 154 current_offset += len(keyword["name"]) + 1 |
| 159 | 155 |
| 160 gperf_input = GPERF_TEMPLATE % { | 156 gperf_input = GPERF_TEMPLATE % { |
| 161 'license': license.license_for_generated_cpp(), | 157 'license': license.license_for_generated_cpp(), |
| 162 'class_name': self.class_name, | 158 'class_name': self.class_name, |
| 163 'value_keyword_strings': '\n'.join(map(lambda property: ' "%(name )s\\0"' % property, self._value_keywords)), | 159 'value_keyword_strings': '\n'.join(map(lambda property: ' "%(name )s\\0"' % property, self._value_keywords)), |
| 164 'value_keyword_offsets': '\n'.join(map(lambda offset: ' %d,' % offs et, keyword_offsets)), | 160 'value_keyword_offsets': '\n'.join(map(lambda offset: ' %d,' % offs et, keyword_offsets)), |
| 165 'value_keyword_to_enum_map': '\n'.join(map(lambda property: '%(name) s, %(enum_name)s' % property, self._value_keywords)), | 161 'value_keyword_to_enum_map': '\n'.join(map(lambda property: '%(name) s, %(enum_name)s' % property, self._value_keywords)), |
| 166 'ua_sheet_mode_values_keywords': '\n '.join(map(self._case_va lue_keyword, self._value_keywords_with_mode('UASheet'))), | 162 'ua_sheet_mode_values_keywords': '\n '.join(map(self._case_va lue_keyword, self._value_keywords_with_mode('UASheet'))), |
| 167 'quirks_mode_values_keywords': '\n '.join(map(self._case_valu e_keyword, self._value_keywords_with_mode('Quirks'))), | |
| 168 'quirks_mode_or_ua_sheet_mode_values_keywords': '\n '.join(map(se lf._case_value_keyword, self._value_keywords_with_mode('QuirksOrUASheet'))), | 163 'quirks_mode_or_ua_sheet_mode_values_keywords': '\n '.join(map(se lf._case_value_keyword, self._value_keywords_with_mode('QuirksOrUASheet'))), |
| 169 } | 164 } |
| 170 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output | 165 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output |
| 171 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 166 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
| 172 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 167 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
| 173 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 168 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
| 174 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) | 169 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) |
| 175 return gperf.communicate(gperf_input)[0] | 170 return gperf.communicate(gperf_input)[0] |
| 176 | 171 |
| 177 | 172 |
| 178 if __name__ == "__main__": | 173 if __name__ == "__main__": |
| 179 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) | 174 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) |
| OLD | NEW |