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

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

Issue 2567473002: Made a generator for CSSPropertyDescriptor.cpp (Closed)
Patch Set: removed accidental comment Created 4 years 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import sys
7
8 import in_generator
9 import template_expander
10 import make_style_builder
11
12
13 class CSSPropertyAPIWriter(make_style_builder.StyleBuilderWriter):
14 def __init__(self, in_file_path):
15 super(CSSPropertyAPIWriter, self).__init__(in_file_path)
16 self._outputs = {
17 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_h,
18 }
19
20 # Stores a list of all the property classnames.
21 self._api_classnames = []
22
23 # Stores a list of all CSS properties which have an index 'api_array_ind ex'.
24 self._properties_by_index = []
25
26 for property in self._properties.values():
27 if property['api_class'] is not None:
28 if property['api_class'] is True:
29 # This property had the generated_api_class flag set in CSSP roperties.in,
30 # but did not specify a class name.
31 self._api_classnames.append(property['upper_camel_name'])
32 elif isinstance(property['api_class'], str):
33 # This property has a specified class name.
34 self._api_classnames.append(property['api_class'])
35 self._properties_by_index.append(property)
36
37 # Sort classnames and remove duplicates.
38 self._api_classnames = sorted(list(set(self._api_classnames)))
alancutter (OOO until 2018) 2016/12/12 00:00:04 No need for list().
aazzam 2016/12/12 04:05:40 done :)
39
40 # Adding indexes to all of the properties, which specifies the order in which the properties
41 # are stored and accessed in the cssPropertyDescriptors array in CSSProp ertyDescriptors.cpp.
sashab 2016/12/09 00:58:25 Beautiful!! This whole file is awesome!
42 for i, property in enumerate(self._properties_by_index):
43 property['api_array_index'] = i + 1
44
45 @template_expander.use_jinja('CSSPropertyDescriptor.cpp.tmpl')
46 def generate_property_descriptor_h(self):
47 return {
48 'classnames': self._api_classnames,
49 'properties': self._properties_by_index,
alancutter (OOO until 2018) 2016/12/12 00:00:04 Use the same names between the script and the temp
aazzam 2016/12/12 04:05:40 done :)
50 }
51
52 if __name__ == '__main__':
53 in_generator.Maker(CSSPropertyAPIWriter).main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698