| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 callback_name, | 536 callback_name, |
| 537 needs_receiver, | 537 needs_receiver, |
| 538 function_expression, | 538 function_expression, |
| 539 node, | 539 node, |
| 540 arguments, | 540 arguments, |
| 541 return_type, | 541 return_type, |
| 542 raises_dom_exception): | 542 raises_dom_exception): |
| 543 ext_attrs = node.ext_attrs | 543 ext_attrs = node.ext_attrs |
| 544 | 544 |
| 545 cpp_arguments = [] | 545 cpp_arguments = [] |
| 546 requires_v8_scope = \ | |
| 547 any((self._TypeInfo(argument.type.id).requires_v8_scope() for argument i
n arguments)) or\ | |
| 548 self._interface.id.startswith('IDB') | |
| 549 runtime_check = None | 546 runtime_check = None |
| 550 raises_exceptions = raises_dom_exception or arguments | 547 raises_exceptions = raises_dom_exception or arguments |
| 551 | 548 |
| 552 # TODO(antonm): unify with ScriptState below. | 549 # TODO(antonm): unify with ScriptState below. |
| 553 requires_stack_info = ext_attrs.get('CallWith') == 'ScriptArguments|ScriptSt
ate' | 550 requires_stack_info = ext_attrs.get('CallWith') == 'ScriptArguments|ScriptSt
ate' |
| 554 if requires_stack_info: | 551 if requires_stack_info: |
| 555 raises_exceptions = True | 552 raises_exceptions = True |
| 556 requires_v8_scope = True | |
| 557 cpp_arguments = ['&state', 'scriptArguments.release()'] | 553 cpp_arguments = ['&state', 'scriptArguments.release()'] |
| 558 # WebKit uses scriptArguments to reconstruct last argument, so | 554 # WebKit uses scriptArguments to reconstruct last argument, so |
| 559 # it's not needed and should be just removed. | 555 # it's not needed and should be just removed. |
| 560 arguments = arguments[:-1] | 556 arguments = arguments[:-1] |
| 561 | 557 |
| 562 # TODO(antonm): unify with ScriptState below. | 558 # TODO(antonm): unify with ScriptState below. |
| 563 requires_script_arguments = ext_attrs.get('CallWith') == 'ScriptArguments' | 559 requires_script_arguments = ext_attrs.get('CallWith') == 'ScriptArguments' |
| 564 if requires_script_arguments: | 560 if requires_script_arguments: |
| 565 raises_exceptions = True | 561 raises_exceptions = True |
| 566 requires_v8_scope = True | |
| 567 cpp_arguments = ['scriptArguments.release()'] | 562 cpp_arguments = ['scriptArguments.release()'] |
| 568 # WebKit uses scriptArguments to reconstruct last argument, so | 563 # WebKit uses scriptArguments to reconstruct last argument, so |
| 569 # it's not needed and should be just removed. | 564 # it's not needed and should be just removed. |
| 570 arguments = arguments[:-1] | 565 arguments = arguments[:-1] |
| 571 | 566 |
| 572 requires_script_execution_context = ext_attrs.get('CallWith') == 'ScriptExec
utionContext' | 567 requires_script_execution_context = ext_attrs.get('CallWith') == 'ScriptExec
utionContext' |
| 573 if requires_script_execution_context: | 568 if requires_script_execution_context: |
| 574 raises_exceptions = True | 569 raises_exceptions = True |
| 575 cpp_arguments = ['context'] | 570 cpp_arguments = ['context'] |
| 576 | 571 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 'fail:\n' | 629 'fail:\n' |
| 635 ' Dart_ThrowException(exception);\n' | 630 ' Dart_ThrowException(exception);\n' |
| 636 ' ASSERT_NOT_REACHED();\n') | 631 ' ASSERT_NOT_REACHED();\n') |
| 637 | 632 |
| 638 body_emitter = body_emitter.Emit( | 633 body_emitter = body_emitter.Emit( |
| 639 ' {\n' | 634 ' {\n' |
| 640 '$!BODY' | 635 '$!BODY' |
| 641 ' return;\n' | 636 ' return;\n' |
| 642 ' }\n') | 637 ' }\n') |
| 643 | 638 |
| 644 if requires_v8_scope: | |
| 645 body_emitter.Emit( | |
| 646 ' V8Scope v8scope;\n\n') | |
| 647 | |
| 648 if runtime_check: | 639 if runtime_check: |
| 649 body_emitter.Emit( | 640 body_emitter.Emit( |
| 650 '$RUNTIME_CHECK\n', | 641 '$RUNTIME_CHECK\n', |
| 651 RUNTIME_CHECK=runtime_check) | 642 RUNTIME_CHECK=runtime_check) |
| 652 | 643 |
| 653 if requires_script_execution_context: | 644 if requires_script_execution_context: |
| 654 body_emitter.Emit( | 645 body_emitter.Emit( |
| 655 ' ScriptExecutionContext* context = DartUtilities::scriptExecut
ionContext();\n' | 646 ' ScriptExecutionContext* context = DartUtilities::scriptExecut
ionContext();\n' |
| 656 ' if (!context) {\n' | 647 ' if (!context) {\n' |
| 657 ' exception = Dart_NewStringFromCString("Failed to retrieve
a context");\n' | 648 ' exception = Dart_NewStringFromCString("Failed to retrieve
a context");\n' |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 LIBRARY_NAME=library_name) | 898 LIBRARY_NAME=library_name) |
| 908 | 899 |
| 909 headers = self._library_headers[library_name] | 900 headers = self._library_headers[library_name] |
| 910 for header_file in headers: | 901 for header_file in headers: |
| 911 path = os.path.relpath(header_file, output_dir) | 902 path = os.path.relpath(header_file, output_dir) |
| 912 includes_emitter.Emit('#include "$PATH"\n', PATH=path) | 903 includes_emitter.Emit('#include "$PATH"\n', PATH=path) |
| 913 body_emitter.Emit( | 904 body_emitter.Emit( |
| 914 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 905 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 915 ' return func;\n', | 906 ' return func;\n', |
| 916 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 907 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| OLD | NEW |