| 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 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 domainClassName=domain_name, | 1801 domainClassName=domain_name, |
| 1802 domainFieldName=domain_name_lower, | 1802 domainFieldName=domain_name_lower, |
| 1803 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m
ethod_declaration_lines)))) | 1803 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m
ethod_declaration_lines)))) |
| 1804 | 1804 |
| 1805 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_
name) + "CommandHandler" | 1805 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_
name) + "CommandHandler" |
| 1806 Generator.backend_agent_interface_list.append(" class %s {\n" % a
gent_interface_name) | 1806 Generator.backend_agent_interface_list.append(" class %s {\n" % a
gent_interface_name) |
| 1807 Generator.backend_agent_interface_list.append(" public:\n") | 1807 Generator.backend_agent_interface_list.append(" public:\n") |
| 1808 if "commands" in json_domain: | 1808 if "commands" in json_domain: |
| 1809 for json_command in json_domain["commands"]: | 1809 for json_command in json_domain["commands"]: |
| 1810 Generator.process_command(json_command, domain_name, agent_f
ield_name, agent_interface_name) | 1810 Generator.process_command(json_command, domain_name, agent_f
ield_name, agent_interface_name) |
| 1811 |
| 1812 Generator.backend_agent_interface_list.append("\n class Contr
oller {\n") |
| 1813 Generator.backend_agent_interface_list.append(" public:\n") |
| 1814 Generator.backend_agent_interface_list.append(" virtual %
s* getCommandHandler() = 0;\n" % agent_interface_name) |
| 1815 Generator.backend_agent_interface_list.append(" protected:\n"
) |
| 1816 Generator.backend_agent_interface_list.append(" virtual ~
Controller() { }\n") |
| 1817 Generator.backend_agent_interface_list.append(" };\n\n") |
| 1818 agent_controller_name = agent_interface_name + "::Controller" |
| 1819 |
| 1811 Generator.backend_agent_interface_list.append("\n protected:\n") | 1820 Generator.backend_agent_interface_list.append("\n protected:\n") |
| 1812 Generator.backend_agent_interface_list.append(" virtual ~%s()
{ }\n" % agent_interface_name) | 1821 Generator.backend_agent_interface_list.append(" virtual ~%s()
{ }\n" % agent_interface_name) |
| 1813 Generator.backend_agent_interface_list.append(" };\n\n") | 1822 Generator.backend_agent_interface_list.append(" };\n\n") |
| 1814 | 1823 |
| 1815 Generator.backend_constructor_init_list.append(" , m_%s(0)" %
agent_field_name) | 1824 Generator.backend_constructor_init_list.append(" , m_%s(0)" %
agent_field_name) |
| 1816 Generator.backend_virtual_setters_list.append(" virtual void regi
sterAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name)) | 1825 Generator.backend_virtual_setters_list.append(" virtual void regi
sterAgent(%s* %s) = 0;" % (agent_controller_name, agent_field_name)) |
| 1817 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)) | 1826 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)) |
| 1818 Generator.backend_field_list.append(" %s* m_%s;" % (agent_interfa
ce_name, agent_field_name)) | 1827 Generator.backend_field_list.append(" %s* m_%s;" % (agent_control
ler_name, agent_field_name)) |
| 1819 | 1828 |
| 1820 @staticmethod | 1829 @staticmethod |
| 1821 def process_event(json_event, domain_name, frontend_method_declaration_lines
): | 1830 def process_event(json_event, domain_name, frontend_method_declaration_lines
): |
| 1822 event_name = json_event["name"] | 1831 event_name = json_event["name"] |
| 1823 | 1832 |
| 1824 ad_hoc_type_output = [] | 1833 ad_hoc_type_output = [] |
| 1825 frontend_method_declaration_lines.append(ad_hoc_type_output) | 1834 frontend_method_declaration_lines.append(ad_hoc_type_output) |
| 1826 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") | 1835 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") |
| 1827 | 1836 |
| 1828 decl_parameter_list = [] | 1837 decl_parameter_list = [] |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 agent_call_param_list.append(param) | 1991 agent_call_param_list.append(param) |
| 1983 | 1992 |
| 1984 response_cook_text = "".join(response_cook_list) | 1993 response_cook_text = "".join(response_cook_list) |
| 1985 | 1994 |
| 1986 if len(response_cook_text) != 0: | 1995 if len(response_cook_text) != 0: |
| 1987 response_cook_text = " if (!error.length()) {\n" + re
sponse_cook_text + " }" | 1996 response_cook_text = " if (!error.length()) {\n" + re
sponse_cook_text + " }" |
| 1988 | 1997 |
| 1989 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, | 1998 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, |
| 1990 domainName=domain_name, methodName=json_command_name, | 1999 domainName=domain_name, methodName=json_command_name, |
| 1991 agentField="m_" + agent_field_name, | 2000 agentField="m_" + agent_field_name, |
| 2001 handlerClass=agent_interface_name, |
| 1992 methodInCode=method_in_code, | 2002 methodInCode=method_in_code, |
| 1993 methodOutCode=method_out_code, | 2003 methodOutCode=method_out_code, |
| 1994 agentCallParams="".join(agent_call_param_list), | 2004 agentCallParams="".join(agent_call_param_list), |
| 1995 requestMessageObject=request_message_param, | 2005 requestMessageObject=request_message_param, |
| 1996 responseCook=response_cook_text, | 2006 responseCook=response_cook_text, |
| 1997 commandNameIndex=cmd_enum_name)) | 2007 commandNameIndex=cmd_enum_name)) |
| 1998 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," %
(domain_name, json_command_name)) | 2008 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," %
(domain_name, json_command_name)) |
| 1999 | 2009 |
| 2000 Generator.backend_agent_interface_list.append(") = 0;\n") | 2010 Generator.backend_agent_interface_list.append(") = 0;\n") |
| 2001 | 2011 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 validatorIfdefName=VALIDATOR_IFDEF_NAME)) | 2269 validatorIfdefName=VALIDATOR_IFDEF_NAME)) |
| 2260 | 2270 |
| 2261 backend_h_file.close() | 2271 backend_h_file.close() |
| 2262 backend_cpp_file.close() | 2272 backend_cpp_file.close() |
| 2263 | 2273 |
| 2264 frontend_h_file.close() | 2274 frontend_h_file.close() |
| 2265 frontend_cpp_file.close() | 2275 frontend_cpp_file.close() |
| 2266 | 2276 |
| 2267 typebuilder_h_file.close() | 2277 typebuilder_h_file.close() |
| 2268 typebuilder_cpp_file.close() | 2278 typebuilder_cpp_file.close() |
| OLD | NEW |