| 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 provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import copy | 9 import copy |
| 10 import json | 10 import json |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 # Nodes with different tags in different browsers can be listed as multiple | 107 # Nodes with different tags in different browsers can be listed as multiple |
| 108 # tags here provided there is not conflict in usage (e.g. browser X has tag | 108 # tags here provided there is not conflict in usage (e.g. browser X has tag |
| 109 # T and no other browser has tag T). | 109 # T and no other browser has tag T). |
| 110 | 110 |
| 111 'AnalyserNode': 'AnalyserNode,RealtimeAnalyserNode', | 111 'AnalyserNode': 'AnalyserNode,RealtimeAnalyserNode', |
| 112 'AudioContext': 'AudioContext,webkitAudioContext', | 112 'AudioContext': 'AudioContext,webkitAudioContext', |
| 113 | 113 |
| 114 'ChannelMergerNode': 'ChannelMergerNode,AudioChannelMerger', | 114 'ChannelMergerNode': 'ChannelMergerNode,AudioChannelMerger', |
| 115 'ChannelSplitterNode': 'ChannelSplitterNode,AudioChannelSplitter', | 115 'ChannelSplitterNode': 'ChannelSplitterNode,AudioChannelSplitter', |
| 116 | 116 |
| 117 'ClientRect': 'ClientRect,DOMRect', | |
| 118 'ClientRectList': 'ClientRectList,DOMRectList', | 117 'ClientRectList': 'ClientRectList,DOMRectList', |
| 119 | 118 |
| 120 'CSSStyleDeclaration': | 119 'CSSStyleDeclaration': |
| 121 # IE Firefox | 120 # IE Firefox |
| 122 'CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties', | 121 'CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties', |
| 123 | 122 |
| 124 'Clipboard': 'Clipboard,DataTransfer', | 123 'Clipboard': 'Clipboard,DataTransfer', |
| 125 | 124 |
| 126 'ApplicationCache': | 125 'ApplicationCache': |
| 127 'ApplicationCache,DOMApplicationCache,OfflineResourceList', | 126 'ApplicationCache,DOMApplicationCache,OfflineResourceList', |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return argument.optional | 231 return argument.optional |
| 233 if 'DartForceOptional' in argument.ext_attrs: | 232 if 'DartForceOptional' in argument.ext_attrs: |
| 234 return True | 233 return True |
| 235 return False | 234 return False |
| 236 | 235 |
| 237 # Given a list of overloaded arguments, choose a suitable name. | 236 # Given a list of overloaded arguments, choose a suitable name. |
| 238 def OverloadedName(args): | 237 def OverloadedName(args): |
| 239 return '_OR_'.join(sorted(set(arg.id for arg in args))) | 238 return '_OR_'.join(sorted(set(arg.id for arg in args))) |
| 240 | 239 |
| 241 def DartType(idl_type_name): | 240 def DartType(idl_type_name): |
| 242 if idl_type_name in _idl_type_registry: | 241 if idl_type_name in _idl_type_registry: |
| 243 return _idl_type_registry[idl_type_name].dart_type or idl_type_name | 242 return _idl_type_registry[idl_type_name].dart_type or idl_type_name |
| 244 return idl_type_name | 243 return idl_type_name |
| 245 | 244 |
| 246 # Given a list of overloaded arguments, choose a suitable type. | 245 # Given a list of overloaded arguments, choose a suitable type. |
| 247 def OverloadedType(args): | 246 def OverloadedType(args): |
| 248 type_ids = sorted(set(arg.type.id for arg in args)) | 247 type_ids = sorted(set(arg.type.id for arg in args)) |
| 249 if len(set(DartType(arg.type.id) for arg in args)) == 1: | 248 if len(set(DartType(arg.type.id) for arg in args)) == 1: |
| 250 return type_ids[0] | 249 return type_ids[0] |
| 251 else: | 250 else: |
| 252 return None | 251 return None |
| 253 | 252 |
| 254 result = [] | 253 result = [] |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 dart_type = rename_type(param.type_id) if param.type_id else 'dynamic' | 442 dart_type = rename_type(param.type_id) if param.type_id else 'dynamic' |
| 444 return (TypeOrNothing(dart_type, param.type_id), param.name) | 443 return (TypeOrNothing(dart_type, param.type_id), param.name) |
| 445 required = [] | 444 required = [] |
| 446 optional = [] | 445 optional = [] |
| 447 for param_info in self.param_infos: | 446 for param_info in self.param_infos: |
| 448 if param_info.is_optional: | 447 if param_info.is_optional: |
| 449 optional.append(FormatParam(param_info)) | 448 optional.append(FormatParam(param_info)) |
| 450 else: | 449 else: |
| 451 if optional: | 450 if optional: |
| 452 raise Exception('Optional parameters cannot precede required ones: ' | 451 raise Exception('Optional parameters cannot precede required ones: ' |
| 453 + str(params)) | 452 + str(param_info)) |
| 454 required.append(FormatParam(param_info)) | 453 required.append(FormatParam(param_info)) |
| 455 needs_named = optional and self.requires_named_arguments and not force_optio
nal | 454 needs_named = optional and self.requires_named_arguments and not force_optio
nal |
| 456 return (required, optional, needs_named) | 455 return (required, optional, needs_named) |
| 457 | 456 |
| 458 def ParametersAsDecStringList(self, rename_type, force_optional=False): | 457 def ParametersAsDecStringList(self, rename_type, force_optional=False): |
| 459 """Returns a list of strings where each string corresponds to a parameter | 458 """Returns a list of strings where each string corresponds to a parameter |
| 460 declaration. All of the optional/named parameters if any will appear as | 459 declaration. All of the optional/named parameters if any will appear as |
| 461 a single entry at the end of the list. | 460 a single entry at the end of the list. |
| 462 """ | 461 """ |
| 463 (required, optional, needs_named) = \ | 462 (required, optional, needs_named) = \ |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 if type_data.clazz == 'BasicTypedList': | 1322 if type_data.clazz == 'BasicTypedList': |
| 1324 if type_name == 'ArrayBuffer': | 1323 if type_name == 'ArrayBuffer': |
| 1325 dart_interface_name = 'ByteBuffer' | 1324 dart_interface_name = 'ByteBuffer' |
| 1326 else: | 1325 else: |
| 1327 dart_interface_name = self._renamer.RenameInterfaceId(type_name) | 1326 dart_interface_name = self._renamer.RenameInterfaceId(type_name) |
| 1328 return BasicTypedListIDLTypeInfo( | 1327 return BasicTypedListIDLTypeInfo( |
| 1329 type_name, type_data, dart_interface_name, self) | 1328 type_name, type_data, dart_interface_name, self) |
| 1330 | 1329 |
| 1331 class_name = '%sIDLTypeInfo' % type_data.clazz | 1330 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1332 return globals()[class_name](type_name, type_data) | 1331 return globals()[class_name](type_name, type_data) |
| OLD | NEW |