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 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 def _HasCustomImplementation(self, member_name): | 921 def _HasCustomImplementation(self, member_name): |
922 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) | 922 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) |
923 return member_name in _js_custom_members | 923 return member_name in _js_custom_members |
924 | 924 |
925 def _RenamingAnnotation(self, idl_name, member_name): | 925 def _RenamingAnnotation(self, idl_name, member_name): |
926 if member_name != idl_name: | 926 if member_name != idl_name: |
927 return "@JSName('%s')\n " % idl_name | 927 return "@JSName('%s')\n " % idl_name |
928 return '' | 928 return '' |
929 | 929 |
930 def _Annotations(self, idl_type, idl_member_name): | 930 def _Annotations(self, idl_type, idl_member_name): |
| 931 out = '' |
931 annotations = FindDart2JSAnnotations(idl_type, self._interface.id, | 932 annotations = FindDart2JSAnnotations(idl_type, self._interface.id, |
932 idl_member_name) | 933 idl_member_name) |
933 if annotations: | 934 if annotations: |
934 return '%s\n ' % annotations | 935 out = '%s\n ' % annotations |
935 return_type = self.SecureOutputType(idl_type) | 936 if not AnyConversionAnnotations(idl_type, self._interface.id, |
936 native_type = self._NarrowToImplementationType(idl_type) | 937 idl_member_name): |
937 if native_type != return_type: | 938 return_type = self.SecureOutputType(idl_type) |
938 return "@Returns('%s') @Creates('%s')\n " % (native_type, native_type) | 939 native_type = self._NarrowToImplementationType(idl_type) |
939 else: | 940 if native_type != return_type: |
940 return '' | 941 out += "@Returns('%s') @Creates('%s')\n " % (native_type, native_type) |
| 942 return out |
941 | 943 |
942 def CustomJSMembers(self): | 944 def CustomJSMembers(self): |
943 return _js_custom_members | 945 return _js_custom_members |
944 | 946 |
945 def _NarrowToImplementationType(self, type_name): | 947 def _NarrowToImplementationType(self, type_name): |
946 return self._type_registry.TypeInfo(type_name).narrow_dart_type() | 948 return self._type_registry.TypeInfo(type_name).narrow_dart_type() |
947 | 949 |
948 def _NarrowInputType(self, type_name): | 950 def _NarrowInputType(self, type_name): |
949 return self._NarrowToImplementationType(type_name) | 951 return self._NarrowToImplementationType(type_name) |
950 | 952 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 for library_name in libraries: | 1049 for library_name in libraries: |
1048 self._libraries[library_name] = DartLibrary( | 1050 self._libraries[library_name] = DartLibrary( |
1049 library_name, template_loader, library_type, output_dir) | 1051 library_name, template_loader, library_type, output_dir) |
1050 | 1052 |
1051 def AddFile(self, basename, library_name, path): | 1053 def AddFile(self, basename, library_name, path): |
1052 self._libraries[library_name].AddFile(path) | 1054 self._libraries[library_name].AddFile(path) |
1053 | 1055 |
1054 def Emit(self, emitter, auxiliary_dir): | 1056 def Emit(self, emitter, auxiliary_dir): |
1055 for lib in self._libraries.values(): | 1057 for lib in self._libraries.values(): |
1056 lib.Emit(emitter, auxiliary_dir) | 1058 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |