| 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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 return name if interface_name.endswith('List') else '%s->propertyReference()
' % name | 803 return name if interface_name.endswith('List') else '%s->propertyReference()
' % name |
| 804 | 804 |
| 805 | 805 |
| 806 class TypeData(object): | 806 class TypeData(object): |
| 807 def __init__(self, clazz, dart_type=None, native_type=None, | 807 def __init__(self, clazz, dart_type=None, native_type=None, |
| 808 custom_to_dart=None, custom_to_native=None, | 808 custom_to_dart=None, custom_to_native=None, |
| 809 conversion_includes=None, | 809 conversion_includes=None, |
| 810 webcore_getter_name='getAttribute', | 810 webcore_getter_name='getAttribute', |
| 811 webcore_setter_name='setAttribute', | 811 webcore_setter_name='setAttribute', |
| 812 requires_v8_scope=False, suppress_public_interface=False): | 812 requires_v8_scope=False, suppress_public_interface=False): |
| 813 """Constructor. | 813 """Constructor. |
| 814 Arguments: | 814 Arguments: |
| 815 - suppress_public_interface is True if we are converting a DOM type to a | 815 - suppress_public_interface is True if we are converting a DOM type to a |
| 816 built-in Dart type in which case we do not want to generate the new | 816 built-in Dart type in which case we do not want to generate the new |
| 817 interface in the library (FooList -> List<Foo> for example) but we still | 817 interface in the library (FooList -> List<Foo> for example) but we still |
| 818 generate the underlying implementation classes.""" | 818 generate the underlying implementation classes.""" |
| 819 self.clazz = clazz | 819 self.clazz = clazz |
| 820 self.dart_type = dart_type | 820 self.dart_type = dart_type |
| 821 self.native_type = native_type | 821 self.native_type = native_type |
| 822 self.custom_to_dart = custom_to_dart | 822 self.custom_to_dart = custom_to_dart |
| 823 self.custom_to_native = custom_to_native | 823 self.custom_to_native = custom_to_native |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 suppress_public_interface=True), | 901 suppress_public_interface=True), |
| 902 'GamepadList': TypeData(clazz='Interface', dart_type='List<Gamepad>', | 902 'GamepadList': TypeData(clazz='Interface', dart_type='List<Gamepad>', |
| 903 suppress_public_interface=True), | 903 suppress_public_interface=True), |
| 904 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), | 904 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), |
| 905 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), | 905 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), |
| 906 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), | 906 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
True), |
| 907 'MediaStreamList': TypeData(clazz='Interface', | 907 'MediaStreamList': TypeData(clazz='Interface', |
| 908 dart_type='List<MediaStream>', suppress_public_interface=True), | 908 dart_type='List<MediaStream>', suppress_public_interface=True), |
| 909 'MutationRecordArray': TypeData(clazz='Interface', # C++ pass by pointer. | 909 'MutationRecordArray': TypeData(clazz='Interface', # C++ pass by pointer. |
| 910 native_type='MutationRecordArray', dart_type='List<MutationRecord>'), | 910 native_type='MutationRecordArray', dart_type='List<MutationRecord>'), |
| 911 'NodeList': TypeData(clazz='Interface', dart_type='List<Node>', |
| 912 suppress_public_interface=False), |
| 911 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
t']), | 913 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
t']), |
| 912 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), | 914 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), |
| 913 'SVGElementInstanceList': TypeData(clazz='Interface', | 915 'SVGElementInstanceList': TypeData(clazz='Interface', |
| 914 dart_type='List<SVGElementInstance>', suppress_public_interface=True), | 916 dart_type='List<SVGElementInstance>', suppress_public_interface=True), |
| 915 'SpeechInputResultList': TypeData(clazz='Interface', | 917 'SpeechInputResultList': TypeData(clazz='Interface', |
| 916 dart_type='List<SpeechInputResult>', suppress_public_interface=True), | 918 dart_type='List<SpeechInputResult>', suppress_public_interface=True), |
| 917 'SpeechRecognitionResultList': TypeData(clazz='Interface', | 919 'SpeechRecognitionResultList': TypeData(clazz='Interface', |
| 918 dart_type='List<SpeechRecognitionResult>', | 920 dart_type='List<SpeechRecognitionResult>', |
| 919 suppress_public_interface=True), | 921 suppress_public_interface=True), |
| 920 'StyleSheetList': TypeData(clazz='Interface', | 922 'StyleSheetList': TypeData(clazz='Interface', |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 if match: | 984 if match: |
| 983 if type_name == 'DOMString[]': | 985 if type_name == 'DOMString[]': |
| 984 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) | 986 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) |
| 985 item_info = self.TypeInfo(match.group(1) or match.group(2)) | 987 item_info = self.TypeInfo(match.group(1) or match.group(2)) |
| 986 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) | 988 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) |
| 987 if not type_name in _idl_type_registry: | 989 if not type_name in _idl_type_registry: |
| 988 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) | 990 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) |
| 989 type_data = _idl_type_registry.get(type_name) | 991 type_data = _idl_type_registry.get(type_name) |
| 990 class_name = '%sIDLTypeInfo' % type_data.clazz | 992 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 991 return globals()[class_name](type_name, type_data) | 993 return globals()[class_name](type_name, type_data) |
| OLD | NEW |