| 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 base functionality for systems to generate | 6 """This module provides base functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 from generator import * | 10 from generator import * |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 def GenerateLibraries(self, lib_dir): | 43 def GenerateLibraries(self, lib_dir): |
| 44 pass | 44 pass |
| 45 | 45 |
| 46 def Finish(self): | 46 def Finish(self): |
| 47 pass | 47 pass |
| 48 | 48 |
| 49 | 49 |
| 50 # Helper methods used by several systems. | 50 # Helper methods used by several systems. |
| 51 | 51 |
| 52 def _ProcessCallback(self, interface, info, file_path): | |
| 53 """Generates a typedef for the callback interface.""" | |
| 54 self._dart_interface_file_paths.append(file_path) | |
| 55 code = self._emitters.FileEmitter(file_path) | |
| 56 | |
| 57 code.Emit(self._templates.Load('callback.darttemplate')) | |
| 58 code.Emit('typedef $TYPE $NAME($PARAMS);\n', | |
| 59 NAME=interface.id, | |
| 60 TYPE=DartType(info.type_name), | |
| 61 PARAMS=info.ParametersImplementationDeclaration(DartType)) | |
| 62 | |
| 63 | |
| 64 def _GenerateLibFile(self, lib_template, lib_file_path, file_paths, | 52 def _GenerateLibFile(self, lib_template, lib_file_path, file_paths, |
| 65 **template_args): | 53 **template_args): |
| 66 """Generates a lib file from a template and a list of files. | 54 """Generates a lib file from a template and a list of files. |
| 67 | 55 |
| 68 Additional keyword arguments are passed to the template. | 56 Additional keyword arguments are passed to the template. |
| 69 Typically called from self.GenerateLibraries. | 57 Typically called from self.GenerateLibraries. |
| 70 """ | 58 """ |
| 71 # Load template. | 59 # Load template. |
| 72 template = self._templates.Load(lib_template) | 60 template = self._templates.Load(lib_template) |
| 73 # Generate the .lib file. | 61 # Generate the .lib file. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 self.templates = templates | 221 self.templates = templates |
| 234 self.database = database | 222 self.database = database |
| 235 self.emitters = emitters | 223 self.emitters = emitters |
| 236 self.type_registry = type_registry | 224 self.type_registry = type_registry |
| 237 self.renamer = renamer | 225 self.renamer = renamer |
| 238 self.output_dir = output_dir | 226 self.output_dir = output_dir |
| 239 | 227 |
| 240 | 228 |
| 241 def IsReadOnly(attribute): | 229 def IsReadOnly(attribute): |
| 242 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs | 230 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs |
| OLD | NEW |