| 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 generates Dart APIs from the IDL database.""" | 6 """This module generates Dart APIs from the IDL database.""" |
| 7 | 7 |
| 8 import emitter | 8 import emitter |
| 9 import idlnode | 9 import idlnode |
| 10 import logging | 10 import logging |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 _logger.warn('removing %s in %s which has unidentified type %s' % | 135 _logger.warn('removing %s in %s which has unidentified type %s' % |
| 136 (node_name, interface.id, type_name)) | 136 (node_name, interface.id, type_name)) |
| 137 return False | 137 return False |
| 138 return True | 138 return True |
| 139 | 139 |
| 140 interface.constants = filter(IsIdentified, interface.constants) | 140 interface.constants = filter(IsIdentified, interface.constants) |
| 141 interface.attributes = filter(IsIdentified, interface.attributes) | 141 interface.attributes = filter(IsIdentified, interface.attributes) |
| 142 interface.operations = filter(IsIdentified, interface.operations) | 142 interface.operations = filter(IsIdentified, interface.operations) |
| 143 interface.parents = filter(IsIdentified, interface.parents) | 143 interface.parents = filter(IsIdentified, interface.parents) |
| 144 | 144 |
| 145 def ConvertToDartTypes(self, database): | |
| 146 """Converts all IDL types to Dart primitives or qualified types""" | |
| 147 | |
| 148 def ConvertType(interface, type_name): | |
| 149 """Helper method for converting a type name to the proper | |
| 150 Dart name""" | |
| 151 if IsPrimitiveType(type_name): | |
| 152 return ConvertPrimitiveType(type_name) | |
| 153 | |
| 154 if self._IsDartType(type_name): | |
| 155 # This is for when dart qualified names are explicitly | |
| 156 # defined in the IDLs. Just let them be. | |
| 157 return type_name | |
| 158 | |
| 159 dart_template_match = self._dart_templates_re.match(type_name) | |
| 160 if dart_template_match: | |
| 161 # Dart templates | |
| 162 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] | |
| 163 sub_type_name = dart_template_match.group(1) | |
| 164 return '%s<%s>' % (ConvertType(interface, parent_type_name), | |
| 165 ConvertType(interface, sub_type_name)) | |
| 166 | |
| 167 return self._StripModules(type_name) | |
| 168 | |
| 169 for interface in database.GetInterfaces(): | |
| 170 for idl_type in interface.all(idlnode.IDLType): | |
| 171 original_type_name = idl_type.id | |
| 172 idl_type.id = ConvertType(interface, idl_type.id) | |
| 173 # FIXME: remember original idl types that are needed by native | |
| 174 # generator. We should migrate other generators to idl registry and | |
| 175 # remove this hack. | |
| 176 if original_type_name != idl_type.id: | |
| 177 original_idl_types[idl_type] = original_type_name | |
| 178 | |
| 179 def FilterInterfaces(self, database, | 145 def FilterInterfaces(self, database, |
| 180 and_annotations=[], | 146 and_annotations=[], |
| 181 or_annotations=[], | 147 or_annotations=[], |
| 182 exclude_displaced=[], | 148 exclude_displaced=[], |
| 183 exclude_suppressed=[]): | 149 exclude_suppressed=[]): |
| 184 """Filters a database to remove interfaces and members that are missing | 150 """Filters a database to remove interfaces and members that are missing |
| 185 annotations. | 151 annotations. |
| 186 | 152 |
| 187 The FremontCut IDLs use annotations to specify implementation | 153 The FremontCut IDLs use annotations to specify implementation |
| 188 status in various platforms. For example, if a member is annotated | 154 status in various platforms. For example, if a member is annotated |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 pass | 665 pass |
| 700 | 666 |
| 701 def AddTypedArrayConstructors(self, element_type): | 667 def AddTypedArrayConstructors(self, element_type): |
| 702 pass | 668 pass |
| 703 | 669 |
| 704 def AddOperation(self, info): | 670 def AddOperation(self, info): |
| 705 pass | 671 pass |
| 706 | 672 |
| 707 def AddEventAttributes(self, event_attrs): | 673 def AddEventAttributes(self, event_attrs): |
| 708 pass | 674 pass |
| OLD | NEW |