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

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

Issue 10987042: Speed up fremontcut/dartdomgenerator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 8 years, 2 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/go.sh ('k') | lib/html/scripts/systembase.py » ('j') | 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 28 matching lines...) Expand all
39 """Returns string of extra info for __repr__().""" 39 """Returns string of extra info for __repr__()."""
40 return '' 40 return ''
41 41
42 def __cmp__(self, other): 42 def __cmp__(self, other):
43 """Override default compare operation. 43 """Override default compare operation.
44 IDLNodes are equal if all their properties are equal.""" 44 IDLNodes are equal if all their properties are equal."""
45 if other is None or not isinstance(other, IDLNode): 45 if other is None or not isinstance(other, IDLNode):
46 return 1 46 return 1
47 return self.__dict__.__cmp__(other.__dict__) 47 return self.__dict__.__cmp__(other.__dict__)
48 48
49 def reset_id(self, newId):
50 """Reset the id of the Node. This is typically done during a normalization
51 phase (e.g., "DOMWindow" -> "Window")."""
52 self.id = newId
53
49 def all(self, type_filter=None): 54 def all(self, type_filter=None):
50 """Returns a list containing this node and all it child nodes 55 """Returns a list containing this node and all it child nodes
51 (recursive). 56 (recursive).
52 57
53 Args: 58 Args:
54 type_filter -- can be used to limit the results to a specific 59 type_filter -- can be used to limit the results to a specific
55 node type (e.g. IDLOperation). 60 node type (e.g. IDLOperation).
56 """ 61 """
57 res = [] 62 res = []
58 if type_filter is None or isinstance(self, type_filter): 63 if type_filter is None or isinstance(self, type_filter):
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 self.operations = self._convert_all(ast, 'Operation', 384 self.operations = self._convert_all(ast, 'Operation',
380 lambda ast: IDLOperation(ast, self.doc_js_name)) 385 lambda ast: IDLOperation(ast, self.doc_js_name))
381 self.attributes = self._convert_all(ast, 'Attribute', 386 self.attributes = self._convert_all(ast, 'Attribute',
382 lambda ast: IDLAttribute(ast, self.doc_js_name)) 387 lambda ast: IDLAttribute(ast, self.doc_js_name))
383 self.constants = self._convert_all(ast, 'Const', 388 self.constants = self._convert_all(ast, 'Const',
384 lambda ast: IDLConstant(ast, self.doc_js_name)) 389 lambda ast: IDLConstant(ast, self.doc_js_name))
385 self.is_supplemental = 'Supplemental' in self.ext_attrs 390 self.is_supplemental = 'Supplemental' in self.ext_attrs
386 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs 391 self.is_no_interface_object = 'NoInterfaceObject' in self.ext_attrs
387 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs 392 self.is_fc_suppressed = 'Suppressed' in self.ext_attrs
388 393
394 def reset_id(self, new_id):
395 """Reset the id of the Interface and corresponding the JS names."""
396 if self.id != new_id:
397 self.id = new_id
398 self.doc_js_name = new_id
399 self.javascript_binding_name = new_id
400 for member in self.operations:
401 member.doc_js_interface_name = new_id
402 for member in self.attributes:
403 member.doc_js_interface_name = new_id
404 for member in self.constants:
405 member.doc_js_interface_name = new_id
406
389 def has_attribute(self, candidate): 407 def has_attribute(self, candidate):
390 for attribute in self.attributes: 408 for attribute in self.attributes:
391 if (attribute.id == candidate.id and 409 if (attribute.id == candidate.id and
392 attribute.is_read_only == candidate.is_read_only): 410 attribute.is_read_only == candidate.is_read_only):
393 return True 411 return True
394 return False 412 return False
395 413
396 414
397 class IDLParentInterface(IDLNode): 415 class IDLParentInterface(IDLNode):
398 """This IDLNode specialization is for 'Interface Child : Parent {}' 416 """This IDLNode specialization is for 'Interface Child : Parent {}'
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 """IDLDictNode specialization for one annotation.""" 509 """IDLDictNode specialization for one annotation."""
492 def __init__(self, ast=None): 510 def __init__(self, ast=None):
493 IDLDictNode.__init__(self, ast) 511 IDLDictNode.__init__(self, ast)
494 self.id = None 512 self.id = None
495 if not ast: 513 if not ast:
496 return 514 return
497 for arg in self._find_all(ast, 'AnnotationArg'): 515 for arg in self._find_all(ast, 'AnnotationArg'):
498 name = self._find_first(arg, 'Id') 516 name = self._find_first(arg, 'Id')
499 value = self._find_first(arg, 'AnnotationArgValue') 517 value = self._find_first(arg, 'AnnotationArgValue')
500 self[name] = value 518 self[name] = value
OLDNEW
« no previous file with comments | « lib/html/scripts/go.sh ('k') | lib/html/scripts/systembase.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698