| 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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 if not read_only: | 773 if not read_only: |
| 774 self._AddRenamingSetter(attribute, html_name) | 774 self._AddRenamingSetter(attribute, html_name) |
| 775 | 775 |
| 776 def _AddRenamingGetter(self, attr, html_name): | 776 def _AddRenamingGetter(self, attr, html_name): |
| 777 conversion = self._OutputConversion(attr.type.id, attr.id) | 777 conversion = self._OutputConversion(attr.type.id, attr.id) |
| 778 if conversion: | 778 if conversion: |
| 779 return self._AddConvertingGetter(attr, html_name, conversion) | 779 return self._AddConvertingGetter(attr, html_name, conversion) |
| 780 return_type = self._NarrowOutputType(attr.type.id) | 780 return_type = self._NarrowOutputType(attr.type.id) |
| 781 self._members_emitter.Emit( | 781 self._members_emitter.Emit( |
| 782 # TODO(sra): Use metadata to provide native name. | 782 # TODO(sra): Use metadata to provide native name. |
| 783 '\n $TYPE get $HTML_NAME() => JS("$TYPE", "#.$NAME", this);' | 783 '\n $TYPE get $HTML_NAME => JS("$TYPE", "#.$NAME", this);' |
| 784 '\n', | 784 '\n', |
| 785 HTML_NAME=html_name, | 785 HTML_NAME=html_name, |
| 786 NAME=attr.id, | 786 NAME=attr.id, |
| 787 TYPE=return_type) | 787 TYPE=return_type) |
| 788 | 788 |
| 789 def _AddRenamingSetter(self, attr, html_name): | 789 def _AddRenamingSetter(self, attr, html_name): |
| 790 conversion = self._InputConversion(attr.type.id, attr.id) | 790 conversion = self._InputConversion(attr.type.id, attr.id) |
| 791 if conversion: | 791 if conversion: |
| 792 return self._AddConvertingSetter(attr, html_name, conversion) | 792 return self._AddConvertingSetter(attr, html_name, conversion) |
| 793 self._members_emitter.Emit( | 793 self._members_emitter.Emit( |
| 794 # TODO(sra): Use metadata to provide native name. | 794 # TODO(sra): Use metadata to provide native name. |
| 795 '\n void set $HTML_NAME($TYPE value) {' | 795 '\n void set $HTML_NAME($TYPE value) {' |
| 796 '\n JS("void", "#.$NAME = #", this, value);' | 796 '\n JS("void", "#.$NAME = #", this, value);' |
| 797 '\n }' | 797 '\n }' |
| 798 '\n', | 798 '\n', |
| 799 HTML_NAME=html_name, | 799 HTML_NAME=html_name, |
| 800 NAME=attr.id, | 800 NAME=attr.id, |
| 801 TYPE=self._NarrowInputType(attr.type.id)) | 801 TYPE=self._NarrowInputType(attr.type.id)) |
| 802 | 802 |
| 803 def _AddConvertingGetter(self, attr, html_name, conversion): | 803 def _AddConvertingGetter(self, attr, html_name, conversion): |
| 804 self._members_emitter.Emit( | 804 self._members_emitter.Emit( |
| 805 # TODO(sra): Use metadata to provide native name. | 805 # TODO(sra): Use metadata to provide native name. |
| 806 '\n $RETURN_TYPE get $HTML_NAME => $CONVERT(this._$(HTML_NAME));' | 806 '\n $RETURN_TYPE get $HTML_NAME => $CONVERT(this._$(HTML_NAME));' |
| 807 '\n $NATIVE_TYPE get _$HTML_NAME() =>' | 807 '\n $NATIVE_TYPE get _$HTML_NAME =>' |
| 808 ' JS("$NATIVE_TYPE", "#.$NAME", this);' | 808 ' JS("$NATIVE_TYPE", "#.$NAME", this);' |
| 809 '\n', | 809 '\n', |
| 810 CONVERT=conversion.function_name, | 810 CONVERT=conversion.function_name, |
| 811 HTML_NAME=html_name, | 811 HTML_NAME=html_name, |
| 812 NAME=attr.id, | 812 NAME=attr.id, |
| 813 RETURN_TYPE=conversion.output_type, | 813 RETURN_TYPE=conversion.output_type, |
| 814 NATIVE_TYPE=conversion.input_type) | 814 NATIVE_TYPE=conversion.input_type) |
| 815 | 815 |
| 816 def _AddConvertingSetter(self, attr, html_name, conversion): | 816 def _AddConvertingSetter(self, attr, html_name, conversion): |
| 817 self._members_emitter.Emit( | 817 self._members_emitter.Emit( |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 | 1116 |
| 1117 library_emitter = self._multiemitter.FileEmitter(library_file_path) | 1117 library_emitter = self._multiemitter.FileEmitter(library_file_path) |
| 1118 library_file_dir = os.path.dirname(library_file_path) | 1118 library_file_dir = os.path.dirname(library_file_path) |
| 1119 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) | 1119 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) |
| 1120 imports_emitter = library_emitter.Emit( | 1120 imports_emitter = library_emitter.Emit( |
| 1121 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) | 1121 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) |
| 1122 for path in sorted(self._path_to_emitter.keys()): | 1122 for path in sorted(self._path_to_emitter.keys()): |
| 1123 relpath = os.path.relpath(path, library_file_dir) | 1123 relpath = os.path.relpath(path, library_file_dir) |
| 1124 imports_emitter.Emit( | 1124 imports_emitter.Emit( |
| 1125 "#source('$PATH');\n", PATH=massage_path(relpath)) | 1125 "#source('$PATH');\n", PATH=massage_path(relpath)) |
| OLD | NEW |