Chromium Code Reviews| 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 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 for interface in self._database.Hierarchy(interface): | 351 for interface in self._database.Hierarchy(interface): |
| 352 html_interface_name = self.RenameInterface(interface) | 352 html_interface_name = self.RenameInterface(interface) |
| 353 member_name = html_interface_name + '.' + member | 353 member_name = html_interface_name + '.' + member |
| 354 if member_name in candidates: | 354 if member_name in candidates: |
| 355 return member_name | 355 return member_name |
| 356 member_name = html_interface_name + '.' + member_prefix + member | 356 member_name = html_interface_name + '.' + member_prefix + member |
| 357 if member_name in candidates: | 357 if member_name in candidates: |
| 358 return member_name | 358 return member_name |
| 359 | 359 |
| 360 def GetLibraryName(self, interface): | 360 def GetLibraryName(self, interface): |
| 361 if interface.module_name == 'webaudio': | |
| 362 return 'web_audio' | |
|
sra1
2012/12/04 20:18:48
This works so much better.
| |
| 363 | |
| 364 if interface.module_name == 'svg': | |
| 365 return 'svg' | |
| 366 | |
| 361 return self._GetLibraryName(interface.id) | 367 return self._GetLibraryName(interface.id) |
| 362 | 368 |
| 369 # TODO(blois): remove this method when all members are renamed. | |
| 363 def _GetLibraryName(self, idl_type_name): | 370 def _GetLibraryName(self, idl_type_name): |
| 364 """ | 371 """ |
| 365 Gets the name of the library this type should live in. | 372 Gets the name of the library this type should live in. |
| 366 This is private because this should use interfaces to resolve the library. | 373 This is private because this should use interfaces to resolve the library. |
| 367 """ | 374 """ |
| 368 if idl_type_name.startswith('SVG'): | 375 if idl_type_name.startswith('SVG'): |
|
blois
2012/12/04 18:39:39
There are still collection cases which do not have
| |
| 369 return 'svg' | 376 return 'svg' |
| 370 if 'Audio' in idl_type_name: | |
| 371 return 'web_audio' | |
| 372 | |
| 373 if self._database.HasInterface(idl_type_name): | |
| 374 interface = self._database.GetInterface(idl_type_name) | |
| 375 for parent in self._database.Hierarchy(interface): | |
| 376 if parent.id == 'AudioNode': | |
| 377 return 'web_audio' | |
| 378 | 377 |
| 379 return 'html' | 378 return 'html' |
| 380 | 379 |
| 381 | 380 |
| 382 def DartifyTypeName(self, type_name): | 381 def DartifyTypeName(self, type_name): |
| 383 """Converts a DOM name to a Dart-friendly class name. """ | 382 """Converts a DOM name to a Dart-friendly class name. """ |
| 384 library_name = self._GetLibraryName(type_name) | 383 library_name = self._GetLibraryName(type_name) |
| 385 # Only renaming SVG for now. | 384 # Only renaming SVG for now. |
| 386 if library_name != 'svg': | 385 if library_name != 'svg': |
| 387 return type_name | 386 return type_name |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 402 | 401 |
| 403 # We're looking for a sequence of letters which start with capital letter | 402 # We're looking for a sequence of letters which start with capital letter |
| 404 # then a series of caps and finishes with either the end of the string or | 403 # then a series of caps and finishes with either the end of the string or |
| 405 # a capital letter. | 404 # a capital letter. |
| 406 # The [0-9] check is for names such as 2D or 3D | 405 # The [0-9] check is for names such as 2D or 3D |
| 407 # The following test cases should match as: | 406 # The following test cases should match as: |
| 408 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 407 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
| 409 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 408 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
| 410 # IFrameElement: (I)()(F)rameElement (no change) | 409 # IFrameElement: (I)()(F)rameElement (no change) |
| 411 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 410 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
| OLD | NEW |