| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 399 |
| 400 secure_base_name = self._backend.SecureBaseName(interface_name) | 400 secure_base_name = self._backend.SecureBaseName(interface_name) |
| 401 if secure_base_name: | 401 if secure_base_name: |
| 402 implements.append(secure_base_name) | 402 implements.append(secure_base_name) |
| 403 | 403 |
| 404 implements_str = '' | 404 implements_str = '' |
| 405 if implements: | 405 if implements: |
| 406 implements_str = ' implements ' + ', '.join(set(implements)) | 406 implements_str = ' implements ' + ', '.join(set(implements)) |
| 407 | 407 |
| 408 annotations = FormatAnnotationsAndComments( | 408 annotations = FormatAnnotationsAndComments( |
| 409 GetAnnotationsAndComments(self._interface.doc_js_name, | 409 GetAnnotationsAndComments(self._library_name, |
| 410 library_name=self._library_name), '') | 410 self._interface.doc_js_name), '') |
| 411 | 411 |
| 412 self._implementation_members_emitter = implementation_emitter.Emit( | 412 self._implementation_members_emitter = implementation_emitter.Emit( |
| 413 self._backend.ImplementationTemplate(), | 413 self._backend.ImplementationTemplate(), |
| 414 LIBRARYNAME=self._library_name, | 414 LIBRARYNAME=self._library_name, |
| 415 ANNOTATIONS=annotations, | 415 ANNOTATIONS=annotations, |
| 416 CLASSNAME=self._interface_type_info.implementation_name(), | 416 CLASSNAME=self._interface_type_info.implementation_name(), |
| 417 EXTENDS=' extends %s' % base_class if base_class else '', | 417 EXTENDS=' extends %s' % base_class if base_class else '', |
| 418 IMPLEMENTS=implements_str, | 418 IMPLEMENTS=implements_str, |
| 419 DOMNAME=self._interface.doc_js_name, | 419 DOMNAME=self._interface.doc_js_name, |
| 420 NATIVESPEC=self._backend.NativeSpec()) | 420 NATIVESPEC=self._backend.NativeSpec()) |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 def _HasCustomImplementation(self, member_name): | 890 def _HasCustomImplementation(self, member_name): |
| 891 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) | 891 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) |
| 892 return member_name in _js_custom_members | 892 return member_name in _js_custom_members |
| 893 | 893 |
| 894 def _RenamingAnnotation(self, idl_name, member_name): | 894 def _RenamingAnnotation(self, idl_name, member_name): |
| 895 if member_name != idl_name: | 895 if member_name != idl_name: |
| 896 return "@JSName('%s')\n " % idl_name | 896 return "@JSName('%s')\n " % idl_name |
| 897 return '' | 897 return '' |
| 898 | 898 |
| 899 def _Annotations(self, idl_type, idl_member_name, indent=' '): | 899 def _Annotations(self, idl_type, idl_member_name, indent=' '): |
| 900 anns = FindDart2JSAnnotationsAndComments(idl_type, self._interface.id, | 900 anns = FindDart2JSAnnotationsAndComments(idl_type, self._library_name, |
| 901 idl_member_name, self._library_name) | 901 self._interface.id, |
| 902 idl_member_name) |
| 902 | 903 |
| 903 if not AnyConversionAnnotations(idl_type, self._interface.id, | 904 if not AnyConversionAnnotations(idl_type, self._interface.id, |
| 904 idl_member_name): | 905 idl_member_name): |
| 905 return_type = self.SecureOutputType(idl_type) | 906 return_type = self.SecureOutputType(idl_type) |
| 906 native_type = self._NarrowToImplementationType(idl_type) | 907 native_type = self._NarrowToImplementationType(idl_type) |
| 907 if native_type != return_type: | 908 if native_type != return_type: |
| 908 anns = anns + [ | 909 anns = anns + [ |
| 909 "@Returns('%s')" % native_type, | 910 "@Returns('%s')" % native_type, |
| 910 "@Creates('%s')" % native_type, | 911 "@Creates('%s')" % native_type, |
| 911 ] | 912 ] |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 for library_name in libraries: | 1020 for library_name in libraries: |
| 1020 self._libraries[library_name] = DartLibrary( | 1021 self._libraries[library_name] = DartLibrary( |
| 1021 library_name, template_loader, library_type, output_dir) | 1022 library_name, template_loader, library_type, output_dir) |
| 1022 | 1023 |
| 1023 def AddFile(self, basename, library_name, path): | 1024 def AddFile(self, basename, library_name, path): |
| 1024 self._libraries[library_name].AddFile(path) | 1025 self._libraries[library_name].AddFile(path) |
| 1025 | 1026 |
| 1026 def Emit(self, emitter, auxiliary_dir): | 1027 def Emit(self, emitter, auxiliary_dir): |
| 1027 for lib in self._libraries.values(): | 1028 for lib in self._libraries.values(): |
| 1028 lib.Emit(emitter, auxiliary_dir) | 1029 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |