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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_names.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 sys 30 import sys
31 31
32 import hasher 32 import hasher
33 import in_generator 33 import json5_generator
34 import template_expander 34 import template_expander
35 import name_utilities 35 import name_utilities
36 36
37 def _symbol(entry): 37 def _symbol(entry):
38 if entry['Symbol'] is not None: 38 if entry['Symbol'] is not None:
39 return entry['Symbol'] 39 return entry['Symbol']
40 # FIXME: Remove this special case for the ugly x-webkit-foo attributes. 40 # FIXME: Remove this special case for the ugly x-webkit-foo attributes.
41 if entry['name'].startswith('-webkit-'): 41 if entry['name'].startswith('-webkit-'):
42 return entry['name'].replace('-', '_')[1:] 42 return entry['name'].replace('-', '_')[1:]
43 return name_utilities.cpp_name(entry).replace('-', '_') 43 return name_utilities.cpp_name(entry).replace('-', '_')
44 44
45 45
46 class MakeNamesWriter(in_generator.Writer): 46 class MakeNamesWriter(json5_generator.Writer):
47 defaults = { 47 default_parameters = {
48 'Conditional': None, # FIXME: Add support for Conditional. 48 'Conditional': None, # FIXME: Add support for Conditional.
49 'ImplementedAs': None, 49 'ImplementedAs': None,
50 'RuntimeEnabled': None, # What should we do for runtime-enabled feature s? 50 'RuntimeEnabled': None, # What should we do for runtime-enabled feature s?
51 'Symbol': None, 51 'Symbol': None,
52 } 52 }
53 default_parameters = { 53 default_metadata = {
54 'export': '', 54 'export': '',
55 'namespace': '', 55 'namespace': '',
56 'suffix': '', 56 'suffix': '',
57 } 57 }
58 filters = { 58 filters = {
59 'cpp_name': name_utilities.cpp_name, 59 'cpp_name': name_utilities.cpp_name,
60 'hash': hasher.hash, 60 'hash': hasher.hash,
61 'script_name': name_utilities.script_name, 61 'script_name': name_utilities.script_name,
62 'symbol': _symbol, 62 'symbol': _symbol,
63 'to_macro_style': name_utilities.to_macro_style, 63 'to_macro_style': name_utilities.to_macro_style,
64 } 64 }
65 65
66 def __init__(self, in_file_path): 66 def __init__(self, json5_file_path):
67 super(MakeNamesWriter, self).__init__(in_file_path) 67 super(MakeNamesWriter, self).__init__(json5_file_path)
68 68
69 namespace = self.in_file.parameters['namespace'].strip('"') 69 namespace = self.json5_file.metadata['namespace'].strip('"')
70 suffix = self.in_file.parameters['suffix'].strip('"') 70 suffix = self.json5_file.metadata['suffix'].strip('"')
71 export = self.in_file.parameters['export'].strip('"') 71 export = self.json5_file.metadata['export'].strip('"')
72 72
73 assert namespace, 'A namespace is required.' 73 assert namespace, 'A namespace is required.'
74 74
75 self._outputs = { 75 self._outputs = {
76 (namespace + suffix + 'Names.h'): self.generate_header, 76 (namespace + suffix + 'Names.h'): self.generate_header,
77 (namespace + suffix + 'Names.cpp'): self.generate_implementation, 77 (namespace + suffix + 'Names.cpp'): self.generate_implementation,
78 } 78 }
79 self._template_context = { 79 self._template_context = {
80 'namespace': namespace, 80 'namespace': namespace,
81 'suffix': suffix, 81 'suffix': suffix,
82 'export': export, 82 'export': export,
83 'entries': self.in_file.name_dictionaries, 83 'entries': self.json5_file.name_dictionaries,
84 'in_files': self.in_file.file_paths, 84 'in_files': self.json5_file.file_paths,
85 } 85 }
86 86
87 @template_expander.use_jinja("MakeNames.h.tmpl", filters=filters) 87 @template_expander.use_jinja("MakeNames.h.tmpl", filters=filters)
88 def generate_header(self): 88 def generate_header(self):
89 return self._template_context 89 return self._template_context
90 90
91 @template_expander.use_jinja("MakeNames.cpp.tmpl", filters=filters) 91 @template_expander.use_jinja("MakeNames.cpp.tmpl", filters=filters)
92 def generate_implementation(self): 92 def generate_implementation(self):
93 return self._template_context 93 return self._template_context
94 94
95 95
96 if __name__ == "__main__": 96 if __name__ == "__main__":
97 in_generator.Maker(MakeNamesWriter).main(sys.argv) 97 json5_generator.Maker(MakeNamesWriter).main()
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/build/scripts/make_media_features.py ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698