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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 import_options=DatabaseBuilderOptions()): | 472 import_options=DatabaseBuilderOptions()): |
473 """Parses, loads into memory and cleans up and IDL file""" | 473 """Parses, loads into memory and cleans up and IDL file""" |
474 idl_file = self._load_idl_file(file_path, import_options) | 474 idl_file = self._load_idl_file(file_path, import_options) |
475 | 475 |
476 self._strip_ext_attributes(idl_file) | 476 self._strip_ext_attributes(idl_file) |
477 self._resolve_type_defs(idl_file) | 477 self._resolve_type_defs(idl_file) |
478 self._rename_types(idl_file, import_options) | 478 self._rename_types(idl_file, import_options) |
479 | 479 |
480 for module in idl_file.modules: | 480 for module in idl_file.modules: |
481 for interface in module.interfaces: | 481 for interface in module.interfaces: |
482 if not self._is_node_enabled(interface, import_options.idl_defines): | |
483 _logger.info('skipping interface %s/%s (source=%s file=%s)' | |
484 % (module.id, interface.id, import_options.source, | |
485 file_path)) | |
486 continue | |
487 | |
482 _logger.info('importing interface %s/%s (source=%s file=%s)' | 488 _logger.info('importing interface %s/%s (source=%s file=%s)' |
483 % (module.id, interface.id, import_options.source, | 489 % (module.id, interface.id, import_options.source, |
484 file_path)) | 490 file_path)) |
485 self._imported_interfaces.append( | 491 interface.attributes = [attribute for attribute in interface.attributes |
486 (interface, module.id, import_options)) | 492 if self._is_node_enabled(attribute, import_options.idl_defines)] |
sra1
2012/02/03 20:53:56
you might define a local function and use filter:
podivilov
2012/02/06 12:09:40
Done.
| |
493 interface.operations = [operation for operation in interface.operations | |
494 if self._is_node_enabled(operation, import_options.idl_defines)] | |
495 self._imported_interfaces.append((interface, module.id, import_options)) | |
496 | |
487 for implStmt in module.implementsStatements: | 497 for implStmt in module.implementsStatements: |
488 self._impl_stmts.append((implStmt, import_options)) | 498 self._impl_stmts.append((implStmt, import_options)) |
489 | 499 |
500 def _is_node_enabled(self, node, idl_defines): | |
501 if not 'Conditional' in node.ext_attrs: | |
502 return True | |
503 | |
504 def enabled(condition): | |
505 return 'ENABLE_%s' % condition in idl_defines | |
506 | |
507 conditional = node.ext_attrs['Conditional'] | |
508 if conditional.find('&') != -1: | |
509 for condition in conditional.split('&'): | |
sra1
2012/02/03 20:53:56
can & and | occur together?
podivilov
2012/02/06 12:09:40
AFAIK they could not, and webkit code generators d
| |
510 if not enabled(condition): | |
511 return False | |
512 return True | |
513 | |
514 for condition in conditional.split('|'): | |
515 if enabled(condition): | |
516 return True | |
517 return False | |
518 | |
490 def import_idl_directory(self, directory_path, | 519 def import_idl_directory(self, directory_path, |
491 import_options=DatabaseBuilderOptions()): | 520 import_options=DatabaseBuilderOptions()): |
492 """Parses, loads into memory and cleans up all IDL files in a given | 521 """Parses, loads into memory and cleans up all IDL files in a given |
493 directory""" | 522 directory""" |
494 if not os.path.exists(directory_path): | 523 if not os.path.exists(directory_path): |
495 raise RuntimeError('directory not found: %s' % directory_path) | 524 raise RuntimeError('directory not found: %s' % directory_path) |
496 | 525 |
497 def visitor(arg, dir_name, names): | 526 def visitor(arg, dir_name, names): |
498 module = dir_name[len(directory_path) + 1:] | 527 module = dir_name[len(directory_path) + 1:] |
499 for name in names: | 528 for name in names: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 annotation = idl_node.annotations[source] | 594 annotation = idl_node.annotations[source] |
566 for name, value in annotation.items(): | 595 for name, value in annotation.items(): |
567 if (name in top_level_annotation | 596 if (name in top_level_annotation |
568 and value == top_level_annotation[name]): | 597 and value == top_level_annotation[name]): |
569 del annotation[name] | 598 del annotation[name] |
570 | 599 |
571 map(normalize, interface.parents) | 600 map(normalize, interface.parents) |
572 map(normalize, interface.constants) | 601 map(normalize, interface.constants) |
573 map(normalize, interface.attributes) | 602 map(normalize, interface.attributes) |
574 map(normalize, interface.operations) | 603 map(normalize, interface.operations) |
OLD | NEW |