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

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

Issue 11819034: No need in require_v8_scope flag any more. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « no previous file | tools/dom/scripts/systemnative.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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 806
807 def native_type(self): 807 def native_type(self):
808 return self._data.native_type or self._idl_type 808 return self._data.native_type or self._idl_type
809 809
810 def bindings_class(self): 810 def bindings_class(self):
811 return 'Dart%s' % self.idl_type() 811 return 'Dart%s' % self.idl_type()
812 812
813 def vector_to_dart_template_parameter(self): 813 def vector_to_dart_template_parameter(self):
814 return self.bindings_class() 814 return self.bindings_class()
815 815
816 def requires_v8_scope(self):
817 return self._data.requires_v8_scope
818
819 def to_native_info(self, idl_node, interface_name): 816 def to_native_info(self, idl_node, interface_name):
820 cls = self.bindings_class() 817 cls = self.bindings_class()
821 818
822 if 'Callback' in idl_node.ext_attrs: 819 if 'Callback' in idl_node.ext_attrs:
823 return '%s', 'RefPtr<%s>' % self.native_type(), cls, 'create' 820 return '%s', 'RefPtr<%s>' % self.native_type(), cls, 'create'
824 821
825 if self.custom_to_native(): 822 if self.custom_to_native():
826 type = 'RefPtr<%s>' % self.native_type() 823 type = 'RefPtr<%s>' % self.native_type()
827 argument_expression_template = '%s.get()' 824 argument_expression_template = '%s.get()'
828 else: 825 else:
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 return name if interface_name.endswith('List') else '%s->propertyReference() ' % name 1074 return name if interface_name.endswith('List') else '%s->propertyReference() ' % name
1078 1075
1079 1076
1080 class TypeData(object): 1077 class TypeData(object):
1081 def __init__(self, clazz, dart_type=None, native_type=None, 1078 def __init__(self, clazz, dart_type=None, native_type=None,
1082 merged_interface=None, merged_into=None, 1079 merged_interface=None, merged_into=None,
1083 custom_to_dart=None, custom_to_native=None, 1080 custom_to_dart=None, custom_to_native=None,
1084 conversion_includes=None, 1081 conversion_includes=None,
1085 webcore_getter_name='getAttribute', 1082 webcore_getter_name='getAttribute',
1086 webcore_setter_name='setAttribute', 1083 webcore_setter_name='setAttribute',
1087 requires_v8_scope=False,
1088 item_type=None, suppress_interface=False, is_typed_array=False): 1084 item_type=None, suppress_interface=False, is_typed_array=False):
1089 self.clazz = clazz 1085 self.clazz = clazz
1090 self.dart_type = dart_type 1086 self.dart_type = dart_type
1091 self.native_type = native_type 1087 self.native_type = native_type
1092 self.merged_interface = merged_interface 1088 self.merged_interface = merged_interface
1093 self.merged_into = merged_into 1089 self.merged_into = merged_into
1094 self.custom_to_dart = custom_to_dart 1090 self.custom_to_dart = custom_to_dart
1095 self.custom_to_native = custom_to_native 1091 self.custom_to_native = custom_to_native
1096 self.conversion_includes = conversion_includes 1092 self.conversion_includes = conversion_includes
1097 self.webcore_getter_name = webcore_getter_name 1093 self.webcore_getter_name = webcore_getter_name
1098 self.webcore_setter_name = webcore_setter_name 1094 self.webcore_setter_name = webcore_setter_name
1099 self.requires_v8_scope = requires_v8_scope
1100 self.item_type = item_type 1095 self.item_type = item_type
1101 self.suppress_interface = suppress_interface 1096 self.suppress_interface = suppress_interface
1102 self.is_typed_array = is_typed_array 1097 self.is_typed_array = is_typed_array
1103 1098
1104 1099
1105 def TypedArrayTypeData(item_type): 1100 def TypedArrayTypeData(item_type):
1106 return TypeData(clazz='Interface', item_type=item_type, is_typed_array=True) 1101 return TypeData(clazz='Interface', item_type=item_type, is_typed_array=True)
1107 1102
1108 1103
1109 _idl_type_registry = { 1104 _idl_type_registry = {
(...skipping 13 matching lines...) Expand all
1123 webcore_setter_name='setIntegralAttribute'), 1118 webcore_setter_name='setIntegralAttribute'),
1124 'unsigned long': TypeData(clazz='Primitive', dart_type='int', 1119 'unsigned long': TypeData(clazz='Primitive', dart_type='int',
1125 native_type='unsigned', 1120 native_type='unsigned',
1126 webcore_getter_name='getUnsignedIntegralAttribute' , 1121 webcore_getter_name='getUnsignedIntegralAttribute' ,
1127 webcore_setter_name='setUnsignedIntegralAttribute' ), 1122 webcore_setter_name='setUnsignedIntegralAttribute' ),
1128 'long long': TypeData(clazz='Primitive', dart_type='int'), 1123 'long long': TypeData(clazz='Primitive', dart_type='int'),
1129 'unsigned long long': TypeData(clazz='Primitive', dart_type='int'), 1124 'unsigned long long': TypeData(clazz='Primitive', dart_type='int'),
1130 'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'), 1125 'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'),
1131 'double': TypeData(clazz='Primitive', dart_type='num'), 1126 'double': TypeData(clazz='Primitive', dart_type='num'),
1132 1127
1133 'any': TypeData(clazz='Primitive', dart_type='Object', native_type='ScriptVa lue', requires_v8_scope=True), 1128 'any': TypeData(clazz='Primitive', dart_type='Object', native_type='ScriptVa lue'),
1134 'Array': TypeData(clazz='Primitive', dart_type='List'), 1129 'Array': TypeData(clazz='Primitive', dart_type='List'),
1135 'custom': TypeData(clazz='Primitive', dart_type='dynamic'), 1130 'custom': TypeData(clazz='Primitive', dart_type='dynamic'),
1136 'Date': TypeData(clazz='Primitive', dart_type='Date', native_type='double'), 1131 'Date': TypeData(clazz='Primitive', dart_type='Date', native_type='double'),
1137 'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc riptValue'), 1132 'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc riptValue'),
1138 'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St ring'), 1133 'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St ring'),
1139 # TODO(vsm): This won't actually work until we convert the Map to 1134 # TODO(vsm): This won't actually work until we convert the Map to
1140 # a native JS Map for JS DOM. 1135 # a native JS Map for JS DOM.
1141 'Dictionary': TypeData(clazz='Primitive', dart_type='Map', requires_v8_scope =True), 1136 'Dictionary': TypeData(clazz='Primitive', dart_type='Map'),
1142 # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} 1137 # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool}
1143 # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa ce 1138 # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa ce
1144 'Flags': TypeData(clazz='Primitive', dart_type='Object'), 1139 'Flags': TypeData(clazz='Primitive', dart_type='Object'),
1145 'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un signed long long'), 1140 'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un signed long long'),
1146 'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip tValue'), 1141 'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip tValue'),
1147 'ObjectArray': TypeData(clazz='Primitive', dart_type='List'), 1142 'ObjectArray': TypeData(clazz='Primitive', dart_type='List'),
1148 'PositionOptions': TypeData(clazz='Primitive', dart_type='Object'), 1143 'PositionOptions': TypeData(clazz='Primitive', dart_type='Object'),
1149 # TODO(sra): Come up with some meaningful name so that where this appears in 1144 # TODO(sra): Come up with some meaningful name so that where this appears in
1150 # the documentation, the user is made aware that only a limited subset of 1145 # the documentation, the user is made aware that only a limited subset of
1151 # serializable types are actually permitted. 1146 # serializable types are actually permitted.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 self) 1293 self)
1299 1294
1300 if type_data.clazz == 'SVGTearOff': 1295 if type_data.clazz == 'SVGTearOff':
1301 dart_interface_name = self._renamer.RenameInterface( 1296 dart_interface_name = self._renamer.RenameInterface(
1302 self._database.GetInterface(type_name)) 1297 self._database.GetInterface(type_name))
1303 return SVGTearOffIDLTypeInfo( 1298 return SVGTearOffIDLTypeInfo(
1304 type_name, type_data, dart_interface_name, self) 1299 type_name, type_data, dart_interface_name, self)
1305 1300
1306 class_name = '%sIDLTypeInfo' % type_data.clazz 1301 class_name = '%sIDLTypeInfo' % type_data.clazz
1307 return globals()[class_name](type_name, type_data) 1302 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « no previous file | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698