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 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 | 1274 |
1275 validator_writer.newline("\n\n") | 1275 validator_writer.newline("\n\n") |
1276 | 1276 |
1277 if is_open_type: | 1277 if is_open_type: |
1278 cpp_writer = generate_context.cpp_writer | 1278 cpp_writer = generate_context.cpp_writer |
1279 writer.append("\n") | 1279 writer.append("\n") |
1280 writer.newline(" // Property names for ty
pe generated as open.\n") | 1280 writer.newline(" // Property names for ty
pe generated as open.\n") |
1281 for prop_data in resolve_data.main_propertie
s + resolve_data.optional_properties: | 1281 for prop_data in resolve_data.main_propertie
s + resolve_data.optional_properties: |
1282 prop_name = prop_data.p["name"] | 1282 prop_name = prop_data.p["name"] |
1283 prop_field_name = Capitalizer.lower_came
l_case_to_upper(prop_name) | 1283 prop_field_name = Capitalizer.lower_came
l_case_to_upper(prop_name) |
1284 writer.newline(" static const char* %
s;\n" % (prop_field_name)) | 1284 writer.newline(" static const char %s
[];\n" % (prop_field_name)) |
1285 cpp_writer.newline("const char* %s%s::%s
= \"%s\";\n" % (helper.full_name_prefix_for_impl, class_name, prop_field_name,
prop_name)) | 1285 cpp_writer.newline("const char %s%s::%s[
] = \"%s\";\n" % (helper.full_name_prefix_for_impl, class_name, prop_field_name,
prop_name)) |
1286 | 1286 |
1287 | 1287 |
1288 writer.newline("};\n\n") | 1288 writer.newline("};\n\n") |
1289 | 1289 |
1290 @staticmethod | 1290 @staticmethod |
1291 def generate_forward_declaration(writer): | 1291 def generate_forward_declaration(writer): |
1292 class_name = fixed_type_name.class_name | 1292 class_name = fixed_type_name.class_name |
1293 writer.newline("class ") | 1293 writer.newline("class ") |
1294 writer.append(class_name) | 1294 writer.append(class_name) |
1295 writer.append(";\n") | 1295 writer.append(";\n") |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 return value_ref | 1766 return value_ref |
1767 | 1767 |
1768 class Generator: | 1768 class Generator: |
1769 frontend_class_field_lines = [] | 1769 frontend_class_field_lines = [] |
1770 frontend_domain_class_lines = [] | 1770 frontend_domain_class_lines = [] |
1771 | 1771 |
1772 method_name_enum_list = [] | 1772 method_name_enum_list = [] |
1773 backend_method_declaration_list = [] | 1773 backend_method_declaration_list = [] |
1774 backend_method_implementation_list = [] | 1774 backend_method_implementation_list = [] |
1775 backend_method_name_declaration_list = [] | 1775 backend_method_name_declaration_list = [] |
| 1776 backend_method_name_declaration_index_list = [] |
| 1777 backend_method_name_declaration_current_index = 0 |
1776 method_handler_list = [] | 1778 method_handler_list = [] |
1777 frontend_method_list = [] | 1779 frontend_method_list = [] |
1778 | 1780 |
1779 backend_virtual_setters_list = [] | 1781 backend_virtual_setters_list = [] |
1780 backend_agent_interface_list = [] | 1782 backend_agent_interface_list = [] |
1781 backend_setters_list = [] | 1783 backend_setters_list = [] |
1782 backend_constructor_init_list = [] | 1784 backend_constructor_init_list = [] |
1783 backend_field_list = [] | 1785 backend_field_list = [] |
1784 frontend_constructor_init_list = [] | 1786 frontend_constructor_init_list = [] |
1785 type_builder_fragments = [] | 1787 type_builder_fragments = [] |
1786 type_builder_forwards = [] | 1788 type_builder_forwards = [] |
1787 validator_impl_list = [] | 1789 validator_impl_list = [] |
1788 type_builder_impl_list = [] | 1790 type_builder_impl_list = [] |
1789 | 1791 |
1790 | 1792 |
1791 @staticmethod | 1793 @staticmethod |
1792 def go(): | 1794 def go(): |
1793 Generator.process_types(type_map) | 1795 Generator.process_types(type_map) |
1794 | 1796 |
1795 first_cycle_guardable_list_list = [ | 1797 first_cycle_guardable_list_list = [ |
1796 Generator.backend_method_declaration_list, | 1798 Generator.backend_method_declaration_list, |
1797 Generator.backend_method_implementation_list, | 1799 Generator.backend_method_implementation_list, |
1798 Generator.backend_method_name_declaration_list, | 1800 Generator.backend_method_name_declaration_list, |
| 1801 Generator.backend_method_name_declaration_index_list, |
1799 Generator.backend_agent_interface_list, | 1802 Generator.backend_agent_interface_list, |
1800 Generator.frontend_class_field_lines, | 1803 Generator.frontend_class_field_lines, |
1801 Generator.frontend_constructor_init_list, | 1804 Generator.frontend_constructor_init_list, |
1802 Generator.frontend_domain_class_lines, | 1805 Generator.frontend_domain_class_lines, |
1803 Generator.frontend_method_list, | 1806 Generator.frontend_method_list, |
1804 Generator.method_handler_list, | 1807 Generator.method_handler_list, |
1805 Generator.method_name_enum_list, | 1808 Generator.method_name_enum_list, |
1806 Generator.backend_constructor_init_list, | 1809 Generator.backend_constructor_init_list, |
1807 Generator.backend_virtual_setters_list, | 1810 Generator.backend_virtual_setters_list, |
1808 Generator.backend_setters_list, | 1811 Generator.backend_setters_list, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 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 |
1915 | 1918 |
1916 cook = " resultErrorData = %s;\n" % error_assigment_value | 1919 cook = " resultErrorData = %s;\n" % error_assigment_value |
1917 | 1920 |
1918 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() |
1919 cook = (" if (%s)\n " % (error_condition_pattern % "er
rorData")) + cook | 1922 cook = (" if (%s)\n " % (error_condition_pattern % "er
rorData")) + cook |
1920 error_response_cook_text = " if (error.length()) {\n" + cook
+ " }\n" | 1923 error_response_cook_text = " if (error.length()) {\n" + cook
+ " }\n" |
1921 | 1924 |
1922 if "parameters" in json_command: | 1925 if "parameters" in json_command: |
1923 json_params = json_command["parameters"] | 1926 json_params = json_command["parameters"] |
1924 method_in_code += Templates.param_container_access_code | |
1925 request_message_param = " requestMessageObject" | 1927 request_message_param = " requestMessageObject" |
1926 | 1928 |
| 1929 if json_params: |
| 1930 method_in_code += Templates.param_container_access_code |
| 1931 |
1927 for json_parameter in json_params: | 1932 for json_parameter in json_params: |
1928 json_param_name = json_parameter["name"] | 1933 json_param_name = json_parameter["name"] |
1929 param_raw_type = resolve_param_raw_type(json_parameter, domain_n
ame) | 1934 param_raw_type = resolve_param_raw_type(json_parameter, domain_n
ame) |
1930 | 1935 |
1931 getter_name = param_raw_type.get_getter_name() | 1936 getter_name = param_raw_type.get_getter_name() |
1932 | 1937 |
1933 optional = json_parameter.get("optional") | 1938 optional = json_parameter.get("optional") |
1934 | 1939 |
1935 non_optional_type_model = param_raw_type.get_raw_type_model() | 1940 non_optional_type_model = param_raw_type.get_raw_type_model() |
1936 if optional: | 1941 if optional: |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, | 2061 Generator.backend_method_implementation_list.append(Templates.backend_me
thod.substitute(None, |
2057 domainName=domain_name, methodName=json_command_name, | 2062 domainName=domain_name, methodName=json_command_name, |
2058 agentField="m_" + agent_field_name, | 2063 agentField="m_" + agent_field_name, |
2059 methodInCode=method_in_code, | 2064 methodInCode=method_in_code, |
2060 methodOutCode=method_out_code, | 2065 methodOutCode=method_out_code, |
2061 agentCallParams="".join(agent_call_param_list), | 2066 agentCallParams="".join(agent_call_param_list), |
2062 requestMessageObject=request_message_param, | 2067 requestMessageObject=request_message_param, |
2063 responseCook=normal_response_cook_text, | 2068 responseCook=normal_response_cook_text, |
2064 errorCook=error_response_cook_text, | 2069 errorCook=error_response_cook_text, |
2065 commandNameIndex=cmd_enum_name)) | 2070 commandNameIndex=cmd_enum_name)) |
2066 Generator.backend_method_name_declaration_list.append(" \"%s.%s\"," %
(domain_name, json_command_name)) | 2071 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name) |
| 2072 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) |
| 2074 Generator.backend_method_name_declaration_current_index += len(declarati
on_command_name) - 1 |
2067 | 2075 |
2068 Generator.backend_agent_interface_list.append(") = 0;\n") | 2076 Generator.backend_agent_interface_list.append(") = 0;\n") |
2069 | 2077 |
2070 class CallbackMethodStructTemplate: | 2078 class CallbackMethodStructTemplate: |
2071 @staticmethod | 2079 @staticmethod |
2072 def append_prolog(line_list): | 2080 def append_prolog(line_list): |
2073 pass | 2081 pass |
2074 | 2082 |
2075 @staticmethod | 2083 @staticmethod |
2076 def append_epilog(line_list): | 2084 def append_epilog(line_list): |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2300 backend_h_file.write(Templates.backend_h.substitute(None, | 2308 backend_h_file.write(Templates.backend_h.substitute(None, |
2301 virtualSetters="\n".join(Generator.backend_virtual_setters_list), | 2309 virtualSetters="\n".join(Generator.backend_virtual_setters_list), |
2302 agentInterfaces="".join(flatten_list(Generator.backend_agent_interface_list)
), | 2310 agentInterfaces="".join(flatten_list(Generator.backend_agent_interface_list)
), |
2303 methodNamesEnumContent="\n".join(Generator.method_name_enum_list))) | 2311 methodNamesEnumContent="\n".join(Generator.method_name_enum_list))) |
2304 | 2312 |
2305 backend_cpp_file.write(Templates.backend_cpp.substitute(None, | 2313 backend_cpp_file.write(Templates.backend_cpp.substitute(None, |
2306 constructorInit="\n".join(Generator.backend_constructor_init_list), | 2314 constructorInit="\n".join(Generator.backend_constructor_init_list), |
2307 setters="\n".join(Generator.backend_setters_list), | 2315 setters="\n".join(Generator.backend_setters_list), |
2308 fieldDeclarations="\n".join(Generator.backend_field_list), | 2316 fieldDeclarations="\n".join(Generator.backend_field_list), |
2309 methodNameDeclarations="\n".join(Generator.backend_method_name_declaration_l
ist), | 2317 methodNameDeclarations="\n".join(Generator.backend_method_name_declaration_l
ist), |
| 2318 methodNameDeclarationsIndex="\n".join(Generator.backend_method_name_declarat
ion_index_list), |
2310 methods="\n".join(Generator.backend_method_implementation_list), | 2319 methods="\n".join(Generator.backend_method_implementation_list), |
2311 methodDeclarations="\n".join(Generator.backend_method_declaration_list), | 2320 methodDeclarations="\n".join(Generator.backend_method_declaration_list), |
2312 messageHandlers="\n".join(Generator.method_handler_list))) | 2321 messageHandlers="\n".join(Generator.method_handler_list))) |
2313 | 2322 |
2314 frontend_h_file.write(Templates.frontend_h.substitute(None, | 2323 frontend_h_file.write(Templates.frontend_h.substitute(None, |
2315 fieldDeclarations="".join(Generator.frontend_class_field_lines), | 2324 fieldDeclarations="".join(Generator.frontend_class_field_lines), |
2316 domainClassList="".join(Generator.frontend_domain_class_lines))) | 2325 domainClassList="".join(Generator.frontend_domain_class_lines))) |
2317 | 2326 |
2318 frontend_cpp_file.write(Templates.frontend_cpp.substitute(None, | 2327 frontend_cpp_file.write(Templates.frontend_cpp.substitute(None, |
2319 constructorInit="".join(Generator.frontend_constructor_init_list), | 2328 constructorInit="".join(Generator.frontend_constructor_init_list), |
(...skipping 11 matching lines...) Expand all Loading... |
2331 validatorIfdefName=VALIDATOR_IFDEF_NAME)) | 2340 validatorIfdefName=VALIDATOR_IFDEF_NAME)) |
2332 | 2341 |
2333 backend_h_file.close() | 2342 backend_h_file.close() |
2334 backend_cpp_file.close() | 2343 backend_cpp_file.close() |
2335 | 2344 |
2336 frontend_h_file.close() | 2345 frontend_h_file.close() |
2337 frontend_cpp_file.close() | 2346 frontend_cpp_file.close() |
2338 | 2347 |
2339 typebuilder_h_file.close() | 2348 typebuilder_h_file.close() |
2340 typebuilder_cpp_file.close() | 2349 typebuilder_cpp_file.close() |
OLD | NEW |