| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if operation.type.id != 'void': | 464 if operation.type.id != 'void': |
| 465 template = ' if ($CHECKS) {\n return $CALL;\n }\n' | 465 template = ' if ($CHECKS) {\n return $CALL;\n }\n' |
| 466 else: | 466 else: |
| 467 template = ' if ($CHECKS) {\n $CALL;\n return;\n }\n' | 467 template = ' if ($CHECKS) {\n $CALL;\n return;\n }\n' |
| 468 else: | 468 else: |
| 469 if operation.type.id != 'void': | 469 if operation.type.id != 'void': |
| 470 template = ' return $CALL;\n' | 470 template = ' return $CALL;\n' |
| 471 else: | 471 else: |
| 472 template = ' $CALL;\n' | 472 template = ' $CALL;\n' |
| 473 | 473 |
| 474 overload_name = '%s_%s' % (operation.id, version[0]) | 474 overload_name = '_%s_%s' % (operation.id, version[0]) |
| 475 version[0] += 1 | 475 version[0] += 1 |
| 476 argument_list = ', '.join(parameter_names[:argument_count]) | 476 argument_list = ', '.join(parameter_names[:argument_count]) |
| 477 call = '_%s(%s)' % (overload_name, argument_list) | 477 call = '%s(%s)' % (overload_name, argument_list) |
| 478 body.Emit(template, CHECKS=' && '.join(checks), CALL=call) | 478 body.Emit(template, CHECKS=' && '.join(checks), CALL=call) |
| 479 | 479 |
| 480 dart_declaration = '%s%s _%s(%s)' % ( | 480 dart_declaration = '%s%s %s(%s)' % ( |
| 481 'static ' if operation.is_static else '', | 481 'static ' if operation.is_static else '', |
| 482 self.SecureOutputType(operation.type.id), | 482 self.SecureOutputType(operation.type.id), |
| 483 overload_name, argument_list) | 483 overload_name, argument_list) |
| 484 cpp_callback_name = self._GenerateNativeBinding( | 484 cpp_callback_name = self._GenerateNativeBinding( |
| 485 overload_name, (0 if operation.is_static else 1) + argument_count, | 485 overload_name, (0 if operation.is_static else 1) + argument_count, |
| 486 dart_declaration, 'Callback', False) | 486 dart_declaration, 'Callback', False) |
| 487 self._GenerateOperationNativeCallback(operation, operation.arguments[:argu
ment_count], cpp_callback_name) | 487 self._GenerateOperationNativeCallback(operation, operation.arguments[:argu
ment_count], cpp_callback_name) |
| 488 | 488 |
| 489 self._GenerateDispatcherBody( | 489 self._GenerateDispatcherBody( |
| 490 body, | 490 body, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 LIBRARY_NAME=library_name) | 868 LIBRARY_NAME=library_name) |
| 869 | 869 |
| 870 headers = self._library_headers[library_name] | 870 headers = self._library_headers[library_name] |
| 871 for header_file in headers: | 871 for header_file in headers: |
| 872 path = os.path.relpath(header_file, output_dir) | 872 path = os.path.relpath(header_file, output_dir) |
| 873 includes_emitter.Emit('#include "$PATH"\n', PATH=path) | 873 includes_emitter.Emit('#include "$PATH"\n', PATH=path) |
| 874 body_emitter.Emit( | 874 body_emitter.Emit( |
| 875 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 875 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 876 ' return func;\n', | 876 ' return func;\n', |
| 877 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 877 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| OLD | NEW |