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

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

Issue 2638233002: Convert make_names and make_event_factory to use json5 config format. (Closed)
Patch Set: fix PLATFORM_EXPORT 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 (C) 2013 Google Inc. All rights reserved. 2 # Copyright (C) 2013 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 import os.path 30 import os.path
31 import sys 31 import sys
32 32
33 import in_generator 33 import json5_generator
34 import license 34 import license
35 import name_utilities 35 import name_utilities
36 import template_expander 36 import template_expander
37 37
38 38
39 HEADER_TEMPLATE = """%(license)s 39 HEADER_TEMPLATE = """%(license)s
40 40
41 #ifndef %(namespace)s%(suffix)sHeaders_h 41 #ifndef %(namespace)s%(suffix)sHeaders_h
42 #define %(namespace)s%(suffix)sHeaders_h 42 #define %(namespace)s%(suffix)sHeaders_h
43 %(base_header_for_suffix)s 43 %(base_header_for_suffix)s
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 or name == 'WebGLContextEvent' 95 or name == 'WebGLContextEvent'
96 or name == 'WebKitAnimationEvent' 96 or name == 'WebKitAnimationEvent'
97 or name == 'WebKitTransitionEvent' 97 or name == 'WebKitTransitionEvent'
98 or name == 'WheelEvent') 98 or name == 'WheelEvent')
99 99
100 100
101 def measure_name(name): 101 def measure_name(name):
102 return 'DocumentCreateEvent' + name 102 return 'DocumentCreateEvent' + name
103 103
104 104
105 class EventFactoryWriter(in_generator.Writer): 105 class EventFactoryWriter(json5_generator.Writer):
106 defaults = { 106 default_parameters = {
107 'ImplementedAs': None, 107 'ImplementedAs': None,
108 'RuntimeEnabled': None, 108 'RuntimeEnabled': None,
109 } 109 }
110 default_parameters = { 110 default_metadata = {
111 'export': '', 111 'export': '',
112 'namespace': '', 112 'namespace': '',
113 'suffix': '', 113 'suffix': '',
114 } 114 }
115 filters = { 115 filters = {
116 'cpp_name': name_utilities.cpp_name, 116 'cpp_name': name_utilities.cpp_name,
117 'lower_first': name_utilities.lower_first, 117 'lower_first': name_utilities.lower_first,
118 'script_name': name_utilities.script_name, 118 'script_name': name_utilities.script_name,
119 'create_event_whitelist': create_event_whitelist, 119 'create_event_whitelist': create_event_whitelist,
120 'create_event_legacy_whitelist': create_event_legacy_whitelist, 120 'create_event_legacy_whitelist': create_event_legacy_whitelist,
121 'measure_name': measure_name, 121 'measure_name': measure_name,
122 } 122 }
123 123
124 def __init__(self, in_file_path): 124 def __init__(self, json5_file_path):
125 super(EventFactoryWriter, self).__init__(in_file_path) 125 super(EventFactoryWriter, self).__init__(json5_file_path)
126 self.namespace = self.in_file.parameters['namespace'].strip('"') 126 self.namespace = self.json5_file.metadata['namespace'].strip('"')
127 self.suffix = self.in_file.parameters['suffix'].strip('"') 127 self.suffix = self.json5_file.metadata['suffix'].strip('"')
128 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header, 128 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header,
129 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation, 129 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation,
130 } 130 }
131 131
132 def _fatal(self, message): 132 def _fatal(self, message):
133 print 'FATAL ERROR: ' + message 133 print 'FATAL ERROR: ' + message
134 exit(1) 134 exit(1)
135 135
136 def _headers_header_include_path(self, entry): 136 def _headers_header_include_path(self, entry):
137 if entry['ImplementedAs']: 137 if entry['ImplementedAs']:
(...skipping 25 matching lines...) Expand all
163 163
164 def generate_headers_header(self): 164 def generate_headers_header(self):
165 base_header_for_suffix = '' 165 base_header_for_suffix = ''
166 if self.suffix: 166 if self.suffix:
167 base_header_for_suffix = '\n#include "core/%(namespace)sHeaders.h"\n ' % {'namespace': self.namespace} 167 base_header_for_suffix = '\n#include "core/%(namespace)sHeaders.h"\n ' % {'namespace': self.namespace}
168 return HEADER_TEMPLATE % { 168 return HEADER_TEMPLATE % {
169 'license': license.license_for_generated_cpp(), 169 'license': license.license_for_generated_cpp(),
170 'namespace': self.namespace, 170 'namespace': self.namespace,
171 'suffix': self.suffix, 171 'suffix': self.suffix,
172 'base_header_for_suffix': base_header_for_suffix, 172 'base_header_for_suffix': base_header_for_suffix,
173 'includes': '\n'.join(self._headers_header_includes(self.in_file.nam e_dictionaries)), 173 'includes': '\n'.join(self._headers_header_includes(self.json5_file. name_dictionaries)),
174 } 174 }
175 175
176 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) 176 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters)
177 def generate_implementation(self): 177 def generate_implementation(self):
178 return { 178 return {
179 'namespace': self.namespace, 179 'namespace': self.namespace,
180 'suffix': self.suffix, 180 'suffix': self.suffix,
181 'events': self.in_file.name_dictionaries, 181 'events': self.json5_file.name_dictionaries,
182 } 182 }
183 183
184 184
185 if __name__ == "__main__": 185 if __name__ == "__main__":
186 in_generator.Maker(EventFactoryWriter).main(sys.argv) 186 json5_generator.Maker(EventFactoryWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698