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

Side by Side Diff: sdk/lib/html/scripts/idlnode.py

Issue 11348382: Moving AudioElement back to dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, 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 import os
6 import sys 7 import sys
7 8
8 9
9 class IDLNode(object): 10 class IDLNode(object):
10 """Base class for all IDL elements. 11 """Base class for all IDL elements.
11 IDLNode may contain various child nodes, and have properties. Examples 12 IDLNode may contain various child nodes, and have properties. Examples
12 of IDLNode are interfaces, interface members, function arguments, 13 of IDLNode are interfaces, interface members, function arguments,
13 etc. 14 etc.
14 """ 15 """
15 16
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return [] 245 return []
245 246
246 247
247 class IDLFile(IDLNode): 248 class IDLFile(IDLNode):
248 """IDLFile is the top-level node in each IDL file. It may contain interfaces." "" 249 """IDLFile is the top-level node in each IDL file. It may contain interfaces." ""
249 250
250 def __init__(self, ast, filename=None): 251 def __init__(self, ast, filename=None):
251 IDLNode.__init__(self, ast) 252 IDLNode.__init__(self, ast)
252 self.filename = filename 253 self.filename = filename
253 self.interfaces = self._convert_all(ast, 'Interface', IDLInterface) 254 self.interfaces = self._convert_all(ast, 'Interface', IDLInterface)
255 # Treat the directory name as a module name.
256 module_name = os.path.split(os.path.dirname(self.filename))[1]
257 for interface in self.interfaces:
258 interface.module_name = module_name
254 modules = self._convert_all(ast, 'Module', IDLModule) 259 modules = self._convert_all(ast, 'Module', IDLModule)
255 self.implementsStatements = self._convert_all(ast, 'ImplStmt', 260 self.implementsStatements = self._convert_all(ast, 'ImplStmt',
256 IDLImplementsStatement) 261 IDLImplementsStatement)
257 for module in modules: 262 for module in modules:
258 self.interfaces.extend(module.interfaces) 263 self.interfaces.extend(module.interfaces)
259 self.implementsStatements.extend(module.implementsStatements) 264 self.implementsStatements.extend(module.implementsStatements)
260 265
261 266
262 class IDLModule(IDLNode): 267 class IDLModule(IDLNode):
263 """IDLModule has an id, and may contain interfaces, type defs and 268 """IDLModule has an id, and may contain interfaces, type defs and
264 implements statements.""" 269 implements statements."""
265 def __init__(self, ast): 270 def __init__(self, ast):
266 IDLNode.__init__(self, ast) 271 IDLNode.__init__(self, ast)
267 self._convert_ext_attrs(ast) 272 self._convert_ext_attrs(ast)
268 self._convert_annotations(ast) 273 self._convert_annotations(ast)
269 self.interfaces = self._convert_all(ast, 'Interface', IDLInterface) 274 self.interfaces = self._convert_all(ast, 'Interface', IDLInterface)
275 for interface in self.interfaces:
276 interface.module_name = self.id
270 self.typeDefs = self._convert_all(ast, 'TypeDef', IDLTypeDef) 277 self.typeDefs = self._convert_all(ast, 'TypeDef', IDLTypeDef)
271 self.implementsStatements = self._convert_all(ast, 'ImplStmt', 278 self.implementsStatements = self._convert_all(ast, 'ImplStmt',
272 IDLImplementsStatement) 279 IDLImplementsStatement)
273 280
274 281
275 class IDLExtAttrs(IDLDictNode): 282 class IDLExtAttrs(IDLDictNode):
276 """IDLExtAttrs is an IDLDictNode that stores IDL Extended Attributes. 283 """IDLExtAttrs is an IDLDictNode that stores IDL Extended Attributes.
277 Modules, interfaces, members and arguments can all own IDLExtAttrs.""" 284 Modules, interfaces, members and arguments can all own IDLExtAttrs."""
278 def __init__(self, ast=None): 285 def __init__(self, ast=None):
279 IDLDictNode.__init__(self, None) 286 IDLDictNode.__init__(self, None)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 381
375 382
376 class IDLInterface(IDLNode): 383 class IDLInterface(IDLNode):
377 """IDLInterface node contains operations, attributes, constants, 384 """IDLInterface node contains operations, attributes, constants,
378 as well as parent references.""" 385 as well as parent references."""
379 386
380 def __init__(self, ast): 387 def __init__(self, ast):
381 IDLNode.__init__(self, ast) 388 IDLNode.__init__(self, ast)
382 self._convert_ext_attrs(ast) 389 self._convert_ext_attrs(ast)
383 self._convert_annotations(ast) 390 self._convert_annotations(ast)
391 self.module_name = None
384 self.parents = self._convert_all(ast, 'ParentInterface', 392 self.parents = self._convert_all(ast, 'ParentInterface',
385 IDLParentInterface) 393 IDLParentInterface)
386 javascript_interface_name = self.ext_attrs.get('InterfaceName', self.id) 394 javascript_interface_name = self.ext_attrs.get('InterfaceName', self.id)
387 self.javascript_binding_name = javascript_interface_name 395 self.javascript_binding_name = javascript_interface_name
388 self.doc_js_name = javascript_interface_name 396 self.doc_js_name = javascript_interface_name
389 self.operations = self._convert_all(ast, 'Operation', 397 self.operations = self._convert_all(ast, 'Operation',
390 lambda ast: IDLOperation(ast, self.doc_js_name)) 398 lambda ast: IDLOperation(ast, self.doc_js_name))
391 self.attributes = self._convert_all(ast, 'Attribute', 399 self.attributes = self._convert_all(ast, 'Attribute',
392 lambda ast: IDLAttribute(ast, self.doc_js_name)) 400 lambda ast: IDLAttribute(ast, self.doc_js_name))
393 self.constants = self._convert_all(ast, 'Const', 401 self.constants = self._convert_all(ast, 'Const',
394 lambda ast: IDLConstant(ast, self.doc_js_name)) 402 lambda ast: IDLConstant(ast, self.doc_js_name))
395 self.is_supplemental = 'Supplemental' in self.ext_attrs 403 self.is_supplemental = 'Supplemental' in self.ext_attrs
396 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs 404 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs
397 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs 405 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs
398 406
399 def reset_id(self, new_id): 407 def reset_id(self, new_id):
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 """IDLDictNode specialization for one annotation.""" 522 """IDLDictNode specialization for one annotation."""
515 def __init__(self, ast=None): 523 def __init__(self, ast=None):
516 IDLDictNode.__init__(self, ast) 524 IDLDictNode.__init__(self, ast)
517 self.id = None 525 self.id = None
518 if not ast: 526 if not ast:
519 return 527 return
520 for arg in self._find_all(ast, 'AnnotationArg'): 528 for arg in self._find_all(ast, 'AnnotationArg'):
521 name = self._find_first(arg, 'Id') 529 name = self._find_first(arg, 'Id')
522 value = self._find_first(arg, 'AnnotationArgValue') 530 value = self._find_first(arg, 'AnnotationArgValue')
523 self[name] = value 531 self[name] = value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698