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

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

Issue 10957064: Revert 12799. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/html/idl/dart/dart.idl ('k') | lib/html/scripts/systemdart2js.py » ('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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 def argument_expression(self, name, interface_name): 801 def argument_expression(self, name, interface_name):
802 return name if interface_name.endswith('List') else '%s->propertyReference() ' % name 802 return name if interface_name.endswith('List') else '%s->propertyReference() ' % name
803 803
804 804
805 class TypeData(object): 805 class TypeData(object):
806 def __init__(self, clazz, dart_type=None, native_type=None, 806 def __init__(self, clazz, dart_type=None, native_type=None,
807 custom_to_dart=None, custom_to_native=None, 807 custom_to_dart=None, custom_to_native=None,
808 conversion_includes=None, 808 conversion_includes=None,
809 webcore_getter_name='getAttribute', 809 webcore_getter_name='getAttribute',
810 webcore_setter_name='setAttribute', 810 webcore_setter_name='setAttribute',
811 requires_v8_scope=False, suppress_public_interface=False): 811 requires_v8_scope=False):
812 """Constructor.
813 Arguments:
814 - suppress_public_interface is True if we are converting a DOM type to a
815 built-in Dart type in which case we do not want to generate the new
816 interface in the library (FooList -> List<Foo> for example) but we still
817 generate the underlying implementation classes."""
818 self.clazz = clazz 812 self.clazz = clazz
819 self.dart_type = dart_type 813 self.dart_type = dart_type
820 self.native_type = native_type 814 self.native_type = native_type
821 self.custom_to_dart = custom_to_dart 815 self.custom_to_dart = custom_to_dart
822 self.custom_to_native = custom_to_native 816 self.custom_to_native = custom_to_native
823 self.conversion_includes = conversion_includes 817 self.conversion_includes = conversion_includes
824 self.webcore_getter_name = webcore_getter_name 818 self.webcore_getter_name = webcore_getter_name
825 self.webcore_setter_name = webcore_setter_name 819 self.webcore_setter_name = webcore_setter_name
826 self.requires_v8_scope = requires_v8_scope 820 self.requires_v8_scope = requires_v8_scope
827 self.suppress_public_interface = suppress_public_interface
828 821
829 822
830 _idl_type_registry = { 823 _idl_type_registry = {
831 'boolean': TypeData(clazz='Primitive', dart_type='bool', native_type='bool', 824 'boolean': TypeData(clazz='Primitive', dart_type='bool', native_type='bool',
832 webcore_getter_name='hasAttribute', 825 webcore_getter_name='hasAttribute',
833 webcore_setter_name='setBooleanAttribute'), 826 webcore_setter_name='setBooleanAttribute'),
834 'byte': TypeData(clazz='Primitive', dart_type='int', native_type='int'), 827 'byte': TypeData(clazz='Primitive', dart_type='int', native_type='int'),
835 'octet': TypeData(clazz='Primitive', dart_type='int', native_type='int'), 828 'octet': TypeData(clazz='Primitive', dart_type='int', native_type='int'),
836 'short': TypeData(clazz='Primitive', dart_type='int', native_type='int'), 829 'short': TypeData(clazz='Primitive', dart_type='int', native_type='int'),
837 'unsigned short': TypeData(clazz='Primitive', dart_type='int', 830 'unsigned short': TypeData(clazz='Primitive', dart_type='int',
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 # the documentation, the user is made aware that only a limited subset of 864 # the documentation, the user is made aware that only a limited subset of
872 # serializable types are actually permitted. 865 # serializable types are actually permitted.
873 'SerializedScriptValue': TypeData(clazz='Primitive', dart_type='Dynamic'), 866 'SerializedScriptValue': TypeData(clazz='Primitive', dart_type='Dynamic'),
874 # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} 867 # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool}
875 # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa ce 868 # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa ce
876 'WebKitFlags': TypeData(clazz='Primitive', dart_type='Object'), 869 'WebKitFlags': TypeData(clazz='Primitive', dart_type='Object'),
877 870
878 'sequence': TypeData(clazz='Primitive', dart_type='List'), 871 'sequence': TypeData(clazz='Primitive', dart_type='List'),
879 'void': TypeData(clazz='Primitive', dart_type='void'), 872 'void': TypeData(clazz='Primitive', dart_type='void'),
880 873
881 'ClientRectList': TypeData(clazz='Interface', dart_type='List<ClientRect>',
882 custom_to_native=True, suppress_public_interface=True),
883 'CSSRuleList': TypeData(clazz='Interface', dart_type='List<CSSRule>',
884 custom_to_native=True, suppress_public_interface=True),
885 'CSSValueList': TypeData(clazz='Interface', dart_type='List<CSSValue>',
886 custom_to_native=True, suppress_public_interface=True),
887 'CSSRule': TypeData(clazz='Interface', conversion_includes=['CSSImportRule'] ), 874 'CSSRule': TypeData(clazz='Interface', conversion_includes=['CSSImportRule'] ),
888 'DOMException': TypeData(clazz='Interface', native_type='DOMCoreException'), 875 'DOMException': TypeData(clazz='Interface', native_type='DOMCoreException'),
889 'DOMStringList': TypeData(clazz='Interface', dart_type='List<String>', custo m_to_native=True), 876 'DOMStringList': TypeData(clazz='Interface', dart_type='List<String>', custo m_to_native=True),
890 'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>') , 877 'DOMStringMap': TypeData(clazz='Interface', dart_type='Map<String, String>') ,
891 'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True), 878 'DOMWindow': TypeData(clazz='Interface', custom_to_dart=True),
892 'Element': TypeData(clazz='Interface', custom_to_dart=True), 879 'Element': TypeData(clazz='Interface', custom_to_dart=True),
893 'EntryArray': TypeData(clazz='Interface', dart_type='List<EntryArray>',
894 custom_to_native=True, suppress_public_interface=True),
895 'EntryArraySync': TypeData(clazz='Interface',
896 dart_type='List<EntryArraySync>', custom_to_native=True,
897 suppress_public_interface=True),
898 'EventListener': TypeData(clazz='Interface', custom_to_native=True), 880 'EventListener': TypeData(clazz='Interface', custom_to_native=True),
899 'EventTarget': TypeData(clazz='Interface', custom_to_native=True), 881 'EventTarget': TypeData(clazz='Interface', custom_to_native=True),
900 'FileList': TypeData(clazz='Interface', dart_type='List<File>',
901 custom_to_native=True, suppress_public_interface=True),
902 'GamepadList': TypeData(clazz='Interface', dart_type='List<Gamepad>',
903 custom_to_native=True, suppress_public_interface=True),
904 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True), 882 'HTMLElement': TypeData(clazz='Interface', custom_to_dart=True),
905 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True), 883 'IDBAny': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True),
906 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True), 884 'IDBKey': TypeData(clazz='Interface', dart_type='Dynamic', custom_to_native= True),
907 'MediaStreamList': TypeData(clazz='Interface',
908 dart_type='List<MediaStream>', custom_to_native=True,
909 suppress_public_interface=True),
910 'MutationRecordArray': TypeData(clazz='Interface', # C++ pass by pointer. 885 'MutationRecordArray': TypeData(clazz='Interface', # C++ pass by pointer.
911 native_type='MutationRecordArray', dart_type='List<MutationRecord>'), 886 native_type='MutationRecordArray',
887 dart_type='List<MutationRecord>'),
912 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee t']), 888 'StyleSheet': TypeData(clazz='Interface', conversion_includes=['CSSStyleShee t']),
913 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True), 889 'SVGElement': TypeData(clazz='Interface', custom_to_dart=True),
914 'SVGElementInstanceList': TypeData(clazz='Interface',
915 dart_type='List<SVGElementInstance>', custom_to_native=True,
916 suppress_public_interface=True),
917 'SpeechInputResultList': TypeData(clazz='Interface',
918 dart_type='List<SpeechInputResult>', custom_to_native=True,
919 suppress_public_interface=True),
920 'SpeechRecognitionResultList': TypeData(clazz='Interface',
921 dart_type='List<SpeechRecognitionResult>', custom_to_native=True,
922 suppress_public_interface=True),
923 'StyleSheetList': TypeData(clazz='Interface',
924 dart_type='List<StyleSheet>', custom_to_native=True,
925 suppress_public_interface=True),
926 890
927 'SVGAngle': TypeData(clazz='SVGTearOff'), 891 'SVGAngle': TypeData(clazz='SVGTearOff'),
928 'SVGLength': TypeData(clazz='SVGTearOff'), 892 'SVGLength': TypeData(clazz='SVGTearOff'),
929 'SVGLengthList': TypeData(clazz='SVGTearOff'), 893 'SVGLengthList': TypeData(clazz='SVGTearOff'),
930 'SVGMatrix': TypeData(clazz='SVGTearOff'), 894 'SVGMatrix': TypeData(clazz='SVGTearOff'),
931 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl oat>'), 895 'SVGNumber': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<fl oat>'),
932 'SVGNumberList': TypeData(clazz='SVGTearOff'), 896 'SVGNumberList': TypeData(clazz='SVGTearOff'),
933 'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr opertyTearOff'), 897 'SVGPathSegList': TypeData(clazz='SVGTearOff', native_type='SVGPathSegListPr opertyTearOff'),
934 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo atPoint>'), 898 'SVGPoint': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Flo atPoint>'),
935 'SVGPointList': TypeData(clazz='SVGTearOff'), 899 'SVGPointList': TypeData(clazz='SVGTearOff'),
936 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'), 900 'SVGPreserveAspectRatio': TypeData(clazz='SVGTearOff'),
937 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa tRect>'), 901 'SVGRect': TypeData(clazz='SVGTearOff', native_type='SVGPropertyTearOff<Floa tRect>'),
938 'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp ertyTearOff<SVGStringList>'), 902 'SVGStringList': TypeData(clazz='SVGTearOff', native_type='SVGStaticListProp ertyTearOff<SVGStringList>'),
939 'SVGTransform': TypeData(clazz='SVGTearOff'), 903 'SVGTransform': TypeData(clazz='SVGTearOff'),
940 'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi stPropertyTearOff'), 904 'SVGTransformList': TypeData(clazz='SVGTearOff', native_type='SVGTransformLi stPropertyTearOff'),
941 } 905 }
942 906
943 # A list constructed of DOM types that are converted to built-in dart types
944 # (like Lists) and therefore whose actual interface generation should be
945 # suppressed. (For type information, we still generate the implementations
946 # though, so these types should not be suppressed entirely.)
947 nativified_classes = {}
948 for key in _idl_type_registry:
949 value = _idl_type_registry[key]
950 if value.suppress_public_interface:
951 nativified_classes[value.dart_type] = key
952
953 _svg_supplemental_includes = [ 907 _svg_supplemental_includes = [
954 '"SVGAnimatedPropertyTearOff.h"', 908 '"SVGAnimatedPropertyTearOff.h"',
955 '"SVGAnimatedListPropertyTearOff.h"', 909 '"SVGAnimatedListPropertyTearOff.h"',
956 '"SVGStaticListPropertyTearOff.h"', 910 '"SVGStaticListPropertyTearOff.h"',
957 '"SVGAnimatedListPropertyTearOff.h"', 911 '"SVGAnimatedListPropertyTearOff.h"',
958 '"SVGTransformListPropertyTearOff.h"', 912 '"SVGTransformListPropertyTearOff.h"',
959 '"SVGPathSegListPropertyTearOff.h"', 913 '"SVGPathSegListPropertyTearOff.h"',
960 ] 914 ]
961 915
962 class TypeRegistry(object): 916 class TypeRegistry(object):
(...skipping 22 matching lines...) Expand all
985 if match: 939 if match:
986 if type_name == 'DOMString[]': 940 if type_name == 'DOMString[]':
987 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt ring')) 941 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt ring'))
988 item_info = self.TypeInfo(match.group(1) or match.group(2)) 942 item_info = self.TypeInfo(match.group(1) or match.group(2))
989 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) 943 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info)
990 if not type_name in _idl_type_registry: 944 if not type_name in _idl_type_registry:
991 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) 945 return InterfaceIDLTypeInfo(type_name, TypeData('Interface'))
992 type_data = _idl_type_registry.get(type_name) 946 type_data = _idl_type_registry.get(type_name)
993 class_name = '%sIDLTypeInfo' % type_data.clazz 947 class_name = '%sIDLTypeInfo' % type_data.clazz
994 return globals()[class_name](type_name, type_data) 948 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « lib/html/idl/dart/dart.idl ('k') | lib/html/scripts/systemdart2js.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698