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 * |
11 | 11 |
12 def MassagePath(path): | 12 def MassagePath(path): |
13 # The most robust way to emit path separators is to use / always. | 13 # The most robust way to emit path separators is to use / always. |
14 return path.replace('\\', '/') | 14 return path.replace('\\', '/') |
15 | 15 |
16 class System(object): | 16 class System(object): |
17 """A System generates all the files for one implementation. | 17 """A System generates all the files for one implementation. |
18 | 18 |
19 This is a base class for all the specific systems. | 19 This is a base class for all the specific systems. |
20 The life-cycle of a System is: | 20 The life-cycle of a System is: |
21 - construction (__init__) | 21 - construction (__init__) |
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, options): |
28 self._templates = templates | 28 self._templates = options.templates |
29 self._database = database | 29 self._database = options.database |
30 self._emitters = emitters | 30 self._emitters = options.emitters |
31 self._output_dir = output_dir | 31 self._type_registry = options.type_registry |
| 32 self._output_dir = options.output_dir |
32 | 33 |
33 def ProcessInterface(self, interface): | 34 def ProcessInterface(self, interface): |
34 """Processes an interface that is not a callback function.""" | 35 """Processes an interface that is not a callback function.""" |
35 pass | 36 pass |
36 | 37 |
37 def ProcessCallback(self, interface, info): | 38 def ProcessCallback(self, interface, info): |
38 """Processes an interface that is a callback function.""" | 39 """Processes an interface that is a callback function.""" |
39 pass | 40 pass |
40 | 41 |
41 def GenerateLibraries(self, lib_dir): | 42 def GenerateLibraries(self, lib_dir): |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 215 |
215 result = [] | 216 result = [] |
216 if interface.parents: | 217 if interface.parents: |
217 parent = interface.parents[0] | 218 parent = interface.parents[0] |
218 if IsPureInterface(parent.type.id): | 219 if IsPureInterface(parent.type.id): |
219 walk(interface.parents) | 220 walk(interface.parents) |
220 else: | 221 else: |
221 walk(interface.parents[1:]) | 222 walk(interface.parents[1:]) |
222 return result | 223 return result |
223 | 224 |
| 225 class GeneratorOptions(object): |
| 226 def __init__(self, templates, database, emitters, type_registry, output_dir): |
| 227 self.templates = templates |
| 228 self.database = database |
| 229 self.emitters = emitters |
| 230 self.type_registry = type_registry |
| 231 self.output_dir = output_dir |
| 232 |
224 | 233 |
225 def IsReadOnly(attribute): | 234 def IsReadOnly(attribute): |
226 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs | 235 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs |
OLD | NEW |