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

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

Issue 11434079: Adding dart:indexed_db. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Syncing with latest. Created 8 years 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 | « sdk/lib/html/scripts/htmleventgenerator.py ('k') | sdk/lib/html/scripts/systemhtml.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 re 5 import re
6 6
7 html_interface_renames = { 7 html_interface_renames = {
8 'DOMCoreException': 'DOMException', 8 'DOMCoreException': 'DOMException',
9 'DOMFormData': 'FormData', 9 'DOMFormData': 'FormData',
10 'DOMURL': 'Url', 10 'DOMURL': 'Url',
11 'DOMWindow': 'LocalWindow', 11 'DOMWindow': 'LocalWindow',
12 'History': 'LocalHistory', 12 'History': 'LocalHistory',
13 'HTMLDocument' : 'HtmlDocument', 13 'HTMLDocument' : 'HtmlDocument',
14 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts.
14 'Location': 'LocalLocation', 15 'Location': 'LocalLocation',
15 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. 16 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
16 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. 17 'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
17 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. 18 'SVGException': 'SvgException', # Manual of avoid conflict with Exception.
18 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. 19 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
19 'WebKitAnimation': 'Animation', 20 'WebKitAnimation': 'Animation',
20 'WebKitAnimationEvent': 'AnimationEvent', 21 'WebKitAnimationEvent': 'AnimationEvent',
21 'WebKitBlobBuilder': 'BlobBuilder', 22 'WebKitBlobBuilder': 'BlobBuilder',
22 'WebKitCSSKeyframeRule': 'CSSKeyframeRule', 23 'WebKitCSSKeyframeRule': 'CSSKeyframeRule',
23 'WebKitCSSKeyframesRule': 'CSSKeyframesRule', 24 'WebKitCSSKeyframesRule': 'CSSKeyframesRule',
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 "Node.get:nodeName", 302 "Node.get:nodeName",
302 "Node.lookupPrefix", 303 "Node.lookupPrefix",
303 "Node.get:PROCESSING_INSTRUCTION_NODE", 304 "Node.get:PROCESSING_INSTRUCTION_NODE",
304 'ShadowRoot.getElementsByTagNameNS', 305 'ShadowRoot.getElementsByTagNameNS',
305 "LocalWindow.blur", 306 "LocalWindow.blur",
306 "LocalWindow.clientInformation", 307 "LocalWindow.clientInformation",
307 "LocalWindow.get:frames", 308 "LocalWindow.get:frames",
308 "LocalWindow.get:length", 309 "LocalWindow.get:length",
309 "LocalWindow.focus", 310 "LocalWindow.focus",
310 "LocalWindow.prompt", 311 "LocalWindow.prompt",
312 "LocalWindow.webkitIndexedDB",
311 "LocalWindow.webkitCancelRequestAnimationFrame", 313 "LocalWindow.webkitCancelRequestAnimationFrame",
312 "WheelEvent.wheelDelta", 314 "WheelEvent.wheelDelta",
315 "WorkerContext.webkitIndexedDB",
313 ]) 316 ])
314 317
315 class HtmlRenamer(object): 318 class HtmlRenamer(object):
316 def __init__(self, database): 319 def __init__(self, database):
317 self._database = database 320 self._database = database
318 321
319 def RenameInterface(self, interface): 322 def RenameInterface(self, interface):
320 if interface.id in html_interface_renames: 323 if interface.id in html_interface_renames:
321 return html_interface_renames[interface.id] 324 return html_interface_renames[interface.id]
322 elif interface.id.startswith('HTML'): 325 elif interface.id.startswith('HTML'):
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 member_name = html_interface_name + '.' + member_prefix + member 362 member_name = html_interface_name + '.' + member_prefix + member
360 if member_name in candidates: 363 if member_name in candidates:
361 return member_name 364 return member_name
362 365
363 def GetLibraryName(self, interface): 366 def GetLibraryName(self, interface):
364 if 'Conditional' in interface.ext_attrs: 367 if 'Conditional' in interface.ext_attrs:
365 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: 368 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']:
366 return 'web_audio' 369 return 'web_audio'
367 if 'SVG' in interface.ext_attrs['Conditional']: 370 if 'SVG' in interface.ext_attrs['Conditional']:
368 return 'svg' 371 return 'svg'
372 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']:
373 return 'indexed_db'
369 374
370 return self._GetLibraryName(interface.id) 375 return self._GetLibraryName(interface.id)
371 376
372 # TODO(blois): remove this method when all members are renamed. 377 # TODO(blois): remove this method when all members are renamed.
373 def _GetLibraryName(self, idl_type_name): 378 def _GetLibraryName(self, idl_type_name):
374 """ 379 """
375 Gets the name of the library this type should live in. 380 Gets the name of the library this type should live in.
376 This is private because this should use interfaces to resolve the library. 381 This is private because this should use interfaces to resolve the library.
377 """ 382 """
378 if idl_type_name.startswith('SVG'): 383 if idl_type_name.startswith('SVG'):
379 return 'svg' 384 return 'svg'
385 if idl_type_name.startswith('IDB'):
386 return 'indexed_db'
380 387
381 return 'html' 388 return 'html'
382 389
383 390
384 def DartifyTypeName(self, type_name): 391 def DartifyTypeName(self, type_name):
385 """Converts a DOM name to a Dart-friendly class name. """ 392 """Converts a DOM name to a Dart-friendly class name. """
386 library_name = self._GetLibraryName(type_name) 393 library_name = self._GetLibraryName(type_name)
387 # Only renaming SVG for now. 394 # Rename everything except html.
388 if library_name != 'svg': 395 if library_name == 'html':
389 return type_name 396 return type_name
390 397
391 # Strip off the SVG prefix. 398 # Strip off any SVG prefix.
392 name = re.sub(r'^SVG', '', type_name) 399 name = re.sub(r'^SVG', '', type_name)
400 # Strip off any IDB prefix.
401 name = re.sub(r'^IDB', '', name)
402
393 return self._CamelCaseName(name) 403 return self._CamelCaseName(name)
394 404
395 def _DartifyMemberName(self, member_name): 405 def _DartifyMemberName(self, member_name):
396 # Strip off any OpenGL ES suffixes. 406 # Strip off any OpenGL ES suffixes.
397 name = re.sub(r'OES$', '', member_name) 407 name = re.sub(r'OES$', '', member_name)
398 return self._CamelCaseName(name) 408 return self._CamelCaseName(name)
399 409
400 def _CamelCaseName(self, name): 410 def _CamelCaseName(self, name):
401 411
402 def toLower(match): 412 def toLower(match):
403 return match.group(1) + match.group(2).lower() + match.group(3) 413 return match.group(1) + match.group(2).lower() + match.group(3)
404 414
405 # We're looking for a sequence of letters which start with capital letter 415 # We're looking for a sequence of letters which start with capital letter
406 # then a series of caps and finishes with either the end of the string or 416 # then a series of caps and finishes with either the end of the string or
407 # a capital letter. 417 # a capital letter.
408 # The [0-9] check is for names such as 2D or 3D 418 # The [0-9] check is for names such as 2D or 3D
409 # The following test cases should match as: 419 # The following test cases should match as:
410 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 420 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
411 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 421 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
412 # IFrameElement: (I)()(F)rameElement (no change) 422 # IFrameElement: (I)()(F)rameElement (no change)
413 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 423 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/htmleventgenerator.py ('k') | sdk/lib/html/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698