OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import sys | 6 import sys |
7 | 7 |
8 import json5_generator | 8 import json5_generator |
9 import template_expander | 9 import template_expander |
10 import make_style_builder | 10 import make_style_builder |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 index=i + 1, | 87 index=i + 1, |
88 classname=classname, | 88 classname=classname, |
89 property_ids=properties_for_class[classname], | 89 property_ids=properties_for_class[classname], |
90 methods_for_class=self.methods_for_classes[classname] | 90 methods_for_class=self.methods_for_classes[classname] |
91 )) | 91 )) |
92 | 92 |
93 # Build a table converting id (including aliases) to api class descripto
rs | 93 # Build a table converting id (including aliases) to api class descripto
rs |
94 self._invalid_descriptor_index = 0 | 94 self._invalid_descriptor_index = 0 |
95 # Initialize the whole thing to the invalid descriptor to handle gaps | 95 # Initialize the whole thing to the invalid descriptor to handle gaps |
96 num_indices = self.last_unresolved_property_id + 1 | 96 num_indices = self.last_unresolved_property_id + 1 |
97 self._descriptor_indices = [self._invalid_descriptor_index] * num_indice
s | 97 self._descriptor_indices = dict.fromkeys(xrange(num_indices), {'id': sel
f._invalid_descriptor_index, 'api': None}) |
98 # Now populate all entries for which there exists a class, i.e. that are
n't gaps | 98 # Now populate all entries for which there exists a class, i.e. that are
n't gaps |
99 for api_class in self._api_classes: | 99 for api_class in self._api_classes: |
100 for property_enum in property_enums_for_class[api_class.classname]: | 100 for property_enum in property_enums_for_class[api_class.classname]: |
101 self._descriptor_indices[property_enum] = api_class.index | 101 self._descriptor_indices[property_enum] = {'id': api_class.index
, 'api': api_class.classname} |
102 | 102 |
103 @template_expander.use_jinja('CSSPropertyDescriptor.cpp.tmpl') | 103 @template_expander.use_jinja('CSSPropertyDescriptor.cpp.tmpl') |
104 def generate_property_descriptor_cpp(self): | 104 def generate_property_descriptor_cpp(self): |
105 return { | 105 return { |
106 'api_classes': self._api_classes, | 106 'api_classes': self._api_classes, |
107 'ordered_api_method_names': self.ordered_api_method_names, | 107 'ordered_api_method_names': self.ordered_api_method_names, |
108 'descriptor_indices': self._descriptor_indices, | 108 'descriptor_indices': self._descriptor_indices, |
109 'invalid_descriptor_index': self._invalid_descriptor_index | 109 'invalid_descriptor_index': self._invalid_descriptor_index |
110 } | 110 } |
111 | 111 |
(...skipping 17 matching lines...) Expand all Loading... |
129 def generate_property_api_h(): | 129 def generate_property_api_h(): |
130 return { | 130 return { |
131 'api_classname': api_classname, | 131 'api_classname': api_classname, |
132 'methods_for_class': self.methods_for_classes[api_classname], | 132 'methods_for_class': self.methods_for_classes[api_classname], |
133 'all_api_methods': self.all_api_methods, | 133 'all_api_methods': self.all_api_methods, |
134 } | 134 } |
135 return generate_property_api_h | 135 return generate_property_api_h |
136 | 136 |
137 if __name__ == '__main__': | 137 if __name__ == '__main__': |
138 json5_generator.Maker(CSSPropertyAPIWriter).main() | 138 json5_generator.Maker(CSSPropertyAPIWriter).main() |
OLD | NEW |