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 17 matching lines...) Expand all Loading... |
28 # This property had the generated_api_class flag set in CSSProperties.js
on5. | 28 # This property had the generated_api_class flag set in CSSProperties.js
on5. |
29 return 'CSSPropertyAPI' + property['upper_camel_name'] | 29 return 'CSSPropertyAPI' + property['upper_camel_name'] |
30 # This property has a specified class name. | 30 # This property has a specified class name. |
31 assert isinstance(property['api_class'], str), \ | 31 assert isinstance(property['api_class'], str), \ |
32 ("api_class value for " + property['api_class'] + " should be None, True
or a string") | 32 ("api_class value for " + property['api_class'] + " should be None, True
or a string") |
33 return property['api_class'] | 33 return property['api_class'] |
34 | 34 |
35 | 35 |
36 class CSSPropertyAPIWriter(StyleBuilderWriter): | 36 class CSSPropertyAPIWriter(StyleBuilderWriter): |
37 def __init__(self, json5_file_paths): | 37 def __init__(self, json5_file_paths): |
38 super(CSSPropertyAPIWriter, self).__init__(json5_file_paths[0]) | 38 super(CSSPropertyAPIWriter, self).__init__([json5_file_paths[0]]) |
39 # TODO(aazzam): Move the logic for loading CSSPropertyAPIMethods.json5 i
nto a new class APIMethodsWriter(). | 39 # TODO(aazzam): Move the logic for loading CSSPropertyAPIMethods.json5 i
nto a new class APIMethodsWriter(). |
40 assert len(json5_file_paths) == 2,\ | 40 assert len(json5_file_paths) == 2,\ |
41 'CSSPropertyAPIWriter requires 2 input json5 files files, got {}.'.f
ormat(len(json5_file_paths)) | 41 'CSSPropertyAPIWriter requires 2 input json5 files files, got {}.'.f
ormat(len(json5_file_paths)) |
42 | 42 |
43 self.css_property_api_methods = Json5File.load_from_files([json5_file_pa
ths[1]], {}, {}) | 43 self.css_property_api_methods = Json5File.load_from_files([json5_file_pa
ths[1]]) |
44 | 44 |
45 self._outputs = { | 45 self._outputs = { |
46 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_cpp, | 46 'CSSPropertyDescriptor.cpp': self.generate_property_descriptor_cpp, |
47 'CSSPropertyDescriptor.h': self.generate_property_descriptor_h, | 47 'CSSPropertyDescriptor.h': self.generate_property_descriptor_h, |
48 'CSSPropertyAPI.h': self.generate_property_api, | 48 'CSSPropertyAPI.h': self.generate_property_api, |
49 } | 49 } |
50 | 50 |
51 # Stores a map of API method name -> (return_type, parameters) | 51 # Stores a map of API method name -> (return_type, parameters) |
52 self.all_api_methods = {} | 52 self.all_api_methods = {} |
53 # Stores an ordered list of all API method names. This must match the | 53 # Stores an ordered list of all API method names. This must match the |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 'methods_for_class': self.methods_for_classes[api_classname], | 132 'methods_for_class': self.methods_for_classes[api_classname], |
133 'all_api_methods': self.all_api_methods, | 133 'all_api_methods': self.all_api_methods, |
134 } | 134 } |
135 return generate_property_api_h | 135 return generate_property_api_h |
136 | 136 |
137 if __name__ == '__main__': | 137 if __name__ == '__main__': |
138 json5_generator.Maker(CSSPropertyAPIWriter).main() | 138 json5_generator.Maker(CSSPropertyAPIWriter).main() |
OLD | NEW |