| 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 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 domainClassName=domain_name, | 1830 domainClassName=domain_name, |
| 1831 domainFieldName=domain_name_lower, | 1831 domainFieldName=domain_name_lower, |
| 1832 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m
ethod_declaration_lines)))) | 1832 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m
ethod_declaration_lines)))) |
| 1833 | 1833 |
| 1834 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_
name) + "CommandHandler" | 1834 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_
name) + "CommandHandler" |
| 1835 Generator.backend_agent_interface_list.append(" class %s {\n" % a
gent_interface_name) | 1835 Generator.backend_agent_interface_list.append(" class %s {\n" % a
gent_interface_name) |
| 1836 Generator.backend_agent_interface_list.append(" public:\n") | 1836 Generator.backend_agent_interface_list.append(" public:\n") |
| 1837 if "commands" in json_domain: | 1837 if "commands" in json_domain: |
| 1838 for json_command in json_domain["commands"]: | 1838 for json_command in json_domain["commands"]: |
| 1839 Generator.process_command(json_command, domain_name, agent_f
ield_name, agent_interface_name) | 1839 Generator.process_command(json_command, domain_name, agent_f
ield_name, agent_interface_name) |
| 1840 |
| 1841 Generator.backend_agent_interface_list.append("\n class Facto
ry {\n") |
| 1842 Generator.backend_agent_interface_list.append(" public:\n") |
| 1843 Generator.backend_agent_interface_list.append(" virtual %
s* commandHandler() = 0;\n" % agent_interface_name) |
| 1844 Generator.backend_agent_interface_list.append(" protected:\n"
) |
| 1845 Generator.backend_agent_interface_list.append(" virtual ~
Factory() { }\n") |
| 1846 Generator.backend_agent_interface_list.append(" };\n\n") |
| 1847 agent_controller_name = agent_interface_name + "::Factory" |
| 1848 |
| 1840 Generator.backend_agent_interface_list.append("\n protected:\n") | 1849 Generator.backend_agent_interface_list.append("\n protected:\n") |
| 1841 Generator.backend_agent_interface_list.append(" virtual ~%s()
{ }\n" % agent_interface_name) | 1850 Generator.backend_agent_interface_list.append(" virtual ~%s()
{ }\n" % agent_interface_name) |
| 1842 Generator.backend_agent_interface_list.append(" };\n\n") | 1851 Generator.backend_agent_interface_list.append(" };\n\n") |
| 1843 | 1852 |
| 1844 Generator.backend_constructor_init_list.append(" , m_%s(0)" %
agent_field_name) | 1853 Generator.backend_constructor_init_list.append(" , m_%s(0)" %
agent_field_name) |
| 1845 Generator.backend_virtual_setters_list.append(" virtual void regi
sterAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name)) | 1854 Generator.backend_virtual_setters_list.append(" virtual void regi
sterAgent(%s* %s) = 0;" % (agent_controller_name, agent_field_name)) |
| 1846 Generator.backend_setters_list.append(" virtual void registerAgen
t(%s* %s) { ASSERT(!m_%s); m_%s = %s; }" % (agent_interface_name, agent_field_na
me, agent_field_name, agent_field_name, agent_field_name)) | 1855 Generator.backend_setters_list.append(" virtual void registerAgen
t(%s* %s) { ASSERT(!m_%s); m_%s = %s; }" % (agent_controller_name, agent_field_n
ame, agent_field_name, agent_field_name, agent_field_name)) |
| 1847 Generator.backend_field_list.append(" %s* m_%s;" % (agent_interfa
ce_name, agent_field_name)) | 1856 Generator.backend_field_list.append(" %s* m_%s;" % (agent_control
ler_name, agent_field_name)) |
| 1848 | 1857 |
| 1849 @staticmethod | 1858 @staticmethod |
| 1850 def process_event(json_event, domain_name, frontend_method_declaration_lines
): | 1859 def process_event(json_event, domain_name, frontend_method_declaration_lines
): |
| 1851 event_name = json_event["name"] | 1860 event_name = json_event["name"] |
| 1852 | 1861 |
| 1853 ad_hoc_type_output = [] | 1862 ad_hoc_type_output = [] |
| 1854 frontend_method_declaration_lines.append(ad_hoc_type_output) | 1863 frontend_method_declaration_lines.append(ad_hoc_type_output) |
| 1855 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") | 1864 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") |
| 1856 | 1865 |
| 1857 decl_parameter_list = [] | 1866 decl_parameter_list = [] |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 agent_call_param_list.append(param) | 2058 agent_call_param_list.append(param) |
| 2050 | 2059 |
| 2051 normal_response_cook_text += "".join(response_cook_list) | 2060 normal_response_cook_text += "".join(response_cook_list) |
| 2052 | 2061 |
| 2053 if len(normal_response_cook_text) != 0: | 2062 if len(normal_response_cook_text) != 0: |
| 2054 normal_response_cook_text = " if (!error.length()) {\
n" + normal_response_cook_text + " }" | 2063 normal_response_cook_text = " if (!error.length()) {\
n" + normal_response_cook_text + " }" |
| 2055 | 2064 |
| 2056 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, | 2065 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, |
| 2057 domainName=domain_name, methodName=json_command_name, | 2066 domainName=domain_name, methodName=json_command_name, |
| 2058 agentField="m_" + agent_field_name, | 2067 agentField="m_" + agent_field_name, |
| 2068 handlerClass=agent_interface_name, |
| 2059 methodInCode=method_in_code, | 2069 methodInCode=method_in_code, |
| 2060 methodOutCode=method_out_code, | 2070 methodOutCode=method_out_code, |
| 2061 agentCallParams="".join(agent_call_param_list), | 2071 agentCallParams="".join(agent_call_param_list), |
| 2062 requestMessageObject=request_message_param, | 2072 requestMessageObject=request_message_param, |
| 2063 responseCook=normal_response_cook_text, | 2073 responseCook=normal_response_cook_text, |
| 2064 errorCook=error_response_cook_text, | 2074 errorCook=error_response_cook_text, |
| 2065 commandNameIndex=cmd_enum_name)) | 2075 commandNameIndex=cmd_enum_name)) |
| 2066 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," %
(domain_name, json_command_name)) | 2076 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," %
(domain_name, json_command_name)) |
| 2067 | 2077 |
| 2068 Generator.backend_agent_interface_list.append(") = 0;\n") | 2078 Generator.backend_agent_interface_list.append(") = 0;\n") |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 validatorIfdefName=VALIDATOR_IFDEF_NAME)) | 2341 validatorIfdefName=VALIDATOR_IFDEF_NAME)) |
| 2332 | 2342 |
| 2333 backend_h_file.close() | 2343 backend_h_file.close() |
| 2334 backend_cpp_file.close() | 2344 backend_cpp_file.close() |
| 2335 | 2345 |
| 2336 frontend_h_file.close() | 2346 frontend_h_file.close() |
| 2337 frontend_cpp_file.close() | 2347 frontend_cpp_file.close() |
| 2338 | 2348 |
| 2339 typebuilder_h_file.close() | 2349 typebuilder_h_file.close() |
| 2340 typebuilder_cpp_file.close() | 2350 typebuilder_cpp_file.close() |
| OLD | NEW |