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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 MODIFIER=modifier, | 592 MODIFIER=modifier, |
593 TYPE=info.type_name, | 593 TYPE=info.type_name, |
594 NAME=info.name, | 594 NAME=info.name, |
595 PARAMETERS=info.ParametersImplementationDeclaration()) | 595 PARAMETERS=info.ParametersImplementationDeclaration()) |
596 | 596 |
597 # Process in order of ascending number of arguments to ensure missing | 597 # Process in order of ascending number of arguments to ensure missing |
598 # optional arguments are processed early. | 598 # optional arguments are processed early. |
599 overloads = sorted(info.overloads, | 599 overloads = sorted(info.overloads, |
600 key=lambda overload: len(overload.arguments)) | 600 key=lambda overload: len(overload.arguments)) |
601 self._native_version = 0 | 601 self._native_version = 0 |
602 fallthrough = self.GenerateDispatch(body, info, ' ', 0, overloads) | 602 fallthrough = GenerateDispatch(self, body, info, ' ', 0, overloads) |
603 if fallthrough: | 603 if fallthrough: |
604 body.Emit(' throw "Incorrect number or type of arguments";\n'); | 604 body.Emit(' throw "Incorrect number or type of arguments";\n'); |
605 | 605 |
606 def AddOperation(self, info): | 606 def AddOperation(self, info): |
607 self._AddOperation(info) | 607 self._AddOperation(info) |
608 | 608 |
609 def AddStaticOperation(self, info): | 609 def AddStaticOperation(self, info): |
610 self._AddOperation(info) | 610 self._AddOperation(info) |
611 | 611 |
612 def GenerateSingleOperation(self, dispatch_emitter, info, indent, operation): | 612 def GenerateSingleOperation(self, dispatch_emitter, info, indent, operation): |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 def _InstanceOfNode(database, interface): | 842 def _InstanceOfNode(database, interface): |
843 if interface.id == 'Node': | 843 if interface.id == 'Node': |
844 return True | 844 return True |
845 for parent in interface.parents: | 845 for parent in interface.parents: |
846 if not database.HasInterface(parent.type.id): | 846 if not database.HasInterface(parent.type.id): |
847 continue | 847 continue |
848 parent_interface = database.GetInterface(parent.type.id) | 848 parent_interface = database.GetInterface(parent.type.id) |
849 if _InstanceOfNode(database, parent_interface): | 849 if _InstanceOfNode(database, parent_interface): |
850 return True | 850 return True |
851 return False | 851 return False |
OLD | NEW |