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 provides shared functionality for the system to generate | 6 """This module provides shared functionality for the system to generate |
7 Dart:html APIs from the IDL database.""" | 7 Dart:html APIs from the IDL database.""" |
8 | 8 |
9 import emitter | 9 import emitter |
10 import os | 10 import os |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 self.GenerateInterface() | 269 self.GenerateInterface() |
270 | 270 |
271 def GenerateCallback(self): | 271 def GenerateCallback(self): |
272 """Generates a typedef for the callback interface.""" | 272 """Generates a typedef for the callback interface.""" |
273 handlers = [operation for operation in self._interface.operations | 273 handlers = [operation for operation in self._interface.operations |
274 if operation.id == 'handleEvent'] | 274 if operation.id == 'handleEvent'] |
275 info = AnalyzeOperation(self._interface, handlers) | 275 info = AnalyzeOperation(self._interface, handlers) |
276 code = self._library_emitter.FileEmitter(self._interface.id, | 276 code = self._library_emitter.FileEmitter(self._interface.id, |
277 self._library_name) | 277 self._library_name) |
278 code.Emit(self._template_loader.Load('callback.darttemplate')) | 278 code.Emit(self._template_loader.Load('callback.darttemplate')) |
| 279 |
| 280 typedef_name = self._renamer.RenameInterface(self._interface) |
279 code.Emit('typedef void $NAME($PARAMS);\n', | 281 code.Emit('typedef void $NAME($PARAMS);\n', |
280 NAME=self._interface.id, | 282 NAME=self._interface.id, |
281 PARAMS=info.ParametersDeclaration(self._DartType)) | 283 PARAMS=info.ParametersDeclaration(self._DartType)) |
282 self._backend.GenerateCallback(info) | 284 self._backend.GenerateCallback(info) |
283 | 285 |
284 def GenerateInterface(self): | 286 def GenerateInterface(self): |
285 interface_name = self._interface_type_info.interface_name() | 287 interface_name = self._interface_type_info.interface_name() |
286 | 288 |
287 factory_provider = None | 289 factory_provider = None |
288 if interface_name in interface_factories: | 290 if interface_name in interface_factories: |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 for library_name in libraries: | 990 for library_name in libraries: |
989 self._libraries[library_name] = DartLibrary( | 991 self._libraries[library_name] = DartLibrary( |
990 library_name, template_loader, library_type, output_dir) | 992 library_name, template_loader, library_type, output_dir) |
991 | 993 |
992 def AddFile(self, basename, library_name, path): | 994 def AddFile(self, basename, library_name, path): |
993 self._libraries[library_name].AddFile(path) | 995 self._libraries[library_name].AddFile(path) |
994 | 996 |
995 def Emit(self, emitter, auxiliary_dir): | 997 def Emit(self, emitter, auxiliary_dir): |
996 for lib in self._libraries.values(): | 998 for lib in self._libraries.values(): |
997 lib.Emit(emitter, auxiliary_dir) | 999 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |