Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: lib/html/scripts/systembase.py

Issue 11018012: Get rid of System class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class System(object):
13 """A System generates all the files for one implementation.
14
15 This is a base class for all the specific systems.
16 The life-cycle of a System is:
17 - construction (__init__)
18 - (ProcessInterface)* # for each IDL interface
19 """
20
21 def __init__(self, options):
22 self._templates = options.templates
23 self._database = options.database
24 self._type_registry = options.type_registry
25 self._renamer = options.renamer
26
27 def ProcessInterface(self, interface):
28 """Processes an interface that is not a callback function."""
29 pass
30
31 # Helper methods used by several systems.
32
33 def _BaseDefines(self, interface):
34 """Returns a set of names (strings) for members defined in a base class.
35 """
36 def WalkParentChain(interface):
37 if interface.parents:
38 # Only consider primary parent, secondary parents are not on the
39 # implementation class inheritance chain.
40 parent = interface.parents[0]
41 if IsDartCollectionType(parent.type.id):
42 return
43 if self._database.HasInterface(parent.type.id):
44 parent_interface = self._database.GetInterface(parent.type.id)
45 for attr in parent_interface.attributes:
46 result.add(attr.id)
47 for op in parent_interface.operations:
48 result.add(op.id)
49 WalkParentChain(parent_interface)
50
51 result = set()
52 WalkParentChain(interface)
53 return result
54
55 class BaseGenerator(object): 12 class BaseGenerator(object):
56 def __init__(self, database, type_registry, interface): 13 def __init__(self, database, type_registry, interface):
57 self._database = database 14 self._database = database
58 self._type_registry = type_registry 15 self._type_registry = type_registry
59 self._interface = interface 16 self._interface = interface
60 17
61 def Generate(self): 18 def Generate(self):
62 if 'Callback' in self._interface.ext_attrs: 19 if 'Callback' in self._interface.ext_attrs:
63 handlers = [operation for operation in self._interface.operations 20 handlers = [operation for operation in self._interface.operations
64 if operation.id == 'handleEvent'] 21 if operation.id == 'handleEvent']
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 class GeneratorOptions(object): 144 class GeneratorOptions(object):
188 def __init__(self, templates, database, type_registry, renamer): 145 def __init__(self, templates, database, type_registry, renamer):
189 self.templates = templates 146 self.templates = templates
190 self.database = database 147 self.database = database
191 self.type_registry = type_registry 148 self.type_registry = type_registry
192 self.renamer = renamer 149 self.renamer = renamer
193 150
194 151
195 def IsReadOnly(attribute): 152 def IsReadOnly(attribute):
196 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs 153 return attribute.is_read_only or 'Replaceable' in attribute.ext_attrs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698