| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 for domain in json_api["domains"]: | 104 for domain in json_api["domains"]: |
| 105 patch_full_qualified_refs_in_domain(domain, domain["domain"]) | 105 patch_full_qualified_refs_in_domain(domain, domain["domain"]) |
| 106 | 106 |
| 107 | 107 |
| 108 def create_user_type_definition(domain_name, type): | 108 def create_user_type_definition(domain_name, type): |
| 109 return { | 109 return { |
| 110 "return_type": "PassOwnPtr<protocol::%s::%s>" % (domain_name, type["id"]
), | 110 "return_type": "PassOwnPtr<protocol::%s::%s>" % (domain_name, type["id"]
), |
| 111 "pass_type": "PassOwnPtr<protocol::%s::%s>" % (domain_name, type["id"]), | 111 "pass_type": "PassOwnPtr<protocol::%s::%s>" % (domain_name, type["id"]), |
| 112 "to_raw_type": "%s.get()", | 112 "to_raw_type": "%s.get()", |
| 113 "to_pass_type": "%s.release()", | 113 "to_pass_type": "std::move(%s)", |
| 114 "to_rvalue": "std::move(%s)", | 114 "to_rvalue": "std::move(%s)", |
| 115 "type": "OwnPtr<protocol::%s::%s>" % (domain_name, type["id"]), | 115 "type": "OwnPtr<protocol::%s::%s>" % (domain_name, type["id"]), |
| 116 "raw_type": "protocol::%s::%s" % (domain_name, type["id"]), | 116 "raw_type": "protocol::%s::%s" % (domain_name, type["id"]), |
| 117 "raw_pass_type": "protocol::%s::%s*" % (domain_name, type["id"]), | 117 "raw_pass_type": "protocol::%s::%s*" % (domain_name, type["id"]), |
| 118 "raw_return_type": "protocol::%s::%s*" % (domain_name, type["id"]), | 118 "raw_return_type": "protocol::%s::%s*" % (domain_name, type["id"]), |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 def create_object_type_definition(): | 122 def create_object_type_definition(): |
| 123 return { | 123 return { |
| 124 "return_type": "PassOwnPtr<protocol::DictionaryValue>", | 124 "return_type": "PassOwnPtr<protocol::DictionaryValue>", |
| 125 "pass_type": "PassOwnPtr<protocol::DictionaryValue>", | 125 "pass_type": "PassOwnPtr<protocol::DictionaryValue>", |
| 126 "to_raw_type": "%s.get()", | 126 "to_raw_type": "%s.get()", |
| 127 "to_pass_type": "%s.release()", | 127 "to_pass_type": "std::move(%s)", |
| 128 "to_rvalue": "std::move(%s)", | 128 "to_rvalue": "std::move(%s)", |
| 129 "type": "OwnPtr<protocol::DictionaryValue>", | 129 "type": "OwnPtr<protocol::DictionaryValue>", |
| 130 "raw_type": "protocol::DictionaryValue", | 130 "raw_type": "protocol::DictionaryValue", |
| 131 "raw_pass_type": "protocol::DictionaryValue*", | 131 "raw_pass_type": "protocol::DictionaryValue*", |
| 132 "raw_return_type": "protocol::DictionaryValue*", | 132 "raw_return_type": "protocol::DictionaryValue*", |
| 133 } | 133 } |
| 134 | 134 |
| 135 | 135 |
| 136 def create_any_type_definition(): | 136 def create_any_type_definition(): |
| 137 return { | 137 return { |
| 138 "return_type": "PassOwnPtr<protocol::Value>", | 138 "return_type": "PassOwnPtr<protocol::Value>", |
| 139 "pass_type": "PassOwnPtr<protocol::Value>", | 139 "pass_type": "PassOwnPtr<protocol::Value>", |
| 140 "to_raw_type": "%s.get()", | 140 "to_raw_type": "%s.get()", |
| 141 "to_pass_type": "%s.release()", | 141 "to_pass_type": "std::move(%s)", |
| 142 "to_rvalue": "std::move(%s)", | 142 "to_rvalue": "std::move(%s)", |
| 143 "type": "OwnPtr<protocol::Value>", | 143 "type": "OwnPtr<protocol::Value>", |
| 144 "raw_type": "protocol::Value", | 144 "raw_type": "protocol::Value", |
| 145 "raw_pass_type": "protocol::Value*", | 145 "raw_pass_type": "protocol::Value*", |
| 146 "raw_return_type": "protocol::Value*", | 146 "raw_return_type": "protocol::Value*", |
| 147 } | 147 } |
| 148 | 148 |
| 149 | 149 |
| 150 def create_string_type_definition(domain): | 150 def create_string_type_definition(domain): |
| 151 if domain in ["Runtime", "Debugger", "Profiler", "HeapProfiler"]: | 151 if domain in ["Runtime", "Debugger", "Profiler", "HeapProfiler"]: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 type_definitions["integer"] = create_primitive_type_definition("integer") | 201 type_definitions["integer"] = create_primitive_type_definition("integer") |
| 202 type_definitions["boolean"] = create_primitive_type_definition("boolean") | 202 type_definitions["boolean"] = create_primitive_type_definition("boolean") |
| 203 type_definitions["object"] = create_object_type_definition() | 203 type_definitions["object"] = create_object_type_definition() |
| 204 type_definitions["any"] = create_any_type_definition() | 204 type_definitions["any"] = create_any_type_definition() |
| 205 | 205 |
| 206 def wrap_array_definition(type): | 206 def wrap_array_definition(type): |
| 207 return { | 207 return { |
| 208 "return_type": "PassOwnPtr<protocol::Array<%s>>" % type["raw_type"], | 208 "return_type": "PassOwnPtr<protocol::Array<%s>>" % type["raw_type"], |
| 209 "pass_type": "PassOwnPtr<protocol::Array<%s>>" % type["raw_type"], | 209 "pass_type": "PassOwnPtr<protocol::Array<%s>>" % type["raw_type"], |
| 210 "to_raw_type": "%s.get()", | 210 "to_raw_type": "%s.get()", |
| 211 "to_pass_type": "%s.release()", | 211 "to_pass_type": "std::move(%s)", |
| 212 "to_rvalue": "std::move(%s)", | 212 "to_rvalue": "std::move(%s)", |
| 213 "type": "OwnPtr<protocol::Array<%s>>" % type["raw_type"], | 213 "type": "OwnPtr<protocol::Array<%s>>" % type["raw_type"], |
| 214 "raw_type": "protocol::Array<%s>" % type["raw_type"], | 214 "raw_type": "protocol::Array<%s>" % type["raw_type"], |
| 215 "raw_pass_type": "protocol::Array<%s>*" % type["raw_type"], | 215 "raw_pass_type": "protocol::Array<%s>*" % type["raw_type"], |
| 216 "raw_return_type": "protocol::Array<%s>*" % type["raw_type"], | 216 "raw_return_type": "protocol::Array<%s>*" % type["raw_type"], |
| 217 "create_type": "adoptPtr(new protocol::Array<%s>())" % type["raw_type"], | 217 "create_type": "adoptPtr(new protocol::Array<%s>())" % type["raw_type"], |
| 218 "out_type": "protocol::Array<%s>&" % type["raw_type"], | 218 "out_type": "protocol::Array<%s>&" % type["raw_type"], |
| 219 } | 219 } |
| 220 | 220 |
| 221 | 221 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 cpp_file.write(cpp_template.render(template_context)) | 275 cpp_file.write(cpp_template.render(template_context)) |
| 276 h_file.close() | 276 h_file.close() |
| 277 cpp_file.close() | 277 cpp_file.close() |
| 278 | 278 |
| 279 | 279 |
| 280 jinja_env = initialize_jinja_env(output_dirname) | 280 jinja_env = initialize_jinja_env(output_dirname) |
| 281 generate("Backend") | 281 generate("Backend") |
| 282 generate("Dispatcher") | 282 generate("Dispatcher") |
| 283 generate("Frontend") | 283 generate("Frontend") |
| 284 generate("TypeBuilder") | 284 generate("TypeBuilder") |
| OLD | NEW |