(table)
| 330 | |
| 331 | |
| 332 | def write_function_array(table): |
| 333 | |
| 334 | op_dic = {} |
| 335 | for (gnm_name, packet_count, pm4type, opcode, handler, code_lines) in table: |
| 336 | if opcode not in op_dic: |
| 337 | op_dic[opcode] = [] |
| 338 | |
| 339 | proxy_name = get_proxy_func_name(gnm_name) |
| 340 | op_dic[opcode].append(proxy_name) |
| 341 | |
| 342 | ordered_table = OrderedDict(sorted(op_dic.items(), key=lambda obj: obj[0])) |
| 343 | |
| 344 | fout = open('PacketArray.cpp', 'w') |
| 345 | max_code, max_sub_code = get_max_code(table) |
| 346 | head = 'const std::array<const std::array<ProxyFunction, {}>, {}> m_proxyTable = {{ {{\n'.format(max_sub_code + 1, max_code + 1) |
| 347 | fout.write(head) |
| 348 | last_opcode = -1 |
| 349 | for opcode, proxy_list in ordered_table.items(): |
| 350 | |
| 351 | for i in range(last_opcode + 1, opcode): |
| 352 | fout.write('\t// {}\n'.format(get_code_name(i))) |
| 353 | fout.write('\t{ nullptr },\n') |
| 354 | last_opcode = opcode |
| 355 | |
| 356 | fout.write('\t// {}\n'.format(get_code_name(opcode))) |
| 357 | fout.write('\t{\n') |
| 358 | for proxy_func in proxy_list: |
| 359 | fout.write('\t\t&{},\n'.format(proxy_func)) |
| 360 | fout.write('\t\tnullptr,\n') |
| 361 | |
| 362 | fout.write('\t},\n') |
| 363 | fout.write('\n') |
| 364 | |
| 365 | fout.write('} };\n') |
| 366 | fout.close() |
| 367 | |
| 368 | |
| 369 | def get_comment_func_body(code_lines): |
no test coverage detected