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

Unified Diff: third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win compile Created 4 years, 4 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
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 985236821316c6d0f68bae9a790dd2a6bd7fc7b8..9fd74a73481b3f762d2331e8a5f09f4f23fa9c55 100644
--- a/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py
+++ b/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py
@@ -164,18 +164,18 @@ def calculate_exports(protocol):
protocol.json_api["has_exports"] = True
-def create_imported_type_definition(domain_name, type):
+def create_imported_type_definition(domain_name, type, imported_namespace):
# pylint: disable=W0622
return {
- "return_type": "std::unique_ptr<protocol::%s::API::%s>" % (domain_name, type["id"]),
- "pass_type": "std::unique_ptr<protocol::%s::API::%s>" % (domain_name, type["id"]),
+ "return_type": "std::unique_ptr<%s::%s::API::%s>" % (imported_namespace, domain_name, type["id"]),
+ "pass_type": "std::unique_ptr<%s::%s::API::%s>" % (imported_namespace, domain_name, type["id"]),
"to_raw_type": "%s.get()",
"to_pass_type": "std::move(%s)",
"to_rvalue": "std::move(%s)",
- "type": "std::unique_ptr<protocol::%s::API::%s>" % (domain_name, type["id"]),
- "raw_type": "protocol::%s::API::%s" % (domain_name, type["id"]),
- "raw_pass_type": "protocol::%s::API::%s*" % (domain_name, type["id"]),
- "raw_return_type": "protocol::%s::API::%s*" % (domain_name, type["id"]),
+ "type": "std::unique_ptr<%s::%s::API::%s>" % (imported_namespace, domain_name, type["id"]),
+ "raw_type": "%s::%s::API::%s" % (imported_namespace, domain_name, type["id"]),
+ "raw_pass_type": "%s::%s::API::%s*" % (imported_namespace, domain_name, type["id"]),
+ "raw_return_type": "%s::%s::API::%s*" % (imported_namespace, domain_name, type["id"]),
}
@@ -224,18 +224,18 @@ def create_any_type_definition():
}
-def create_string_type_definition(string_type):
+def create_string_type_definition():
# pylint: disable=W0622
return {
- "return_type": string_type,
- "pass_type": ("const %s&" % string_type),
+ "return_type": "String",
+ "pass_type": "const String&",
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
- "type": string_type,
- "raw_type": string_type,
- "raw_pass_type": ("const %s&" % string_type),
- "raw_return_type": string_type,
+ "type": "String",
+ "raw_type": "String",
+ "raw_pass_type": "const String&",
+ "raw_return_type": "String",
}
@@ -287,7 +287,7 @@ def wrap_array_definition(type):
}
-def create_type_definitions(protocol, string_type):
+def create_type_definitions(protocol, imported_namespace):
protocol.type_definitions = {}
protocol.type_definitions["number"] = create_primitive_type_definition("number")
protocol.type_definitions["integer"] = create_primitive_type_definition("integer")
@@ -295,20 +295,20 @@ def create_type_definitions(protocol, string_type):
protocol.type_definitions["object"] = create_object_type_definition()
protocol.type_definitions["any"] = create_any_type_definition()
for domain in protocol.json_api["domains"]:
- protocol.type_definitions[domain["domain"] + ".string"] = create_string_type_definition(string_type)
+ protocol.type_definitions[domain["domain"] + ".string"] = create_string_type_definition()
if not ("types" in domain):
continue
for type in domain["types"]:
type_name = domain["domain"] + "." + type["id"]
if type["type"] == "object" and domain["domain"] in protocol.imported_domains:
- protocol.type_definitions[type_name] = create_imported_type_definition(domain["domain"], type)
+ protocol.type_definitions[type_name] = create_imported_type_definition(domain["domain"], type, imported_namespace)
elif type["type"] == "object":
protocol.type_definitions[type_name] = create_user_type_definition(domain["domain"], type)
elif type["type"] == "array":
items_type = type["items"]["type"]
protocol.type_definitions[type_name] = wrap_array_definition(protocol.type_definitions[items_type])
elif type["type"] == domain["domain"] + ".string":
- protocol.type_definitions[type_name] = create_string_type_definition(string_type)
+ protocol.type_definitions[type_name] = create_string_type_definition()
else:
protocol.type_definitions[type_name] = create_primitive_type_definition(type["type"])
@@ -370,7 +370,7 @@ def main():
protocol.imported_domains = read_protocol_file(config.imported.path, protocol.json_api) if config.imported else []
patch_full_qualified_refs(protocol)
calculate_exports(protocol)
- create_type_definitions(protocol, config.string.class_name)
+ create_type_definitions(protocol, "::".join(config.imported.namespace) if config.imported else "")
if not config.exported:
for domain_json in protocol.json_api["domains"]:
@@ -429,25 +429,20 @@ def main():
# Note these should be sorted in the right order.
# TODO(dgozman): sort them programmatically based on commented includes.
lib_h_templates = [
- "Allocator_h.template",
- "Platform_h.template",
"Collections_h.template",
- "String16_h.template",
"ErrorSupport_h.template",
"Values_h.template",
"Object_h.template",
"ValueConversions_h.template",
"Maybe_h.template",
"Array_h.template",
- "FrontendChannel_h.template",
"BackendCallback_h.template",
"DispatcherBase_h.template",
"Parser_h.template",
]
lib_cpp_templates = [
- "InspectorProtocol_cpp.template",
- "String16_cpp.template",
+ "Protocol_cpp.template",
"ErrorSupport_cpp.template",
"Values_cpp.template",
"Object_cpp.template",
@@ -455,6 +450,12 @@ def main():
"Parser_cpp.template",
]
+ forward_h_templates = [
+ "Forward_h.template",
+ "Allocator_h.template",
+ "FrontendChannel_h.template",
+ ]
+
def generate_lib_file(file_name, template_files):
parts = []
for template_file in template_files:
@@ -463,8 +464,9 @@ def main():
parts.append(template.render(template_context))
outputs[file_name] = "\n\n".join(parts)
- generate_lib_file(os.path.join(config.lib.output, "InspectorProtocol.h"), lib_h_templates)
- generate_lib_file(os.path.join(config.lib.output, "InspectorProtocol.cpp"), lib_cpp_templates)
+ generate_lib_file(os.path.join(config.lib.output, "Forward.h"), forward_h_templates)
+ generate_lib_file(os.path.join(config.lib.output, "Protocol.h"), lib_h_templates)
+ generate_lib_file(os.path.join(config.lib.output, "Protocol.cpp"), lib_cpp_templates)
# Make gyp / make generatos happy, otherwise make rebuilds world.
inputs_ts = max(map(os.path.getmtime, inputs))

Powered by Google App Engine
This is Rietveld 408576698