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 18 matching lines...) Expand all Loading... |
29 super(CSSPropertyAPIWriter, self).__init__(None) | 29 super(CSSPropertyAPIWriter, self).__init__(None) |
30 # TODO(aazzam): Move the logic for loading CSSPropertyAPIMethods.json5 i
nto a new class APIMethodsWriter(). | 30 # TODO(aazzam): Move the logic for loading CSSPropertyAPIMethods.json5 i
nto a new class APIMethodsWriter(). |
31 assert len(json5_file_paths) == 2, 'CSSPropertyAPIWriter requires 2 inpu
t json5 files files, got %d.' % len(json5_file_paths) | 31 assert len(json5_file_paths) == 2, 'CSSPropertyAPIWriter requires 2 inpu
t json5 files files, got %d.' % len(json5_file_paths) |
32 | 32 |
33 self.css_properties = StyleBuilderWriter([json5_file_paths[0]]) | 33 self.css_properties = StyleBuilderWriter([json5_file_paths[0]]) |
34 self.css_property_api_methods = Json5File.load_from_files([json5_file_pa
ths[1]], {}, {}) | 34 self.css_property_api_methods = Json5File.load_from_files([json5_file_pa
ths[1]], {}, {}) |
35 | 35 |
36 self._outputs = { | 36 self._outputs = { |
37 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_cpp, | 37 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_cpp, |
38 'CSSPropertyAPI.h': self.generate_property_api, | 38 'CSSPropertyAPI.h': self.generate_property_api, |
| 39 'CSSPropertyDescriptor.h': self.generate_property_descriptor_h, |
39 } | 40 } |
40 | 41 |
41 # Stores a map of API method name -> (return_type, parameters, comment) | 42 # Stores a map of API method name -> (return_type, parameters, comment) |
42 self.all_api_methods = {} | 43 self.all_api_methods = {} |
43 # Stores an ordered list of all API method names. This must match the | 44 # Stores an ordered list of all API method names. This must match the |
44 # order they appear in the Descriptor object. | 45 # order they appear in the Descriptor object. |
45 self.ordered_api_method_names = [] | 46 self.ordered_api_method_names = [] |
46 ApiMethod = namedtuple('ApiMethod', ('return_type', 'parameters', 'comme
nt')) | 47 ApiMethod = namedtuple('ApiMethod', ('return_type', 'parameters', 'comme
nt')) |
47 for api_method in self.css_property_api_methods.name_dictionaries: | 48 for api_method in self.css_property_api_methods.name_dictionaries: |
48 self.ordered_api_method_names.append(api_method['name']) | 49 self.ordered_api_method_names.append(api_method['name']) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 'ordered_api_method_names': self.ordered_api_method_names, | 86 'ordered_api_method_names': self.ordered_api_method_names, |
86 } | 87 } |
87 | 88 |
88 @template_expander.use_jinja('CSSPropertyAPI.h.tmpl') | 89 @template_expander.use_jinja('CSSPropertyAPI.h.tmpl') |
89 def generate_property_api(self): | 90 def generate_property_api(self): |
90 return { | 91 return { |
91 'ordered_api_method_names': self.ordered_api_method_names, | 92 'ordered_api_method_names': self.ordered_api_method_names, |
92 'all_api_methods': self.all_api_methods, | 93 'all_api_methods': self.all_api_methods, |
93 } | 94 } |
94 | 95 |
| 96 @template_expander.use_jinja('CSSPropertyDescriptor.h.tmpl') |
| 97 def generate_property_descriptor_h(self): |
| 98 return { |
| 99 'ordered_api_method_names': self.ordered_api_method_names, |
| 100 'all_api_methods': self.all_api_methods, |
| 101 } |
| 102 |
95 # Provides a function object given the classname of the property. | 103 # Provides a function object given the classname of the property. |
96 def generate_property_api_h_builder(self, api_classname): | 104 def generate_property_api_h_builder(self, api_classname): |
97 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl') | 105 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl') |
98 def generate_property_api_h(): | 106 def generate_property_api_h(): |
99 return { | 107 return { |
100 'api_classname': api_classname, | 108 'api_classname': api_classname, |
101 'methods_for_class': self.methods_for_classes[api_classname], | 109 'methods_for_class': self.methods_for_classes[api_classname], |
102 'all_api_methods': self.all_api_methods, | 110 'all_api_methods': self.all_api_methods, |
103 } | 111 } |
104 return generate_property_api_h | 112 return generate_property_api_h |
105 | 113 |
106 if __name__ == '__main__': | 114 if __name__ == '__main__': |
107 json5_generator.Maker(CSSPropertyAPIWriter).main() | 115 json5_generator.Maker(CSSPropertyAPIWriter).main() |
OLD | NEW |