| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 %%} | 90 %%} |
| 91 %%struct-type | 91 %%struct-type |
| 92 struct Property; | 92 struct Property; |
| 93 %%omit-struct-type | 93 %%omit-struct-type |
| 94 %%language=C++ | 94 %%language=C++ |
| 95 %%readonly-tables | 95 %%readonly-tables |
| 96 %%global-table | 96 %%global-table |
| 97 %%compare-strncmp | 97 %%compare-strncmp |
| 98 %%define class-name %(class_name)sHash | 98 %%define class-name %(class_name)sHash |
| 99 %%define lookup-function-name findPropertyImpl | 99 %%define lookup-function-name findPropertyImpl |
| 100 %%define hash-function-name propery_hash_function | 100 %%define hash-function-name property_hash_function |
| 101 %%define slot-name nameOffset | 101 %%define slot-name nameOffset |
| 102 %%define word-array-name property_wordlist | 102 %%define word-array-name property_word_list |
| 103 %%enum | 103 %%enum |
| 104 %%%% | 104 %%%% |
| 105 %(property_to_enum_map)s | 105 %(property_to_enum_map)s |
| 106 %%%% | 106 %%%% |
| 107 const Property* findProperty(register const char* str, register unsigned int len
) | 107 const Property* findProperty(register const char* str, register unsigned int len
) |
| 108 { | 108 { |
| 109 return %(class_name)sHash::findPropertyImpl(str, len); | 109 return %(class_name)sHash::findPropertyImpl(str, len); |
| 110 } | 110 } |
| 111 | 111 |
| 112 const char* getPropertyName(CSSPropertyID id) | 112 const char* getPropertyName(CSSPropertyID id) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 gperf_input = GPERF_TEMPLATE % { | 239 gperf_input = GPERF_TEMPLATE % { |
| 240 'license': license.license_for_generated_cpp(), | 240 'license': license.license_for_generated_cpp(), |
| 241 'class_name': self.class_name, | 241 'class_name': self.class_name, |
| 242 'property_name_strings': '\n'.join(map(lambda property: ' "%(name
)s\\0"' % property, self._properties)), | 242 'property_name_strings': '\n'.join(map(lambda property: ' "%(name
)s\\0"' % property, self._properties)), |
| 243 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % of
fset, property_offsets)), | 243 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % of
fset, property_offsets)), |
| 244 'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(
enum_name)s' % property, self._properties + self._aliases)), | 244 'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(
enum_name)s' % property, self._properties + self._aliases)), |
| 245 'internal_properties': '\n'.join(map(self._case_properties, filter(l
ambda property: property['is_internal'], self._properties))), | 245 'internal_properties': '\n'.join(map(self._case_properties, filter(l
ambda property: property['is_internal'], self._properties))), |
| 246 } | 246 } |
| 247 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 247 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 248 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-D', '-n', '-
s', '2'] | 248 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
| 249 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
| 250 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
| 249 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) | 251 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) |
| 250 return gperf.communicate(gperf_input)[0] | 252 return gperf.communicate(gperf_input)[0] |
| 251 | 253 |
| 252 | 254 |
| 253 if __name__ == "__main__": | 255 if __name__ == "__main__": |
| 254 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) | 256 in_generator.Maker(CSSPropertiesWriter).main(sys.argv) |
| OLD | NEW |