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 | 5 |
| 6 """This module provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import re | 9 import re |
| 10 import string | |
| 11 | 10 |
| 12 _pure_interfaces = set([ | 11 _pure_interfaces = set([ |
| 13 'DOMStringMap', | 12 'DOMStringMap', |
| 14 'ElementTimeControl', | 13 'ElementTimeControl', |
| 15 'ElementTraversal', | 14 'ElementTraversal', |
| 16 'MediaQueryListListener', | 15 'MediaQueryListListener', |
| 17 'NodeSelector', | 16 'NodeSelector', |
| 18 'SVGExternalResourcesRequired', | 17 'SVGExternalResourcesRequired', |
| 19 'SVGFilterPrimitiveStandardAttributes', | 18 'SVGFilterPrimitiveStandardAttributes', |
| 20 'SVGFitToViewBox', | 19 'SVGFitToViewBox', |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 return 'const String&' | 535 return 'const String&' |
| 537 return self.native_type() | 536 return self.native_type() |
| 538 | 537 |
| 539 def conversion_includes(self): | 538 def conversion_includes(self): |
| 540 return [] | 539 return [] |
| 541 | 540 |
| 542 def to_dart_conversion(self, value, interface_name=None, attributes=None): | 541 def to_dart_conversion(self, value, interface_name=None, attributes=None): |
| 543 conversion_arguments = [value] | 542 conversion_arguments = [value] |
| 544 if attributes and 'TreatReturnedNullStringAs' in attributes: | 543 if attributes and 'TreatReturnedNullStringAs' in attributes: |
| 545 conversion_arguments.append('DartUtilities::ConvertNullToDefaultValue') | 544 conversion_arguments.append('DartUtilities::ConvertNullToDefaultValue') |
| 546 function_name = 'toDartValue' | 545 function_name = re.sub(r' [a-z]', lambda x: x.group(0)[1:].upper(), self.nat ive_type()) |
|
Anton Muhin
2012/04/25 10:05:18
nit.
I am probably biased here, but is it more re
podivilov
2012/04/25 11:12:58
I've changed this logic for ScriptValue -> scriptV
Anton Muhin
2012/04/25 13:09:55
I see, thanks for explanations.
Still maybe: def
| |
| 547 # FIXME: implement DartUtilities::toDart for other primitive types and | 546 function_name = function_name[0].lower() + function_name[1:] |
| 548 # remove this list. | 547 function_name = 'DartUtilities::%sToDart' % function_name |
| 549 if self.native_type() in ['String', 'bool', 'int', 'unsigned', 'long long', 'unsigned long long', 'double']: | |
| 550 function_name = string.capwords(self.native_type()).replace(' ', '') | |
| 551 function_name = function_name[0].lower() + function_name[1:] | |
| 552 function_name = 'DartUtilities::%sToDart' % function_name | |
| 553 return '%s(%s)' % (function_name, ', '.join(conversion_arguments)) | 548 return '%s(%s)' % (function_name, ', '.join(conversion_arguments)) |
| 554 | 549 |
| 555 def webcore_getter_name(self): | 550 def webcore_getter_name(self): |
| 556 return self._webcore_getter_name | 551 return self._webcore_getter_name |
| 557 | 552 |
| 558 def webcore_setter_name(self): | 553 def webcore_setter_name(self): |
| 559 return self._webcore_setter_name | 554 return self._webcore_setter_name |
| 560 | 555 |
| 561 class SVGTearOffIDLTypeInfo(IDLTypeInfo): | 556 class SVGTearOffIDLTypeInfo(IDLTypeInfo): |
| 562 def __init__(self, idl_type, native_type='', ref_counted=True): | 557 def __init__(self, idl_type, native_type='', ref_counted=True): |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 '"SVGAnimatedListPropertyTearOff.h"', | 673 '"SVGAnimatedListPropertyTearOff.h"', |
| 679 '"SVGTransformListPropertyTearOff.h"', | 674 '"SVGTransformListPropertyTearOff.h"', |
| 680 '"SVGPathSegListPropertyTearOff.h"', | 675 '"SVGPathSegListPropertyTearOff.h"', |
| 681 ] | 676 ] |
| 682 | 677 |
| 683 def GetIDLTypeInfo(idl_type_name): | 678 def GetIDLTypeInfo(idl_type_name): |
| 684 match = re.match(r'sequence<(\w+)>$', idl_type_name) | 679 match = re.match(r'sequence<(\w+)>$', idl_type_name) |
| 685 if match: | 680 if match: |
| 686 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 681 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
| 687 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | 682 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) |
| OLD | NEW |