mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-11-26 09:28:01 -05:00
Fix reccmp html output for template functions (#296)
This commit is contained in:
parent
343b0ff3cb
commit
abcc3afb31
2 changed files with 35 additions and 23 deletions
|
@ -10,7 +10,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import colorama
|
import colorama
|
||||||
import html
|
import json
|
||||||
import re
|
import re
|
||||||
from isledecomp.dir import walk_source_dir
|
from isledecomp.dir import walk_source_dir
|
||||||
from isledecomp.parser import find_code_blocks
|
from isledecomp.parser import find_code_blocks
|
||||||
|
@ -526,14 +526,16 @@ def can_resolve_register_differences(original_asm, new_asm):
|
||||||
|
|
||||||
# If html, record the diffs to an HTML file
|
# If html, record the diffs to an HTML file
|
||||||
if html_path:
|
if html_path:
|
||||||
escaped = html.escape('\\n'.join(udiff).replace('"', '\\"').replace('\n', '\\n'))
|
htmlinsert.append({"address": f"0x{addr:x}",
|
||||||
htmlinsert.append(f'{{address: "0x{addr:x}", name: "{html.escape(recinfo.name)}", matching: {effective_ratio}, diff: "{escaped}"}}')
|
"name": recinfo.name,
|
||||||
|
"matching": effective_ratio,
|
||||||
|
"diff": '\n'.join(udiff)})
|
||||||
|
|
||||||
|
|
||||||
def gen_html(html_file, data):
|
def gen_html(html_file, data):
|
||||||
output_data = Renderer().render_path(get_file_in_script_dir('template.html'),
|
output_data = Renderer().render_path(get_file_in_script_dir('template.html'),
|
||||||
{
|
{
|
||||||
"data": ','.join(data)
|
"data": data,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -564,7 +566,7 @@ def gen_svg(svg_file, name_svg, icon, svg_implemented_funcs, total_funcs, raw_ac
|
||||||
|
|
||||||
|
|
||||||
if html_path:
|
if html_path:
|
||||||
gen_html(html_path, htmlinsert)
|
gen_html(html_path, json.dumps(htmlinsert))
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
if not found_verbose_target:
|
if not found_verbose_target:
|
||||||
|
|
|
@ -64,6 +64,11 @@
|
||||||
color: #80FF80;
|
color: #80FF80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.identical {
|
||||||
|
font-style: italic;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
#sortind {
|
#sortind {
|
||||||
margin: 0 0.5em;
|
margin: 0 0.5em;
|
||||||
}
|
}
|
||||||
|
@ -75,23 +80,23 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
var data = [{{{data}}}];
|
var data = {{{data}}};
|
||||||
|
|
||||||
|
function diffCssClass(firstChar) {
|
||||||
|
return firstChar === '-' ? 'diffneg' : (firstChar === '+' ? 'diffpos' : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function asmLineToDiv(line) {
|
||||||
|
const diff_line = document.createElement('div');
|
||||||
|
diff_line.className = diffCssClass(line[0]);
|
||||||
|
diff_line.innerText = line;
|
||||||
|
return diff_line;
|
||||||
|
}
|
||||||
|
|
||||||
function formatAsm(asm) {
|
function formatAsm(asm) {
|
||||||
var lines = asm.split('\n');
|
var lines = asm.split('\n');
|
||||||
|
return lines.filter(line => line.length > 0)
|
||||||
for (var i = 0; i < lines.length; i++) {
|
.map(asmLineToDiv);
|
||||||
var l = lines[i];
|
|
||||||
if (l.length > 0) {
|
|
||||||
if (l[0] == '-') {
|
|
||||||
lines[i] = '<span class="diffneg">' + l + '</span>';
|
|
||||||
} else if (l[0] == '+') {
|
|
||||||
lines[i] = '<span class="diffpos">' + l + '</span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lines.join('<br>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowClick() {
|
function rowClick() {
|
||||||
|
@ -105,11 +110,16 @@
|
||||||
decCel.colSpan = 3;
|
decCel.colSpan = 3;
|
||||||
var diff = data[this.dataset.index].diff;
|
var diff = data[this.dataset.index].diff;
|
||||||
if (diff == '') {
|
if (diff == '') {
|
||||||
diff = '<center><i>Identical function - no diff</i></center>';
|
diff = document.createElement('div');
|
||||||
|
diff.className = 'identical';
|
||||||
|
diff.innerText = 'Identical function - no diff';
|
||||||
|
decCel.appendChild(diff);
|
||||||
} else {
|
} else {
|
||||||
diff = formatAsm(diff);
|
diff = formatAsm(diff);
|
||||||
|
for (const el of diff) {
|
||||||
|
decCel.appendChild(el);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
decCel.innerHTML = diff;
|
|
||||||
this.dataset.expanded = true;
|
this.dataset.expanded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,8 +229,8 @@
|
||||||
var nameCel = row.appendChild(document.createElement('td'));
|
var nameCel = row.appendChild(document.createElement('td'));
|
||||||
var matchCel = row.appendChild(document.createElement('td'));
|
var matchCel = row.appendChild(document.createElement('td'));
|
||||||
|
|
||||||
addrCel.innerHTML = addrCel.dataset.value = element.address;
|
addrCel.innerText = addrCel.dataset.value = element.address;
|
||||||
nameCel.innerHTML = nameCel.dataset.value = element.name;
|
nameCel.innerText = nameCel.dataset.value = element.name;
|
||||||
|
|
||||||
var effectiveNote = (element.matching == 1 && element.diff != '') ? '*' : '';
|
var effectiveNote = (element.matching == 1 && element.diff != '') ? '*' : '';
|
||||||
matchCel.innerHTML = (element.matching * 100).toFixed(2) + '%' + effectiveNote;
|
matchCel.innerHTML = (element.matching * 100).toFixed(2) + '%' + effectiveNote;
|
||||||
|
|
Loading…
Reference in a new issue