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

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
« lib/html/scripts/generator.py ('K') | « 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 childAst in ast:
podivilov 2012/09/13 14:01:39 nit: for (label, childAst) in ast
Anton Muhin 2012/09/13 14:47:53 There are some technical issues with it, but as yo
322 if label.endswith('Type'): 322 (label, childAst) = childAst
323 self.id = self._label_to_type(label, ast) 323 if label.endswith('Type'):
podivilov 2012/09/13 13:01:57 The new code is very hard to read. Please replace
Anton Muhin 2012/09/13 13:10:47 Sorry, do not quite follow, may you provide some m
324 break 324 type = self._label_to_type(label, ast)
325 if type == 'sequence':
podivilov 2012/09/13 14:01:39 Please move this code out of the loop and use earl
326 type_ast = self._find_first(childAst, 'Type')
327 if type_ast:
328 type_argument = findType(type_ast)
329 if type_argument:
330 type = 'sequence<%s>' % type_argument
331 return type
332 self.id = findType(ast)
325 array_modifiers = self._find_first(ast, 'ArrayModifiers') 333 array_modifiers = self._find_first(ast, 'ArrayModifiers')
326 if array_modifiers: 334 if array_modifiers:
327 self.id += array_modifiers 335 self.id += array_modifiers
328 elif isinstance(ast, tuple): 336 elif isinstance(ast, tuple):
329 (label, value) = ast 337 (label, value) = ast
330 if label == 'ScopedName': 338 if label == 'ScopedName':
331 self.id = value 339 self.id = value
332 else: 340 else:
333 self.id = self._label_to_type(label, ast) 341 self.id = self._label_to_type(label, ast)
334 elif isinstance(ast, str): 342 elif isinstance(ast, str):
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 """IDLDictNode specialization for one annotation.""" 492 """IDLDictNode specialization for one annotation."""
485 def __init__(self, ast=None): 493 def __init__(self, ast=None):
486 IDLDictNode.__init__(self, ast) 494 IDLDictNode.__init__(self, ast)
487 self.id = None 495 self.id = None
488 if not ast: 496 if not ast:
489 return 497 return
490 for arg in self._find_all(ast, 'AnnotationArg'): 498 for arg in self._find_all(ast, 'AnnotationArg'):
491 name = self._find_first(arg, 'Id') 499 name = self._find_first(arg, 'Id')
492 value = self._find_first(arg, 'AnnotationArgValue') 500 value = self._find_first(arg, 'AnnotationArgValue')
493 self[name] = value 501 self[name] = value
OLDNEW
« lib/html/scripts/generator.py ('K') | « lib/html/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698