| OLD | NEW |
| 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 Loading... |
| 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] |
| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 assert any([is_static == o.is_static for o in self.overloads]) | 447 assert any([is_static == o.is_static for o in self.overloads]) |
| 450 return is_static | 448 return is_static |
| 451 | 449 |
| 452 def ConstructorFullName(self): | 450 def ConstructorFullName(self): |
| 453 if self.constructor_name: | 451 if self.constructor_name: |
| 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): | |
| 460 """Canonical output ordering for attributes.""" | |
| 461 # Getters before setters: | |
| 462 if a.id < b.id: return -1 | |
| 463 if a.id > b.id: return 1 | |
| 464 if a.is_fc_setter < b.is_fc_setter: return -1 | |
| 465 if a.is_fc_setter > b.is_fc_setter: return 1 | |
| 466 return 0 | |
| 467 | |
| 468 def ConstantOutputOrder(a, b): | 457 def ConstantOutputOrder(a, b): |
| 469 """Canonical output ordering for constants.""" | 458 """Canonical output ordering for constants.""" |
| 470 if a.id < b.id: return -1 | 459 if a.id < b.id: return -1 |
| 471 if a.id > b.id: return 1 | 460 if a.id > b.id: return 1 |
| 472 return 0 | 461 return 0 |
| 473 | 462 |
| 474 | 463 |
| 475 def _FormatNameList(names): | 464 def _FormatNameList(names): |
| 476 """Returns JavaScript array literal expression with one name per line.""" | 465 """Returns JavaScript array literal expression with one name per line.""" |
| 477 #names = sorted(names) | 466 #names = sorted(names) |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 825 |
| 837 match = re.match(r'sequence<(\w+)>$', idl_type_name) | 826 match = re.match(r'sequence<(\w+)>$', idl_type_name) |
| 838 if match: | 827 if match: |
| 839 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 828 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
| 840 | 829 |
| 841 match = re.match(r'(\w+)\[\]$', idl_type_name) | 830 match = re.match(r'(\w+)\[\]$', idl_type_name) |
| 842 if match: | 831 if match: |
| 843 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 832 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
| 844 | 833 |
| 845 return IDLTypeInfo(idl_type_name) | 834 return IDLTypeInfo(idl_type_name) |
| OLD | NEW |