| 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 27 matching lines...) Expand all Loading... |
| 38 if IsRegisteredType(type_name): | 38 if IsRegisteredType(type_name): |
| 39 return True | 39 return True |
| 40 | 40 |
| 41 if type_name.endswith('?'): | 41 if type_name.endswith('?'): |
| 42 return self._IsCompoundType(database, type_name[:-len('?')]) | 42 return self._IsCompoundType(database, type_name[:-len('?')]) |
| 43 | 43 |
| 44 if type_name.endswith('[]'): | 44 if type_name.endswith('[]'): |
| 45 return self._IsCompoundType(database, type_name[:-len('[]')]) | 45 return self._IsCompoundType(database, type_name[:-len('[]')]) |
| 46 | 46 |
| 47 stripped_type_name = self._StripModules(type_name) | 47 stripped_type_name = self._StripModules(type_name) |
| 48 if database.HasInterface(stripped_type_name): | 48 if (database.HasInterface(stripped_type_name) or |
| 49 database.HasDictionary(stripped_type_name)): |
| 49 return True | 50 return True |
| 50 | 51 |
| 51 if database.HasEnum(stripped_type_name): | 52 if database.HasEnum(stripped_type_name): |
| 52 return True | 53 return True |
| 53 | 54 |
| 54 dart_template_match = self._dart_templates_re.match(type_name) | 55 dart_template_match = self._dart_templates_re.match(type_name) |
| 55 if dart_template_match: | 56 if dart_template_match: |
| 56 # Dart templates | 57 # Dart templates |
| 57 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] | 58 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] |
| 58 sub_type_name = dart_template_match.group(1) | 59 sub_type_name = dart_template_match.group(1) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 # Create fake EventTarget parent interface for interfaces that have | 223 # Create fake EventTarget parent interface for interfaces that have |
| 223 # 'EventTarget' extended attribute. | 224 # 'EventTarget' extended attribute. |
| 224 ast = [('Annotation', [('Id', 'WebKit')]), | 225 ast = [('Annotation', [('Id', 'WebKit')]), |
| 225 ('InterfaceType', ('ScopedName', 'EventTarget'))] | 226 ('InterfaceType', ('ScopedName', 'EventTarget'))] |
| 226 interface.parents.append(idlnode.IDLParentInterface(ast)) | 227 interface.parents.append(idlnode.IDLParentInterface(ast)) |
| 227 | 228 |
| 228 def AddMissingArguments(self, database): | 229 def AddMissingArguments(self, database): |
| 229 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) | 230 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) |
| 230 for interface in database.GetInterfaces(): | 231 for interface in database.GetInterfaces(): |
| 231 for operation in interface.operations: | 232 for operation in interface.operations: |
| 232 call_with = (operation.ext_attrs.get('CallWith', '') + | 233 call_with = operation.ext_attrs.get('CallWith', []) |
| 233 operation.ext_attrs.get('ConstructorCallWith', '')) | 234 if not(isinstance(call_with, list)): |
| 235 call_with = [call_with] |
| 236 constructor_with = operation.ext_attrs.get('ConstructorCallWith', []) |
| 237 if not(isinstance(constructor_with, list)): |
| 238 constructor_with = [constructor_with] |
| 239 call_with = call_with + constructor_with |
| 240 |
| 234 if 'ScriptArguments' in call_with: | 241 if 'ScriptArguments' in call_with: |
| 235 operation.arguments.append(ARG) | 242 operation.arguments.append(ARG) |
| OLD | NEW |