| 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 json | 10 import json |
| 11 import os | 11 import os |
| 12 import re | 12 import re |
| 13 from htmlrenamer import html_interface_renames | 13 from htmlrenamer import html_interface_renames |
| 14 | 14 |
| 15 # Set up json file for retrieving comments. | 15 # Set up json file for retrieving comments. |
| 16 _current_dir = os.path.dirname(__file__) | 16 _current_dir = os.path.dirname(__file__) |
| 17 _json_path = os.path.join(_current_dir, '..', 'docs', 'docs.json') | 17 _json_path = os.path.join(_current_dir, '..', 'docs', 'docs.json') |
| 18 _dom_json = json.load(open(_json_path)) | 18 _dom_json = json.load(open(_json_path)) |
| 19 | 19 |
| 20 _pure_interfaces = set([ | 20 _pure_interfaces = set([ |
| 21 # TODO(sra): DOMStringMap should be a class implementing Map<String,String>. | 21 # TODO(sra): DOMStringMap should be a class implementing Map<String,String>. |
| 22 'DOMStringMap', | 22 'DOMStringMap', |
| 23 'ElementTimeControl', | 23 'ElementTimeControl', |
| 24 'ElementTraversal', | 24 'ElementTraversal', |
| 25 'EventListener', | 25 'EventListener', |
| 26 'MediaQueryListListener', | 26 'MediaQueryListListener', |
| 27 'MutationCallback', | 27 'MutationCallback', |
| 28 'NodeSelector', | 28 'NodeSelector', |
| 29 'SVGExternalResourcesRequired', | |
| 30 'SVGFilterPrimitiveStandardAttributes', | 29 'SVGFilterPrimitiveStandardAttributes', |
| 31 'SVGFitToViewBox', | 30 'SVGFitToViewBox', |
| 32 'SVGLangSpace', | |
| 33 'SVGLocatable', | 31 'SVGLocatable', |
| 34 'SVGTests', | 32 'SVGTests', |
| 35 'SVGTransformable', | 33 'SVGTransformable', |
| 36 'SVGURIReference', | 34 'SVGURIReference', |
| 37 'SVGZoomAndPan', | 35 'SVGZoomAndPan', |
| 38 'TimeoutHandler']) | 36 'TimeoutHandler']) |
| 39 | 37 |
| 40 def IsPureInterface(interface_name): | 38 def IsPureInterface(interface_name): |
| 41 return interface_name in _pure_interfaces | 39 return interface_name in _pure_interfaces |
| 42 | 40 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 "@annotation_Returns_SerializedScriptValue", | 645 "@annotation_Returns_SerializedScriptValue", |
| 648 ], | 646 ], |
| 649 | 647 |
| 650 'SQLResultSetRowList.item': ["@Creates('=Object')"], | 648 'SQLResultSetRowList.item': ["@Creates('=Object')"], |
| 651 | 649 |
| 652 'XMLHttpRequest.response': [ | 650 'XMLHttpRequest.response': [ |
| 653 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", | 651 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", |
| 654 ], | 652 ], |
| 655 } | 653 } |
| 656 | 654 |
| 657 # Placeholder to add experimental flag, implementation for this is | |
| 658 # pending in a separate CL. | |
| 659 dart_annotations = { | |
| 660 'Element.webkitMatchesSelector': ['@Experimental'], | |
| 661 } | |
| 662 | |
| 663 _indexed_db_annotations = [ | 655 _indexed_db_annotations = [ |
| 664 "@SupportedBrowser(SupportedBrowser.CHROME)", | 656 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 665 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", | 657 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", |
| 666 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 658 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 667 "@Experimental", | 659 "@Experimental", |
| 668 ] | 660 ] |
| 669 | 661 |
| 670 _file_system_annotations = [ | 662 _file_system_annotations = [ |
| 671 "@SupportedBrowser(SupportedBrowser.CHROME)", | 663 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 672 "@Experimental", | 664 "@Experimental", |
| 673 ] | 665 ] |
| 674 | 666 |
| 675 _all_but_ie9_annotations = [ | 667 _all_but_ie9_annotations = [ |
| 676 "@SupportedBrowser(SupportedBrowser.CHROME)", | 668 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 677 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 669 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 678 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 670 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 679 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 671 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 680 ] | 672 ] |
| 681 | 673 |
| 682 _webkit_experimental_annotations = [ | 674 _webkit_experimental_annotations = [ |
| 683 "@SupportedBrowser(SupportedBrowser.CHROME)", | 675 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 684 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 676 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 685 "@Experimental", | 677 "@Experimental", |
| 686 ] | 678 ] |
| 687 | 679 |
| 688 _history_annotations = _all_but_ie9_annotations | 680 _history_annotations = _all_but_ie9_annotations |
| 689 | 681 |
| 682 _no_ie_annotations = [ |
| 683 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 684 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 685 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 686 ] |
| 687 |
| 690 _performance_annotations = [ | 688 _performance_annotations = [ |
| 691 "@SupportedBrowser(SupportedBrowser.CHROME)", | 689 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 692 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 690 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 693 "@SupportedBrowser(SupportedBrowser.IE)", | 691 "@SupportedBrowser(SupportedBrowser.IE)", |
| 694 ] | 692 ] |
| 695 | 693 |
| 696 _speech_recognition_annotations = [ | 694 _speech_recognition_annotations = [ |
| 697 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 695 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 698 "@Experimental", | 696 "@Experimental", |
| 699 ] | 697 ] |
| 700 | 698 |
| 699 _svg_annotations = _all_but_ie9_annotations; |
| 700 |
| 701 _web_sql_annotations = [ | 701 _web_sql_annotations = [ |
| 702 "@SupportedBrowser(SupportedBrowser.CHROME)", | 702 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 703 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 703 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 704 "@Experimental", | 704 "@Experimental", |
| 705 ] | 705 ] |
| 706 | 706 |
| 707 _webgl_annotations = [ | 707 _webgl_annotations = [ |
| 708 "@SupportedBrowser(SupportedBrowser.CHROME)", | 708 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 709 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 709 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 710 "@Experimental", | 710 "@Experimental", |
| (...skipping 16 matching lines...) Expand all Loading... |
| 727 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 727 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 728 ], | 728 ], |
| 729 'DOMWindow.convertPointFromNodeToPage': _webkit_experimental_annotations, | 729 'DOMWindow.convertPointFromNodeToPage': _webkit_experimental_annotations, |
| 730 'DOMWindow.convertPointFromPageToNode': _webkit_experimental_annotations, | 730 'DOMWindow.convertPointFromPageToNode': _webkit_experimental_annotations, |
| 731 'DOMWindow.indexedDB': _indexed_db_annotations, | 731 'DOMWindow.indexedDB': _indexed_db_annotations, |
| 732 'DOMWindow.openDatabase': _web_sql_annotations, | 732 'DOMWindow.openDatabase': _web_sql_annotations, |
| 733 'DOMWindow.performance': _performance_annotations, | 733 'DOMWindow.performance': _performance_annotations, |
| 734 'DOMWindow.webkitNotifications': _webkit_experimental_annotations, | 734 'DOMWindow.webkitNotifications': _webkit_experimental_annotations, |
| 735 'DOMWindow.webkitRequestFileSystem': _file_system_annotations, | 735 'DOMWindow.webkitRequestFileSystem': _file_system_annotations, |
| 736 'DOMWindow.webkitResolveLocalFileSystemURL': _file_system_annotations, | 736 'DOMWindow.webkitResolveLocalFileSystemURL': _file_system_annotations, |
| 737 # Placeholder to add experimental flag, implementation for this is |
| 738 # pending in a separate CL. |
| 739 'Element.webkitMatchesSelector': ['@Experimental()'], |
| 737 'Element.webkitCreateShadowRoot': [ | 740 'Element.webkitCreateShadowRoot': [ |
| 738 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 741 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 739 "@Experimental", | 742 "@Experimental", |
| 740 ], | 743 ], |
| 741 'FileSystem': _file_system_annotations, | 744 'FileSystem': _file_system_annotations, |
| 742 'FileSystemSync': _file_system_annotations, | 745 'FileSystemSync': _file_system_annotations, |
| 743 'HashChangeEvent': [ | 746 'HashChangeEvent': [ |
| 744 "@SupportedBrowser(SupportedBrowser.CHROME)", | 747 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 745 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 748 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 746 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 749 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 747 ], | 750 ], |
| 748 'History.pushState': _history_annotations, | 751 'History.pushState': _history_annotations, |
| 749 'History.replaceState': _history_annotations, | 752 'History.replaceState': _history_annotations, |
| 750 'HTMLContentElement': [ | 753 'HTMLContentElement': [ |
| 751 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 754 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 752 "@Experimental", | 755 "@Experimental", |
| 753 ], | 756 ], |
| 754 'HTMLDataListElement': _all_but_ie9_annotations, | 757 'HTMLDataListElement': _all_but_ie9_annotations, |
| 755 'HTMLDetailsElement': _webkit_experimental_annotations, | 758 'HTMLDetailsElement': _webkit_experimental_annotations, |
| 756 'HTMLEmbedElement': [ | 759 'HTMLEmbedElement': [ |
| 757 "@SupportedBrowser(SupportedBrowser.CHROME)", | 760 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 758 "@SupportedBrowser(SupportedBrowser.IE)", | 761 "@SupportedBrowser(SupportedBrowser.IE)", |
| 759 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 762 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 760 ], | 763 ], |
| 761 'HTMLKeygenElement': _webkit_experimental_annotations, | 764 'HTMLKeygenElement': _webkit_experimental_annotations, |
| 762 'HTMLMeterElement': [ | 765 'HTMLMeterElement': _no_ie_annotations, |
| 763 "@SupportedBrowser(SupportedBrowser.CHROME)", | 766 'HTMLObjectElement': _no_ie_annotations, |
| 764 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 767 'HTMLOutputElement': _no_ie_annotations, |
| 765 "@SupportedBrowser(SupportedBrowser.SAFARI)", | |
| 766 ], | |
| 767 'HTMLObjectElement': [ | |
| 768 "@SupportedBrowser(SupportedBrowser.CHROME)", | |
| 769 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | |
| 770 "@SupportedBrowser(SupportedBrowser.SAFARI)", | |
| 771 ], | |
| 772 'HTMLOutputElement': [ | |
| 773 "@SupportedBrowser(SupportedBrowser.CHROME)", | |
| 774 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | |
| 775 "@SupportedBrowser(SupportedBrowser.SAFARI)", | |
| 776 ], | |
| 777 'HTMLProgressElement': _all_but_ie9_annotations, | 768 'HTMLProgressElement': _all_but_ie9_annotations, |
| 778 'HTMLShadowElement': [ | 769 'HTMLShadowElement': [ |
| 779 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 770 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 780 "@Experimental", | 771 "@Experimental", |
| 781 ], | 772 ], |
| 782 'HTMLTrackElement': [ | 773 'HTMLTrackElement': [ |
| 783 "@SupportedBrowser(SupportedBrowser.CHROME)", | 774 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 784 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 775 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 785 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 776 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 786 ], | 777 ], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 797 'PopStateEvent': _history_annotations, | 788 'PopStateEvent': _history_annotations, |
| 798 'ShadowRoot': [ | 789 'ShadowRoot': [ |
| 799 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 790 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 800 "@Experimental", | 791 "@Experimental", |
| 801 ], | 792 ], |
| 802 'SpeechRecognition': _speech_recognition_annotations, | 793 'SpeechRecognition': _speech_recognition_annotations, |
| 803 'SpeechRecognitionAlternative': _speech_recognition_annotations, | 794 'SpeechRecognitionAlternative': _speech_recognition_annotations, |
| 804 'SpeechRecognitionError': _speech_recognition_annotations, | 795 'SpeechRecognitionError': _speech_recognition_annotations, |
| 805 'SpeechRecognitionEvent': _speech_recognition_annotations, | 796 'SpeechRecognitionEvent': _speech_recognition_annotations, |
| 806 'SpeechRecognitionResult': _speech_recognition_annotations, | 797 'SpeechRecognitionResult': _speech_recognition_annotations, |
| 798 'SVGAltGlyphElement': _no_ie_annotations, |
| 799 'SVGAnimateElement': _no_ie_annotations, |
| 800 'SVGAnimateMotionElement': _no_ie_annotations, |
| 801 'SVGAnimateTransformElement': _no_ie_annotations, |
| 802 'SVGFEBlendElement': _svg_annotations, |
| 803 'SVGFEColorMatrixElement': _svg_annotations, |
| 804 'SVGFEComponentTransferElement': _svg_annotations, |
| 805 'SVGFEConvolveMatrixElement': _svg_annotations, |
| 806 'SVGFEDiffuseLightingElement': _svg_annotations, |
| 807 'SVGFEDisplacementMapElement': _svg_annotations, |
| 808 'SVGFEDistantLightElement': _svg_annotations, |
| 809 'SVGFEFloodElement': _svg_annotations, |
| 810 'SVGFEFuncAElement': _svg_annotations, |
| 811 'SVGFEFuncBElement': _svg_annotations, |
| 812 'SVGFEFuncGElement': _svg_annotations, |
| 813 'SVGFEFuncRElement': _svg_annotations, |
| 814 'SVGFEGaussianBlurElement': _svg_annotations, |
| 815 'SVGFEImageElement': _svg_annotations, |
| 816 'SVGFEMergeElement': _svg_annotations, |
| 817 'SVGFEMergeNodeElement': _svg_annotations, |
| 818 'SVGFEMorphology': _svg_annotations, |
| 819 'SVGFEOffsetElement': _svg_annotations, |
| 820 'SVGFEPointLightElement': _svg_annotations, |
| 821 'SVGFESpecularLightingElement': _svg_annotations, |
| 822 'SVGFESpotLightElement': _svg_annotations, |
| 823 'SVGFETileElement': _svg_annotations, |
| 824 'SVGFETurbulenceElement': _svg_annotations, |
| 825 'SVGFilterElement': _svg_annotations, |
| 826 'SVGForeignObjectElement': _no_ie_annotations, |
| 827 'SVGSetElement': _no_ie_annotations, |
| 807 'SQLTransaction': _web_sql_annotations, | 828 'SQLTransaction': _web_sql_annotations, |
| 808 'SQLTransactionSync': _web_sql_annotations, | 829 'SQLTransactionSync': _web_sql_annotations, |
| 809 'WebGLRenderingContext': _webgl_annotations, | 830 'WebGLRenderingContext': _webgl_annotations, |
| 810 'WebKitCSSMatrix': _webkit_experimental_annotations, | 831 'WebKitCSSMatrix': _webkit_experimental_annotations, |
| 811 'WebKitPoint': _webkit_experimental_annotations, | 832 'WebKitPoint': _webkit_experimental_annotations, |
| 812 'WebSocket': _all_but_ie9_annotations, | 833 'WebSocket': _all_but_ie9_annotations, |
| 813 'WorkerContext.indexedDB': _indexed_db_annotations, | 834 'WorkerContext.indexedDB': _indexed_db_annotations, |
| 814 'WorkerContext.openDatabase': _web_sql_annotations, | 835 'WorkerContext.openDatabase': _web_sql_annotations, |
| 815 'WorkerContext.openDatabaseSync': _web_sql_annotations, | 836 'WorkerContext.openDatabaseSync': _web_sql_annotations, |
| 816 'WorkerContext.webkitRequestFileSystem': _file_system_annotations, | 837 'WorkerContext.webkitRequestFileSystem': _file_system_annotations, |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 self) | 1471 self) |
| 1451 | 1472 |
| 1452 if type_data.clazz == 'SVGTearOff': | 1473 if type_data.clazz == 'SVGTearOff': |
| 1453 dart_interface_name = self._renamer.RenameInterface( | 1474 dart_interface_name = self._renamer.RenameInterface( |
| 1454 self._database.GetInterface(type_name)) | 1475 self._database.GetInterface(type_name)) |
| 1455 return SVGTearOffIDLTypeInfo( | 1476 return SVGTearOffIDLTypeInfo( |
| 1456 type_name, type_data, dart_interface_name, self) | 1477 type_name, type_data, dart_interface_name, self) |
| 1457 | 1478 |
| 1458 class_name = '%sIDLTypeInfo' % type_data.clazz | 1479 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1459 return globals()[class_name](type_name, type_data) | 1480 return globals()[class_name](type_name, type_data) |
| OLD | NEW |