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 typed_array_renames = { | 9 typed_array_renames = { |
10 'ArrayBuffer': 'ByteBuffer', | 10 'ArrayBuffer': 'ByteBuffer', |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 'DataTransferItemList.add(File file)': 'addFile', | 368 'DataTransferItemList.add(File file)': 'addFile', |
369 'DataTransferItemList.add(DOMString data, DOMString type)': 'addData', | 369 'DataTransferItemList.add(DOMString data, DOMString type)': 'addData', |
370 'FormData.append(DOMString name, Blob value, DOMString filename)': | 370 'FormData.append(DOMString name, Blob value, DOMString filename)': |
371 'appendBlob', | 371 'appendBlob', |
372 'IDBDatabase.transaction(DOMStringList storeNames, DOMString mode)': | 372 'IDBDatabase.transaction(DOMStringList storeNames, DOMString mode)': |
373 'transactionStores', | 373 'transactionStores', |
374 'IDBDatabase.transaction(sequence<DOMString> storeNames, DOMString mode)': | 374 'IDBDatabase.transaction(sequence<DOMString> storeNames, DOMString mode)': |
375 'transactionList', | 375 'transactionList', |
376 'IDBDatabase.transaction(DOMString storeName, DOMString mode)': | 376 'IDBDatabase.transaction(DOMString storeName, DOMString mode)': |
377 'transactionStore', | 377 'transactionStore', |
378 'ImageBitmapFactories.createImageBitmap(HTMLImageElement image)' : 'createImag
eBitmap0', | |
379 'ImageBitmapFactories.createImageBitmap(HTMLImageElement image, long sx, long
sy, long sw, long sh)' : 'createImageBitmap1', | |
380 'ImageBitmapFactories.createImageBitmap(HTMLVideoElement video)' : 'createImag
eBitmap2', | |
381 'ImageBitmapFactories.createImageBitmap(HTMLVideoElement video, long sx, long
sy, long sw, long sh)' : 'createImageBitmap3', | |
382 'ImageBitmapFactories.createImageBitmap(CanvasRenderingContext2D context)' : '
createImageBitmap4', | |
383 'ImageBitmapFactories.createImageBitmap(CanvasRenderingContext2D context, long
sx, long sy, long sw, long sh)' : 'createImageBitmap5', | |
384 'ImageBitmapFactories.createImageBitmap(HTMLCanvasElement canvas)' : 'createIm
ageBitmap6', | |
385 'ImageBitmapFactories.createImageBitmap(HTMLCanvasElement canvas, long sx, lon
g sy, long sw, long sh)' : 'createImageBitmap7', | |
386 'ImageBitmapFactories.createImageBitmap(ImageData data)' : 'createImageBitmap8
', | |
387 'ImageBitmapFactories.createImageBitmap(ImageData data, long sx, long sy, long
sw, long sh)' : 'createImageBitmap9', | |
388 'ImageBitmapFactories.createImageBitmap(ImageBitmap bitmap)' : 'createImageBit
map10', | |
389 'ImageBitmapFactories.createImageBitmap(ImageBitmap bitmap, long sx, long sy,
long sw, long sh)' : 'createImageBitmap11', | |
390 'RTCDataChannel.send(ArrayBuffer data)': 'sendByteBuffer', | 378 'RTCDataChannel.send(ArrayBuffer data)': 'sendByteBuffer', |
391 'RTCDataChannel.send(ArrayBufferView data)': 'sendTypedData', | 379 'RTCDataChannel.send(ArrayBufferView data)': 'sendTypedData', |
392 'RTCDataChannel.send(Blob data)': 'sendBlob', | 380 'RTCDataChannel.send(Blob data)': 'sendBlob', |
393 'RTCDataChannel.send(DOMString data)': 'sendString', | 381 'RTCDataChannel.send(DOMString data)': 'sendString', |
394 'SourceBuffer.appendBuffer(ArrayBufferView data)': 'appendBufferView', | 382 'SourceBuffer.appendBuffer(ArrayBufferView data)': 'appendBufferView', |
395 'URL.createObjectURL(MediaSource source)': | 383 'URL.createObjectURL(MediaSource source)': |
396 'createObjectUrlFromSource', | 384 'createObjectUrlFromSource', |
397 'URL.createObjectURL(WebKitMediaSource source)': | 385 'URL.createObjectURL(WebKitMediaSource source)': |
398 '_createObjectUrlFromWebKitSource', | 386 '_createObjectUrlFromWebKitSource', |
399 'URL.createObjectURL(MediaStream stream)': 'createObjectUrlFromStream', | 387 'URL.createObjectURL(MediaStream stream)': 'createObjectUrlFromStream', |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 | 731 |
744 class HtmlRenamer(object): | 732 class HtmlRenamer(object): |
745 def __init__(self, database): | 733 def __init__(self, database): |
746 self._database = database | 734 self._database = database |
747 | 735 |
748 def RenameInterface(self, interface): | 736 def RenameInterface(self, interface): |
749 if 'Callback' in interface.ext_attrs: | 737 if 'Callback' in interface.ext_attrs: |
750 if interface.id in _removed_html_interfaces: | 738 if interface.id in _removed_html_interfaces: |
751 return None | 739 return None |
752 | 740 |
753 candidate = self.RenameInterfaceId(interface.id) | 741 if interface.id in html_interface_renames: |
754 if candidate: | 742 return html_interface_renames[interface.id] |
755 return candidate | 743 elif interface.id.startswith('HTML'): |
756 | |
757 if interface.id.startswith('HTML'): | |
758 if any(interface.id in ['Element', 'Document'] | 744 if any(interface.id in ['Element', 'Document'] |
759 for interface in self._database.Hierarchy(interface)): | 745 for interface in self._database.Hierarchy(interface)): |
760 return interface.id[len('HTML'):] | 746 return interface.id[len('HTML'):] |
761 return self._DartifyName(interface.javascript_binding_name) | 747 return self._DartifyName(interface.javascript_binding_name) |
762 | 748 |
763 def RenameInterfaceId(self, interface_id): | |
764 if interface_id in html_interface_renames: | |
765 return html_interface_renames[interface_id] | |
766 return None; | |
767 | 749 |
768 | 750 |
769 def RenameMember(self, interface_name, member_node, member, member_prefix='', | 751 def RenameMember(self, interface_name, member_node, member, member_prefix='', |
770 dartify_name=True): | 752 dartify_name=True): |
771 """ | 753 """ |
772 Returns the name of the member in the HTML library or None if the member is | 754 Returns the name of the member in the HTML library or None if the member is |
773 suppressed in the HTML library | 755 suppressed in the HTML library |
774 """ | 756 """ |
775 interface = self._database.GetInterface(interface_name) | 757 interface = self._database.GetInterface(interface_name) |
776 | 758 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 866 |
885 # We're looking for a sequence of letters which start with capital letter | 867 # We're looking for a sequence of letters which start with capital letter |
886 # then a series of caps and finishes with either the end of the string or | 868 # then a series of caps and finishes with either the end of the string or |
887 # a capital letter. | 869 # a capital letter. |
888 # The [0-9] check is for names such as 2D or 3D | 870 # The [0-9] check is for names such as 2D or 3D |
889 # The following test cases should match as: | 871 # The following test cases should match as: |
890 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 872 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
891 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 873 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
892 # IFrameElement: (I)()(F)rameElement (no change) | 874 # IFrameElement: (I)()(F)rameElement (no change) |
893 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 875 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
OLD | NEW |