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..6635a2a8a39c2f59794bf9abfae6978c412d7bfa 100644 |
| --- a/tools/dom/scripts/htmldartgenerator.py |
| +++ b/tools/dom/scripts/htmldartgenerator.py |
| @@ -234,17 +234,32 @@ class HtmlDartGenerator(object): |
| generate_call(stmts_emitter, call_emitter, |
| version[0], signature_index, argument_count) |
| + def IsDartTypeNullable(type_signature): |
|
Anton Muhin
2013/05/23 15:06:25
Andrei, thanks a lot, now I understand what is the
|
| + 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.split('_OR_')): |
| + |
| + checks.append('%s != null' % parameter_name) |
| + 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:]]) |