| 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 sys | 6 import sys |
| 7 | 7 |
| 8 | 8 |
| 9 class IDLNode(object): | 9 class IDLNode(object): |
| 10 """Base class for all IDL elements. | 10 """Base class for all IDL elements. |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return and input types. IDLType matches AST labels such as ScopedName, | 310 return and input types. IDLType matches AST labels such as ScopedName, |
| 311 StringType, VoidType, IntegerType, etc.""" | 311 StringType, VoidType, IntegerType, etc.""" |
| 312 | 312 |
| 313 def __init__(self, ast): | 313 def __init__(self, ast): |
| 314 IDLNode.__init__(self, ast) | 314 IDLNode.__init__(self, ast) |
| 315 # Search for a 'ScopedName' or any label ending with 'Type'. | 315 # Search for a 'ScopedName' or any label ending with 'Type'. |
| 316 if isinstance(ast, list): | 316 if isinstance(ast, list): |
| 317 self.id = self._find_first(ast, 'ScopedName') | 317 self.id = self._find_first(ast, 'ScopedName') |
| 318 if not self.id: | 318 if not self.id: |
| 319 # FIXME: use regexp search instead | 319 # FIXME: use regexp search instead |
| 320 for childAst in ast: | 320 def findType(ast): |
| 321 (label, childAst) = childAst | 321 for label, childAst in ast: |
| 322 if label.endswith('Type'): | 322 if label.endswith('Type'): |
| 323 self.id = self._label_to_type(label, ast) | 323 type = self._label_to_type(label, ast) |
| 324 break | 324 if type != 'sequence': |
| 325 return type |
| 326 type_ast = self._find_first(childAst, 'Type') |
| 327 if not type_ast: |
| 328 return type |
| 329 return 'sequence<%s>' % findType(type_ast) |
| 330 raise Exception('No type declaration found in %s' % ast) |
| 331 self.id = findType(ast) |
| 325 array_modifiers = self._find_first(ast, 'ArrayModifiers') | 332 array_modifiers = self._find_first(ast, 'ArrayModifiers') |
| 326 if array_modifiers: | 333 if array_modifiers: |
| 327 self.id += array_modifiers | 334 self.id += array_modifiers |
| 328 elif isinstance(ast, tuple): | 335 elif isinstance(ast, tuple): |
| 329 (label, value) = ast | 336 (label, value) = ast |
| 330 if label == 'ScopedName': | 337 if label == 'ScopedName': |
| 331 self.id = value | 338 self.id = value |
| 332 else: | 339 else: |
| 333 self.id = self._label_to_type(label, ast) | 340 self.id = self._label_to_type(label, ast) |
| 334 elif isinstance(ast, str): | 341 elif isinstance(ast, str): |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 """IDLDictNode specialization for one annotation.""" | 491 """IDLDictNode specialization for one annotation.""" |
| 485 def __init__(self, ast=None): | 492 def __init__(self, ast=None): |
| 486 IDLDictNode.__init__(self, ast) | 493 IDLDictNode.__init__(self, ast) |
| 487 self.id = None | 494 self.id = None |
| 488 if not ast: | 495 if not ast: |
| 489 return | 496 return |
| 490 for arg in self._find_all(ast, 'AnnotationArg'): | 497 for arg in self._find_all(ast, 'AnnotationArg'): |
| 491 name = self._find_first(arg, 'Id') | 498 name = self._find_first(arg, 'Id') |
| 492 value = self._find_first(arg, 'AnnotationArgValue') | 499 value = self._find_first(arg, 'AnnotationArgValue') |
| 493 self[name] = value | 500 self[name] = value |
| OLD | NEW |