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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py

Issue 2044343002: DevTools: update V8Inspector to work with the new v8_inspector API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comment addressed Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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
8 import optparse 7 import optparse
9 import re
10 try: 8 try:
11 import json 9 import json
12 except ImportError: 10 except ImportError:
13 import simplejson as json 11 import simplejson as json
14 12
15 # Path handling for libraries and templates 13 # Path handling for libraries and templates
16 # Paths have to be normalized because Jinja uses the exact template path to 14 # Paths have to be normalized because Jinja uses the exact template path to
17 # determine the hash used in the cache filename, and we need a pre-caching step 15 # determine the hash used in the cache filename, and we need a pre-caching step
18 # to be concurrency-safe. Use absolute path because __file__ is absolute if 16 # to be concurrency-safe. Use absolute path because __file__ is absolute if
19 # module is imported, and relative if executed directly. 17 # module is imported, and relative if executed directly.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 "raw_return_type": string_type, 194 "raw_return_type": string_type,
197 } 195 }
198 196
199 197
200 def create_primitive_type_definition(type): 198 def create_primitive_type_definition(type):
201 typedefs = { 199 typedefs = {
202 "number": "double", 200 "number": "double",
203 "integer": "int", 201 "integer": "int",
204 "boolean": "bool" 202 "boolean": "bool"
205 } 203 }
204 defaults = {
205 "number": "0",
206 "integer": "0",
207 "boolean": "false"
208 }
206 jsontypes = { 209 jsontypes = {
207 "number": "TypeNumber", 210 "number": "TypeNumber",
208 "integer": "TypeNumber", 211 "integer": "TypeNumber",
209 "boolean": "TypeBoolean", 212 "boolean": "TypeBoolean",
210 } 213 }
211 return { 214 return {
212 "return_type": typedefs[type], 215 "return_type": typedefs[type],
213 "pass_type": typedefs[type], 216 "pass_type": typedefs[type],
214 "to_pass_type": "%s", 217 "to_pass_type": "%s",
215 "to_raw_type": "%s", 218 "to_raw_type": "%s",
216 "to_rvalue": "%s", 219 "to_rvalue": "%s",
217 "type": typedefs[type], 220 "type": typedefs[type],
218 "raw_type": typedefs[type], 221 "raw_type": typedefs[type],
219 "raw_pass_type": typedefs[type], 222 "raw_pass_type": typedefs[type],
220 "raw_return_type": typedefs[type], 223 "raw_return_type": typedefs[type],
224 "default_value": defaults[type]
221 } 225 }
222 226
227
223 type_definitions = {} 228 type_definitions = {}
224 type_definitions["number"] = create_primitive_type_definition("number") 229 type_definitions["number"] = create_primitive_type_definition("number")
225 type_definitions["integer"] = create_primitive_type_definition("integer") 230 type_definitions["integer"] = create_primitive_type_definition("integer")
226 type_definitions["boolean"] = create_primitive_type_definition("boolean") 231 type_definitions["boolean"] = create_primitive_type_definition("boolean")
227 type_definitions["object"] = create_object_type_definition() 232 type_definitions["object"] = create_object_type_definition()
228 type_definitions["any"] = create_any_type_definition() 233 type_definitions["any"] = create_any_type_definition()
229 234
230 235
231 def wrap_array_definition(type): 236 def wrap_array_definition(type):
232 return { 237 return {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 cpp_file = output_file(cpp_file_name) 338 cpp_file = output_file(cpp_file_name)
334 h_file.write(h_template.render(template_context)) 339 h_file.write(h_template.render(template_context))
335 cpp_file.write(cpp_template.render(template_context)) 340 cpp_file.write(cpp_template.render(template_context))
336 h_file.close() 341 h_file.close()
337 cpp_file.close() 342 cpp_file.close()
338 343
339 344
340 for domain in json_api["domains"]: 345 for domain in json_api["domains"]:
341 if domain["domain"] in generate_domains: 346 if domain["domain"] in generate_domains:
342 generate(domain) 347 generate(domain)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698