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

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

Issue 12052076: Support overloaded constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return info 208 return info
209 209
210 210
211 def AnalyzeConstructor(interface): 211 def AnalyzeConstructor(interface):
212 """Returns an OperationInfo object for the constructor. 212 """Returns an OperationInfo object for the constructor.
213 213
214 Returns None if the interface has no Constructor. 214 Returns None if the interface has no Constructor.
215 """ 215 """
216 if 'Constructor' in interface.ext_attrs: 216 if 'Constructor' in interface.ext_attrs:
217 name = None 217 name = None
218 func_value = interface.ext_attrs.get('Constructor') 218 overloads = interface.ext_attrs['Constructor']
219 if not func_value: 219 idl_args = [[] if f is None else f.arguments for f in overloads]
220 args = []
221 idl_args = []
222 elif 'NamedConstructor' in interface.ext_attrs: 220 elif 'NamedConstructor' in interface.ext_attrs:
223 func_value = interface.ext_attrs.get('NamedConstructor') 221 func_value = interface.ext_attrs.get('NamedConstructor')
222 idl_args = [func_value.arguments]
224 name = func_value.id 223 name = func_value.id
225 else: 224 else:
226 return None 225 return None
227 226
228 if func_value:
229 idl_args = func_value.arguments
230 args =_BuildArguments([idl_args], interface, True)
231
232 info = OperationInfo() 227 info = OperationInfo()
233 info.overloads = None 228 info.overloads = None
234 info.idl_args = idl_args 229 info.idl_args = idl_args
235 info.declared_name = name 230 info.declared_name = name
236 info.name = name 231 info.name = name
237 info.constructor_name = None 232 info.constructor_name = None
238 info.js_name = name 233 info.js_name = name
239 info.type_name = interface.id 234 info.type_name = interface.id
240 info.param_infos = args 235 info.param_infos = _BuildArguments(idl_args, interface, constructor=True)
241 info.requires_named_arguments = False 236 info.requires_named_arguments = False
242 info.pure_dart_constructor = False 237 info.pure_dart_constructor = False
243 return info 238 return info
244 239
245 def IsDartListType(type): 240 def IsDartListType(type):
246 return type == 'List' or type.startswith('sequence<') 241 return type == 'List' or type.startswith('sequence<')
247 242
248 def IsDartCollectionType(type): 243 def IsDartCollectionType(type):
249 return IsDartListType(type) 244 return IsDartListType(type)
250 245
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 self) 1384 self)
1390 1385
1391 if type_data.clazz == 'SVGTearOff': 1386 if type_data.clazz == 'SVGTearOff':
1392 dart_interface_name = self._renamer.RenameInterface( 1387 dart_interface_name = self._renamer.RenameInterface(
1393 self._database.GetInterface(type_name)) 1388 self._database.GetInterface(type_name))
1394 return SVGTearOffIDLTypeInfo( 1389 return SVGTearOffIDLTypeInfo(
1395 type_name, type_data, dart_interface_name, self) 1390 type_name, type_data, dart_interface_name, self)
1396 1391
1397 class_name = '%sIDLTypeInfo' % type_data.clazz 1392 class_name = '%sIDLTypeInfo' % type_data.clazz
1398 return globals()[class_name](type_name, type_data) 1393 return globals()[class_name](type_name, type_data)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698