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

Side by Side Diff: sdk/lib/html/scripts/systemhtml.py

Issue 11415067: Add annotations on native fields and methods (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comment Created 8 years 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
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 os 10 import os
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 NAME=DartDomNameOfAttribute(attribute), 577 NAME=DartDomNameOfAttribute(attribute),
578 TYPE=self.SecureOutputType(attribute.type.id)) 578 TYPE=self.SecureOutputType(attribute.type.id))
579 579
580 def _AddRenamingGetter(self, attr, html_name): 580 def _AddRenamingGetter(self, attr, html_name):
581 self.EmitAttributeDocumentation(attr) 581 self.EmitAttributeDocumentation(attr)
582 582
583 conversion = self._OutputConversion(attr.type.id, attr.id) 583 conversion = self._OutputConversion(attr.type.id, attr.id)
584 if conversion: 584 if conversion:
585 return self._AddConvertingGetter(attr, html_name, conversion) 585 return self._AddConvertingGetter(attr, html_name, conversion)
586 return_type = self.SecureOutputType(attr.type.id) 586 return_type = self.SecureOutputType(attr.type.id)
587 native_type = self._NarrowToImplementationType(attr.type.id)
587 self._members_emitter.Emit( 588 self._members_emitter.Emit(
588 # TODO(sra): Use metadata to provide native name. 589 # TODO(sra): Use metadata to provide native name.
589 '\n $TYPE get $HTML_NAME => JS("$TYPE", "#.$NAME", this);' 590 '\n $TYPE get $HTML_NAME => JS("$NATIVE_TYPE", "#.$NAME", this);'
590 '\n', 591 '\n',
591 HTML_NAME=html_name, 592 HTML_NAME=html_name,
592 NAME=attr.id, 593 NAME=attr.id,
593 TYPE=return_type) 594 TYPE=return_type,
595 NATIVE_TYPE=native_type)
594 596
595 def _AddRenamingSetter(self, attr, html_name): 597 def _AddRenamingSetter(self, attr, html_name):
596 self.EmitAttributeDocumentation(attr) 598 self.EmitAttributeDocumentation(attr)
597 599
598 conversion = self._InputConversion(attr.type.id, attr.id) 600 conversion = self._InputConversion(attr.type.id, attr.id)
599 if conversion: 601 if conversion:
600 return self._AddConvertingSetter(attr, html_name, conversion) 602 return self._AddConvertingSetter(attr, html_name, conversion)
601 self._members_emitter.Emit( 603 self._members_emitter.Emit(
602 # TODO(sra): Use metadata to provide native name. 604 # TODO(sra): Use metadata to provide native name.
603 '\n void set $HTML_NAME($TYPE value) {' 605 '\n void set $HTML_NAME($TYPE value) {'
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 868
867 def _HasCustomImplementation(self, member_name): 869 def _HasCustomImplementation(self, member_name):
868 member_name = '%s.%s' % (self._interface_type_info.interface_name(), 870 member_name = '%s.%s' % (self._interface_type_info.interface_name(),
869 member_name) 871 member_name)
870 return member_name in _js_custom_members 872 return member_name in _js_custom_members
871 873
872 def _Annotations(self, idl_type, member_name): 874 def _Annotations(self, idl_type, member_name):
873 annotations = FindAnnotations(idl_type, self._interface.id, member_name) 875 annotations = FindAnnotations(idl_type, self._interface.id, member_name)
874 if annotations: 876 if annotations:
875 return '%s\n ' % annotations 877 return '%s\n ' % annotations
878 return_type = self.SecureOutputType(idl_type)
879 native_type = self._NarrowToImplementationType(idl_type)
880 if native_type != return_type:
881 return "@Returns('%s') @Creates('%s')\n " % (native_type, native_type)
876 else: 882 else:
877 return '' 883 return ''
878 884
879 def CustomJSMembers(self): 885 def CustomJSMembers(self):
880 return _js_custom_members 886 return _js_custom_members
881 887
882 def _NarrowToImplementationType(self, type_name): 888 def _NarrowToImplementationType(self, type_name):
883 return self._type_registry.TypeInfo(type_name).narrow_dart_type() 889 return self._type_registry.TypeInfo(type_name).narrow_dart_type()
884 890
885 def _NarrowInputType(self, type_name): 891 def _NarrowInputType(self, type_name):
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 'svg': DartLibrary('svg', template_loader, library_type, output_dir), 990 'svg': DartLibrary('svg', template_loader, library_type, output_dir),
985 'html': DartLibrary('html', template_loader, library_type, output_dir), 991 'html': DartLibrary('html', template_loader, library_type, output_dir),
986 } 992 }
987 993
988 def AddFile(self, basename, library_name, path): 994 def AddFile(self, basename, library_name, path):
989 self._libraries[library_name].AddFile(path) 995 self._libraries[library_name].AddFile(path)
990 996
991 def Emit(self, emitter, auxiliary_dir): 997 def Emit(self, emitter, auxiliary_dir):
992 for lib in self._libraries.values(): 998 for lib in self._libraries.values():
993 lib.Emit(emitter, auxiliary_dir) 999 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/templates/html/dart2js/factoryprovider_MutationObserver.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698