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 | 16 |
16 _logger = logging.getLogger('dartgenerator') | 17 _logger = logging.getLogger('dartgenerator') |
17 | 18 |
18 def MergeNodes(node, other): | 19 def MergeNodes(node, other): |
19 node.operations.extend(other.operations) | 20 node.operations.extend(other.operations) |
20 for attribute in other.attributes: | 21 for attribute in other.attributes: |
21 if not node.has_attribute(attribute): | 22 if not node.has_attribute(attribute): |
22 node.attributes.append(attribute) | 23 node.attributes.append(attribute) |
23 | 24 |
24 node.constants.extend(other.constants) | 25 node.constants.extend(other.constants) |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if not(isinstance(call_with, list)): | 239 if not(isinstance(call_with, list)): |
239 call_with = [call_with] | 240 call_with = [call_with] |
240 constructor_with = operation.ext_attrs.get('ConstructorCallWith', []) | 241 constructor_with = operation.ext_attrs.get('ConstructorCallWith', []) |
241 if not(isinstance(constructor_with, list)): | 242 if not(isinstance(constructor_with, list)): |
242 constructor_with = [constructor_with] | 243 constructor_with = [constructor_with] |
243 call_with = call_with + constructor_with | 244 call_with = call_with + constructor_with |
244 | 245 |
245 if 'ScriptArguments' in call_with: | 246 if 'ScriptArguments' in call_with: |
246 operation.arguments.append(ARG) | 247 operation.arguments.append(ARG) |
247 | 248 |
248 # TODO(terry): Hack to remove 3rd arguments in setInterval/setTimeout. | 249 def CleanupOperationArguments(self, database): |
249 def HackCleanupTimers(self, database): | |
250 for interface in database.GetInterfaces(): | 250 for interface in database.GetInterfaces(): |
251 for operation in interface.operations: | 251 for operation in interface.operations: |
| 252 # TODO(terry): Hack to remove 3rd arguments in setInterval/setTimeout. |
252 if ((operation.id == 'setInterval' or operation.id == 'setTimeout') and
\ | 253 if ((operation.id == 'setInterval' or operation.id == 'setTimeout') and
\ |
253 operation.arguments[0].type.id == 'any'): | 254 operation.arguments[0].type.id == 'any'): |
254 operation.arguments.pop(2) | 255 operation.arguments.pop(2) |
| 256 |
| 257 # Massage any operation argument type that is IDLEnum to String. |
| 258 for index, argument in enumerate(operation.arguments): |
| 259 type_name = argument.type.id |
| 260 if database.HasEnum(type_name): |
| 261 operation.arguments[index].type = IDLType('DOMString') |
| 262 |
OLD | NEW |