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

Unified Diff: tools/dom/scripts/htmldartgenerator.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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/htmldartgenerator.py
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index 266bc20c7a25d3724b42301e1daacc64d5ff643a..26aab5a3faa007afdde7b28ac064c5385ba56cbe 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -198,14 +198,17 @@ class HtmlDartGenerator(object):
self.EmitOperation(info, method_name)
def _GenerateOverloadDispatcher(self,
+ info,
signatures,
is_void,
- parameter_names,
declaration,
generate_call,
is_optional,
can_omit_type_check=lambda type, pos: False):
+ parameter_names = [p.name for p in info.param_infos]
+ number_of_required_in_dart = info.NumberOfRequiredInDart()
+
body_emitter = self._members_emitter.Emit(
'\n'
' $DECLARATION {\n'
@@ -246,13 +249,8 @@ class HtmlDartGenerator(object):
elif not can_omit_type_check(test_type, i):
checks.append('(%s is %s || %s == null)' % (
parameter_name, test_type, parameter_name))
- else:
- for signature in signatures:
- if (len(signature) <= i or signature[i].id not in
- parameter_name.split('_OR_')):
-
- checks.append('?%s' % parameter_name)
- break
+ elif i >= number_of_required_in_dart:
+ checks.append('?%s' % parameter_name)
# There can be multiple presence checks. We need them all since a later
# optional argument could have been passed by name, leaving 'holes'.
@@ -307,8 +305,8 @@ class HtmlDartGenerator(object):
GenerateCall(0, argument_count, [])
def _GenerateDispatcherBody(self,
+ info,
operations,
- parameter_names,
declaration,
generate_call,
is_optional,
@@ -324,9 +322,9 @@ class HtmlDartGenerator(object):
return is_optional(operations[signature_index], argument)
self._GenerateOverloadDispatcher(
+ info,
[operation.arguments for operation in operations],
operations[0].type.id == 'void',
- parameter_names,
declaration,
GenerateCall,
IsOptional,
@@ -437,9 +435,9 @@ class HtmlDartGenerator(object):
constructor_full_name = constructor_info._ConstructorFullName(
self._DartType)
self._GenerateOverloadDispatcher(
+ constructor_info,
constructor_info.idl_args,
False,
- [info.name for info in constructor_info.param_infos],
emitter.Format('$(METADATA)$FACTORY_KEYWORD $CTOR($PARAMS)',
FACTORY_KEYWORD=('factory' if not custom_factory_ctr else
'static %s' % constructor_full_name),
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698