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

Side by Side Diff: lib/html/scripts/htmlrenamer.py

Issue 10941047: Don't generate FooList if it behaves like List<Foo> exactly. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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 5
6 _html_interface_renames = { 6 html_interface_renames = {
7 'ClientRectList': 'List<ClientRect>',
8 'CSSRuleList': 'List<CSSRule>',
9 'CSSValueList': 'List<CSSValue>',
7 'DOMFormData': 'FormData', 10 'DOMFormData': 'FormData',
8 'DOMWindow': 'Window', 11 'DOMWindow': 'Window',
12 'EntryArray': 'List<Entry>',
13 'EntryArraySync': 'List<EntrySync>',
14 'FileList': 'List<File>',
15 'GamepadList': 'List<Gamepad>',
16 'MediaStreamList': 'List<MediaStream>',
17 'SVGElementInstanceList': 'List<SVGElementInstance>',
18 'SVGPathSegList': 'List<SVGPathSeg>',
19 'SpeechInputResultList': 'List<SpeechInputResult>',
20 'SpeechRecognitionResultList': 'List<SpeechRecognitionResult>',
21 'StyleSheetList': 'List<StyleSheet>',
9 'WebKitAnimation': 'Animation', 22 'WebKitAnimation': 'Animation',
10 'WebKitAnimationEvent': 'AnimationEvent', 23 'WebKitAnimationEvent': 'AnimationEvent',
11 'WebKitAnimationList': 'AnimationList', 24 'WebKitAnimationList': 'AnimationList',
12 'WebKitBlobBuilder': 'BlobBuilder', 25 'WebKitBlobBuilder': 'BlobBuilder',
13 'WebKitCSSKeyframeRule': 'CSSKeyframeRule', 26 'WebKitCSSKeyframeRule': 'CSSKeyframeRule',
14 'WebKitCSSKeyframesRule': 'CSSKeyframesRule', 27 'WebKitCSSKeyframesRule': 'CSSKeyframesRule',
15 'WebKitCSSMatrix': 'CSSMatrix', 28 'WebKitCSSMatrix': 'CSSMatrix',
16 'WebKitCSSTransformValue': 'CSSTransformValue', 29 'WebKitCSSTransformValue': 'CSSTransformValue',
17 'WebKitFlags': 'Flags', 30 'WebKitFlags': 'Flags',
18 'WebKitLoseContext': 'LoseContext', 31 'WebKitLoseContext': 'LoseContext',
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 285
273 class HtmlRenamer(object): 286 class HtmlRenamer(object):
274 def __init__(self, database): 287 def __init__(self, database):
275 self._database = database 288 self._database = database
276 289
277 def RenameInterface(self, interface): 290 def RenameInterface(self, interface):
278 if interface.id.startswith('HTML'): 291 if interface.id.startswith('HTML'):
279 if any(interface.id in ['Element', 'Document'] 292 if any(interface.id in ['Element', 'Document']
280 for interface in self._database.Hierarchy(interface)): 293 for interface in self._database.Hierarchy(interface)):
281 return interface.id[len('HTML'):] 294 return interface.id[len('HTML'):]
282 elif interface.id in _html_interface_renames: 295 elif interface.id in html_interface_renames:
283 return _html_interface_renames[interface.id] 296 return html_interface_renames[interface.id]
284 return interface.id 297 return interface.id
285 298
286 def RenameMember(self, interface_name, member, member_prefix=''): 299 def RenameMember(self, interface_name, member, member_prefix=''):
287 """ 300 """
288 Returns the name of the member in the HTML library or None if the member is 301 Returns the name of the member in the HTML library or None if the member is
289 suppressed in the HTML library 302 suppressed in the HTML library
290 """ 303 """
291 interface = self._database.GetInterface(interface_name) 304 interface = self._database.GetInterface(interface_name)
292 305
293 if self._FindMatch(interface, member, member_prefix, _removed_html_members): 306 if self._FindMatch(interface, member, member_prefix, _removed_html_members):
294 return None 307 return None
295 308
296 name = self._FindMatch(interface, member, member_prefix, 309 name = self._FindMatch(interface, member, member_prefix,
297 _renamed_html_members) 310 _renamed_html_members)
298 target_name = _renamed_html_members[name] if name else member 311 target_name = _renamed_html_members[name] if name else member
299 if self._FindMatch(interface, member, member_prefix, _private_html_members): 312 if self._FindMatch(interface, member, member_prefix, _private_html_members):
300 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName 313 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
301 target_name = '$dom_' + target_name 314 target_name = '$dom_' + target_name
302 return target_name 315 return target_name
303 316
304 def _FindMatch(self, interface, member, member_prefix, candidates): 317 def _FindMatch(self, interface, member, member_prefix, candidates):
305 for interface in self._database.Hierarchy(interface): 318 for interface in self._database.Hierarchy(interface):
306 html_interface_name = self.RenameInterface(interface) 319 html_interface_name = self.RenameInterface(interface)
307 member_name = html_interface_name + '.' + member 320 member_name = html_interface_name + '.' + member
308 if member_name in candidates: 321 if member_name in candidates:
309 return member_name 322 return member_name
310 member_name = html_interface_name + '.' + member_prefix + member 323 member_name = html_interface_name + '.' + member_prefix + member
311 if member_name in candidates: 324 if member_name in candidates:
312 return member_name 325 return member_name
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698