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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 ' JS("void", "#[#] = #", this, index, value);\n', | 690 ' JS("void", "#[#] = #", this, index, value);\n', |
691 TYPE=self._NarrowInputType(element_type)) | 691 TYPE=self._NarrowInputType(element_type)) |
692 else: | 692 else: |
693 # The HTML library implementation of NodeList has a custom indexed setter | 693 # The HTML library implementation of NodeList has a custom indexed setter |
694 # implementation that uses the parent node the NodeList is associated | 694 # implementation that uses the parent node the NodeList is associated |
695 # with if one is available. | 695 # with if one is available. |
696 if self._interface.id != 'NodeList': | 696 if self._interface.id != 'NodeList': |
697 self._members_emitter.Emit( | 697 self._members_emitter.Emit( |
698 '\n' | 698 '\n' |
699 ' void operator[]=(int index, $TYPE value) {\n' | 699 ' void operator[]=(int index, $TYPE value) {\n' |
700 ' throw new UnsupportedOperationException("Cannot assign element
of immutable List.");\n' | 700 ' throw new StateError("Cannot assign element of immutable List."
);\n' |
701 ' }\n', | 701 ' }\n', |
702 TYPE=self._NarrowInputType(element_type)) | 702 TYPE=self._NarrowInputType(element_type)) |
703 | 703 |
704 # TODO(sra): Use separate mixins for mutable implementations of List<T>. | 704 # TODO(sra): Use separate mixins for mutable implementations of List<T>. |
705 # TODO(sra): Use separate mixins for typed array implementations of List<T>. | 705 # TODO(sra): Use separate mixins for typed array implementations of List<T>. |
706 if self._interface.id != 'NodeList': | 706 if self._interface.id != 'NodeList': |
707 template_file = 'immutable_list_mixin.darttemplate' | 707 template_file = 'immutable_list_mixin.darttemplate' |
708 has_contains = any(op.id == 'contains' for op in self._interface.operation
s) | 708 has_contains = any(op.id == 'contains' for op in self._interface.operation
s) |
709 template = self._template_loader.Load( | 709 template = self._template_loader.Load( |
710 template_file, | 710 template_file, |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 | 1114 |
1115 library_emitter = self._multiemitter.FileEmitter(library_file_path) | 1115 library_emitter = self._multiemitter.FileEmitter(library_file_path) |
1116 library_file_dir = os.path.dirname(library_file_path) | 1116 library_file_dir = os.path.dirname(library_file_path) |
1117 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) | 1117 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) |
1118 imports_emitter = library_emitter.Emit( | 1118 imports_emitter = library_emitter.Emit( |
1119 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) | 1119 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) |
1120 for path in sorted(self._path_to_emitter.keys()): | 1120 for path in sorted(self._path_to_emitter.keys()): |
1121 relpath = os.path.relpath(path, library_file_dir) | 1121 relpath = os.path.relpath(path, library_file_dir) |
1122 imports_emitter.Emit( | 1122 imports_emitter.Emit( |
1123 "#source('$PATH');\n", PATH=massage_path(relpath)) | 1123 "#source('$PATH');\n", PATH=massage_path(relpath)) |
OLD | NEW |