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 monitored | 10 import monitored |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 '\n void set $HTML_NAME($TYPE value) {' | 813 '\n void set $HTML_NAME($TYPE value) {' |
814 '\n JS("void", "#.$NAME = #", this, value);' | 814 '\n JS("void", "#.$NAME = #", this, value);' |
815 '\n }' | 815 '\n }' |
816 '\n', | 816 '\n', |
817 HTML_NAME=html_name, | 817 HTML_NAME=html_name, |
818 NAME=attr.id, | 818 NAME=attr.id, |
819 TYPE=self._NarrowInputType(attr.type.id)) | 819 TYPE=self._NarrowInputType(attr.type.id)) |
820 | 820 |
821 def _AddConvertingGetter(self, attr, html_name, conversion): | 821 def _AddConvertingGetter(self, attr, html_name, conversion): |
822 self._members_emitter.Emit( | 822 self._members_emitter.Emit( |
823 '\n $RETURN_TYPE get $HTML_NAME => $CONVERT(this._$(HTML_NAME));' | 823 '\n $RETURN_TYPE get $HTML_NAME => $CONVERT(this._get_$(HTML_NAME));' |
824 "\n @JSName('$NAME')" | 824 "\n @JSName('$NAME')" |
825 '\n $(ANNOTATIONS)final $NATIVE_TYPE _$HTML_NAME;' | 825 '\n $(ANNOTATIONS)final $NATIVE_TYPE _get_$HTML_NAME;' |
826 '\n', | 826 '\n', |
827 ANNOTATIONS=self._Annotations(attr.type.id, html_name), | 827 ANNOTATIONS=self._Annotations(attr.type.id, html_name), |
828 CONVERT=conversion.function_name, | 828 CONVERT=conversion.function_name, |
829 HTML_NAME=html_name, | 829 HTML_NAME=html_name, |
830 NAME=attr.id, | 830 NAME=attr.id, |
831 RETURN_TYPE=conversion.output_type, | 831 RETURN_TYPE=conversion.output_type, |
832 NATIVE_TYPE=conversion.input_type) | 832 NATIVE_TYPE=conversion.input_type) |
833 | 833 |
834 def _AddConvertingSetter(self, attr, html_name, conversion): | 834 def _AddConvertingSetter(self, attr, html_name, conversion): |
835 self._members_emitter.Emit( | 835 self._members_emitter.Emit( |
836 # TODO(sra): Use metadata to provide native name. | 836 # TODO(sra): Use metadata to provide native name. |
837 '\n void set $HTML_NAME($INPUT_TYPE value) {' | 837 '\n void set $HTML_NAME($INPUT_TYPE value) {' |
838 '\n this._$HTML_NAME = $CONVERT(value);' | 838 '\n this._set_$HTML_NAME = $CONVERT(value);' |
839 '\n }' | 839 '\n }' |
840 '\n void set _$HTML_NAME(/*$NATIVE_TYPE*/ value) {' | 840 '\n void set _set_$HTML_NAME(/*$NATIVE_TYPE*/ value) {' |
841 '\n JS("void", "#.$NAME = #", this, value);' | 841 '\n JS("void", "#.$NAME = #", this, value);' |
842 '\n }' | 842 '\n }' |
843 '\n', | 843 '\n', |
844 CONVERT=conversion.function_name, | 844 CONVERT=conversion.function_name, |
845 HTML_NAME=html_name, | 845 HTML_NAME=html_name, |
846 NAME=attr.id, | 846 NAME=attr.id, |
847 INPUT_TYPE=conversion.input_type, | 847 INPUT_TYPE=conversion.input_type, |
848 NATIVE_TYPE=conversion.output_type) | 848 NATIVE_TYPE=conversion.output_type) |
849 | 849 |
850 def AmendIndexer(self, element_type): | 850 def AmendIndexer(self, element_type): |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 for library_name in libraries: | 1135 for library_name in libraries: |
1136 self._libraries[library_name] = DartLibrary( | 1136 self._libraries[library_name] = DartLibrary( |
1137 library_name, template_loader, library_type, output_dir) | 1137 library_name, template_loader, library_type, output_dir) |
1138 | 1138 |
1139 def AddFile(self, basename, library_name, path): | 1139 def AddFile(self, basename, library_name, path): |
1140 self._libraries[library_name].AddFile(path) | 1140 self._libraries[library_name].AddFile(path) |
1141 | 1141 |
1142 def Emit(self, emitter, auxiliary_dir): | 1142 def Emit(self, emitter, auxiliary_dir): |
1143 for lib in self._libraries.values(): | 1143 for lib in self._libraries.values(): |
1144 lib.Emit(emitter, auxiliary_dir) | 1144 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |