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

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

Issue 2620883002: Convert Settings.in, CSSValueKeywords.in, SVGCSSValueKeywords.in to json5 (Closed)
Patch Set: Convert CSSProperties.in to json5 format Created 3 years, 11 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 in_generator 8 import json5_generator
9 import template_expander 9 import template_expander
10 import make_style_builder 10 import make_style_builder
11 11
12 from collections import namedtuple, defaultdict 12 from collections import namedtuple, defaultdict
13 13
14 14
15 # Gets the classname for a given property. 15 # Gets the classname for a given property.
16 def get_classname(property): 16 def get_classname(property):
17 if property['api_class'] is True: 17 if property['api_class'] is True:
18 # This property had the generated_api_class flag set in CSSProperties.in . 18 # This property had the generated_api_class flag set in CSSProperties.js on5.
19 return 'CSSPropertyAPI' + property['upper_camel_name'] 19 return 'CSSPropertyAPI' + property['upper_camel_name']
20 # This property has a specified class name. 20 # This property has a specified class name.
21 assert isinstance(property['api_class'], str), \ 21 assert isinstance(property['api_class'], str), \
22 ("api_class value for " + property['api_class'] + " should be None, True or a string") 22 ("api_class value for " + property['api_class'] + " should be None, True or a string")
23 return property['api_class'] 23 return property['api_class']
24 24
25 25
26 class CSSPropertyAPIWriter(make_style_builder.StyleBuilderWriter): 26 class CSSPropertyAPIWriter(make_style_builder.StyleBuilderWriter):
27 def __init__(self, in_file_path): 27 def __init__(self, json5_file_path):
28 super(CSSPropertyAPIWriter, self).__init__(in_file_path) 28 super(CSSPropertyAPIWriter, self).__init__(json5_file_path)
29 self._outputs = { 29 self._outputs = {
30 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_cpp, 30 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_cpp,
31 } 31 }
32 32
33 # Temporary map of API classname to list of propertyIDs that the API cla ss is for. 33 # Temporary map of API classname to list of propertyIDs that the API cla ss is for.
34 properties_for_class = defaultdict(list) 34 properties_for_class = defaultdict(list)
35 for property in self._properties.values(): 35 for property in self._properties.values():
36 if property['api_class'] is None: 36 if property['api_class'] is None:
37 continue 37 continue
38 classname = get_classname(property) 38 classname = get_classname(property)
(...skipping 21 matching lines...) Expand all
60 # This returned function generates a .h file for the specified property. 60 # This returned function generates a .h file for the specified property.
61 def generate_property_api_h_builder(self, api_classname): 61 def generate_property_api_h_builder(self, api_classname):
62 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl') 62 @template_expander.use_jinja('CSSPropertyAPIFiles.h.tmpl')
63 def generate_property_api_h(): 63 def generate_property_api_h():
64 return { 64 return {
65 'api_classname': api_classname, 65 'api_classname': api_classname,
66 } 66 }
67 return generate_property_api_h 67 return generate_property_api_h
68 68
69 if __name__ == '__main__': 69 if __name__ == '__main__':
70 in_generator.Maker(CSSPropertyAPIWriter).main(sys.argv) 70 json5_generator.Maker(CSSPropertyAPIWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698