| OLD | NEW |
| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 return | 249 return |
| 250 res.append(current_interface) | 250 res.append(current_interface) |
| 251 for parent in current_interface.parents: | 251 for parent in current_interface.parents: |
| 252 parent_name = parent.type.id | 252 parent_name = parent.type.id |
| 253 if self._database.HasInterface(parent_name): | 253 if self._database.HasInterface(parent_name): |
| 254 recurse(self._database.GetInterface(parent_name)) | 254 recurse(self._database.GetInterface(parent_name)) |
| 255 | 255 |
| 256 recurse(interface) | 256 recurse(interface) |
| 257 return res[1:] | 257 return res[1:] |
| 258 | 258 |
| 259 def _merge_ext_attrs(self, old_attrs, new_attrs): |
| 260 """Merges two sets of extended attributes. |
| 261 |
| 262 Returns: True if old_attrs has changed. |
| 263 """ |
| 264 changed = False |
| 265 for (name, value) in new_attrs.items(): |
| 266 if name in old_attrs and old_attrs[name] == value: |
| 267 pass # Identical |
| 268 else: |
| 269 old_attrs[name] = value |
| 270 changed = True |
| 271 return changed |
| 272 |
| 259 def _merge_nodes(self, old_list, new_list, import_options): | 273 def _merge_nodes(self, old_list, new_list, import_options): |
| 260 """Merges two lists of nodes. Annotates nodes with the source of each | 274 """Merges two lists of nodes. Annotates nodes with the source of each |
| 261 node. | 275 node. |
| 262 | 276 |
| 263 Returns: | 277 Returns: |
| 264 True is the old_list has changed. | 278 True if the old_list has changed. |
| 265 | 279 |
| 266 Args: | 280 Args: |
| 267 old_list -- the list to merge into. | 281 old_list -- the list to merge into. |
| 268 new_list -- list containing more nodes. | 282 new_list -- list containing more nodes. |
| 269 import_options -- controls how merging is done. | 283 import_options -- controls how merging is done. |
| 270 """ | 284 """ |
| 271 changed = False | 285 changed = False |
| 272 | 286 |
| 273 source = import_options.source | 287 source = import_options.source |
| 274 | 288 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 295 new_arg_name = new_node.arguments[i].id | 309 new_arg_name = new_node.arguments[i].id |
| 296 if (old_arg_name != new_arg_name | 310 if (old_arg_name != new_arg_name |
| 297 and (old_arg_name == 'arg' | 311 and (old_arg_name == 'arg' |
| 298 or old_arg_name.endswith('Arg') | 312 or old_arg_name.endswith('Arg') |
| 299 or import_options.rename_operation_arguments_on_merge)): | 313 or import_options.rename_operation_arguments_on_merge)): |
| 300 old_node.arguments[i].id = new_arg_name | 314 old_node.arguments[i].id = new_arg_name |
| 301 changed = True | 315 changed = True |
| 302 # Maybe merge annotations: | 316 # Maybe merge annotations: |
| 303 if (isinstance(old_node, IDLAttribute) or | 317 if (isinstance(old_node, IDLAttribute) or |
| 304 isinstance(old_node, IDLOperation)): | 318 isinstance(old_node, IDLOperation)): |
| 305 for (name, value) in new_node.ext_attrs.items(): | 319 if self._merge_ext_attrs(old_node.ext_attrs, new_node.ext_attrs): |
| 306 if name in old_node.ext_attrs and old_node.ext_attrs[name] == value: | 320 changed = True |
| 307 pass # Identical | |
| 308 else: | |
| 309 old_node.ext_attrs[name] = value | |
| 310 changed = True | |
| 311 | 321 |
| 312 # Remove annotations on obsolete items from the same source | 322 # Remove annotations on obsolete items from the same source |
| 313 if import_options.obsolete_old_declarations: | 323 if import_options.obsolete_old_declarations: |
| 314 for (sig, old_node) in old_signatures_map.items(): | 324 for (sig, old_node) in old_signatures_map.items(): |
| 315 if (source in old_node.annotations | 325 if (source in old_node.annotations |
| 316 and sig not in new_signatures_map): | 326 and sig not in new_signatures_map): |
| 317 _logger.warn('%s not available in %s anymore' % | 327 _logger.warn('%s not available in %s anymore' % |
| 318 (sig, source)) | 328 (sig, source)) |
| 319 del old_node.annotations[source] | 329 del old_node.annotations[source] |
| 320 changed = True | 330 changed = True |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 # Smartly merge various declarations: | 362 # Smartly merge various declarations: |
| 353 if merge_list('parents'): | 363 if merge_list('parents'): |
| 354 changed = True | 364 changed = True |
| 355 if merge_list('constants'): | 365 if merge_list('constants'): |
| 356 changed = True | 366 changed = True |
| 357 if merge_list('attributes'): | 367 if merge_list('attributes'): |
| 358 changed = True | 368 changed = True |
| 359 if merge_list('operations'): | 369 if merge_list('operations'): |
| 360 changed = True | 370 changed = True |
| 361 | 371 |
| 372 if self._merge_ext_attrs(old_interface.ext_attrs, new_interface.ext_attrs): |
| 373 changed = True |
| 374 |
| 362 # Snippets are just concatentated: | 375 # Snippets are just concatentated: |
| 363 if new_interface.snippets: | 376 if new_interface.snippets: |
| 364 old_interface.snippets.extend( | 377 old_interface.snippets.extend( |
| 365 copy.deepcopy(new_interface.snippets)) | 378 copy.deepcopy(new_interface.snippets)) |
| 366 changed = True | 379 changed = True |
| 367 | 380 |
| 368 _logger.info('merged interface %s (changed=%s, supplemental=%s)' % | 381 _logger.info('merged interface %s (changed=%s, supplemental=%s)' % |
| 369 (old_interface.id, changed, new_interface.is_supplemental)) | 382 (old_interface.id, changed, new_interface.is_supplemental)) |
| 370 | 383 |
| 371 return changed | 384 return changed |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 for name, value in annotation.items(): | 551 for name, value in annotation.items(): |
| 539 if (name in top_level_annotation | 552 if (name in top_level_annotation |
| 540 and value == top_level_annotation[name]): | 553 and value == top_level_annotation[name]): |
| 541 del annotation[name] | 554 del annotation[name] |
| 542 | 555 |
| 543 map(normalize, interface.parents) | 556 map(normalize, interface.parents) |
| 544 map(normalize, interface.constants) | 557 map(normalize, interface.constants) |
| 545 map(normalize, interface.attributes) | 558 map(normalize, interface.attributes) |
| 546 map(normalize, interface.operations) | 559 map(normalize, interface.operations) |
| 547 map(normalize, interface.snippets) | 560 map(normalize, interface.snippets) |
| OLD | NEW |