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

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

Issue 11280103: Splitting out the Audio library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding missing lib registrations 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/dartdomgenerator.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',
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 def RenameInterface(self, interface): 310 def RenameInterface(self, interface):
311 if interface.id in html_interface_renames: 311 if interface.id in html_interface_renames:
312 return html_interface_renames[interface.id] 312 return html_interface_renames[interface.id]
313 elif interface.id.startswith('HTML'): 313 elif interface.id.startswith('HTML'):
314 if any(interface.id in ['Element', 'Document'] 314 if any(interface.id in ['Element', 'Document']
315 for interface in self._database.Hierarchy(interface)): 315 for interface in self._database.Hierarchy(interface)):
316 return interface.id[len('HTML'):] 316 return interface.id[len('HTML'):]
317 return self.DartifyTypeName(interface.id) 317 return self.DartifyTypeName(interface.id)
318 318
319
319 def RenameMember(self, interface_name, member_node, member, member_prefix=''): 320 def RenameMember(self, interface_name, member_node, member, member_prefix=''):
320 """ 321 """
321 Returns the name of the member in the HTML library or None if the member is 322 Returns the name of the member in the HTML library or None if the member is
322 suppressed in the HTML library 323 suppressed in the HTML library
323 """ 324 """
324 interface = self._database.GetInterface(interface_name) 325 interface = self._database.GetInterface(interface_name)
325 326
326 if self._FindMatch(interface, member, member_prefix, _removed_html_members): 327 if self._FindMatch(interface, member, member_prefix, _removed_html_members):
327 return None 328 return None
328 329
(...skipping 24 matching lines...) Expand all
353 def GetLibraryName(self, interface): 354 def GetLibraryName(self, interface):
354 return self._GetLibraryName(interface.id) 355 return self._GetLibraryName(interface.id)
355 356
356 def _GetLibraryName(self, idl_type_name): 357 def _GetLibraryName(self, idl_type_name):
357 """ 358 """
358 Gets the name of the library this type should live in. 359 Gets the name of the library this type should live in.
359 This is private because this should use interfaces to resolve the library. 360 This is private because this should use interfaces to resolve the library.
360 """ 361 """
361 if idl_type_name.startswith('SVG'): 362 if idl_type_name.startswith('SVG'):
362 return 'svg' 363 return 'svg'
364 if 'Audio' in idl_type_name:
365 return 'web_audio'
366
367 if self._database.HasInterface(idl_type_name):
368 interface = self._database.GetInterface(idl_type_name)
369 for parent in self._database.Hierarchy(interface):
370 if parent.id == 'AudioNode':
371 return 'web_audio'
372
363 return 'html' 373 return 'html'
364 374
365 375
366 def DartifyTypeName(self, type_name): 376 def DartifyTypeName(self, type_name):
367 """Converts a DOM name to a Dart-friendly class name. """ 377 """Converts a DOM name to a Dart-friendly class name. """
368 library_name = self._GetLibraryName(type_name) 378 library_name = self._GetLibraryName(type_name)
369 # Only renaming SVG for now. 379 # Only renaming SVG for now.
370 if library_name != 'svg': 380 if library_name != 'svg':
371 return type_name 381 return type_name
372 382
(...skipping 13 matching lines...) Expand all
386 396
387 # We're looking for a sequence of letters which start with capital letter 397 # We're looking for a sequence of letters which start with capital letter
388 # then a series of caps and finishes with either the end of the string or 398 # then a series of caps and finishes with either the end of the string or
389 # a capital letter. 399 # a capital letter.
390 # The [0-9] check is for names such as 2D or 3D 400 # The [0-9] check is for names such as 2D or 3D
391 # The following test cases should match as: 401 # The following test cases should match as:
392 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 402 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
393 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 403 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
394 # IFrameElement: (I)()(F)rameElement (no change) 404 # IFrameElement: (I)()(F)rameElement (no change)
395 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 405 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/dartdomgenerator.py ('k') | sdk/lib/html/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698