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

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

Issue 9303011: Implement WebKit IDL 'module' feature [Supplemental=Foo] (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: manual fix Created 8 years, 10 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 | « client/dom/generated/wrapping_dom_externs.js ('k') | 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 import copy 6 import copy
7 import database 7 import database
8 import idlparser 8 import idlparser
9 import logging 9 import logging
10 import os 10 import os
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 op.arguments[i].is_optional = False 142 op.arguments[i].is_optional = False
143 new_op = copy.deepcopy(op) 143 new_op = copy.deepcopy(op)
144 new_op.arguments = new_op.arguments[:i] 144 new_op.arguments = new_op.arguments[:i]
145 new_ops.append(new_op) 145 new_ops.append(new_op)
146 new_ops.append(op) 146 new_ops.append(op)
147 interface.operations = new_ops 147 interface.operations = new_ops
148 148
149 def _rename_types(self, idl_file, import_options): 149 def _rename_types(self, idl_file, import_options):
150 """Rename interface and type names with names provided in the 150 """Rename interface and type names with names provided in the
151 options. Also clears scopes from scoped names""" 151 options. Also clears scopes from scoped names"""
152 def rename(idl_node): 152
153 name_parts = idl_node.id.split('::') 153 def rename(name):
154 idl_node.id = name_parts[-1] 154 name_parts = name.split('::')
155 if idl_node.id in import_options.type_rename_map: 155 name = name_parts[-1]
156 idl_node.id = import_options.type_rename_map[idl_node.id] 156 if name in import_options.type_rename_map:
157 map(rename, idl_file.all(IDLInterface)) 157 name = import_options.type_rename_map[name]
158 map(rename, idl_file.all(IDLType)) 158 return name
159
160 def rename_node(idl_node):
161 idl_node.id = rename(idl_node.id)
162
163 def rename_ext_attrs(ext_attrs_node):
164 for type_valued_attribute_name in ['Supplemental']:
vsm 2012/01/31 00:12:53 Do you expect any more attrs in this list?
165 if type_valued_attribute_name in ext_attrs_node:
166 value = ext_attrs_node[type_valued_attribute_name]
167 if isinstance(value, str):
168 ext_attrs_node[type_valued_attribute_name] = rename(value)
169
170 map(rename_node, idl_file.all(IDLInterface))
171 map(rename_node, idl_file.all(IDLType))
172 map(rename_ext_attrs, idl_file.all(IDLExtAttrs))
159 173
160 def _annotate(self, interface, module_name, import_options): 174 def _annotate(self, interface, module_name, import_options):
161 """Adds @ annotations based on the source and source_attributes 175 """Adds @ annotations based on the source and source_attributes
162 members of import_options.""" 176 members of import_options."""
163 177
164 source = import_options.source 178 source = import_options.source
165 if not source: 179 if not source:
166 return 180 return
167 181
168 def add_source_annotation(idl_node): 182 def add_source_annotation(idl_node):
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if self._database.HasInterface(interface.id): 441 if self._database.HasInterface(interface.id):
428 old_interface = self._database.GetInterface(interface.id) 442 old_interface = self._database.GetInterface(interface.id)
429 self._merge_interfaces(old_interface, interface, import_options) 443 self._merge_interfaces(old_interface, interface, import_options)
430 else: 444 else:
431 if import_options.add_new_interfaces: 445 if import_options.add_new_interfaces:
432 self._database.AddInterface(interface) 446 self._database.AddInterface(interface)
433 447
434 # Step 3: Merge in supplemental interfaces 448 # Step 3: Merge in supplemental interfaces
435 for interface, module_name, import_options in self._imported_interfaces: 449 for interface, module_name, import_options in self._imported_interfaces:
436 if interface.is_supplemental: 450 if interface.is_supplemental:
437 # For now, ignore WebKit [Supplemental=BaseInterface] attributes. 451 target_name = interface.ext_attrs['Supplemental']
438 target = interface.ext_attrs['Supplemental'] 452 if target_name:
439 if target: 453 # [Supplemental=DOMWindow] - merge into DOMWindow.
440 continue 454 target = target_name
441 target = interface.id 455 else:
456 # [Supplemental] - merge into existing inteface with same name.
457 target = interface.id
442 if self._database.HasInterface(target): 458 if self._database.HasInterface(target):
443 old_interface = self._database.GetInterface(target) 459 old_interface = self._database.GetInterface(target)
444 self._merge_interfaces(old_interface, interface, import_options) 460 self._merge_interfaces(old_interface, interface, import_options)
461 else:
462 raise Exception("Supplemental target '%s' not found", target)
445 463
446 # Step 4: Resolve 'implements' statements 464 # Step 4: Resolve 'implements' statements
447 for impl_stmt, import_options in self._impl_stmts: 465 for impl_stmt, import_options in self._impl_stmts:
448 self._merge_impl_stmt(impl_stmt, import_options) 466 self._merge_impl_stmt(impl_stmt, import_options)
449 467
450 self._impl_stmts = [] 468 self._impl_stmts = []
451 self._imported_interfaces = [] 469 self._imported_interfaces = []
452 470
453 def import_idl_file(self, file_path, 471 def import_idl_file(self, file_path,
454 import_options=DatabaseBuilderOptions()): 472 import_options=DatabaseBuilderOptions()):
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 annotation = idl_node.annotations[source] 565 annotation = idl_node.annotations[source]
548 for name, value in annotation.items(): 566 for name, value in annotation.items():
549 if (name in top_level_annotation 567 if (name in top_level_annotation
550 and value == top_level_annotation[name]): 568 and value == top_level_annotation[name]):
551 del annotation[name] 569 del annotation[name]
552 570
553 map(normalize, interface.parents) 571 map(normalize, interface.parents)
554 map(normalize, interface.constants) 572 map(normalize, interface.constants)
555 map(normalize, interface.attributes) 573 map(normalize, interface.attributes)
556 map(normalize, interface.operations) 574 map(normalize, interface.operations)
OLDNEW
« no previous file with comments | « client/dom/generated/wrapping_dom_externs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698