| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, 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 generates Dart APIs from the IDL database.""" | 6 """This module generates Dart APIs from the IDL database.""" |
| 7 | 7 |
| 8 import emitter | 8 import emitter |
| 9 import idlnode | 9 import idlnode |
| 10 import logging | 10 import logging |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 self._ComputeInheritanceClosure() | 424 self._ComputeInheritanceClosure() |
| 425 | 425 |
| 426 interface_system = WrappingInterfacesSystem( | 426 interface_system = WrappingInterfacesSystem( |
| 427 TemplateLoader('../templates', ['dom/interface', 'dom', '']), | 427 TemplateLoader('../templates', ['dom/interface', 'dom', '']), |
| 428 self._database, self._emitters, self._output_dir) | 428 self._database, self._emitters, self._output_dir) |
| 429 | 429 |
| 430 wrapping_system = WrappingImplementationSystem( | 430 wrapping_system = WrappingImplementationSystem( |
| 431 TemplateLoader('../templates', ['dom/wrapping', 'dom', '']), | 431 TemplateLoader('../templates', ['dom/wrapping', 'dom', '']), |
| 432 self._database, self._emitters, self._output_dir) | 432 self._database, self._emitters, self._output_dir) |
| 433 | 433 |
| 434 # Makes wrapper implementations available for listing in interface lib. | 434 # Makes interface files available for listing in the library for the |
| 435 interface_system._implementation_system = wrapping_system | 435 # wrapping implementation. |
| 436 wrapping_system._interface_system = interface_system |
| 436 | 437 |
| 437 frog_system = FrogSystem( | 438 frog_system = FrogSystem( |
| 438 TemplateLoader('../templates', ['dom/frog', 'dom', '']), | 439 TemplateLoader('../templates', ['dom/frog', 'dom', '']), |
| 439 self._database, self._emitters, self._output_dir) | 440 self._database, self._emitters, self._output_dir) |
| 440 | 441 |
| 441 self._systems = [interface_system, | 442 self._systems = [interface_system, |
| 442 wrapping_system, | 443 wrapping_system, |
| 443 frog_system] | 444 frog_system] |
| 444 | 445 |
| 445 # Render all interfaces into Dart and save them in files. | 446 # Render all interfaces into Dart and save them in files. |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 common_prefix, super_interface_name, | 1012 common_prefix, super_interface_name, |
| 1012 source_filter) | 1013 source_filter) |
| 1013 | 1014 |
| 1014 def ProcessCallback(self, interface, info): | 1015 def ProcessCallback(self, interface, info): |
| 1015 """Generates a typedef for the callback interface.""" | 1016 """Generates a typedef for the callback interface.""" |
| 1016 interface_name = interface.id | 1017 interface_name = interface.id |
| 1017 file_path = self._FilePathForDartInterface(interface_name) | 1018 file_path = self._FilePathForDartInterface(interface_name) |
| 1018 self._ProcessCallback(interface, info, file_path) | 1019 self._ProcessCallback(interface, info, file_path) |
| 1019 | 1020 |
| 1020 def GenerateLibraries(self, lib_dir): | 1021 def GenerateLibraries(self, lib_dir): |
| 1021 # Library generated for implementation. | 1022 pass |
| 1022 self._GenerateLibFile( | |
| 1023 'wrapping_dom.darttemplate', | |
| 1024 os.path.join(lib_dir, 'wrapping_dom.dart'), | |
| 1025 (self._dart_interface_file_paths + | |
| 1026 self._dart_callback_file_paths + | |
| 1027 # FIXME: Move the implementation to a separate | |
| 1028 # library. | |
| 1029 self._implementation_system._dart_wrapping_file_paths | |
| 1030 )) | |
| 1031 | 1023 |
| 1032 | 1024 |
| 1033 def _FilePathForDartInterface(self, interface_name): | 1025 def _FilePathForDartInterface(self, interface_name): |
| 1034 """Returns the file path of the Dart interface definition.""" | 1026 """Returns the file path of the Dart interface definition.""" |
| 1035 return os.path.join(self._output_dir, 'src', 'interface', | 1027 return os.path.join(self._output_dir, 'src', 'interface', |
| 1036 '%s.dart' % interface_name) | 1028 '%s.dart' % interface_name) |
| 1037 | 1029 |
| 1038 | 1030 |
| 1039 # ------------------------------------------------------------------------------ | 1031 # ------------------------------------------------------------------------------ |
| 1040 | 1032 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 return WrappingInterfaceGenerator(interface, super_interface_name, | 1070 return WrappingInterfaceGenerator(interface, super_interface_name, |
| 1079 dart_code, self._wrapping_js_natives, | 1071 dart_code, self._wrapping_js_natives, |
| 1080 self._wrapping_map, | 1072 self._wrapping_map, |
| 1081 self._wrapping_externs, | 1073 self._wrapping_externs, |
| 1082 self._BaseDefines(interface)) | 1074 self._BaseDefines(interface)) |
| 1083 | 1075 |
| 1084 def ProcessCallback(self, interface, info): | 1076 def ProcessCallback(self, interface, info): |
| 1085 pass | 1077 pass |
| 1086 | 1078 |
| 1087 def GenerateLibraries(self, lib_dir): | 1079 def GenerateLibraries(self, lib_dir): |
| 1088 pass | 1080 # Library generated for implementation. |
| 1081 self._GenerateLibFile( |
| 1082 'wrapping_dom.darttemplate', |
| 1083 os.path.join(lib_dir, 'wrapping_dom.dart'), |
| 1084 (self._interface_system._dart_interface_file_paths + |
| 1085 self._interface_system._dart_callback_file_paths + |
| 1086 # FIXME: Move the implementation to a separate library. |
| 1087 self._dart_wrapping_file_paths |
| 1088 )) |
| 1089 |
| 1089 | 1090 |
| 1090 def Finish(self): | 1091 def Finish(self): |
| 1091 self._GenerateJavaScriptExternsWrapping(self._database, self._output_dir) | 1092 self._GenerateJavaScriptExternsWrapping(self._database, self._output_dir) |
| 1092 | 1093 |
| 1093 | 1094 |
| 1094 def _FilePathForDartWrappingImpl(self, interface_name): | 1095 def _FilePathForDartWrappingImpl(self, interface_name): |
| 1095 """Returns the file path of the Dart wrapping implementation.""" | 1096 """Returns the file path of the Dart wrapping implementation.""" |
| 1096 return os.path.join(self._output_dir, 'src', 'wrapping', | 1097 return os.path.join(self._output_dir, 'src', 'wrapping', |
| 1097 '_%sWrappingImplementation.dart' % interface_name) | 1098 '_%sWrappingImplementation.dart' % interface_name) |
| 1098 | 1099 |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 Arguments: | 2074 Arguments: |
| 2074 info: An OperationInfo object. | 2075 info: An OperationInfo object. |
| 2075 """ | 2076 """ |
| 2076 # TODO(vsm): Handle overloads. | 2077 # TODO(vsm): Handle overloads. |
| 2077 self._members_emitter.Emit( | 2078 self._members_emitter.Emit( |
| 2078 '\n' | 2079 '\n' |
| 2079 ' $TYPE $NAME($ARGS) native;\n', | 2080 ' $TYPE $NAME($ARGS) native;\n', |
| 2080 TYPE=info.type_name, | 2081 TYPE=info.type_name, |
| 2081 NAME=info.name, | 2082 NAME=info.name, |
| 2082 ARGS=info.arg_implementation_declaration) | 2083 ARGS=info.arg_implementation_declaration) |
| OLD | NEW |