| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os.path | 5 import os.path |
| 6 import sys | 6 import sys |
| 7 import string | 7 import string |
| 8 import optparse | 8 import optparse |
| 9 import re | 9 import re |
| 10 try: | 10 try: |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 continue | 104 continue |
| 105 if json["$ref"].find(".") == -1: | 105 if json["$ref"].find(".") == -1: |
| 106 json["$ref"] = domain_name + "." + json["$ref"] | 106 json["$ref"] = domain_name + "." + json["$ref"] |
| 107 | 107 |
| 108 for domain in json_api["domains"]: | 108 for domain in json_api["domains"]: |
| 109 patch_full_qualified_refs_in_domain(domain, domain["domain"]) | 109 patch_full_qualified_refs_in_domain(domain, domain["domain"]) |
| 110 | 110 |
| 111 | 111 |
| 112 def create_user_type_definition(domain_name, type): | 112 def create_user_type_definition(domain_name, type): |
| 113 return { | 113 return { |
| 114 "return_type": "PassOwnPtr<protocol::%s::%s>" % (domain_name, type["id"]
), | 114 "return_type": "std::unique_ptr<protocol::%s::%s>" % (domain_name, type[
"id"]), |
| 115 "pass_type": "PassOwnPtr<protocol::%s::%s>" % (domain_name, type["id"]), | 115 "pass_type": "std::unique_ptr<protocol::%s::%s>" % (domain_name, type["i
d"]), |
| 116 "to_raw_type": "%s.get()", | 116 "to_raw_type": "%s.get()", |
| 117 "to_pass_type": "std::move(%s)", | 117 "to_pass_type": "std::move(%s)", |
| 118 "to_rvalue": "std::move(%s)", | 118 "to_rvalue": "std::move(%s)", |
| 119 "type": "OwnPtr<protocol::%s::%s>" % (domain_name, type["id"]), | 119 "type": "std::unique_ptr<protocol::%s::%s>" % (domain_name, type["id"]), |
| 120 "raw_type": "protocol::%s::%s" % (domain_name, type["id"]), | 120 "raw_type": "protocol::%s::%s" % (domain_name, type["id"]), |
| 121 "raw_pass_type": "protocol::%s::%s*" % (domain_name, type["id"]), | 121 "raw_pass_type": "protocol::%s::%s*" % (domain_name, type["id"]), |
| 122 "raw_return_type": "protocol::%s::%s*" % (domain_name, type["id"]), | 122 "raw_return_type": "protocol::%s::%s*" % (domain_name, type["id"]), |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 def create_object_type_definition(): | 126 def create_object_type_definition(): |
| 127 return { | 127 return { |
| 128 "return_type": "PassOwnPtr<protocol::DictionaryValue>", | 128 "return_type": "std::unique_ptr<protocol::DictionaryValue>", |
| 129 "pass_type": "PassOwnPtr<protocol::DictionaryValue>", | 129 "pass_type": "std::unique_ptr<protocol::DictionaryValue>", |
| 130 "to_raw_type": "%s.get()", | 130 "to_raw_type": "%s.get()", |
| 131 "to_pass_type": "std::move(%s)", | 131 "to_pass_type": "std::move(%s)", |
| 132 "to_rvalue": "std::move(%s)", | 132 "to_rvalue": "std::move(%s)", |
| 133 "type": "OwnPtr<protocol::DictionaryValue>", | 133 "type": "std::unique_ptr<protocol::DictionaryValue>", |
| 134 "raw_type": "protocol::DictionaryValue", | 134 "raw_type": "protocol::DictionaryValue", |
| 135 "raw_pass_type": "protocol::DictionaryValue*", | 135 "raw_pass_type": "protocol::DictionaryValue*", |
| 136 "raw_return_type": "protocol::DictionaryValue*", | 136 "raw_return_type": "protocol::DictionaryValue*", |
| 137 } | 137 } |
| 138 | 138 |
| 139 | 139 |
| 140 def create_any_type_definition(): | 140 def create_any_type_definition(): |
| 141 return { | 141 return { |
| 142 "return_type": "PassOwnPtr<protocol::Value>", | 142 "return_type": "std::unique_ptr<protocol::Value>", |
| 143 "pass_type": "PassOwnPtr<protocol::Value>", | 143 "pass_type": "std::unique_ptr<protocol::Value>", |
| 144 "to_raw_type": "%s.get()", | 144 "to_raw_type": "%s.get()", |
| 145 "to_pass_type": "std::move(%s)", | 145 "to_pass_type": "std::move(%s)", |
| 146 "to_rvalue": "std::move(%s)", | 146 "to_rvalue": "std::move(%s)", |
| 147 "type": "OwnPtr<protocol::Value>", | 147 "type": "std::unique_ptr<protocol::Value>", |
| 148 "raw_type": "protocol::Value", | 148 "raw_type": "protocol::Value", |
| 149 "raw_pass_type": "protocol::Value*", | 149 "raw_pass_type": "protocol::Value*", |
| 150 "raw_return_type": "protocol::Value*", | 150 "raw_return_type": "protocol::Value*", |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 def create_string_type_definition(domain): | 154 def create_string_type_definition(domain): |
| 155 if domain in ["Runtime", "Debugger", "Profiler", "HeapProfiler"]: | 155 if domain in ["Runtime", "Debugger", "Profiler", "HeapProfiler"]: |
| 156 return { | 156 return { |
| 157 "return_type": "String16", | 157 "return_type": "String16", |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 type_definitions = {} | 203 type_definitions = {} |
| 204 type_definitions["number"] = create_primitive_type_definition("number") | 204 type_definitions["number"] = create_primitive_type_definition("number") |
| 205 type_definitions["integer"] = create_primitive_type_definition("integer") | 205 type_definitions["integer"] = create_primitive_type_definition("integer") |
| 206 type_definitions["boolean"] = create_primitive_type_definition("boolean") | 206 type_definitions["boolean"] = create_primitive_type_definition("boolean") |
| 207 type_definitions["object"] = create_object_type_definition() | 207 type_definitions["object"] = create_object_type_definition() |
| 208 type_definitions["any"] = create_any_type_definition() | 208 type_definitions["any"] = create_any_type_definition() |
| 209 | 209 |
| 210 def wrap_array_definition(type): | 210 def wrap_array_definition(type): |
| 211 return { | 211 return { |
| 212 "return_type": "PassOwnPtr<protocol::Array<%s>>" % type["raw_type"], | 212 "return_type": "std::unique_ptr<protocol::Array<%s>>" % type["raw_type"]
, |
| 213 "pass_type": "PassOwnPtr<protocol::Array<%s>>" % type["raw_type"], | 213 "pass_type": "std::unique_ptr<protocol::Array<%s>>" % type["raw_type"], |
| 214 "to_raw_type": "%s.get()", | 214 "to_raw_type": "%s.get()", |
| 215 "to_pass_type": "std::move(%s)", | 215 "to_pass_type": "std::move(%s)", |
| 216 "to_rvalue": "std::move(%s)", | 216 "to_rvalue": "std::move(%s)", |
| 217 "type": "OwnPtr<protocol::Array<%s>>" % type["raw_type"], | 217 "type": "std::unique_ptr<protocol::Array<%s>>" % type["raw_type"], |
| 218 "raw_type": "protocol::Array<%s>" % type["raw_type"], | 218 "raw_type": "protocol::Array<%s>" % type["raw_type"], |
| 219 "raw_pass_type": "protocol::Array<%s>*" % type["raw_type"], | 219 "raw_pass_type": "protocol::Array<%s>*" % type["raw_type"], |
| 220 "raw_return_type": "protocol::Array<%s>*" % type["raw_type"], | 220 "raw_return_type": "protocol::Array<%s>*" % type["raw_type"], |
| 221 "create_type": "adoptPtr(new protocol::Array<%s>())" % type["raw_type"], | 221 "create_type": "wrapUnique(new protocol::Array<%s>())" % type["raw_type"
], |
| 222 "out_type": "protocol::Array<%s>&" % type["raw_type"], | 222 "out_type": "protocol::Array<%s>&" % type["raw_type"], |
| 223 } | 223 } |
| 224 | 224 |
| 225 | 225 |
| 226 def create_type_definitions(): | 226 def create_type_definitions(): |
| 227 for domain in json_api["domains"]: | 227 for domain in json_api["domains"]: |
| 228 type_definitions[domain["domain"] + ".string"] = create_string_type_defi
nition(domain["domain"]) | 228 type_definitions[domain["domain"] + ".string"] = create_string_type_defi
nition(domain["domain"]) |
| 229 if not ("types" in domain): | 229 if not ("types" in domain): |
| 230 continue | 230 continue |
| 231 for type in domain["types"]: | 231 for type in domain["types"]: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 cpp_file.write(cpp_template.render(template_context)) | 302 cpp_file.write(cpp_template.render(template_context)) |
| 303 h_file.close() | 303 h_file.close() |
| 304 cpp_file.close() | 304 cpp_file.close() |
| 305 | 305 |
| 306 | 306 |
| 307 jinja_env = initialize_jinja_env(output_dirname) | 307 jinja_env = initialize_jinja_env(output_dirname) |
| 308 generate("Backend") | 308 generate("Backend") |
| 309 generate("Dispatcher") | 309 generate("Dispatcher") |
| 310 generate("Frontend") | 310 generate("Frontend") |
| 311 generate("TypeBuilder") | 311 generate("TypeBuilder") |
| OLD | NEW |