Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: tools/dom/scripts/generator.py

Issue 11962049: Revert "Fixing formatting of dart:html's dart2js annotations." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/web_audio/dart2js/web_audio_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 # interface and member name, and by IDL return or field type name. Both are 506 # interface and member name, and by IDL return or field type name. Both are
507 # used to assemble the annotations: 507 # used to assemble the annotations:
508 # 508 #
509 # INTERFACE.MEMBER: annotations for member. 509 # INTERFACE.MEMBER: annotations for member.
510 # +TYPE: add annotations only if there are member annotations. 510 # +TYPE: add annotations only if there are member annotations.
511 # -TYPE: add annotations only if there are no member annotations. 511 # -TYPE: add annotations only if there are no member annotations.
512 # TYPE: add regardless of member annotations. 512 # TYPE: add regardless of member annotations.
513 513
514 dart2js_annotations = { 514 dart2js_annotations = {
515 515
516 'CanvasRenderingContext2D.createImageData': [ 516 'CanvasRenderingContext2D.createImageData':
517 "@Creates('ImageData|=Object')", 517 "@Creates('ImageData|=Object')",
518 ],
519 518
520 'CanvasRenderingContext2D.getImageData': [ 519 'CanvasRenderingContext2D.getImageData':
521 "@Creates('ImageData|=Object')", 520 "@Creates('ImageData|=Object')",
522 ],
523 521
524 'CanvasRenderingContext2D.webkitGetImageDataHD': [ 522 'CanvasRenderingContext2D.webkitGetImageDataHD':
525 "@Creates('ImageData|=Object')", 523 "@Creates('ImageData|=Object')",
526 ],
527 524
528 'CanvasRenderingContext2D.fillStyle': [ 525 'CanvasRenderingContext2D.fillStyle':
529 "@Creates('String|CanvasGradient|CanvasPattern')", 526 "@Creates('String|CanvasGradient|CanvasPattern') "
530 "@Returns('String|CanvasGradient|CanvasPattern')", 527 "@Returns('String|CanvasGradient|CanvasPattern')",
531 ],
532 528
533 'CanvasRenderingContext2D.strokeStyle': [ 529 'CanvasRenderingContext2D.strokeStyle':
534 "@Creates('String|CanvasGradient|CanvasPattern')", 530 "@Creates('String|CanvasGradient|CanvasPattern') "
535 "@Returns('String|CanvasGradient|CanvasPattern')", 531 "@Returns('String|CanvasGradient|CanvasPattern')",
536 ],
537 532
538 # Methods returning Window can return a local window, or a cross-frame 533 # Methods returning Window can return a local window, or a cross-frame
539 # window (=Object) that needs wrapping. 534 # window (=Object) that needs wrapping.
540 'DOMWindow': [ 535 'DOMWindow':
541 "@Creates('Window|=Object')", 536 "@Creates('Window|=Object') @Returns('Window|=Object')",
542 "@Returns('Window|=Object')",
543 ],
544 537
545 'DOMWindow.openDatabase': [ 538 'DOMWindow.openDatabase': "@Creates('Database') @Creates('DatabaseSync')",
546 "@Creates('Database')",
547 "@Creates('DatabaseSync')",
548 ],
549 539
550 # Cross-frame windows are EventTargets. 540 # Cross-frame windows are EventTargets.
551 '-EventTarget': [ 541 '-EventTarget':
552 "@Creates('EventTarget|=Object')", 542 "@Creates('EventTarget|=Object') @Returns('EventTarget|=Object')",
553 "@Returns('EventTarget|=Object')",
554 ],
555 543
556 # To be in callback with the browser-created Event, we had to have called 544 # To be in callback with the browser-created Event, we had to have called
557 # addEventListener on the target, so we avoid 545 # addEventListener on the target, so we avoid
558 'Event.currentTarget': [ 546 'Event.currentTarget':
559 "@Creates('Null')", 547 "@Creates('Null') @Returns('EventTarget|=Object')",
560 "@Returns('EventTarget|=Object')",
561 ],
562 548
563 # Only nodes in the DOM bubble and have target !== currentTarget. 549 # Only nodes in the DOM bubble and have target !== currentTarget.
564 'Event.target': [ 550 'Event.target':
565 "@Creates('Node')", 551 "@Creates('Node') @Returns('EventTarget|=Object')",
566 "@Returns('EventTarget|=Object')",
567 ],
568 552
569 'MouseEvent.relatedTarget': [ 553 'MouseEvent.relatedTarget':
570 "@Creates('Node')", 554 "@Creates('Node') @Returns('EventTarget|=Object')",
571 "@Returns('EventTarget|=Object')",
572 ],
573 555
574 # Touch targets are Elements in a Document, or the Document. 556 # Touch targets are Elements in a Document, or the Document.
575 'Touch.target': [ 557 'Touch.target':
576 "@Creates('Element|Document')", 558 "@Creates('Element|Document') @Returns('Element|Document')",
577 "@Returns('Element|Document')",
578 ],
579 559
580 560
581 'FileReader.result': ["@Creates('String|ArrayBuffer|Null')"], 561 'FileReader.result': "@Creates('String|ArrayBuffer|Null')",
582 562
583 # Rather than have the result of an IDBRequest as a union over all possible 563 # Rather than have the result of an IDBRequest as a union over all possible
584 # results, we mark the result as instantiating any classes, and mark 564 # results, we mark the result as instantiating any classes, and mark
585 # each operation with the classes that it could cause to be asynchronously 565 # each operation with the classes that it could cause to be asynchronously
586 # instantiated. 566 # instantiated.
587 'IDBRequest.result': ["@Creates('Null')"], 567 'IDBRequest.result': "@Creates('Null')",
588 568
589 # The source is usually a participant in the operation that generated the 569 # The source is usually a participant in the operation that generated the
590 # IDBRequest. 570 # IDBRequest.
591 'IDBRequest.source': ["@Creates('Null')"], 571 'IDBRequest.source': "@Creates('Null')",
592 572
593 'IDBFactory.open': ["@Creates('Database')"], 573 'IDBFactory.open': "@Creates('Database')",
594 574
595 'IDBObjectStore.put': ["@_annotation_Creates_IDBKey"], 575 'IDBObjectStore.put': "@_annotation_Creates_IDBKey",
596 'IDBObjectStore.add': ["@_annotation_Creates_IDBKey"], 576 'IDBObjectStore.add': "@_annotation_Creates_IDBKey",
597 'IDBObjectStore.get': ["@annotation_Creates_SerializedScriptValue"], 577 'IDBObjectStore.get': "@annotation_Creates_SerializedScriptValue",
598 'IDBObjectStore.openCursor': ["@Creates('Cursor')"], 578 'IDBObjectStore.openCursor': "@Creates('Cursor')",
599 579
600 'IDBIndex.get': ["@annotation_Creates_SerializedScriptValue"], 580 'IDBIndex.get': "@annotation_Creates_SerializedScriptValue",
601 'IDBIndex.getKey': [ 581 'IDBIndex.getKey':
602 "@annotation_Creates_SerializedScriptValue", 582 "@annotation_Creates_SerializedScriptValue "
603 # The source is the object store behind the index. 583 # The source is the object store behind the index.
604 "@Creates('ObjectStore')", 584 "@Creates('ObjectStore')",
605 ], 585 'IDBIndex.openCursor': "@Creates('Cursor')",
606 'IDBIndex.openCursor': ["@Creates('Cursor')"], 586 'IDBIndex.openKeyCursor': "@Creates('Cursor')",
607 'IDBIndex.openKeyCursor': ["@Creates('Cursor')"],
608 587
609 'IDBCursorWithValue.value': [ 588 'IDBCursorWithValue.value':
610 '@annotation_Creates_SerializedScriptValue', 589 '@annotation_Creates_SerializedScriptValue '
611 '@annotation_Returns_SerializedScriptValue', 590 '@annotation_Returns_SerializedScriptValue',
612 ],
613 591
614 'IDBCursor.key': [ 592 'IDBCursor.key': "@_annotation_Creates_IDBKey @_annotation_Returns_IDBKey",
615 "@_annotation_Creates_IDBKey",
616 "@_annotation_Returns_IDBKey",
617 ],
618 593
619 '+IDBRequest': [ 594 '+IDBRequest': "@Returns('Request') @Creates('Request')",
620 "@Returns('Request')",
621 "@Creates('Request')",
622 ],
623 595
624 '+IDBOpenDBRequest': [ 596 '+IDBOpenDBRequest': "@Returns('Request') @Creates('Request')",
625 "@Returns('Request')", 597 '+IDBVersionChangeRequest': "@Returns('Request') @Creates('Request')",
626 "@Creates('Request')",
627 ],
628 '+IDBVersionChangeRequest': [
629 "@Returns('Request')",
630 "@Creates('Request')",
631 ],
632 598
633 'MessageEvent.ports': ["@Creates('=List')"],
634 599
635 'MessageEvent.data': [ 600 'MessageEvent.ports': "@Creates('=List')",
636 "@annotation_Creates_SerializedScriptValue", 601
602 'MessageEvent.data':
603 "@annotation_Creates_SerializedScriptValue "
637 "@annotation_Returns_SerializedScriptValue", 604 "@annotation_Returns_SerializedScriptValue",
638 ], 605 'PopStateEvent.state':
639 'PopStateEvent.state': [ 606 "@annotation_Creates_SerializedScriptValue "
640 "@annotation_Creates_SerializedScriptValue",
641 "@annotation_Returns_SerializedScriptValue", 607 "@annotation_Returns_SerializedScriptValue",
642 ], 608 'SerializedScriptValue':
643 'SerializedScriptValue': [ 609 "@annotation_Creates_SerializedScriptValue "
644 "@annotation_Creates_SerializedScriptValue",
645 "@annotation_Returns_SerializedScriptValue", 610 "@annotation_Returns_SerializedScriptValue",
646 ],
647 611
648 'SQLResultSetRowList.item': ["@Creates('=Object')"], 612 'SQLResultSetRowList.item': "@Creates('=Object')",
649 613
650 'XMLHttpRequest.response': [ 614 'XMLHttpRequest.response':
651 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", 615 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')",
652 ],
653 } 616 }
654 617
655 # Placeholder to add experimental flag, implementation for this is 618 # Placeholder to add experimental flag, implementation for this is
656 # pending in a separate CL. 619 # pending in a separate CL.
657 dart_annotations = { 620 dart_annotations = {
658 'Element.webkitMatchesSelector': ['@Experimental()'], 621 'Element.webkitMatchesSelector': ['@Experimental()'],
659 } 622 }
660 623
661 _indexed_db_annotations = [ 624 _indexed_db_annotations = [
662 "@SupportedBrowser(SupportedBrowser.CHROME)", 625 "@SupportedBrowser(SupportedBrowser.CHROME)",
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", 713 "@SupportedBrowser(SupportedBrowser.CHROME, '25')",
751 "@Experimental()", 714 "@Experimental()",
752 ], 715 ],
753 'HTMLTrackElement': [ 716 'HTMLTrackElement': [
754 "@SupportedBrowser(SupportedBrowser.CHROME)", 717 "@SupportedBrowser(SupportedBrowser.CHROME)",
755 "@SupportedBrowser(SupportedBrowser.IE, '10')", 718 "@SupportedBrowser(SupportedBrowser.IE, '10')",
756 "@SupportedBrowser(SupportedBrowser.SAFARI)", 719 "@SupportedBrowser(SupportedBrowser.SAFARI)",
757 ], 720 ],
758 'IDBFactory': _indexed_db_annotations, 721 'IDBFactory': _indexed_db_annotations,
759 'IDBDatabase': _indexed_db_annotations, 722 'IDBDatabase': _indexed_db_annotations,
760 'MutationObserver': [
761 "@SupportedBrowser(SupportedBrowser.CHROME)",
762 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
763 "@SupportedBrowser(SupportedBrowser.SAFARI)",
764 "@Experimental()",
765 ],
766 'NotificationCenter': _webkit_experimental_annotations, 723 'NotificationCenter': _webkit_experimental_annotations,
767 'Performance': _performance_annotations, 724 'Performance': _performance_annotations,
768 'ShadowRoot': [ 725 'ShadowRoot': [
769 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", 726 "@SupportedBrowser(SupportedBrowser.CHROME, '25')",
770 "@Experimental()", 727 "@Experimental()",
771 ], 728 ],
772 'WebSocket': _all_but_ie9_annotations, 729 'WebSocket': _all_but_ie9_annotations,
773 'WorkerContext.indexedDB': _indexed_db_annotations, 730 'WorkerContext.indexedDB': _indexed_db_annotations,
774 'WorkerContext.webkitRequestFileSystem': _file_system_annotations, 731 'WorkerContext.webkitRequestFileSystem': _file_system_annotations,
775 'WorkerContext.webkitRequestFileSystemSync': _file_system_annotations, 732 'WorkerContext.webkitRequestFileSystemSync': _file_system_annotations,
(...skipping 14 matching lines...) Expand all
790 if (dart_annotations.get(key) != None): 747 if (dart_annotations.get(key) != None):
791 annotations.extend(dart_annotations.get(key)) 748 annotations.extend(dart_annotations.get(key))
792 749
793 return annotations 750 return annotations
794 751
795 def FindDart2JSAnnotations(idl_type, interface_name, member_name): 752 def FindDart2JSAnnotations(idl_type, interface_name, member_name):
796 """ Finds all annotations for Dart2JS members- including annotations for 753 """ Finds all annotations for Dart2JS members- including annotations for
797 both dart2js and dartium. 754 both dart2js and dartium.
798 """ 755 """
799 annotations = FindCommonAnnotations(interface_name, member_name) 756 annotations = FindCommonAnnotations(interface_name, member_name)
757 if annotations:
758 annotations = ' '.join(annotations)
800 759
801 ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name) 760 ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name)
802 if ann2: 761 if ann2:
803 if annotations: 762 if annotations:
804 annotations.extend(ann2) 763 annotations = annotations + ' ' + ann2
805 else: 764 else:
806 annotations = ann2 765 annotations = ann2
807 return annotations 766 return annotations
808 767
809 def AnyConversionAnnotations(idl_type, interface_name, member_name): 768 def AnyConversionAnnotations(idl_type, interface_name, member_name):
810 if (dart_annotations.get('%s.%s' % (interface_name, member_name)) or 769 if (dart_annotations.get('%s.%s' % (interface_name, member_name)) or
811 _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name)): 770 _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name)):
812 return True 771 return True
813 else: 772 else:
814 return False 773 return False
815 774
816 def FormatAnnotations(annotations, indentation):
817 if annotations:
818 newline = '\n%s' % indentation
819 result = newline.join(annotations) + newline
820 return result
821 return ''
822
823 def _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name): 775 def _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name):
824 """ Finds dart2js-specific annotations. This does not include ones shared with 776 """ Finds dart2js-specific annotations. This does not include ones shared with
825 dartium. 777 dartium.
826 """ 778 """
827 ann1 = dart2js_annotations.get("%s.%s" % (interface_name, member_name)) 779 ann1 = dart2js_annotations.get("%s.%s" % (interface_name, member_name))
828 if ann1: 780 if ann1:
829 ann2 = dart2js_annotations.get('+' + idl_type) 781 ann2 = dart2js_annotations.get('+' + idl_type)
830 if ann2: 782 if ann2:
831 return ann1.extend(ann2) 783 return ann2 + ' ' + ann1
832 ann2 = dart2js_annotations.get(idl_type) 784 ann2 = dart2js_annotations.get(idl_type)
833 if ann2: 785 if ann2:
834 return ann1.extend(ann2) 786 return ann2 + ' ' + ann1
835 return ann1 787 return ann1
836 788
837 ann2 = dart2js_annotations.get('-' + idl_type) 789 ann2 = dart2js_annotations.get('-' + idl_type)
838 if ann2: 790 if ann2:
839 return ann2 791 return ann2
840 ann2 = dart2js_annotations.get(idl_type) 792 ann2 = dart2js_annotations.get(idl_type)
841 return ann2 793 return ann2
842 794
843 # ------------------------------------------------------------------------------ 795 # ------------------------------------------------------------------------------
844 796
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 self) 1319 self)
1368 1320
1369 if type_data.clazz == 'SVGTearOff': 1321 if type_data.clazz == 'SVGTearOff':
1370 dart_interface_name = self._renamer.RenameInterface( 1322 dart_interface_name = self._renamer.RenameInterface(
1371 self._database.GetInterface(type_name)) 1323 self._database.GetInterface(type_name))
1372 return SVGTearOffIDLTypeInfo( 1324 return SVGTearOffIDLTypeInfo(
1373 type_name, type_data, dart_interface_name, self) 1325 type_name, type_data, dart_interface_name, self)
1374 1326
1375 class_name = '%sIDLTypeInfo' % type_data.clazz 1327 class_name = '%sIDLTypeInfo' % type_data.clazz
1376 return globals()[class_name](type_name, type_data) 1328 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « sdk/lib/web_audio/dart2js/web_audio_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698