| 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 name_utilities import enum_for_css_keyword | 8 from name_utilities import enum_for_css_keyword |
| 9 from name_utilities import upper_first_letter | 9 from name_utilities import upper_first_letter |
| 10 import json5_generator | 10 import json5_generator |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 %%} | 64 %%} |
| 65 %%struct-type | 65 %%struct-type |
| 66 struct Value; | 66 struct Value; |
| 67 %%omit-struct-type | 67 %%omit-struct-type |
| 68 %%language=C++ | 68 %%language=C++ |
| 69 %%readonly-tables | 69 %%readonly-tables |
| 70 %%compare-strncmp | 70 %%compare-strncmp |
| 71 %%define class-name %(class_name)sHash | 71 %%define class-name %(class_name)sHash |
| 72 %%define lookup-function-name findValueImpl | 72 %%define lookup-function-name findValueImpl |
| 73 %%define hash-function-name value_hash_function | 73 %%define hash-function-name value_hash_function |
| 74 %%define slot-name nameOffset | 74 %%define slot-name name_offset |
| 75 %%define word-array-name value_word_list | 75 %%define word-array-name value_word_list |
| 76 %%pic | 76 %%pic |
| 77 %%enum | 77 %%enum |
| 78 %%%% | 78 %%%% |
| 79 %(value_keyword_to_enum_map)s | 79 %(value_keyword_to_enum_map)s |
| 80 %%%% | 80 %%%% |
| 81 const Value* findValue(register const char* str, register unsigned int len) | 81 const Value* FindValue(register const char* str, register unsigned int len) |
| 82 { | 82 { |
| 83 return CSSValueKeywordsHash::findValueImpl(str, len); | 83 return CSSValueKeywordsHash::findValueImpl(str, len); |
| 84 } | 84 } |
| 85 | 85 |
| 86 const char* getValueName(CSSValueID id) | 86 const char* getValueName(CSSValueID id) |
| 87 { | 87 { |
| 88 ASSERT(id > 0 && id < numCSSValueKeywords); | 88 ASSERT(id > 0 && id < numCSSValueKeywords); |
| 89 return valueListStringPool + valueListStringOffsets[id - 1]; | 89 return valueListStringPool + valueListStringOffsets[id - 1]; |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode) | 92 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode) |
| 93 { | 93 { |
| 94 switch (id) { | 94 switch (id) { |
| 95 %(ua_sheet_mode_values_keywords)s | 95 %(ua_sheet_mode_values_keywords)s |
| 96 return isUASheetBehavior(mode); | 96 return IsUASheetBehavior(mode); |
| 97 %(quirks_mode_or_ua_sheet_mode_values_keywords)s | 97 %(quirks_mode_or_ua_sheet_mode_values_keywords)s |
| 98 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); | 98 return IsUASheetBehavior(mode) || IsQuirksModeBehavior(mode); |
| 99 default: | 99 default: |
| 100 return true; | 100 return true; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace blink | 104 } // namespace blink |
| 105 """ | 105 """ |
| 106 | 106 |
| 107 | 107 |
| 108 class CSSValueKeywordsWriter(json5_generator.Writer): | 108 class CSSValueKeywordsWriter(json5_generator.Writer): |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 164 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 165 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 165 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
| 166 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 166 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
| 167 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 167 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
| 168 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) | 168 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) |
| 169 return gperf.communicate(gperf_input)[0] | 169 return gperf.communicate(gperf_input)[0] |
| 170 | 170 |
| 171 | 171 |
| 172 if __name__ == "__main__": | 172 if __name__ == "__main__": |
| 173 json5_generator.Maker(CSSValueKeywordsWriter).main() | 173 json5_generator.Maker(CSSValueKeywordsWriter).main() |
| OLD | NEW |