| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 for property_ in self.properties().values(): | 71 for property_ in self.properties().values(): |
| 72 if property_['api_class'] is None: | 72 if property_['api_class'] is None: |
| 73 continue | 73 continue |
| 74 classname = get_classname(property_) | 74 classname = get_classname(property_) |
| 75 properties_for_class[classname].append(property_['property_id']) | 75 properties_for_class[classname].append(property_['property_id']) |
| 76 property_enums_for_class[classname].append(property_['enum_value']) | 76 property_enums_for_class[classname].append(property_['enum_value']) |
| 77 # For api_classes that contain multiple properties, combine all impl
emented properties. | 77 # For api_classes that contain multiple properties, combine all impl
emented properties. |
| 78 # This list contains duplicate entries, but is only used to check if
a method is | 78 # This list contains duplicate entries, but is only used to check if
a method is |
| 79 # implemented for an api_class. | 79 # implemented for an api_class. |
| 80 self.methods_for_classes[classname] += property_['api_methods'] | 80 self.methods_for_classes[classname] += property_['api_methods'] |
| 81 self._outputs[classname + '.h'] = self.generate_property_api_h_build
er(classname) | 81 self._outputs[classname + '.h'] = self.generate_property_api_h_build
er(classname, property_['name']) |
| 82 | 82 |
| 83 # Stores a list of classes with elements (index, classname, [propertyIDs
, ..], [api_methods, ...]). | 83 # Stores a list of classes with elements (index, classname, [propertyIDs
, ..], [api_methods, ...]). |
| 84 self._api_classes = [] | 84 self._api_classes = [] |
| 85 for i, classname in enumerate(properties_for_class.keys()): | 85 for i, classname in enumerate(properties_for_class.keys()): |
| 86 self._api_classes.append(ApiClass( | 86 self._api_classes.append(ApiClass( |
| 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 )) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 117 } | 117 } |
| 118 | 118 |
| 119 @template_expander.use_jinja('CSSPropertyAPI.h.tmpl') | 119 @template_expander.use_jinja('CSSPropertyAPI.h.tmpl') |
| 120 def generate_property_api(self): | 120 def generate_property_api(self): |
| 121 return { | 121 return { |
| 122 'ordered_api_method_names': self.ordered_api_method_names, | 122 'ordered_api_method_names': self.ordered_api_method_names, |
| 123 'all_api_methods': self.all_api_methods, | 123 'all_api_methods': self.all_api_methods, |
| 124 } | 124 } |
| 125 | 125 |
| 126 # Provides a function object given the classname of the property. | 126 # Provides a function object given the classname of the property. |
| 127 def generate_property_api_h_builder(self, api_classname): | 127 def generate_property_api_h_builder(self, api_classname, property_name): |
| 128 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl') | 128 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl') |
| 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 'property_name': property_name, |
| 132 'methods_for_class': self.methods_for_classes[api_classname], | 133 'methods_for_class': self.methods_for_classes[api_classname], |
| 133 'all_api_methods': self.all_api_methods, | 134 'all_api_methods': self.all_api_methods, |
| 134 } | 135 } |
| 135 return generate_property_api_h | 136 return generate_property_api_h |
| 136 | 137 |
| 137 if __name__ == '__main__': | 138 if __name__ == '__main__': |
| 138 json5_generator.Maker(CSSPropertyAPIWriter).main() | 139 json5_generator.Maker(CSSPropertyAPIWriter).main() |
| OLD | NEW |