| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 '\n' | 691 '\n' |
| 692 ' void operator[]=(int index, $TYPE value) {\n' | 692 ' void operator[]=(int index, $TYPE value) {\n' |
| 693 ' throw new UnsupportedOperationException("Cannot assign element
of immutable List.");\n' | 693 ' throw new UnsupportedOperationException("Cannot assign element
of immutable List.");\n' |
| 694 ' }\n', | 694 ' }\n', |
| 695 TYPE=self._NarrowInputType(element_type)) | 695 TYPE=self._NarrowInputType(element_type)) |
| 696 | 696 |
| 697 # TODO(sra): Use separate mixins for mutable implementations of List<T>. | 697 # TODO(sra): Use separate mixins for mutable implementations of List<T>. |
| 698 # TODO(sra): Use separate mixins for typed array implementations of List<T>. | 698 # TODO(sra): Use separate mixins for typed array implementations of List<T>. |
| 699 if self._interface.id != 'NodeList': | 699 if self._interface.id != 'NodeList': |
| 700 template_file = 'immutable_list_mixin.darttemplate' | 700 template_file = 'immutable_list_mixin.darttemplate' |
| 701 template = self._template_loader.Load(template_file) | 701 has_contains = any(op.id == 'contains' for op in self._interface.operation
s) |
| 702 template = self._template_loader.Load( |
| 703 template_file, |
| 704 {'DEFINE_CONTAINS': not has_contains}) |
| 702 self._members_emitter.Emit(template, E=self._DartType(element_type)) | 705 self._members_emitter.Emit(template, E=self._DartType(element_type)) |
| 703 | 706 |
| 704 def AddAttribute(self, attribute, html_name, read_only): | 707 def AddAttribute(self, attribute, html_name, read_only): |
| 705 if self._HasCustomImplementation(attribute.id): | 708 if self._HasCustomImplementation(attribute.id): |
| 706 return | 709 return |
| 707 | 710 |
| 708 if attribute.id != html_name: | 711 if attribute.id != html_name: |
| 709 self._AddAttributeUsingProperties(attribute, html_name, read_only) | 712 self._AddAttributeUsingProperties(attribute, html_name, read_only) |
| 710 return | 713 return |
| 711 | 714 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 | 1114 |
| 1112 library_emitter = self._multiemitter.FileEmitter(library_file_path) | 1115 library_emitter = self._multiemitter.FileEmitter(library_file_path) |
| 1113 library_file_dir = os.path.dirname(library_file_path) | 1116 library_file_dir = os.path.dirname(library_file_path) |
| 1114 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) | 1117 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) |
| 1115 imports_emitter = library_emitter.Emit( | 1118 imports_emitter = library_emitter.Emit( |
| 1116 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) | 1119 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) |
| 1117 for path in sorted(self._path_to_emitter.keys()): | 1120 for path in sorted(self._path_to_emitter.keys()): |
| 1118 relpath = os.path.relpath(path, library_file_dir) | 1121 relpath = os.path.relpath(path, library_file_dir) |
| 1119 imports_emitter.Emit( | 1122 imports_emitter.Emit( |
| 1120 "#source('$PATH');\n", PATH=massage_path(relpath)) | 1123 "#source('$PATH');\n", PATH=massage_path(relpath)) |
| OLD | NEW |