1
0
mirror of synced 2024-11-13 18:50:53 +01:00

sys: Reformat all

This commit is contained in:
WerWolv 2022-02-01 22:09:44 +01:00
parent 1991afb87b
commit ce59226909
99 changed files with 2304 additions and 2314 deletions

View File

@ -2,10 +2,10 @@
Language: Cpp Language: Cpp
# BasedOnStyle: LLVM # BasedOnStyle: LLVM
AccessModifierOffset: -4 AccessModifierOffset: -4
AlignAfterOpenBracket: Align AlignAfterOpenBracket: false
AlignArrayOfStructures: Left AlignArrayOfStructures: Left
AlignConsecutiveMacros: Consecutive AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: None AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
AlignConsecutiveDeclarations: None AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left AlignEscapedNewlines: Left
@ -13,7 +13,7 @@ AlignOperands: Align
AlignTrailingComments: true AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: false AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Always AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
@ -95,7 +95,7 @@ IncludeCategories:
IncludeIsMainRegex: '(Test)?$' IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: '' IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false IndentAccessModifiers: false
IndentCaseLabels: false IndentCaseLabels: true
IndentCaseBlocks: true IndentCaseBlocks: true
IndentGotoLabels: true IndentGotoLabels: true
IndentPPDirectives: BeforeHash IndentPPDirectives: BeforeHash

View File

@ -85,7 +85,11 @@ namespace hex {
}; };
void add( void add(
Type type, const std::string &command, const std::string &unlocalizedDescription, const DisplayCallback &displayCallback, const ExecuteCallback &executeCallback = [](auto) {}); Type type,
const std::string &command,
const std::string &unlocalizedDescription,
const DisplayCallback &displayCallback,
const ExecuteCallback &executeCallback = [](auto) {});
std::vector<Entry> &getEntries(); std::vector<Entry> &getEntries();
} }

View File

@ -187,6 +187,7 @@ namespace hex {
static void process(View *currentView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode); static void process(View *currentView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode);
static void clearShortcuts(); static void clearShortcuts();
private: private:
static std::map<Shortcut, std::function<void()>> s_globalShortcuts; static std::map<Shortcut, std::function<void()>> s_globalShortcuts;
}; };

View File

