| 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 re | 10 import re | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 78     # Some JavaScript processors, especially tools like yuicompress and | 78     # Some JavaScript processors, especially tools like yuicompress and | 
| 79     # JSCompiler, choke on 'this.continue' | 79     # JSCompiler, choke on 'this.continue' | 
| 80     'IDBCursor.continueFunction': | 80     'IDBCursor.continueFunction': | 
| 81       """ | 81       """ | 
| 82         if (key == null) return this['continue'](); | 82         if (key == null) return this['continue'](); | 
| 83         return this['continue'](key); | 83         return this['continue'](key); | 
| 84       """, | 84       """, | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 def IsPrimitiveType(type_name): | 87 def IsPrimitiveType(type_name): | 
| 88   return isinstance(GetIDLTypeInfo(type_name), PrimitiveIDLTypeInfo) | 88   if not type_name in _idl_type_registry: | 
|  | 89     return False | 
|  | 90   return _idl_type_registry[type_name].clazz == 'Primitive' | 
| 89 | 91 | 
| 90 def ListImplementationInfo(interface, database): | 92 def ListImplementationInfo(interface, database): | 
| 91   """Returns a tuple (elment_type, requires_indexer). | 93   """Returns a tuple (elment_type, requires_indexer). | 
| 92   If interface do not have to implement List, element_type is None. | 94   If interface do not have to implement List, element_type is None. | 
| 93   Otherwise element_type is list element type and requires_indexer | 95   Otherwise element_type is list element type and requires_indexer | 
| 94   is true iff this interface implementation must have indexer and | 96   is true iff this interface implementation must have indexer and | 
| 95   false otherwise.  False means that interface implementation | 97   false otherwise.  False means that interface implementation | 
| 96   inherits indexer and may just reuse it.""" | 98   inherits indexer and may just reuse it.""" | 
| 97   element_type = MaybeListElementType(interface) | 99   element_type = MaybeListElementType(interface) | 
| 98   if element_type: | 100   if element_type: | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 159     # is useful not only for browser compat, but to allow code that links | 161     # is useful not only for browser compat, but to allow code that links | 
| 160     # against dart:dom_deprecated to load in a worker isolate. | 162     # against dart:dom_deprecated to load in a worker isolate. | 
| 161     return '*' + javascript_binding_name | 163     return '*' + javascript_binding_name | 
| 162 | 164 | 
| 163 | 165 | 
| 164 def MatchSourceFilter(thing): | 166 def MatchSourceFilter(thing): | 
| 165   return 'WebKit' in thing.annotations or 'Dart' in thing.annotations | 167   return 'WebKit' in thing.annotations or 'Dart' in thing.annotations | 
| 166 | 168 | 
| 167 | 169 | 
| 168 def DartType(idl_type_name): | 170 def DartType(idl_type_name): | 
| 169   return GetIDLTypeInfo(idl_type_name).dart_type() | 171   return TypeRegistry().TypeInfo(idl_type_name).dart_type() | 
| 170 | 172 | 
| 171 | 173 | 
| 172 class ParamInfo(object): | 174 class ParamInfo(object): | 
| 173   """Holder for various information about a parameter of a Dart operation. | 175   """Holder for various information about a parameter of a Dart operation. | 
| 174 | 176 | 
| 175   Attributes: | 177   Attributes: | 
| 176     name: Name of parameter. | 178     name: Name of parameter. | 
| 177     type_id: Original type id.  None for merged types. | 179     type_id: Original type id.  None for merged types. | 
| 178     dart_type: DartType of parameter. | 180     dart_type: DartType of parameter. | 
| 179     is_optional: Parameter optionality. | 181     is_optional: Parameter optionality. | 
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 483 | 485 | 
| 484 # Given a sorted sequence of type identifiers, return an appropriate type | 486 # Given a sorted sequence of type identifiers, return an appropriate type | 
| 485 # name | 487 # name | 
| 486 def TypeName(type_ids, interface): | 488 def TypeName(type_ids, interface): | 
| 487   # Dynamically type this field for now. | 489   # Dynamically type this field for now. | 
| 488   return 'Dynamic' | 490   return 'Dynamic' | 
| 489 | 491 | 
| 490 # ------------------------------------------------------------------------------ | 492 # ------------------------------------------------------------------------------ | 
| 491 | 493 | 
| 492 class IDLTypeInfo(object): | 494 class IDLTypeInfo(object): | 
| 493   def __init__(self, idl_type, dart_type=None, | 495   def __init__(self, idl_type, data): | 
| 494                native_type=None, |  | 
| 495                custom_to_native=False, |  | 
| 496                custom_to_dart=False, conversion_includes=[]): |  | 
| 497     self._idl_type = idl_type | 496     self._idl_type = idl_type | 
| 498     self._dart_type = dart_type | 497     self._data = data | 
| 499     self._native_type = native_type |  | 
| 500     self._custom_to_native = custom_to_native |  | 
| 501     self._custom_to_dart = custom_to_dart |  | 
| 502     self._conversion_includes = conversion_includes + [idl_type] |  | 
| 503 | 498 | 
| 504   def idl_type(self): | 499   def idl_type(self): | 
| 505     return self._idl_type | 500     return self._idl_type | 
| 506 | 501 | 
| 507   def dart_type(self): | 502   def dart_type(self): | 
| 508     return self._dart_type or self._idl_type | 503     return self._data.dart_type or self._idl_type | 
| 509 | 504 | 
| 510   def native_type(self): | 505   def native_type(self): | 
| 511     return self._native_type or self._idl_type | 506     return self._data.native_type or self._idl_type | 
| 512 | 507 | 
| 513   def emit_to_native(self, emitter, idl_node, name, handle, interface_name): | 508   def emit_to_native(self, emitter, idl_node, name, handle, interface_name): | 
| 514     if 'Callback' in idl_node.ext_attrs: | 509     if 'Callback' in idl_node.ext_attrs: | 
| 515       if set(['Optional', 'Callback']).issubset(idl_node.ext_attrs.keys()): | 510       if set(['Optional', 'Callback']).issubset(idl_node.ext_attrs.keys()): | 
| 516         flag = 'DartUtilities::ConvertNullToDefaultValue' | 511         flag = 'DartUtilities::ConvertNullToDefaultValue' | 
| 517       else: | 512       else: | 
| 518         flag = 'DartUtilities::ConvertNone' | 513         flag = 'DartUtilities::ConvertNone' | 
| 519       emitter.Emit( | 514       emitter.Emit( | 
| 520         '\n' | 515         '\n' | 
| 521         '        RefPtr<$TYPE> $NAME = Dart$IDL_TYPE::create($HANDLE, $FLAG, exc
     eption);\n' | 516         '        RefPtr<$TYPE> $NAME = Dart$IDL_TYPE::create($HANDLE, $FLAG, exc
     eption);\n' | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 541         '        $TYPE $NAME = Dart$IDL_TYPE::toNative($HANDLE, exception);\n' | 536         '        $TYPE $NAME = Dart$IDL_TYPE::toNative($HANDLE, exception);\n' | 
| 542         '        if (exception)\n' | 537         '        if (exception)\n' | 
| 543         '            goto fail;\n', | 538         '            goto fail;\n', | 
| 544         TYPE=type, | 539         TYPE=type, | 
| 545         NAME=name, | 540         NAME=name, | 
| 546         IDL_TYPE=self.idl_type(), | 541         IDL_TYPE=self.idl_type(), | 
| 547         HANDLE=handle) | 542         HANDLE=handle) | 
| 548     return argument | 543     return argument | 
| 549 | 544 | 
| 550   def custom_to_native(self): | 545   def custom_to_native(self): | 
| 551     return self._custom_to_native | 546     return self._data.custom_to_native | 
| 552 | 547 | 
| 553   def parameter_type(self): | 548   def parameter_type(self): | 
| 554     return '%s*' % self.native_type() | 549     return '%s*' % self.native_type() | 
| 555 | 550 | 
| 556   def webcore_includes(self): | 551   def webcore_includes(self): | 
| 557     WTF_INCLUDES = [ | 552     WTF_INCLUDES = [ | 
| 558         'ArrayBuffer', | 553         'ArrayBuffer', | 
| 559         'ArrayBufferView', | 554         'ArrayBufferView', | 
| 560         'Float32Array', | 555         'Float32Array', | 
| 561         'Float64Array', | 556         'Float64Array', | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 579     if self._idl_type.startswith('SVGPathSeg'): | 574     if self._idl_type.startswith('SVGPathSeg'): | 
| 580       include = self._idl_type.replace('Abs', '').replace('Rel', '') | 575       include = self._idl_type.replace('Abs', '').replace('Rel', '') | 
| 581     else: | 576     else: | 
| 582       include = self._idl_type | 577       include = self._idl_type | 
| 583     return ['"%s.h"' % include] + _svg_supplemental_includes | 578     return ['"%s.h"' % include] + _svg_supplemental_includes | 
| 584 | 579 | 
| 585   def receiver(self): | 580   def receiver(self): | 
| 586     return 'receiver->' | 581     return 'receiver->' | 
| 587 | 582 | 
| 588   def conversion_includes(self): | 583   def conversion_includes(self): | 
| 589     return ['"Dart%s.h"' % include for include in self._conversion_includes] | 584     includes = [self._idl_type] + (self._data.conversion_includes or []) | 
|  | 585     return ['"Dart%s.h"' % include for include in includes] | 
| 590 | 586 | 
| 591   def to_native_includes(self): | 587   def to_native_includes(self): | 
| 592     return ['"Dart%s.h"' % self.idl_type()] | 588     return ['"Dart%s.h"' % self.idl_type()] | 
| 593 | 589 | 
| 594   def to_dart_conversion(self, value, interface_name=None, attributes=None): | 590   def to_dart_conversion(self, value, interface_name=None, attributes=None): | 
| 595     return 'Dart%s::toDart(%s)' % (self._idl_type, value) | 591     return 'Dart%s::toDart(%s)' % (self._idl_type, value) | 
| 596 | 592 | 
| 597   def custom_to_dart(self): | 593   def custom_to_dart(self): | 
| 598     return self._custom_to_dart | 594     return self._data.custom_to_dart | 
|  | 595 | 
|  | 596 | 
|  | 597 class InterfaceIDLTypeInfo(IDLTypeInfo): | 
|  | 598   def __init__(self, idl_type, data): | 
|  | 599     super(InterfaceIDLTypeInfo, self).__init__(idl_type, data) | 
| 599 | 600 | 
| 600 | 601 | 
| 601 class SequenceIDLTypeInfo(IDLTypeInfo): | 602 class SequenceIDLTypeInfo(IDLTypeInfo): | 
| 602   def __init__(self, idl_type, item_info): | 603   def __init__(self, idl_type, item_info): | 
| 603     super(SequenceIDLTypeInfo, self).__init__(idl_type) | 604     super(SequenceIDLTypeInfo, self).__init__(idl_type, {}) | 
| 604     self._item_info = item_info | 605     self._item_info = item_info | 
| 605 | 606 | 
| 606   def dart_type(self): | 607   def dart_type(self): | 
| 607     return 'List<%s>' % self._item_info.dart_type() | 608     return 'List<%s>' % self._item_info.dart_type() | 
| 608 | 609 | 
| 609   def to_dart_conversion(self, value, interface_name=None, attributes=None): | 610   def to_dart_conversion(self, value, interface_name=None, attributes=None): | 
| 610     return 'DartDOMWrapper::vectorToDart<Dart%s>(%s)' % (self._item_info.native_
     type(), value) | 611     return 'DartDOMWrapper::vectorToDart<Dart%s>(%s)' % (self._item_info.native_
     type(), value) | 
| 611 | 612 | 
| 612   def conversion_includes(self): | 613   def conversion_includes(self): | 
| 613     return self._item_info.conversion_includes() | 614     return self._item_info.conversion_includes() | 
| 614 | 615 | 
| 615 | 616 | 
| 616 class DOMStringArrayTypeInfo(SequenceIDLTypeInfo): | 617 class DOMStringArrayTypeInfo(SequenceIDLTypeInfo): | 
| 617   def __init__(self): | 618   def __init__(self, item_info): | 
| 618     super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', _dom_string_type
     _info) | 619     super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', item_info) | 
| 619 | 620 | 
| 620   def emit_to_native(self, emitter, idl_node, name, handle, interface_name): | 621   def emit_to_native(self, emitter, idl_node, name, handle, interface_name): | 
| 621     emitter.Emit( | 622     emitter.Emit( | 
| 622         '\n' | 623         '\n' | 
| 623         '        RefPtr<DOMStringList> $NAME = DartDOMStringList::toNative($HAND
     LE, exception);\n' | 624         '        RefPtr<DOMStringList> $NAME = DartDOMStringList::toNative($HAND
     LE, exception);\n' | 
| 624         '        if (exception)\n' | 625         '        if (exception)\n' | 
| 625         '            goto fail;\n', | 626         '            goto fail;\n', | 
| 626         NAME=name, | 627         NAME=name, | 
| 627         HANDLE=handle) | 628         HANDLE=handle) | 
| 628     return name | 629     return name | 
| 629 | 630 | 
| 630   def to_native_includes(self): | 631   def to_native_includes(self): | 
| 631     return ['"DartDOMStringList.h"'] | 632     return ['"DartDOMStringList.h"'] | 
| 632 | 633 | 
| 633 | 634 | 
| 634 class PrimitiveIDLTypeInfo(IDLTypeInfo): | 635 class PrimitiveIDLTypeInfo(IDLTypeInfo): | 
| 635   def __init__(self, idl_type, dart_type, native_type=None, | 636   def __init__(self, idl_type, data): | 
| 636                webcore_getter_name='getAttribute', | 637     super(PrimitiveIDLTypeInfo, self).__init__(idl_type, data) | 
| 637                webcore_setter_name='setAttribute'): |  | 
| 638     super(PrimitiveIDLTypeInfo, self).__init__(idl_type, dart_type=dart_type, |  | 
| 639         native_type=native_type) |  | 
| 640     self._webcore_getter_name = webcore_getter_name |  | 
| 641     self._webcore_setter_name = webcore_setter_name |  | 
| 642 | 638 | 
| 643   def emit_to_native(self, emitter, idl_node, name, handle, interface_name): | 639   def emit_to_native(self, emitter, idl_node, name, handle, interface_name): | 
| 644     function_name = 'dartTo%s' % self._capitalized_native_type() | 640     function_name = 'dartTo%s' % self._capitalized_native_type() | 
| 645     if idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString': | 641     if idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString': | 
| 646       function_name += 'WithNullCheck' | 642       function_name += 'WithNullCheck' | 
| 647     type = self.native_type() | 643     type = self.native_type() | 
| 648     if type == 'SerializedScriptValue': | 644     if type == 'SerializedScriptValue': | 
| 649       type = 'RefPtr<%s>' % type | 645       type = 'RefPtr<%s>' % type | 
| 650     if type == 'String': | 646     if type == 'String': | 
| 651       type = 'DartStringAdapter' | 647       type = 'DartStringAdapter' | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 674   def to_dart_conversion(self, value, interface_name=None, attributes=None): | 670   def to_dart_conversion(self, value, interface_name=None, attributes=None): | 
| 675     conversion_arguments = [value] | 671     conversion_arguments = [value] | 
| 676     if attributes and 'TreatReturnedNullStringAs' in attributes: | 672     if attributes and 'TreatReturnedNullStringAs' in attributes: | 
| 677       conversion_arguments.append('DartUtilities::ConvertNullToDefaultValue') | 673       conversion_arguments.append('DartUtilities::ConvertNullToDefaultValue') | 
| 678     function_name = self._capitalized_native_type() | 674     function_name = self._capitalized_native_type() | 
| 679     function_name = function_name[0].lower() + function_name[1:] | 675     function_name = function_name[0].lower() + function_name[1:] | 
| 680     function_name = 'DartUtilities::%sToDart' % function_name | 676     function_name = 'DartUtilities::%sToDart' % function_name | 
| 681     return '%s(%s)' % (function_name, ', '.join(conversion_arguments)) | 677     return '%s(%s)' % (function_name, ', '.join(conversion_arguments)) | 
| 682 | 678 | 
| 683   def webcore_getter_name(self): | 679   def webcore_getter_name(self): | 
| 684     return self._webcore_getter_name | 680     return self._data.webcore_getter_name | 
| 685 | 681 | 
| 686   def webcore_setter_name(self): | 682   def webcore_setter_name(self): | 
| 687     return self._webcore_setter_name | 683     return self._data.webcore_setter_name | 
| 688 | 684 | 
| 689   def _capitalized_native_type(self): | 685   def _capitalized_native_type(self): | 
| 690     return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_typ
     e()) | 686     return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_typ
     e()) | 
