Chromium Code Reviews| Index: third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py |
| diff --git a/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py b/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py |
| index 57bd6cea47911adae46fbe1d9a00ff449bff0395..e328867c20b92250faf2d8926e4640f4c62e2fc5 100644 |
| --- a/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py |
| +++ b/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py |
| @@ -88,6 +88,30 @@ def output_file(file_name): |
| return open(file_name, "w") |
| +def topsort_domains(): |
| + domains = {} |
| + for domain in json_api["domains"]: |
| + domains[domain["domain"]] = domain |
| + |
| + processed = set() |
| + result = [] |
| + |
| + def process(name): |
| + if name in processed: |
| + return |
| + domain = domains[name] |
| + deps = [] |
| + if "depends" in domain: |
|
dgozman
2016/05/27 05:20:48
I think we should either infer this from type usag
|
| + for dep in domain["depends"]: |
| + process(dep) |
| + result.append(domain) |
| + processed.add(name) |
| + |
| + for domain in json_api["domains"]: |
| + process(domain["domain"]) |
| + json_api["domains"] = result |
| + |
| + |
| def patch_full_qualified_refs(): |
| def patch_full_qualified_refs_in_domain(json, domain_name): |
| if isinstance(json, list): |
| @@ -239,6 +263,7 @@ def create_type_definitions(): |
| else: |
| type_definitions[domain["domain"] + "." + type["id"]] = create_primitive_type_definition(type["type"]) |
| +topsort_domains() |
| patch_full_qualified_refs() |
| create_type_definitions() |
| @@ -305,7 +330,4 @@ def generate(class_name): |
| jinja_env = initialize_jinja_env(output_dirname) |
| -generate("Backend") |
| -generate("Dispatcher") |
| -generate("Frontend") |
| generate("TypeBuilder") |