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

Unified Diff: tools/dom/scripts/htmldartgenerator.py

Issue 15138002: Added tests to previously broken functionality and added null checks. (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 | « tests/html/canvasrenderingcontext2d_test.dart ('k') | no next file » | 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 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:]])
« no previous file with comments | « tests/html/canvasrenderingcontext2d_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698