| 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 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', { |
| 10 'CDATASection': 'CDataSection', | 10 'CDATASection': 'CDataSection', |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 682 |
| 683 if 'Conditional' in interface.ext_attrs: | 683 if 'Conditional' in interface.ext_attrs: |
| 684 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: | 684 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: |
| 685 return 'web_audio' | 685 return 'web_audio' |
| 686 if 'SVG' in interface.ext_attrs['Conditional']: | 686 if 'SVG' in interface.ext_attrs['Conditional']: |
| 687 return 'svg' | 687 return 'svg' |
| 688 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: | 688 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: |
| 689 return 'indexed_db' | 689 return 'indexed_db' |
| 690 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: | 690 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: |
| 691 return 'web_sql' | 691 return 'web_sql' |
| 692 if 'WEBGL' in interface.ext_attrs['Conditional']: |
| 693 return 'web_gl' |
| 692 | 694 |
| 693 return 'html' | 695 return 'html' |
| 694 | 696 |
| 695 def DartifyTypeName(self, type_name): | 697 def DartifyTypeName(self, type_name): |
| 696 """Converts a DOM name to a Dart-friendly class name. """ | 698 """Converts a DOM name to a Dart-friendly class name. """ |
| 697 | 699 |
| 698 if type_name in html_interface_renames: | 700 if type_name in html_interface_renames: |
| 699 return html_interface_renames[type_name] | 701 return html_interface_renames[type_name] |
| 700 | 702 |
| 701 # Strip off any standard prefixes. | 703 # Strip off any standard prefixes. |
| 702 name = re.sub(r'^SVG', '', type_name) | 704 name = re.sub(r'^SVG', '', type_name) |
| 703 name = re.sub(r'^IDB', '', name) | 705 name = re.sub(r'^IDB', '', name) |
| 706 name = re.sub(r'^WebGL', '', name) |
| 704 | 707 |
| 705 return self._CamelCaseName(name) | 708 return self._CamelCaseName(name) |
| 706 | 709 |
| 707 def _DartifyMemberName(self, member_name): | 710 def _DartifyMemberName(self, member_name): |
| 708 # Strip off any OpenGL ES suffixes. | 711 # Strip off any OpenGL ES suffixes. |
| 709 name = re.sub(r'OES$', '', member_name) | 712 name = re.sub(r'OES$', '', member_name) |
| 710 return self._CamelCaseName(name) | 713 return self._CamelCaseName(name) |
| 711 | 714 |
| 712 def _CamelCaseName(self, name): | 715 def _CamelCaseName(self, name): |
| 713 | 716 |
| 714 def toLower(match): | 717 def toLower(match): |
| 715 return match.group(1) + match.group(2).lower() + match.group(3) | 718 return match.group(1) + match.group(2).lower() + match.group(3) |
| 716 | 719 |
| 717 # We're looking for a sequence of letters which start with capital letter | 720 # We're looking for a sequence of letters which start with capital letter |
| 718 # then a series of caps and finishes with either the end of the string or | 721 # then a series of caps and finishes with either the end of the string or |
| 719 # a capital letter. | 722 # a capital letter. |
| 720 # The [0-9] check is for names such as 2D or 3D | 723 # The [0-9] check is for names such as 2D or 3D |
| 721 # The following test cases should match as: | 724 # The following test cases should match as: |
| 722 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 725 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
| 723 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 726 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
| 724 # IFrameElement: (I)()(F)rameElement (no change) | 727 # IFrameElement: (I)()(F)rameElement (no change) |
| 725 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 728 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
| OLD | NEW |