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

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

Issue 10916286: Support proper parsing of sequence<T>. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « lib/html/scripts/generator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
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 break
324 break 324 type = self._label_to_type(label, ast)
podivilov 2012/09/13 15:22:44 Please move this statement inside the loop.
Anton Muhin 2012/09/13 16:18:38 Done.
325 if type != 'sequence':
326 return type
327 type_ast = self._find_first(childAst, 'Type')
328 if not type_ast:
329 return type
330 return 'sequence<%s>' % findType(type_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
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
OLDNEW
« no previous file with comments | « lib/html/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698