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

Side by Side Diff: core/inspector/CodeGeneratorInspector.py

Issue 1660113002: Updated to Chrome 45 (2454) moved from SVN to git. Base URL: https://github.com/dart-lang/webcore.git@roll_45
Patch Set: Created 4 years, 10 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
« no previous file with comments | « core/input/InputDeviceInit.idl ('k') | core/inspector/CodeGeneratorInspectorStrings.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ollectionEntry", "Debugger.CallFrame", "Debugger.Location", 51 "Debugger.FunctionDetails", "Debugger.G eneratorObjectDetails", "Debugger.CollectionEntry", "Debugger.CallFrame", "Debug ger.Location"])
52 "Canvas.TraceLog", "Canvas.ResourceStat e"])
53 52
54 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([ 53 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([
55 # InspectorStyleSheet not only creat es this property but wants to read it and modify it. 54 # InspectorStyleSheet not only creat es this property but wants to read it and modify it.
56 "CSS.CSSProperty", 55 "CSS.CSSProperty",
57 # InspectorResourceAgent needs to up date mime-type. 56 # InspectorResourceAgent needs to up date mime-type.
58 "Network.Response"]) 57 "Network.Response"])
59 58
60 cmdline_parser = optparse.OptionParser() 59 cmdline_parser = optparse.OptionParser()
61 cmdline_parser.add_option("--output_dir") 60 cmdline_parser.add_option("--output_dir")
62 61
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 Capitalizer.lower_camel_case_to_upper (prop_name), 998 Capitalizer.lower_camel_case_to_upper (prop_name),
1000 param_type_binding.get_type_model().g et_input_param_type_text(), 999 param_type_binding.get_type_model().g et_input_param_type_text(),
1001 state_enum_items[pos], prop_name, 1000 state_enum_items[pos], prop_name,
1002 param_raw_type.get_setter_name(), pro p_name, 1001 param_raw_type.get_setter_name(), pro p_name,
1003 format_setter_value_expression(param_ type_binding, "value"), 1002 format_setter_value_expression(param_ type_binding, "value"),
1004 state_enum_items[pos])) 1003 state_enum_items[pos]))
1005 1004
1006 pos += 1 1005 pos += 1
1007 1006
1008 writer.newline_multiline(CodeGeneratorInspectorS trings.class_binding_builder_part_3 1007 writer.newline_multiline(CodeGeneratorInspectorS trings.class_binding_builder_part_3
1009 % (class_name, class_na me, class_name, class_name, class_name)) 1008 % (class_name, class_na me, class_name, class_name, class_name, class_name))
1010 1009
1011 writer.newline(" /*\n") 1010 writer.newline(" /*\n")
1012 writer.newline(" * Synthetic constructor:\n" ) 1011 writer.newline(" * Synthetic constructor:\n" )
1013 writer.newline(" * RefPtr<%s> result = %s::c reate()" % (class_name, class_name)) 1012 writer.newline(" * RefPtr<%s> result = %s::c reate()" % (class_name, class_name))
1014 for prop_data in resolve_data.main_properties: 1013 for prop_data in resolve_data.main_properties:
1015 writer.append_multiline("\n * .set%s (...)" % Capitalizer.lower_camel_case_to_upper(prop_data.p["name"])) 1014 writer.append_multiline("\n * .set%s (...)" % Capitalizer.lower_camel_case_to_upper(prop_data.p["name"]))
1016 writer.append_multiline(";\n */\n") 1015 writer.append_multiline(";\n */\n")
1017 1016
1018 writer.newline_multiline(CodeGeneratorInspectorS trings.class_binding_builder_part_4) 1017 writer.newline_multiline(CodeGeneratorInspectorS trings.class_binding_builder_part_4)
1019 1018
(...skipping 28 matching lines...) Expand all
1048 1047
1049 if class_binding_cls.need_user_runtime_cast_: 1048 if class_binding_cls.need_user_runtime_cast_:
1050 writer.newline(" static PassRefPtr<%s> ru ntimeCast(PassRefPtr<JSONValue> value)\n" % class_name) 1049 writer.newline(" static PassRefPtr<%s> ru ntimeCast(PassRefPtr<JSONValue> value)\n" % class_name)
1051 writer.newline(" {\n") 1050 writer.newline(" {\n")
1052 writer.newline(" RefPtr<JSONObject> o bject;\n") 1051 writer.newline(" RefPtr<JSONObject> o bject;\n")
1053 writer.newline(" bool castRes = value ->asObject(&object);\n") 1052 writer.newline(" bool castRes = value ->asObject(&object);\n")
1054 writer.newline(" ASSERT_UNUSED(castRe s, castRes);\n") 1053 writer.newline(" ASSERT_UNUSED(castRe s, castRes);\n")
1055 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 1054 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
1056 writer.newline(" assertCorrectValue(o bject.get());\n") 1055 writer.newline(" assertCorrectValue(o bject.get());\n")
1057 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 1056 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
1058 writer.newline(" COMPILE_ASSERT(sizeo f(%s) == sizeof(JSONObjectBase), type_cast_problem);\n" % class_name) 1057 writer.newline(" static_assert(sizeof (%s) == sizeof(JSONObjectBase), \"%s should be the same size as JSONObjectBase\" );\n" % (class_name, class_name))
1059 writer.newline(" return static_cast<% s*>(static_cast<JSONObjectBase*>(object.get()));\n" % class_name) 1058 writer.newline(" return static_cast<% s*>(static_cast<JSONObjectBase*>(object.get()));\n" % class_name)
1060 writer.newline(" }\n") 1059 writer.newline(" }\n")
1061 writer.append("\n") 1060 writer.append("\n")
1062 1061
1063 if class_binding_cls.need_internal_runtime_cast_ : 1062 if class_binding_cls.need_internal_runtime_cast_ :
1064 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME) 1063 writer.append("#if %s\n" % VALIDATOR_IFDEF_N AME)
1065 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n") 1064 writer.newline(" static void assertCorrec tValue(JSONValue* value);\n")
1066 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME) 1065 writer.append("#endif // %s\n" % VALIDATOR_ IFDEF_NAME)
1067 1066
1068 closed_field_set = (context_domain_name + ". " + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET 1067 closed_field_set = (context_domain_name + ". " + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 Generator.frontend_class_field_lines.append(" %s m_%s;\n" % (doma in_name, domain_name_lower)) 1640 Generator.frontend_class_field_lines.append(" %s m_%s;\n" % (doma in_name, domain_name_lower))
1642 if Generator.frontend_constructor_init_list: 1641 if Generator.frontend_constructor_init_list:
1643 Generator.frontend_constructor_init_list.append(" , ") 1642 Generator.frontend_constructor_init_list.append(" , ")
1644 Generator.frontend_constructor_init_list.append("m_%s(inspectorFront endChannel)\n" % domain_name_lower) 1643 Generator.frontend_constructor_init_list.append("m_%s(inspectorFront endChannel)\n" % domain_name_lower)
1645 Generator.frontend_domain_class_lines.append(Templates.frontend_doma in_class.substitute(None, 1644 Generator.frontend_domain_class_lines.append(Templates.frontend_doma in_class.substitute(None,
1646 domainClassName=domain_name, 1645 domainClassName=domain_name,
1647 domainFieldName=domain_name_lower, 1646 domainFieldName=domain_name_lower,
1648 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m ethod_declaration_lines)))) 1647 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m ethod_declaration_lines))))
1649 1648
1650 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_ name) + "CommandHandler" 1649 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_ name) + "CommandHandler"
1651 Generator.backend_agent_interface_list.append(" class %s {\n" % a gent_interface_name) 1650 Generator.backend_agent_interface_list.append(" class CORE_EXPORT %s {\n" % agent_interface_name)
1652 Generator.backend_agent_interface_list.append(" public:\n") 1651 Generator.backend_agent_interface_list.append(" public:\n")
1653 if "commands" in json_domain: 1652 if "commands" in json_domain:
1654 for json_command in json_domain["commands"]: 1653 for json_command in json_domain["commands"]:
1655 Generator.process_command(json_command, domain_name, agent_f ield_name, agent_interface_name) 1654 Generator.process_command(json_command, domain_name, agent_f ield_name, agent_interface_name)
1656 Generator.backend_agent_interface_list.append("\n protected:\n") 1655 Generator.backend_agent_interface_list.append("\n protected:\n")
1657 Generator.backend_agent_interface_list.append(" virtual ~%s() { }\n" % agent_interface_name) 1656 Generator.backend_agent_interface_list.append(" virtual ~%s() { }\n" % agent_interface_name)
1658 Generator.backend_agent_interface_list.append(" };\n\n") 1657 Generator.backend_agent_interface_list.append(" };\n\n")
1659 1658
1660 Generator.backend_constructor_init_list.append(" , m_%s(0)" % agent_field_name) 1659 Generator.backend_constructor_init_list.append(" , m_%s(0)" % agent_field_name)
1661 Generator.backend_virtual_setters_list.append(" virtual void regi sterAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name)) 1660 Generator.backend_virtual_setters_list.append(" virtual void regi sterAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 def process_command(json_command, domain_name, agent_field_name, agent_inter face_name): 1698 def process_command(json_command, domain_name, agent_field_name, agent_inter face_name):
1700 if (("handlers" in json_command) and (not ("renderer" in json_command["h andlers"]))): 1699 if (("handlers" in json_command) and (not ("renderer" in json_command["h andlers"]))):
1701 return 1700 return
1702 1701
1703 json_command_name = json_command["name"] 1702 json_command_name = json_command["name"]
1704 1703
1705 cmd_enum_name = "k%s_%sCmd" % (domain_name, json_command["name"]) 1704 cmd_enum_name = "k%s_%sCmd" % (domain_name, json_command["name"])
1706 1705
1707 Generator.method_name_enum_list.append(" %s," % cmd_enum_name) 1706 Generator.method_name_enum_list.append(" %s," % cmd_enum_name)
1708 Generator.method_handler_list.append(" &InspectorBackendDispa tcherImpl::%s_%s," % (domain_name, json_command_name)) 1707 Generator.method_handler_list.append(" &InspectorBackendDispa tcherImpl::%s_%s," % (domain_name, json_command_name))
1709 Generator.backend_method_declaration_list.append(" void %s_%s(long ca llId, JSONObject* requestMessageObject, JSONArray* protocolErrors);" % (domain_n ame, json_command_name)) 1708 Generator.backend_method_declaration_list.append(" void %s_%s(int cal lId, JSONObject* requestMessageObject, JSONArray* protocolErrors);" % (domain_na me, json_command_name))
1710 1709
1711 backend_agent_interface_list = [] if "redirect" in json_command else Gen erator.backend_agent_interface_list 1710 backend_agent_interface_list = [] if "redirect" in json_command else Gen erator.backend_agent_interface_list
1712 1711
1713 ad_hoc_type_output = [] 1712 ad_hoc_type_output = []
1714 backend_agent_interface_list.append(ad_hoc_type_output) 1713 backend_agent_interface_list.append(ad_hoc_type_output)
1715 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") 1714 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ")
1716 1715
1717 backend_agent_interface_list.append(" virtual void %s(ErrorString *" % json_command_name) 1716 backend_agent_interface_list.append(" virtual void %s(ErrorString *" % json_command_name)
1718 1717
1719 method_in_code = "" 1718 method_in_code = ""
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 decl_parameter_list = [] 1780 decl_parameter_list = []
1782 Generator.generate_send_method(json_command.get("returns"), json_com mand_name, domain_name, ad_hoc_type_writer, 1781 Generator.generate_send_method(json_command.get("returns"), json_com mand_name, domain_name, ad_hoc_type_writer,
1783 decl_parameter_list, 1782 decl_parameter_list,
1784 Generator.CallbackMethodStructTemplat e, 1783 Generator.CallbackMethodStructTemplat e,
1785 Generator.backend_method_implementati on_list, Templates.callback_main_methods, 1784 Generator.backend_method_implementati on_list, Templates.callback_main_methods,
1786 {"callbackName": callback_name, "agen tName": agent_interface_name}) 1785 {"callbackName": callback_name, "agen tName": agent_interface_name})
1787 1786
1788 callback_writer.newline("class " + callback_name + " : public Callba ckBase {\n") 1787 callback_writer.newline("class " + callback_name + " : public Callba ckBase {\n")
1789 callback_writer.newline("public:\n") 1788 callback_writer.newline("public:\n")
1790 callback_writer.newline(" " + callback_name + "(PassRefPtrWillBeR awPtr<InspectorBackendDispatcherImpl>, int id);\n") 1789 callback_writer.newline(" " + callback_name + "(PassRefPtrWillBeR awPtr<InspectorBackendDispatcherImpl>, int id);\n")
1791 callback_writer.newline(" void sendSuccess(" + ", ".join(decl_par ameter_list) + ");\n") 1790 callback_writer.newline(" CORE_EXPORT void sendSuccess(" + ", ".j oin(decl_parameter_list) + ");\n")
1792 error_part_writer = callback_writer.insert_writer("") 1791 error_part_writer = callback_writer.insert_writer("")
1793 callback_writer.newline("};\n") 1792 callback_writer.newline("};\n")
1794 1793
1795 if error_type_binding: 1794 if error_type_binding:
1796 annotated_type = error_type_model.get_input_param_type_text() 1795 annotated_type = error_type_model.get_input_param_type_text()
1797 error_part_writer.newline(" void sendFailure(const ErrorStrin g&, %s);\n" % annotated_type) 1796 error_part_writer.newline(" void sendFailure(const ErrorStrin g&, %s);\n" % annotated_type)
1798 error_part_writer.newline(" using CallbackBase::sendFailure;\ n") 1797 error_part_writer.newline(" using CallbackBase::sendFailure;\ n")
1799 1798
1800 assigment_value = error_type_model.get_event_setter_expression_p attern() % "errorData" 1799 assigment_value = error_type_model.get_event_setter_expression_p attern() % "errorData"
1801 assigment_value = error_type_binding.reduce_to_raw_type().get_co nstructor_pattern() % assigment_value 1800 assigment_value = error_type_binding.reduce_to_raw_type().get_co nstructor_pattern() % assigment_value
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 agentField=agent_field, 1874 agentField=agent_field,
1876 methodCode="".join([method_in_code, method_out_code]), 1875 methodCode="".join([method_in_code, method_out_code]),
1877 agentCallParamsDeclaration="\n".join(agent_call_params_declaration_l ist), 1876 agentCallParamsDeclaration="\n".join(agent_call_params_declaration_l ist),
1878 agentCallParams=", ".join(agent_call_param_list), 1877 agentCallParams=", ".join(agent_call_param_list),
1879 requestMessageObject=request_message_param, 1878 requestMessageObject=request_message_param,
1880 responseCook=normal_response_cook_text, 1879 responseCook=normal_response_cook_text,
1881 sendResponseCallParams=", ".join(send_response_call_params_list), 1880 sendResponseCallParams=", ".join(send_response_call_params_list),
1882 commandNameIndex=cmd_enum_name)) 1881 commandNameIndex=cmd_enum_name))
1883 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name) 1882 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name)
1884 Generator.backend_method_name_declaration_list.append(" \"%s\"" % dec laration_command_name) 1883 Generator.backend_method_name_declaration_list.append(" \"%s\"" % dec laration_command_name)
1884 assert Generator.backend_method_name_declaration_current_index < 2 ** 16 , "Number too large for unsigned short."
1885 Generator.backend_method_name_declaration_index_list.append(" %d," % Generator.backend_method_name_declaration_current_index) 1885 Generator.backend_method_name_declaration_index_list.append(" %d," % Generator.backend_method_name_declaration_current_index)
1886 Generator.backend_method_name_declaration_current_index += len(declarati on_command_name) - 1 1886 Generator.backend_method_name_declaration_current_index += len(declarati on_command_name) - 1
1887 1887
1888 backend_agent_interface_list.append(") = 0;\n") 1888 backend_agent_interface_list.append(") = 0;\n")
1889 1889
1890 class CallbackMethodStructTemplate: 1890 class CallbackMethodStructTemplate:
1891 @staticmethod 1891 @staticmethod
1892 def append_prolog(line_list): 1892 def append_prolog(line_list):
1893 pass 1893 pass
1894 1894
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 validatorIfdefName=VALIDATOR_IFDEF_NAME)) 2118 validatorIfdefName=VALIDATOR_IFDEF_NAME))
2119 2119
2120 backend_h_file.close() 2120 backend_h_file.close()
2121 backend_cpp_file.close() 2121 backend_cpp_file.close()
2122 2122
2123 frontend_h_file.close() 2123 frontend_h_file.close()
2124 frontend_cpp_file.close() 2124 frontend_cpp_file.close()
2125 2125
2126 typebuilder_h_file.close() 2126 typebuilder_h_file.close()
2127 typebuilder_cpp_file.close() 2127 typebuilder_cpp_file.close()
OLDNEW
« no previous file with comments | « core/input/InputDeviceInit.idl ('k') | core/inspector/CodeGeneratorInspectorStrings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698