| 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 copy | 9 import copy |
| 10 import re | 10 import re |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 dom_frog_native_bodies = { | 77 dom_frog_native_bodies = { |
| 78 # Some JavaScript processors, especially tools like yuicompress and | 78 # Some JavaScript processors, especially tools like yuicompress and |
| 79 # JSCompiler, choke on 'this.continue' | 79 # JSCompiler, choke on 'this.continue' |
| 80 'IDBCursor.continueFunction': | 80 'IDBCursor.continueFunction': |
| 81 """ | 81 """ |
| 82 if (key == null) return this['continue'](); | 82 if (key == null) return this['continue'](); |
| 83 return this['continue'](key); | 83 return this['continue'](key); |
| 84 """, | 84 """, |
| 85 } | 85 } |
| 86 | 86 |
| 87 def IsRegisteredType(type_name): | 87 def IsPrimitiveType(type_name): |
| 88 return type_name in _idl_type_registry | 88 if not type_name in _idl_type_registry: |
| 89 return False |
| 90 return _idl_type_registry[type_name].clazz == 'Primitive' |
| 89 | 91 |
| 90 def ListImplementationInfo(interface, database): | 92 def ListImplementationInfo(interface, database): |
| 91 """Returns a tuple (elment_type, requires_indexer). | 93 """Returns a tuple (elment_type, requires_indexer). |
| 92 If interface do not have to implement List, element_type is None. | 94 If interface do not have to implement List, element_type is None. |
| 93 Otherwise element_type is list element type and requires_indexer | 95 Otherwise element_type is list element type and requires_indexer |
| 94 is true iff this interface implementation must have indexer and | 96 is true iff this interface implementation must have indexer and |
| 95 false otherwise. False means that interface implementation | 97 false otherwise. False means that interface implementation |
| 96 inherits indexer and may just reuse it.""" | 98 inherits indexer and may just reuse it.""" |
| 97 element_type = MaybeListElementType(interface) | 99 element_type = MaybeListElementType(interface) |
| 98 if element_type: | 100 if element_type: |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>')
, | 781 'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>')
, |
| 780 'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True), | 782 'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True), |
| 781 'Element': TypeData(clazz='Interface', custom_to_dart=True), | 783 'Element': TypeData(clazz='Interface', custom_to_dart=True), |
| 782 'EventListener': TypeData(clazz='Interface', custom_to_native=True), | 784 'EventListener': TypeData(clazz='Interface', custom_to_native=True), |
| 783 'EventTarget': TypeData(clazz='Interface', custom_to_native=True), | 785 'EventTarget': TypeData(clazz='Interface', custom_to_native=True), |
| 784 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), | 786 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), |
| 785 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), | 787 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), |
| 786 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), | 788 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), |
| 787 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
t']), | 789 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
t']), |
| 788 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), | 790 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), |
| 789 'MutationRecordArray': TypeData(clazz='Interface', # C++ pass by pointer. | |
| 790 native_type='MutationRecordArray', | |
| 791 dart_type='List<MutationRecord>'), | |
| 792 | 791 |
| 793 'SVGAngle': TypeData(clazz='SVGTearOff'), | 792 'SVGAngle': TypeData(clazz='SVGTearOff'), |
| 794 'SVGLength': TypeData(clazz='SVGTearOff'), | 793 'SVGLength': TypeData(clazz='SVGTearOff'), |
| 795 'SVGLengthList': TypeData(clazz='SVGTearOff'), | 794 'SVGLengthList': TypeData(clazz='SVGTearOff'), |
| 796 'SVGMatrix': TypeData(clazz='SVGTearOff'), | 795 'SVGMatrix': TypeData(clazz='SVGTearOff'), |
| 797 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl
oat>'), | 796 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl
oat>'), |
| 798 'SVGNumberList': TypeData(clazz='SVGTearOff'), | 797 'SVGNumberList': TypeData(clazz='SVGTearOff'), |
| 799 'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr
opertyTearOff'), | 798 'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr
opertyTearOff'), |
| 800 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
atPoint>'), | 799 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
atPoint>'), |
| 801 'SVGPointList': TypeData(clazz='SVGTearOff'), | 800 'SVGPointList': TypeData(clazz='SVGTearOff'), |
| 802 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), | 801 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), |
| 803 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa
tRect>'), | 802 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa
tRect>'), |
| 804 'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp
ertyTearOff<SVGStringList>'), | 803 'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp
ertyTearOff<SVGStringList>'), |
| 805 'SVGTransform': TypeData(clazz='SVGTearOff'), | 804 'SVGTransform': TypeData(clazz='SVGTearOff'), |
| 806 'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi
stPropertyTearOff'), | 805 'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi
stPropertyTearOff') |
| 807 } | 806 } |
| 808 | 807 |
| 809 _svg_supplemental_includes = [ | 808 _svg_supplemental_includes = [ |
| 810 '"SVGAnimatedPropertyTearOff.h"', | 809 '"SVGAnimatedPropertyTearOff.h"', |
| 811 '"SVGAnimatedListPropertyTearOff.h"', | 810 '"SVGAnimatedListPropertyTearOff.h"', |
| 812 '"SVGStaticListPropertyTearOff.h"', | 811 '"SVGStaticListPropertyTearOff.h"', |
| 813 '"SVGAnimatedListPropertyTearOff.h"', | 812 '"SVGAnimatedListPropertyTearOff.h"', |
| 814 '"SVGTransformListPropertyTearOff.h"', | 813 '"SVGTransformListPropertyTearOff.h"', |
| 815 '"SVGPathSegListPropertyTearOff.h"', | 814 '"SVGPathSegListPropertyTearOff.h"', |
| 816 ] | 815 ] |
| (...skipping 23 matching lines...) Expand all Loading... |
| 840 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) | 839 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) |
| 841 if match: | 840 if match: |
| 842 if type_name == 'DOMString[]': | 841 if type_name == 'DOMString[]': |
| 843 return DOMStringArrayTypeInfo(self.TypeInfo('DOMString')) | 842 return DOMStringArrayTypeInfo(self.TypeInfo('DOMString')) |
| 844 return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc
h.group(2))) | 843 return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc
h.group(2))) |
| 845 if not type_name in _idl_type_registry: | 844 if not type_name in _idl_type_registry: |
| 846 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) | 845 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) |
| 847 type_data = _idl_type_registry.get(type_name) | 846 type_data = _idl_type_registry.get(type_name) |
| 848 class_name = '%sIDLTypeInfo' % type_data.clazz | 847 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 849 return globals()[class_name](type_name, type_data) | 848 return globals()[class_name](type_name, type_data) |
| OLD | NEW |