| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "core/css/HashTools.h" | 45 #include "core/css/HashTools.h" |
| 46 #include <string.h> | 46 #include <string.h> |
| 47 | 47 |
| 48 #ifdef _MSC_VER | 48 #ifdef _MSC_VER |
| 49 // Disable the warnings from casting a 64-bit pointer to 32-bit long | 49 // Disable the warnings from casting a 64-bit pointer to 32-bit long |
| 50 // warning C4302: 'type cast': truncation from 'char (*)[28]' to 'long' | 50 // warning C4302: 'type cast': truncation from 'char (*)[28]' to 'long' |
| 51 // warning C4311: 'type cast': pointer truncation from 'char (*)[18]' to 'long' | 51 // warning C4311: 'type cast': pointer truncation from 'char (*)[18]' to 'long' |
| 52 #pragma warning(disable : 4302 4311) | 52 #pragma warning(disable : 4302 4311) |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #if defined(__clang__) |
| 56 #pragma clang diagnostic push |
| 57 // TODO(thakis): Remove once we use a gperf that no longer produces "register". |
| 58 #pragma clang diagnostic ignored "-Wdeprecated-register" |
| 59 #endif |
| 60 |
| 55 namespace blink { | 61 namespace blink { |
| 56 static const char valueListStringPool[] = { | 62 static const char valueListStringPool[] = { |
| 57 %(value_keyword_strings)s | 63 %(value_keyword_strings)s |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 static const unsigned short valueListStringOffsets[] = { | 66 static const unsigned short valueListStringOffsets[] = { |
| 61 %(value_keyword_offsets)s | 67 %(value_keyword_offsets)s |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 %%} | 70 %%} |
| 65 %%struct-type | 71 %%struct-type |
| 66 struct Value; | 72 struct Value; |
| 67 %%omit-struct-type | 73 %%omit-struct-type |
| 68 %%language=C++ | 74 %%language=C++ |
| 69 %%readonly-tables | 75 %%readonly-tables |
| 70 %%compare-strncmp | 76 %%compare-strncmp |
| 71 %%define class-name %(class_name)sHash | 77 %%define class-name %(class_name)sHash |
| 72 %%define lookup-function-name findValueImpl | 78 %%define lookup-function-name findValueImpl |
| 73 %%define hash-function-name value_hash_function | 79 %%define hash-function-name value_hash_function |
| 74 %%define slot-name nameOffset | 80 %%define slot-name nameOffset |
| 75 %%define word-array-name value_word_list | 81 %%define word-array-name value_word_list |
| 76 %%pic | 82 %%pic |
| 77 %%enum | 83 %%enum |
| 78 %%%% | 84 %%%% |
| 79 %(value_keyword_to_enum_map)s | 85 %(value_keyword_to_enum_map)s |
| 80 %%%% | 86 %%%% |
| 81 const Value* findValue(register const char* str, register unsigned int len) | 87 |
| 82 { | 88 #if defined(__clang__) |
| 83 return CSSValueKeywordsHash::findValueImpl(str, len); | 89 #pragma clang diagnostic pop |
| 90 #endif |
| 91 |
| 92 const Value* findValue(const char* str, unsigned int len) { |
| 93 return CSSValueKeywordsHash::findValueImpl(str, len); |
| 84 } | 94 } |
| 85 | 95 |
| 86 const char* getValueName(CSSValueID id) | 96 const char* getValueName(CSSValueID id) { |
| 87 { | 97 ASSERT(id > 0 && id < numCSSValueKeywords); |
| 88 ASSERT(id > 0 && id < numCSSValueKeywords); | 98 return valueListStringPool + valueListStringOffsets[id - 1]; |
| 89 return valueListStringPool + valueListStringOffsets[id - 1]; | |
| 90 } | 99 } |
| 91 | 100 |
| 92 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode) | 101 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode) { |
| 93 { | 102 switch (id) { |
| 94 switch (id) { | 103 %(ua_sheet_mode_values_keywords)s |
| 95 %(ua_sheet_mode_values_keywords)s | 104 return isUASheetBehavior(mode); |
| 96 return isUASheetBehavior(mode); | 105 %(quirks_mode_or_ua_sheet_mode_values_keywords)s |
| 97 %(quirks_mode_or_ua_sheet_mode_values_keywords)s | 106 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); |
| 98 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); | 107 default: |
| 99 default: | 108 return true; |
| 100 return true; | 109 } |
| 101 } | |
| 102 } | 110 } |
| 103 | 111 |
| 104 } // namespace blink | 112 } // namespace blink |
| 105 """ | 113 """ |
| 106 | 114 |
| 107 | 115 |
| 108 class CSSValueKeywordsWriter(json5_generator.Writer): | 116 class CSSValueKeywordsWriter(json5_generator.Writer): |
| 109 class_name = "CSSValueKeywords" | 117 class_name = "CSSValueKeywords" |
| 110 | 118 |
| 111 def __init__(self, file_paths): | 119 def __init__(self, file_paths): |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 # CalledProcessError like subprocess would do when shell=True is set. | 180 # CalledProcessError like subprocess would do when shell=True is set. |
| 173 try: | 181 try: |
| 174 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s
ubprocess.PIPE, universal_newlines=True) | 182 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s
ubprocess.PIPE, universal_newlines=True) |
| 175 return gperf.communicate(gperf_input)[0] | 183 return gperf.communicate(gperf_input)[0] |
| 176 except OSError: | 184 except OSError: |
| 177 raise subprocess.CalledProcessError(127, gperf_args, output='Command
not found.') | 185 raise subprocess.CalledProcessError(127, gperf_args, output='Command
not found.') |
| 178 | 186 |
| 179 | 187 |
| 180 if __name__ == "__main__": | 188 if __name__ == "__main__": |
| 181 json5_generator.Maker(CSSValueKeywordsWriter).main() | 189 json5_generator.Maker(CSSValueKeywordsWriter).main() |
| OLD | NEW |