| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 self._DartType(info.type_name), | 763 self._DartType(info.type_name), |
| 764 html_name or info.name, | 764 html_name or info.name, |
| 765 info.ParametersImplementationDeclaration(self._DartType)) | 765 info.ParametersImplementationDeclaration(self._DartType)) |
| 766 | 766 |
| 767 if 'Custom' in info.overloads[0].ext_attrs: | 767 if 'Custom' in info.overloads[0].ext_attrs: |
| 768 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) | 768 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) |
| 769 self._GenerateNativeBinding(info.name , argument_count, | 769 self._GenerateNativeBinding(info.name , argument_count, |
| 770 dart_declaration, 'Callback', True) | 770 dart_declaration, 'Callback', True) |
| 771 return | 771 return |
| 772 | 772 |
| 773 if self._interface.id == 'Document' and info.name == 'querySelector': | 773 body = self._members_emitter.Emit( |
| 774 # Document.querySelector has custom implementation in dart:html. | 774 '\n' |
| 775 # FIXME: Cleanup query selectors and remove this hack. | 775 ' $DECLARATION {\n' |
| 776 body = emitter.Emitter() | 776 '$!BODY' |
| 777 else: | 777 ' }\n', |
| 778 body = self._members_emitter.Emit( | 778 DECLARATION=dart_declaration) |
| 779 '\n' | |
| 780 ' $DECLARATION {\n' | |
| 781 '$!BODY' | |
| 782 ' }\n', | |
| 783 DECLARATION=dart_declaration) | |
| 784 | 779 |
| 785 self._native_version = 0 | 780 self._native_version = 0 |
| 786 overloads = self.CombineOverloads(info.overloads) | 781 overloads = self.CombineOverloads(info.overloads) |
| 787 fallthrough = self.GenerateDispatch(body, info, ' ', overloads) | 782 fallthrough = self.GenerateDispatch(body, info, ' ', overloads) |
| 788 if fallthrough: | 783 if fallthrough: |
| 789 body.Emit(' throw "Incorrect number or type of arguments";\n'); | 784 body.Emit(' throw "Incorrect number or type of arguments";\n'); |
| 790 | 785 |
| 791 def CombineOverloads(self, overloads): | 786 def CombineOverloads(self, overloads): |
| 792 # Combine overloads that can be implemented by the same native method. This | 787 # Combine overloads that can be implemented by the same native method. This |
| 793 # undoes the expansion of optional arguments into multiple overloads unless | 788 # undoes the expansion of optional arguments into multiple overloads unless |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 for parent in interface.parents: | 1192 for parent in interface.parents: |
| 1198 parent_name = parent.type.id | 1193 parent_name = parent.type.id |
| 1199 if not database.HasInterface(parent.type.id): | 1194 if not database.HasInterface(parent.type.id): |
| 1200 continue | 1195 continue |
| 1201 parent_interface = database.GetInterface(parent.type.id) | 1196 parent_interface = database.GetInterface(parent.type.id) |
| 1202 if callback(parent_interface): | 1197 if callback(parent_interface): |
| 1203 return parent_interface | 1198 return parent_interface |
| 1204 parent_interface = _FindParent(parent_interface, database, callback) | 1199 parent_interface = _FindParent(parent_interface, database, callback) |
| 1205 if parent_interface: | 1200 if parent_interface: |
| 1206 return parent_interface | 1201 return parent_interface |
| OLD | NEW |