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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 710 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
711 "@Experimental()", | 711 "@Experimental()", |
712 ], | 712 ], |
713 'WebSocket': _all_but_ie9_annotations, | 713 'WebSocket': _all_but_ie9_annotations, |
714 'WorkerContext.indexedDB': _indexed_db_annotations, | 714 'WorkerContext.indexedDB': _indexed_db_annotations, |
715 } | 715 } |
716 | 716 |
717 def FindCommonAnnotations(interface_name, member_name=None): | 717 def FindCommonAnnotations(interface_name, member_name=None): |
718 """ Finds annotations common between dart2js and dartium. | 718 """ Finds annotations common between dart2js and dartium. |
719 """ | 719 """ |
720 annotations = [] | |
720 if member_name: | 721 if member_name: |
721 return dart_annotations.get('%s.%s' % (interface_name, member_name)) | 722 key = '%s.%s' % (interface_name, member_name) |
722 else: | 723 else: |
723 return dart_annotations.get(interface_name) | 724 key = interface_name |
725 | |
726 annotations.append('@DomName("' + key + '")') | |
blois
2013/01/12 01:21:29
how about annotations = ['@DomName("' + key + '")'
Andrei Mouravski
2013/01/14 22:56:46
Done.
blois
2013/01/15 22:26:32
Undone?
Andrei Mouravski
2013/01/16 00:24:25
I'm confused. What's wrong here?
| |
727 if (dart_annotations.get(key) != None): | |
728 annotations.extend(dart_annotations.get(key)) | |
729 | |
730 return annotations | |
724 | 731 |
725 def FindDart2JSAnnotations(idl_type, interface_name, member_name): | 732 def FindDart2JSAnnotations(idl_type, interface_name, member_name): |
726 """ Finds all annotations for Dart2JS members- including annotations for | 733 """ Finds all annotations for Dart2JS members- including annotations for |
727 both dart2js and dartium. | 734 both dart2js and dartium. |
728 """ | 735 """ |
729 annotations = FindCommonAnnotations(interface_name, member_name) | 736 annotations = FindCommonAnnotations(interface_name, member_name) |
730 if annotations: | 737 if annotations: |
731 annotations = ' '.join(annotations) | 738 annotations = ' '.join(annotations) |
732 | 739 |
733 ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name) | 740 ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name) |
734 if ann2: | 741 if ann2: |
735 if annotations: | 742 if annotations: |
736 annotations = annotations + ' ' + ann2 | 743 annotations = annotations + ' ' + ann2 |
737 else: | 744 else: |
738 annotations = ann2 | 745 annotations = ann2 |
739 return annotations | 746 return annotations |
740 | 747 |
748 def AnySpecificAnnotations(idl_type, interface_name, member_name): | |
749 if (dart_annotations.get('%s.%s' % (interface_name, member_name)) or | |
750 _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name)): | |
751 return True | |
752 else: | |
753 return False | |
754 | |
741 def _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name): | 755 def _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name): |
742 """ Finds dart2js-specific annotations. This does not include ones shared with | 756 """ Finds dart2js-specific annotations. This does not include ones shared with |
743 dartium. | 757 dartium. |
744 """ | 758 """ |
745 ann1 = dart2js_annotations.get("%s.%s" % (interface_name, member_name)) | 759 ann1 = dart2js_annotations.get("%s.%s" % (interface_name, member_name)) |
746 if ann1: | 760 if ann1: |
747 ann2 = dart2js_annotations.get('+' + idl_type) | 761 ann2 = dart2js_annotations.get('+' + idl_type) |
748 if ann2: | 762 if ann2: |
749 return ann2 + ' ' + ann1 | 763 return ann2 + ' ' + ann1 |
750 ann2 = dart2js_annotations.get(idl_type) | 764 ann2 = dart2js_annotations.get(idl_type) |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1284 self) | 1298 self) |
1285 | 1299 |
1286 if type_data.clazz == 'SVGTearOff': | 1300 if type_data.clazz == 'SVGTearOff': |
1287 dart_interface_name = self._renamer.RenameInterface( | 1301 dart_interface_name = self._renamer.RenameInterface( |
1288 self._database.GetInterface(type_name)) | 1302 self._database.GetInterface(type_name)) |
1289 return SVGTearOffIDLTypeInfo( | 1303 return SVGTearOffIDLTypeInfo( |
1290 type_name, type_data, dart_interface_name, self) | 1304 type_name, type_data, dart_interface_name, self) |
1291 | 1305 |
1292 class_name = '%sIDLTypeInfo' % type_data.clazz | 1306 class_name = '%sIDLTypeInfo' % type_data.clazz |
1293 return globals()[class_name](type_name, type_data) | 1307 return globals()[class_name](type_name, type_data) |
OLD | NEW |