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 |
11 | 11 |
12 | 12 |
13 HEADER_TEMPLATE = """ | 13 HEADER_TEMPLATE = """ |
14 %(license)s | 14 %(license)s |
15 | 15 |
16 #ifndef %(class_name)s_h | 16 #ifndef %(class_name)s_h |
17 #define %(class_name)s_h | 17 #define %(class_name)s_h |
18 | 18 |
19 #include "core/css/CSSParserMode.h" | 19 #include "core/css/CSSParserMode.h" |
20 #include <string.h> | 20 #include <string.h> |
21 | 21 |
22 namespace WebCore { | 22 namespace blink { |
23 | 23 |
24 enum CSSValueID { | 24 enum CSSValueID { |
25 %(value_keyword_enums)s | 25 %(value_keyword_enums)s |
26 }; | 26 }; |
27 | 27 |
28 const int numCSSValueKeywords = %(value_keywords_count)d; | 28 const int numCSSValueKeywords = %(value_keywords_count)d; |
29 const size_t maxCSSValueKeywordLength = %(max_value_keyword_length)d; | 29 const size_t maxCSSValueKeywordLength = %(max_value_keyword_length)d; |
30 | 30 |
31 const char* getValueName(unsigned short id); | 31 const char* getValueName(unsigned short id); |
32 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode); | 32 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode); |
33 | 33 |
34 } // namespace WebCore | 34 } // namespace blink |
35 | 35 |
36 #endif // %(class_name)s_h | 36 #endif // %(class_name)s_h |
37 """ | 37 """ |
38 | 38 |
39 GPERF_TEMPLATE = """ | 39 GPERF_TEMPLATE = """ |
40 %%{ | 40 %%{ |
41 %(license)s | 41 %(license)s |
42 | 42 |
43 #include "config.h" | 43 #include "config.h" |
44 #include "%(class_name)s.h" | 44 #include "%(class_name)s.h" |
45 #include "core/css/HashTools.h" | 45 #include "core/css/HashTools.h" |
46 #include <string.h> | 46 #include <string.h> |
47 | 47 |
48 namespace WebCore { | 48 namespace blink { |
49 static const char valueListStringPool[] = { | 49 static const char valueListStringPool[] = { |
50 "\\0" | 50 "\\0" |
51 %(value_keyword_strings)s | 51 %(value_keyword_strings)s |
52 }; | 52 }; |
53 | 53 |
54 static const unsigned short valueListStringOffsets[] = { | 54 static const unsigned short valueListStringOffsets[] = { |
55 %(value_keyword_offsets)s | 55 %(value_keyword_offsets)s |
56 }; | 56 }; |
57 | 57 |
58 %%} | 58 %%} |
(...skipping 30 matching lines...) Expand all Loading... |
89 switch (id) { | 89 switch (id) { |
90 %(ua_sheet_mode_values_keywords)s | 90 %(ua_sheet_mode_values_keywords)s |
91 return isUASheetBehavior(mode); | 91 return isUASheetBehavior(mode); |
92 %(quirks_mode_or_ua_sheet_mode_values_keywords)s | 92 %(quirks_mode_or_ua_sheet_mode_values_keywords)s |
93 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); | 93 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode); |
94 default: | 94 default: |
95 return true; | 95 return true; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 } // namespace WebCore | 99 } // namespace blink |
100 """ | 100 """ |
101 | 101 |
102 | 102 |
103 class CSSValueKeywordsWriter(in_generator.Writer): | 103 class CSSValueKeywordsWriter(in_generator.Writer): |
104 class_name = "CSSValueKeywords" | 104 class_name = "CSSValueKeywords" |
105 defaults = { | 105 defaults = { |
106 'mode': None, | 106 'mode': None, |
107 } | 107 } |
108 | 108 |
109 def __init__(self, file_paths): | 109 def __init__(self, file_paths): |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 # 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 |
166 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 166 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
167 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 167 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
168 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 168 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
169 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) |
170 return gperf.communicate(gperf_input)[0] | 170 return gperf.communicate(gperf_input)[0] |
171 | 171 |
172 | 172 |
173 if __name__ == "__main__": | 173 if __name__ == "__main__": |
174 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) | 174 in_generator.Maker(CSSValueKeywordsWriter).main(sys.argv) |
OLD | NEW |