| 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', |
| 29 'SVGFilterPrimitiveStandardAttributes', | 30 'SVGFilterPrimitiveStandardAttributes', |
| 30 'SVGFitToViewBox', | 31 'SVGFitToViewBox', |
| 32 'SVGLangSpace', |
| 31 'SVGLocatable', | 33 'SVGLocatable', |
| 32 'SVGTests', | 34 'SVGTests', |
| 33 'SVGTransformable', | 35 'SVGTransformable', |
| 34 'SVGURIReference', | 36 'SVGURIReference', |
| 35 'SVGZoomAndPan', | 37 'SVGZoomAndPan', |
| 36 'TimeoutHandler']) | 38 'TimeoutHandler']) |
| 37 | 39 |
| 38 def IsPureInterface(interface_name): | 40 def IsPureInterface(interface_name): |
| 39 return interface_name in _pure_interfaces | 41 return interface_name in _pure_interfaces |
| 40 | 42 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 "@annotation_Returns_SerializedScriptValue", | 647 "@annotation_Returns_SerializedScriptValue", |
| 646 ], | 648 ], |
| 647 | 649 |
| 648 'SQLResultSetRowList.item': ["@Creates('=Object')"], | 650 'SQLResultSetRowList.item': ["@Creates('=Object')"], |
| 649 | 651 |
| 650 'XMLHttpRequest.response': [ | 652 'XMLHttpRequest.response': [ |
| 651 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", | 653 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", |
| 652 ], | 654 ], |
| 653 } | 655 } |
| 654 | 656 |
| 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 |
| 655 _indexed_db_annotations = [ | 663 _indexed_db_annotations = [ |
| 656 "@SupportedBrowser(SupportedBrowser.CHROME)", | 664 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 657 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", | 665 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", |
| 658 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 666 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 659 "@Experimental", | 667 "@Experimental", |
| 660 ] | 668 ] |
| 661 | 669 |
| 662 _file_system_annotations = [ | 670 _file_system_annotations = [ |
| 663 "@SupportedBrowser(SupportedBrowser.CHROME)", | 671 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 664 "@Experimental", | 672 "@Experimental", |
| 665 ] | 673 ] |
| 666 | 674 |
| 667 _all_but_ie9_annotations = [ | 675 _all_but_ie9_annotations = [ |
| 668 "@SupportedBrowser(SupportedBrowser.CHROME)", | 676 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 669 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 677 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 670 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 678 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 671 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 679 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 672 ] | 680 ] |
| 673 | 681 |
| 674 _webkit_experimental_annotations = [ | 682 _webkit_experimental_annotations = [ |
| 675 "@SupportedBrowser(SupportedBrowser.CHROME)", | 683 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 676 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 684 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 677 "@Experimental", | 685 "@Experimental", |
| 678 ] | 686 ] |
| 679 | 687 |
| 680 _history_annotations = _all_but_ie9_annotations | 688 _history_annotations = _all_but_ie9_annotations |
| 681 | 689 |
| 682 _no_ie_annotations = [ | |
| 683 "@SupportedBrowser(SupportedBrowser.CHROME)", | |
| 684 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | |
| 685 "@SupportedBrowser(SupportedBrowser.SAFARI)", | |
| 686 ] | |
| 687 | |
| 688 _performance_annotations = [ | 690 _performance_annotations = [ |
| 689 "@SupportedBrowser(SupportedBrowser.CHROME)", | 691 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 690 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 692 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 691 "@SupportedBrowser(SupportedBrowser.IE)", | 693 "@SupportedBrowser(SupportedBrowser.IE)", |
| 692 ] | 694 ] |
| 693 | 695 |
| 694 _speech_recognition_annotations = [ | 696 _speech_recognition_annotations = [ |
| 695 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 697 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 696 "@Experimental", | 698 "@Experimental", |
| 697 ] | 699 ] |
| 698 | 700 |
| 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()'], | |
| 740 'Element.webkitCreateShadowRoot': [ | 737 'Element.webkitCreateShadowRoot': [ |
| 741 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 738 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 742 "@Experimental", | 739 "@Experimental", |
| 743 ], | 740 ], |
| 744 'FileSystem': _file_system_annotations, | 741 'FileSystem': _file_system_annotations, |
| 745 'FileSystemSync': _file_system_annotations, | 742 'FileSystemSync': _file_system_annotations, |
| 746 'HashChangeEvent': [ | 743 'HashChangeEvent': [ |
| 747 "@SupportedBrowser(SupportedBrowser.CHROME)", | 744 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 748 "@SupportedBrowser(SupportedBrowser.FIREFOX)", | 745 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 749 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 746 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 750 ], | 747 ], |
| 751 'History.pushState': _history_annotations, | 748 'History.pushState': _history_annotations, |
| 752 'History.replaceState': _history_annotations, | 749 'History.replaceState': _history_annotations, |
| 753 'HTMLContentElement': [ | 750 'HTMLContentElement': [ |
| 754 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 751 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 755 "@Experimental", | 752 "@Experimental", |
| 756 ], | 753 ], |
| 757 'HTMLDataListElement': _all_but_ie9_annotations, | 754 'HTMLDataListElement': _all_but_ie9_annotations, |
| 758 'HTMLDetailsElement': _webkit_experimental_annotations, | 755 'HTMLDetailsElement': _webkit_experimental_annotations, |
| 759 'HTMLEmbedElement': [ | 756 'HTMLEmbedElement': [ |
| 760 "@SupportedBrowser(SupportedBrowser.CHROME)", | 757 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 761 "@SupportedBrowser(SupportedBrowser.IE)", | 758 "@SupportedBrowser(SupportedBrowser.IE)", |
| 762 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 759 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 763 ], | 760 ], |
| 764 'HTMLKeygenElement': _webkit_experimental_annotations, | 761 'HTMLKeygenElement': _webkit_experimental_annotations, |
| 765 'HTMLMeterElement': _no_ie_annotations, | 762 'HTMLMeterElement': [ |
| 766 'HTMLObjectElement': _no_ie_annotations, | 763 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 767 'HTMLOutputElement': _no_ie_annotations, | 764 "@SupportedBrowser(SupportedBrowser.FIREFOX)", |
| 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 ], |
| 768 'HTMLProgressElement': _all_but_ie9_annotations, | 777 'HTMLProgressElement': _all_but_ie9_annotations, |
| 769 'HTMLShadowElement': [ | 778 'HTMLShadowElement': [ |
| 770 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 779 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 771 "@Experimental", | 780 "@Experimental", |
| 772 ], | 781 ], |
| 773 'HTMLTrackElement': [ | 782 'HTMLTrackElement': [ |
| 774 "@SupportedBrowser(SupportedBrowser.CHROME)", | 783 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 775 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 784 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 776 "@SupportedBrowser(SupportedBrowser.SAFARI)", | 785 "@SupportedBrowser(SupportedBrowser.SAFARI)", |
| 777 ], | 786 ], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 788 'PopStateEvent': _history_annotations, | 797 'PopStateEvent': _history_annotations, |
| 789 'ShadowRoot': [ | 798 'ShadowRoot': [ |
| 790 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", | 799 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", |
| 791 "@Experimental", | 800 "@Experimental", |
| 792 ], | 801 ], |
| 793 'SpeechRecognition': _speech_recognition_annotations, | 802 'SpeechRecognition': _speech_recognition_annotations, |
| 794 'SpeechRecognitionAlternative': _speech_recognition_annotations, | 803 'SpeechRecognitionAlternative': _speech_recognition_annotations, |
| 795 'SpeechRecognitionError': _speech_recognition_annotations, | 804 'SpeechRecognitionError': _speech_recognition_annotations, |
| 796 'SpeechRecognitionEvent': _speech_recognition_annotations, | 805 'SpeechRecognitionEvent': _speech_recognition_annotations, |
| 797 'SpeechRecognitionResult': _speech_recognition_annotations, | 806 '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, | |
| 828 'SQLTransaction': _web_sql_annotations, | 807 'SQLTransaction': _web_sql_annotations, |
| 829 'SQLTransactionSync': _web_sql_annotations, | 808 'SQLTransactionSync': _web_sql_annotations, |
| 830 'WebGLRenderingContext': _webgl_annotations, | 809 'WebGLRenderingContext': _webgl_annotations, |
| 831 'WebKitCSSMatrix': _webkit_experimental_annotations, | 810 'WebKitCSSMatrix': _webkit_experimental_annotations, |
| 832 'WebKitPoint': _webkit_experimental_annotations, | 811 'WebKitPoint': _webkit_experimental_annotations, |
| 833 'WebSocket': _all_but_ie9_annotations, | 812 'WebSocket': _all_but_ie9_annotations, |
| 834 'WorkerContext.indexedDB': _indexed_db_annotations, | 813 'WorkerContext.indexedDB': _indexed_db_annotations, |
| 835 'WorkerContext.openDatabase': _web_sql_annotations, | 814 'WorkerContext.openDatabase': _web_sql_annotations, |
| 836 'WorkerContext.openDatabaseSync': _web_sql_annotations, | 815 'WorkerContext.openDatabaseSync': _web_sql_annotations, |
| 837 'WorkerContext.webkitRequestFileSystem': _file_system_annotations, | 816 'WorkerContext.webkitRequestFileSystem': _file_system_annotations, |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 self) | 1450 self) |
| 1472 | 1451 |
| 1473 if type_data.clazz == 'SVGTearOff': | 1452 if type_data.clazz == 'SVGTearOff': |
| 1474 dart_interface_name = self._renamer.RenameInterface( | 1453 dart_interface_name = self._renamer.RenameInterface( |
| 1475 self._database.GetInterface(type_name)) | 1454 self._database.GetInterface(type_name)) |
| 1476 return SVGTearOffIDLTypeInfo( | 1455 return SVGTearOffIDLTypeInfo( |
| 1477 type_name, type_data, dart_interface_name, self) | 1456 type_name, type_data, dart_interface_name, self) |
| 1478 | 1457 |
| 1479 class_name = '%sIDLTypeInfo' % type_data.clazz | 1458 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1480 return globals()[class_name](type_name, type_data) | 1459 return globals()[class_name](type_name, type_data) |
| OLD | NEW |