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

Side by Side Diff: client/dom/scripts/dartgenerator.py

Issue 9187082: Remove dead code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, 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 generates Dart APIs from the IDL database.""" 6 """This module generates Dart APIs from the IDL database."""
7 7
8 import emitter 8 import emitter
9 import idlnode 9 import idlnode
10 import logging 10 import logging
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 info.arg_infos = args 688 info.arg_infos = args
689 return info 689 return info
690 690
691 691
692 def Flush(self): 692 def Flush(self):
693 """Write out all pending files.""" 693 """Write out all pending files."""
694 _logger.info('Flush...') 694 _logger.info('Flush...')
695 self._emitters.Flush() 695 self._emitters.Flush()
696 696
697 697
698 def FilePathForDartInterface(self, interface_name):
699 """Returns the file path of the Dart interface definition."""
700 return os.path.join(self._output_dir, 'src', 'interface',
701 '%s.dart' % interface_name)
702
703
704 def FilePathForDartWrappingImpl(self, interface_name):
705 """Returns the file path of the Dart wrapping implementation."""
706 return os.path.join(self._output_dir, 'src', 'wrapping',
707 '_%sWrappingImplementation.dart' % interface_name)
708
709 def FilePathForFrogImpl(self, interface_name):
710 """Returns the file path of the Frog implementation."""
711 return os.path.join(self._output_dir, 'src', 'frog',
712 '%s.dart' % interface_name)
713
714
715 def _ComputeInheritanceClosure(self): 698 def _ComputeInheritanceClosure(self):
716 def Collect(interface, seen, collected): 699 def Collect(interface, seen, collected):
717 name = interface.id 700 name = interface.id
718 if '<' in name: 701 if '<' in name:
719 # TODO(sra): Handle parameterized types. 702 # TODO(sra): Handle parameterized types.
720 return 703 return
721 if not name in seen: 704 if not name in seen:
722 seen.add(name) 705 seen.add(name)
723 collected.append(name) 706 collected.append(name)
724 for parent in interface.parents: 707 for parent in interface.parents:
(...skipping 10 matching lines...) Expand all
735 Collect(interface, seen, collected) 718 Collect(interface, seen, collected)
736 self._inheritance_closure[interface.id] = collected 719 self._inheritance_closure[interface.id] = collected
737 720
738 def _AllImplementedInterfaces(self, interface): 721 def _AllImplementedInterfaces(self, interface):
739 """Returns a list of the names of all interfaces implemented by 'interface'. 722 """Returns a list of the names of all interfaces implemented by 'interface'.
740 List includes the name of 'interface'. 723 List includes the name of 'interface'.
741 """ 724 """
742 return self._inheritance_closure[interface.id] 725 return self._inheritance_closure[interface.id]
743 726
744 727
745
746 def _GenerateJavaScriptExternInterfaces(self,
747 database,
748 namespace,
749 window_code,
750 prop_code):
751 """Generate externs for JavaScript patch code.
752 """
753
754 props = set()
755
756 for interface in database.GetInterfaces():
757 self._GatherInterfacePropertyNames(interface, props)
758
759 for name in sorted(list(props)):
760 prop_code.Emit('$NAMESPACE.prototype.$NAME;\n',
761 NAMESPACE=namespace, NAME=name)
762
763 for interface in database.GetInterfaces():
764 window_code.Emit('Window.prototype.$CLASSREF;\n',
765 CLASSREF=interface.id)
766
767
768 def _GatherInterfacePropertyNames(self, interface, props):
769 """Gather the properties that will be defined on the interface.
770 """
771
772 # Define getters and setters.
773 getters = [attr.id for attr in interface.attributes if attr.is_fc_getter]
774 setters = [attr.id for attr in interface.attributes if attr.is_fc_setter]
775
776 for name in getters:
777 props.add(name + '$getter')
778
779 for name in setters:
780 props.add(name + '$setter')
781
782 # Define members.
783 operations = [op.ext_attrs.get('DartName', op.id)
784 for op in interface.operations]
785 members = sorted(set(operations))
786 for name in members:
787 props.add(name + '$member')
788
789
790 class OperationInfo(object): 728 class OperationInfo(object):
791 """Holder for various derived information from a set of overloaded operations. 729 """Holder for various derived information from a set of overloaded operations.
792 730
793 Attributes: 731 Attributes:
794 overloads: A list of IDL operation overloads with the same name. 732 overloads: A list of IDL operation overloads with the same name.
795 name: A string, the simple name of the operation. 733 name: A string, the simple name of the operation.
796 type_name: A string, the name of the return type of the operation. 734 type_name: A string, the name of the return type of the operation.
797 arg_declarations: A list of strings, Dart argument declarations for the 735 arg_declarations: A list of strings, Dart argument declarations for the
798 member that implements the set of overloads. Each string is of the form 736 member that implements the set of overloads. Each string is of the form
799 "T arg" or "T arg = null". 737 "T arg" or "T arg = null".
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 Arguments: 2012 Arguments:
2075 info: An OperationInfo object. 2013 info: An OperationInfo object.
2076 """ 2014 """
2077 # TODO(vsm): Handle overloads. 2015 # TODO(vsm): Handle overloads.
2078 self._members_emitter.Emit( 2016 self._members_emitter.Emit(
2079 '\n' 2017 '\n'
2080 ' $TYPE $NAME($ARGS) native;\n', 2018 ' $TYPE $NAME($ARGS) native;\n',
2081 TYPE=info.type_name, 2019 TYPE=info.type_name,
2082 NAME=info.name, 2020 NAME=info.name,
2083 ARGS=info.arg_implementation_declaration) 2021 ARGS=info.arg_implementation_declaration)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698