| 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 json | 10 import json |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 def merged_into(self): | 954 def merged_into(self): |
| 955 return None | 955 return None |
| 956 | 956 |
| 957 def native_type(self): | 957 def native_type(self): |
| 958 return self._data.native_type or self._idl_type | 958 return self._data.native_type or self._idl_type |
| 959 | 959 |
| 960 def bindings_class(self): | 960 def bindings_class(self): |
| 961 return 'Dart%s' % self.idl_type() | 961 return 'Dart%s' % self.idl_type() |
| 962 | 962 |
| 963 def vector_to_dart_template_parameter(self): | 963 def vector_to_dart_template_parameter(self): |
| 964 return self.bindings_class() | 964 return self.native_type() |
| 965 | 965 |
| 966 def to_native_info(self, idl_node, interface_name): | 966 def to_native_info(self, idl_node, interface_name): |
| 967 cls = self.bindings_class() | 967 cls = self.bindings_class() |
| 968 | 968 |
| 969 if 'Callback' in idl_node.ext_attrs: | 969 if 'Callback' in idl_node.ext_attrs: |
| 970 return '%s', 'RefPtr<%s>' % self.native_type(), cls, 'create' | 970 return '%s', 'RefPtr<%s>' % self.native_type(), cls, 'create' |
| 971 | 971 |
| 972 if self.custom_to_native(): | 972 if self.custom_to_native(): |
| 973 type = 'RefPtr<%s>' % self.native_type() | 973 type = 'RefPtr<%s>' % self.native_type() |
| 974 argument_expression_template = '%s.get()' | 974 argument_expression_template = '%s.get()' |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 return self.dart_type() | 1113 return self.dart_type() |
| 1114 | 1114 |
| 1115 def implementation_name(self): | 1115 def implementation_name(self): |
| 1116 return self.dart_type() | 1116 return self.dart_type() |
| 1117 | 1117 |
| 1118 def vector_to_dart_template_parameter(self): | 1118 def vector_to_dart_template_parameter(self): |
| 1119 raise Exception('sequences of sequences are not supported yet') | 1119 raise Exception('sequences of sequences are not supported yet') |
| 1120 | 1120 |
| 1121 def to_native_info(self, idl_node, interface_name): | 1121 def to_native_info(self, idl_node, interface_name): |
| 1122 item_native_type = self._item_info.vector_to_dart_template_parameter() | 1122 item_native_type = self._item_info.vector_to_dart_template_parameter() |
| 1123 return '%s', 'Vector<%s>' % item_native_type, 'DartUtilities', 'toNativeVect
or<%s>' % item_native_type | 1123 if isinstance(self._item_info, PrimitiveIDLTypeInfo): |
| 1124 return '%s', 'Vector<%s>' % item_native_type, 'DartUtilities', 'toNativeVe
ctor<%s>' % item_native_type |
| 1125 return '%s', 'Vector< RefPtr<%s> >' % item_native_type, 'DartUtilities', 'to
NativeVector< RefPtr<%s> >' % item_native_type |
| 1124 | 1126 |
| 1125 def pass_native_by_ref(self): return True | 1127 def pass_native_by_ref(self): return True |
| 1126 | 1128 |
| 1127 def to_dart_conversion(self, value, interface_name=None, attributes=None): | 1129 def to_dart_conversion(self, value, interface_name=None, attributes=None): |
| 1128 return 'DartDOMWrapper::vectorToDart<%s>(%s)' % (self._item_info.vector_to_d
art_template_parameter(), value) | 1130 if isinstance(self._item_info, PrimitiveIDLTypeInfo): |
| 1131 return 'DartDOMWrapper::vectorToDart(%s)' % value |
| 1132 return 'DartDOMWrapper::vectorToDart<%s>(%s)' % (self._item_info.bindings_cl
ass(), value) |
| 1129 | 1133 |
| 1130 def conversion_includes(self): | 1134 def conversion_includes(self): |
| 1131 return self._item_info.conversion_includes() | 1135 return self._item_info.conversion_includes() |
| 1132 | 1136 |
| 1133 | 1137 |
| 1134 class DOMStringArrayTypeInfo(SequenceIDLTypeInfo): | 1138 class DOMStringArrayTypeInfo(SequenceIDLTypeInfo): |
| 1135 def __init__(self, data, item_info): | 1139 def __init__(self, data, item_info): |
| 1136 super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', data, item_info) | 1140 super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', data, item_info) |
| 1137 | 1141 |
| 1138 def to_native_info(self, idl_node, interface_name): | 1142 def to_native_info(self, idl_node, interface_name): |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 self) | 1448 self) |
| 1445 | 1449 |
| 1446 if type_data.clazz == 'SVGTearOff': | 1450 if type_data.clazz == 'SVGTearOff': |
| 1447 dart_interface_name = self._renamer.RenameInterface( | 1451 dart_interface_name = self._renamer.RenameInterface( |
| 1448 self._database.GetInterface(type_name)) | 1452 self._database.GetInterface(type_name)) |
| 1449 return SVGTearOffIDLTypeInfo( | 1453 return SVGTearOffIDLTypeInfo( |
| 1450 type_name, type_data, dart_interface_name, self) | 1454 type_name, type_data, dart_interface_name, self) |
| 1451 | 1455 |
| 1452 class_name = '%sIDLTypeInfo' % type_data.clazz | 1456 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1453 return globals()[class_name](type_name, type_data) | 1457 return globals()[class_name](type_name, type_data) |
| OLD | NEW |