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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } | 475 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } |
476 # | 476 # |
477 self._members_emitter.Emit( | 477 self._members_emitter.Emit( |
478 '\n' | 478 '\n' |
479 ' $TYPE operator[](int index) => JS("$TYPE", "#[#]", this, index);\n', | 479 ' $TYPE operator[](int index) => JS("$TYPE", "#[#]", this, index);\n', |
480 TYPE=self.SecureOutputType(element_type)) | 480 TYPE=self.SecureOutputType(element_type)) |
481 | 481 |
482 if 'CustomIndexedSetter' in self._interface.ext_attrs: | 482 if 'CustomIndexedSetter' in self._interface.ext_attrs: |
483 self._members_emitter.Emit( | 483 self._members_emitter.Emit( |
484 '\n' | 484 '\n' |
485 ' void operator[]=(int index, $TYPE value) =>' | 485 ' void operator[]=(int index, $TYPE value) {' |
486 ' JS("void", "#[#] = #", this, index, value);\n', | 486 ' JS("void", "#[#] = #", this, index, value); }', |
487 TYPE=self._NarrowInputType(element_type)) | 487 TYPE=self._NarrowInputType(element_type)) |
488 else: | 488 else: |
489 self._members_emitter.Emit( | 489 self._members_emitter.Emit( |
490 '\n' | 490 '\n' |
491 ' void operator[]=(int index, $TYPE value) {\n' | 491 ' void operator[]=(int index, $TYPE value) {\n' |
492 ' throw new UnsupportedError("Cannot assign element of immutable Li
st.");\n' | 492 ' throw new UnsupportedError("Cannot assign element of immutable Li
st.");\n' |
493 ' }\n', | 493 ' }\n', |
494 TYPE=self._NarrowInputType(element_type)) | 494 TYPE=self._NarrowInputType(element_type)) |
495 | 495 |
496 # TODO(sra): Use separate mixins for mutable implementations of List<T>. | 496 # TODO(sra): Use separate mixins for mutable implementations of List<T>. |
(...skipping 472 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 |