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

Unified Diff: third_party/inspector_protocol/CodeGenerator.py

Issue 2475663004: [DevTools] Roll third_party/inspector_protocol to 3c6f5ff8ab6653b47cf226233d488701a527d761. (Closed)
Patch Set: Created 4 years, 1 month 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
Index: third_party/inspector_protocol/CodeGenerator.py
diff --git a/third_party/inspector_protocol/CodeGenerator.py b/third_party/inspector_protocol/CodeGenerator.py
index de1029e801fb876ebf45fe7e861fc85d03313e70..4eb06a65405a04024b0eba002db1efc64500afb1 100644
--- a/third_party/inspector_protocol/CodeGenerator.py
+++ b/third_party/inspector_protocol/CodeGenerator.py
@@ -82,6 +82,7 @@ def read_config():
".imported.package": False,
".protocol.export_macro": "",
".protocol.export_header": False,
+ ".protocol.options": False,
".exported": False,
".exported.export_macro": "",
".exported.export_header": False,
@@ -337,11 +338,51 @@ def join_arrays(dict, keys):
return result
-def has_disable(commands):
- for command in commands:
- if command["name"] == "disable" and (not ("handlers" in command) or "renderer" in command["handlers"]):
- return True
- return False
+def entity_options(protocol, config, domain, entity, entity_name):
+ def update(generate, async, rule, property, suffix):
+ if not hasattr(rule, property):
+ return generate, async
+ value = getattr(rule, property)
+ if value == "+" + suffix:
+ generate = True
+ if hasattr(rule, "async"):
+ async = getattr(rule, "async")
+ if value == "-" + suffix:
+ generate = False
+ return generate, async
+
+ if not config.protocol.options:
+ return (domain in protocol.generate_domain, False)
+
+ generate, async = False, False
+ for rule in config.protocol.options:
+ generate, async = update(generate, async, rule, "domain", domain)
+ generate, async = update(generate, async, rule, entity, domain + "." + entity_name)
+ return generate, async
+
+
+def generate_command(protocol, config, domain, command):
+ generate, _ = entity_options(protocol, config, domain, "command", command)
+ return generate
+
+
+def generate_event(protocol, config, domain, event):
+ generate, _ = entity_options(protocol, config, domain, "event", event)
+ return generate
+
+
+def is_async_command(protocol, config, domain, command):
+ _, async = entity_options(protocol, config, domain, "command", command)
+ return async
+
+
+def generate_disable(protocol, config, domain):
+ if "commands" not in domain:
+ return True
+ for command in domain["commands"]:
+ if command["name"] == "disable" and generate_command(protocol, config, domain["domain"], "disable"):
+ return False
+ return True
def format_include(header):
@@ -419,7 +460,10 @@ def main():
"join_arrays": join_arrays,
"resolve_type": functools.partial(resolve_type, protocol),
"type_definition": functools.partial(type_definition, protocol),
- "has_disable": has_disable,
+ "generate_command": functools.partial(generate_command, protocol, config),
+ "generate_event": functools.partial(generate_event, protocol, config),
+ "is_async_command": functools.partial(is_async_command, protocol, config),
+ "generate_disable": functools.partial(generate_disable, protocol, config),
"format_include": format_include
}

Powered by Google App Engine
This is Rietveld 408576698