| Index: third_party/WebKit/Source/devtools/scripts/generate_protocol_externs.py
|
| diff --git a/third_party/WebKit/Source/devtools/scripts/generate_protocol_externs.py b/third_party/WebKit/Source/devtools/scripts/generate_protocol_externs.py
|
| index fca2d6333f24a6ed1ecd3cacae55ec858e2bdabb..55a2a88a303eb87f1f25d8d96c10525d84a35659 100755
|
| --- a/third_party/WebKit/Source/devtools/scripts/generate_protocol_externs.py
|
| +++ b/third_party/WebKit/Source/devtools/scripts/generate_protocol_externs.py
|
| @@ -27,7 +27,12 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| +import os
|
| import re
|
| +try:
|
| + import json
|
| +except ImportError:
|
| + import simplejson as json
|
|
|
| type_traits = {
|
| "any": "*",
|
| @@ -88,13 +93,17 @@ def param_type(domain_name, param):
|
| return "!! Type not found: " + type_id
|
|
|
|
|
| -def generate_protocol_externs(output_path, input_path):
|
| - input_file = open(input_path, "r")
|
| +def load_schema(file, domains):
|
| + input_file = open(file, "r")
|
| json_string = input_file.read()
|
| - json_string = json_string.replace(": true", ": True")
|
| - json_string = json_string.replace(": false", ": False")
|
| - json_api = eval(json_string)["domains"]
|
| + parsed_json = json.loads(json_string)
|
| + domains.append(parsed_json["domains"])
|
|
|
| +
|
| +def generate_protocol_externs(output_path, file1, file2):
|
| + domains = []
|
| + load_schema(file1, domains)
|
| + load_schema(file2, domains)
|
| output_file = open(output_path, "w")
|
|
|
| output_file.write(
|
| @@ -106,14 +115,14 @@ var Protocol = {};
|
| Protocol.Error;
|
| """)
|
|
|
| - for domain in json_api:
|
| + for domain in domains:
|
| domain_name = domain["domain"]
|
| if "types" in domain:
|
| for type in domain["types"]:
|
| type_id = full_qualified_type_id(domain_name, type["id"])
|
| ref_types[type_id] = "%sAgent.%s" % (domain_name, type["id"])
|
|
|
| - for domain in json_api:
|
| + for domain in domains:
|
| domain_name = domain["domain"]
|
| promisified = domain_name in promisified_domains
|
|
|
| @@ -210,7 +219,7 @@ Protocol.Error;
|
| output_file.write("Protocol.Agents = function(agentsMap){this._agentsMap;};\n")
|
| output_file.write("/**\n * @param {string} domain\n * @param {!Object} dispatcher\n */\n")
|
| output_file.write("Protocol.Agents.prototype.registerDispatcher = function(domain, dispatcher){};\n")
|
| - for domain in json_api:
|
| + for domain in domains:
|
| domain_name = domain["domain"]
|
| uppercase_length = 0
|
| while uppercase_length < len(domain_name) and domain_name[uppercase_length].isupper():
|
|
|