| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 argument.id)) | 82 argument.id)) |
| 83 arguments.append(argument_type_info.to_dart_conversion(argument.id)) | 83 arguments.append(argument_type_info.to_dart_conversion(argument.id)) |
| 84 cpp_impl_includes |= set(argument_type_info.conversion_includes()) | 84 cpp_impl_includes |= set(argument_type_info.conversion_includes()) |
| 85 | 85 |
| 86 native_return_type = GetIDLTypeInfo(operation.type.id).native_type() | 86 native_return_type = GetIDLTypeInfo(operation.type.id).native_type() |
| 87 cpp_header_handlers_emitter.Emit( | 87 cpp_header_handlers_emitter.Emit( |
| 88 '\n' | 88 '\n' |
| 89 ' virtual $TYPE handleEvent($PARAMETERS);\n', | 89 ' virtual $TYPE handleEvent($PARAMETERS);\n', |
| 90 TYPE=native_return_type, PARAMETERS=', '.join(parameters)) | 90 TYPE=native_return_type, PARAMETERS=', '.join(parameters)) |
| 91 | 91 |
| 92 arguments_declaration = 'Dart_Handle arguments[] = { %s }' % ', '.join(arg
uments) |
| 93 if not len(arguments): |
| 94 arguments_declaration = 'Dart_Handle* arguments = 0' |
| 92 cpp_impl_handlers_emitter.Emit( | 95 cpp_impl_handlers_emitter.Emit( |
| 93 '\n' | 96 '\n' |
| 94 '$TYPE $CLASS_NAME::handleEvent($PARAMETERS)\n' | 97 '$TYPE $CLASS_NAME::handleEvent($PARAMETERS)\n' |
| 95 '{\n' | 98 '{\n' |
| 96 ' if (!m_callback.isolate()->isAlive())\n' | 99 ' if (!m_callback.isolate()->isAlive())\n' |
| 97 ' return$ERROR_RETURN;\n' | 100 ' return$ERROR_RETURN;\n' |
| 98 ' DartIsolate::Scope scope(m_callback.isolate());\n' | 101 ' DartIsolate::Scope scope(m_callback.isolate());\n' |
| 99 ' DartApiScope apiScope;\n' | 102 ' DartApiScope apiScope;\n' |
| 100 ' Dart_Handle arguments[] = { $ARGUMENTS };\n' | 103 ' $ARGUMENTS_DECLARATION;\n' |
| 101 ' $(RETURN_PREFIX)m_callback.handleEvent($ARGUMENT_COUNT, arguments
);\n' | 104 ' $(RETURN_PREFIX)m_callback.handleEvent($ARGUMENT_COUNT, arguments
);\n' |
| 102 '}\n', | 105 '}\n', |
| 103 TYPE=native_return_type, | 106 TYPE=native_return_type, |
| 104 CLASS_NAME=class_name, | 107 CLASS_NAME=class_name, |
| 105 PARAMETERS=', '.join(parameters), | 108 PARAMETERS=', '.join(parameters), |
| 106 ERROR_RETURN=error_return, | 109 ERROR_RETURN=error_return, |
| 107 RETURN_PREFIX=return_prefix, | 110 RETURN_PREFIX=return_prefix, |
| 108 ARGUMENTS=', '.join(arguments), | 111 ARGUMENTS_DECLARATION=arguments_declaration, |
| 109 ARGUMENT_COUNT=len(arguments)) | 112 ARGUMENT_COUNT=len(arguments)) |
| 110 | 113 |
| 111 cpp_header_path = self._FilePathForCppHeader(self._interface.id) | 114 cpp_header_path = self._FilePathForCppHeader(self._interface.id) |
| 112 cpp_header_emitter = self._emitters.FileEmitter(cpp_header_path) | 115 cpp_header_emitter = self._emitters.FileEmitter(cpp_header_path) |
| 113 cpp_header_emitter.Emit( | 116 cpp_header_emitter.Emit( |
| 114 self._templates.Load('cpp_callback_header.template'), | 117 self._templates.Load('cpp_callback_header.template'), |
| 115 INTERFACE=self._interface.id, | 118 INTERFACE=self._interface.id, |
| 116 HANDLERS=cpp_header_handlers_emitter.Fragments()) | 119 HANDLERS=cpp_header_handlers_emitter.Fragments()) |
| 117 | 120 |
| 118 cpp_impl_path = self._FilePathForCppImplementation(self._interface.id) | 121 cpp_impl_path = self._FilePathForCppImplementation(self._interface.id) |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 def _InstanceOfNode(database, interface): | 838 def _InstanceOfNode(database, interface): |
| 836 if interface.id == 'Node': | 839 if interface.id == 'Node': |
| 837 return True | 840 return True |
| 838 for parent in interface.parents: | 841 for parent in interface.parents: |
| 839 if not database.HasInterface(parent.type.id): | 842 if not database.HasInterface(parent.type.id): |
| 840 continue | 843 continue |
| 841 parent_interface = database.GetInterface(parent.type.id) | 844 parent_interface = database.GetInterface(parent.type.id) |
| 842 if _InstanceOfNode(database, parent_interface): | 845 if _InstanceOfNode(database, parent_interface): |
| 843 return True | 846 return True |
| 844 return False | 847 return False |
| OLD | NEW |