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

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

Issue 11968047: 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
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 = FindCommonAnnotations(self._interface.doc_js_name) 396 annotations = FormatAnnotations(
397 annotations_str = '' 397 FindCommonAnnotations(self._interface.doc_js_name), '')
398 if annotations:
399 annotations_str = '\n' + '\n'.join(annotations)
400 398
401 self._implementation_members_emitter = implementation_emitter.Emit( 399 self._implementation_members_emitter = implementation_emitter.Emit(
402 self._backend.ImplementationTemplate(), 400 self._backend.ImplementationTemplate(),
403 LIBRARYNAME=self._library_name, 401 LIBRARYNAME=self._library_name,
404 ANNOTATIONS=annotations_str, 402 ANNOTATIONS=annotations,
405 CLASSNAME=self._interface_type_info.implementation_name(), 403 CLASSNAME=self._interface_type_info.implementation_name(),
406 EXTENDS=' extends %s' % base_class if base_class else '', 404 EXTENDS=' extends %s' % base_class if base_class else '',
407 IMPLEMENTS=implements_str, 405 IMPLEMENTS=implements_str,
408 DOMNAME=self._interface.doc_js_name, 406 DOMNAME=self._interface.doc_js_name,
409 NATIVESPEC=self._backend.NativeSpec()) 407 NATIVESPEC=self._backend.NativeSpec())
410 self._backend.StartInterface(self._implementation_members_emitter) 408 self._backend.StartInterface(self._implementation_members_emitter)
411 409
412 self._backend.EmitHelpers(base_class) 410 self._backend.EmitHelpers(base_class)
413 self._event_generator.EmitStreamProviders( 411 self._event_generator.EmitStreamProviders(
414 self._interface, 412 self._interface,
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 913
916 def _HasCustomImplementation(self, member_name): 914 def _HasCustomImplementation(self, member_name):
917 member_name = '%s.%s' % (self._interface.doc_js_name, member_name) 915 member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
918 return member_name in _js_custom_members 916 return member_name in _js_custom_members
919 917
920 def _RenamingAnnotation(self, idl_name, member_name): 918 def _RenamingAnnotation(self, idl_name, member_name):
921 if member_name != idl_name: 919 if member_name != idl_name:
922 return "@JSName('%s')\n " % idl_name 920 return "@JSName('%s')\n " % idl_name
923 return '' 921 return ''
924 922
925 def _Annotations(self, idl_type, idl_member_name): 923 def _Annotations(self, idl_type, idl_member_name, indent=' '):
926 out = ''
927 annotations = FindDart2JSAnnotations(idl_type, self._interface.id, 924 annotations = FindDart2JSAnnotations(idl_type, self._interface.id,
928 idl_member_name) 925 idl_member_name)
929 if annotations: 926
930 out = '%s\n ' % annotations
931 if not AnyConversionAnnotations(idl_type, self._interface.id, 927 if not AnyConversionAnnotations(idl_type, self._interface.id,
932 idl_member_name): 928 idl_member_name):
933 return_type = self.SecureOutputType(idl_type) 929 return_type = self.SecureOutputType(idl_type)
934 native_type = self._NarrowToImplementationType(idl_type) 930 native_type = self._NarrowToImplementationType(idl_type)
935 if native_type != return_type: 931 if native_type != return_type:
936 out += "@Returns('%s') @Creates('%s')\n " % (native_type, native_type) 932 annotations.extend([
937 return out 933 "@Returns('%s')" % native_type,
934 "@Creates('%s')" % native_type,
935 ])
936 return FormatAnnotations(annotations, indent);
938 937
939 def CustomJSMembers(self): 938 def CustomJSMembers(self):
940 return _js_custom_members 939 return _js_custom_members
941 940
942 def _NarrowToImplementationType(self, type_name): 941 def _NarrowToImplementationType(self, type_name):
943 return self._type_registry.TypeInfo(type_name).narrow_dart_type() 942 return self._type_registry.TypeInfo(type_name).narrow_dart_type()
944 943
945 def _NarrowInputType(self, type_name): 944 def _NarrowInputType(self, type_name):
946 return self._NarrowToImplementationType(type_name) 945 return self._NarrowToImplementationType(type_name)
947 946
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 for library_name in libraries: 1043 for library_name in libraries:
1045 self._libraries[library_name] = DartLibrary( 1044 self._libraries[library_name] = DartLibrary(
1046 library_name, template_loader, library_type, output_dir) 1045 library_name, template_loader, library_type, output_dir)
1047 1046
1048 def AddFile(self, basename, library_name, path): 1047 def AddFile(self, basename, library_name, path):
1049 self._libraries[library_name].AddFile(path) 1048 self._libraries[library_name].AddFile(path)
1050 1049
1051 def Emit(self, emitter, auxiliary_dir): 1050 def Emit(self, emitter, auxiliary_dir):
1052 for lib in self._libraries.values(): 1051 for lib in self._libraries.values():
1053 lib.Emit(emitter, auxiliary_dir) 1052 lib.Emit(emitter, auxiliary_dir)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698