@ -69,15 +69,16 @@ namespace hex::pl {
getEvaluator()->patternDestroyed(); getEvaluator()->patternDestroyed();
} }
[[nodiscard]] [[nodiscard]] Evaluator *getEvaluator() const {
Evaluator* getEvaluator() const {
return this->m_evaluator; return this->m_evaluator;
} }
private: private:
Evaluator *m_evaluator = nullptr; Evaluator *m_evaluator = nullptr;
}; };
class PatternData : public PatternCreationLimiter, public Cloneable<PatternData> { class PatternData : public PatternCreationLimiter,
public Cloneable<PatternData> {
public: public:
PatternData(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0) PatternData(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
: PatternCreationLimiter(evaluator), m_offset(offset), m_size(size), m_color(color) { : PatternCreationLimiter(evaluator), m_offset(offset), m_size(size), m_color(color) {
@ -318,8 +319,7 @@ namespace hex::pl {
public: public:
PatternDataPadding(Evaluator *evaluator, u64 offset, size_t size) : PatternData(evaluator, offset, size, 0xFF000000) { } PatternDataPadding(Evaluator *evaluator, u64 offset, size_t size) : PatternData(evaluator, offset, size, 0xFF000000) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataPadding(*this); return new PatternDataPadding(*this);
} }
@ -347,8 +347,7 @@ namespace hex::pl {
delete this->m_pointedAt; delete this->m_pointedAt;
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataPointer(*this); return new PatternDataPointer(*this);
} }
@ -469,8 +468,7 @@ namespace hex::pl {
PatternDataUnsigned(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0) PatternDataUnsigned(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
: PatternData(evaluator, offset, size, color) { } : PatternData(evaluator, offset, size, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataUnsigned(*this); return new PatternDataUnsigned(*this);
} }
@ -507,8 +505,7 @@ namespace hex::pl {
PatternDataSigned(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0) PatternDataSigned(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
: PatternData(evaluator, offset, size, color) { } : PatternData(evaluator, offset, size, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataSigned(*this); return new PatternDataSigned(*this);
} }
@ -546,8 +543,7 @@ namespace hex::pl {
PatternDataFloat(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0) PatternDataFloat(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
: PatternData(evaluator, offset, size, color) { } : PatternData(evaluator, offset, size, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataFloat(*this); return new PatternDataFloat(*this);
} }
@ -586,8 +582,7 @@ namespace hex::pl {
explicit PatternDataBoolean(Evaluator *evaluator, u64 offset, u32 color = 0) explicit PatternDataBoolean(Evaluator *evaluator, u64 offset, u32 color = 0)
: PatternData(evaluator, offset, 1, color) { } : PatternData(evaluator, offset, 1, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataBoolean(*this); return new PatternDataBoolean(*this);
} }
@ -615,8 +610,7 @@ namespace hex::pl {
explicit PatternDataCharacter(Evaluator *evaluator, u64 offset, u32 color = 0) explicit PatternDataCharacter(Evaluator *evaluator, u64 offset, u32 color = 0)
: PatternData(evaluator, offset, 1, color) { } : PatternData(evaluator, offset, 1, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataCharacter(*this); return new PatternDataCharacter(*this);
} }
@ -639,8 +633,7 @@ namespace hex::pl {
explicit PatternDataCharacter16(Evaluator *evaluator, u64 offset, u32 color = 0) explicit PatternDataCharacter16(Evaluator *evaluator, u64 offset, u32 color = 0)
: PatternData(evaluator, offset, 2, color) { } : PatternData(evaluator, offset, 2, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataCharacter16(*this); return new PatternDataCharacter16(*this);
} }
@ -673,8 +666,7 @@ namespace hex::pl {
PatternDataString(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0) PatternDataString(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
: PatternData(evaluator, offset, size, color) { } : PatternData(evaluator, offset, size, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataString(*this); return new PatternDataString(*this);
} }
@ -714,8 +706,7 @@ namespace hex::pl {
PatternDataString16(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0) PatternDataString16(Evaluator *evaluator, u64 offset, size_t size, u32 color = 0)
: PatternData(evaluator, offset, size, color) { } : PatternData(evaluator, offset, size, color) { }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataString16(*this); return new PatternDataString16(*this);
} }
@ -733,7 +724,8 @@ namespace hex::pl {
buffer.erase(std::remove_if(buffer.begin(), buffer.end(), [](auto c) { buffer.erase(std::remove_if(buffer.begin(), buffer.end(), [](auto c) {
return c == 0x00; return c == 0x00;
}), buffer.end()); }),
buffer.end());
auto utf8String = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(buffer); auto utf8String = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(buffer);
@ -781,8 +773,7 @@ namespace hex::pl {
delete entry; delete entry;
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataDynamicArray(*this); return new PatternDataDynamicArray(*this);
} }
@ -934,8 +925,7 @@ namespace hex::pl {
delete this->m_highlightTemplate; delete this->m_highlightTemplate;
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataStaticArray(*this); return new PatternDataStaticArray(*this);
} }
@ -1094,8 +1084,7 @@ namespace hex::pl {
delete member; delete member;
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataStruct(*this); return new PatternDataStruct(*this);
} }
@ -1242,8 +1231,7 @@ namespace hex::pl {
delete member; delete member;
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataUnion(*this); return new PatternDataUnion(*this);
} }
@ -1380,8 +1368,7 @@ namespace hex::pl {
: PatternData(evaluator, offset, size, color) { : PatternData(evaluator, offset, size, color) {
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataEnum(*this); return new PatternDataEnum(*this);
} }
@ -1476,8 +1463,7 @@ namespace hex::pl {
: PatternData(evaluator, offset, 0, color), m_bitOffset(bitOffset), m_bitSize(bitSize), m_bitField(bitField) { : PatternData(evaluator, offset, 0, color), m_bitOffset(bitOffset), m_bitSize(bitSize), m_bitField(bitField) {
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataBitfieldField(*this); return new PatternDataBitfieldField(*this);
} }
@ -1556,8 +1542,7 @@ namespace hex::pl {
delete field; delete field;
} }
[[nodiscard]] [[nodiscard]] PatternData *clone() const override {
PatternData *clone() const override {
return new PatternDataBitfield(*this); return new PatternDataBitfield(*this);
} }

View File

@ -219,10 +219,8 @@ namespace hex {
} }
void ContentRegistry::PatternLanguage::addColorPalette(const std::string &unlocalizedName, const std::vector<u32> &colors) { void ContentRegistry::PatternLanguage::addColorPalette(const std::string &unlocalizedName, const std::vector<u32> &colors) {
s_colorPalettes.push_back({ s_colorPalettes.push_back({ unlocalizedName,
unlocalizedName, colors });
colors
});
} }
void ContentRegistry::PatternLanguage::setSelectedPalette(u32 index) { void ContentRegistry::PatternLanguage::setSelectedPalette(u32 index) {

View File

@ -35,7 +35,9 @@ namespace hex {
u32 addHighlight(const Region &region, color_t color, std::string tooltip) { u32 addHighlight(const Region &region, color_t color, std::string tooltip) {
auto id = s_highlights.size(); auto id = s_highlights.size();
s_highlights.insert({ id, Highlighting{ region, color, tooltip } }); s_highlights.insert({
id, Highlighting {region, color, tooltip}
});
return id; return id;
} }
@ -169,7 +171,6 @@ namespace hex {
} }
const ProgramArguments &getProgramArguments() { const ProgramArguments &getProgramArguments() {
return impl::s_programArguments; return impl::s_programArguments;
} }

View File

@ -425,7 +425,6 @@ namespace hex {
} }
void Window::drawWelcomeScreen() { void Window::drawWelcomeScreen() {
} }
void Window::resetLayout() const { void Window::resetLayout() const {

View File

@ -507,7 +507,6 @@ namespace hex::plugin::builtin {
ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atanh", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> { ContentRegistry::PatternLanguage::addFunction(nsStdMath, "atanh", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
return std::atanh(Token::literalToFloatingPoint(params[0])); return std::atanh(Token::literalToFloatingPoint(params[0]));
}); });
} }
} }

