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

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: 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 d6ab65e9535938315741066681d7adca768a12e8..91f8c6bea85c2d12627253605508152c450f3a61 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"])
@@ -368,7 +368,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"]:
@@ -430,7 +430,6 @@ def main():
"Allocator_h.template",
"Platform_h.template",
"Collections_h.template",
- "String16_h.template",
"ErrorSupport_h.template",
"Values_h.template",
"Object_h.template",
@@ -445,7 +444,6 @@ def main():
lib_cpp_templates = [
"InspectorProtocol_cpp.template",
- "String16_cpp.template",
"ErrorSupport_cpp.template",
"Values_cpp.template",
"Object_cpp.template",

Powered by Google App Engine
This is Rietveld 408576698