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

Side by Side Diff: dart/tools/dom/scripts/htmldartgenerator.py

Issue 363243002: Version 1.5.3 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.5/
Patch Set: Created 6 years, 5 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 | « dart/tools/dom/scripts/generator.py ('k') | dart/tools/dom/scripts/systemhtml.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 the system to generate 6 """This module provides shared functionality for the system to generate
7 dart:html APIs from the IDL database.""" 7 dart:html APIs from the IDL database."""
8 8
9 import emitter 9 import emitter
10 from generator import AnalyzeOperation, ConstantOutputOrder, \ 10 from generator import AnalyzeOperation, ConstantOutputOrder, \
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 351
352 version[0] += 1 352 version[0] += 1
353 generate_call(stmts_emitter, call_emitter, 353 generate_call(stmts_emitter, call_emitter,
354 version[0], signature_index, argument_count) 354 version[0], signature_index, argument_count)
355 355
356 def GenerateChecksAndCall(signature_index, argument_count): 356 def GenerateChecksAndCall(signature_index, argument_count):
357 checks = [] 357 checks = []
358 for i in reversed(range(0, argument_count)): 358 for i in reversed(range(0, argument_count)):
359 argument = signatures[signature_index][i] 359 argument = signatures[signature_index][i]
360 parameter_name = parameter_names[i] 360 parameter_name = parameter_names[i]
361 test_type = self._DartType(argument.type.id) 361
362 test_type = self._NarrowToImplementationType(argument.type.id)
362 363
363 if test_type in ['dynamic', 'Object']: 364 if test_type in ['dynamic', 'Object']:
364 checks.append('%s != null' % parameter_name) 365 checks.append('%s != null' % parameter_name)
365 elif not can_omit_type_check(test_type, i): 366 elif not can_omit_type_check(test_type, i):
366 checks.append('(%s is %s || %s == null)' % ( 367 checks.append('(%s is %s || %s == null)' % (
367 parameter_name, test_type, parameter_name)) 368 parameter_name, test_type, parameter_name))
368 elif i >= number_of_required_in_dart: 369 elif i >= number_of_required_in_dart:
369 checks.append('%s != null' % parameter_name) 370 checks.append('%s != null' % parameter_name)
370 371
371 # There can be multiple presence checks. We need them all since a later 372 # There can be multiple presence checks. We need them all since a later
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 # returned in generated code. 749 # returned in generated code.
749 assert(dart_name != 'HistoryBase' and dart_name != 'LocationBase') 750 assert(dart_name != 'HistoryBase' and dart_name != 'LocationBase')
750 if dart_name == 'Window': 751 if dart_name == 'Window':
751 return _secure_base_types[dart_name] 752 return _secure_base_types[dart_name]
752 return dart_name 753 return dart_name
753 754
754 def SecureBaseName(self, type_name): 755 def SecureBaseName(self, type_name):
755 if type_name in _secure_base_types: 756 if type_name in _secure_base_types:
756 return _secure_base_types[type_name] 757 return _secure_base_types[type_name]
757 758
759 def _NarrowToImplementationType(self, type_name):
760 return self._type_registry.TypeInfo(type_name).narrow_dart_type()
761
762 def _NarrowInputType(self, type_name):
763 return self._NarrowToImplementationType(type_name)
764
758 def _DartType(self, type_name): 765 def _DartType(self, type_name):
759 return self._type_registry.DartType(type_name) 766 return self._type_registry.DartType(type_name)
760 767
761 def _TypeInfo(self, type_name): 768 def _TypeInfo(self, type_name):
762 return self._type_registry.TypeInfo(type_name) 769 return self._type_registry.TypeInfo(type_name)
OLDNEW
« no previous file with comments | « dart/tools/dom/scripts/generator.py ('k') | dart/tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698