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

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

Issue 11962049: Revert "Fixing formatting of dart:html's dart2js annotations." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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/generator.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 os 10 import os
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 implements.append(parent_type_info.interface_name()) 386 implements.append(parent_type_info.interface_name())
387 387
388 secure_base_name = self._backend.SecureBaseName(interface_name) 388 secure_base_name = self._backend.SecureBaseName(interface_name)
389 if secure_base_name: 389 if secure_base_name:
390 implements.append(secure_base_name) 390 implements.append(secure_base_name)
391 391
392 implements_str = '' 392 implements_str = ''
393 if implements: 393 if implements:
394 implements_str = ' implements ' + ', '.join(set(implements)) 394 implements_str = ' implements ' + ', '.join(set(implements))
395 395
396 annotations = FormatAnnotations( 396 annotations = FindCommonAnnotations(self._interface.doc_js_name)
397 FindCommonAnnotations(self._interface.doc_js_name), '') 397 annotations_str = ''
398 if annotations:
399 annotations_str = '\n' + '\n'.join(annotations)
398 400
399 self._implementation_members_emitter = implementation_emitter.Emit( 401 self._implementation_members_emitter = implementation_emitter.Emit(
400 self._backend.ImplementationTemplate(), 402 self._backend.ImplementationTemplate(),
401 LIBRARYNAME=self._library_name, 403 LIBRARYNAME=self._library_name,
402 ANNOTATIONS=annotations, 404 ANNOTATIONS=annotations_str,
403 CLASSNAME=self._interface_type_info.implementation_name(), 405 CLASSNAME=self._interface_type_info.implementation_name(),
404 EXTENDS=' extends %s' % base_class if base_class else '', 406 EXTENDS=' extends %s' % base_class if base_class else '',
405 IMPLEMENTS=implements_str, 407 IMPLEMENTS=implements_str,
406 DOMNAME=self._interface.doc_js_name, 408 DOMNAME=self._interface.doc_js_name,
407 NATIVESPEC=self._backend.NativeSpec()) 409 NATIVESPEC=self._backend.NativeSpec())
408 self._backend.StartInterface(self._implementation_members_emitter) 410 self._backend.StartInterface(self._implementation_members_emitter)
409 411
410 self._backend.EmitHelpers(base_class) 412 self._backend.EmitHelpers(base_class)
411 self._event_generator.EmitStreamProviders( 413 self._event_generator.EmitStreamProviders(
412 self._interface, 414 self._interface,
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 915
914 def _HasCustomImplementation(self, member_name): 916 def _HasCustomImplementation(self, member_name):
915 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) 917 member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
916 return member_name in _js_custom_members 918 return member_name in _js_custom_members
917 919
918 def _RenamingAnnotation(self, idl_name, member_name): 920 def _RenamingAnnotation(self, idl_name, member_name):
919 if member_name != idl_name: 921 if member_name != idl_name:
920 return "@JSName('%s')\n " % idl_name 922 return "@JSName('%s')\n " % idl_name
921 return '' 923 return ''
922 924
923 def _Annotations(self, idl_type, idl_member_name, indent=' '): 925 def _Annotations(self, idl_type, idl_member_name):
926 out = ''
924 annotations = FindDart2JSAnnotations(idl_type, self._interface.id, 927 annotations = FindDart2JSAnnotations(idl_type, self._interface.id,
925 idl_member_name) 928 idl_member_name)
926 929 if annotations:
930 out = '%s\n ' % annotations
927 if not AnyConversionAnnotations(idl_type, self._interface.id, 931 if not AnyConversionAnnotations(idl_type, self._interface.id,
928 idl_member_name): 932 idl_member_name):
929 return_type = self.SecureOutputType(idl_type) 933 return_type = self.SecureOutputType(idl_type)
930 native_type = self._NarrowToImplementationType(idl_type) 934 native_type = self._NarrowToImplementationType(idl_type)
931 if native_type != return_type: 935 if native_type != return_type:
932 annotations.extend([ 936 out += "@Returns('%s') @Creates('%s')\n " % (native_type, native_type)
933 "@Returns('%s')" % native_type, 937 return out
934 "@Creates('%s')" % native_type,
935 ])
936 return FormatAnnotations(annotations, indent);
937 938
938 def CustomJSMembers(self): 939 def CustomJSMembers(self):
939 return _js_custom_members 940 return _js_custom_members
940 941
941 def _NarrowToImplementationType(self, type_name): 942 def _NarrowToImplementationType(self, type_name):
942 return self._type_registry.TypeInfo(type_name).narrow_dart_type() 943 return self._type_registry.TypeInfo(type_name).narrow_dart_type()
943 944
944 def _NarrowInputType(self, type_name): 945 def _NarrowInputType(self, type_name):
945 return self._NarrowToImplementationType(type_name) 946 return self._NarrowToImplementationType(type_name)
946 947
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 for library_name in libraries: 1044 for library_name in libraries:
1044 self._libraries[library_name] = DartLibrary( 1045 self._libraries[library_name] = DartLibrary(
1045 library_name, template_loader, library_type, output_dir) 1046 library_name, template_loader, library_type, output_dir)
1046 1047
1047 def AddFile(self, basename, library_name, path): 1048 def AddFile(self, basename, library_name, path):
1048 self._libraries[library_name].AddFile(path) 1049 self._libraries[library_name].AddFile(path)
1049 1050
1050 def Emit(self, emitter, auxiliary_dir): 1051 def Emit(self, emitter, auxiliary_dir):
1051 for lib in self._libraries.values(): 1052 for lib in self._libraries.values():
1052 lib.Emit(emitter, auxiliary_dir) 1053 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698