| 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 stmts_emitter, call_emitter, version, operation, argument_count): | 569 stmts_emitter, call_emitter, version, operation, argument_count): |
| 570 overload_name = '_%s_%s' % (operation.id, version) | 570 overload_name = '_%s_%s' % (operation.id, version) |
| 571 argument_list = ', '.join( | 571 argument_list = ', '.join( |
| 572 [p.name for p in info.param_infos[:argument_count]]) | 572 [p.name for p in info.param_infos[:argument_count]]) |
| 573 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list) | 573 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list) |
| 574 | 574 |
| 575 dart_declaration = '%s%s %s(%s)' % ( | 575 dart_declaration = '%s%s %s(%s)' % ( |
| 576 'static ' if operation.is_static else '', | 576 'static ' if operation.is_static else '', |
| 577 self.SecureOutputType(operation.type.id), | 577 self.SecureOutputType(operation.type.id), |
| 578 overload_name, argument_list) | 578 overload_name, argument_list) |
| 579 is_custom = 'Custom' in operation.ext_attrs |
| 579 cpp_callback_name = self._GenerateNativeBinding( | 580 cpp_callback_name = self._GenerateNativeBinding( |
| 580 overload_name, (0 if operation.is_static else 1) + argument_count, | 581 overload_name, (0 if operation.is_static else 1) + argument_count, |
| 581 dart_declaration, 'Callback', False, False) | 582 dart_declaration, 'Callback', is_custom, emit_metadata=False) |
| 582 self._GenerateOperationNativeCallback(operation, operation.arguments[:argu
ment_count], cpp_callback_name) | 583 if not is_custom: |
| 584 self._GenerateOperationNativeCallback(operation, operation.arguments[:ar
gument_count], cpp_callback_name) |
| 583 | 585 |
| 584 self._GenerateDispatcherBody( | 586 self._GenerateDispatcherBody( |
| 585 info, | 587 info, |
| 586 operations, | 588 operations, |
| 587 dart_declaration, | 589 dart_declaration, |
| 588 GenerateCall, | 590 GenerateCall, |
| 589 self._IsArgumentOptionalInWebCore) | 591 self._IsArgumentOptionalInWebCore) |
| 590 | 592 |
| 591 def SecondaryContext(self, interface): | 593 def SecondaryContext(self, interface): |
| 592 pass | 594 pass |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 ' goto fail;\n' | 782 ' goto fail;\n' |
| 781 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' | 783 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' |
| 782 ' if (!scriptCallStack->size())\n' | 784 ' if (!scriptCallStack->size())\n' |
| 783 ' return;\n', | 785 ' return;\n', |
| 784 INDEX=len(arguments) + 1) | 786 INDEX=len(arguments) + 1) |
| 785 | 787 |
| 786 # Emit arguments. | 788 # Emit arguments. |
| 787 start_index = 1 if needs_receiver else 0 | 789 start_index = 1 if needs_receiver else 0 |
| 788 for i, argument in enumerate(arguments): | 790 for i, argument in enumerate(arguments): |
| 789 type_info = self._TypeInfo(argument.type.id) | 791 type_info = self._TypeInfo(argument.type.id) |
| 792 self._cpp_impl_includes |= set(type_info.conversion_includes()) |
| 790 argument_expression_template, type, cls, function = \ | 793 argument_expression_template, type, cls, function = \ |
| 791 type_info.to_native_info(argument, self._interface.id) | 794 type_info.to_native_info(argument, self._interface.id) |
| 792 | 795 |
| 793 def AllowsNull(): | 796 def AllowsNull(): |
| 794 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin
g' | 797 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin
g' |
| 795 if argument.ext_attrs.get('TreatNullAs') == 'NullString': | 798 if argument.ext_attrs.get('TreatNullAs') == 'NullString': |
| 796 return True | 799 return True |
| 797 | 800 |
| 798 if argument.type.nullable: | 801 if argument.type.nullable: |
| 799 return True | 802 return True |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 1028 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 1026 ' return func;\n', | 1029 ' return func;\n', |
| 1027 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 1030 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 1028 | 1031 |
| 1029 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1032 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1030 return ( | 1033 return ( |
| 1031 interface.id.endswith('Event') and | 1034 interface.id.endswith('Event') and |
| 1032 operation.id.startswith('init') and | 1035 operation.id.startswith('init') and |
| 1033 argument.ext_attrs.get('Default') == 'Undefined' and | 1036 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1034 argument.type.id == 'DOMString') | 1037 argument.type.id == 'DOMString') |
| OLD | NEW |