| 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 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 # | 72 # |
| 73 _dart_attribute_renames = monitored.Dict('generator._dart_attribute_renames', { | 73 _dart_attribute_renames = monitored.Dict('generator._dart_attribute_renames', { |
| 74 'default': 'defaultValue', | 74 'default': 'defaultValue', |
| 75 }) | 75 }) |
| 76 | 76 |
| 77 # | 77 # |
| 78 # Interface version of the DOM needs to delegate typed array constructors to a | 78 # Interface version of the DOM needs to delegate typed array constructors to a |
| 79 # factory provider. | 79 # factory provider. |
| 80 # | 80 # |
| 81 interface_factories = monitored.Dict('generator.interface_factories', { | 81 interface_factories = monitored.Dict('generator.interface_factories', { |
| 82 'Float32Array': '_TypedArrayFactoryProvider', | 82 'Float32List': '_TypedArrayFactoryProvider', |
| 83 'Float64Array': '_TypedArrayFactoryProvider', | 83 'Float64List': '_TypedArrayFactoryProvider', |
| 84 'Int8Array': '_TypedArrayFactoryProvider', | 84 'Int8List': '_TypedArrayFactoryProvider', |
| 85 'Int16Array': '_TypedArrayFactoryProvider', | 85 'Int16List': '_TypedArrayFactoryProvider', |
| 86 'Int32Array': '_TypedArrayFactoryProvider', | 86 'Int32List': '_TypedArrayFactoryProvider', |
| 87 'Uint8Array': '_TypedArrayFactoryProvider', | 87 'Uint8List': '_TypedArrayFactoryProvider', |
| 88 'Uint8ClampedArray': '_TypedArrayFactoryProvider', | 88 'Uint8ClampedList': '_TypedArrayFactoryProvider', |
| 89 'Uint16Array': '_TypedArrayFactoryProvider', | 89 'Uint16List': '_TypedArrayFactoryProvider', |
| 90 'Uint32Array': '_TypedArrayFactoryProvider', | 90 'Uint32List': '_TypedArrayFactoryProvider', |
| 91 }) | 91 }) |
| 92 | 92 |
| 93 # | 93 # |
| 94 # Custom native specs for the dart2js dom. | 94 # Custom native specs for the dart2js dom. |
| 95 # | 95 # |
| 96 _dart2js_dom_custom_native_specs = monitored.Dict( | 96 _dart2js_dom_custom_native_specs = monitored.Dict( |
| 97 'generator._dart2js_dom_custom_native_specs', { | 97 'generator._dart2js_dom_custom_native_specs', { |
| 98 # Decorate the singleton Console object, if present (workers do not have a | 98 # Decorate the singleton Console object, if present (workers do not have a |
| 99 # console). | 99 # console). |
| 100 'Console': "=(typeof console == 'undefined' ? {} : console)", | 100 'Console': "=(typeof console == 'undefined' ? {} : console)", |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 def _ConstructorFullName(self, rename_type): | 390 def _ConstructorFullName(self, rename_type): |
| 391 if self.constructor_name: | 391 if self.constructor_name: |
| 392 return rename_type(self.type_name) + '.' + self.constructor_name | 392 return rename_type(self.type_name) + '.' + self.constructor_name |
| 393 else: | 393 else: |
| 394 # TODO(antonm): temporary ugly hack. | 394 # TODO(antonm): temporary ugly hack. |
| 395 # While in transition phase we allow both DOM's ArrayBuffer | 395 # While in transition phase we allow both DOM's ArrayBuffer |
| 396 # and dart:typeddata's ByteBuffer for IDLs' ArrayBuffers, | 396 # and dart:typeddata's ByteBuffer for IDLs' ArrayBuffers, |
| 397 # hence ArrayBuffer is mapped to dynamic in arguments and return | 397 # hence ArrayBuffer is mapped to dynamic in arguments and return |
| 398 # values. To compensate for that when generating ArrayBuffer itself, | 398 # values. To compensate for that when generating ArrayBuffer itself, |
| 399 # we need to lie a bit: | 399 # we need to lie a bit: |
| 400 if self.type_name == 'ArrayBuffer': return 'ArrayBuffer' | 400 if self.type_name == 'ArrayBuffer': return 'ByteBuffer' |
| 401 return rename_type(self.type_name) | 401 return rename_type(self.type_name) |
| 402 | 402 |
| 403 def ConstantOutputOrder(a, b): | 403 def ConstantOutputOrder(a, b): |
| 404 """Canonical output ordering for constants.""" | 404 """Canonical output ordering for constants.""" |
| 405 return cmp(a.id, b.id) | 405 return cmp(a.id, b.id) |
| 406 | 406 |
| 407 | 407 |
| 408 def _FormatNameList(names): | 408 def _FormatNameList(names): |
| 409 """Returns JavaScript array literal expression with one name per line.""" | 409 """Returns JavaScript array literal expression with one name per line.""" |
| 410 #names = sorted(names) | 410 #names = sorted(names) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 # used to assemble the annotations: | 547 # used to assemble the annotations: |
| 548 # | 548 # |
| 549 # INTERFACE.MEMBER: annotations for member. | 549 # INTERFACE.MEMBER: annotations for member. |
| 550 # +TYPE: add annotations only if there are member annotations. | 550 # +TYPE: add annotations only if there are member annotations. |
| 551 # -TYPE: add annotations only if there are no member annotations. | 551 # -TYPE: add annotations only if there are no member annotations. |
| 552 # TYPE: add regardless of member annotations. | 552 # TYPE: add regardless of member annotations. |
| 553 | 553 |
| 554 dart2js_annotations = monitored.Dict('generator.dart2js_annotations', { | 554 dart2js_annotations = monitored.Dict('generator.dart2js_annotations', { |
| 555 | 555 |
| 556 'ArrayBuffer': [ | 556 'ArrayBuffer': [ |
| 557 "@Creates('ArrayBuffer')", | 557 "@Creates('ByteBuffer')", |
| 558 "@Returns('ArrayBuffer|Null')", | 558 "@Returns('ByteBuffer|Null')", |
| 559 ], | 559 ], |
| 560 | 560 |
| 561 'ArrayBufferView': [ | 561 'ArrayBufferView': [ |
| 562 "@Creates('ArrayBufferView')", | 562 "@Creates('TypedData')", |
| 563 "@Returns('ArrayBufferView|Null')", | 563 "@Returns('TypedData|Null')", |
| 564 ], | 564 ], |
| 565 | 565 |
| 566 'CanvasRenderingContext2D.createImageData': [ | 566 'CanvasRenderingContext2D.createImageData': [ |
| 567 "@Creates('ImageData|=Object')", | 567 "@Creates('ImageData|=Object')", |
| 568 ], | 568 ], |
| 569 | 569 |
| 570 'CanvasRenderingContext2D.getImageData': [ | 570 'CanvasRenderingContext2D.getImageData': [ |
| 571 "@Creates('ImageData|=Object')", | 571 "@Creates('ImageData|=Object')", |
| 572 ], | 572 ], |
| 573 | 573 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 "@Creates('Node')", | 614 "@Creates('Node')", |
| 615 "@Returns('EventTarget|=Object')", | 615 "@Returns('EventTarget|=Object')", |
| 616 ], | 616 ], |
| 617 | 617 |
| 618 # Touch targets are Elements in a Document, or the Document. | 618 # Touch targets are Elements in a Document, or the Document. |
| 619 'Touch.target': [ | 619 'Touch.target': [ |
| 620 "@Creates('Element|Document')", | 620 "@Creates('Element|Document')", |
| 621 "@Returns('Element|Document')", | 621 "@Returns('Element|Document')", |
| 622 ], | 622 ], |
| 623 | 623 |
| 624 'FileReader.result': ["@Creates('String|ArrayBuffer|Null')"], | 624 'FileReader.result': ["@Creates('String|ByteBuffer|Null')"], |
| 625 | 625 |
| 626 # Rather than have the result of an IDBRequest as a union over all possible | 626 # Rather than have the result of an IDBRequest as a union over all possible |
| 627 # results, we mark the result as instantiating any classes, and mark | 627 # results, we mark the result as instantiating any classes, and mark |
| 628 # each operation with the classes that it could cause to be asynchronously | 628 # each operation with the classes that it could cause to be asynchronously |
| 629 # instantiated. | 629 # instantiated. |
| 630 'IDBRequest.result': ["@Creates('Null')"], | 630 'IDBRequest.result': ["@Creates('Null')"], |
| 631 | 631 |
| 632 # The source is usually a participant in the operation that generated the | 632 # The source is usually a participant in the operation that generated the |
| 633 # IDBRequest. | 633 # IDBRequest. |
| 634 'IDBRequest.source': ["@Creates('Null')"], | 634 'IDBRequest.source': ["@Creates('Null')"], |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 'SerializedScriptValue': [ | 683 'SerializedScriptValue': [ |
| 684 "@annotation_Creates_SerializedScriptValue", | 684 "@annotation_Creates_SerializedScriptValue", |
| 685 "@annotation_Returns_SerializedScriptValue", | 685 "@annotation_Returns_SerializedScriptValue", |
| 686 ], | 686 ], |
| 687 | 687 |
| 688 'SQLResultSetRowList.item': ["@Creates('=Object')"], | 688 'SQLResultSetRowList.item': ["@Creates('=Object')"], |
| 689 | 689 |
| 690 'WebGLRenderingContext.getParameter': [ | 690 'WebGLRenderingContext.getParameter': [ |
| 691 # Taken from http://www.khronos.org/registry/webgl/specs/latest/ | 691 # Taken from http://www.khronos.org/registry/webgl/specs/latest/ |
| 692 # Section 5.14.3 Setting and getting state | 692 # Section 5.14.3 Setting and getting state |
| 693 "@Creates('Null|num|String|bool|=List|Float32Array|Int32Array|Uint32Array" | 693 "@Creates('Null|num|String|bool|=List|Float32List|Int32List|Uint32List" |
| 694 "|WebGLFramebuffer|WebGLRenderbuffer|WebGLTexture')", | 694 "|WebGLFramebuffer|WebGLRenderbuffer|WebGLTexture')", |
| 695 "@Returns('Null|num|String|bool|=List|Float32Array|Int32Array|Uint32Array" | 695 "@Returns('Null|num|String|bool|=List|Float32List|Int32List|Uint32List" |
| 696 "|WebGLFramebuffer|WebGLRenderbuffer|WebGLTexture')", | 696 "|WebGLFramebuffer|WebGLRenderbuffer|WebGLTexture')", |
| 697 ], | 697 ], |
| 698 | 698 |
| 699 'XMLHttpRequest.response': [ | 699 'XMLHttpRequest.response': [ |
| 700 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", | 700 "@Creates('ByteBuffer|Blob|Document|=Object|=List|String|num')", |
| 701 ], | 701 ], |
| 702 }) | 702 }) |
| 703 | 703 |
| 704 _indexed_db_annotations = [ | 704 _indexed_db_annotations = [ |
| 705 "@SupportedBrowser(SupportedBrowser.CHROME)", | 705 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 706 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", | 706 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", |
| 707 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 707 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 708 "@Experimental", | 708 "@Experimental", |
| 709 ] | 709 ] |
| 710 | 710 |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 self) | 1565 self) |
| 1566 | 1566 |
| 1567 if type_data.clazz == 'SVGTearOff': | 1567 if type_data.clazz == 'SVGTearOff': |
| 1568 dart_interface_name = self._renamer.RenameInterface( | 1568 dart_interface_name = self._renamer.RenameInterface( |
| 1569 self._database.GetInterface(type_name)) | 1569 self._database.GetInterface(type_name)) |
| 1570 return SVGTearOffIDLTypeInfo( | 1570 return SVGTearOffIDLTypeInfo( |
| 1571 type_name, type_data, dart_interface_name, self) | 1571 type_name, type_data, dart_interface_name, self) |
| 1572 | 1572 |
| 1573 class_name = '%sIDLTypeInfo' % type_data.clazz | 1573 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1574 return globals()[class_name](type_name, type_data) | 1574 return globals()[class_name](type_name, type_data) |
| OLD | NEW |