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

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

Issue 12663017: Reapply the expanded names with the correct form of requestFileSystem on the (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « tests/html/notifications_test.dart ('k') | tools/dom/scripts/htmlrenamer.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 from generator import AnalyzeOperation, ConstantOutputOrder, \ 10 from generator import AnalyzeOperation, ConstantOutputOrder, \
11 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ 11 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \
12 IsPureInterface, TypeOrNothing, GetAnnotationsAndComments, \ 12 IsPureInterface, TypeOrNothing, GetAnnotationsAndComments, \
13 FormatAnnotationsAndComments, ConvertToFuture, GetCallbackInfo 13 FormatAnnotationsAndComments, ConvertToFuture, GetCallbackInfo
14 from htmlrenamer import convert_to_future_members 14 from htmlrenamer import convert_to_future_members
15 15
16 # Types that are accessible cross-frame in a limited fashion. 16 # Types that are accessible cross-frame in a limited fashion.
17 # In these cases, the base type (e.g., WindowBase) provides restricted access 17 # In these cases, the base type (e.g., WindowBase) provides restricted access
18 # while the subtype (e.g., Window) provides full access to the 18 # while the subtype (e.g., Window) provides full access to the
19 # corresponding objects if there are from the same frame. 19 # corresponding objects if there are from the same frame.
20 _secure_base_types = { 20 _secure_base_types = {
21 'Window': 'WindowBase', 21 'Window': 'WindowBase',
22 'Location': 'LocationBase', 22 'Location': 'LocationBase',
23 'History': 'HistoryBase', 23 'History': 'HistoryBase',
24 } 24 }
25 25
26 _custom_factories = [
27 'Notification',
28 'EventSource',
29 ]
26 30
27 class HtmlDartGenerator(object): 31 class HtmlDartGenerator(object):
28 def __init__(self, interface, options): 32 def __init__(self, interface, options):
29 self._database = options.database 33 self._database = options.database
30 self._interface = interface 34 self._interface = interface
31 self._type_registry = options.type_registry 35 self._type_registry = options.type_registry
32 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) 36 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id)
33 self._renamer = options.renamer 37 self._renamer = options.renamer
34 self._library_name = self._renamer.GetLibraryName(self._interface) 38 self._library_name = self._renamer.GetLibraryName(self._interface)
35 39
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 NAME=name, 482 NAME=name,
479 FACTORY_PARAMS= \ 483 FACTORY_PARAMS= \
480 constructor_info.ParametersAsArgumentList(argument_count)) 484 constructor_info.ParametersAsArgumentList(argument_count))
481 self.EmitStaticFactoryOverload( 485 self.EmitStaticFactoryOverload(
482 constructor_info, name, 486 constructor_info, name,
483 constructor_info.idl_args[signature_index][:argument_count]) 487 constructor_info.idl_args[signature_index][:argument_count])
484 488
485 def IsOptional(signature_index, argument): 489 def IsOptional(signature_index, argument):
486 return self.IsConstructorArgumentOptional(argument) 490 return self.IsConstructorArgumentOptional(argument)
487 491
492 custom_factory_ctr = self._interface.id in _custom_factories
493 constructor_full_name = constructor_info._ConstructorFullName(
494 self._DartType)
488 self._GenerateOverloadDispatcher( 495 self._GenerateOverloadDispatcher(
489 constructor_info.idl_args, 496 constructor_info.idl_args,
490 False, 497 False,
491 [info.name for info in constructor_info.param_infos], 498 [info.name for info in constructor_info.param_infos],
492 emitter.Format('$(ANNOTATIONS)factory $CTOR($PARAMS)', 499 emitter.Format('$(ANNOTATIONS)$FACTORY_KEYWORD $CTOR($PARAMS)',
493 CTOR=constructor_info._ConstructorFullName(self._DartType), 500 FACTORY_KEYWORD=('factory' if not custom_factory_ctr else
501 'static %s' % constructor_full_name),
502 CTOR=(('' if not custom_factory_ctr else '_factory')
503 + constructor_full_name),
494 ANNOTATIONS=annotations, 504 ANNOTATIONS=annotations,
495 PARAMS=constructor_info.ParametersDeclaration(self._DartType)), 505 PARAMS=constructor_info.ParametersDeclaration(self._DartType)),
496 GenerateCall, 506 GenerateCall,
497 IsOptional) 507 IsOptional)
498 508
499 def _AddFutureifiedOperation(self, info, html_name): 509 def _AddFutureifiedOperation(self, info, html_name):
500 """Given a API function that uses callbacks, convert it to using Futures. 510 """Given a API function that uses callbacks, convert it to using Futures.
501 511
502 This conversion assumes the success callback is always provided before the 512 This conversion assumes the success callback is always provided before the
503 error callback (and so far in the DOM API, this is the case).""" 513 error callback (and so far in the DOM API, this is the case)."""
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 walk(interface.parents) 651 walk(interface.parents)
642 else: 652 else:
643 walk(interface.parents[1:]) 653 walk(interface.parents[1:])
644 return result 654 return result
645 655
646 def _DartType(self, type_name): 656 def _DartType(self, type_name):
647 return self._type_registry.DartType(type_name) 657 return self._type_registry.DartType(type_name)
648 658
649 def _IsPrivate(self, name): 659 def _IsPrivate(self, name):
650 return name.startswith('_') 660 return name.startswith('_')
OLDNEW
« no previous file with comments | « tests/html/notifications_test.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698