OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import sys | 6 import sys |
7 import string | 7 import string |
8 import json | 8 import json |
9 | 9 |
10 blink_protocol_path = sys.argv[1] | 10 blink_protocol_path = sys.argv[1] |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 item_raw_type = items_map["raw_type"], | 561 item_raw_type = items_map["raw_type"], |
562 item_pass = items_map["pass_template"].substitute(name="item", opt=""), | 562 item_pass = items_map["pass_template"].substitute(name="item", opt=""), |
563 ItemType = items_map["Type"]) | 563 ItemType = items_map["Type"]) |
564 mapping["arg_out"] = "&out_%s" % mapping["param"] | 564 mapping["arg_out"] = "&out_%s" % mapping["param"] |
565 | 565 |
566 def ResolveObject(json, mapping): | 566 def ResolveObject(json, mapping): |
567 mapping["Type"] = "Dictionary" | 567 mapping["Type"] = "Dictionary" |
568 mapping["storage_type"] = "scoped_ptr<base::DictionaryValue>" | 568 mapping["storage_type"] = "scoped_ptr<base::DictionaryValue>" |
569 mapping["raw_type"] = "base::DictionaryValue*" | 569 mapping["raw_type"] = "base::DictionaryValue*" |
570 mapping["pass_template"] = tmpl_object_pass | 570 mapping["pass_template"] = tmpl_object_pass |
571 mapping["init"] = " = nullptr" | |
572 if "properties" in json: | 571 if "properties" in json: |
573 if not "declared_name" in mapping: | 572 if not "declared_name" in mapping: |
574 mapping["declared_name"] = ("%s%s" % | 573 mapping["declared_name"] = ("%s%s" % |
575 (mapping["Command"], Capitalize(mapping["proto_param"]))) | 574 (mapping["Command"], Capitalize(mapping["proto_param"]))) |
576 mapping["param_type"] = ("scoped_refptr<%s>" % | 575 mapping["param_type"] = ("scoped_refptr<%s>" % |
577 tmpl_typename.substitute(mapping)) | 576 tmpl_typename.substitute(mapping)) |
578 DeclareStruct(json["properties"], mapping) | 577 DeclareStruct(json["properties"], mapping) |
579 else: | 578 else: |
580 mapping["param_type"] = ("scoped_refptr<%s>" % | 579 mapping["param_type"] = ("scoped_refptr<%s>" % |
581 tmpl_typename.substitute(mapping)) | 580 tmpl_typename.substitute(mapping)) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 output_h_file.close() | 796 output_h_file.close() |
798 | 797 |
799 output_cc_file.write(template_cc.substitute({}, | 798 output_cc_file.write(template_cc.substitute({}, |
800 major = blink_protocol["version"]["major"], | 799 major = blink_protocol["version"]["major"], |
801 minor = blink_protocol["version"]["minor"], | 800 minor = blink_protocol["version"]["minor"], |
802 includes = "".join(sorted(includes)), | 801 includes = "".join(sorted(includes)), |
803 fields_init = ",\n ".join(fields_init), | 802 fields_init = ",\n ".join(fields_init), |
804 methods = "\n".join(handler_method_impls), | 803 methods = "\n".join(handler_method_impls), |
805 types = "\n".join(type_impls))) | 804 types = "\n".join(type_impls))) |
806 output_cc_file.close() | 805 output_cc_file.close() |
OLD | NEW |