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 from systemfrog import * | 9 from systemfrog import * |
10 from systeminterface import * | 10 from systeminterface import * |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 return | 974 return |
975 | 975 |
976 # Do we need a native body? | 976 # Do we need a native body? |
977 if (html_name != info.name): | 977 if (html_name != info.name): |
978 return_type = self._NarrowOutputType(info.type_name) | 978 return_type = self._NarrowOutputType(info.type_name) |
979 | 979 |
980 operation_emitter = self._members_emitter.Emit('$!SCOPE', | 980 operation_emitter = self._members_emitter.Emit('$!SCOPE', |
981 TYPE=return_type, | 981 TYPE=return_type, |
982 HTML_NAME=html_name, | 982 HTML_NAME=html_name, |
983 NAME=info.name, | 983 NAME=info.name, |
984 RETURN='' if return_type == 'void' else 'return ', | |
985 PARAMNAMES=info.ParametersAsArgumentList(), | |
986 PARAMS=info.ParametersImplementationDeclaration( | 984 PARAMS=info.ParametersImplementationDeclaration( |
987 lambda type_name: self._NarrowInputType(type_name))) | 985 lambda type_name: self._NarrowInputType(type_name))) |
988 | 986 |
989 operation_emitter.Emit( | 987 operation_emitter.Emit( |
990 '\n' | 988 '\n' |
991 ' $TYPE $(HTML_NAME)($PARAMS)' | 989 ' $TYPE $(HTML_NAME)($PARAMS) native "$NAME";\n') |
992 ' native "$(RETURN)this.$NAME($PARAMNAMES);";\n') | |
993 else: | 990 else: |
994 self._members_emitter.Emit( | 991 self._members_emitter.Emit( |
995 '\n' | 992 '\n' |
996 ' $TYPE $NAME($PARAMS) native;\n', | 993 ' $TYPE $NAME($PARAMS) native;\n', |
997 TYPE=self._NarrowOutputType(info.type_name), | 994 TYPE=self._NarrowOutputType(info.type_name), |
998 NAME=info.name, | 995 NAME=info.name, |
999 PARAMS=info.ParametersImplementationDeclaration( | 996 PARAMS=info.ParametersImplementationDeclaration( |
1000 lambda type_name: self._NarrowInputType(type_name))) | 997 lambda type_name: self._NarrowInputType(type_name))) |
1001 | 998 |
1002 def AddEventAttributes(self, event_attrs): | 999 def AddEventAttributes(self, event_attrs): |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee | 1713 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee |
1717 # that Y = Z-X, so we need to check for Y. | 1714 # that Y = Z-X, so we need to check for Y. |
1718 true_code = emitter.Emit( | 1715 true_code = emitter.Emit( |
1719 '$(INDENT)if ($COND) {\n' | 1716 '$(INDENT)if ($COND) {\n' |
1720 '$!TRUE' | 1717 '$!TRUE' |
1721 '$(INDENT)}\n', | 1718 '$(INDENT)}\n', |
1722 COND=test, INDENT=indent) | 1719 COND=test, INDENT=indent) |
1723 self.GenerateDispatch( | 1720 self.GenerateDispatch( |
1724 true_code, info, indent + ' ', position + 1, positive) | 1721 true_code, info, indent + ' ', position + 1, positive) |
1725 return True | 1722 return True |
OLD | NEW |