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

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

Issue 14211014: Chrome roll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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/idlrenderer.py ('k') | tools/dom/scripts/systemnative.py » ('j') | 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 monitored 10 import monitored
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 " && (new %sElement.tag('%s') is %s)" % (lib_prefix, 644 " && (new %sElement.tag('%s') is %s)" % (lib_prefix,
645 constructors[self._interface.doc_js_name], 645 constructors[self._interface.doc_js_name],
646 self._renamer.RenameInterface(self._interface))) 646 self._renamer.RenameInterface(self._interface)))
647 return js_support_checks.get(self._interface.doc_js_name) 647 return js_support_checks.get(self._interface.doc_js_name)
648 648
649 def GenerateCustomFactory(self, constructor_info): 649 def GenerateCustomFactory(self, constructor_info):
650 # Custom factory will be taken from the template. 650 # Custom factory will be taken from the template.
651 return self._interface.doc_js_name in _js_custom_constructors 651 return self._interface.doc_js_name in _js_custom_constructors
652 652
653 def IsConstructorArgumentOptional(self, argument): 653 def IsConstructorArgumentOptional(self, argument):
654 return 'Optional' in argument.ext_attrs 654 return argument.optional
655 655
656 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): 656 def EmitStaticFactoryOverload(self, constructor_info, name, arguments):
657 index = len(arguments) 657 index = len(arguments)
658 arguments = constructor_info.ParametersAsArgumentList(index) 658 arguments = constructor_info.ParametersAsArgumentList(index)
659 if arguments: 659 if arguments:
660 arguments = ', ' + arguments 660 arguments = ', ' + arguments
661 self._members_emitter.Emit( 661 self._members_emitter.Emit(
662 " static $INTERFACE_NAME $NAME($PARAMETERS) => " 662 " static $INTERFACE_NAME $NAME($PARAMETERS) => "
663 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n", 663 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n",
664 INTERFACE_NAME=self._interface_type_info.interface_name(), 664 INTERFACE_NAME=self._interface_type_info.interface_name(),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 self._Annotations(info.type_name, info.declared_name), 987 self._Annotations(info.type_name, info.declared_name),
988 'static ' if info.IsStatic() else '', 988 'static ' if info.IsStatic() else '',
989 return_type, 989 return_type,
990 html_name, 990 html_name,
991 info.ParametersDeclaration(InputType)) 991 info.ParametersDeclaration(InputType))
992 self._GenerateDispatcherBody( 992 self._GenerateDispatcherBody(
993 operations, 993 operations,
994 parameter_names, 994 parameter_names,
995 declaration, 995 declaration,
996 GenerateCall, 996 GenerateCall,
997 self._IsOptional, 997 lambda _, argument: IsOptional(argument),
998 can_omit_type_check=lambda type, pos: type == parameter_types[pos]) 998 can_omit_type_check=lambda type, pos: type == parameter_types[pos])
999 999
1000 def _AddInterfaceOperation(self, info, html_name): 1000 def _AddInterfaceOperation(self, info, html_name):
1001 self._members_emitter.Emit( 1001 self._members_emitter.Emit(
1002 '\n' 1002 '\n'
1003 ' $TYPE $NAME($PARAMS);\n', 1003 ' $TYPE $NAME($PARAMS);\n',
1004 TYPE=self.SecureOutputType(info.type_name), 1004 TYPE=self.SecureOutputType(info.type_name),
1005 NAME=info.name, 1005 NAME=info.name,
1006 PARAMS=info.ParametersDeclaration(self._NarrowInputType)) 1006 PARAMS=info.ParametersDeclaration(self._NarrowInputType))
1007 1007
1008 def _IsOptional(self, operation, argument):
1009 return IsOptional(argument)
1010
1011 1008
1012 def _OperationRequiresConversions(self, operation): 1009 def _OperationRequiresConversions(self, operation):
1013 return (self._OperationRequiresOutputConversion(operation) or 1010 return (self._OperationRequiresOutputConversion(operation) or
1014 self._OperationRequiresInputConversions(operation)) 1011 self._OperationRequiresInputConversions(operation))
1015 1012
1016 def _OperationRequiresOutputConversion(self, operation): 1013 def _OperationRequiresOutputConversion(self, operation):
1017 return self._OutputConversion(operation.type.id, operation.id) 1014 return self._OutputConversion(operation.type.id, operation.id)
1018 1015
1019 def _OperationRequiresInputConversions(self, operation): 1016 def _OperationRequiresInputConversions(self, operation):
1020 return any(self._InputConversion(arg.type.id, operation.id) 1017 return any(self._InputConversion(arg.type.id, operation.id)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 for library_name in libraries: 1156 for library_name in libraries:
1160 self._libraries[library_name] = DartLibrary( 1157 self._libraries[library_name] = DartLibrary(
1161 library_name, template_loader, library_type, output_dir) 1158 library_name, template_loader, library_type, output_dir)
1162 1159
1163 def AddFile(self, basename, library_name, path): 1160 def AddFile(self, basename, library_name, path):
1164 self._libraries[library_name].AddFile(path) 1161 self._libraries[library_name].AddFile(path)
1165 1162
1166 def Emit(self, emitter, auxiliary_dir): 1163 def Emit(self, emitter, auxiliary_dir):
1167 for lib in self._libraries.values(): 1164 for lib in self._libraries.values():
1168 lib.Emit(emitter, auxiliary_dir) 1165 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « tools/dom/scripts/idlrenderer.py ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698