| 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 29 matching lines...) Expand all Loading... |
| 40 if type_name.endswith('?'): | 40 if type_name.endswith('?'): |
| 41 return self._IsCompoundType(database, type_name[:-len('?')]) | 41 return self._IsCompoundType(database, type_name[:-len('?')]) |
| 42 | 42 |
| 43 if type_name.endswith('[]'): | 43 if type_name.endswith('[]'): |
| 44 return self._IsCompoundType(database, type_name[:-len('[]')]) | 44 return self._IsCompoundType(database, type_name[:-len('[]')]) |
| 45 | 45 |
| 46 stripped_type_name = self._StripModules(type_name) | 46 stripped_type_name = self._StripModules(type_name) |
| 47 if database.HasInterface(stripped_type_name): | 47 if database.HasInterface(stripped_type_name): |
| 48 return True | 48 return True |
| 49 | 49 |
| 50 if database.HasEnum(stripped_type_name): |
| 51 return True |
| 52 |
| 50 dart_template_match = self._dart_templates_re.match(type_name) | 53 dart_template_match = self._dart_templates_re.match(type_name) |
| 51 if dart_template_match: | 54 if dart_template_match: |
| 52 # Dart templates | 55 # Dart templates |
| 53 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] | 56 parent_type_name = type_name[0 : dart_template_match.start(1) - 1] |
| 54 sub_type_name = dart_template_match.group(1) | 57 sub_type_name = dart_template_match.group(1) |
| 55 return (self._IsCompoundType(database, parent_type_name) and | 58 return (self._IsCompoundType(database, parent_type_name) and |
| 56 self._IsCompoundType(database, sub_type_name)) | 59 self._IsCompoundType(database, sub_type_name)) |
| 57 return False | 60 return False |
| 58 | 61 |
| 59 def _IsDartType(self, type_name): | 62 def _IsDartType(self, type_name): |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ast = [('Annotation', [('Id', 'WebKit')]), | 224 ast = [('Annotation', [('Id', 'WebKit')]), |
| 222 ('InterfaceType', ('ScopedName', 'EventTarget'))] | 225 ('InterfaceType', ('ScopedName', 'EventTarget'))] |
| 223 interface.parents.append(idlnode.IDLParentInterface(ast)) | 226 interface.parents.append(idlnode.IDLParentInterface(ast)) |
| 224 | 227 |
| 225 def AddMissingArguments(self, database): | 228 def AddMissingArguments(self, database): |
| 226 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) | 229 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'object')), ('Id', 'arg')
]) |
| 227 for interface in database.GetInterfaces(): | 230 for interface in database.GetInterfaces(): |
| 228 for operation in interface.operations: | 231 for operation in interface.operations: |
| 229 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|ScriptState': | 232 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|ScriptState': |
| 230 operation.arguments.append(ARG) | 233 operation.arguments.append(ARG) |
| OLD | NEW |