Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tools/dom/scripts/htmlrenamer.py

Issue 16494002: Expand overloaded methods and optional parameters in the html library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/htmldartgenerator.py ('k') | tools/dom/scripts/logging.conf » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 'RTCPeerConnection.setLocalDescription', 144 'RTCPeerConnection.setLocalDescription',
145 'RTCPeerConnection.setRemoteDescription', 145 'RTCPeerConnection.setRemoteDescription',
146 'StorageInfo.requestQuota', 146 'StorageInfo.requestQuota',
147 'WorkerContext.webkitResolveLocalFileSystemURL', 147 'WorkerContext.webkitResolveLocalFileSystemURL',
148 'WorkerContext.webkitRequestFileSystem', 148 'WorkerContext.webkitRequestFileSystem',
149 ]) 149 ])
150 150
151 # Members from the standard dom that should not be exposed publicly in dart:html 151 # Members from the standard dom that should not be exposed publicly in dart:html
152 # but need to be exposed internally to implement dart:html on top of a standard 152 # but need to be exposed internally to implement dart:html on top of a standard
153 # browser. 153 # browser.
154 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [ 154 private_html_members = monitored.Set('htmlrenamer.private_html_members', [
155 'AudioNode.connect',
155 'CanvasRenderingContext2D.arc', 156 'CanvasRenderingContext2D.arc',
156 'CompositionEvent.initCompositionEvent', 157 'CompositionEvent.initCompositionEvent',
157 'CustomEvent.initCustomEvent', 158 'CustomEvent.initCustomEvent',
158 'DeviceOrientationEvent.initDeviceOrientationEvent', 159 'DeviceOrientationEvent.initDeviceOrientationEvent',
159 'Document.createElement', 160 'Document.createElement',
160 'Document.createElementNS', 161 'Document.createElementNS',
161 'Document.createEvent', 162 'Document.createEvent',
162 'Document.createNodeIterator', 163 'Document.createNodeIterator',
163 'Document.createRange', 164 'Document.createRange',
164 'Document.createTextNode', 165 'Document.createTextNode',
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 'SVGElement.className': '$dom_svgClassName', 340 'SVGElement.className': '$dom_svgClassName',
340 'SVGStopElement.offset': 'gradientOffset', 341 'SVGStopElement.offset': 'gradientOffset',
341 'URL.createObjectURL': 'createObjectUrl', 342 'URL.createObjectURL': 'createObjectUrl',
342 'URL.revokeObjectURL': 'revokeObjectUrl', 343 'URL.revokeObjectURL': 'revokeObjectUrl',
343 'WheelEvent.wheelDeltaX': '_wheelDeltaX', 344 'WheelEvent.wheelDeltaX': '_wheelDeltaX',
344 'WheelEvent.wheelDeltaY': '_wheelDeltaY', 345 'WheelEvent.wheelDeltaY': '_wheelDeltaY',
345 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', 346 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem',
346 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', 347 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync',
347 }) 348 })
348 349
350 # Members that have multiple definitions, but their types are vary, so we rename
351 # them to make them distinct.
352 renamed_overloads = monitored.Dict('htmldartgenreator.renamed_overloads', {
353 'AudioContext.createBuffer(ArrayBuffer buffer, boolean mixToMono)':
354 'createBufferFromBuffer',
355 'CSS.supports(DOMString conditionText)': 'supportsCondition',
356 'CanvasRenderingContext2D.createPattern(HTMLImageElement image, '
357 'DOMString repetitionType)': 'createPatternFromImage',
358 'DataTransferItemList.add(File file)': 'addFile',
359 'DataTransferItemList.add(DOMString data, DOMString type)': 'addData',
360 'IDBDatabase.transaction(DOMStringList storeNames, DOMString mode)':
361 'transactionStores',
362 'IDBDatabase.transaction(sequence<DOMString> storeNames, DOMString mode)':
363 'transactionList',
364 'IDBDatabase.transaction(DOMString storeName, DOMString mode)':
365 'transactionStore',
366 'RTCDataChannel.send(ArrayBuffer data)': 'sendByteBuffer',
367 'RTCDataChannel.send(ArrayBufferView data)': 'sendTypedData',
368 'RTCDataChannel.send(Blob data)': 'sendBlob',
369 'RTCDataChannel.send(DOMString data)': 'sendString',
370 'URL.createObjectURL(WebKitMediaSource source)':
371 'createObjectUrlFromSource',
372 'URL.createObjectURL(MediaStream stream)': 'createObjectUrlFromStream',
373 'URL.createObjectURL(Blob blob)': 'createObjectUrlFromBlob',
374 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
375 'unsigned long internalformat, long width, long height, long border, '
376 'unsigned long format, unsigned long type, ArrayBufferView pixels)':
377 'texImage2DTypedData',
378 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
379 'unsigned long internalformat, unsigned long format, unsigned long '
380 'type, HTMLImageElement image)': 'texImage2DImage',
381 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
382 'unsigned long internalformat, unsigned long format, unsigned long '
383 'type, HTMLCanvasElement canvas)': 'texImage2DCanvas',
384 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
385 'unsigned long internalformat, unsigned long format, unsigned long '
386 'type, HTMLVideoElement video)': 'texImage2DVideo',
387 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
388 'long xoffset, long yoffset, long width, long height, unsigned long '
389 'format, unsigned long type, ArrayBufferView pixels)':
390 'texSubImage2DTypedData',
391 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
392 'long xoffset, long yoffset, unsigned long format, unsigned long type, '
393 'HTMLImageElement image)': 'texSubImage2DImage',
394 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
395 'long xoffset, long yoffset, unsigned long format, unsigned long type, '
396 'HTMLCanvasElement canvas)': 'texSubImage2DCanvas',
397 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
398 'long xoffset, long yoffset, unsigned long format, unsigned long type, '
399 'HTMLVideoElement video)': 'texSubImage2DVideo',
400 'WebGLRenderingContext.bufferData(unsigned long target, ArrayBuffer data, '
401 'unsigned long usage)': 'bufferByteData',
402 'WebGLRenderingContext.bufferData(unsigned long target, '
403 'ArrayBufferView data, unsigned long usage)': 'bufferTypedData',
404 'WebGLRenderingContext.bufferSubData(unsigned long target, '
405 'long long offset, ArrayBuffer data)': 'bufferSubByteData',
406 'WebGLRenderingContext.bufferSubData(unsigned long target, '
407 'long long offset, ArrayBufferView data)': 'bufferSubTypedData',
408 'WebSocket.send(ArrayBuffer data)': 'sendByteBuffer',
409 'WebSocket.send(ArrayBufferView data)': 'sendTypeData',
410 'WebSocket.send(DOMString data)': 'sendString',
411 'WebSocket.send(Blob data)': 'sendBlob'
412 })
413
414 # Members that have multiple definitions, but their types are identical (only
415 # number of arguments vary), so we do not rename them as a _raw method.
416 keep_overloaded_members = monitored.Set(
417 'htmldartgenerator.keep_overloaded_members', [
418 'AudioBufferSourceNode.start',
419 'CanvasRenderingContext2D.putImageData',
420 'CanvasRenderingContext2D.webkitPutImageDataHD',
421 'DataTransferItemList.add',
422 'HTMLInputElement.setRangeText',
423 'HTMLTextAreaElement.setRangeText',
424 'IDBDatabase.transaction',
425 'RTCDataChannel.send',
426 'URL.createObjectURL',
427 'WebSocket.send',
428 'XMLHttpRequest.send'
429 ])
430
349 for member in convert_to_future_members: 431 for member in convert_to_future_members:
350 if member in renamed_html_members: 432 if member in renamed_html_members:
351 renamed_html_members[member] = '_' + renamed_html_members[member] 433 renamed_html_members[member] = '_' + renamed_html_members[member]
352 else: 434 else:
353 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] 435 renamed_html_members[member] = '_' + member[member.find('.') + 1 :]
354 436
355 # Members and classes from the dom that should be removed completely from 437 # Members and classes from the dom that should be removed completely from
356 # dart:html. These could be expressed in the IDL instead but expressing this 438 # dart:html. These could be expressed in the IDL instead but expressing this
357 # as a simple table instead is more concise. 439 # as a simple table instead is more concise.
358 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName 440 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
359 # Using get: and set: is optional and should only be used when a getter needs 441 # Using get: and set: is optional and should only be used when a getter needs
360 # to be suppressed but not the setter, etc. 442 # to be suppressed but not the setter, etc.
361 # TODO(jacobr): cleanup and augment this list. 443 # TODO(jacobr): cleanup and augment this list.
362 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [ 444 removed_html_members = monitored.Set('htmlrenamer.removed_html_members', [
363 'AudioBufferSourceNode.looping', # TODO(vsm): Use deprecated IDL annotation 445 'AudioBufferSourceNode.looping', # TODO(vsm): Use deprecated IDL annotation
364 'CSSStyleDeclaration.getPropertyCSSValue', 446 'CSSStyleDeclaration.getPropertyCSSValue',
365 'CanvasRenderingContext2D.clearShadow', 447 'CanvasRenderingContext2D.clearShadow',
366 'CanvasRenderingContext2D.drawImageFromRect', 448 'CanvasRenderingContext2D.drawImageFromRect',
367 'CanvasRenderingContext2D.setAlpha', 449 'CanvasRenderingContext2D.setAlpha',
368 'CanvasRenderingContext2D.setCompositeOperation', 450 'CanvasRenderingContext2D.setCompositeOperation',
369 'CanvasRenderingContext2D.setFillColor', 451 'CanvasRenderingContext2D.setFillColor',
370 'CanvasRenderingContext2D.setLineCap', 452 'CanvasRenderingContext2D.setLineCap',
371 'CanvasRenderingContext2D.setLineJoin', 453 'CanvasRenderingContext2D.setLineJoin',
372 'CanvasRenderingContext2D.setLineWidth', 454 'CanvasRenderingContext2D.setLineWidth',
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 if self.ShouldSuppressMember(interface, member, member_prefix): 748 if self.ShouldSuppressMember(interface, member, member_prefix):
667 return None 749 return None
668 750
669 if 'CheckSecurityForNode' in member_node.ext_attrs: 751 if 'CheckSecurityForNode' in member_node.ext_attrs:
670 return None 752 return None
671 753
672 name = self._FindMatch(interface, member, member_prefix, 754 name = self._FindMatch(interface, member, member_prefix,
673 renamed_html_members) 755 renamed_html_members)
674 756
675 target_name = renamed_html_members[name] if name else member 757 target_name = renamed_html_members[name] if name else member
676 if self._FindMatch(interface, member, member_prefix, _private_html_members): 758 if self._FindMatch(interface, member, member_prefix, private_html_members):
677 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName 759 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
678 target_name = '$dom_' + target_name 760 target_name = '$dom_' + target_name
679 761
680 if not name and target_name.startswith('webkit'): 762 if not name and target_name.startswith('webkit'):
681 target_name = member[len('webkit'):] 763 target_name = member[len('webkit'):]
682 target_name = target_name[:1].lower() + target_name[1:] 764 target_name = target_name[:1].lower() + target_name[1:]
683 765
684 if dartify_name: 766 if dartify_name:
685 target_name = self._DartifyMemberName(target_name) 767 target_name = self._DartifyMemberName(target_name)
686 return target_name 768 return target_name
687 769
688 def ShouldSuppressMember(self, interface, member, member_prefix=''): 770 def ShouldSuppressMember(self, interface, member, member_prefix=''):
689 """ Returns true if the member should be suppressed.""" 771 """ Returns true if the member should be suppressed."""
690 if self._FindMatch(interface, member, member_prefix, 772 if self._FindMatch(interface, member, member_prefix, removed_html_members):
691 _removed_html_members):
692 return True 773 return True
693 if interface.id in _removed_html_interfaces: 774 if interface.id in _removed_html_interfaces:
694 return True 775 return True
695 return False 776 return False
696 777
697 def ShouldSuppressInterface(self, interface): 778 def ShouldSuppressInterface(self, interface):
698 """ Returns true if the interface should be suppressed.""" 779 """ Returns true if the interface should be suppressed."""
699 if interface.id in _removed_html_interfaces: 780 if interface.id in _removed_html_interfaces:
700 return True 781 return True
701 782
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 851
771 # We're looking for a sequence of letters which start with capital letter 852 # We're looking for a sequence of letters which start with capital letter
772 # then a series of caps and finishes with either the end of the string or 853 # then a series of caps and finishes with either the end of the string or
773 # a capital letter. 854 # a capital letter.
774 # The [0-9] check is for names such as 2D or 3D 855 # The [0-9] check is for names such as 2D or 3D
775 # The following test cases should match as: 856 # The following test cases should match as:
776 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 857 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
777 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 858 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
778 # IFrameElement: (I)()(F)rameElement (no change) 859 # IFrameElement: (I)()(F)rameElement (no change)
779 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 860 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmldartgenerator.py ('k') | tools/dom/scripts/logging.conf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698