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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 | 224 |
225 def FinishInterface(self): | 225 def FinishInterface(self): |
226 self._GenerateCPPHeader() | 226 self._GenerateCPPHeader() |
227 | 227 |
228 self._cpp_impl_emitter.Emit( | 228 self._cpp_impl_emitter.Emit( |
229 self._template_loader.Load('cpp_implementation.template'), | 229 self._template_loader.Load('cpp_implementation.template'), |
230 INTERFACE=self._interface.id, | 230 INTERFACE=self._interface.id, |
231 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes), | 231 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes), |
232 CALLBACKS=self._cpp_definitions_emitter.Fragments(), | 232 CALLBACKS=self._cpp_definitions_emitter.Fragments(), |
233 RESOLVER=self._cpp_resolver_emitter.Fragments(), | 233 RESOLVER=self._cpp_resolver_emitter.Fragments(), |
234 DART_IMPLEMENTATION_CLASS=self._interface_type_info.implementation_name( )) | 234 DART_IMPLEMENTATION_CLASS=self._interface_type_info.implementation_name( ), |
235 DART_IMPLEMENTATION_LIBRARY='dart:%s' % self._renamer.GetLibraryName(sel f._interface)) | |
Anton Muhin
2012/11/09 13:13:23
does it have access to self._library_name?
blois
2012/11/09 18:21:56
It does not.
| |
235 | 236 |
236 def _GenerateCPPHeader(self): | 237 def _GenerateCPPHeader(self): |
237 to_native_emitter = emitter.Emitter() | 238 to_native_emitter = emitter.Emitter() |
238 if self._interface_type_info.custom_to_native(): | 239 if self._interface_type_info.custom_to_native(): |
239 to_native_emitter.Emit( | 240 to_native_emitter.Emit( |
240 ' static PassRefPtr<NativeType> toNative(Dart_Handle handle, Dart_H andle& exception);\n') | 241 ' static PassRefPtr<NativeType> toNative(Dart_Handle handle, Dart_H andle& exception);\n') |
241 else: | 242 else: |
242 to_native_emitter.Emit( | 243 to_native_emitter.Emit( |
243 ' static NativeType* toNative(Dart_Handle handle, Dart_Handle& exce ption)\n' | 244 ' static NativeType* toNative(Dart_Handle handle, Dart_Handle& exce ption)\n' |
244 ' {\n' | 245 ' {\n' |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 def EmitResolver(self, template, output_dir): | 889 def EmitResolver(self, template, output_dir): |
889 file_path = os.path.join(output_dir, 'DartResolver.cpp') | 890 file_path = os.path.join(output_dir, 'DartResolver.cpp') |
890 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) | 891 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) |
891 for header_file in self._headers_list: | 892 for header_file in self._headers_list: |
892 path = os.path.relpath(header_file, output_dir) | 893 path = os.path.relpath(header_file, output_dir) |
893 includes_emitter.Emit('#include "$PATH"\n', PATH=path) | 894 includes_emitter.Emit('#include "$PATH"\n', PATH=path) |
894 body_emitter.Emit( | 895 body_emitter.Emit( |
895 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' | 896 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' |
896 ' return func;\n', | 897 ' return func;\n', |
897 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 898 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
OLD | NEW |