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 'DOMFormData': 'FormData', | 33 'DOMFormData': 'FormData', |
18 'DOMPoint': '_DomPoint', | 34 'DOMPoint': '_DomPoint', |
19 'DOMURL': 'Url', | 35 'DOMURL': 'Url', |
(...skipping 23 matching lines...) Expand all Loading... |
43 'SVGGradientElement': '_GradientElement', | 59 'SVGGradientElement': '_GradientElement', |
44 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. | 60 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. |
45 'WebGLVertexArrayObjectOES': 'VertexArrayObject', | 61 'WebGLVertexArrayObjectOES': 'VertexArrayObject', |
46 'WebKitCSSKeyframeRule': 'CssKeyframeRule', | 62 'WebKitCSSKeyframeRule': 'CssKeyframeRule', |
47 'WebKitCSSKeyframesRule': 'CssKeyframesRule', | 63 'WebKitCSSKeyframesRule': 'CssKeyframesRule', |
48 'WebKitCSSTransformValue': 'CssTransformValue', | 64 'WebKitCSSTransformValue': 'CssTransformValue', |
49 'XMLHttpRequest': 'HttpRequest', | 65 'XMLHttpRequest': 'HttpRequest', |
50 'XMLHttpRequestException': 'HttpRequestException', | 66 'XMLHttpRequestException': 'HttpRequestException', |
51 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', | 67 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', |
52 'XMLHttpRequestUpload': 'HttpRequestUpload', | 68 'XMLHttpRequestUpload': 'HttpRequestUpload', |
53 }) | 69 }, **typed_array_renames)) |
54 | 70 |
55 # Interfaces that are suppressed, but need to still exist for Dartium and to | 71 # Interfaces that are suppressed, but need to still exist for Dartium and to |
56 # properly wrap DOM objects if/when encountered. | 72 # properly wrap DOM objects if/when encountered. |
57 _removed_html_interfaces = [ | 73 _removed_html_interfaces = [ |
58 'CSSPrimitiveValue', | 74 'CSSPrimitiveValue', |
59 'CSSValue', | 75 'CSSValue', |
60 'Counter', | 76 'Counter', |
61 'DOMFileSystemSync', # Workers | 77 'DOMFileSystemSync', # Workers |
62 'DatabaseSync', # Workers | 78 'DatabaseSync', # Workers |
| 79 'DataView', # Typed arrays |
63 'DedicatedWorkerContext', # Workers | 80 'DedicatedWorkerContext', # Workers |
64 'DirectoryEntrySync', # Workers | 81 'DirectoryEntrySync', # Workers |
65 'DirectoryReaderSync', # Workers | 82 'DirectoryReaderSync', # Workers |
66 'EntrySync', # Workers | 83 'EntrySync', # Workers |
67 'FileEntrySync', # Workers | 84 'FileEntrySync', # Workers |
68 'FileReaderSync', # Workers | 85 'FileReaderSync', # Workers |
69 'FileWriterSync', # Workers | 86 'FileWriterSync', # Workers |
70 'HTMLAppletElement', | 87 'HTMLAppletElement', |
71 'HTMLBaseFontElement', | 88 'HTMLBaseFontElement', |
72 'HTMLDirectoryElement', | 89 'HTMLDirectoryElement', |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 'Node.nextSibling': 'nextNode', | 336 'Node.nextSibling': 'nextNode', |
320 'Node.ownerDocument': 'document', | 337 'Node.ownerDocument': 'document', |
321 'Node.parentElement': 'parent', | 338 'Node.parentElement': 'parent', |
322 'Node.previousSibling': 'previousNode', | 339 'Node.previousSibling': 'previousNode', |
323 'Node.textContent': 'text', | 340 'Node.textContent': 'text', |
324 'RTCPeerConnection.createAnswer': '_createAnswer', | 341 'RTCPeerConnection.createAnswer': '_createAnswer', |
325 'RTCPeerConnection.createOffer': '_createOffer', | 342 'RTCPeerConnection.createOffer': '_createOffer', |
326 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota', | 343 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota', |
327 'SVGElement.className': '$dom_svgClassName', | 344 'SVGElement.className': '$dom_svgClassName', |
328 'SVGStopElement.offset': 'gradientOffset', | 345 'SVGStopElement.offset': 'gradientOffset', |
329 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', # Workers | 346 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', |
330 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', # Wo
rkers | 347 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', |
331 }) | 348 }) |
332 | 349 |
333 for member in convert_to_future_members: | 350 for member in convert_to_future_members: |
334 if member in renamed_html_members: | 351 if member in renamed_html_members: |
335 renamed_html_members[member] = '_' + renamed_html_members[member] | 352 renamed_html_members[member] = '_' + renamed_html_members[member] |
336 else: | 353 else: |
337 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] | 354 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] |
338 | 355 |
339 # Members and classes from the dom that should be removed completely from | 356 # Members and classes from the dom that should be removed completely from |
340 # dart:html. These could be expressed in the IDL instead but expressing this | 357 # dart:html. These could be expressed in the IDL instead but expressing this |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 return 'web_audio' | 730 return 'web_audio' |
714 if 'SVG' in interface.ext_attrs['Conditional']: | 731 if 'SVG' in interface.ext_attrs['Conditional']: |
715 return 'svg' | 732 return 'svg' |
716 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: | 733 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: |
717 return 'indexed_db' | 734 return 'indexed_db' |
718 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: | 735 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: |
719 return 'web_sql' | 736 return 'web_sql' |
720 if 'WEBGL' in interface.ext_attrs['Conditional']: | 737 if 'WEBGL' in interface.ext_attrs['Conditional']: |
721 return 'web_gl' | 738 return 'web_gl' |
722 | 739 |
| 740 if interface.id in typed_array_renames: |
| 741 return 'typeddata' |
| 742 |
723 return 'html' | 743 return 'html' |
724 | 744 |
725 def DartifyTypeName(self, type_name): | 745 def DartifyTypeName(self, type_name): |
726 """Converts a DOM name to a Dart-friendly class name. """ | 746 """Converts a DOM name to a Dart-friendly class name. """ |
727 | 747 |
728 if type_name in html_interface_renames: | 748 if type_name in html_interface_renames: |
729 return html_interface_renames[type_name] | 749 return html_interface_renames[type_name] |
730 | 750 |
731 # Strip off any standard prefixes. | 751 # Strip off any standard prefixes. |
732 name = re.sub(r'^SVG', '', type_name) | 752 name = re.sub(r'^SVG', '', type_name) |
(...skipping 14 matching lines...) Expand all Loading... |
747 | 767 |
748 # We're looking for a sequence of letters which start with capital letter | 768 # We're looking for a sequence of letters which start with capital letter |
749 # then a series of caps and finishes with either the end of the string or | 769 # then a series of caps and finishes with either the end of the string or |
750 # a capital letter. | 770 # a capital letter. |
751 # The [0-9] check is for names such as 2D or 3D | 771 # The [0-9] check is for names such as 2D or 3D |
752 # The following test cases should match as: | 772 # The following test cases should match as: |
753 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 773 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
754 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 774 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
755 # IFrameElement: (I)()(F)rameElement (no change) | 775 # IFrameElement: (I)()(F)rameElement (no change) |
756 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 776 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
OLD | NEW |