| 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 11 matching lines...) Expand all Loading... |
| 22 - (InterfaceGenerator | ProcessCallback)* # for each IDL interface | 22 - (InterfaceGenerator | ProcessCallback)* # for each IDL interface |
| 23 - GenerateLibraries | 23 - GenerateLibraries |
| 24 - Finish | 24 - Finish |
| 25 """ | 25 """ |
| 26 | 26 |
| 27 def __init__(self, templates, database, emitters, output_dir): | 27 def __init__(self, templates, database, emitters, output_dir): |
| 28 self._templates = templates | 28 self._templates = templates |
| 29 self._database = database | 29 self._database = database |
| 30 self._emitters = emitters | 30 self._emitters = emitters |
| 31 self._output_dir = output_dir | 31 self._output_dir = output_dir |
| 32 self._dart_callback_file_paths = [] | |
| 33 | 32 |
| 34 def ProcessInterface(self, interface): | 33 def ProcessInterface(self, interface): |
| 35 """Processes an interface that is not a callback function.""" | 34 """Processes an interface that is not a callback function.""" |
| 36 pass | 35 pass |
| 37 | 36 |
| 38 def ProcessCallback(self, interface, info): | 37 def ProcessCallback(self, interface, info): |
| 39 """Processes an interface that is a callback function.""" | 38 """Processes an interface that is a callback function.""" |
| 40 pass | 39 pass |
| 41 | 40 |
| 42 def GenerateLibraries(self, lib_dir): | 41 def GenerateLibraries(self, lib_dir): |
| 43 pass | 42 pass |
| 44 | 43 |
| 45 def Finish(self): | 44 def Finish(self): |
| 46 pass | 45 pass |
| 47 | 46 |
| 48 | 47 |
| 49 # Helper methods used by several systems. | 48 # Helper methods used by several systems. |
| 50 | 49 |
| 51 def _ProcessCallback(self, interface, info, file_path): | 50 def _ProcessCallback(self, interface, info, file_path): |
| 52 """Generates a typedef for the callback interface.""" | 51 """Generates a typedef for the callback interface.""" |
| 53 self._dart_callback_file_paths.append(file_path) | 52 self._dart_interface_file_paths.append(file_path) |
| 54 code = self._emitters.FileEmitter(file_path) | 53 code = self._emitters.FileEmitter(file_path) |
| 55 | 54 |
| 56 code.Emit(self._templates.Load('callback.darttemplate')) | 55 code.Emit(self._templates.Load('callback.darttemplate')) |
| 57 code.Emit('typedef $TYPE $NAME($PARAMS);\n', | 56 code.Emit('typedef $TYPE $NAME($PARAMS);\n', |
| 58 NAME=interface.id, | 57 NAME=interface.id, |
| 59 TYPE=info.type_name, | 58 TYPE=info.type_name, |
| 60 PARAMS=info.ParametersImplementationDeclaration()) | 59 PARAMS=info.ParametersImplementationDeclaration()) |
| 61 | 60 |
| 62 | 61 |
| 63 def _GenerateLibFile(self, lib_template, lib_file_path, file_paths, | 62 def _GenerateLibFile(self, lib_template, lib_file_path, file_paths, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 """ | 231 """ |
| 233 names = sorted(set(attr.id for attr in attributes)) | 232 names = sorted(set(attr.id for attr in attributes)) |
| 234 getters = {} | 233 getters = {} |
| 235 setters = {} | 234 setters = {} |
| 236 for attr in attributes: | 235 for attr in attributes: |
| 237 if attr.is_fc_getter: | 236 if attr.is_fc_getter: |
| 238 getters[attr.id] = attr | 237 getters[attr.id] = attr |
| 239 elif attr.is_fc_setter and 'Replaceable' not in attr.ext_attrs: | 238 elif attr.is_fc_setter and 'Replaceable' not in attr.ext_attrs: |
| 240 setters[attr.id] = attr | 239 setters[attr.id] = attr |
| 241 return [(getters.get(id), setters.get(id)) for id in names] | 240 return [(getters.get(id), setters.get(id)) for id in names] |
| OLD | NEW |