View File

@ -19,15 +19,13 @@ namespace hex::plugin::builtin {
color = ImGui::GetColorU32(ImGuiCol_Header); color = ImGui::GetColorU32(ImGuiCol_Header);
this->m_bookmarks.push_back({ this->m_bookmarks.push_back({ region,
region,
name, name,
std::move(comment), std::move(comment),
color, color,
false, false,
ImHexApi::HexEditor::addHighlight(region, color, name) ImHexApi::HexEditor::addHighlight(region, color, name) });
});
ProjectFile::markDirty(); ProjectFile::markDirty();
}); });

View File

@ -136,7 +136,8 @@ namespace hex::plugin::builtin {
ImGui::NewLine(); ImGui::NewLine();
switch (this->m_architecture) { switch (this->m_architecture) {
case Architecture::ARM: { case Architecture::ARM:
{
static int mode = CS_MODE_ARM; static int mode = CS_MODE_ARM;
ImGui::RadioButton("hex.builtin.view.disassembler.arm.arm"_lang, &mode, CS_MODE_ARM); ImGui::RadioButton("hex.builtin.view.disassembler.arm.arm"_lang, &mode, CS_MODE_ARM);
ImGui::SameLine(); ImGui::SameLine();
@ -152,7 +153,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(mode | extraMode); this->m_mode = cs_mode(mode | extraMode);
} }
break; break;
case Architecture::MIPS: { case Architecture::MIPS:
{
static int mode = CS_MODE_MIPS32; static int mode = CS_MODE_MIPS32;
ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips32"_lang, &mode, CS_MODE_MIPS32); ImGui::RadioButton("hex.builtin.view.disassembler.mips.mips32"_lang, &mode, CS_MODE_MIPS32);
ImGui::SameLine(); ImGui::SameLine();
@ -170,7 +172,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(mode | (microMode ? CS_MODE_MICRO : 0)); this->m_mode = cs_mode(mode | (microMode ? CS_MODE_MICRO : 0));
} }
break; break;
case Architecture::X86: { case Architecture::X86:
{
static int mode = CS_MODE_32; static int mode = CS_MODE_32;
ImGui::RadioButton("hex.builtin.view.disassembler.16bit"_lang, &mode, CS_MODE_16); ImGui::RadioButton("hex.builtin.view.disassembler.16bit"_lang, &mode, CS_MODE_16);
ImGui::SameLine(); ImGui::SameLine();
@ -181,7 +184,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(mode); this->m_mode = cs_mode(mode);
} }
break; break;
case Architecture::PPC: { case Architecture::PPC:
{
static int mode = CS_MODE_32; static int mode = CS_MODE_32;
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_32); ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_32);
ImGui::SameLine(); ImGui::SameLine();
@ -197,14 +201,16 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(mode | (qpx ? CS_MODE_QPX : 0) | (spe ? CS_MODE_SPE : 0) | (booke ? CS_MODE_BOOKE : 0)); this->m_mode = cs_mode(mode | (qpx ? CS_MODE_QPX : 0) | (spe ? CS_MODE_SPE : 0) | (booke ? CS_MODE_BOOKE : 0));
} }
break; break;
case Architecture::SPARC: { case Architecture::SPARC:
{
static bool v9Mode = false; static bool v9Mode = false;
ImGui::Checkbox("hex.builtin.view.disassembler.sparc.v9"_lang, &v9Mode); ImGui::Checkbox("hex.builtin.view.disassembler.sparc.v9"_lang, &v9Mode);
this->m_mode = cs_mode(v9Mode ? CS_MODE_V9 : 0); this->m_mode = cs_mode(v9Mode ? CS_MODE_V9 : 0);
} }
break; break;
case Architecture::RISCV: { case Architecture::RISCV:
{
static int mode = CS_MODE_RISCV32; static int mode = CS_MODE_RISCV32;
ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_RISCV32); ImGui::RadioButton("hex.builtin.view.disassembler.32bit"_lang, &mode, CS_MODE_RISCV32);
ImGui::SameLine(); ImGui::SameLine();
@ -216,7 +222,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(mode | (compressed ? CS_MODE_RISCVC : 0)); this->m_mode = cs_mode(mode | (compressed ? CS_MODE_RISCVC : 0));
} }
break; break;
case Architecture::M68K: { case Architecture::M68K:
{
static int selectedMode = 0; static int selectedMode = 0;
std::pair<const char *, cs_mode> modes[] = { std::pair<const char *, cs_mode> modes[] = {
@ -239,7 +246,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(modes[selectedMode].second); this->m_mode = cs_mode(modes[selectedMode].second);
} }
break; break;
case Architecture::M680X: { case Architecture::M680X:
{
static int selectedMode = 0; static int selectedMode = 0;
std::pair<const char *, cs_mode> modes[] = { std::pair<const char *, cs_mode> modes[] = {
@ -266,7 +274,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(modes[selectedMode].second); this->m_mode = cs_mode(modes[selectedMode].second);
} }
break; break;
case Architecture::MOS65XX: { case Architecture::MOS65XX:
{
static int selectedMode = 0; static int selectedMode = 0;
std::pair<const char *, cs_mode> modes[] = { std::pair<const char *, cs_mode> modes[] = {
@ -290,7 +299,8 @@ namespace hex::plugin::builtin {
this->m_mode = cs_mode(modes[selectedMode].second); this->m_mode = cs_mode(modes[selectedMode].second);
} }
break; break;
case Architecture::BPF: { case Architecture::BPF:
{
static int mode = CS_MODE_BPF_CLASSIC; static int mode = CS_MODE_BPF_CLASSIC;
ImGui::RadioButton("hex.builtin.view.disassembler.bpf.classic"_lang, &mode, CS_MODE_BPF_CLASSIC); ImGui::RadioButton("hex.builtin.view.disassembler.bpf.classic"_lang, &mode, CS_MODE_BPF_CLASSIC);
ImGui::SameLine(); ImGui::SameLine();

View File

@ -972,7 +972,6 @@ namespace hex::plugin::builtin {
bool providerValid = ImHexApi::Provider::isValid(); bool providerValid = ImHexApi::Provider::isValid();
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save"_lang, "CTRL + S", false, providerValid && provider->isWritable())) { if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save"_lang, "CTRL + S", false, providerValid && provider->isWritable())) {
save(); save();
} }

View File

@ -323,15 +323,11 @@ namespace hex::plugin::builtin {
ImGui::NewLine(); ImGui::NewLine();
View::confirmButtons( View::confirmButtons(
"hex.common.yes"_lang, "hex.common.no"_lang, "hex.common.yes"_lang, "hex.common.no"_lang, [] {
[] {
ImHexApi::Provider::get()->getPatternLanguageRuntime().allowDangerousFunctions(true); ImHexApi::Provider::get()->getPatternLanguageRuntime().allowDangerousFunctions(true);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup(); }, [] {
},
[] {
ImHexApi::Provider::get()->getPatternLanguageRuntime().allowDangerousFunctions(false); ImHexApi::Provider::get()->getPatternLanguageRuntime().allowDangerousFunctions(false);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup(); });
});
ImGui::EndPopup(); ImGui::EndPopup();
} }
@ -651,7 +647,9 @@ namespace hex::plugin::builtin {
if (!result) { if (!result) {
auto error = runtime.getError(); auto error = runtime.getError();
if (error) { if (error) {
TextEditor::ErrorMarkers errorMarkers = { { error->getLineNumber(), error->what() } }; TextEditor::ErrorMarkers errorMarkers = {
{error->getLineNumber(), error->what()}
};
this->m_textEditor.SetErrorMarkers(errorMarkers); this->m_textEditor.SetErrorMarkers(errorMarkers);
} }
} }

View File

@ -387,8 +387,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1050, [&] { ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1050, [&] {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) { if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, {}, hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, {}, [](const auto &path) {
[](const auto &path) {
EventManager::post<RequestOpenFile>(path); EventManager::post<RequestOpenFile>(path);
}); });
} }
@ -422,7 +421,6 @@ namespace hex::plugin::builtin {
ImGui::EndMenu(); ImGui::EndMenu();
} }
}); });