| 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 system to generate | 6 """This module provides shared functionality for the system to generate |
| 7 Dart:html APIs from the IDL database.""" | 7 Dart:html APIs from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 | 10 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 if info.name == 'item': | 655 if info.name == 'item': |
| 656 # FIXME: item should be renamed to operator[], not removed. | 656 # FIXME: item should be renamed to operator[], not removed. |
| 657 self._backend.AddOperation(info, '_item') | 657 self._backend.AddOperation(info, '_item') |
| 658 return | 658 return |
| 659 | 659 |
| 660 if not self._shared.IsPrivate(html_name) and not skip_declaration: | 660 if not self._shared.IsPrivate(html_name) and not skip_declaration: |
| 661 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */', | 661 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */', |
| 662 DOMINTERFACE=info.overloads[0].doc_js_interface_name, | 662 DOMINTERFACE=info.overloads[0].doc_js_interface_name, |
| 663 DOMNAME=info.name) | 663 DOMNAME=info.name) |
| 664 | 664 |
| 665 self._members_emitter.Emit('\n' | 665 if info.IsStatic(): |
| 666 ' $TYPE $NAME($PARAMS);\n', | 666 # FIXME: provide a type. |
| 667 TYPE=self._DartType(info.type_name), | 667 self._members_emitter.Emit('\n' |
| 668 NAME=html_name, | 668 ' static final $NAME = $IMPL_CLASS_NAME.$NAME
;\n', |
| 669 PARAMS=info.ParametersInterfaceDeclaration(self
._DartType)) | 669 IMPL_CLASS_NAME=self._backend.ImplementationCl
assName(), |
| 670 NAME=html_name) |
| 671 else: |
| 672 self._members_emitter.Emit('\n' |
| 673 ' $TYPE $NAME($PARAMS);\n', |
| 674 TYPE=self._DartType(info.type_name), |
| 675 NAME=html_name, |
| 676 PARAMS=info.ParametersInterfaceDeclaration(sel
f._DartType)) |
| 670 self._backend.AddOperation(info, html_name) | 677 self._backend.AddOperation(info, html_name) |
| 671 | 678 |
| 672 def AddStaticOperation(self, info): | |
| 673 self.AddOperation(info, True) | |
| 674 | |
| 675 def AddSecondaryOperation(self, interface, info): | 679 def AddSecondaryOperation(self, interface, info): |
| 676 self._backend.SecondaryContext(interface) | 680 self._backend.SecondaryContext(interface) |
| 677 self.AddOperation(info, True) | 681 self.AddOperation(info, True) |
| 678 | 682 |
| 679 def FinishInterface(self): | 683 def FinishInterface(self): |
| 680 self._backend.FinishInterface() | 684 self._backend.FinishInterface() |
| 681 | 685 |
| 682 def AddConstant(self, constant): | 686 def AddConstant(self, constant): |
| 683 type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id) | 687 type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id) |
| 684 self._members_emitter.Emit('\n static const $TYPE$NAME = $VALUE;\n', | 688 self._members_emitter.Emit('\n static const $TYPE$NAME = $VALUE;\n', |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 | 1006 |
| 1003 | 1007 |
| 1004 def AddOperation(self, info, html_name): | 1008 def AddOperation(self, info, html_name): |
| 1005 """ | 1009 """ |
| 1006 Arguments: | 1010 Arguments: |
| 1007 info: An OperationInfo object. | 1011 info: An OperationInfo object. |
| 1008 """ | 1012 """ |
| 1009 if self._HasCustomImplementation(info.name): | 1013 if self._HasCustomImplementation(info.name): |
| 1010 return | 1014 return |
| 1011 | 1015 |
| 1012 # FIXME: support static operations. | |
| 1013 if info.IsStatic(): | |
| 1014 return | |
| 1015 | |
| 1016 # Any conversions needed? | 1016 # Any conversions needed? |
| 1017 if any(self._OperationRequiresConversions(op) for op in info.overloads): | 1017 if any(self._OperationRequiresConversions(op) for op in info.overloads): |
| 1018 self._AddOperationWithConversions(info, html_name) | 1018 self._AddOperationWithConversions(info, html_name) |
| 1019 else: | 1019 else: |
| 1020 self._AddDirectNativeOperation(info, html_name) | 1020 self._AddDirectNativeOperation(info, html_name) |
| 1021 | 1021 |
| 1022 def _AddDirectNativeOperation(self, info, html_name): | 1022 def _AddDirectNativeOperation(self, info, html_name): |
| 1023 # Do we need a native body? | 1023 # Do we need a native body? |
| 1024 if html_name != info.declared_name: | 1024 if html_name != info.declared_name: |
| 1025 return_type = self._NarrowOutputType(info.type_name) | 1025 return_type = self._NarrowOutputType(info.type_name) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 def GenerateLibraries(self, dart_files): | 1230 def GenerateLibraries(self, dart_files): |
| 1231 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir) | 1231 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir) |
| 1232 self._GenerateLibFile( | 1232 self._GenerateLibFile( |
| 1233 'html_dart2js.darttemplate', | 1233 'html_dart2js.darttemplate', |
| 1234 os.path.join(self._output_dir, 'html_dart2js.dart'), | 1234 os.path.join(self._output_dir, 'html_dart2js.dart'), |
| 1235 dart_files, | 1235 dart_files, |
| 1236 AUXILIARY_DIR=systembase.MassagePath(auxiliary_dir)) | 1236 AUXILIARY_DIR=systembase.MassagePath(auxiliary_dir)) |
| 1237 | 1237 |
| 1238 def Finish(self): | 1238 def Finish(self): |
| 1239 pass | 1239 pass |
| OLD | NEW |