| 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 import logging | 5 import logging |
| 6 import monitored | 6 import monitored |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', { | 9 typed_array_renames = { |
| 10 'ArrayBuffer': 'ByteBuffer', |
| 11 'ArrayBufferView': 'TypedData', |
| 12 'DataView': 'ByteData', |
| 13 'Float32Array': 'Float32List', |
| 14 'Float64Array': 'Float64List', |
| 15 'Int8Array': 'Int8List', |
| 16 'Int16Array': 'Int16List', |
| 17 'Int32Array': 'Int32List', |
| 18 'Uint8Array': 'Uint8List', |
| 19 'Uint8ClampedArray': 'Uint8ClampedList', |
| 20 'Uint16Array': 'Uint16List', |
| 21 'Uint32Array': 'Uint32List', |
| 22 } |
| 23 |
| 24 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', |
| 25 dict({ |
| 10 'CDATASection': 'CDataSection', | 26 'CDATASection': 'CDataSection', |
| 11 'Clipboard': 'DataTransfer', | 27 'Clipboard': 'DataTransfer', |
| 12 'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database. | 28 'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database. |
| 13 'DatabaseSync': 'SqlDatabaseSync', | 29 'DatabaseSync': 'SqlDatabaseSync', |
| 14 'DOMApplicationCache': 'ApplicationCache', | 30 'DOMApplicationCache': 'ApplicationCache', |
| 15 'DOMCoreException': 'DomException', | 31 'DOMCoreException': 'DomException', |
| 16 'DOMFileSystem': 'FileSystem', | 32 'DOMFileSystem': 'FileSystem', |
| 17 'DOMFileSystemSync': 'FileSystemSync', | 33 'DOMFileSystemSync': 'FileSystemSync', |
| 18 'DOMFormData': 'FormData', | 34 'DOMFormData': 'FormData', |
| 19 'DOMURL': 'Url', | 35 'DOMURL': 'Url', |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 'WebKitCSSKeyframeRule': 'CssKeyframeRule', | 64 'WebKitCSSKeyframeRule': 'CssKeyframeRule', |
| 49 'WebKitCSSKeyframesRule': 'CssKeyframesRule', | 65 'WebKitCSSKeyframesRule': 'CssKeyframesRule', |
| 50 'WebKitCSSMatrix': 'CssMatrix', | 66 'WebKitCSSMatrix': 'CssMatrix', |
| 51 'WebKitCSSTransformValue': 'CssTransformValue', | 67 'WebKitCSSTransformValue': 'CssTransformValue', |
| 52 'WebKitPoint': 'DomPoint', | 68 'WebKitPoint': 'DomPoint', |
| 53 'WebKitTransitionEvent': '_WebKitTransitionEvent', | 69 'WebKitTransitionEvent': '_WebKitTransitionEvent', |
| 54 'XMLHttpRequest': 'HttpRequest', | 70 'XMLHttpRequest': 'HttpRequest', |
| 55 'XMLHttpRequestException': 'HttpRequestException', | 71 'XMLHttpRequestException': 'HttpRequestException', |
| 56 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', | 72 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', |
| 57 'XMLHttpRequestUpload': 'HttpRequestUpload', | 73 'XMLHttpRequestUpload': 'HttpRequestUpload', |
| 58 }) | 74 }, **typed_array_renames)) |
| 59 | 75 |
| 60 # Interfaces that are suppressed, but need to still exist for Dartium and to | 76 # Interfaces that are suppressed, but need to still exist for Dartium and to |
| 61 # properly wrap DOM objects if/when encountered. | 77 # properly wrap DOM objects if/when encountered. |
| 62 _removed_html_interfaces = [ | 78 _removed_html_interfaces = [ |
| 63 'HTMLAppletElement', | 79 'HTMLAppletElement', |
| 64 'HTMLBaseFontElement', | 80 'HTMLBaseFontElement', |
| 65 'HTMLDirectoryElement', | 81 'HTMLDirectoryElement', |
| 66 'HTMLFontElement', | 82 'HTMLFontElement', |
| 67 'HTMLFrameElement', | 83 'HTMLFrameElement', |
| 68 'HTMLFrameSetElement', | 84 'HTMLFrameSetElement', |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota', | 330 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota', |
| 315 'SVGComponentTransferFunctionElement.offset': 'gradientOffset', | 331 'SVGComponentTransferFunctionElement.offset': 'gradientOffset', |
| 316 'SVGElement.className': '$dom_svgClassName', | 332 'SVGElement.className': '$dom_svgClassName', |
| 317 'SVGStopElement.offset': 'gradientOffset', | 333 'SVGStopElement.offset': 'gradientOffset', |
| 318 'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', | 334 'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', |
| 319 'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', | 335 'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', |
| 320 'WorkerContext.webkitResolveLocalFileSystemSyncURL': | 336 'WorkerContext.webkitResolveLocalFileSystemSyncURL': |
| 321 'resolveLocalFileSystemSyncUrl', | 337 'resolveLocalFileSystemSyncUrl', |
| 322 'WorkerContext.webkitResolveLocalFileSystemURL': | 338 'WorkerContext.webkitResolveLocalFileSystemURL': |
| 323 'resolveLocalFileSystemUrl', | 339 'resolveLocalFileSystemUrl', |
| 340 |
| 341 # Typed array renames |
| 342 'ArrayBuffer.byteLength': 'lengthInBytes', |
| 343 'ArrayBufferView.byteLength': 'lengthInBytes', |
| 344 'ArrayBufferView.byteOffset': 'offsetInBytes', |
| 324 }) | 345 }) |
| 325 | 346 |
| 326 for member in convert_to_future_members: | 347 for member in convert_to_future_members: |
| 327 if member in renamed_html_members: | 348 if member in renamed_html_members: |
| 328 renamed_html_members[member] = '_' + renamed_html_members[member] | 349 renamed_html_members[member] = '_' + renamed_html_members[member] |
| 329 else: | 350 else: |
| 330 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] | 351 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] |
| 331 | 352 |
| 332 # Members and classes from the dom that should be removed completely from | 353 # Members and classes from the dom that should be removed completely from |
| 333 # dart:html. These could be expressed in the IDL instead but expressing this | 354 # dart:html. These could be expressed in the IDL instead but expressing this |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 if 'Conditional' in interface.ext_attrs: | 704 if 'Conditional' in interface.ext_attrs: |
| 684 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: | 705 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: |
| 685 return 'web_audio' | 706 return 'web_audio' |
| 686 if 'SVG' in interface.ext_attrs['Conditional']: | 707 if 'SVG' in interface.ext_attrs['Conditional']: |
| 687 return 'svg' | 708 return 'svg' |
| 688 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: | 709 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: |
| 689 return 'indexed_db' | 710 return 'indexed_db' |
| 690 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: | 711 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: |
| 691 return 'web_sql' | 712 return 'web_sql' |
| 692 | 713 |
| 714 if interface.id in typed_array_renames: |
| 715 return 'typeddata' |
| 716 |
| 693 return 'html' | 717 return 'html' |
| 694 | 718 |
| 695 def DartifyTypeName(self, type_name): | 719 def DartifyTypeName(self, type_name): |
| 696 """Converts a DOM name to a Dart-friendly class name. """ | 720 """Converts a DOM name to a Dart-friendly class name. """ |
| 697 | 721 |
| 698 if type_name in html_interface_renames: | 722 if type_name in html_interface_renames: |
| 699 return html_interface_renames[type_name] | 723 return html_interface_renames[type_name] |
| 700 | 724 |
| 701 # Strip off any standard prefixes. | 725 # Strip off any standard prefixes. |
| 702 name = re.sub(r'^SVG', '', type_name) | 726 name = re.sub(r'^SVG', '', type_name) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 716 | 740 |
| 717 # We're looking for a sequence of letters which start with capital letter | 741 # We're looking for a sequence of letters which start with capital letter |
| 718 # then a series of caps and finishes with either the end of the string or | 742 # then a series of caps and finishes with either the end of the string or |
| 719 # a capital letter. | 743 # a capital letter. |
| 720 # The [0-9] check is for names such as 2D or 3D | 744 # The [0-9] check is for names such as 2D or 3D |
| 721 # The following test cases should match as: | 745 # The following test cases should match as: |
| 722 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 746 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
| 723 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 747 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
| 724 # IFrameElement: (I)()(F)rameElement (no change) | 748 # IFrameElement: (I)()(F)rameElement (no change) |
| 725 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 749 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
| OLD | NEW |