| 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 |
| 11 import monitored | 11 import monitored |
| 12 import os | 12 import os |
| 13 import re | 13 import re |
| 14 from htmlrenamer import custom_html_constructors, html_interface_renames, \ | 14 from htmlrenamer import custom_html_constructors, html_interface_renames, \ |
| 15 typed_array_renames | 15 typed_array_renames |
| 16 | 16 |
| 17 _pure_interfaces = monitored.Set('generator._pure_interfaces', [ | 17 _pure_interfaces = monitored.Set('generator._pure_interfaces', [ |
| 18 # TODO(sra): DOMStringMap should be a class implementing Map<String,String>. | 18 # TODO(sra): DOMStringMap should be a class implementing Map<String,String>. |
| 19 'DOMStringMap', | 19 'DOMStringMap', |
| 20 'ChildNode', | 20 'ChildNode', |
| 21 'EventListener', | 21 'EventListener', |
| 22 'GlobalEventHandlers', |
| 22 'MediaQueryListListener', | 23 'MediaQueryListListener', |
| 23 'MutationCallback', | 24 'MutationCallback', |
| 24 'NavigatorID', | 25 'NavigatorID', |
| 25 'NavigatorOnLine', | 26 'NavigatorOnLine', |
| 26 'ParentNode', | 27 'ParentNode', |
| 27 'SVGExternalResourcesRequired', | 28 'SVGExternalResourcesRequired', |
| 28 'SVGFilterPrimitiveStandardAttributes', | 29 'SVGFilterPrimitiveStandardAttributes', |
| 29 'SVGFitToViewBox', | 30 'SVGFitToViewBox', |
| 30 'SVGTests', | 31 'SVGTests', |
| 31 'SVGURIReference', | 32 'SVGURIReference', |
| 32 'SVGZoomAndPan', | 33 'SVGZoomAndPan', |
| 33 'TimeoutHandler', | 34 'TimeoutHandler', |
| 35 'URLUtils', |
| 36 'URLUtilsReadOnly', |
| 34 'WindowBase64', | 37 'WindowBase64', |
| 38 'WindowEventHandlers', |
| 35 'WindowTimers', | 39 'WindowTimers', |
| 36 ]) | 40 ]) |
| 37 | 41 |
| 38 def IsPureInterface(interface_name): | 42 def IsPureInterface(interface_name): |
| 39 return interface_name in _pure_interfaces | 43 return interface_name in _pure_interfaces |
| 40 | 44 |
| 41 # | 45 # |
| 42 # Classes which have native constructors but which we are suppressing because | 46 # Classes which have native constructors but which we are suppressing because |
| 43 # they are not cross-platform. | 47 # they are not cross-platform. |
| 44 # | 48 # |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 def __repr__(self): | 191 def __repr__(self): |
| 188 content = 'name = %s, type_id = %s, is_optional = %s' % ( | 192 content = 'name = %s, type_id = %s, is_optional = %s' % ( |
| 189 self.name, self.type_id, self.is_optional) | 193 self.name, self.type_id, self.is_optional) |
| 190 return '<ParamInfo(%s)>' % content | 194 return '<ParamInfo(%s)>' % content |
| 191 | 195 |
| 192 def GetCallbackInfo(interface): | 196 def GetCallbackInfo(interface): |
| 193 """For the given interface, find operations that take callbacks (for use in | 197 """For the given interface, find operations that take callbacks (for use in |
| 194 auto-transforming callbacks into futures).""" | 198 auto-transforming callbacks into futures).""" |
| 195 callback_handlers = [operation for operation in interface.operations | 199 callback_handlers = [operation for operation in interface.operations |
| 196 if operation.id == 'handleEvent'] | 200 if operation.id == 'handleEvent'] |
| 201 if callback_handlers == []: |
| 202 callback_handlers = [operation for operation in interface.operations |
| 203 if operation.id == 'handleItem'] |
| 197 return AnalyzeOperation(interface, callback_handlers) | 204 return AnalyzeOperation(interface, callback_handlers) |
| 198 | 205 |
| 199 # Given a list of overloaded arguments, render dart arguments. | 206 # Given a list of overloaded arguments, render dart arguments. |
| 200 def _BuildArguments(args, interface, constructor=False): | 207 def _BuildArguments(args, interface, constructor=False): |
| 201 def IsOptional(argument): | 208 def IsOptional(argument): |
| 202 if 'Callback' in argument.ext_attrs: | 209 if 'Callback' in argument.ext_attrs: |
| 203 # Optional callbacks arguments are treated as optional arguments. | 210 # Optional callbacks arguments are treated as optional arguments. |
| 204 return argument.optional | 211 return argument.optional |
| 205 if constructor: | 212 if constructor: |
| 206 # FIXME: Optional constructors arguments should not be treated as | 213 # FIXME: Optional constructors arguments should not be treated as |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 'SVGLength': TypeData(clazz='SVGTearOff'), | 1172 'SVGLength': TypeData(clazz='SVGTearOff'), |
| 1166 'SVGLengthList': TypeData(clazz='SVGTearOff', item_type='SVGLength'), | 1173 'SVGLengthList': TypeData(clazz='SVGTearOff', item_type='SVGLength'), |
| 1167 'SVGMatrix': TypeData(clazz='SVGTearOff'), | 1174 'SVGMatrix': TypeData(clazz='SVGTearOff'), |
| 1168 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<SV
GNumber>'), | 1175 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<SV
GNumber>'), |
| 1169 'SVGNumberList': TypeData(clazz='SVGTearOff', item_type='SVGNumber'), | 1176 'SVGNumberList': TypeData(clazz='SVGTearOff', item_type='SVGNumber'), |
| 1170 'SVGPathSegList': TypeData(clazz='SVGTearOff', item_type='SVGPathSeg', | 1177 'SVGPathSegList': TypeData(clazz='SVGTearOff', item_type='SVGPathSeg', |
| 1171 native_type='SVGPathSegListPropertyTearOff'), | 1178 native_type='SVGPathSegListPropertyTearOff'), |
| 1172 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
atPoint>'), | 1179 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
atPoint>'), |
| 1173 'SVGPointList': TypeData(clazz='SVGTearOff'), | 1180 'SVGPointList': TypeData(clazz='SVGTearOff'), |
| 1174 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), | 1181 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), |
| 1175 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa
tRect>'), | 1182 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<SVGR
ect>'), |
| 1176 'SVGStringList': TypeData(clazz='SVGTearOff', item_type='DOMString', | 1183 'SVGStringList': TypeData(clazz='SVGTearOff', item_type='DOMString', |
| 1177 native_type='SVGStaticListPropertyTearOff<SVGStringList>'), | 1184 native_type='SVGStaticListPropertyTearOff<SVGStringList>'), |
| 1178 'SVGTransform': TypeData(clazz='SVGTearOff'), | 1185 'SVGTransform': TypeData(clazz='SVGTearOff'), |
| 1179 'SVGTransformList': TypeData(clazz='SVGTearOff', item_type='SVGTransform', | 1186 'SVGTransformList': TypeData(clazz='SVGTearOff', item_type='SVGTransform', |
| 1180 native_type='SVGTransformListPropertyTearOff'), | 1187 native_type='SVGTransformListPropertyTearOff'), |
| 1181 }) | 1188 }) |
| 1182 | 1189 |
| 1183 _svg_supplemental_includes = [ | 1190 _svg_supplemental_includes = [ |
| 1184 '"SVGAnimatedPropertyTearOff.h"', | 1191 '"SVGAnimatedPropertyTearOff.h"', |
| 1185 '"SVGAnimatedListPropertyTearOff.h"', | 1192 '"SVGAnimatedListPropertyTearOff.h"', |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 if type_data.clazz == 'BasicTypedList': | 1261 if type_data.clazz == 'BasicTypedList': |
| 1255 if type_name == 'ArrayBuffer': | 1262 if type_name == 'ArrayBuffer': |
| 1256 dart_interface_name = 'ByteBuffer' | 1263 dart_interface_name = 'ByteBuffer' |
| 1257 else: | 1264 else: |
| 1258 dart_interface_name = self._renamer.RenameInterfaceId(type_name) | 1265 dart_interface_name = self._renamer.RenameInterfaceId(type_name) |
| 1259 return BasicTypedListIDLTypeInfo( | 1266 return BasicTypedListIDLTypeInfo( |
| 1260 type_name, type_data, dart_interface_name, self) | 1267 type_name, type_data, dart_interface_name, self) |
| 1261 | 1268 |
| 1262 class_name = '%sIDLTypeInfo' % type_data.clazz | 1269 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1263 return globals()[class_name](type_name, type_data) | 1270 return globals()[class_name](type_name, type_data) |
| OLD | NEW |