Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: lib/dom/scripts/generator.py

Issue 10704219: Handle all registered types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/dom/scripts/dartgenerator.py ('k') | lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 dom_frog_native_bodies = { 77 dom_frog_native_bodies = {
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 IsRegisteredType(type_name):
88 if not type_name in _idl_type_registry: 88 return type_name in _idl_type_registry
89 return False
90 return _idl_type_registry[type_name].clazz == 'Primitive'
91 89
92 def ListImplementationInfo(interface, database): 90 def ListImplementationInfo(interface, database):
93 """Returns a tuple (elment_type, requires_indexer). 91 """Returns a tuple (elment_type, requires_indexer).
94 If interface do not have to implement List, element_type is None. 92 If interface do not have to implement List, element_type is None.
95 Otherwise element_type is list element type and requires_indexer 93 Otherwise element_type is list element type and requires_indexer
96 is true iff this interface implementation must have indexer and 94 is true iff this interface implementation must have indexer and
97 false otherwise. False means that interface implementation 95 false otherwise. False means that interface implementation
98 inherits indexer and may just reuse it.""" 96 inherits indexer and may just reuse it."""
99 element_type = MaybeListElementType(interface) 97 element_type = MaybeListElementType(interface)
100 if element_type: 98 if element_type:
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>') , 779 'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>') ,
782 'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True), 780 'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True),
783 'Element': TypeData(clazz='Interface', custom_to_dart=True), 781 'Element': TypeData(clazz='Interface', custom_to_dart=True),
784 'EventListener': TypeData(clazz='Interface', custom_to_native=True), 782 'EventListener': TypeData(clazz='Interface', custom_to_native=True),
785 'EventTarget': TypeData(clazz='Interface', custom_to_native=True), 783 'EventTarget': TypeData(clazz='Interface', custom_to_native=True),
786 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), 784 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True),
787 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True), 785 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True),
788 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True), 786 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True),
789 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee t']), 787 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee t']),
790 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), 788 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True),
789 'MutationRecordArray': TypeData(clazz='Interface', # C++ pass by pointer.
790 native_type='MutationRecordArray',
791 dart_type='List<MutationRecord>'),
791 792
792 'SVGAngle': TypeData(clazz='SVGTearOff'), 793 'SVGAngle': TypeData(clazz='SVGTearOff'),
793 'SVGLength': TypeData(clazz='SVGTearOff'), 794 'SVGLength': TypeData(clazz='SVGTearOff'),
794 'SVGLengthList': TypeData(clazz='SVGTearOff'), 795 'SVGLengthList': TypeData(clazz='SVGTearOff'),
795 'SVGMatrix': TypeData(clazz='SVGTearOff'), 796 'SVGMatrix': TypeData(clazz='SVGTearOff'),
796 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl oat>'), 797 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl oat>'),
797 'SVGNumberList': TypeData(clazz='SVGTearOff'), 798 'SVGNumberList': TypeData(clazz='SVGTearOff'),
798 'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr opertyTearOff'), 799 'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr opertyTearOff'),
799 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo atPoint>'), 800 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo atPoint>'),
800 'SVGPointList': TypeData(clazz='SVGTearOff'), 801 'SVGPointList': TypeData(clazz='SVGTearOff'),
801 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), 802 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'),
802 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa tRect>'), 803 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa tRect>'),
803 'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp ertyTearOff<SVGStringList>'), 804 'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp ertyTearOff<SVGStringList>'),
804 'SVGTransform': TypeData(clazz='SVGTearOff'), 805 'SVGTransform': TypeData(clazz='SVGTearOff'),
805 'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi stPropertyTearOff') 806 'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi stPropertyTearOff'),
806 } 807 }
807 808
808 _svg_supplemental_includes = [ 809 _svg_supplemental_includes = [
809 '"SVGAnimatedPropertyTearOff.h"', 810 '"SVGAnimatedPropertyTearOff.h"',
810 '"SVGAnimatedListPropertyTearOff.h"', 811 '"SVGAnimatedListPropertyTearOff.h"',
811 '"SVGStaticListPropertyTearOff.h"', 812 '"SVGStaticListPropertyTearOff.h"',
812 '"SVGAnimatedListPropertyTearOff.h"', 813 '"SVGAnimatedListPropertyTearOff.h"',
813 '"SVGTransformListPropertyTearOff.h"', 814 '"SVGTransformListPropertyTearOff.h"',
814 '"SVGPathSegListPropertyTearOff.h"', 815 '"SVGPathSegListPropertyTearOff.h"',
815 ] 816 ]
(...skipping 23 matching lines...) Expand all
839 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) 840 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name)
840 if match: 841 if match:
841 if type_name == 'DOMString[]': 842 if type_name == 'DOMString[]':
842 return DOMStringArrayTypeInfo(self.TypeInfo('DOMString')) 843 return DOMStringArrayTypeInfo(self.TypeInfo('DOMString'))
843 return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc h.group(2))) 844 return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc h.group(2)))
844 if not type_name in _idl_type_registry: 845 if not type_name in _idl_type_registry:
845 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) 846 return InterfaceIDLTypeInfo(type_name, TypeData('Interface'))
846 type_data = _idl_type_registry.get(type_name) 847 type_data = _idl_type_registry.get(type_name)
847 class_name = '%sIDLTypeInfo' % type_data.clazz 848 class_name = '%sIDLTypeInfo' % type_data.clazz
848 return globals()[class_name](type_name, type_data) 849 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « lib/dom/scripts/dartgenerator.py ('k') | lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698