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