| OLD | NEW |
| 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 import os | 10 import os |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 GenerateCall(operation, argument_count, checks) | 802 GenerateCall(operation, argument_count, checks) |
| 803 | 803 |
| 804 # TODO: Optimize the dispatch to avoid repeated checks. | 804 # TODO: Optimize the dispatch to avoid repeated checks. |
| 805 if len(operations) > 1: | 805 if len(operations) > 1: |
| 806 for operation in operations: | 806 for operation in operations: |
| 807 for position, argument in enumerate(operation.arguments): | 807 for position, argument in enumerate(operation.arguments): |
| 808 if self._IsOptional(operation, argument): | 808 if self._IsOptional(operation, argument): |
| 809 GenerateChecksAndCall(operation, position) | 809 GenerateChecksAndCall(operation, position) |
| 810 GenerateChecksAndCall(operation, len(operation.arguments)) | 810 GenerateChecksAndCall(operation, len(operation.arguments)) |
| 811 body.Emit( | 811 body.Emit( |
| 812 ' throw const Exception("Incorrect number or type of arguments");' | 812 ' throw new ArgumentError("Incorrect number or type of arguments");
' |
| 813 '\n'); | 813 '\n'); |
| 814 else: | 814 else: |
| 815 operation = operations[0] | 815 operation = operations[0] |
| 816 argument_count = len(operation.arguments) | 816 argument_count = len(operation.arguments) |
| 817 for position, argument in list(enumerate(operation.arguments))[::-1]: | 817 for position, argument in list(enumerate(operation.arguments))[::-1]: |
| 818 if self._IsOptional(operation, argument): | 818 if self._IsOptional(operation, argument): |
| 819 check = '?%s' % parameter_names[position] | 819 check = '?%s' % parameter_names[position] |
| 820 GenerateCall(operation, position + 1, [check]) | 820 GenerateCall(operation, position + 1, [check]) |
| 821 argument_count = position | 821 argument_count = position |
| 822 GenerateCall(operation, argument_count, []) | 822 GenerateCall(operation, argument_count, []) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 'svg': DartLibrary('svg', template_loader, library_type, output_dir), | 969 'svg': DartLibrary('svg', template_loader, library_type, output_dir), |
| 970 'html': DartLibrary('html', template_loader, library_type, output_dir), | 970 'html': DartLibrary('html', template_loader, library_type, output_dir), |
| 971 } | 971 } |
| 972 | 972 |
| 973 def AddFile(self, basename, library_name, path): | 973 def AddFile(self, basename, library_name, path): |
| 974 self._libraries[library_name].AddFile(path) | 974 self._libraries[library_name].AddFile(path) |
| 975 | 975 |
| 976 def Emit(self, emitter, auxiliary_dir): | 976 def Emit(self, emitter, auxiliary_dir): |
| 977 for lib in self._libraries.values(): | 977 for lib in self._libraries.values(): |
| 978 lib.Emit(emitter, auxiliary_dir) | 978 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |