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