| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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)", |
| 101 | 101 |
| 102 # DOMWindow aliased with global scope. | 102 # DOMWindow aliased with global scope. |
| 103 'Window': '@*DOMWindow', | 103 'Window': '@*DOMWindow', |
| 104 }) | 104 }, dart2jsOnly=True) |
| 105 | 105 |
| 106 def IsRegisteredType(type_name): | 106 def IsRegisteredType(type_name): |
| 107 return type_name in _idl_type_registry | 107 return type_name in _idl_type_registry |
| 108 | 108 |
| 109 def MakeNativeSpec(javascript_binding_name): | 109 def MakeNativeSpec(javascript_binding_name): |
| 110 if javascript_binding_name in _dart2js_dom_custom_native_specs: | 110 if javascript_binding_name in _dart2js_dom_custom_native_specs: |
| 111 return _dart2js_dom_custom_native_specs[javascript_binding_name] | 111 return _dart2js_dom_custom_native_specs[javascript_binding_name] |
| 112 else: | 112 else: |
| 113 # Make the class 'hidden' so it is dynamically patched at runtime. This | 113 # Make the class 'hidden' so it is dynamically patched at runtime. This |
| 114 # is useful for browser compat. | 114 # is useful for browser compat. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 # something that does not need conversion. | 521 # something that does not need conversion. |
| 522 'IDBAny get IDBRequest.result': | 522 'IDBAny get IDBRequest.result': |
| 523 Conversion('_convertNativeToDart_IDBAny', 'dynamic', 'dynamic'), | 523 Conversion('_convertNativeToDart_IDBAny', 'dynamic', 'dynamic'), |
| 524 | 524 |
| 525 # "source: On getting, returns the IDBObjectStore or IDBIndex that the | 525 # "source: On getting, returns the IDBObjectStore or IDBIndex that the |
| 526 # cursor is iterating. ...". So we should not try to convert it. | 526 # cursor is iterating. ...". So we should not try to convert it. |
| 527 'IDBAny get IDBCursor.source': None, | 527 'IDBAny get IDBCursor.source': None, |
| 528 | 528 |
| 529 # Should be either a DOMString, an Array of DOMStrings or null. | 529 # Should be either a DOMString, an Array of DOMStrings or null. |
| 530 'IDBAny get IDBObjectStore.keyPath': None, | 530 'IDBAny get IDBObjectStore.keyPath': None, |
| 531 }) | 531 }, dart2jsOnly=True) |
| 532 | 532 |
| 533 def FindConversion(idl_type, direction, interface, member): | 533 def FindConversion(idl_type, direction, interface, member): |
| 534 table = dart2js_conversions | 534 table = dart2js_conversions |
| 535 return (table.get('%s %s %s.%s' % (idl_type, direction, interface, member)) or | 535 return (table.get('%s %s %s.%s' % (idl_type, direction, interface, member)) or |
| 536 table.get('* %s %s.%s' % (direction, interface, member)) or | 536 table.get('* %s %s.%s' % (direction, interface, member)) or |
| 537 table.get('%s %s %s.*' % (idl_type, direction, interface)) or | 537 table.get('%s %s %s.*' % (idl_type, direction, interface)) or |
| 538 table.get('%s %s' % (idl_type, direction))) | 538 table.get('%s %s' % (idl_type, direction))) |
| 539 return None | 539 return None |
| 540 | 540 |
| 541 # ------------------------------------------------------------------------------ | 541 # ------------------------------------------------------------------------------ |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 # Section 5.14.3 Setting and getting state | 689 # Section 5.14.3 Setting and getting state |
| 690 "@Creates('Null|num|String|bool|=List|Float32Array|Int32Array|Uint32Array" | 690 "@Creates('Null|num|String|bool|=List|Float32Array|Int32Array|Uint32Array" |
| 691 "|Framebuffer|Renderbuffer|Texture')", | 691 "|Framebuffer|Renderbuffer|Texture')", |
| 692 "@Returns('Null|num|String|bool|=List|Float32Array|Int32Array|Uint32Array" | 692 "@Returns('Null|num|String|bool|=List|Float32Array|Int32Array|Uint32Array" |
| 693 "|Framebuffer|Renderbuffer|Texture')", | 693 "|Framebuffer|Renderbuffer|Texture')", |
| 694 ], | 694 ], |
| 695 | 695 |
| 696 'XMLHttpRequest.response': [ | 696 'XMLHttpRequest.response': [ |
| 697 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", | 697 "@Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')", |
| 698 ], | 698 ], |
| 699 }) | 699 }, dart2jsOnly=True) |
| 700 | 700 |
| 701 _indexed_db_annotations = [ | 701 _indexed_db_annotations = [ |
| 702 "@SupportedBrowser(SupportedBrowser.CHROME)", | 702 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| 703 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", | 703 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", |
| 704 "@SupportedBrowser(SupportedBrowser.IE, '10')", | 704 "@SupportedBrowser(SupportedBrowser.IE, '10')", |
| 705 "@Experimental", | 705 "@Experimental", |
| 706 ] | 706 ] |
| 707 | 707 |
| 708 _file_system_annotations = [ | 708 _file_system_annotations = [ |
| 709 "@SupportedBrowser(SupportedBrowser.CHROME)", | 709 "@SupportedBrowser(SupportedBrowser.CHROME)", |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 self) | 1560 self) |
| 1561 | 1561 |
| 1562 if type_data.clazz == 'SVGTearOff': | 1562 if type_data.clazz == 'SVGTearOff': |
| 1563 dart_interface_name = self._renamer.RenameInterface( | 1563 dart_interface_name = self._renamer.RenameInterface( |
| 1564 self._database.GetInterface(type_name)) | 1564 self._database.GetInterface(type_name)) |
| 1565 return SVGTearOffIDLTypeInfo( | 1565 return SVGTearOffIDLTypeInfo( |
| 1566 type_name, type_data, dart_interface_name, self) | 1566 type_name, type_data, dart_interface_name, self) |
| 1567 | 1567 |
| 1568 class_name = '%sIDLTypeInfo' % type_data.clazz | 1568 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1569 return globals()[class_name](type_name, type_data) | 1569 return globals()[class_name](type_name, type_data) |
| OLD | NEW |