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

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

Issue 25626002: Generate a library ID instead of a library name, so that the ID can be used (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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/dartdomgenerator.py ('k') | tools/dom/scripts/systemnative.py » ('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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 ]) 748 ])
749 749
750 # Manual dart: library name lookup. 750 # Manual dart: library name lookup.
751 _library_names = monitored.Dict('htmlrenamer._library_names', { 751 _library_names = monitored.Dict('htmlrenamer._library_names', {
752 'ANGLEInstancedArrays': 'web_gl', 752 'ANGLEInstancedArrays': 'web_gl',
753 'Database': 'web_sql', 753 'Database': 'web_sql',
754 'Navigator': 'html', 754 'Navigator': 'html',
755 'Window': 'html', 755 'Window': 'html',
756 }) 756 })
757 757
758 _library_ids = monitored.Dict('htmlrenamer._library_names', {
759 'ANGLEInstancedArrays': 'WebGl',
760 'Database': 'WebSql',
761 'Navigator': 'Html',
762 'Window': 'Html',
763 })
764
758 class HtmlRenamer(object): 765 class HtmlRenamer(object):
759 def __init__(self, database): 766 def __init__(self, database):
760 self._database = database 767 self._database = database
761 768
762 def RenameInterface(self, interface): 769 def RenameInterface(self, interface):
763 if 'Callback' in interface.ext_attrs: 770 if 'Callback' in interface.ext_attrs:
764 if interface.id in _removed_html_interfaces: 771 if interface.id in _removed_html_interfaces:
765 return None 772 return None
766 773
767 candidate = self.RenameInterfaceId(interface.id) 774 candidate = self.RenameInterfaceId(interface.id)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: 873 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']:
867 return 'indexed_db' 874 return 'indexed_db'
868 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: 875 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']:
869 return 'web_sql' 876 return 'web_sql'
870 877
871 if interface.id in typed_array_renames: 878 if interface.id in typed_array_renames:
872 return 'typed_data' 879 return 'typed_data'
873 880
874 return 'html' 881 return 'html'
875 882
883 def GetLibraryId(self, interface):
884 # Some types have attributes merged in from many other interfaces.
885 if interface.id in _library_ids:
886 return _library_ids[interface.id]
887
888 # TODO(ager, blois): The conditional has been removed from indexed db,
889 # so we can no longer determine the library based on the conditionals.
890 if interface.id.startswith("IDB"):
891 return 'IndexedDb'
892 if interface.id.startswith("SQL"):
893 return 'WebSql'
894 if interface.id.startswith("SVG"):
895 return 'Svg'
896 if interface.id.startswith("WebGL") or interface.id.startswith("OES") \
897 or interface.id.startswith("EXT"):
898 return 'WebGl'
899
900 if 'Conditional' in interface.ext_attrs:
901 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']:
902 return 'WebAudio'
903 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']:
904 return 'IndexedDb'
905 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']:
906 return 'WebSql'
907
908 if interface.id in typed_array_renames:
909 return 'TypedData'
910
911 return 'Html'
912
876 def DartifyTypeName(self, type_name): 913 def DartifyTypeName(self, type_name):
877 """Converts a DOM name to a Dart-friendly class name. """ 914 """Converts a DOM name to a Dart-friendly class name. """
878 915
879 if type_name in html_interface_renames: 916 if type_name in html_interface_renames:
880 return html_interface_renames[type_name] 917 return html_interface_renames[type_name]
881 918
882 return self._DartifyName(type_name) 919 return self._DartifyName(type_name)
883 920
884 def _DartifyName(self, dart_name): 921 def _DartifyName(self, dart_name):
885 # Strip off any standard prefixes. 922 # Strip off any standard prefixes.
(...skipping 16 matching lines...) Expand all
902 939
903 # We're looking for a sequence of letters which start with capital letter 940 # We're looking for a sequence of letters which start with capital letter
904 # then a series of caps and finishes with either the end of the string or 941 # then a series of caps and finishes with either the end of the string or
905 # a capital letter. 942 # a capital letter.
906 # The [0-9] check is for names such as 2D or 3D 943 # The [0-9] check is for names such as 2D or 3D
907 # The following test cases should match as: 944 # The following test cases should match as:
908 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 945 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
909 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 946 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
910 # IFrameElement: (I)()(F)rameElement (no change) 947 # IFrameElement: (I)()(F)rameElement (no change)
911 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 948 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « tools/dom/scripts/dartdomgenerator.py ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698