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

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

Issue 10703194: Extract interfaces and members renaming logic to a new HtmlRenamer class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 10
11 from systemfrog import * 11 from systemfrog import *
12 from systeminterface import * 12 from systeminterface import *
13 13
14 _html_strip_webkit_prefix_classes = [
15 'Animation',
16 'AnimationEvent',
17 'AnimationList',
18 'BlobBuilder',
19 'CSSKeyframeRule',
20 'CSSKeyframesRule',
21 'CSSMatrix',
22 'CSSTransformValue',
23 'Flags',
24 'LoseContext',
25 'Point',
26 'TransitionEvent']
27
28 # Members from the standard dom that should not be exposed publicly in dart:html
29 # but need to be exposed internally to implement dart:html on top of a standard
30 # browser.
31 _private_html_members = set([
32 'Document.createElement',
33 'Document.createElementNS',
34 'Document.createEvent',
35 'Document.createTextNode',
36 'Document.createTouchList',
37 'Document.getElementById',
38 'Document.getElementsByClassName',
39 'Document.getElementsByName',
40 'Document.getElementsByTagName',
41 'Document.querySelector',
42 'Document.querySelectorAll',
43 'DocumentFragment.querySelector',
44 'DocumentFragment.querySelectorAll',
45 'Element.childElementCount',
46 'Element.children',
47 'Element.className',
48 'Element.clientHeight',
49 'Element.clientLeft',
50 'Element.clientTop',
51 'Element.clientWidth',
52 'Element.firstElementChild',
53 'Element.getAttribute',
54 'Element.getBoundingClientRect',
55 'Element.getClientRects',
56 'Element.getElementsByClassName',
57 'Element.getElementsByTagName',
58 'Element.hasAttribute',
59 'Element.lastElementChild',
60 'Element.offsetHeight',
61 'Element.offsetLeft',
62 'Element.offsetTop',
63 'Element.offsetWidth',
64 'Element.querySelector',
65 'Element.querySelectorAll',
66 'Element.removeAttribute',
67 'Element.scrollHeight',
68 'Element.scrollLeft',
69 'Element.scrollTop',
70 'Element.scrollWidth',
71 'Element.setAttribute',
72 'Event.initEvent',
73 'EventTarget.addEventListener',
74 'EventTarget.dispatchEvent',
75 'EventTarget.removeEventListener',
76 'MouseEvent.initMouseEvent',
77 'Node.appendChild',
78 'Node.attributes',
79 'Node.childNodes',
80 'Node.firstChild',
81 'Node.lastChild',
82 "Node.nodeType",
83 'Node.removeChild',
84 'Node.replaceChild',
85 'Storage.length',
86 'Storage.clear',
87 'Storage.getItem',
88 'Storage.key',
89 'Storage.removeItem',
90 'Storage.setItem',
91 'Window.getComputedStyle',
92 ])
93
94 # Members from the standard dom that exist in the dart:html library with
95 # identical functionality but with cleaner names.
96 _html_library_renames = {
97 'Document.defaultView': 'window',
98 'Element.webkitMatchesSelector' : 'matchesSelector',
99 'Element.scrollIntoViewIfNeeded': 'scrollIntoView',
100 'Node.cloneNode': 'clone',
101 'Node.nextSibling': 'nextNode',
102 'Node.ownerDocument': 'document',
103 'Node.parentNode': 'parent',
104 'Node.previousSibling': 'previousNode',
105 'Node.textContent': 'text',
106 'SVGElement.className': '$dom_svgClassName',
107 'SVGAnimatedString.className': '$dom_svgClassName',
108 'SVGStylable.className': '$dom_svgClassName',
109 }
110
111 # Members and classes from the dom that should be removed completelly from
112 # dart:html. These could be expressed in the IDL instead but expressing this
113 # as a simple table instead is more concise.
114 # Syntax is: ClassName.(get\.|set\.)?MemberName
115 # Using get: and set: is optional and should only be used when a getter needs
116 # to be suppressed but not the setter, etc.
117 # TODO(jacobr): cleanup and augment this list.
118 _html_library_remove = set([
119 'NodeList.item',
120 "Attr.*",
121 # "BarProp.*",
122 # "BarInfo.*",
123 # "Blob.webkitSlice",
124 # "CDATASection.*",
125 # "Comment.*",
126 # "DOMImplementation.*",
127 "Document.get:forms",
128 # "Document.get:selectedStylesheetSet",
129 # "Document.set:selectedStylesheetSet",
130 # "Document.get:preferredStylesheetSet",
131 "Document.get:links",
132 "Document.set:domain",
133 "Document.get:implementation",
134 "Document.createAttributeNS",
135 "Document.get:inputEncoding",
136 "Document.get:height",
137 "Document.get:width",
138 "Element.getElementsByTagNameNS",
139 "Document.get:compatMode",
140 "Document.importNode",
141 "Document.evaluate",
142 "Document.get:images",
143 "Document.createExpression",
144 "Document.getOverrideStyle",
145 "Document.xmlStandalone",
146 "Document.createComment",
147 "Document.adoptNode",
148 "Document.get:characterSet",
149 "Document.createAttribute",
150 "Document.get:URL",
151 "Document.createEntityReference",
152 "Document.get:documentURI",
153 "Document.set:documentURI",
154 "Document.createNodeIterator",
155 "Document.createProcessingInstruction",
156 "Document.get:doctype",
157 "Document.createTreeWalker",
158 "Document.location",
159 "Document.createNSResolver",
160 "Document.get:xmlEncoding",
161 "Document.get:defaultCharset",
162 "Document.get:applets",
163 "Document.getSelection",
164 "Document.xmlVersion",
165 "Document.get:anchors",
166 "Document.getElementsByTagNameNS",
167 "DocumentType.*",
168 "Element.hasAttributeNS",
169 "Element.getAttributeNS",
170 "Element.setAttributeNode",
171 "Element.getAttributeNode",
172 "Element.removeAttributeNode",
173 "Element.removeAttributeNS",
174 "Element.setAttributeNodeNS",
175 "Element.getAttributeNodeNS",
176 "Element.setAttributeNS",
177 "BodyElement.text",
178 "AnchorElement.text",
179 "OptionElement.text",
180 "ScriptElement.text",
181 "TitleElement.text",
182 # "EventSource.get:url",
183 # TODO(jacobr): should these be removed?
184 "Document.close",
185 "Document.hasFocus",
186
187 "Document.vlinkColor",
188 "Document.captureEvents",
189 "Document.releaseEvents",
190 "Document.get:compatMode",
191 "Document.designMode",
192 "Document.dir",
193 "Document.all",
194 "Document.write",
195 "Document.fgColor",
196 "Document.bgColor",
197 "Document.get:plugins",
198 "Document.alinkColor",
199 "Document.get:embeds",
200 "Document.open",
201 "Document.clear",
202 "Document.get:scripts",
203 "Document.writeln",
204 "Document.linkColor",
205 "Element.get:itemRef",
206 "Element.outerText",
207 "Element.accessKey",
208 "Element.get:itemType",
209 "Element.innerText",
210 "Element.set:outerHTML",
211 "Element.itemScope",
212 "Element.itemValue",
213 "Element.itemId",
214 "Element.get:itemProp",
215 'Element.scrollIntoView',
216 'Element.get:classList',
217 "EmbedElement.getSVGDocument",
218 "FormElement.get:elements",
219 "HTMLFrameElement.*",
220 "HTMLFrameSetElement.*",
221 "HtmlElement.version",
222 "HtmlElement.manifest",
223 "Document.version",
224 "Document.manifest",
225 # "IFrameElement.getSVGDocument", #TODO(jacobr): should this be removed
226 "InputElement.dirName",
227 "HTMLIsIndexElement.*",
228 "ObjectElement.getSVGDocument",
229 "HTMLOptionsCollection.*",
230 "HTMLPropertiesCollection.*",
231 "SelectElement.remove",
232 "TextAreaElement.dirName",
233 "NamedNodeMap.*",
234 "Node.isEqualNode",
235 "Node.get:TEXT_NODE",
236 "Node.hasAttributes",
237 "Node.get:DOCUMENT_TYPE_NODE",
238 "Node.get:DOCUMENT_POSITION_FOLLOWING",
239 "Node.lookupNamespaceURI",
240 "Node.get:ELEMENT_NODE",
241 "Node.get:namespaceURI",
242 "Node.get:DOCUMENT_FRAGMENT_NODE",
243 "Node.get:localName",
244 "Node.isDefaultNamespace",
245 "Node.compareDocumentPosition",
246 "Node.get:baseURI",
247 "Node.isSameNode",
248 "Node.get:DOCUMENT_POSITION_DISCONNECTED",
249 "Node.get:DOCUMENT_NODE",
250 "Node.get:DOCUMENT_POSITION_CONTAINS",
251 "Node.get:COMMENT_NODE",
252 "Node.get:ENTITY_REFERENCE_NODE",
253 "Node.isSupported",
254 "Node.get:DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
255 "Node.get:NOTATION_NODE",
256 "Node.normalize",
257 "Node.get:parentElement",
258 "Node.get:ATTRIBUTE_NODE",
259 "Node.get:ENTITY_NODE",
260 "Node.get:DOCUMENT_POSITION_CONTAINED_BY",
261 "Node.get:prefix",
262 "Node.set:prefix",
263 "Node.get:DOCUMENT_POSITION_PRECEDING",
264 "Node.get:nodeValue",
265 "Node.set:nodeValue",
266 "Node.get:CDATA_SECTION_NODE",
267 "Node.get:nodeName",
268 "Node.lookupPrefix",
269 "Node.get:PROCESSING_INSTRUCTION_NODE",
270 "IFrameElement.get:contentDocument",
271 "Window.get:frameElement",
272 ])
273
274 _js_custom_members = set([ 14 _js_custom_members = set([
275 'IFrameElement.contentWindow', 15 'IFrameElement.contentWindow',
276 'Window.document', 16 'Window.document',
277 'Window.top', 17 'Window.top',
278 'Window.location', 18 'Window.location',
279 'Window.open', 19 'Window.open',
280 'IDBDatabase.transaction', 20 'IDBDatabase.transaction',
281 ]) 21 ])
282 22
283 # This map controls merging of interfaces in dart:html library. 23 # This map controls merging of interfaces in dart:html library.
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 'No known html event name for event: ' + event_name 359 'No known html event name for event: ' + event_name
620 return _html_event_names[event_name] 360 return _html_event_names[event_name]
621 361
622 # ------------------------------------------------------------------------------ 362 # ------------------------------------------------------------------------------
623 class HtmlSystemShared(object): 363 class HtmlSystemShared(object):
624 364
625 def __init__(self, context): 365 def __init__(self, context):
626 self._event_classes = set() 366 self._event_classes = set()
627 self._seen_event_names = {} 367 self._seen_event_names = {}
628 self._database = context.database 368 self._database = context.database
629 self._type_registry = context.type_registry
630 self._inheritance_closure = _ComputeInheritanceClosure(self._database)
631
632 @staticmethod
633 def _HasAncestor(database, interface, names_to_match):
634 for parent in interface.parents:
635 if parent.type.id in names_to_match:
636 return True
637 if not database.HasInterface(parent.type.id):
638 continue
639 parent_interface = database.GetInterface(parent.type.id)
640 if HtmlSystemShared._HasAncestor(database, parent_interface, names_to_matc h):
641 return True
642 return False
643
644 @staticmethod
645 def MakeHtmlRenames(database):
646 html_renames = {}
647
648 for interface in database.GetInterfaces():
649 if (interface.id.startswith('HTML') and
650 HtmlSystemShared._HasAncestor(database, interface, ['Element', 'Docume nt'])):
651 html_renames[interface.id] = interface.id[4:]
652
653 for subclass in _html_strip_webkit_prefix_classes:
654 html_renames['WebKit' + subclass] = subclass
655
656 # TODO(jacobr): we almost want to add this commented out line back.
657 # html_renames['HTMLCollection'] = 'ElementList'
658 # html_renames['NodeList'] = 'ElementList'
659 # html_renames['HTMLOptionsCollection'] = 'ElementList'
660 html_renames['DOMWindow'] = 'Window'
661
662 return html_renames
663
664 def _FindMatch(self, interface_name, member, member_prefix, candidates):
665 for ancestor_name in self._AllAncestorInterfaces(interface_name):
666 name = self._DartType(ancestor_name) + '.' + member
667 if name in candidates:
668 return name
669 name = (self._DartType(interface_name) + '.' + member_prefix +
670 member)
671 if name in candidates:
672 return name
673 return None
674
675 def _AllAncestorInterfaces(self, interface_name):
676 return [interface_name] + self._inheritance_closure[interface_name]
677
678 def RenameInHtmlLibrary(self, interface_name, member, member_prefix='',
679 implementation_class=False):
680 """
681 Returns the name of the member in the HTML library or None if the member is
682 suppressed in the HTML library
683 """
684 if self._FindMatch(interface_name, member, member_prefix,
685 _html_library_remove):
686 return None
687
688 name = self._FindMatch(interface_name, member, member_prefix,
689 _html_library_renames)
690 target_name = _html_library_renames[name] if name else member
691
692 if not target_name.startswith('_'):
693 if self._FindMatch(interface_name, member, member_prefix,
694 _private_html_members):
695 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
696 target_name = '$dom_' + target_name
697
698 return target_name
699
700 def IsCustomInHtmlLibrary(self, interface, member, member_prefix=''):
701 return self._FindMatch(interface.id, member, member_prefix,
702 _html_library_custom)
703 369
704 # TODO(jacobr): this already exists 370 # TODO(jacobr): this already exists
705 def _TraverseParents(self, interface, callback): 371 def _TraverseParents(self, interface, callback):
706 for parent in interface.parents: 372 for parent in interface.parents:
707 parent_id = parent.type.id 373 parent_id = parent.type.id
708 if self._database.HasInterface(parent_id): 374 if self._database.HasInterface(parent_id):
709 parent_interface = self._database.GetInterface(parent_id) 375 parent_interface = self._database.GetInterface(parent_id)
710 callback(parent_interface) 376 callback(parent_interface)
711 self._TraverseParents(parent_interface, callback) 377 self._TraverseParents(parent_interface, callback)
712 378
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 if attr.type.id == 'EventListener']) 411 if attr.type.id == 'EventListener'])
746 412
747 if events or interface.id in _html_explicit_event_classes: 413 if events or interface.id in _html_explicit_event_classes:
748 return True, events 414 return True, events
749 else: 415 else:
750 return False, None 416 return False, None
751 417
752 def IsPrivate(self, name): 418 def IsPrivate(self, name):
753 return name.startswith('_') 419 return name.startswith('_')
754 420
755 def _DartType(self, type_name):
756 return self._type_registry.DartType(type_name)
757
758 421
759 class HtmlInterfacesSystem(System): 422 class HtmlInterfacesSystem(System):
760 def __init__(self, options, backend): 423 def __init__(self, options, backend):
761 super(HtmlInterfacesSystem, self).__init__(options) 424 super(HtmlInterfacesSystem, self).__init__(options)
762 self._backend = backend 425 self._backend = backend
763 self._shared = HtmlSystemShared(options) 426 self._shared = HtmlSystemShared(options)
764 self._dart_interface_file_paths = [] 427 self._dart_interface_file_paths = []
765 self._elements_factory_emitter = None 428 self._elements_factory_emitter = None
766 429
767 def ProcessInterface(self, interface): 430 def ProcessInterface(self, interface):
(...skipping 18 matching lines...) Expand all
786 # ------------------------------------------------------------------------------ 449 # ------------------------------------------------------------------------------
787 450
788 class HtmlDartInterfaceGenerator(BaseGenerator): 451 class HtmlDartInterfaceGenerator(BaseGenerator):
789 """Generates dart interface and implementation for the DOM IDL interface.""" 452 """Generates dart interface and implementation for the DOM IDL interface."""
790 453
791 def __init__(self, system, interface): 454 def __init__(self, system, interface):
792 super(HtmlDartInterfaceGenerator, self).__init__( 455 super(HtmlDartInterfaceGenerator, self).__init__(
793 system._database, interface) 456 system._database, interface)
794 self._system = system 457 self._system = system
795 self._shared = system._shared 458 self._shared = system._shared
796 self._html_interface_name = system._type_registry.InterfaceName(self._interf ace.id) 459 self._html_interface_name = system._renamer.RenameInterface(self._interface)
797 self._backend = system._backend.ImplementationGenerator(self._interface) 460 self._backend = system._backend.ImplementationGenerator(self._interface)
798 461
799 def StartInterface(self): 462 def StartInterface(self):
800 if not self._interface.id in _merged_html_interfaces: 463 if not self._interface.id in _merged_html_interfaces:
801 path = self._system._FilePathForDartInterface(self._html_interface_name) 464 path = self._system._FilePathForDartInterface(self._html_interface_name)
802 self._system._dart_interface_file_paths.append(path) 465 self._system._dart_interface_file_paths.append(path)
803 self._interface_emitter = self._system._emitters.FileEmitter(path) 466 self._interface_emitter = self._system._emitters.FileEmitter(path)
804 else: 467 else:
805 self._interface_emitter = emitter.Emitter() 468 self._interface_emitter = emitter.Emitter()
806 469
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 self._backend = old_backend 590 self._backend = old_backend
928 591
929 def AddIndexer(self, element_type): 592 def AddIndexer(self, element_type):
930 self._backend.AddIndexer(element_type) 593 self._backend.AddIndexer(element_type)
931 594
932 def AmendIndexer(self, element_type): 595 def AmendIndexer(self, element_type):
933 self._backend.AmendIndexer(element_type) 596 self._backend.AmendIndexer(element_type)
934 597
935 def AddAttribute(self, attribute, is_secondary=False): 598 def AddAttribute(self, attribute, is_secondary=False):
936 dom_name = DartDomNameOfAttribute(attribute) 599 dom_name = DartDomNameOfAttribute(attribute)
937 html_name = self._shared.RenameInHtmlLibrary( 600 html_name = self._system._renamer.RenameMember(
938 self._interface.id, dom_name, 'get:') 601 self._interface.id, dom_name, 'get:')
939 if not html_name or self._shared.IsPrivate(html_name): 602 if not html_name or self._shared.IsPrivate(html_name):
940 return 603 return
941 604
942 605
943 html_setter_name = self._shared.RenameInHtmlLibrary( 606 html_setter_name = self._system._renamer.RenameMember(
944 self._interface.id, dom_name, 'set:') 607 self._interface.id, dom_name, 'set:')
945 read_only = IsReadOnly(attribute) or not html_setter_name 608 read_only = IsReadOnly(attribute) or not html_setter_name
946 609
947 # We don't yet handle inconsistent renames of the getter and setter yet. 610 # We don't yet handle inconsistent renames of the getter and setter yet.
948 assert(not html_setter_name or html_name == html_setter_name) 611 assert(not html_setter_name or html_name == html_setter_name)
949 612
950 if not is_secondary: 613 if not is_secondary:
951 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */', 614 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
952 DOMINTERFACE=attribute.doc_js_interface_name, 615 DOMINTERFACE=attribute.doc_js_interface_name,
953 DOMNAME=dom_name) 616 DOMNAME=dom_name)
954 modifier = 'final ' if read_only else '' 617 modifier = 'final ' if read_only else ''
955 self._members_emitter.Emit('\n $MODIFIER$TYPE $NAME;\n', 618 self._members_emitter.Emit('\n $MODIFIER$TYPE $NAME;\n',
956 MODIFIER=modifier, 619 MODIFIER=modifier,
957 NAME=html_name, 620 NAME=html_name,
958 TYPE=self._DartType(attribute.type.id)) 621 TYPE=self._DartType(attribute.type.id))
959 self._backend.AddAttribute(attribute, html_name, read_only) 622 self._backend.AddAttribute(attribute, html_name, read_only)
960 623
961 def AddSecondaryAttribute(self, interface, attribute): 624 def AddSecondaryAttribute(self, interface, attribute):
962 self._backend.SecondaryContext(interface) 625 self._backend.SecondaryContext(interface)
963 self.AddAttribute(attribute, True) 626 self.AddAttribute(attribute, True)
964 627
965 def AddOperation(self, info, skip_declaration=False): 628 def AddOperation(self, info, skip_declaration=False):
966 """ 629 """
967 Arguments: 630 Arguments:
968 operations - contains the overloads, one or more operations with the same 631 operations - contains the overloads, one or more operations with the same
969 name. 632 name.
970 """ 633 """
971 html_name = self._shared.RenameInHtmlLibrary(self._interface.id, info.name) 634 html_name = self._system._renamer.RenameMember(self._interface.id, info.name )
972 if not html_name: 635 if not html_name:
973 if info.name == 'item': 636 if info.name == 'item':
974 # FIXME: item should be renamed to operator[], not removed. 637 # FIXME: item should be renamed to operator[], not removed.
975 self._backend.AddOperation(info, '_item') 638 self._backend.AddOperation(info, '_item')
976 return 639 return
977 640
978 if not self._shared.IsPrivate(html_name) and not skip_declaration: 641 if not self._shared.IsPrivate(html_name) and not skip_declaration:
979 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */', 642 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
980 DOMINTERFACE=info.overloads[0].doc_js_interface_name, 643 DOMINTERFACE=info.overloads[0].doc_js_interface_name,
981 DOMNAME=info.name) 644 DOMNAME=info.name)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 # TODO(jmesserly): inheritance is probably not the right way to factor this long 741 # TODO(jmesserly): inheritance is probably not the right way to factor this long
1079 # term, but it makes merging better for now. 742 # term, but it makes merging better for now.
1080 class HtmlFrogClassGenerator(FrogInterfaceGenerator): 743 class HtmlFrogClassGenerator(FrogInterfaceGenerator):
1081 """Generates a Frog class for the dart:html library from a DOM IDL 744 """Generates a Frog class for the dart:html library from a DOM IDL
1082 interface. 745 interface.
1083 """ 746 """
1084 747
1085 def __init__(self, system, interface): 748 def __init__(self, system, interface):
1086 super(HtmlFrogClassGenerator, self).__init__( 749 super(HtmlFrogClassGenerator, self).__init__(
1087 system, interface, None, None) 750 system, interface, None, None)
1088 self._html_interface_name = system._type_registry.InterfaceName(self._interf ace.id) 751 self._html_interface_name = system._renamer.RenameInterface(self._interface)
1089 752
1090 def HasImplementation(self): 753 def HasImplementation(self):
1091 return not (IsPureInterface(self._interface.id) or 754 return not (IsPureInterface(self._interface.id) or
1092 self._interface.id in _merged_html_interfaces) 755 self._interface.id in _merged_html_interfaces)
1093 756
1094 def ImplementationClassName(self): 757 def ImplementationClassName(self):
1095 return self._ImplClassName(self._html_interface_name) 758 return self._ImplClassName(self._html_interface_name)
1096 759
1097 def FilePathForDartImplementation(self): 760 def FilePathForDartImplementation(self):
1098 return os.path.join(self._system._output_dir, 'html', 'frog', 761 return os.path.join(self._system._output_dir, 'html', 'frog',
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 return HtmlFrogClassGenerator(self, interface) 1008 return HtmlFrogClassGenerator(self, interface)
1346 1009
1347 def GenerateLibraries(self, dart_files): 1010 def GenerateLibraries(self, dart_files):
1348 self._GenerateLibFile( 1011 self._GenerateLibFile(
1349 'html_frog.darttemplate', 1012 'html_frog.darttemplate',
1350 os.path.join(self._output_dir, 'html_frog.dart'), 1013 os.path.join(self._output_dir, 'html_frog.dart'),
1351 dart_files) 1014 dart_files)
1352 1015
1353 def Finish(self): 1016 def Finish(self):
1354 pass 1017 pass
1355
1356 # -----------------------------------------------------------------------------
1357
1358 def _ComputeInheritanceClosure(database):
1359 def Collect(interface, seen, collected):
1360 name = interface.id
1361 if '<' in name:
1362 # TODO(sra): Handle parameterized types.
1363 return
1364 if not name in seen:
1365 seen.add(name)
1366 collected.append(name)
1367 for parent in interface.parents:
1368 # TODO(sra): Handle parameterized types.
1369 if not '<' in parent.type.id:
1370 if database.HasInterface(parent.type.id):
1371 Collect(database.GetInterface(parent.type.id),
1372 seen, collected)
1373
1374 inheritance_closure = {}
1375 for interface in database.GetInterfaces():
1376 seen = set()
1377 collected = []
1378 Collect(interface, seen, collected)
1379 inheritance_closure[interface.id] = collected
1380 return inheritance_closure
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698