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 systems to generate | 6 """This module provides shared functionality for the systems to generate |
7 native binding from the IDL database.""" | 7 native binding from the IDL database.""" |
8 | 8 |
9 import emitter | 9 import emitter |
10 import os | 10 import os |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 HANDLERS=cpp_impl_handlers_emitter.Fragments()) | 114 HANDLERS=cpp_impl_handlers_emitter.Fragments()) |
115 | 115 |
116 def GenerateLibraries(self, lib_dir): | 116 def GenerateLibraries(self, lib_dir): |
117 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir) | 117 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir) |
118 | 118 |
119 # Generate dom_public.dart. | 119 # Generate dom_public.dart. |
120 self._GenerateLibFile( | 120 self._GenerateLibFile( |
121 'dom_public.darttemplate', | 121 'dom_public.darttemplate', |
122 os.path.join(self._output_dir, 'dom_public.dart'), | 122 os.path.join(self._output_dir, 'dom_public.dart'), |
123 self._dom_public_files, | 123 self._dom_public_files, |
124 AUXILIARY_DIR=auxiliary_dir); | 124 AUXILIARY_DIR=EscapePath(auxiliary_dir)); |
125 | 125 |
126 # Generate dom_impl.dart. | 126 # Generate dom_impl.dart. |
127 self._GenerateLibFile( | 127 self._GenerateLibFile( |
128 'dom_impl.darttemplate', | 128 'dom_impl.darttemplate', |
129 os.path.join(self._output_dir, 'dom_impl.dart'), | 129 os.path.join(self._output_dir, 'dom_impl.dart'), |
130 self._dom_impl_files, | 130 self._dom_impl_files, |
131 AUXILIARY_DIR=auxiliary_dir); | 131 AUXILIARY_DIR=EscapePath(auxiliary_dir)); |
132 | 132 |
133 # Generate DartDerivedSourcesXX.cpp. | 133 # Generate DartDerivedSourcesXX.cpp. |
134 partitions = 20 # FIXME: this should be configurable. | 134 partitions = 20 # FIXME: this should be configurable. |
135 sources_count = len(self._cpp_impl_files) | 135 sources_count = len(self._cpp_impl_files) |
136 for i in range(0, partitions): | 136 for i in range(0, partitions): |
137 derived_sources_path = os.path.join(self._output_dir, | 137 derived_sources_path = os.path.join(self._output_dir, |
138 'DartDerivedSources%02i.cpp' % (i + 1)) | 138 'DartDerivedSources%02i.cpp' % (i + 1)) |
139 | 139 |
140 includes_emitter = emitter.Emitter() | 140 includes_emitter = emitter.Emitter() |
141 for impl_file in self._cpp_impl_files[i::partitions]: | 141 for impl_file in self._cpp_impl_files[i::partitions]: |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 754 |
755 if 'ImplementedBy' in attributes: | 755 if 'ImplementedBy' in attributes: |
756 arguments.insert(0, 'receiver') | 756 arguments.insert(0, 'receiver') |
757 self._cpp_impl_includes.add(attributes['ImplementedBy']) | 757 self._cpp_impl_includes.add(attributes['ImplementedBy']) |
758 | 758 |
759 return emitter.Format(invocation_template, | 759 return emitter.Format(invocation_template, |
760 FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments))) | 760 FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments))) |
761 | 761 |
762 def _GenerateCPPIncludes(includes): | 762 def _GenerateCPPIncludes(includes): |
763 return ''.join(['#include "%s.h"\n' % include for include in includes]) | 763 return ''.join(['#include "%s.h"\n' % include for include in includes]) |
OLD | NEW |