| 691 | 687 | 
| 692 | 688 | 
| 693 class SVGTearOffIDLTypeInfo(IDLTypeInfo): | 689 class SVGTearOffIDLTypeInfo(IDLTypeInfo): | 
| 694   def __init__(self, idl_type, native_type=''): | 690   def __init__(self, idl_type, data): | 
| 695     super(SVGTearOffIDLTypeInfo, self).__init__(idl_type, | 691     super(SVGTearOffIDLTypeInfo, self).__init__(idl_type, data) | 
| 696                                                 native_type=native_type) |  | 
| 697 | 692 | 
| 698   def native_type(self): | 693   def native_type(self): | 
| 699     if self._native_type: | 694     if self._data.native_type: | 
| 700       return self._native_type | 695       return self._data.native_type | 
| 701     tear_off_type = 'SVGPropertyTearOff' | 696     tear_off_type = 'SVGPropertyTearOff' | 
| 702     if self._idl_type.endswith('List'): | 697     if self._idl_type.endswith('List'): | 
| 703       tear_off_type = 'SVGListPropertyTearOff' | 698       tear_off_type = 'SVGListPropertyTearOff' | 
| 704     return '%s<%s>' % (tear_off_type, self._idl_type) | 699     return '%s<%s>' % (tear_off_type, self._idl_type) | 
| 705 | 700 | 
| 706   def receiver(self): | 701   def receiver(self): | 
| 707     if self._idl_type.endswith('List'): | 702     if self._idl_type.endswith('List'): | 
| 708       return 'receiver->' | 703       return 'receiver->' | 
| 709     return 'receiver->propertyReference().' | 704     return 'receiver->propertyReference().' | 
| 710 | 705 | 
| 711   def to_dart_conversion(self, value, interface_name, attributes): | 706   def to_dart_conversion(self, value, interface_name, attributes): | 
| 712     svg_primitive_types = ['SVGAngle', 'SVGLength', 'SVGMatrix', | 707     svg_primitive_types = ['SVGAngle', 'SVGLength', 'SVGMatrix', | 
| 713         'SVGNumber', 'SVGPoint', 'SVGRect', 'SVGTransform'] | 708         'SVGNumber', 'SVGPoint', 'SVGRect', 'SVGTransform'] | 
| 714     conversion_cast = '%s::create(%s)' | 709     conversion_cast = '%s::create(%s)' | 
| 715     if interface_name.startswith('SVGAnimated'): | 710     if interface_name.startswith('SVGAnimated'): | 
| 716       conversion_cast = 'static_cast<%s*>(%s)' | 711       conversion_cast = 'static_cast<%s*>(%s)' | 
| 717     elif self.idl_type() == 'SVGStringList': | 712     elif self.idl_type() == 'SVGStringList': | 
| 718       conversion_cast = '%s::create(receiver, %s)' | 713       conversion_cast = '%s::create(receiver, %s)' | 
| 719     elif interface_name.endswith('List'): | 714     elif interface_name.endswith('List'): | 
| 720       conversion_cast = 'static_cast<%s*>(%s.get())' | 715       conversion_cast = 'static_cast<%s*>(%s.get())' | 
| 721     elif self.idl_type() in svg_primitive_types: | 716     elif self.idl_type() in svg_primitive_types: | 
| 722       conversion_cast = '%s::create(%s)' | 717       conversion_cast = '%s::create(%s)' | 
| 723     else: | 718     else: | 
| 724       conversion_cast = 'static_cast<%s*>(%s)' | 719       conversion_cast = 'static_cast<%s*>(%s)' | 
| 725     conversion_cast = conversion_cast % (self.native_type(), value) | 720     conversion_cast = conversion_cast % (self.native_type(), value) | 
| 726     return 'Dart%s::toDart(%s)' %  (self._idl_type, conversion_cast) | 721     return 'Dart%s::toDart(%s)' % (self._idl_type, conversion_cast) | 
| 727 | 722 | 
| 728 _dom_string_type_info = PrimitiveIDLTypeInfo( | 723 | 
| 729     'DOMString', dart_type='String', native_type='String') | 724 class TypeData(object): | 
|  | 725   def __init__(self, clazz, dart_type=None, native_type=None, | 
|  | 726                custom_to_dart=None, custom_to_native=None, | 
|  | 727                conversion_includes=None, | 
|  | 728                webcore_getter_name='getAttribute', | 
|  | 729                webcore_setter_name='setAttribute'): | 
|  | 730     self.clazz = clazz | 
|  | 731     self.dart_type = dart_type | 
|  | 732     self.native_type = native_type | 
|  | 733     self.custom_to_dart = custom_to_dart | 
|  | 734     self.custom_to_native = custom_to_native | 
|  | 735     self.conversion_includes = conversion_includes | 
|  | 736     self.webcore_getter_name = webcore_getter_name | 
|  | 737     self.webcore_setter_name = webcore_setter_name | 
|  | 738 | 
| 730 | 739 | 
| 731 _idl_type_registry = { | 740 _idl_type_registry = { | 
| 732     'boolean': PrimitiveIDLTypeInfo('boolean', dart_type='bool', native_type='bo
     ol', | 741     'boolean': TypeData(clazz='Primitive', dart_type='bool', native_type='bool', | 
| 733                                     webcore_getter_name='hasAttribute', | 742                         webcore_getter_name='hasAttribute', | 
| 734                                     webcore_setter_name='setBooleanAttribute'), | 743                         webcore_setter_name='setBooleanAttribute'), | 
| 735     'byte': PrimitiveIDLTypeInfo('byte', dart_type='int', native_type='int'), | 744     'byte': TypeData(clazz='Primitive', dart_type='int', native_type='int'), | 
| 736     'octet': PrimitiveIDLTypeInfo('octet', dart_type='int', native_type='int'), | 745     'octet': TypeData(clazz='Primitive', dart_type='int', native_type='int'), | 
| 737     'short': PrimitiveIDLTypeInfo('short', dart_type='int', native_type='int'), | 746     'short': TypeData(clazz='Primitive', dart_type='int', native_type='int'), | 
| 738     'unsigned short': PrimitiveIDLTypeInfo('unsigned short', dart_type='int', | 747     'unsigned short': TypeData(clazz='Primitive', dart_type='int', | 
| 739         native_type='int'), | 748         native_type='int'), | 
| 740     'int': PrimitiveIDLTypeInfo('int', dart_type='int'), | 749     'int': TypeData(clazz='Primitive', dart_type='int'), | 
| 741     'unsigned int': PrimitiveIDLTypeInfo('unsigned int', dart_type='int', | 750     'unsigned int': TypeData(clazz='Primitive', dart_type='int', | 
| 742         native_type='unsigned'), | 751         native_type='unsigned'), | 
| 743     'long': PrimitiveIDLTypeInfo('long', dart_type='int', native_type='int', | 752     'long': TypeData(clazz='Primitive', dart_type='int', native_type='int', | 
| 744         webcore_getter_name='getIntegralAttribute', | 753         webcore_getter_name='getIntegralAttribute', | 
| 745         webcore_setter_name='setIntegralAttribute'), | 754         webcore_setter_name='setIntegralAttribute'), | 
| 746     'unsigned long': PrimitiveIDLTypeInfo('unsigned long', dart_type='int', | 755     'unsigned long': TypeData(clazz='Primitive', dart_type='int', | 
| 747         native_type='unsigned', | 756                               native_type='unsigned', | 
| 748         webcore_getter_name='getUnsignedIntegralAttribute', | 757                               webcore_getter_name='getUnsignedIntegralAttribute'
     , | 
| 749         webcore_setter_name='setUnsignedIntegralAttribute'), | 758                               webcore_setter_name='setUnsignedIntegralAttribute'
     ), | 
| 750     'long long': PrimitiveIDLTypeInfo('long long', dart_type='int'), | 759     'long long': TypeData(clazz='Primitive', dart_type='int'), | 
| 751     'unsigned long long': PrimitiveIDLTypeInfo('unsigned long long', dart_type='
     int'), | 760     'unsigned long long': TypeData(clazz='Primitive', dart_type='int'), | 
| 752     'float': PrimitiveIDLTypeInfo('float', dart_type='num', native_type='double'
     ), | 761     'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'), | 
| 753     'double': PrimitiveIDLTypeInfo('double', dart_type='num'), | 762     'double': TypeData(clazz='Primitive', dart_type='num'), | 
| 754 | 763 | 
| 755     'any': PrimitiveIDLTypeInfo('any', dart_type='Object'), | 764     'any': TypeData(clazz='Primitive', dart_type='Object'), | 
| 756     'Array': PrimitiveIDLTypeInfo('Array', dart_type='List'), | 765     'Array': TypeData(clazz='Primitive', dart_type='List'), | 
| 757     'custom': PrimitiveIDLTypeInfo('custom', dart_type='Dynamic'), | 766     'custom': TypeData(clazz='Primitive', dart_type='Dynamic'), | 
| 758     'Date': PrimitiveIDLTypeInfo('Date', dart_type='Date', native_type='double')
     , | 767     'Date': TypeData(clazz='Primitive', dart_type='Date', native_type='double'), | 
| 759     'DOMObject': PrimitiveIDLTypeInfo('DOMObject', dart_type='Object', native_ty
     pe='ScriptValue'), | 768     'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc
     riptValue'), | 
| 760     'DOMString': _dom_string_type_info, | 769     'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St
     ring'), | 
| 761     # TODO(vsm): This won't actually work until we convert the Map to | 770     # TODO(vsm): This won't actually work until we convert the Map to | 
| 762     # a native JS Map for JS DOM. | 771     # a native JS Map for JS DOM. | 
| 763     'Dictionary': PrimitiveIDLTypeInfo('Dictionary', dart_type='Map'), | 772     'Dictionary': TypeData(clazz='Primitive', dart_type='Map'), | 
| 764     # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} | 773     # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} | 
| 765     # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa
     ce | 774     # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa
     ce | 
| 766     'Flags': PrimitiveIDLTypeInfo('Flags', dart_type='Object'), | 775     'Flags': TypeData(clazz='Primitive', dart_type='Object'), | 
| 767     'DOMTimeStamp': PrimitiveIDLTypeInfo('DOMTimeStamp', dart_type='int', native
     _type='unsigned long long'), | 776     'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un
     signed long long'), | 
| 768     'object': PrimitiveIDLTypeInfo('object', dart_type='Object', native_type='Sc
     riptValue'), | 777     'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip
     tValue'), | 
| 769     'PositionOptions': PrimitiveIDLTypeInfo('PositionOptions', dart_type='Object
     '), | 778     'PositionOptions': TypeData(clazz='Primitive', dart_type='Object'), | 
| 770     # TODO(sra): Come up with some meaningful name so that where this appears in | 779     # TODO(sra): Come up with some meaningful name so that where this appears in | 
| 771     # the documentation, the user is made aware that only a limited subset of | 780     # the documentation, the user is made aware that only a limited subset of | 
| 772     # serializable types are actually permitted. | 781     # serializable types are actually permitted. | 
| 773     'SerializedScriptValue': PrimitiveIDLTypeInfo('SerializedScriptValue', dart_
     type='Dynamic'), | 782     'SerializedScriptValue': TypeData(clazz='Primitive', dart_type='Dynamic'), | 
| 774     # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} | 783     # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} | 
| 775     # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa
     ce | 784     # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa
     ce | 
| 776     'WebKitFlags': PrimitiveIDLTypeInfo('WebKitFlags', dart_type='Object'), | 785     'WebKitFlags': TypeData(clazz='Primitive', dart_type='Object'), | 
| 777 | 786 | 
| 778     'sequence': PrimitiveIDLTypeInfo('sequence', dart_type='List'), | 787     'sequence': TypeData(clazz='Primitive', dart_type='List'), | 
| 779     'void': PrimitiveIDLTypeInfo('void', dart_type='void'), | 788     'void': TypeData(clazz='Primitive', dart_type='void'), | 
| 780 | 789 | 
| 781     'CSSRule': IDLTypeInfo('CSSRule', conversion_includes=['CSSImportRule']), | 790     'CSSRule': TypeData(clazz='Interface', conversion_includes=['CSSImportRule']
     ), | 
| 782     'DOMException': IDLTypeInfo('DOMException', native_type='DOMCoreException'), | 791     'DOMException': TypeData(clazz='Interface', native_type='DOMCoreException'), | 
| 783     'DOMString[]': DOMStringArrayTypeInfo(), | 792     'DOMStringList': TypeData(clazz='Interface', dart_type='List<String>', custo
     m_to_native=True), | 
| 784     'DOMStringList': IDLTypeInfo('DOMStringList', dart_type='List<String>', cust
     om_to_native=True), | 793     'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>')
     , | 
| 785     'DOMStringMap': IDLTypeInfo('DOMStringMap', dart_type='Map<String, String>')
     , | 794     'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True), | 
| 786     'DOMWindow': IDLTypeInfo('DOMWindow', custom_to_dart=True), | 795     'Element': TypeData(clazz='Interface', custom_to_dart=True), | 
| 787     'Element': IDLTypeInfo('Element', custom_to_dart=True), | 796     'EventListener': TypeData(clazz='Interface', custom_to_native=True), | 
| 788     'EventListener': IDLTypeInfo('EventListener', custom_to_native=True), | 797     'EventTarget': TypeData(clazz='Interface', custom_to_native=True), | 
| 789     'EventTarget': IDLTypeInfo('EventTarget', custom_to_native=True), | 798     'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), | 
| 790     'HTMLElement': IDLTypeInfo('HTMLElement', custom_to_dart=True), | 799     'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
     True), | 
| 791     'IDBAny': IDLTypeInfo('IDBAny', dart_type='Dynamic', custom_to_native=True), | 800     'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native=
     True), | 
| 792     'IDBKey': IDLTypeInfo('IDBKey', dart_type='Dynamic', custom_to_native=True), | 801     'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee
     t']), | 
| 793     'StyleSheet': IDLTypeInfo('StyleSheet', conversion_includes=['CSSStyleSheet'
     ]), | 802     'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), | 
| 794     'SVGElement': IDLTypeInfo('SVGElement', custom_to_dart=True), |  | 
| 795 | 803 | 
| 796     'SVGAngle': SVGTearOffIDLTypeInfo('SVGAngle'), | 804     'SVGAngle': TypeData(clazz='SVGTearOff'), | 
| 797     'SVGLength': SVGTearOffIDLTypeInfo('SVGLength'), | 805     'SVGLength': TypeData(clazz='SVGTearOff'), | 
| 798     'SVGLengthList': SVGTearOffIDLTypeInfo('SVGLengthList'), | 806     'SVGLengthList': TypeData(clazz='SVGTearOff'), | 
| 799     'SVGMatrix': SVGTearOffIDLTypeInfo('SVGMatrix'), | 807     'SVGMatrix': TypeData(clazz='SVGTearOff'), | 
| 800     'SVGNumber': SVGTearOffIDLTypeInfo('SVGNumber', native_type='SVGPropertyTear
     Off<float>'), | 808     'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl
     oat>'), | 
| 801     'SVGNumberList': SVGTearOffIDLTypeInfo('SVGNumberList'), | 809     'SVGNumberList': TypeData(clazz='SVGTearOff'), | 
| 802     'SVGPathSegList': SVGTearOffIDLTypeInfo('SVGPathSegList', native_type='SVGPa
     thSegListPropertyTearOff'), | 810     'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr
     opertyTearOff'), | 
| 803     'SVGPoint': SVGTearOffIDLTypeInfo('SVGPoint', native_type='SVGPropertyTearOf
     f<FloatPoint>'), | 811     'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo
     atPoint>'), | 
| 804     'SVGPointList': SVGTearOffIDLTypeInfo('SVGPointList'), | 812     'SVGPointList': TypeData(clazz='SVGTearOff'), | 
| 805     'SVGPreserveAspectRatio': SVGTearOffIDLTypeInfo('SVGPreserveAspectRatio'), | 813     'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), | 
| 806     'SVGRect': SVGTearOffIDLTypeInfo('SVGRect', native_type='SVGPropertyTearOff<
     FloatRect>'), | 814     'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa
     tRect>'), | 
| 807     'SVGStringList': SVGTearOffIDLTypeInfo('SVGStringList', native_type='SVGStat
     icListPropertyTearOff<SVGStringList>'), | 815     'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp
     ertyTearOff<SVGStringList>'), | 
| 808     'SVGTransform': SVGTearOffIDLTypeInfo('SVGTransform'), | 816     'SVGTransform': TypeData(clazz='SVGTearOff'), | 
| 809     'SVGTransformList': SVGTearOffIDLTypeInfo('SVGTransformList', native_type='S
     VGTransformListPropertyTearOff') | 817     'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi
     stPropertyTearOff') | 
| 810 } | 818 } | 
| 811 | 819 | 
| 812 _svg_supplemental_includes = [ | 820 _svg_supplemental_includes = [ | 
| 813     '"SVGAnimatedPropertyTearOff.h"', | 821     '"SVGAnimatedPropertyTearOff.h"', | 
| 814     '"SVGAnimatedListPropertyTearOff.h"', | 822     '"SVGAnimatedListPropertyTearOff.h"', | 
| 815     '"SVGStaticListPropertyTearOff.h"', | 823     '"SVGStaticListPropertyTearOff.h"', | 
| 816     '"SVGAnimatedListPropertyTearOff.h"', | 824     '"SVGAnimatedListPropertyTearOff.h"', | 
| 817     '"SVGTransformListPropertyTearOff.h"', | 825     '"SVGTransformListPropertyTearOff.h"', | 
| 818     '"SVGPathSegListPropertyTearOff.h"', | 826     '"SVGPathSegListPropertyTearOff.h"', | 
| 819 ] | 827 ] | 
| 820 | 828 | 
| 821 def GetIDLTypeInfo(idl_type_name): | 829 class TypeRegistry(object): | 
| 822   type_info = _idl_type_registry.get(idl_type_name) | 830   def __init__(self): | 
| 823   if type_info is not None: | 831     self._cache = {} | 
| 824     return type_info |  | 
| 825 | 832 | 
| 826   match = re.match(r'sequence<(\w+)>$', idl_type_name) | 833   def TypeInfo(self, type_name): | 
| 827   if match: | 834     if not type_name in self._cache: | 
| 828     return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 835       self._cache[type_name] = self._TypeInfo(type_name) | 
|  | 836     return self._cache[type_name] | 
| 829 | 837 | 
| 830   match = re.match(r'(\w+)\[\]$', idl_type_name) | 838   def _TypeInfo(self, type_name): | 
| 831   if match: | 839     match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) | 
| 832     return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 840     if match: | 
| 833 | 841       if type_name == 'DOMString[]': | 
| 834   return IDLTypeInfo(idl_type_name) | 842         return DOMStringArrayTypeInfo(self.TypeInfo('DOMString')) | 
|  | 843       return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc
     h.group(2))) | 
|  | 844     if not type_name in _idl_type_registry: | 
|  | 845       return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) | 
|  | 846     type_data = _idl_type_registry.get(type_name) | 
|  | 847     class_name = '%sIDLTypeInfo' % type_data.clazz | 
|  | 848     return globals()[class_name](type_name, type_data) | 
| OLD | NEW | 
|---|