| 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 self._members_emitter = self._dart_code.Emit( | 784 self._members_emitter = self._dart_code.Emit( |
| 785 self._template, | 785 self._template, |
| 786 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 786 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 787 #$!MEMBERS | 787 #$!MEMBERS |
| 788 #} | 788 #} |
| 789 CLASSNAME=self._class_name, | 789 CLASSNAME=self._class_name, |
| 790 EXTENDS=extends, | 790 EXTENDS=extends, |
| 791 IMPLEMENTS=' implements ' + ', '.join(implements), | 791 IMPLEMENTS=' implements ' + ', '.join(implements), |
| 792 NATIVESPEC=' native "' + native_spec + '"') | 792 NATIVESPEC=' native "' + native_spec + '"') |
| 793 | 793 |
| 794 if element_type: | |
| 795 self.AddTypedArrayConstructors(element_type) | |
| 796 | |
| 797 # Emit a factory provider class for the constructor. | 794 # Emit a factory provider class for the constructor. |
| 798 constructor_info = AnalyzeConstructor(interface) | 795 constructor_info = AnalyzeConstructor(interface) |
| 799 if constructor_info: | 796 if constructor_info: |
| 800 self._EmitFactoryProvider(interface_name, constructor_info) | 797 self._EmitFactoryProvider(interface_name, constructor_info) |
| 801 | 798 |
| 802 emit_events, events = self._shared.GetEventAttributes(self._interface) | 799 emit_events, events = self._shared.GetEventAttributes(self._interface) |
| 803 if not emit_events: | 800 if not emit_events: |
| 804 return | 801 return |
| 805 elif events: | 802 elif events: |
| 806 self.AddEventAttributes(events) | 803 self.AddEventAttributes(events) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 """ | 965 """ |
| 969 Arguments: | 966 Arguments: |
| 970 info: An OperationInfo object. | 967 info: An OperationInfo object. |
| 971 """ | 968 """ |
| 972 html_name = self._shared.RenameInHtmlLibrary( | 969 html_name = self._shared.RenameInHtmlLibrary( |
| 973 self._interface, info.name, implementation_class=True) | 970 self._interface, info.name, implementation_class=True) |
| 974 if not html_name: | 971 if not html_name: |
| 975 return | 972 return |
| 976 | 973 |
| 977 # Do we need a native body? | 974 # Do we need a native body? |
| 978 if (html_name != info.name): | 975 if html_name != info.declared_name: |
| 979 return_type = self._NarrowOutputType(info.type_name) | 976 return_type = self._NarrowOutputType(info.type_name) |
| 980 | 977 |
| 981 operation_emitter = self._members_emitter.Emit('$!SCOPE', | 978 operation_emitter = self._members_emitter.Emit('$!SCOPE', |
| 982 TYPE=return_type, | 979 TYPE=return_type, |
| 983 HTML_NAME=html_name, | 980 HTML_NAME=html_name, |
| 984 NAME=info.name, | 981 NAME=info.declared_name, |
| 985 PARAMS=info.ParametersImplementationDeclaration( | 982 PARAMS=info.ParametersImplementationDeclaration( |
| 986 lambda type_name: self._NarrowInputType(type_name))) | 983 lambda type_name: self._NarrowInputType(type_name))) |
| 987 | 984 |
| 988 operation_emitter.Emit( | 985 operation_emitter.Emit( |
| 989 '\n' | 986 '\n' |
| 990 ' $TYPE $(HTML_NAME)($PARAMS) native "$NAME";\n') | 987 ' $TYPE $(HTML_NAME)($PARAMS) native "$NAME";\n') |
| 991 else: | 988 else: |
| 992 self._members_emitter.Emit( | 989 self._members_emitter.Emit( |
| 993 '\n' | 990 '\n' |
| 994 ' $TYPE $NAME($PARAMS) native;\n', | 991 ' $TYPE $NAME($PARAMS) native;\n', |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee | 1711 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee |
| 1715 # that Y = Z-X, so we need to check for Y. | 1712 # that Y = Z-X, so we need to check for Y. |
| 1716 true_code = emitter.Emit( | 1713 true_code = emitter.Emit( |
| 1717 '$(INDENT)if ($COND) {\n' | 1714 '$(INDENT)if ($COND) {\n' |
| 1718 '$!TRUE' | 1715 '$!TRUE' |
| 1719 '$(INDENT)}\n', | 1716 '$(INDENT)}\n', |
| 1720 COND=test, INDENT=indent) | 1717 COND=test, INDENT=indent) |
| 1721 self.GenerateDispatch( | 1718 self.GenerateDispatch( |
| 1722 true_code, info, indent + ' ', position + 1, positive) | 1719 true_code, info, indent + ' ', position + 1, positive) |
| 1723 return True | 1720 return True |
| OLD | NEW |