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

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

Issue 15885002: 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, 7 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 | « sdk/lib/web_gl/dart2js/web_gl_dart2js.dart ('k') | tools/dom/scripts/htmldartgenerator.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 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 return len(filter(lambda i: not i.is_optional, self.param_infos))
362
360 def ParametersAsArgumentList(self, parameter_count=None): 363 def ParametersAsArgumentList(self, parameter_count=None):
361 """Returns a string of the parameter names suitable for passing the 364 """Returns a string of the parameter names suitable for passing the
362 parameters as arguments. 365 parameters as arguments.
363 """ 366 """
364 def param_name(param_info): 367 def param_name(param_info):
365 if self.requires_named_arguments and param_info.is_optional: 368 if self.requires_named_arguments and param_info.is_optional:
366 return '%s : %s' % (param_info.name, param_info.name) 369 return '%s : %s' % (param_info.name, param_info.name)
367 else: 370 else:
368 return param_info.name 371 return param_info.name
369 372
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 type_name, type_data, dart_interface_name, self) 1106 type_name, type_data, dart_interface_name, self)
1104 1107
1105 if type_data.clazz == 'BasicTypedList': 1108 if type_data.clazz == 'BasicTypedList':
1106 dart_interface_name = self._renamer.RenameInterface( 1109 dart_interface_name = self._renamer.RenameInterface(
1107 self._database.GetInterface(type_name)) 1110 self._database.GetInterface(type_name))
1108 return BasicTypedListIDLTypeInfo( 1111 return BasicTypedListIDLTypeInfo(
1109 type_name, type_data, dart_interface_name, self) 1112 type_name, type_data, dart_interface_name, self)
1110 1113
1111 class_name = '%sIDLTypeInfo' % type_data.clazz 1114 class_name = '%sIDLTypeInfo' % type_data.clazz
1112 return globals()[class_name](type_name, type_data) 1115 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « sdk/lib/web_gl/dart2js/web_gl_dart2js.dart ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698