| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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", "Debugger.Location", | 51 "Debugger.FunctionDetails", "Debugger.C
allFrame", "Debugger.Location", |
| 52 "Canvas.TraceLog", "Canvas.ResourceStat
e", | 52 "Canvas.TraceLog", "Canvas.ResourceStat
e"]) |
| 53 # This should be a temporary hack. Time
lineEvent should be created via generated C++ API. | |
| 54 "Timeline.TimelineEvent"]) | |
| 55 | 53 |
| 56 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset(["Timeline.TimelineEvent", | 54 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([ |
| 57 # InspectorStyleSheet not only creat
es this property but wants to read it and modify it. | 55 # InspectorStyleSheet not only creat
es this property but wants to read it and modify it. |
| 58 "CSS.CSSProperty", | 56 "CSS.CSSProperty", |
| 59 # InspectorResourceAgent needs to up
date mime-type. | 57 # InspectorResourceAgent needs to up
date mime-type. |
| 60 "Network.Response"]) | 58 "Network.Response"]) |
| 61 | 59 |
| 62 EXACTLY_INT_SUPPORTED = False | 60 EXACTLY_INT_SUPPORTED = False |
| 63 | 61 |
| 64 cmdline_parser = optparse.OptionParser() | 62 cmdline_parser = optparse.OptionParser() |
| 65 cmdline_parser.add_option("--output_dir") | 63 cmdline_parser.add_option("--output_dir") |
| 66 | 64 |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 @staticmethod | 1880 @staticmethod |
| 1883 def process_command(json_command, domain_name, agent_field_name, agent_inter
face_name): | 1881 def process_command(json_command, domain_name, agent_field_name, agent_inter
face_name): |
| 1884 json_command_name = json_command["name"] | 1882 json_command_name = json_command["name"] |
| 1885 | 1883 |
| 1886 cmd_enum_name = "k%s_%sCmd" % (domain_name, json_command["name"]) | 1884 cmd_enum_name = "k%s_%sCmd" % (domain_name, json_command["name"]) |
| 1887 | 1885 |
| 1888 Generator.method_name_enum_list.append(" %s," % cmd_enum_name) | 1886 Generator.method_name_enum_list.append(" %s," % cmd_enum_name) |
| 1889 Generator.method_handler_list.append(" &InspectorBackendDispa
tcherImpl::%s_%s," % (domain_name, json_command_name)) | 1887 Generator.method_handler_list.append(" &InspectorBackendDispa
tcherImpl::%s_%s," % (domain_name, json_command_name)) |
| 1890 Generator.backend_method_declaration_list.append(" void %s_%s(long ca
llId, JSONObject* requestMessageObject);" % (domain_name, json_command_name)) | 1888 Generator.backend_method_declaration_list.append(" void %s_%s(long ca
llId, JSONObject* requestMessageObject);" % (domain_name, json_command_name)) |
| 1891 | 1889 |
| 1890 backend_agent_interface_list = [] if "redirect" in json_command else Gen
erator.backend_agent_interface_list |
| 1891 |
| 1892 ad_hoc_type_output = [] | 1892 ad_hoc_type_output = [] |
| 1893 Generator.backend_agent_interface_list.append(ad_hoc_type_output) | 1893 backend_agent_interface_list.append(ad_hoc_type_output) |
| 1894 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") | 1894 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") |
| 1895 | 1895 |
| 1896 Generator.backend_agent_interface_list.append(" virtual void %s(E
rrorString*" % json_command_name) | 1896 backend_agent_interface_list.append(" virtual void %s(ErrorString
*" % json_command_name) |
| 1897 | 1897 |
| 1898 method_in_code = "" | 1898 method_in_code = "" |
| 1899 method_out_code = "" | 1899 method_out_code = "" |
| 1900 agent_call_param_list = [] | 1900 agent_call_param_list = [] |
| 1901 request_message_param = "" | 1901 request_message_param = "" |
| 1902 normal_response_cook_text = "" | 1902 normal_response_cook_text = "" |
| 1903 error_response_cook_text = "" | 1903 error_response_cook_text = "" |
| 1904 error_type_binding = None | 1904 error_type_binding = None |
| 1905 if "error" in json_command: | 1905 if "error" in json_command: |
| 1906 json_error = json_command["error"] | 1906 json_error = json_command["error"] |
| 1907 error_type_binding = Generator.resolve_type_and_generate_ad_hoc(json
_error, json_command_name + "Error", json_command_name, domain_name, ad_hoc_type
_writer, agent_interface_name + "::") | 1907 error_type_binding = Generator.resolve_type_and_generate_ad_hoc(json
_error, json_command_name + "Error", json_command_name, domain_name, ad_hoc_type
_writer, agent_interface_name + "::") |
| 1908 error_type_model = error_type_binding.get_type_model().get_optional(
) | 1908 error_type_model = error_type_binding.get_type_model().get_optional(
) |
| 1909 error_annotated_type = error_type_model.get_command_return_pass_mode
l().get_output_parameter_type() | 1909 error_annotated_type = error_type_model.get_command_return_pass_mode
l().get_output_parameter_type() |
| 1910 agent_call_param_list.append(", %serrorData" % error_type_model.get_
command_return_pass_model().get_output_argument_prefix()) | 1910 agent_call_param_list.append(", %serrorData" % error_type_model.get_
command_return_pass_model().get_output_argument_prefix()) |
| 1911 Generator.backend_agent_interface_list.append(", %s errorData" % err
or_annotated_type) | 1911 backend_agent_interface_list.append(", %s errorData" % error_annotat
ed_type) |
| 1912 method_in_code += " %s errorData;\n" % error_type_model.get_comma
nd_return_pass_model().get_return_var_type() | 1912 method_in_code += " %s errorData;\n" % error_type_model.get_comma
nd_return_pass_model().get_return_var_type() |
| 1913 | 1913 |
| 1914 setter_argument = error_type_model.get_command_return_pass_model().g
et_output_to_raw_expression() % "errorData" | 1914 setter_argument = error_type_model.get_command_return_pass_model().g
et_output_to_raw_expression() % "errorData" |
| 1915 if error_type_binding.get_setter_value_expression_pattern(): | 1915 if error_type_binding.get_setter_value_expression_pattern(): |
| 1916 setter_argument = error_type_binding.get_setter_value_expression
_pattern() % setter_argument | 1916 setter_argument = error_type_binding.get_setter_value_expression
_pattern() % setter_argument |
| 1917 error_assigment_value = error_type_binding.reduce_to_raw_type().get_
constructor_pattern() % setter_argument | 1917 error_assigment_value = error_type_binding.reduce_to_raw_type().get_
constructor_pattern() % setter_argument |
| 1918 | 1918 |
| 1919 cook = " resultErrorData = %s;\n" % error_assigment_value | 1919 cook = " resultErrorData = %s;\n" % error_assigment_value |
| 1920 | 1920 |
| 1921 error_condition_pattern = error_type_model.get_command_return_pass_m
odel().get_set_return_condition() | 1921 error_condition_pattern = error_type_model.get_command_return_pass_m
odel().get_set_return_condition() |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 (non_optional_type_model.get_command_return_pass_mod
el().get_return_var_type(), json_param_name, getter_name, json_param_name)) | 1955 (non_optional_type_model.get_command_return_pass_mod
el().get_return_var_type(), json_param_name, getter_name, json_param_name)) |
| 1956 param = ", in_%s" % json_param_name | 1956 param = ", in_%s" % json_param_name |
| 1957 # FIXME: pass not-optional refptr-values as NonNullPassRefPt
r | 1957 # FIXME: pass not-optional refptr-values as NonNullPassRefPt
r |
| 1958 if param_raw_type.is_heavy_value(): | 1958 if param_raw_type.is_heavy_value(): |
| 1959 formal_param_type_pattern = "const %s&" | 1959 formal_param_type_pattern = "const %s&" |
| 1960 else: | 1960 else: |
| 1961 formal_param_type_pattern = "%s" | 1961 formal_param_type_pattern = "%s" |
| 1962 | 1962 |
| 1963 method_in_code += code | 1963 method_in_code += code |
| 1964 agent_call_param_list.append(param) | 1964 agent_call_param_list.append(param) |
| 1965 Generator.backend_agent_interface_list.append(", %s in_%s" % (fo
rmal_param_type_pattern % non_optional_type_model.get_command_return_pass_model(
).get_return_var_type(), json_param_name)) | 1965 backend_agent_interface_list.append(", %s in_%s" % (formal_param
_type_pattern % non_optional_type_model.get_command_return_pass_model().get_retu
rn_var_type(), json_param_name)) |
| 1966 | 1966 |
| 1967 if json_command.get("async") == True: | 1967 if json_command.get("async") == True: |
| 1968 callback_name = Capitalizer.lower_camel_case_to_upper(json_command_n
ame) + "Callback" | 1968 callback_name = Capitalizer.lower_camel_case_to_upper(json_command_n
ame) + "Callback" |
| 1969 | 1969 |
| 1970 callback_output = [] | 1970 callback_output = [] |
| 1971 callback_writer = Writer(callback_output, ad_hoc_type_writer.get_ind
ent()) | 1971 callback_writer = Writer(callback_output, ad_hoc_type_writer.get_ind
ent()) |
| 1972 | 1972 |
| 1973 decl_parameter_list = [] | 1973 decl_parameter_list = [] |
| 1974 Generator.generate_send_method(json_command.get("returns"), json_com
mand_name, domain_name, ad_hoc_type_writer, | 1974 Generator.generate_send_method(json_command.get("returns"), json_com
mand_name, domain_name, ad_hoc_type_writer, |
| 1975 decl_parameter_list, | 1975 decl_parameter_list, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2000 | 2000 |
| 2001 | 2001 |
| 2002 | 2002 |
| 2003 ad_hoc_type_output.append(callback_output) | 2003 ad_hoc_type_output.append(callback_output) |
| 2004 | 2004 |
| 2005 method_out_code += " RefPtr<" + agent_interface_name + "::" + cal
lback_name + "> callback = adoptRef(new " + agent_interface_name + "::" + callba
ck_name + "(this, callId));\n" | 2005 method_out_code += " RefPtr<" + agent_interface_name + "::" + cal
lback_name + "> callback = adoptRef(new " + agent_interface_name + "::" + callba
ck_name + "(this, callId));\n" |
| 2006 agent_call_param_list.append(", callback") | 2006 agent_call_param_list.append(", callback") |
| 2007 normal_response_cook_text += " if (!error.length()) \n" | 2007 normal_response_cook_text += " if (!error.length()) \n" |
| 2008 normal_response_cook_text += " return;\n" | 2008 normal_response_cook_text += " return;\n" |
| 2009 normal_response_cook_text += " callback->disable();\n" | 2009 normal_response_cook_text += " callback->disable();\n" |
| 2010 Generator.backend_agent_interface_list.append(", PassRefPtr<%s> call
back" % callback_name) | 2010 backend_agent_interface_list.append(", PassRefPtr<%s> callback" % ca
llback_name) |
| 2011 else: | 2011 else: |
| 2012 if "returns" in json_command: | 2012 if "returns" in json_command: |
| 2013 method_out_code += "\n" | 2013 method_out_code += "\n" |
| 2014 response_cook_list = [] | 2014 response_cook_list = [] |
| 2015 for json_return in json_command["returns"]: | 2015 for json_return in json_command["returns"]: |
| 2016 | 2016 |
| 2017 json_return_name = json_return["name"] | 2017 json_return_name = json_return["name"] |
| 2018 | 2018 |
| 2019 optional = bool(json_return.get("optional")) | 2019 optional = bool(json_return.get("optional")) |
| 2020 | 2020 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2040 | 2040 |
| 2041 set_condition_pattern = type_model.get_command_return_pass_m
odel().get_set_return_condition() | 2041 set_condition_pattern = type_model.get_command_return_pass_m
odel().get_set_return_condition() |
| 2042 if set_condition_pattern: | 2042 if set_condition_pattern: |
| 2043 cook = (" if (%s)\n " % (set_condition_pat
tern % var_name)) + cook | 2043 cook = (" if (%s)\n " % (set_condition_pat
tern % var_name)) + cook |
| 2044 annotated_type = type_model.get_command_return_pass_model().
get_output_parameter_type() | 2044 annotated_type = type_model.get_command_return_pass_model().
get_output_parameter_type() |
| 2045 | 2045 |
| 2046 param_name = var_name | 2046 param_name = var_name |
| 2047 if optional: | 2047 if optional: |
| 2048 param_name = "opt_" + param_name | 2048 param_name = "opt_" + param_name |
| 2049 | 2049 |
| 2050 Generator.backend_agent_interface_list.append(", %s %s" % (a
nnotated_type, param_name)) | 2050 backend_agent_interface_list.append(", %s %s" % (annotated_t
ype, param_name)) |
| 2051 response_cook_list.append(cook) | 2051 response_cook_list.append(cook) |
| 2052 | 2052 |
| 2053 method_out_code += code | 2053 method_out_code += code |
| 2054 agent_call_param_list.append(param) | 2054 agent_call_param_list.append(param) |
| 2055 | 2055 |
| 2056 normal_response_cook_text += "".join(response_cook_list) | 2056 normal_response_cook_text += "".join(response_cook_list) |
| 2057 | 2057 |
| 2058 if len(normal_response_cook_text) != 0: | 2058 if len(normal_response_cook_text) != 0: |
| 2059 normal_response_cook_text = " if (!error.length()) {\
n" + normal_response_cook_text + " }" | 2059 normal_response_cook_text = " if (!error.length()) {\
n" + normal_response_cook_text + " }" |
| 2060 | 2060 |
| 2061 # Redirect to another agent's implementation. |
| 2062 agent_field = "m_" + agent_field_name |
| 2063 if "redirect" in json_command: |
| 2064 domain_fixes = DomainNameFixes.get_fixed_data(json_command.get("redi
rect")) |
| 2065 agent_field = "m_" + domain_fixes.agent_field_name |
| 2066 |
| 2061 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, | 2067 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, |
| 2062 domainName=domain_name, methodName=json_command_name, | 2068 domainName=domain_name, methodName=json_command_name, |
| 2063 agentField="m_" + agent_field_name, | 2069 agentField=agent_field, |
| 2064 methodInCode=method_in_code, | 2070 methodInCode=method_in_code, |
| 2065 methodOutCode=method_out_code, | 2071 methodOutCode=method_out_code, |
| 2066 agentCallParams="".join(agent_call_param_list), | 2072 agentCallParams="".join(agent_call_param_list), |
| 2067 requestMessageObject=request_message_param, | 2073 requestMessageObject=request_message_param, |
| 2068 responseCook=normal_response_cook_text, | 2074 responseCook=normal_response_cook_text, |
| 2069 errorCook=error_response_cook_text, | 2075 errorCook=error_response_cook_text, |
| 2070 commandNameIndex=cmd_enum_name)) | 2076 commandNameIndex=cmd_enum_name)) |
| 2071 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name) | 2077 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name) |
| 2072 Generator.backend_method_name_declaration_list.append(" \"%s\"" % dec
laration_command_name) | 2078 Generator.backend_method_name_declaration_list.append(" \"%s\"" % dec
laration_command_name) |
| 2073 Generator.backend_method_name_declaration_index_list.append(" %d," %
Generator.backend_method_name_declaration_current_index) | 2079 Generator.backend_method_name_declaration_index_list.append(" %d," %
Generator.backend_method_name_declaration_current_index) |
| 2074 Generator.backend_method_name_declaration_current_index += len(declarati
on_command_name) - 1 | 2080 Generator.backend_method_name_declaration_current_index += len(declarati
on_command_name) - 1 |
| 2075 | 2081 |
| 2076 Generator.backend_agent_interface_list.append(") = 0;\n") | 2082 backend_agent_interface_list.append(") = 0;\n") |
| 2077 | 2083 |
| 2078 class CallbackMethodStructTemplate: | 2084 class CallbackMethodStructTemplate: |
| 2079 @staticmethod | 2085 @staticmethod |
| 2080 def append_prolog(line_list): | 2086 def append_prolog(line_list): |
| 2081 pass | 2087 pass |
| 2082 | 2088 |
| 2083 @staticmethod | 2089 @staticmethod |
| 2084 def append_epilog(line_list): | 2090 def append_epilog(line_list): |
| 2085 pass | 2091 pass |
| 2086 | 2092 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2340 validatorIfdefName=VALIDATOR_IFDEF_NAME)) | 2346 validatorIfdefName=VALIDATOR_IFDEF_NAME)) |
| 2341 | 2347 |
| 2342 backend_h_file.close() | 2348 backend_h_file.close() |
| 2343 backend_cpp_file.close() | 2349 backend_cpp_file.close() |
| 2344 | 2350 |
| 2345 frontend_h_file.close() | 2351 frontend_h_file.close() |
| 2346 frontend_cpp_file.close() | 2352 frontend_cpp_file.close() |
| 2347 | 2353 |
| 2348 typebuilder_h_file.close() | 2354 typebuilder_h_file.close() |
| 2349 typebuilder_cpp_file.close() | 2355 typebuilder_cpp_file.close() |
| OLD | NEW |