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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 ('V8' + self.namespace + 'ElementWrapperFactory.h'): self.generate_w rapper_factory_header, | 65 ('V8' + self.namespace + 'ElementWrapperFactory.h'): self.generate_w rapper_factory_header, |
66 ('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate _wrapper_factory_implementation, | 66 ('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate _wrapper_factory_implementation, |
67 }) | 67 }) |
68 | 68 |
69 fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName '].strip('"') | 69 fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName '].strip('"') |
70 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 |
71 | 71 |
72 for tag in self._template_context['tags']: | 72 interface_counts = {} |
73 tags = self._template_context['tags'] | |
74 for tag in tags: | |
73 tag['has_js_interface'] = self._has_js_interface(tag) | 75 tag['has_js_interface'] = self._has_js_interface(tag) |
74 tag['js_interface'] = self._js_interface(tag) | 76 tag['js_interface'] = self._js_interface(tag) |
75 tag['interface'] = self._interface(tag) | 77 tag['interface'] = self._interface(tag) |
78 if tag['interface'] not in interface_counts: | |
79 interface_counts[tag['interface']] = 1 | |
80 else: | |
81 interface_counts[tag['interface']] += 1 | |
abarth-chromium
2013/11/09 01:54:50
There's some fancier Pythony way of doing this.
adamk
2013/11/11 20:33:28
Found two ways to do this. defaultdict seems to be
| |
82 | |
83 for tag in tags: | |
84 tag['multipleTagNames'] = interface_counts[tag['interface']] > 1 | |
76 | 85 |
77 self._template_context.update({ | 86 self._template_context.update({ |
78 'fallback_interface': fallback_interface, | 87 'fallback_interface': fallback_interface, |
79 'fallback_js_interface': fallback_js_interface, | 88 'fallback_js_interface': fallback_js_interface, |
80 }) | 89 }) |
81 | 90 |
82 @template_expander.use_jinja('ElementFactory.h.tmpl', filters=filters) | 91 @template_expander.use_jinja('ElementFactory.h.tmpl', filters=filters) |
83 def generate_factory_header(self): | 92 def generate_factory_header(self): |
84 return self._template_context | 93 return self._template_context |
85 | 94 |
(...skipping 26 matching lines...) Expand all Loading... | |
112 if tag['JSInterfaceName']: | 121 if tag['JSInterfaceName']: |
113 return tag['JSInterfaceName'] | 122 return tag['JSInterfaceName'] |
114 return self._interface(tag) | 123 return self._interface(tag) |
115 | 124 |
116 def _has_js_interface(self, tag): | 125 def _has_js_interface(self, tag): |
117 return not tag['mapToTagName'] and not tag['noConstructor'] and self._js _interface(tag) != ('%sElement' % self.namespace) | 126 return not tag['mapToTagName'] and not tag['noConstructor'] and self._js _interface(tag) != ('%sElement' % self.namespace) |
118 | 127 |
119 | 128 |
120 if __name__ == "__main__": | 129 if __name__ == "__main__": |
121 in_generator.Maker(MakeElementFactoryWriter).main(sys.argv) | 130 in_generator.Maker(MakeElementFactoryWriter).main(sys.argv) |
OLD | NEW |