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

Unified Diff: client/dom/scripts/databasebuilder.py

Issue 9323028: Support 'Conditional' idl attribute. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/dom/generated/wrapping_dom_externs.js ('k') | client/dom/wrapping_dom.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/databasebuilder.py
diff --git a/client/dom/scripts/databasebuilder.py b/client/dom/scripts/databasebuilder.py
index 89b4f253c180ea13b1b93c19b34dbcb6fd5588c4..bc9d99d2adb5435620322061d79c25267de93113 100755
--- a/client/dom/scripts/databasebuilder.py
+++ b/client/dom/scripts/databasebuilder.py
@@ -479,14 +479,43 @@ class DatabaseBuilder(object):
for module in idl_file.modules:
for interface in module.interfaces:
+ if not self._is_node_enabled(interface, import_options.idl_defines):
+ _logger.info('skipping interface %s/%s (source=%s file=%s)'
+ % (module.id, interface.id, import_options.source,
+ file_path))
+ continue
+
_logger.info('importing interface %s/%s (source=%s file=%s)'
% (module.id, interface.id, import_options.source,
file_path))
- self._imported_interfaces.append(
- (interface, module.id, import_options))
+ interface.attributes = [attribute for attribute in interface.attributes
+ 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.
+ interface.operations = [operation for operation in interface.operations
+ if self._is_node_enabled(operation, import_options.idl_defines)]
+ self._imported_interfaces.append((interface, module.id, import_options))
+
for implStmt in module.implementsStatements:
self._impl_stmts.append((implStmt, import_options))
+ def _is_node_enabled(self, node, idl_defines):
+ if not 'Conditional' in node.ext_attrs:
+ return True
+
+ def enabled(condition):
+ return 'ENABLE_%s' % condition in idl_defines
+
+ conditional = node.ext_attrs['Conditional']
+ if conditional.find('&') != -1:
+ 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
+ if not enabled(condition):
+ return False
+ return True
+
+ for condition in conditional.split('|'):
+ if enabled(condition):
+ return True
+ return False
+
def import_idl_directory(self, directory_path,
import_options=DatabaseBuilderOptions()):
"""Parses, loads into memory and cleans up all IDL files in a given
« no previous file with comments | « client/dom/generated/wrapping_dom_externs.js ('k') | client/dom/wrapping_dom.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698