MCPcopy Create free account
hub / github.com/Inori/GPCS4 / write_function_array

Function write_function_array

Tools/Pm4Plugin.py:332–366  ·  view source on GitHub ↗
(table)

Source from the content-addressed store, hash-verified

330
331
332def 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
369def get_comment_func_body(code_lines):

Callers 1

process_tableFunction · 0.85

Calls 8

get_proxy_func_nameFunction · 0.85
get_max_codeFunction · 0.85
rangeClass · 0.85
get_code_nameFunction · 0.85
appendMethod · 0.45
formatMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected