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

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

Issue 10987019: Refactor file paths handling in generator. (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 generates Dart APIs from the IDL database.""" 6 """This module generates Dart APIs from the IDL database."""
7 7
8 import emitter 8 import emitter
9 import idlnode 9 import idlnode
10 import logging 10 import logging
11 import os 11 import os
12 import re 12 import re
13 import shutil 13 import shutil
14 import systembase
15 from generator import * 14 from generator import *
16 15
17 _logger = logging.getLogger('dartgenerator') 16 _logger = logging.getLogger('dartgenerator')
18 17
19 def MergeNodes(node, other): 18 def MergeNodes(node, other):
20 node.operations.extend(other.operations) 19 node.operations.extend(other.operations)
21 for attribute in other.attributes: 20 for attribute in other.attributes:
22 if not node.has_attribute(attribute): 21 if not node.has_attribute(attribute):
23 node.attributes.append(attribute) 22 node.attributes.append(attribute)
24 23
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if HasAnnotations(interface): 181 if HasAnnotations(interface):
183 interface.constants = filter(HasAnnotations, interface.constants) 182 interface.constants = filter(HasAnnotations, interface.constants)
184 interface.attributes = filter(HasAnnotations, interface.attributes) 183 interface.attributes = filter(HasAnnotations, interface.attributes)
185 interface.operations = filter(HasAnnotations, interface.operations) 184 interface.operations = filter(HasAnnotations, interface.operations)
186 interface.parents = filter(HasAnnotations, interface.parents) 185 interface.parents = filter(HasAnnotations, interface.parents)
187 else: 186 else:
188 database.DeleteInterface(interface.id) 187 database.DeleteInterface(interface.id)
189 188
190 self.FilterMembersWithUnidentifiedTypes(database) 189 self.FilterMembersWithUnidentifiedTypes(database)
191 190
192 def Generate(self, database, system, super_database=None, webkit_renames={}): 191 def Generate(self, database, super_database, webkit_renames,
vsm 2012/09/25 16:06:14 Should this be renamed to Process or similar? It
podivilov1 2012/09/25 16:40:28 Reverted this change. I'll try to decouple dartgen
192 process_interface, process_callback):
Anton Muhin 2012/09/25 16:15:50 why pass callbacks, not some generator?
podivilov1 2012/09/25 16:40:28 Done.
193 self._database = database 193 self._database = database
194 194
195 # Collect interfaces 195 # Collect interfaces
196 interfaces = [] 196 interfaces = []
197 for interface in database.GetInterfaces(): 197 for interface in database.GetInterfaces():
198 if not MatchSourceFilter(interface): 198 if not MatchSourceFilter(interface):
199 # Skip this interface since it's not present in the required source 199 # Skip this interface since it's not present in the required source
200 _logger.info('Omitting interface - %s' % interface.id) 200 _logger.info('Omitting interface - %s' % interface.id)
201 continue 201 continue
202 interfaces.append(interface) 202 interfaces.append(interface)
(...skipping 19 matching lines...) Expand all
222 interface_name = interface.id 222 interface_name = interface.id
223 auxiliary_file = self._auxiliary_files.get(interface_name) 223 auxiliary_file = self._auxiliary_files.get(interface_name)
224 if auxiliary_file is not None: 224 if auxiliary_file is not None:
225 _logger.info('Skipping %s because %s exists' % ( 225 _logger.info('Skipping %s because %s exists' % (
226 interface_name, auxiliary_file)) 226 interface_name, auxiliary_file))
227 continue 227 continue
228 228
229 if 'Callback' in interface.ext_attrs: 229 if 'Callback' in interface.ext_attrs:
230 handlers = [op for op in interface.operations if op.id == 'handleEvent'] 230 handlers = [op for op in interface.operations if op.id == 'handleEvent']
231 info = AnalyzeOperation(interface, handlers) 231 info = AnalyzeOperation(interface, handlers)
232 system.ProcessCallback(interface, info) 232 process_callback(interface, info)
233 else: 233 else:
234 _logger.info('Generating %s' % interface.id) 234 _logger.info('Generating %s' % interface.id)
235 system.ProcessInterface(interface) 235 process_interface(interface)
236
237 system.GenerateLibraries()
238 system.Finish()
239 236
240 def _PreOrderInterfaces(self, interfaces): 237 def _PreOrderInterfaces(self, interfaces):
241 """Returns the interfaces in pre-order, i.e. parents first.""" 238 """Returns the interfaces in pre-order, i.e. parents first."""
242 seen = set() 239 seen = set()
243 ordered = [] 240 ordered = []
244 def visit(interface): 241 def visit(interface):
245 if interface.id in seen: 242 if interface.id in seen:
246 return 243 return
247 seen.add(interface.id) 244 seen.add(interface.id)
248 for parent in interface.parents: 245 for parent in interface.parents:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 ast = [('Annotation', [('Id', 'WebKit')]), 277 ast = [('Annotation', [('Id', 'WebKit')]),
281 ('InterfaceType', ('ScopedName', 'EventTarget'))] 278 ('InterfaceType', ('ScopedName', 'EventTarget'))]
282 interface.parents.append(idlnode.IDLParentInterface(ast)) 279 interface.parents.append(idlnode.IDLParentInterface(ast))
283 280
284 def AddMissingArguments(self, database): 281 def AddMissingArguments(self, database):
285 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'Object')), ('Id', 'arg') ]) 282 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'Object')), ('Id', 'arg') ])
286 for interface in database.GetInterfaces(): 283 for interface in database.GetInterfaces():
287 for operation in interface.operations: 284 for operation in interface.operations:
288 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|CallStack': 285 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|CallStack':
289 operation.arguments.append(ARG) 286 operation.arguments.append(ARG)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698