OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 """This module providesfunctionality for systems to generate | 6 """This module providesfunctionality for systems to generate |
7 Dart interfaces from the IDL database.""" | 7 Dart interfaces from the IDL database.""" |
8 | 8 |
9 import os | 9 import os |
10 import systembase | 10 import systembase |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 (self._common_prefix, parent.type.id)) | 108 (self._common_prefix, parent.type.id)) |
109 | 109 |
110 comment = ' extends' | 110 comment = ' extends' |
111 extends_str = '' | 111 extends_str = '' |
112 if extends: | 112 if extends: |
113 extends_str += ' extends ' + ', '.join(extends) | 113 extends_str += ' extends ' + ', '.join(extends) |
114 comment = ',' | 114 comment = ',' |
115 if suppressed_extends: | 115 if suppressed_extends: |
116 extends_str += ' /*%s %s */' % (comment, ', '.join(suppressed_extends)) | 116 extends_str += ' /*%s %s */' % (comment, ', '.join(suppressed_extends)) |
117 | 117 |
| 118 factory_provider = None |
| 119 constructor_info = AnalyzeConstructor(self._interface) |
| 120 if constructor_info: |
| 121 factory_provider = '_' + typename + 'FactoryProvider'; |
| 122 |
118 if typename in interface_factories: | 123 if typename in interface_factories: |
119 extends_str += ' default ' + interface_factories[typename] | 124 factory_provider = interface_factories[typename] |
| 125 |
| 126 if factory_provider: |
| 127 extends_str += ' default ' + factory_provider |
120 | 128 |
121 # TODO(vsm): Add appropriate package / namespace syntax. | 129 # TODO(vsm): Add appropriate package / namespace syntax. |
122 (self._members_emitter, | 130 (self._members_emitter, |
123 self._top_level_emitter) = self._emitter.Emit( | 131 self._top_level_emitter) = self._emitter.Emit( |
124 self._template + '$!TOP_LEVEL', | 132 self._template + '$!TOP_LEVEL', |
125 ID=typename, | 133 ID=typename, |
126 EXTENDS=extends_str) | 134 EXTENDS=extends_str) |
127 | 135 |
| 136 if constructor_info: |
| 137 self._members_emitter.Emit( |
| 138 '\n' |
| 139 ' $CTOR($PARAMS);\n', |
| 140 CTOR=typename, |
| 141 PARAMS=constructor_info.ParametersInterfaceDeclaration()); |
| 142 |
128 element_type = MaybeTypedArrayElementType(self._interface) | 143 element_type = MaybeTypedArrayElementType(self._interface) |
129 if element_type: | 144 if element_type: |
130 self._members_emitter.Emit( | 145 self._members_emitter.Emit( |
131 '\n' | 146 '\n' |
132 ' $CTOR(int length);\n' | 147 ' $CTOR(int length);\n' |
133 '\n' | 148 '\n' |
134 ' $CTOR.fromList(List<$TYPE> list);\n' | 149 ' $CTOR.fromList(List<$TYPE> list);\n' |
135 '\n' | 150 '\n' |
136 ' $CTOR.fromBuffer(ArrayBuffer buffer);\n', | 151 ' $CTOR.fromBuffer(ArrayBuffer buffer);\n', |
137 CTOR=self._interface.id, | 152 CTOR=self._interface.id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 209 |
195 # Interfaces get secondary members directly via the superinterfaces. | 210 # Interfaces get secondary members directly via the superinterfaces. |
196 def AddSecondaryAttribute(self, interface, getter, setter): | 211 def AddSecondaryAttribute(self, interface, getter, setter): |
197 pass | 212 pass |
198 | 213 |
199 def AddSecondaryOperation(self, interface, attr): | 214 def AddSecondaryOperation(self, interface, attr): |
200 pass | 215 pass |
201 | 216 |
202 def AddEventAttributes(self, event_attrs): | 217 def AddEventAttributes(self, event_attrs): |
203 pass | 218 pass |
OLD | NEW |