| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 implements.append(parent_type_info.interface_name()) | 387 implements.append(parent_type_info.interface_name()) |
| 388 | 388 |
| 389 secure_base_name = self._backend.SecureBaseName(interface_name) | 389 secure_base_name = self._backend.SecureBaseName(interface_name) |
| 390 if secure_base_name: | 390 if secure_base_name: |
| 391 implements.append(secure_base_name) | 391 implements.append(secure_base_name) |
| 392 | 392 |
| 393 implements_str = '' | 393 implements_str = '' |
| 394 if implements: | 394 if implements: |
| 395 implements_str = ' implements ' + ', '.join(set(implements)) | 395 implements_str = ' implements ' + ', '.join(set(implements)) |
| 396 | 396 |
| 397 annotations = FindCommonAnnotations(self._interface.doc_js_name) | 397 annotations = FormatAnnotations( |
| 398 annotations_str = '' | 398 FindCommonAnnotations(self._interface.doc_js_name), '') |
| 399 if annotations: | |
| 400 annotations_str = '\n' + '\n'.join(annotations) | |
| 401 | 399 |
| 402 self._implementation_members_emitter = implementation_emitter.Emit( | 400 self._implementation_members_emitter = implementation_emitter.Emit( |
| 403 self._backend.ImplementationTemplate(), | 401 self._backend.ImplementationTemplate(), |
| 404 LIBRARYNAME=self._library_name, | 402 LIBRARYNAME=self._library_name, |
| 405 ANNOTATIONS=annotations_str, | 403 ANNOTATIONS=annotations, |
| 406 CLASSNAME=self._interface_type_info.implementation_name(), | 404 CLASSNAME=self._interface_type_info.implementation_name(), |
| 407 EXTENDS=' extends %s' % base_class if base_class else '', | 405 EXTENDS=' extends %s' % base_class if base_class else '', |
| 408 IMPLEMENTS=implements_str, | 406 IMPLEMENTS=implements_str, |
| 409 DOMNAME=self._interface.doc_js_name, | 407 DOMNAME=self._interface.doc_js_name, |
| 410 NATIVESPEC=self._backend.NativeSpec()) | 408 NATIVESPEC=self._backend.NativeSpec()) |
| 411 self._backend.StartInterface(self._implementation_members_emitter) | 409 self._backend.StartInterface(self._implementation_members_emitter) |
| 412 | 410 |
| 413 self._backend.EmitHelpers(base_class) | 411 self._backend.EmitHelpers(base_class) |
| 414 self._event_generator.EmitStreamProviders( | 412 self._event_generator.EmitStreamProviders( |
| 415 self._interface, | 413 self._interface, |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 914 |
| 917 def _HasCustomImplementation(self, member_name): | 915 def _HasCustomImplementation(self, member_name): |
| 918 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) | 916 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) |
| 919 return member_name in _js_custom_members | 917 return member_name in _js_custom_members |
| 920 | 918 |
| 921 def _RenamingAnnotation(self, idl_name, member_name): | 919 def _RenamingAnnotation(self, idl_name, member_name): |
| 922 if member_name != idl_name: | 920 if member_name != idl_name: |
| 923 return "@JSName('%s')\n " % idl_name | 921 return "@JSName('%s')\n " % idl_name |
| 924 return '' | 922 return '' |
| 925 | 923 |
| 926 def _Annotations(self, idl_type, idl_member_name): | 924 def _Annotations(self, idl_type, idl_member_name, indent=' '): |
| 927 out = '' | 925 anns = FindDart2JSAnnotations(idl_type, self._interface.id, |
| 928 annotations = FindDart2JSAnnotations(idl_type, self._interface.id, | |
| 929 idl_member_name) | 926 idl_member_name) |
| 930 if annotations: | 927 |
| 931 out = '%s\n ' % annotations | |
| 932 if not AnyConversionAnnotations(idl_type, self._interface.id, | 928 if not AnyConversionAnnotations(idl_type, self._interface.id, |
| 933 idl_member_name): | 929 idl_member_name): |
| 934 return_type = self.SecureOutputType(idl_type) | 930 return_type = self.SecureOutputType(idl_type) |
| 935 native_type = self._NarrowToImplementationType(idl_type) | 931 native_type = self._NarrowToImplementationType(idl_type) |
| 936 if native_type != return_type: | 932 if native_type != return_type: |
| 937 out += "@Returns('%s') @Creates('%s')\n " % (native_type, native_type) | 933 anns = anns + [ |
| 938 return out | 934 "@Returns('%s')" % native_type, |
| 935 "@Creates('%s')" % native_type, |
| 936 ] |
| 937 return FormatAnnotations(anns, indent); |
| 939 | 938 |
| 940 def CustomJSMembers(self): | 939 def CustomJSMembers(self): |
| 941 return _js_custom_members | 940 return _js_custom_members |
| 942 | 941 |
| 943 def _NarrowToImplementationType(self, type_name): | 942 def _NarrowToImplementationType(self, type_name): |
| 944 return self._type_registry.TypeInfo(type_name).narrow_dart_type() | 943 return self._type_registry.TypeInfo(type_name).narrow_dart_type() |
| 945 | 944 |
| 946 def _NarrowInputType(self, type_name): | 945 def _NarrowInputType(self, type_name): |
| 947 return self._NarrowToImplementationType(type_name) | 946 return self._NarrowToImplementationType(type_name) |
| 948 | 947 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 for library_name in libraries: | 1044 for library_name in libraries: |
| 1046 self._libraries[library_name] = DartLibrary( | 1045 self._libraries[library_name] = DartLibrary( |
| 1047 library_name, template_loader, library_type, output_dir) | 1046 library_name, template_loader, library_type, output_dir) |
| 1048 | 1047 |
| 1049 def AddFile(self, basename, library_name, path): | 1048 def AddFile(self, basename, library_name, path): |
| 1050 self._libraries[library_name].AddFile(path) | 1049 self._libraries[library_name].AddFile(path) |
| 1051 | 1050 |
| 1052 def Emit(self, emitter, auxiliary_dir): | 1051 def Emit(self, emitter, auxiliary_dir): |
| 1053 for lib in self._libraries.values(): | 1052 for lib in self._libraries.values(): |
| 1054 lib.Emit(emitter, auxiliary_dir) | 1053 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |