OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 Google Inc. All rights reserved. | 2 # Copyright (c) 2011 Google Inc. All rights reserved. |
3 # Copyright (c) 2012 Intel Corporation. All rights reserved. | 3 # Copyright (c) 2012 Intel Corporation. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 30 matching lines...) Expand all Loading... |
41 import CodeGeneratorInspectorStrings | 41 import CodeGeneratorInspectorStrings |
42 | 42 |
43 # Manually-filled map of type name replacements. | 43 # Manually-filled map of type name replacements. |
44 TYPE_NAME_FIX_MAP = { | 44 TYPE_NAME_FIX_MAP = { |
45 "RGBA": "Rgba", # RGBA is reported to be conflicting with a define name in
Windows CE. | 45 "RGBA": "Rgba", # RGBA is reported to be conflicting with a define name in
Windows CE. |
46 "": "Empty", | 46 "": "Empty", |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.Proper
tyDescriptor", "Runtime.InternalPropertyDescriptor", | 50 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.Proper
tyDescriptor", "Runtime.InternalPropertyDescriptor", |
51 "Debugger.FunctionDetails", "Debugger.C
allFrame", | 51 "Debugger.FunctionDetails", "Debugger.C
allFrame", "Debugger.Location", |
52 "Canvas.TraceLog", "Canvas.ResourceInfo
", "Canvas.ResourceState", | 52 "Canvas.TraceLog", "Canvas.ResourceStat
e", |
53 # This should be a temporary hack. Time
lineEvent should be created via generated C++ API. | 53 # This should be a temporary hack. Time
lineEvent should be created via generated C++ API. |
54 "Timeline.TimelineEvent"]) | 54 "Timeline.TimelineEvent"]) |
55 | 55 |
56 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset(["Timeline.TimelineEvent", | 56 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset(["Timeline.TimelineEvent", |
57 # InspectorStyleSheet not only creat
es this property but wants to read it and modify it. | 57 # InspectorStyleSheet not only creat
es this property but wants to read it and modify it. |
58 "CSS.CSSProperty", | 58 "CSS.CSSProperty", |
59 # InspectorResourceAgent needs to up
date mime-type. | 59 # InspectorResourceAgent needs to up
date mime-type. |
60 "Network.Response"]) | 60 "Network.Response"]) |
61 | 61 |
62 EXACTLY_INT_SUPPORTED = False | 62 EXACTLY_INT_SUPPORTED = False |
63 | 63 |
64 cmdline_parser = optparse.OptionParser() | 64 cmdline_parser = optparse.OptionParser() |
65 cmdline_parser.add_option("--output_h_dir") | 65 cmdline_parser.add_option("--output_dir") |
66 cmdline_parser.add_option("--output_cpp_dir") | |
67 | 66 |
68 try: | 67 try: |
69 arg_options, arg_values = cmdline_parser.parse_args() | 68 arg_options, arg_values = cmdline_parser.parse_args() |
70 if (len(arg_values) != 1): | 69 if (len(arg_values) != 1): |
71 raise Exception("Exactly one plain argument expected (found %s)" % len(a
rg_values)) | 70 raise Exception("Exactly one plain argument expected (found %s)" % len(a
rg_values)) |
72 input_json_filename = arg_values[0] | 71 input_json_filename = arg_values[0] |
73 output_header_dirname = arg_options.output_h_dir | 72 output_dirname = arg_options.output_dir |
74 output_cpp_dirname = arg_options.output_cpp_dir | 73 if not output_dirname: |
75 if not output_header_dirname: | 74 raise Exception("Output directory must be specified") |
76 raise Exception("Output .h directory must be specified") | |
77 if not output_cpp_dirname: | |
78 raise Exception("Output .cpp directory must be specified") | |
79 except Exception: | 75 except Exception: |
80 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html | 76 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html |
81 exc = sys.exc_info()[1] | 77 exc = sys.exc_info()[1] |
82 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) | 78 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) |
83 sys.stderr.write("Usage: <script> protocol.json --output_h_dir <output_heade
r_dir> --output_cpp_dir <output_cpp_dir>\n") | 79 sys.stderr.write("Usage: <script> --output_dir <output_dir> protocol.json\n"
) |
84 exit(1) | 80 exit(1) |
85 | 81 |
86 | 82 |
87 # FIXME: move this methods under Capitalizer class below and remove duplications
. | 83 # FIXME: move this methods under Capitalizer class below and remove duplications
. |
88 def dash_to_camelcase(word): | 84 def dash_to_camelcase(word): |
89 return ''.join(x.capitalize() or '-' for x in word.split('-')) | 85 return ''.join(x.capitalize() or '-' for x in word.split('-')) |
90 | 86 |
91 | 87 |
92 def fix_camel_case(name): | 88 def fix_camel_case(name): |
93 refined = re.sub(r'-(\w)', lambda pat: pat.group(1).upper(), name) | 89 refined = re.sub(r'-(\w)', lambda pat: pat.group(1).upper(), name) |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 def output_file(file_name): | 2280 def output_file(file_name): |
2285 # For now, disable the incremental build optimisation in all cases. | 2281 # For now, disable the incremental build optimisation in all cases. |
2286 if False: | 2282 if False: |
2287 return SmartOutput(file_name) | 2283 return SmartOutput(file_name) |
2288 else: | 2284 else: |
2289 return open(file_name, "w") | 2285 return open(file_name, "w") |
2290 | 2286 |
2291 | 2287 |
2292 Generator.go() | 2288 Generator.go() |
2293 | 2289 |
2294 backend_h_file = output_file(output_header_dirname + "/InspectorBackendDispatche
r.h") | 2290 backend_h_file = output_file(output_dirname + "/InspectorBackendDispatcher.h") |
2295 backend_cpp_file = output_file(output_cpp_dirname + "/InspectorBackendDispatcher
.cpp") | 2291 backend_cpp_file = output_file(output_dirname + "/InspectorBackendDispatcher.cpp
") |
2296 | 2292 |
2297 frontend_h_file = output_file(output_header_dirname + "/InspectorFrontend.h") | 2293 frontend_h_file = output_file(output_dirname + "/InspectorFrontend.h") |
2298 frontend_cpp_file = output_file(output_cpp_dirname + "/InspectorFrontend.cpp") | 2294 frontend_cpp_file = output_file(output_dirname + "/InspectorFrontend.cpp") |
2299 | 2295 |
2300 typebuilder_h_file = output_file(output_header_dirname + "/InspectorTypeBuilder.
h") | 2296 typebuilder_h_file = output_file(output_dirname + "/InspectorTypeBuilder.h") |
2301 typebuilder_cpp_file = output_file(output_cpp_dirname + "/InspectorTypeBuilder.c
pp") | 2297 typebuilder_cpp_file = output_file(output_dirname + "/InspectorTypeBuilder.cpp") |
2302 | 2298 |
2303 | 2299 |
2304 backend_h_file.write(Templates.backend_h.substitute(None, | 2300 backend_h_file.write(Templates.backend_h.substitute(None, |
2305 virtualSetters="\n".join(Generator.backend_virtual_setters_list), | 2301 virtualSetters="\n".join(Generator.backend_virtual_setters_list), |
2306 agentInterfaces="".join(flatten_list(Generator.backend_agent_interface_list)
), | 2302 agentInterfaces="".join(flatten_list(Generator.backend_agent_interface_list)
), |
2307 methodNamesEnumContent="\n".join(Generator.method_name_enum_list))) | 2303 methodNamesEnumContent="\n".join(Generator.method_name_enum_list))) |
2308 | 2304 |
2309 backend_cpp_file.write(Templates.backend_cpp.substitute(None, | 2305 backend_cpp_file.write(Templates.backend_cpp.substitute(None, |
2310 constructorInit="\n".join(Generator.backend_constructor_init_list), | 2306 constructorInit="\n".join(Generator.backend_constructor_init_list), |
2311 setters="\n".join(Generator.backend_setters_list), | 2307 setters="\n".join(Generator.backend_setters_list), |
(...skipping 23 matching lines...) Expand all Loading... |
2335 validatorIfdefName=VALIDATOR_IFDEF_NAME)) | 2331 validatorIfdefName=VALIDATOR_IFDEF_NAME)) |
2336 | 2332 |
2337 backend_h_file.close() | 2333 backend_h_file.close() |
2338 backend_cpp_file.close() | 2334 backend_cpp_file.close() |
2339 | 2335 |
2340 frontend_h_file.close() | 2336 frontend_h_file.close() |
2341 frontend_cpp_file.close() | 2337 frontend_cpp_file.close() |
2342 | 2338 |
2343 typebuilder_h_file.close() | 2339 typebuilder_h_file.close() |
2344 typebuilder_cpp_file.close() | 2340 typebuilder_cpp_file.close() |
OLD | NEW |