Chromium Code Reviews| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 def Generate(self): | 209 def Generate(self): |
| 210 if 'Callback' in self._interface.ext_attrs: | 210 if 'Callback' in self._interface.ext_attrs: |
| 211 self.GenerateCallback() | 211 self.GenerateCallback() |
| 212 else: | 212 else: |
| 213 self.GenerateInterface() | 213 self.GenerateInterface() |
| 214 | 214 |
| 215 def GenerateCallback(self): | 215 def GenerateCallback(self): |
| 216 """Generates a typedef for the callback interface.""" | 216 """Generates a typedef for the callback interface.""" |
| 217 handlers = [operation for operation in self._interface.operations | 217 handlers = [operation for operation in self._interface.operations |
| 218 if operation.id == 'handleEvent'] | 218 if operation.id == 'handleEvent'] |
| 219 info = AnalyzeOperation(self._interface, handlers) | 219 info = AnalyzeOperation(self._interface, handlers) |
|
Anton Muhin
2012/10/18 09:59:16
nit: you can move this line below and maybe even m
| |
| 220 code = self._library_emitter.FileEmitter(self._interface.id) | 220 code = self._library_emitter.FileEmitter(self._interface.id) |
| 221 code.Emit(self._template_loader.Load('callback.darttemplate')) | 221 code.Emit(self._template_loader.Load('callback.darttemplate')) |
| 222 code.Emit('typedef $TYPE $NAME($PARAMS);\n', | 222 code.Emit('typedef void $NAME($PARAMS);\n', |
| 223 NAME=self._interface.id, | 223 NAME=self._interface.id, |
| 224 TYPE=self._DartType(info.type_name), | |
| 225 PARAMS=info.ParametersDeclaration(self._DartType)) | 224 PARAMS=info.ParametersDeclaration(self._DartType)) |
| 226 self._backend.GenerateCallback(info) | 225 self._backend.GenerateCallback(info) |
| 227 | 226 |
| 228 def GenerateInterface(self): | 227 def GenerateInterface(self): |
| 229 interface_name = self._interface_type_info.interface_name() | 228 interface_name = self._interface_type_info.interface_name() |
| 230 | 229 |
| 231 if (self._interface_type_info.has_generated_interface() and | 230 if (self._interface_type_info.has_generated_interface() and |
| 232 not self._interface_type_info.merged_into()): | 231 not self._interface_type_info.merged_into()): |
| 233 interface_emitter = self._library_emitter.FileEmitter(interface_name) | 232 interface_emitter = self._library_emitter.FileEmitter(interface_name) |
| 234 else: | 233 else: |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1112 | 1111 |
| 1113 library_emitter = self._multiemitter.FileEmitter(library_file_path) | 1112 library_emitter = self._multiemitter.FileEmitter(library_file_path) |
| 1114 library_file_dir = os.path.dirname(library_file_path) | 1113 library_file_dir = os.path.dirname(library_file_path) |
| 1115 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) | 1114 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) |
| 1116 imports_emitter = library_emitter.Emit( | 1115 imports_emitter = library_emitter.Emit( |
| 1117 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) | 1116 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) |
| 1118 for path in sorted(self._path_to_emitter.keys()): | 1117 for path in sorted(self._path_to_emitter.keys()): |
| 1119 relpath = os.path.relpath(path, library_file_dir) | 1118 relpath = os.path.relpath(path, library_file_dir) |
| 1120 imports_emitter.Emit( | 1119 imports_emitter.Emit( |
| 1121 "#source('$PATH');\n", PATH=massage_path(relpath)) | 1120 "#source('$PATH');\n", PATH=massage_path(relpath)) |
| OLD | NEW |