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