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 import logging | 10 import logging |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 self._renamer.RenameInterface(self._interface))) | 720 self._renamer.RenameInterface(self._interface))) |
721 return js_support_checks.get(self._interface.doc_js_name) | 721 return js_support_checks.get(self._interface.doc_js_name) |
722 | 722 |
723 def GenerateCustomFactory(self, constructor_info): | 723 def GenerateCustomFactory(self, constructor_info): |
724 # Custom factory will be taken from the template. | 724 # Custom factory will be taken from the template. |
725 return self._interface.doc_js_name in _js_custom_constructors | 725 return self._interface.doc_js_name in _js_custom_constructors |
726 | 726 |
727 def IsConstructorArgumentOptional(self, argument): | 727 def IsConstructorArgumentOptional(self, argument): |
728 return argument.optional | 728 return argument.optional |
729 | 729 |
730 def FactoryConstructorExpression(self, constructor_info, | |
731 factory_name, factory_constructor_name, factory_parameters): | |
732 expression = super(Dart2JSBackend, self).FactoryConstructorExpression( | |
733 constructor_info, factory_name, factory_constructor_name, | |
734 factory_parameters) | |
735 return emitter.Format( | |
736 "JS('$TYPE', '#', $VALUE)", | |
737 TYPE=self._DartType(constructor_info.type_name), | |
738 VALUE=expression) | |
739 | |
740 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): | 730 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): |
741 index = len(arguments) | 731 index = len(arguments) |
742 arguments = constructor_info.ParametersAsArgumentList(index) | 732 arguments = constructor_info.ParametersAsArgumentList(index) |
743 if arguments: | 733 if arguments: |
744 arguments = ', ' + arguments | 734 arguments = ', ' + arguments |
745 self._members_emitter.Emit( | 735 self._members_emitter.Emit( |
746 " static $INTERFACE_NAME $NAME($PARAMETERS) => " | 736 " static $INTERFACE_NAME $NAME($PARAMETERS) => " |
747 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n", | 737 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n", |
748 INTERFACE_NAME=self._interface_type_info.interface_name(), | 738 INTERFACE_NAME=self._interface_type_info.interface_name(), |
749 NAME=name, | 739 NAME=name, |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 | 1274 |
1285 def AddFile(self, basename, library_name, path): | 1275 def AddFile(self, basename, library_name, path): |
1286 self._libraries[library_name].AddFile(path) | 1276 self._libraries[library_name].AddFile(path) |
1287 | 1277 |
1288 def AddTypeEntry(self, library_name, idl_name, dart_name): | 1278 def AddTypeEntry(self, library_name, idl_name, dart_name): |
1289 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) | 1279 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) |
1290 | 1280 |
1291 def Emit(self, emitter, auxiliary_dir): | 1281 def Emit(self, emitter, auxiliary_dir): |
1292 for lib in self._libraries.values(): | 1282 for lib in self._libraries.values(): |
1293 lib.Emit(emitter, auxiliary_dir) | 1283 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |