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

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

Issue 2620883002: Convert Settings.in, CSSValueKeywords.in, SVGCSSValueKeywords.in to json5 (Closed)
Patch Set: Fix comment indent in data 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 (C) 2013 Google Inc. All rights reserved. 2 # Copyright (C) 2013 Google Inc. All rights reserved.
3 # Copyright (C) 2013 Igalia S.L. All rights reserved. 3 # Copyright (C) 2013 Igalia S.L. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 11 matching lines...) Expand all
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 import sys 31 import sys
32 import in_generator 32 import json5_generator
33 import template_expander 33 import template_expander
34 import name_utilities 34 import name_utilities
35 from make_settings import to_passing_type, to_idl_type 35 from make_settings import to_passing_type, to_idl_type
36 36
37 37
38 class MakeInternalSettingsWriter(in_generator.Writer): 38 class MakeInternalSettingsWriter(json5_generator.Writer):
39 defaults = {
40 'type': 'bool',
41 'initial': None,
42 'invalidate': None,
43 }
44 default_parameters = {}
45 filters = { 39 filters = {
46 'upper_first': name_utilities.upper_first, 40 'upper_first': name_utilities.upper_first,
47 'to_passing_type': to_passing_type, 41 'to_passing_type': to_passing_type,
48 'to_idl_type': to_idl_type, 42 'to_idl_type': to_idl_type,
49 } 43 }
50 44
51 def __init__(self, in_file_path): 45 def __init__(self, json5_file_path):
52 super(MakeInternalSettingsWriter, self).__init__(in_file_path) 46 super(MakeInternalSettingsWriter, self).__init__(json5_file_path)
53 47
54 self.in_file.name_dictionaries.sort(key=lambda entry: entry['name']) 48 self.json5_file.name_dictionaries.sort(key=lambda entry: entry['name'])
55 49
56 self._outputs = { 50 self._outputs = {
57 ('InternalSettingsGenerated.h'): self.generate_header, 51 ('InternalSettingsGenerated.h'): self.generate_header,
58 ('InternalSettingsGenerated.cpp'): self.generate_implementation, 52 ('InternalSettingsGenerated.cpp'): self.generate_implementation,
59 ('InternalSettingsGenerated.idl'): self.generate_idl, 53 ('InternalSettingsGenerated.idl'): self.generate_idl,
60 } 54 }
61 self._template_context = { 55 self._template_context = {
62 'settings': self.in_file.name_dictionaries, 56 'settings': self.json5_file.name_dictionaries,
63 } 57 }
64 58
65 @template_expander.use_jinja('InternalSettingsGenerated.h.tmpl', filters=fil ters) 59 @template_expander.use_jinja('InternalSettingsGenerated.h.tmpl', filters=fil ters)
66 def generate_header(self): 60 def generate_header(self):
67 return self._template_context 61 return self._template_context
68 62
69 @template_expander.use_jinja('InternalSettingsGenerated.cpp.tmpl', filters=f ilters) 63 @template_expander.use_jinja('InternalSettingsGenerated.cpp.tmpl', filters=f ilters)
70 def generate_implementation(self): 64 def generate_implementation(self):
71 return self._template_context 65 return self._template_context
72 66
73 @template_expander.use_jinja('InternalSettingsGenerated.idl.tmpl', filters=f ilters) 67 @template_expander.use_jinja('InternalSettingsGenerated.idl.tmpl', filters=f ilters)
74 def generate_idl(self): 68 def generate_idl(self):
75 return self._template_context 69 return self._template_context
76 70
77 71
78 if __name__ == '__main__': 72 if __name__ == '__main__':
79 in_generator.Maker(MakeInternalSettingsWriter).main(sys.argv) 73 json5_generator.Maker(MakeInternalSettingsWriter).main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698