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

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

Issue 15850004: Verify that correct number of arguments was passed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 json 10 import json
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 argtexts = map(FormatParam, required) 350 argtexts = map(FormatParam, required)
351 if optional: 351 if optional:
352 needs_named = self.requires_named_arguments and not force_optional 352 needs_named = self.requires_named_arguments and not force_optional
353 left_bracket, right_bracket = '{}' if needs_named else '[]' 353 left_bracket, right_bracket = '{}' if needs_named else '[]'
354 argtexts.append( 354 argtexts.append(
355 left_bracket + 355 left_bracket +
356 ', '.join(map(FormatParam, optional)) + 356 ', '.join(map(FormatParam, optional)) +
357 right_bracket) 357 right_bracket)
358 return ', '.join(argtexts) 358 return ', '.join(argtexts)
359 359
360 def NumberOfRequiredInDart(self):
361 """ Returns a number of required arguments in Dart declaration of
362 the operation.
363 """
364 return len(filter(lambda i: not i.is_optional, self.param_infos))
365
360 def ParametersAsArgumentList(self, parameter_count=None): 366 def ParametersAsArgumentList(self, parameter_count=None):
361 """Returns a string of the parameter names suitable for passing the 367 """Returns a string of the parameter names suitable for passing the
362 parameters as arguments. 368 parameters as arguments.
363 """ 369 """
364 def param_name(param_info): 370 def param_name(param_info):
365 if self.requires_named_arguments and param_info.is_optional: 371 if self.requires_named_arguments and param_info.is_optional:
366 return '%s : %s' % (param_info.name, param_info.name) 372 return '%s : %s' % (param_info.name, param_info.name)
367 else: 373 else:
368 return param_info.name 374 return param_info.name
369 375
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 type_name, type_data, dart_interface_name, self) 1109 type_name, type_data, dart_interface_name, self)
1104 1110
1105 if type_data.clazz == 'BasicTypedList': 1111 if type_data.clazz == 'BasicTypedList':
1106 dart_interface_name = self._renamer.RenameInterface( 1112 dart_interface_name = self._renamer.RenameInterface(
1107 self._database.GetInterface(type_name)) 1113 self._database.GetInterface(type_name))
1108 return BasicTypedListIDLTypeInfo( 1114 return BasicTypedListIDLTypeInfo(
1109 type_name, type_data, dart_interface_name, self) 1115 type_name, type_data, dart_interface_name, self)
1110 1116
1111 class_name = '%sIDLTypeInfo' % type_data.clazz 1117 class_name = '%sIDLTypeInfo' % type_data.clazz
1112 return globals()[class_name](type_name, type_data) 1118 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698