| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 import subprocess | 3 import subprocess |
| 4 import sys | 4 import sys |
| 5 | 5 |
| 6 import css_properties | 6 import css_properties |
| 7 import in_generator | 7 import in_generator |
| 8 import license | 8 import license |
| 9 | 9 |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 const int firstCSSProperty = %(first_property_id)s; | 34 const int firstCSSProperty = %(first_property_id)s; |
| 35 const int numCSSProperties = %(properties_count)s; | 35 const int numCSSProperties = %(properties_count)s; |
| 36 const int lastCSSProperty = %(last_property_id)d; | 36 const int lastCSSProperty = %(last_property_id)d; |
| 37 const size_t maxCSSPropertyNameLength = %(max_name_length)d; | 37 const size_t maxCSSPropertyNameLength = %(max_name_length)d; |
| 38 | 38 |
| 39 const char* getPropertyName(CSSPropertyID); | 39 const char* getPropertyName(CSSPropertyID); |
| 40 const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID); | 40 const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID); |
| 41 WTF::String getPropertyNameString(CSSPropertyID); | 41 WTF::String getPropertyNameString(CSSPropertyID); |
| 42 WTF::String getJSPropertyName(CSSPropertyID); | 42 WTF::String getJSPropertyName(CSSPropertyID); |
| 43 bool isInternalProperty(CSSPropertyID id); | |
| 44 | 43 |
| 45 inline CSSPropertyID convertToCSSPropertyID(int value) | 44 inline CSSPropertyID convertToCSSPropertyID(int value) |
| 46 { | 45 { |
| 47 ASSERT((value >= firstCSSProperty && value <= lastCSSProperty) || value == C
SSPropertyInvalid); | 46 ASSERT((value >= firstCSSProperty && value <= lastCSSProperty) || value == C
SSPropertyInvalid); |
| 48 return static_cast<CSSPropertyID>(value); | 47 return static_cast<CSSPropertyID>(value); |
| 49 } | 48 } |
| 50 | 49 |
| 51 } // namespace blink | 50 } // namespace blink |
| 52 | 51 |
| 53 namespace WTF { | 52 namespace WTF { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 if (!nextCharacter) | 154 if (!nextCharacter) |
| 156 break; | 155 break; |
| 157 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp
per(nextCharacter) : nextCharacter; | 156 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp
per(nextCharacter) : nextCharacter; |
| 158 } | 157 } |
| 159 *resultPointer++ = character; | 158 *resultPointer++ = character; |
| 160 } | 159 } |
| 161 *resultPointer = '\\0'; | 160 *resultPointer = '\\0'; |
| 162 return String(result); | 161 return String(result); |
| 163 } | 162 } |
| 164 | 163 |
| 165 bool isInternalProperty(CSSPropertyID id) | |
| 166 { | |
| 167 switch (id) { | |
| 168 %(internal_properties)s | |
| 169 return true; | |
| 170 default: | |
| 171 return false; | |
| 172 } | |
| 173 } | |
| 174 | |
| 175 } // namespace blink | 164 } // namespace blink |
| 176 """ | 165 """ |
| 177 | 166 |
| 178 | 167 |
| 179 class CSSPropertyNamesWriter(css_properties.CSSProperties): | 168 class CSSPropertyNamesWriter(css_properties.CSSProperties): |
| 180 class_name = "CSSPropertyNames" | 169 class_name = "CSSPropertyNames" |
| 181 | 170 |
| 182 def __init__(self, in_file_path): | 171 def __init__(self, in_file_path): |
| 183 super(CSSPropertyNamesWriter, self).__init__(in_file_path) | 172 super(CSSPropertyNamesWriter, self).__init__(in_file_path) |
| 184 self._outputs = {(self.class_name + ".h"): self.generate_header, | 173 self._outputs = {(self.class_name + ".h"): self.generate_header, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 209 css_name_and_enum_pairs = [(property['name'], property_id) for property_
id, property in self._properties.items()] | 198 css_name_and_enum_pairs = [(property['name'], property_id) for property_
id, property in self._properties.items()] |
| 210 for name, aliased_name in self._aliases.items(): | 199 for name, aliased_name in self._aliases.items(): |
| 211 css_name_and_enum_pairs.append((name, css_properties.css_name_to_enu
m(aliased_name))) | 200 css_name_and_enum_pairs.append((name, css_properties.css_name_to_enu
m(aliased_name))) |
| 212 | 201 |
| 213 gperf_input = GPERF_TEMPLATE % { | 202 gperf_input = GPERF_TEMPLATE % { |
| 214 'license': license.license_for_generated_cpp(), | 203 'license': license.license_for_generated_cpp(), |
| 215 'class_name': self.class_name, | 204 'class_name': self.class_name, |
| 216 'property_name_strings': '\n'.join(map(lambda property: ' "%(name
)s\\0"' % property, self._properties_list)), | 205 'property_name_strings': '\n'.join(map(lambda property: ' "%(name
)s\\0"' % property, self._properties_list)), |
| 217 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % of
fset, property_offsets)), | 206 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % of
fset, property_offsets)), |
| 218 'property_to_enum_map': '\n'.join(map(lambda property: '%s, %s' % pr
operty, css_name_and_enum_pairs)), | 207 'property_to_enum_map': '\n'.join(map(lambda property: '%s, %s' % pr
operty, css_name_and_enum_pairs)), |
| 219 'internal_properties': '\n'.join("case %s:" % property_id for proper
ty_id, property in self._properties.items() if property['is_internal']), | |
| 220 } | 208 } |
| 221 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 209 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 222 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 210 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
| 223 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 211 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
| 224 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 212 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
| 225 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) | 213 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) |
| 226 return gperf.communicate(gperf_input)[0] | 214 return gperf.communicate(gperf_input)[0] |
| 227 | 215 |
| 228 | 216 |
| 229 if __name__ == "__main__": | 217 if __name__ == "__main__": |
| 230 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) | 218 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) |
| OLD | NEW |