| 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 html_interface_renames, typed_array_renames | 14 from htmlrenamer import html_interface_renames, typed_array_renames |
| 15 | 15 |
| 16 _pure_interfaces = monitored.Set('generator._pure_interfaces', [ | 16 _pure_interfaces = monitored.Set('generator._pure_interfaces', [ |
| 17 # TODO(sra): DOMStringMap should be a class implementing Map<String,String>. | 17 # TODO(sra): DOMStringMap should be a class implementing Map<String,String>. |
| 18 'DOMStringMap', | 18 'DOMStringMap', |
| 19 'ChildNode', | 19 'ChildNode', |
| 20 #'Crypto', | |
| 21 'ElementTimeControl', | 20 'ElementTimeControl', |
| 22 'ElementTraversal', | |
| 23 'EventListener', | 21 'EventListener', |
| 24 'MediaQueryListListener', | 22 'MediaQueryListListener', |
| 25 'MutationCallback', | 23 'MutationCallback', |
| 26 'ParentNode', | 24 'ParentNode', |
| 27 #'SubtleCrypto', | |
| 28 'SVGExternalResourcesRequired', | 25 'SVGExternalResourcesRequired', |
| 29 'SVGFilterPrimitiveStandardAttributes', | 26 'SVGFilterPrimitiveStandardAttributes', |
| 30 'SVGFitToViewBox', | 27 'SVGFitToViewBox', |
| 31 'SVGLangSpace', | 28 'SVGLangSpace', |
| 32 'SVGLocatable', | 29 'SVGLocatable', |
| 33 'SVGTests', | 30 'SVGTests', |
| 34 'SVGTransformable', | 31 'SVGTransformable', |
| 35 'SVGURIReference', | 32 'SVGURIReference', |
| 36 'SVGZoomAndPan', | 33 'SVGZoomAndPan', |
| 37 'TimeoutHandler', | 34 'TimeoutHandler', |
| 38 'WindowTimers', | 35 'WindowTimers', |
| 39 #'WorkerCrypto', | |
| 40 'WorkerPerformance', | 36 'WorkerPerformance', |
| 41 ]) | 37 ]) |
| 42 | 38 |
| 43 def IsPureInterface(interface_name): | 39 def IsPureInterface(interface_name): |
| 44 return interface_name in _pure_interfaces | 40 return interface_name in _pure_interfaces |
| 45 | 41 |
| 46 # | 42 # |
| 47 # Classes which have native constructors but which we are suppressing because | 43 # Classes which have native constructors but which we are suppressing because |
| 48 # they are not cross-platform. | 44 # they are not cross-platform. |
| 49 # | 45 # |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 986 |
| 991 | 987 |
| 992 def TypedListTypeData(item_type): | 988 def TypedListTypeData(item_type): |
| 993 return TypeData(clazz='TypedList', item_type=item_type) | 989 return TypeData(clazz='TypedList', item_type=item_type) |
| 994 | 990 |
| 995 | 991 |
| 996 _idl_type_registry = monitored.Dict('generator._idl_type_registry', { | 992 _idl_type_registry = monitored.Dict('generator._idl_type_registry', { |
| 997 'boolean': TypeData(clazz='Primitive', dart_type='bool', native_type='bool', | 993 'boolean': TypeData(clazz='Primitive', dart_type='bool', native_type='bool', |
| 998 webcore_getter_name='hasAttribute', | 994 webcore_getter_name='hasAttribute', |
| 999 webcore_setter_name='setBooleanAttribute'), | 995 webcore_setter_name='setBooleanAttribute'), |
| 996 'byte': TypeData(clazz='Primitive', dart_type='int', native_type='int'), |
| 997 'octet': TypeData(clazz='Primitive', dart_type='int', native_type='int'), |
| 1000 'short': TypeData(clazz='Primitive', dart_type='int', native_type='int'), | 998 'short': TypeData(clazz='Primitive', dart_type='int', native_type='int'), |
| 1001 'unsigned short': TypeData(clazz='Primitive', dart_type='int', | 999 'unsigned short': TypeData(clazz='Primitive', dart_type='int', |
| 1002 native_type='int'), | 1000 native_type='int'), |
| 1003 'int': TypeData(clazz='Primitive', dart_type='int'), | 1001 'int': TypeData(clazz='Primitive', dart_type='int'), |
| 1004 'unsigned int': TypeData(clazz='Primitive', dart_type='int', | |
| 1005 native_type='unsigned'), | |
| 1006 'long': TypeData(clazz='Primitive', dart_type='int', native_type='int', | 1002 'long': TypeData(clazz='Primitive', dart_type='int', native_type='int', |
| 1007 webcore_getter_name='getIntegralAttribute', | 1003 webcore_getter_name='getIntegralAttribute', |
| 1008 webcore_setter_name='setIntegralAttribute'), | 1004 webcore_setter_name='setIntegralAttribute'), |
| 1009 'unsigned long': TypeData(clazz='Primitive', dart_type='int', | 1005 'unsigned long': TypeData(clazz='Primitive', dart_type='int', |
| 1010 native_type='unsigned', | 1006 native_type='unsigned', |
| 1011 webcore_getter_name='getUnsignedIntegralAttribute'
, | 1007 webcore_getter_name='getUnsignedIntegralAttribute'
, |
| 1012 webcore_setter_name='setUnsignedIntegralAttribute'
), | 1008 webcore_setter_name='setUnsignedIntegralAttribute'
), |
| 1013 'long long': TypeData(clazz='Primitive', dart_type='int'), | 1009 'long long': TypeData(clazz='Primitive', dart_type='int'), |
| 1014 'unsigned long long': TypeData(clazz='Primitive', dart_type='int'), | 1010 'unsigned long long': TypeData(clazz='Primitive', dart_type='int'), |
| 1015 'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'), | 1011 'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'), |
| 1016 'double': TypeData(clazz='Primitive', dart_type='num'), | 1012 'double': TypeData(clazz='Primitive', dart_type='num'), |
| 1017 | 1013 |
| 1018 'any': TypeData(clazz='Primitive', dart_type='Object', native_type='ScriptVa
lue'), | 1014 'any': TypeData(clazz='Primitive', dart_type='Object', native_type='ScriptVa
lue'), |
| 1019 'Array': TypeData(clazz='Primitive', dart_type='List'), | 1015 'Array': TypeData(clazz='Primitive', dart_type='List'), |
| 1020 'custom': TypeData(clazz='Primitive', dart_type='dynamic'), | 1016 'custom': TypeData(clazz='Primitive', dart_type='dynamic'), |
| 1017 'union': TypeData(clazz='Primitive', dart_type='dynamic'), |
| 1021 'ClientRect': TypeData(clazz='Interface', | 1018 'ClientRect': TypeData(clazz='Interface', |
| 1022 dart_type='Rect', suppress_interface=True), | 1019 dart_type='Rect', suppress_interface=True), |
| 1023 'Date': TypeData(clazz='Primitive', dart_type='DateTime', native_type='doubl
e'), | 1020 'Date': TypeData(clazz='Primitive', dart_type='DateTime', native_type='doubl
e'), |
| 1024 'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc
riptValue'), | 1021 'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc
riptValue'), |
| 1025 'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St
ring'), | 1022 'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St
ring'), |
| 1026 # TODO(vsm): This won't actually work until we convert the Map to | 1023 # TODO(vsm): This won't actually work until we convert the Map to |
| 1027 # a native JS Map for JS DOM. | 1024 # a native JS Map for JS DOM. |
| 1028 'Dictionary': TypeData(clazz='Primitive', dart_type='Map'), | 1025 'Dictionary': TypeData(clazz='Primitive', dart_type='Map'), |
| 1029 'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un
signed long long'), | 1026 'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un
signed long long'), |
| 1030 'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip
tValue'), | 1027 'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip
tValue'), |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 type_name, type_data, dart_interface_name, self) | 1197 type_name, type_data, dart_interface_name, self) |
| 1201 | 1198 |
| 1202 if type_data.clazz == 'BasicTypedList': | 1199 if type_data.clazz == 'BasicTypedList': |
| 1203 dart_interface_name = self._renamer.RenameInterface( | 1200 dart_interface_name = self._renamer.RenameInterface( |
| 1204 self._database.GetInterface(type_name)) | 1201 self._database.GetInterface(type_name)) |
| 1205 return BasicTypedListIDLTypeInfo( | 1202 return BasicTypedListIDLTypeInfo( |
| 1206 type_name, type_data, dart_interface_name, self) | 1203 type_name, type_data, dart_interface_name, self) |
| 1207 | 1204 |
| 1208 class_name = '%sIDLTypeInfo' % type_data.clazz | 1205 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1209 return globals()[class_name](type_name, type_data) | 1206 return globals()[class_name](type_name, type_data) |
| OLD | NEW |