| 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 re | 5 import re |
| 6 | 6 |
| 7 html_interface_renames = { | 7 html_interface_renames = { |
| 8 'DOMCoreException': 'DOMException', | 8 'CDATASection': 'CDataSection', |
| 9 'DOMApplicationCache': 'ApplicationCache', |
| 10 'DOMCoreException': 'DomException', |
| 11 'DOMFileSystem': 'FileSystem', |
| 12 'DOMFileSystemSync': 'FileSystemSync', |
| 9 'DOMFormData': 'FormData', | 13 'DOMFormData': 'FormData', |
| 10 'DOMURL': 'Url', | 14 'DOMURL': 'Url', |
| 11 'DOMWindow': 'LocalWindow', | 15 'DOMWindow': 'LocalWindow', |
| 12 'History': 'LocalHistory', | 16 'History': 'LocalHistory', |
| 13 'HTMLDocument' : 'HtmlDocument', | 17 'HTMLDocument' : 'HtmlDocument', |
| 14 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts. | 18 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts. |
| 15 'Location': 'LocalLocation', | 19 'Location': 'LocalLocation', |
| 16 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. | 20 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. |
| 17 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. | 21 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. |
| 18 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. | 22 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. |
| 19 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. | 23 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. |
| 24 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject', |
| 20 'WebKitAnimation': 'Animation', | 25 'WebKitAnimation': 'Animation', |
| 21 'WebKitAnimationEvent': 'AnimationEvent', | 26 'WebKitAnimationEvent': 'AnimationEvent', |
| 22 'WebKitBlobBuilder': 'BlobBuilder', | 27 'WebKitBlobBuilder': 'BlobBuilder', |
| 23 'WebKitCSSKeyframeRule': 'CSSKeyframeRule', | 28 'WebKitCSSKeyframeRule': 'CssKeyframeRule', |
| 24 'WebKitCSSKeyframesRule': 'CSSKeyframesRule', | 29 'WebKitCSSKeyframesRule': 'CssKeyframesRule', |
| 25 'WebKitCSSMatrix': 'CSSMatrix', | 30 'WebKitCSSMatrix': 'CssMatrix', |
| 26 'WebKitCSSTransformValue': 'CSSTransformValue', | 31 'WebKitCSSTransformValue': 'CssTransformValue', |
| 27 'WebKitFlags': 'Flags', | 32 'WebKitFlags': 'Flags', |
| 28 'WebKitLoseContext': 'LoseContext', | 33 'WebKitLoseContext': 'LoseContext', |
| 29 'WebKitPoint': 'Point', | 34 'WebKitPoint': 'Point', |
| 30 'WebKitTransitionEvent': 'TransitionEvent', | 35 'WebKitTransitionEvent': 'TransitionEvent', |
| 31 'XMLHttpRequest': 'HttpRequest', | 36 'XMLHttpRequest': 'HttpRequest', |
| 32 'XMLHttpRequestException': 'HttpRequestException', | 37 'XMLHttpRequestException': 'HttpRequestException', |
| 33 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', | 38 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', |
| 34 'XMLHttpRequestUpload': 'HttpRequestUpload', | 39 'XMLHttpRequestUpload': 'HttpRequestUpload', |
| 35 } | 40 } |
| 36 | 41 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 return self._GetLibraryName(interface.id) | 380 return self._GetLibraryName(interface.id) |
| 376 | 381 |
| 377 # TODO(blois): remove this method when all members are renamed. | 382 # TODO(blois): remove this method when all members are renamed. |
| 378 def _GetLibraryName(self, idl_type_name): | 383 def _GetLibraryName(self, idl_type_name): |
| 379 """ | 384 """ |
| 380 Gets the name of the library this type should live in. | 385 Gets the name of the library this type should live in. |
| 381 This is private because this should use interfaces to resolve the library. | 386 This is private because this should use interfaces to resolve the library. |
| 382 """ | 387 """ |
| 383 if idl_type_name.startswith('SVG'): | 388 if idl_type_name.startswith('SVG'): |
| 384 return 'svg' | 389 return 'svg' |
| 390 |
| 385 if idl_type_name.startswith('IDB'): | 391 if idl_type_name.startswith('IDB'): |
| 386 return 'indexed_db' | 392 return 'indexed_db' |
| 387 | 393 |
| 388 return 'html' | 394 return 'html' |
| 389 | 395 |
| 390 | 396 |
| 391 def DartifyTypeName(self, type_name): | 397 def DartifyTypeName(self, type_name): |
| 392 """Converts a DOM name to a Dart-friendly class name. """ | 398 """Converts a DOM name to a Dart-friendly class name. """ |
| 393 library_name = self._GetLibraryName(type_name) | 399 library_name = self._GetLibraryName(type_name) |
| 394 # Rename everything except html. | |
| 395 if library_name == 'html': | |
| 396 return type_name | |
| 397 | 400 |
| 398 # Strip off any SVG prefix. | 401 # Strip off any standard prefixes. |
| 399 name = re.sub(r'^SVG', '', type_name) | 402 name = re.sub(r'^SVG', '', type_name) |
| 400 # Strip off any IDB prefix. | |
| 401 name = re.sub(r'^IDB', '', name) | 403 name = re.sub(r'^IDB', '', name) |
| 402 | 404 |
| 403 return self._CamelCaseName(name) | 405 return self._CamelCaseName(name) |
| 404 | 406 |
| 405 def _DartifyMemberName(self, member_name): | 407 def _DartifyMemberName(self, member_name): |
| 406 # Strip off any OpenGL ES suffixes. | 408 # Strip off any OpenGL ES suffixes. |
| 407 name = re.sub(r'OES$', '', member_name) | 409 name = re.sub(r'OES$', '', member_name) |
| 408 return self._CamelCaseName(name) | 410 return self._CamelCaseName(name) |
| 409 | 411 |
| 410 def _CamelCaseName(self, name): | 412 def _CamelCaseName(self, name): |
| 411 | 413 |
| 412 def toLower(match): | 414 def toLower(match): |
| 413 return match.group(1) + match.group(2).lower() + match.group(3) | 415 return match.group(1) + match.group(2).lower() + match.group(3) |
| 414 | 416 |
| 415 # We're looking for a sequence of letters which start with capital letter | 417 # We're looking for a sequence of letters which start with capital letter |
| 416 # then a series of caps and finishes with either the end of the string or | 418 # then a series of caps and finishes with either the end of the string or |
| 417 # a capital letter. | 419 # a capital letter. |
| 418 # The [0-9] check is for names such as 2D or 3D | 420 # The [0-9] check is for names such as 2D or 3D |
| 419 # The following test cases should match as: | 421 # The following test cases should match as: |
| 420 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 422 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
| 421 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 423 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
| 422 # IFrameElement: (I)()(F)rameElement (no change) | 424 # IFrameElement: (I)()(F)rameElement (no change) |
| 423 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 425 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
| OLD | NEW |