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

Side by Side Diff: lib/dom/scripts/generator.py

Issue 10704100: Do not split attributes on getters and setters in databasebuilder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, 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 """This module provides shared functionality for systems to generate 6 """This module provides shared functionality for systems to generate
7 Dart APIs from the IDL database.""" 7 Dart APIs from the IDL database."""
8 8
9 import copy 9 import copy
10 import re 10 import re
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return AnalyzeOperation(interface, handlers) 314 return AnalyzeOperation(interface, handlers)
315 315
316 def IsDartListType(type): 316 def IsDartListType(type):
317 return type == 'List' or type.startswith('sequence<') 317 return type == 'List' or type.startswith('sequence<')
318 318
319 def IsDartCollectionType(type): 319 def IsDartCollectionType(type):
320 return IsDartListType(type) 320 return IsDartListType(type)
321 321
322 def FindMatchingAttribute(interface, attr1): 322 def FindMatchingAttribute(interface, attr1):
323 matches = [attr2 for attr2 in interface.attributes 323 matches = [attr2 for attr2 in interface.attributes
324 if attr1.id == attr2.id 324 if attr1.id == attr2.id]
Anton Muhin 2012/07/04 15:41:25 should you check readonly'ness here?
podivilov 2012/07/04 16:32:47 Nope, if attribute was declared with different "re
325 and attr1.is_fc_getter == attr2.is_fc_getter
326 and attr1.is_fc_setter == attr2.is_fc_setter]
327 if matches: 325 if matches:
328 assert len(matches) == 1 326 assert len(matches) == 1
329 return matches[0] 327 return matches[0]
330 return None 328 return None
331 329
332 330
333 def DartDomNameOfAttribute(attr): 331 def DartDomNameOfAttribute(attr):
334 """Returns the Dart name for an IDLAttribute. 332 """Returns the Dart name for an IDLAttribute.
335 333
336 attr.id is the 'native' or JavaScript name. 334 attr.id is the 'native' or JavaScript name.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return self.type_name + '.' + self.constructor_name 452 return self.type_name + '.' + self.constructor_name
455 else: 453 else:
456 return self.type_name 454 return self.type_name
457 455
458 456
459 def AttributeOutputOrder(a, b): 457 def AttributeOutputOrder(a, b):
460 """Canonical output ordering for attributes.""" 458 """Canonical output ordering for attributes."""
461 # Getters before setters: 459 # Getters before setters:
462 if a.id < b.id: return -1 460 if a.id < b.id: return -1
463 if a.id > b.id: return 1 461 if a.id > b.id: return 1
464 if a.is_fc_setter < b.is_fc_setter: return -1 462 if a.is_read_only < b.is_read_only: return -1
Anton Muhin 2012/07/04 15:41:25 shouldn't you have a.is_read_only > b.is_read_only
podivilov 2012/07/04 16:32:47 Turned out this function isn't used at all :)
465 if a.is_fc_setter > b.is_fc_setter: return 1
466 return 0 463 return 0
Anton Muhin 2012/07/04 15:41:25 overall, I'd rather code that as: def AOO(a, b):
467 464
468 def ConstantOutputOrder(a, b): 465 def ConstantOutputOrder(a, b):
469 """Canonical output ordering for constants.""" 466 """Canonical output ordering for constants."""
470 if a.id < b.id: return -1 467 if a.id < b.id: return -1
471 if a.id > b.id: return 1 468 if a.id > b.id: return 1
472 return 0 469 return 0
473 470
474 471
475 def _FormatNameList(names): 472 def _FormatNameList(names):
476 """Returns JavaScript array literal expression with one name per line.""" 473 """Returns JavaScript array literal expression with one name per line."""
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 833
837 match = re.match(r'sequence<(\w+)>$', idl_type_name) 834 match = re.match(r'sequence<(\w+)>$', idl_type_name)
838 if match: 835 if match:
839 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) 836 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1)))
840 837
841 match = re.match(r'(\w+)\[\]$', idl_type_name) 838 match = re.match(r'(\w+)\[\]$', idl_type_name)
842 if match: 839 if match:
843 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) 840 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1)))
844 841
845 return IDLTypeInfo(idl_type_name) 842 return IDLTypeInfo(idl_type_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698