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 | 10 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 native_type = 'RefPtr< %s >' % native_type | 478 native_type = 'RefPtr< %s >' % native_type |
479 if self._has_dart_wrapper: | 479 if self._has_dart_wrapper: |
480 wrapper_type = 'Dart%s' % self.idl_type() | 480 wrapper_type = 'Dart%s' % self.idl_type() |
481 adapter_type = 'ParameterAdapter<%s, %s>' % (native_type, wrapper_type) | 481 adapter_type = 'ParameterAdapter<%s, %s>' % (native_type, wrapper_type) |
482 return (adapter_type, wrapper_type) | 482 return (adapter_type, wrapper_type) |
483 return ('ParameterAdapter< %s >' % native_type, self._idl_type) | 483 return ('ParameterAdapter< %s >' % native_type, self._idl_type) |
484 | 484 |
485 def parameter_type(self): | 485 def parameter_type(self): |
486 return '%s*' % self.native_type() | 486 return '%s*' % self.native_type() |
487 | 487 |
488 def webcore_include(self): | 488 def webcore_includes(self): |
489 if not self._idl_type.startswith('SVG'): | |
490 return [self._idl_type] | |
491 | |
489 if self._idl_type == 'SVGNumber' or self._idl_type == 'SVGPoint': | 492 if self._idl_type == 'SVGNumber' or self._idl_type == 'SVGPoint': |
antonm
2012/03/01 14:25:31
maybe, as you're touching it anyway, self._idl_typ
podivilov
2012/03/01 15:36:56
Done.
| |
490 return None | 493 return [] |
494 includes = _svg_supplemental_includes | |
491 if self._idl_type.startswith('SVGPathSeg'): | 495 if self._idl_type.startswith('SVGPathSeg'): |
492 return self._idl_type.replace('Abs', '').replace('Rel', '') | 496 includes.append(self._idl_type.replace('Abs', '').replace('Rel', '')) |
antonm
2012/03/01 14:25:31
maybe make it additional_include = self._idl_type.
podivilov
2012/03/01 15:36:56
Done.
| |
493 return self._idl_type | 497 else: |
498 includes.append(self._idl_type) | |
499 return includes | |
494 | 500 |
495 def receiver(self): | 501 def receiver(self): |
496 return 'receiver->' | 502 return 'receiver->' |
497 | 503 |
498 def conversion_include(self): | 504 def conversion_include(self): |
499 return 'Dart%s' % self._idl_type | 505 return 'Dart%s' % self.dart_type() |
500 | 506 |
501 def conversion_cast(self, expression): | 507 def conversion_cast(self, expression): |
502 if self._conversion_template: | 508 if self._conversion_template: |
503 return self._conversion_template % expression | 509 return self._conversion_template % expression |
504 return expression | 510 return expression |
505 | 511 |
506 def custom_to_dart(self): | 512 def custom_to_dart(self): |
507 return self._custom_to_dart | 513 return self._custom_to_dart |
508 | 514 |
509 class PrimitiveIDLTypeInfo(IDLTypeInfo): | 515 class PrimitiveIDLTypeInfo(IDLTypeInfo): |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 'WebKitFlags': PrimitiveIDLTypeInfo('WebKitFlags', dart_type='Object'), | 607 'WebKitFlags': PrimitiveIDLTypeInfo('WebKitFlags', dart_type='Object'), |
602 | 608 |
603 'DOMException': IDLTypeInfo('DOMCoreException', dart_type='DOMException'), | 609 'DOMException': IDLTypeInfo('DOMCoreException', dart_type='DOMException'), |
604 'DOMWindow': IDLTypeInfo('DOMWindow', custom_to_dart=True), | 610 'DOMWindow': IDLTypeInfo('DOMWindow', custom_to_dart=True), |
605 'Element': IDLTypeInfo('Element', custom_to_dart=True), | 611 'Element': IDLTypeInfo('Element', custom_to_dart=True), |
606 'EventListener': IDLTypeInfo('EventListener', has_dart_wrapper=False), | 612 'EventListener': IDLTypeInfo('EventListener', has_dart_wrapper=False), |
607 'EventTarget': IDLTypeInfo('EventTarget', has_dart_wrapper=False), | 613 'EventTarget': IDLTypeInfo('EventTarget', has_dart_wrapper=False), |
608 'HTMLElement': IDLTypeInfo('HTMLElement', custom_to_dart=True), | 614 'HTMLElement': IDLTypeInfo('HTMLElement', custom_to_dart=True), |
609 'MediaQueryListListener': IDLTypeInfo('MediaQueryListListener', has_dart_wra pper=False), | 615 'MediaQueryListListener': IDLTypeInfo('MediaQueryListListener', has_dart_wra pper=False), |
610 'OptionsObject': IDLTypeInfo('OptionsObject', has_dart_wrapper=False), | 616 'OptionsObject': IDLTypeInfo('OptionsObject', has_dart_wrapper=False), |
617 'StyleSheet': IDLTypeInfo('StyleSheet', conversion_template='static_cast<Sty leSheet*>(%s)'), | |
611 'SVGElement': IDLTypeInfo('SVGElement', custom_to_dart=True), | 618 'SVGElement': IDLTypeInfo('SVGElement', custom_to_dart=True), |
612 | 619 |
613 'SVGAngle': SVGTearOffIDLTypeInfo('SVGAngle'), | 620 'SVGAngle': SVGTearOffIDLTypeInfo('SVGAngle'), |
614 'SVGLength': SVGTearOffIDLTypeInfo('SVGLength'), | 621 'SVGLength': SVGTearOffIDLTypeInfo('SVGLength'), |
615 'SVGLengthList': SVGTearOffIDLTypeInfo('SVGLengthList', ref_counted=False), | 622 'SVGLengthList': SVGTearOffIDLTypeInfo('SVGLengthList', ref_counted=False), |
616 'SVGMatrix': SVGTearOffIDLTypeInfo('SVGMatrix'), | 623 'SVGMatrix': SVGTearOffIDLTypeInfo('SVGMatrix'), |
617 'SVGNumber': SVGTearOffIDLTypeInfo('SVGNumber', native_type='SVGPropertyTear Off<float>'), | 624 'SVGNumber': SVGTearOffIDLTypeInfo('SVGNumber', native_type='SVGPropertyTear Off<float>'), |
618 'SVGNumberList': SVGTearOffIDLTypeInfo('SVGNumberList', ref_counted=False), | 625 'SVGNumberList': SVGTearOffIDLTypeInfo('SVGNumberList', ref_counted=False), |
619 'SVGPathSegList': SVGTearOffIDLTypeInfo('SVGPathSegList', native_type='SVGPa thSegListPropertyTearOff', ref_counted=False), | 626 'SVGPathSegList': SVGTearOffIDLTypeInfo('SVGPathSegList', native_type='SVGPa thSegListPropertyTearOff', ref_counted=False), |
620 'SVGPoint': SVGTearOffIDLTypeInfo('SVGPoint', native_type='SVGPropertyTearOf f<FloatPoint>'), | 627 'SVGPoint': SVGTearOffIDLTypeInfo('SVGPoint', native_type='SVGPropertyTearOf f<FloatPoint>'), |
621 'SVGPointList': SVGTearOffIDLTypeInfo('SVGPointList', ref_counted=False), | 628 'SVGPointList': SVGTearOffIDLTypeInfo('SVGPointList', ref_counted=False), |
622 'SVGPreserveAspectRatio': SVGTearOffIDLTypeInfo('SVGPreserveAspectRatio'), | 629 'SVGPreserveAspectRatio': SVGTearOffIDLTypeInfo('SVGPreserveAspectRatio'), |
623 'SVGRect': SVGTearOffIDLTypeInfo('SVGRect', native_type='SVGPropertyTearOff< FloatRect>'), | 630 'SVGRect': SVGTearOffIDLTypeInfo('SVGRect', native_type='SVGPropertyTearOff< FloatRect>'), |
624 'SVGStringList': SVGTearOffIDLTypeInfo('SVGStringList', native_type='SVGStat icListPropertyTearOff<SVGStringList>', ref_counted=False), | 631 'SVGStringList': SVGTearOffIDLTypeInfo('SVGStringList', native_type='SVGStat icListPropertyTearOff<SVGStringList>', ref_counted=False), |
625 'SVGTransform': SVGTearOffIDLTypeInfo('SVGTransform'), | 632 'SVGTransform': SVGTearOffIDLTypeInfo('SVGTransform'), |
626 'SVGTransformList': SVGTearOffIDLTypeInfo('SVGTransformList', native_type='S VGTransformListPropertyTearOff', ref_counted=False) | 633 'SVGTransformList': SVGTearOffIDLTypeInfo('SVGTransformList', native_type='S VGTransformListPropertyTearOff', ref_counted=False) |
627 } | 634 } |
628 | 635 |
636 _svg_supplemental_includes = [ | |
637 'SVGAnimatedPropertyTearOff', | |
638 'SVGAnimatedListPropertyTearOff', | |
639 'SVGStaticListPropertyTearOff', | |
640 'SVGAnimatedListPropertyTearOff', | |
641 'SVGTransformListPropertyTearOff', | |
642 'SVGPathSegListPropertyTearOff', | |
643 ] | |
644 | |
629 def GetIDLTypeInfo(idl_type): | 645 def GetIDLTypeInfo(idl_type): |
630 return GetIDLTypeInfoByName(idl_type.id) | 646 return GetIDLTypeInfoByName(idl_type.id) |
631 | 647 |
632 def GetIDLTypeInfoByName(idl_type_name): | 648 def GetIDLTypeInfoByName(idl_type_name): |
633 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | 649 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) |
OLD | NEW |