| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 'Node.textContent': 'text', | 327 'Node.textContent': 'text', |
| 312 'SVGComponentTransferFunctionElement.offset': 'gradientOffset', | 328 'SVGComponentTransferFunctionElement.offset': 'gradientOffset', |
| 313 'SVGElement.className': '$dom_svgClassName', | 329 'SVGElement.className': '$dom_svgClassName', |
| 314 'SVGStopElement.offset': 'gradientOffset', | 330 'SVGStopElement.offset': 'gradientOffset', |
| 315 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', | 331 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', |
| 316 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', | 332 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', |
| 317 'WorkerContext.webkitResolveLocalFileSystemSyncURL': | 333 'WorkerContext.webkitResolveLocalFileSystemSyncURL': |
| 318 'resolveLocalFileSystemSyncUrl', | 334 'resolveLocalFileSystemSyncUrl', |
| 319 'WorkerContext.webkitResolveLocalFileSystemURL': | 335 'WorkerContext.webkitResolveLocalFileSystemURL': |
| 320 'resolveLocalFileSystemUrl', | 336 'resolveLocalFileSystemUrl', |
| 337 |
| 338 # Typed array renames |
| 339 'ArrayBuffer.byteLength': 'lengthInBytes', |
| 340 'ArrayBufferView.byteLength': 'lengthInBytes', |
| 341 'ArrayBufferView.byteOffset': 'offsetInBytes', |
| 321 }) | 342 }) |
| 322 | 343 |
| 323 for member in convert_to_future_members: | 344 for member in convert_to_future_members: |
| 324 if member in renamed_html_members: | 345 if member in renamed_html_members: |
| 325 renamed_html_members[member] = '_' + renamed_html_members[member] | 346 renamed_html_members[member] = '_' + renamed_html_members[member] |
| 326 else: | 347 else: |
| 327 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] | 348 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] |
| 328 | 349 |
| 329 # Members and classes from the dom that should be removed completely from | 350 # Members and classes from the dom that should be removed completely from |
| 330 # dart:html. These could be expressed in the IDL instead but expressing this | 351 # dart:html. These could be expressed in the IDL instead but expressing this |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: | 690 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: |
| 670 return 'web_audio' | 691 return 'web_audio' |
| 671 if 'SVG' in interface.ext_attrs['Conditional']: | 692 if 'SVG' in interface.ext_attrs['Conditional']: |
| 672 return 'svg' | 693 return 'svg' |
| 673 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: | 694 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: |
| 674 return 'indexed_db' | 695 return 'indexed_db' |
| 675 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: | 696 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: |
| 676 # WorkerContext has attributes merged in from many other interfaces. | 697 # WorkerContext has attributes merged in from many other interfaces. |
| 677 if interface.id != 'WorkerContext': | 698 if interface.id != 'WorkerContext': |
| 678 return 'web_sql' | 699 return 'web_sql' |
| 700 if interface.id in typed_array_renames: |
| 701 return 'typeddata' |
| 679 | 702 |
| 680 return 'html' | 703 return 'html' |
| 681 | 704 |
| 682 def DartifyTypeName(self, type_name): | 705 def DartifyTypeName(self, type_name): |
| 683 """Converts a DOM name to a Dart-friendly class name. """ | 706 """Converts a DOM name to a Dart-friendly class name. """ |
| 684 | 707 |
| 685 if type_name in html_interface_renames: | 708 if type_name in html_interface_renames: |
| 686 return html_interface_renames[type_name] | 709 return html_interface_renames[type_name] |
| 687 | 710 |
| 688 # Strip off any standard prefixes. | 711 # Strip off any standard prefixes. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 703 | 726 |
| 704 # We're looking for a sequence of letters which start with capital letter | 727 # We're looking for a sequence of letters which start with capital letter |
| 705 # then a series of caps and finishes with either the end of the string or | 728 # then a series of caps and finishes with either the end of the string or |
| 706 # a capital letter. | 729 # a capital letter. |
| 707 # The [0-9] check is for names such as 2D or 3D | 730 # The [0-9] check is for names such as 2D or 3D |
| 708 # The following test cases should match as: | 731 # The following test cases should match as: |
| 709 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 732 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
| 710 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 733 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
| 711 # IFrameElement: (I)()(F)rameElement (no change) | 734 # IFrameElement: (I)()(F)rameElement (no change) |
| 712 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 735 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
| OLD | NEW |