Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_css_property_apis.py

Issue 2684353002: Added CSSPropertyDescriptor.h.tmpl to generate CSSPropertyDescriptor.h. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) 42 # Stores a map of API method name -> (return_type, parameters)
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')) 47 ApiMethod = namedtuple('ApiMethod', ('return_type', 'parameters'))
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 'ordered_api_method_names': self.ordered_api_method_names, 85 'ordered_api_method_names': self.ordered_api_method_names,
85 } 86 }
86 87
87 @template_expander.use_jinja('CSSPropertyAPI.h.tmpl') 88 @template_expander.use_jinja('CSSPropertyAPI.h.tmpl')
88 def generate_property_api(self): 89 def generate_property_api(self):
89 return { 90 return {
90 'api_method_names': self.ordered_api_method_names, 91 'api_method_names': self.ordered_api_method_names,
91 'api_methods': self.all_api_methods, 92 'api_methods': self.all_api_methods,
92 } 93 }
93 94
95 @template_expander.use_jinja('CSSPropertyDescriptor.h.tmpl')
96 def generate_property_descriptor_h(self):
97 return {
98 'ordered_api_method_names': self.ordered_api_method_names,
sashab 2017/02/10 01:24:34 Change to ordered in other patch as well
99 'api_methods': self.all_api_methods,
sashab 2017/02/10 01:24:34 all_api_methods
100 }
101
94 # Provides a function object given the classname of the property. 102 # Provides a function object given the classname of the property.
95 def generate_property_api_h_builder(self, api_classname): 103 def generate_property_api_h_builder(self, api_classname):
96 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl') 104 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl')
97 def generate_property_api_h(): 105 def generate_property_api_h():
98 return { 106 return {
99 'api_classname': api_classname, 107 'api_classname': api_classname,
100 'methods_for_class': self.methods_for_classes[api_classname], 108 'methods_for_class': self.methods_for_classes[api_classname],
101 'all_api_methods': self.all_api_methods, 109 'all_api_methods': self.all_api_methods,
102 } 110 }
103 return generate_property_api_h 111 return generate_property_api_h
104 112
105 if __name__ == '__main__': 113 if __name__ == '__main__':
106 json5_generator.Maker(CSSPropertyAPIWriter).main() 114 json5_generator.Maker(CSSPropertyAPIWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698