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 |
11 import os | 11 import os |
12 import re | 12 import re |
13 import shutil | 13 import shutil |
14 from generator import * | 14 from generator import * |
15 from idlnode import IDLType | 15 from idlnode import IDLType, resolveTypedef |
16 | 16 |
17 _logger = logging.getLogger('dartgenerator') | 17 _logger = logging.getLogger('dartgenerator') |
18 | 18 |
19 def MergeNodes(node, other): | 19 def MergeNodes(node, other): |
20 node.operations.extend(other.operations) | 20 node.operations.extend(other.operations) |
21 for attribute in other.attributes: | 21 for attribute in other.attributes: |
22 if not node.has_attribute(attribute): | 22 if not node.has_attribute(attribute): |
23 node.attributes.append(attribute) | 23 node.attributes.append(attribute) |
24 | 24 |
25 node.constants.extend(other.constants) | 25 node.constants.extend(other.constants) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 type_name = idl_type.id | 91 type_name = idl_type.id |
92 if (type_name is not None and | 92 if (type_name is not None and |
93 self._IsCompoundType(database, type_name)): | 93 self._IsCompoundType(database, type_name)): |
94 continue | 94 continue |
95 # Ignore constructor warnings. | 95 # Ignore constructor warnings. |
96 if not (interface.id in ['Window', 'WorkerContext', | 96 if not (interface.id in ['Window', 'WorkerContext', |
97 'WorkerGlobalScope'] and | 97 'WorkerGlobalScope'] and |
98 type_name.endswith('Constructor')): | 98 type_name.endswith('Constructor')): |
99 _logger.warn('removing %s in %s which has unidentified type %s' % | 99 _logger.warn('removing %s in %s which has unidentified type %s' % |
100 (node_name, interface.id, type_name)) | 100 (node_name, interface.id, type_name)) |
| 101 |
| 102 # One last check is the type a typedef in an IDL file (the typedefs |
| 103 # are treated as global). |
| 104 resolvedType = resolveTypedef(idl_type) |
| 105 if (resolvedType != idl_type): |
| 106 idl_type.id = resolvedType.id |
| 107 idl_type.nullable = resolvedType.nullable |
| 108 continue |
| 109 |
101 return False | 110 return False |
102 return True | 111 return True |
103 | 112 |
104 interface.constants = filter(IsIdentified, interface.constants) | 113 interface.constants = filter(IsIdentified, interface.constants) |
105 interface.attributes = filter(IsIdentified, interface.attributes) | 114 interface.attributes = filter(IsIdentified, interface.attributes) |
106 interface.operations = filter(IsIdentified, interface.operations) | 115 interface.operations = filter(IsIdentified, interface.operations) |
107 interface.parents = filter(IsIdentified, interface.parents) | 116 interface.parents = filter(IsIdentified, interface.parents) |
108 | 117 |
109 def FilterInterfaces(self, database, | 118 def FilterInterfaces(self, database, |
110 and_annotations=[], | 119 and_annotations=[], |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 if ((operation.id == 'setInterval' or operation.id == 'setTimeout') and
\ | 262 if ((operation.id == 'setInterval' or operation.id == 'setTimeout') and
\ |
254 operation.arguments[0].type.id == 'any'): | 263 operation.arguments[0].type.id == 'any'): |
255 operation.arguments.pop(2) | 264 operation.arguments.pop(2) |
256 | 265 |
257 # Massage any operation argument type that is IDLEnum to String. | 266 # Massage any operation argument type that is IDLEnum to String. |
258 for index, argument in enumerate(operation.arguments): | 267 for index, argument in enumerate(operation.arguments): |
259 type_name = argument.type.id | 268 type_name = argument.type.id |
260 if database.HasEnum(type_name): | 269 if database.HasEnum(type_name): |
261 operation.arguments[index].type = IDLType('DOMString') | 270 operation.arguments[index].type = IDLType('DOMString') |
262 | 271 |
OLD | NEW |