Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: tools/dom/scripts/systemhtml.py

Issue 896723009: Annotate dart:html constructor expressions with precise non-nullable types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/htmldartgenerator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 self._renamer.RenameInterface(self._interface))) 715 self._renamer.RenameInterface(self._interface)))
716 return js_support_checks.get(self._interface.doc_js_name) 716 return js_support_checks.get(self._interface.doc_js_name)
717 717
718 def GenerateCustomFactory(self, constructor_info): 718 def GenerateCustomFactory(self, constructor_info):
719 # Custom factory will be taken from the template. 719 # Custom factory will be taken from the template.
720 return self._interface.doc_js_name in _js_custom_constructors 720 return self._interface.doc_js_name in _js_custom_constructors
721 721
722 def IsConstructorArgumentOptional(self, argument): 722 def IsConstructorArgumentOptional(self, argument):
723 return argument.optional 723 return argument.optional
724 724
725 def XXFactoryConstructorExpression(self, constructor_info,
726 factory_name, factory_constructor_name, factory_parameters):
727 if factory_name == 'document' and factory_constructor_name == 'createElement ':
Alan Knight 2015/02/06 18:41:03 80 columns
sra1 2015/02/06 22:45:44 Done.
728 return emitter.Format(
729 '''JS('$TYPE', '$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS))''',
730 TYPE=self._DartType(constructor_info.type_name),
731 FACTORY=factory_name,
732 CTOR_FACTORY_NAME=factory_constructor_name,
733 FACTORY_PARAMS=factory_parameters);
734 return super(Dart2JSBackend, self).FactoryConstructorExpression(
735 constructor_info, factory_name, factory_constructor_name, factory_parame ters)
Alan Knight 2015/02/06 18:41:03 and here
sra1 2015/02/06 22:45:44 Done.
736
737 def FactoryConstructorExpression(self, constructor_info,
738 factory_name, factory_constructor_name, factory_parameters):
739 expression = super(Dart2JSBackend, self).FactoryConstructorExpression(
740 constructor_info, factory_name, factory_constructor_name, factory_parame ters)
Alan Knight 2015/02/06 18:41:02 also 80 cols
sra1 2015/02/06 22:45:44 Done.
741 return emitter.Format(
742 "JS('$TYPE', '#', $VALUE)",
743 TYPE=self._DartType(constructor_info.type_name),
744 VALUE=expression)
745
725 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): 746 def EmitStaticFactoryOverload(self, constructor_info, name, arguments):
726 index = len(arguments) 747 index = len(arguments)
727 arguments = constructor_info.ParametersAsArgumentList(index) 748 arguments = constructor_info.ParametersAsArgumentList(index)
728 if arguments: 749 if arguments:
729 arguments = ', ' + arguments 750 arguments = ', ' + arguments
730 self._members_emitter.Emit( 751 self._members_emitter.Emit(
731 " static $INTERFACE_NAME $NAME($PARAMETERS) => " 752 " static $INTERFACE_NAME $NAME($PARAMETERS) => "
732 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n", 753 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n",
733 INTERFACE_NAME=self._interface_type_info.interface_name(), 754 INTERFACE_NAME=self._interface_type_info.interface_name(),
734 NAME=name, 755 NAME=name,
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 1290
1270 def AddFile(self, basename, library_name, path): 1291 def AddFile(self, basename, library_name, path):
1271 self._libraries[library_name].AddFile(path) 1292 self._libraries[library_name].AddFile(path)
1272 1293
1273 def AddTypeEntry(self, library_name, idl_name, dart_name): 1294 def AddTypeEntry(self, library_name, idl_name, dart_name):
1274 self._libraries[library_name].AddTypeEntry(idl_name, dart_name) 1295 self._libraries[library_name].AddTypeEntry(idl_name, dart_name)
1275 1296
1276 def Emit(self, emitter, auxiliary_dir): 1297 def Emit(self, emitter, auxiliary_dir):
1277 for lib in self._libraries.values(): 1298 for lib in self._libraries.values():
1278 lib.Emit(emitter, auxiliary_dir) 1299 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmldartgenerator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698