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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 BASE=self._super_interface) | 168 BASE=self._super_interface) |
169 for const in sorted(self._interface.constants, ConstantOutputOrder): | 169 for const in sorted(self._interface.constants, ConstantOutputOrder): |
170 self._EmitConstant(consts_emitter, const) | 170 self._EmitConstant(consts_emitter, const) |
171 | 171 |
172 def AddConstant(self, constant): | 172 def AddConstant(self, constant): |
173 if (not self._super_interface or | 173 if (not self._super_interface or |
174 self._interface.id is self._super_interface): | 174 self._interface.id is self._super_interface): |
175 self._EmitConstant(self._members_emitter, constant) | 175 self._EmitConstant(self._members_emitter, constant) |
176 | 176 |
177 def _EmitConstant(self, emitter, constant): | 177 def _EmitConstant(self, emitter, constant): |
178 emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n', | 178 emitter.Emit('\n static final $TYPE$NAME = $VALUE;\n', |
179 NAME=constant.id, | 179 NAME=constant.id, |
180 TYPE=DartType(constant.type.id), | 180 TYPE=TypeOrNothing(DartType(constant.type.id), |
| 181 constant.type.id), |
181 VALUE=constant.value) | 182 VALUE=constant.value) |
182 | 183 |
183 def AddAttribute(self, getter, setter): | 184 def AddAttribute(self, getter, setter): |
184 if getter and setter and getter.type.id == setter.type.id: | 185 if getter and setter and getter.type.id == setter.type.id: |
185 self._members_emitter.Emit('\n $TYPE $NAME;\n', | 186 self._members_emitter.Emit('\n $TYPE $NAME;\n', |
186 NAME=DartDomNameOfAttribute(getter), | 187 NAME=DartDomNameOfAttribute(getter), |
187 TYPE=DartType(getter.type.id)); | 188 TYPE=TypeOrVar(DartType(getter.type.id), |
| 189 getter.type.id)) |
188 return | 190 return |
189 if getter and not setter: | 191 if getter and not setter: |
190 self._members_emitter.Emit('\n final $TYPE $NAME;\n', | 192 self._members_emitter.Emit('\n final $TYPE$NAME;\n', |
191 NAME=DartDomNameOfAttribute(getter), | 193 NAME=DartDomNameOfAttribute(getter), |
192 TYPE=DartType(getter.type.id)); | 194 TYPE=TypeOrNothing(DartType(getter.type.id), |
| 195 getter.type.id)) |
193 return | 196 return |
194 raise Exception('Unexpected getter/setter combination %s %s' % | 197 raise Exception('Unexpected getter/setter combination %s %s' % |
195 (getter, setter)) | 198 (getter, setter)) |
196 | 199 |
197 def AddIndexer(self, element_type): | 200 def AddIndexer(self, element_type): |
198 # Interface inherits all operations from List<element_type>. | 201 # Interface inherits all operations from List<element_type>. |
199 pass | 202 pass |
200 | 203 |
201 def AddOperation(self, info): | 204 def AddOperation(self, info): |
202 """ | 205 """ |
203 Arguments: | 206 Arguments: |
204 operations - contains the overloads, one or more operations with the same | 207 operations - contains the overloads, one or more operations with the same |
205 name. | 208 name. |
206 """ | 209 """ |
207 self._members_emitter.Emit('\n' | 210 self._members_emitter.Emit('\n' |
208 ' $TYPE $NAME($PARAMS);\n', | 211 ' $TYPE $NAME($PARAMS);\n', |
209 TYPE=info.type_name, | 212 TYPE=info.type_name, |
210 NAME=info.name, | 213 NAME=info.name, |
211 PARAMS=info.ParametersInterfaceDeclaration()) | 214 PARAMS=info.ParametersInterfaceDeclaration()) |
212 | 215 |
213 # Interfaces get secondary members directly via the superinterfaces. | 216 # Interfaces get secondary members directly via the superinterfaces. |
214 def AddSecondaryAttribute(self, interface, getter, setter): | 217 def AddSecondaryAttribute(self, interface, getter, setter): |
215 pass | 218 pass |
216 | 219 |
217 def AddSecondaryOperation(self, interface, attr): | 220 def AddSecondaryOperation(self, interface, attr): |
218 pass | 221 pass |
OLD | NEW |