mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Remove hex::format, improve format and logging type safety
This commit is contained in:
@@ -67,7 +67,7 @@ namespace hex::plugin::disasm {
|
||||
disassembly.operators = m_instruction->op_str;
|
||||
|
||||
for (u16 j = 0; j < m_instruction->size; j++)
|
||||
disassembly.bytes += hex::format("{0:02X} ", m_instruction->bytes[j]);
|
||||
disassembly.bytes += fmt::format("{0:02X} ", m_instruction->bytes[j]);
|
||||
disassembly.bytes.pop_back();
|
||||
|
||||
return disassembly;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace hex::plugin::disasm {
|
||||
disassembly.operators = instruction.operands;
|
||||
|
||||
for (u8 byte : instruction.bytes)
|
||||
disassembly.bytes += hex::format("{0:02X} ", byte);
|
||||
disassembly.bytes += fmt::format("{0:02X} ", byte);
|
||||
if (!disassembly.bytes.empty())
|
||||
disassembly.bytes.pop_back();
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace hex::plugin::disasm {
|
||||
else if (equalsIgnoreCase(syntaxString, "motorola"))
|
||||
syntax = CS_OPT_SYNTAX_MOTOROLA;
|
||||
else
|
||||
err::E0012.throwError(hex::format("Invalid disassembler syntax name '{}'", syntaxString));
|
||||
err::E0012.throwError(fmt::format("Invalid disassembler syntax name '{}'", syntaxString));
|
||||
|
||||
cs_option(capstone, CS_OPT_SYNTAX, syntax);
|
||||
cs_option(capstone, CS_OPT_SKIPDATA, CS_OPT_ON);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace hex::plugin::disasm {
|
||||
|
||||
size_t instructionCount = cs_disasm(capstone, data.data(), data.size(), u64(baseAddress), 0, &instructions);
|
||||
for (size_t i = 0; i < instructionCount; i++) {
|
||||
disassembly.push_back({ instructions[i].address, { instructions[i].bytes, instructions[i].bytes + instructions[i].size }, hex::format("{} {}", instructions[i].mnemonic, instructions[i].op_str) });
|
||||
disassembly.push_back({ instructions[i].address, { instructions[i].bytes, instructions[i].bytes + instructions[i].size }, fmt::format("{} {}", instructions[i].mnemonic, instructions[i].op_str) });
|
||||
}
|
||||
cs_free(instructions, instructionCount);
|
||||
cs_close(&capstone);
|
||||
@@ -58,7 +58,7 @@ namespace hex::plugin::disasm {
|
||||
ImGui::TableNextColumn();
|
||||
std::string bytes;
|
||||
for (auto byte : entry.bytes)
|
||||
bytes += hex::format("{0:02X} ", byte);
|
||||
bytes += fmt::format("{0:02X} ", byte);
|
||||
ImGui::TextUnformatted(bytes.c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(entry.instruction.c_str());
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace hex::plugin::disasm {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [this, provider](const std::fs::path &path) {
|
||||
auto p = path;
|
||||
if (p.extension() != ".asm")
|
||||
p.replace_filename(hex::format("{}{}", p.filename().string(), ".asm"));
|
||||
p.replace_filename(fmt::format("{}{}", p.filename().string(), ".asm"));
|
||||
auto file = wolv::io::File(p, wolv::io::File::Mode::Create);
|
||||
|
||||
if (!file.isValid()) {
|
||||
@@ -126,9 +126,9 @@ namespace hex::plugin::disasm {
|
||||
continue;
|
||||
|
||||
if (instruction.operators.empty())
|
||||
file.writeString(hex::format("{}\n", instruction.mnemonic));
|
||||
file.writeString(fmt::format("{}\n", instruction.mnemonic));
|
||||
else
|
||||
file.writeString(hex::format("{} {}\n", instruction.mnemonic, instruction.operators));
|
||||
file.writeString(fmt::format("{} {}\n", instruction.mnemonic, instruction.operators));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user