OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
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 | 32 |
32 import in_generator | 33 import in_generator |
33 import template_expander | 34 import template_expander |
34 import name_utilities | 35 import name_utilities |
35 | 36 |
36 from make_qualified_names import MakeQualifiedNamesWriter | 37 from make_qualified_names import MakeQualifiedNamesWriter |
37 | 38 |
38 | 39 |
39 class MakeElementFactoryWriter(MakeQualifiedNamesWriter): | 40 class MakeElementFactoryWriter(MakeQualifiedNamesWriter): |
40 defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{ | 41 defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{ |
(...skipping 20 matching lines...) Expand all Loading... |
61 self._outputs.update({ | 62 self._outputs.update({ |
62 (self.namespace + 'ElementFactory.h'): self.generate_factory_header, | 63 (self.namespace + 'ElementFactory.h'): self.generate_factory_header, |
63 (self.namespace + 'ElementFactory.cpp'): self.generate_factory_imple
mentation, | 64 (self.namespace + 'ElementFactory.cpp'): self.generate_factory_imple
mentation, |
64 ('V8' + self.namespace + 'ElementWrapperFactory.h'): self.generate_w
rapper_factory_header, | 65 ('V8' + self.namespace + 'ElementWrapperFactory.h'): self.generate_w
rapper_factory_header, |
65 ('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate
_wrapper_factory_implementation, | 66 ('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate
_wrapper_factory_implementation, |
66 }) | 67 }) |
67 | 68 |
68 fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName
'].strip('"') | 69 fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName
'].strip('"') |
69 fallback_js_interface = self.tags_in_file.parameters['fallbackJSInterfac
eName'].strip('"') or fallback_interface | 70 fallback_js_interface = self.tags_in_file.parameters['fallbackJSInterfac
eName'].strip('"') or fallback_interface |
70 | 71 |
71 for tag in self._template_context['tags']: | 72 interface_counts = defaultdict(int) |
| 73 tags = self._template_context['tags'] |
| 74 for tag in tags: |
72 tag['has_js_interface'] = self._has_js_interface(tag) | 75 tag['has_js_interface'] = self._has_js_interface(tag) |
73 tag['js_interface'] = self._js_interface(tag) | 76 tag['js_interface'] = self._js_interface(tag) |
74 tag['interface'] = self._interface(tag) | 77 tag['interface'] = self._interface(tag) |
| 78 interface_counts[tag['interface']] += 1 |
| 79 |
| 80 for tag in tags: |
| 81 tag['multipleTagNames'] = interface_counts[tag['interface']] > 1 |
75 | 82 |
76 self._template_context.update({ | 83 self._template_context.update({ |
77 'fallback_interface': fallback_interface, | 84 'fallback_interface': fallback_interface, |
78 'fallback_js_interface': fallback_js_interface, | 85 'fallback_js_interface': fallback_js_interface, |
79 }) | 86 }) |
80 | 87 |
81 @template_expander.use_jinja('ElementFactory.h.tmpl', filters=filters) | 88 @template_expander.use_jinja('ElementFactory.h.tmpl', filters=filters) |
82 def generate_factory_header(self): | 89 def generate_factory_header(self): |
83 return self._template_context | 90 return self._template_context |
84 | 91 |
(...skipping 26 matching lines...) Expand all Loading... |
111 if tag['JSInterfaceName']: | 118 if tag['JSInterfaceName']: |
112 return tag['JSInterfaceName'] | 119 return tag['JSInterfaceName'] |
113 return self._interface(tag) | 120 return self._interface(tag) |
114 | 121 |
115 def _has_js_interface(self, tag): | 122 def _has_js_interface(self, tag): |
116 return not tag['noConstructor'] and self._js_interface(tag) != ('%sEleme
nt' % self.namespace) | 123 return not tag['noConstructor'] and self._js_interface(tag) != ('%sEleme
nt' % self.namespace) |
117 | 124 |
118 | 125 |
119 if __name__ == "__main__": | 126 if __name__ == "__main__": |
120 in_generator.Maker(MakeElementFactoryWriter).main(sys.argv) | 127 in_generator.Maker(MakeElementFactoryWriter).main(sys.argv) |
OLD | NEW |