The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Tidy ipc_generated_protocol.h generator function

+24 -26
+24 -26
src/xrt/ipc/shared/proto.py
··· 151 151 struct ipc_connection; 152 152 ''') 153 153 154 - f.write(''' 155 - typedef enum ipc_command 156 - { 157 - \tIPC_ERR = 0,''') 154 + f.write('\ntypedef enum ipc_command') 155 + f.write('\n{') 156 + f.write('\n\tIPC_ERR = 0,') 158 157 for call in p.calls: 159 158 f.write("\n\t" + call.id + ",") 160 159 f.write("\n} ipc_command_t;\n") ··· 172 171 173 172 ''') 174 173 175 - f.write(''' 176 - static inline const char * 177 - ipc_cmd_to_str(ipc_command_t id) 178 - { 179 - \tswitch (id) { 180 - \tcase IPC_ERR: return "IPC_ERR";''') 174 + write_decl(f, return_type='static inline const char *', 175 + function_name='ipc_cmd_to_str', args=['ipc_command_t id']) 176 + f.write('\n{') 177 + f.write('\n\tswitch (id) {') 178 + f.write('\n\tcase IPC_ERR: return "IPC_ERR";') 181 179 for call in p.calls: 182 - f.write("\n\tcase " + call.id + ": return \"" + call.id + "\";") 183 - f.write("\n\tdefault: return \"IPC_UNKNOWN\";") 184 - f.write("\n\t}\n}\n") 180 + f.write('\n\tcase ' + call.id + ': return "' + call.id + '";') 181 + f.write('\n\tdefault: return "IPC_UNKNOWN";') 182 + f.write('\n\t}\n}\n') 185 183 186 - f.write("#pragma pack (push, 1)") 184 + f.write('#pragma pack (push, 1)') 187 185 188 186 for call in p.calls: 189 187 # Should we emit a msg struct. 190 188 if call.needs_msg_struct: 191 - f.write("\nstruct ipc_" + call.name + "_msg\n") 192 - f.write("{\n") 193 - f.write("\tenum ipc_command cmd;\n") 189 + f.write('\nstruct ipc_' + call.name + '_msg\n') 190 + f.write('{\n') 191 + f.write('\tenum ipc_command cmd;\n') 194 192 for arg in call.in_args: 195 - f.write("\t" + arg.get_struct_field() + ";\n") 193 + f.write('\t' + arg.get_struct_field() + ';\n') 196 194 if call.in_handles: 197 - f.write("\t%s %s;\n" % (call.in_handles.count_arg_type, 195 + f.write('\t%s %s;\n' % (call.in_handles.count_arg_type, 198 196 call.in_handles.count_arg_name)) 199 - f.write("};\n") 197 + f.write('};\n') 200 198 # Should we emit a reply struct. 201 199 if call.out_args: 202 - f.write("\nstruct ipc_" + call.name + "_reply\n") 203 - f.write("{\n") 204 - f.write("\txrt_result_t result;\n") 200 + f.write('\nstruct ipc_' + call.name + '_reply\n') 201 + f.write('{\n') 202 + f.write('\txrt_result_t result;\n') 205 203 for arg in call.out_args: 206 - f.write("\t" + arg.get_struct_field() + ";\n") 207 - f.write("};\n") 204 + f.write('\t' + arg.get_struct_field() + ';\n') 205 + f.write('};\n') 208 206 209 - f.write("#pragma pack (pop)\n") 207 + f.write('#pragma pack (pop)\n') 210 208 211 209 write_cpp_header_guard_end(f) 212 210 f.close()