Chromium Code Reviews| Index: tools/dom/scripts/htmldartgenerator.py |
| diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py |
| index 0dc105415817ab79c08e15ece11bbb821d4f9215..6428e64bcf692d0992b49f8d555286d056317b13 100644 |
| --- a/tools/dom/scripts/htmldartgenerator.py |
| +++ b/tools/dom/scripts/htmldartgenerator.py |
| @@ -234,17 +234,31 @@ class HtmlDartGenerator(object): |
| generate_call(stmts_emitter, call_emitter, |
| version[0], signature_index, argument_count) |
| + def IsDartTypeNullable(type_signature): |
| + return type_signature not in ['int', 'double', 'num', 'bool'] |
| + |
| def GenerateChecksAndCall(signature_index, argument_count): |
| checks = [] |
| for i in range(0, argument_count): |
| argument = signatures[signature_index][i] |
| parameter_name = parameter_names[i] |
| test_type = self._DartType(argument.type.id) |
| + nullable = argument.type.nullable |
| + |
| if test_type in ['dynamic', 'Object']: |
| checks.append('?%s' % parameter_name) |
| elif not can_omit_type_check(test_type, i): |
| + nullable = True |
| checks.append('(%s is %s || %s == null)' % ( |
| parameter_name, test_type, parameter_name)) |
| + |
| + if not nullable and not IsDartTypeNullable(test_type): |
| + for signature in signatures: |
| + if (len(signature) <= i or signature[i].id not in parameter_name): |
|
Anton Muhin
2013/05/22 12:27:33
in parameter_name or == parameter_name?
Andrei Mouravski
2013/05/22 12:37:42
This is to handle the case of merged types.
On 20
Anton Muhin
2013/05/22 12:50:56
I am really concerned with the cases like (hypothe
Andrei Mouravski
2013/05/22 14:40:10
Agreed. I'll run a regex instead or else split on
Andrei Mouravski
2013/05/23 09:53:27
Done.
|
| + |
| + checks.append('%s != null' % parameter_name) |
|
Anton Muhin
2013/05/22 12:27:33
still, I do not understand why this check is neede
Andrei Mouravski
2013/05/22 12:37:42
Because other logic does some dumb things and if t
Anton Muhin
2013/05/22 12:50:56
May you, please, provide an exact example: which c
Andrei Mouravski
2013/05/22 14:40:10
Please take a look at the tests added in this CL.
|
| + break |
| + |
| # There can be multiple presence checks. We need them all since a later |
| # optional argument could have been passed by name, leaving 'holes'. |
| checks.extend(['!?%s' % name for name in parameter_names[argument_count:]]) |