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 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (promisified): | 153 if (promisified): |
154 output_file.write(" * @return {!Promise.<T>}\n") | 154 output_file.write(" * @return {!Promise.<T>}\n") |
155 output_file.write(" * @template T\n") | 155 output_file.write(" * @template T\n") |
156 params.append("opt_callback") | 156 params.append("opt_callback") |
157 | 157 |
158 output_file.write(" */\n") | 158 output_file.write(" */\n") |
159 output_file.write("Protocol.%sAgent.prototype.%s = function(%s)
{}\n" % (domain_name, command["name"], ", ".join(params))) | 159 output_file.write("Protocol.%sAgent.prototype.%s = function(%s)
{}\n" % (domain_name, command["name"], ", ".join(params))) |
160 output_file.write("/** @param {function(%s):void=} opt_callback
*/\n" % ", ".join(returns)) | 160 output_file.write("/** @param {function(%s):void=} opt_callback
*/\n" % ", ".join(returns)) |
161 output_file.write("Protocol.%sAgent.prototype.invoke_%s = functi
on(obj, opt_callback) {}\n" % (domain_name, command["name"])) | 161 output_file.write("Protocol.%sAgent.prototype.invoke_%s = functi
on(obj, opt_callback) {}\n" % (domain_name, command["name"])) |
162 | 162 |
163 output_file.write("\n\n\nvar %sAgent = {};\n" % domain_name) | 163 output_file.write("\n\n\nvar %sAgent = function(){};\n" % domain_name) |
164 | 164 |
165 if "types" in domain: | 165 if "types" in domain: |
166 for type in domain["types"]: | 166 for type in domain["types"]: |
167 if type["type"] == "object": | 167 if type["type"] == "object": |
168 typedef_args = [] | 168 typedef_args = [] |
169 if "properties" in type: | 169 if "properties" in type: |
170 for property in type["properties"]: | 170 for property in type["properties"]: |
171 suffix = "" | 171 suffix = "" |
172 if ("optional" in property): | 172 if ("optional" in property): |
173 suffix = "|undefined" | 173 suffix = "|undefined" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 if __name__ == "__main__": | 227 if __name__ == "__main__": |
228 import sys | 228 import sys |
229 import os.path | 229 import os.path |
230 program_name = os.path.basename(__file__) | 230 program_name = os.path.basename(__file__) |
231 if len(sys.argv) < 4 or sys.argv[1] != "-o": | 231 if len(sys.argv) < 4 or sys.argv[1] != "-o": |
232 sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE\n" % program_name) | 232 sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE\n" % program_name) |
233 exit(1) | 233 exit(1) |
234 output_path = sys.argv[2] | 234 output_path = sys.argv[2] |
235 input_path = sys.argv[3] | 235 input_path = sys.argv[3] |
236 generate_protocol_externs(output_path, input_path) | 236 generate_protocol_externs(output_path, input_path) |
OLD | NEW |