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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 info: An OperationInfo object. | 560 info: An OperationInfo object. |
561 """ | 561 """ |
562 | 562 |
563 if 'CheckSecurityForNode' in info.overloads[0].ext_attrs: | 563 if 'CheckSecurityForNode' in info.overloads[0].ext_attrs: |
564 # FIXME: exclude from interface as well. | 564 # FIXME: exclude from interface as well. |
565 return | 565 return |
566 | 566 |
567 if 'Custom' in info.overloads[0].ext_attrs: | 567 if 'Custom' in info.overloads[0].ext_attrs: |
568 parameters = info.ParametersImplementationDeclaration() | 568 parameters = info.ParametersImplementationDeclaration() |
569 dart_declaration = '%s %s(%s)' % (info.type_name, info.name, parameters) | 569 dart_declaration = '%s %s(%s)' % (info.type_name, info.name, parameters) |
570 argument_count = 1 + len(info.arg_infos) | 570 argument_count = 1 + len(info.param_infos) |
571 self._GenerateNativeBinding(info.name, argument_count, dart_declaration, | 571 self._GenerateNativeBinding(info.name, argument_count, dart_declaration, |
572 'Callback', True) | 572 'Callback', True) |
573 return | 573 return |
574 | 574 |
575 body = self._members_emitter.Emit( | 575 body = self._members_emitter.Emit( |
576 '\n' | 576 '\n' |
577 ' $TYPE $NAME($PARAMETERS) {\n' | 577 ' $TYPE $NAME($PARAMETERS) {\n' |
578 '$!BODY' | 578 '$!BODY' |
579 ' }\n', | 579 ' }\n', |
580 TYPE=info.type_name, | 580 TYPE=info.type_name, |
(...skipping 16 matching lines...) Expand all Loading... |
597 dispatch_emitter: an dispatch_emitter for the body of a block of code. | 597 dispatch_emitter: an dispatch_emitter for the body of a block of code. |
598 info: the compound information about the operation and its overloads. | 598 info: the compound information about the operation and its overloads. |
599 indent: an indentation string for generated code. | 599 indent: an indentation string for generated code. |
600 operation: the IDLOperation to call. | 600 operation: the IDLOperation to call. |
601 """ | 601 """ |
602 | 602 |
603 self._native_version += 1 | 603 self._native_version += 1 |
604 native_name = info.name | 604 native_name = info.name |
605 if self._native_version > 1: | 605 if self._native_version > 1: |
606 native_name = '%s_%s' % (native_name, self._native_version) | 606 native_name = '%s_%s' % (native_name, self._native_version) |
607 argument_list = ', '.join([info.arg_infos[i][0] | 607 argument_list = ', '.join([info.param_infos[i].name |
608 for (i, arg) in enumerate(operation.arguments)]) | 608 for (i, arg) in enumerate(operation.arguments)]) |
609 | 609 |
610 # Generate dispatcher. | 610 # Generate dispatcher. |
611 if info.type_name != 'void': | 611 if info.type_name != 'void': |
612 dispatch_emitter.Emit('$(INDENT)return _$NATIVENAME($ARGS);\n', | 612 dispatch_emitter.Emit('$(INDENT)return _$NATIVENAME($ARGS);\n', |
613 INDENT=indent, | 613 INDENT=indent, |
614 NATIVENAME=native_name, | 614 NATIVENAME=native_name, |
615 ARGS=argument_list) | 615 ARGS=argument_list) |
616 else: | 616 else: |
617 dispatch_emitter.Emit('$(INDENT)_$NATIVENAME($ARGS);\n' | 617 dispatch_emitter.Emit('$(INDENT)_$NATIVENAME($ARGS);\n' |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 def _InstanceOfNode(database, interface): | 843 def _InstanceOfNode(database, interface): |
844 if interface.id == 'Node': | 844 if interface.id == 'Node': |
845 return True | 845 return True |
846 for parent in interface.parents: | 846 for parent in interface.parents: |
847 if not database.HasInterface(parent.type.id): | 847 if not database.HasInterface(parent.type.id): |
848 continue | 848 continue |
849 parent_interface = database.GetInterface(parent.type.id) | 849 parent_interface = database.GetInterface(parent.type.id) |
850 if _InstanceOfNode(database, parent_interface): | 850 if _InstanceOfNode(database, parent_interface): |
851 return True | 851 return True |
852 return False | 852 return False |
OLD | NEW |