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

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

Issue 2677603002: Revert of Convert make_qualified_names and make_element_factory to use JSON5. (Closed)
Patch Set: 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 from collections import defaultdict 31 from collections import defaultdict
32 32
33 import json5_generator 33 import in_generator
34 import template_expander 34 import template_expander
35 import name_utilities 35 import name_utilities
36 36
37 from make_qualified_names import MakeQualifiedNamesWriter 37 from make_qualified_names import MakeQualifiedNamesWriter
38 38
39 39
40 class MakeElementFactoryWriter(MakeQualifiedNamesWriter): 40 class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
41 default_parameters = { 41 defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{
42 'JSInterfaceName': {}, 42 'JSInterfaceName': None,
43 'Conditional': {}, 43 'Conditional': None,
44 'constructorNeedsCreatedByParser': {}, 44 'constructorNeedsCreatedByParser': None,
45 'interfaceName': {}, 45 'interfaceName': None,
46 'noConstructor': {}, 46 'noConstructor': None,
47 'noTypeHelpers': {}, 47 'noTypeHelpers': None,
48 'runtimeEnabled': {}, 48 'runtimeEnabled': None,
49 } 49 })
50 default_metadata = dict(MakeQualifiedNamesWriter.default_metadata, **{ 50 default_parameters = dict(MakeQualifiedNamesWriter.default_parameters, **{
51 'fallbackInterfaceName': '', 51 'fallbackInterfaceName': '',
52 'fallbackJSInterfaceName': '', 52 'fallbackJSInterfaceName': '',
53 }) 53 })
54 filters = MakeQualifiedNamesWriter.filters 54 filters = MakeQualifiedNamesWriter.filters
55 55
56 def __init__(self, json5_file_paths): 56 def __init__(self, in_file_paths):
57 super(MakeElementFactoryWriter, self).__init__(json5_file_paths) 57 super(MakeElementFactoryWriter, self).__init__(in_file_paths)
58 58
59 # FIXME: When we start using these element factories, we'll want to 59 # FIXME: When we start using these element factories, we'll want to
60 # remove the "new" prefix and also have our base class generate 60 # remove the "new" prefix and also have our base class generate
61 # *Names.h and *Names.cpp. 61 # *Names.h and *Names.cpp.
62 self._outputs.update({ 62 self._outputs.update({
63 (self.namespace + 'ElementFactory.h'): self.generate_factory_header, 63 (self.namespace + 'ElementFactory.h'): self.generate_factory_header,
64 (self.namespace + 'ElementFactory.cpp'): self.generate_factory_imple mentation, 64 (self.namespace + 'ElementFactory.cpp'): self.generate_factory_imple mentation,
65 }) 65 })
66 66
67 fallback_interface = self.tags_json5_file.metadata['fallbackInterfaceNam e'].strip('"') 67 fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName '].strip('"')
68 fallback_js_interface = self.tags_json5_file.metadata['fallbackJSInterfa ceName'].strip('"') or fallback_interface 68 fallback_js_interface = self.tags_in_file.parameters['fallbackJSInterfac eName'].strip('"') or fallback_interface
69 69
70 interface_counts = defaultdict(int) 70 interface_counts = defaultdict(int)
71 tags = self._template_context['tags'] 71 tags = self._template_context['tags']
72 for tag in tags: 72 for tag in tags:
73 tag['has_js_interface'] = self._has_js_interface(tag) 73 tag['has_js_interface'] = self._has_js_interface(tag)
74 tag['js_interface'] = self._js_interface(tag) 74 tag['js_interface'] = self._js_interface(tag)
75 tag['interface'] = self._interface(tag) 75 tag['interface'] = self._interface(tag)
76 interface_counts[tag['interface']] += 1 76 interface_counts[tag['interface']] += 1
77 77
78 for tag in tags: 78 for tag in tags:
(...skipping 28 matching lines...) Expand all
107 def _js_interface(self, tag): 107 def _js_interface(self, tag):
108 if tag['JSInterfaceName']: 108 if tag['JSInterfaceName']:
109 return tag['JSInterfaceName'] 109 return tag['JSInterfaceName']
110 return self._interface(tag) 110 return self._interface(tag)
111 111
112 def _has_js_interface(self, tag): 112 def _has_js_interface(self, tag):
113 return not tag['noConstructor'] and self._js_interface(tag) != ('%sEleme nt' % self.namespace) 113 return not tag['noConstructor'] and self._js_interface(tag) != ('%sEleme nt' % self.namespace)
114 114
115 115
116 if __name__ == "__main__": 116 if __name__ == "__main__":
117 json5_generator.Maker(MakeElementFactoryWriter).main() 117 in_generator.Maker(MakeElementFactoryWriter).main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698