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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 # ------------------------------------------------------------------------------ | 870 # ------------------------------------------------------------------------------ |
871 | 871 |
872 class DartLibraryEmitter(): | 872 class DartLibraryEmitter(): |
873 def __init__(self, multiemitter, dart_sources_dir, dart_libraries): | 873 def __init__(self, multiemitter, dart_sources_dir, dart_libraries): |
874 self._multiemitter = multiemitter | 874 self._multiemitter = multiemitter |
875 self._dart_sources_dir = dart_sources_dir | 875 self._dart_sources_dir = dart_sources_dir |
876 self._path_to_emitter = {} | 876 self._path_to_emitter = {} |
877 self._dart_libraries = dart_libraries | 877 self._dart_libraries = dart_libraries |
878 | 878 |
879 def FileEmitter(self, basename, library_name, template=None): | 879 def FileEmitter(self, basename, library_name, template=None): |
880 path = os.path.join(self._dart_sources_dir, '%s.dart' % basename) | 880 aux_dir = os.path.join(self._dart_sources_dir, library_name) |
| 881 path = os.path.join(aux_dir, '%s.dart' % basename) |
881 if not path in self._path_to_emitter: | 882 if not path in self._path_to_emitter: |
882 emitter = self._multiemitter.FileEmitter(path) | 883 emitter = self._multiemitter.FileEmitter(path) |
883 if not template is None: | 884 if not template is None: |
884 emitter = emitter.Emit(template) | 885 emitter = emitter.Emit(template) |
885 self._path_to_emitter[path] = emitter | 886 self._path_to_emitter[path] = emitter |
886 | 887 |
887 self._dart_libraries.AddFile(basename, library_name, path) | 888 self._dart_libraries.AddFile(basename, library_name, path) |
888 return self._path_to_emitter[path] | 889 return self._path_to_emitter[path] |
889 | 890 |
890 def EmitLibraries(self, auxiliary_dir): | 891 def EmitLibraries(self, auxiliary_dir): |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 'svg': DartLibrary('svg', template_loader, library_type, output_dir), | 927 'svg': DartLibrary('svg', template_loader, library_type, output_dir), |
927 'html': DartLibrary('html', template_loader, library_type, output_dir), | 928 'html': DartLibrary('html', template_loader, library_type, output_dir), |
928 } | 929 } |
929 | 930 |
930 def AddFile(self, basename, library_name, path): | 931 def AddFile(self, basename, library_name, path): |
931 self._libraries[library_name].AddFile(path) | 932 self._libraries[library_name].AddFile(path) |
932 | 933 |
933 def Emit(self, emitter, auxiliary_dir): | 934 def Emit(self, emitter, auxiliary_dir): |
934 for lib in self._libraries.values(): | 935 for lib in self._libraries.values(): |
935 lib.Emit(emitter, auxiliary_dir) | 936 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |