1
0
mirror of synced 2025-02-20 20:21:33 +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();
} }
@ -120,7 +124,7 @@ namespace hex {
void addDangerousFunction(const Namespace &ns, const std::string &name, u32 parameterCount, const Callback &func); void addDangerousFunction(const Namespace &ns, const std::string &name, u32 parameterCount, const Callback &func);
std::map<std::string, ContentRegistry::PatternLanguage::Function> &getFunctions(); std::map<std::string, ContentRegistry::PatternLanguage::Function> &getFunctions();
std::vector<impl::ColorPalette>& getPalettes(); std::vector<impl::ColorPalette> &getPalettes();
void addColorPalette(const std::string &unlocalizedName, const std::vector<u32> &colors); void addColorPalette(const std::string &unlocalizedName, const std::vector<u32> &colors);
void setSelectedPalette(u32 index); void setSelectedPalette(u32 index);
u32 getNextColor(); u32 getNextColor();

View File

@ -93,7 +93,7 @@ namespace hex {
Task createTask(const std::string &unlocalizedName, u64 maxValue); Task createTask(const std::string &unlocalizedName, u64 maxValue);
void doLater(const std::function<void()> &function); void doLater(const std::function<void()> &function);
std::vector<std::function<void()>>& getDeferredCalls(); std::vector<std::function<void()>> &getDeferredCalls();
} }
@ -116,7 +116,7 @@ namespace hex {
char **envp; char **envp;
}; };
const ProgramArguments& getProgramArguments(); const ProgramArguments &getProgramArguments();
float getTargetFPS(); float getTargetFPS();
void setTargetFPS(float fps); void setTargetFPS(float fps);
@ -127,7 +127,7 @@ namespace hex {
ImVec2 getMainWindowSize(); ImVec2 getMainWindowSize();
ImGuiID getMainDockSpaceId(); ImGuiID getMainDockSpaceId();
std::map<std::string, std::string>& getInitArguments(); std::map<std::string, std::string> &getInitArguments();
} }

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

@ -37,7 +37,7 @@ namespace hex {
using GetPluginDescriptionFunc = const char *(*)(); using GetPluginDescriptionFunc = const char *(*)();
using GetCompatibleVersionFunc = const char *(*)(); using GetCompatibleVersionFunc = const char *(*)();
using SetImGuiContextFunc = void (*)(ImGuiContext *); using SetImGuiContextFunc = void (*)(ImGuiContext *);
using IsBuiltinPluginFunc = bool(*)(); using IsBuiltinPluginFunc = bool (*)();
void *m_handle = nullptr; void *m_handle = nullptr;
fs::path m_path; fs::path m_path;

View File

@ -24,8 +24,8 @@ namespace hex {
[[nodiscard]] bool isPending() const; [[nodiscard]] bool isPending() const;
static size_t getRunningTaskCount(); static size_t getRunningTaskCount();
static std::list<Task *>& getRunningTasks() { return Task::s_runningTasks; } static std::list<Task *> &getRunningTasks() { return Task::s_runningTasks; }
static std::mutex& getTaskMutex() { return Task::s_taskMutex; } static std::mutex &getTaskMutex() { return Task::s_taskMutex; }
private: private:
std::string m_name; std::string m_name;

View File

@ -166,7 +166,7 @@ namespace hex {
template<typename T> template<typename T>
class Cloneable { class Cloneable {
public: public:
[[nodiscard]] virtual T* clone() const = 0; [[nodiscard]] virtual T *clone() const = 0;
}; };
} }

View File

@ -81,7 +81,7 @@ namespace hex::pl {
Attributable(const Attributable &other) { Attributable(const Attributable &other) {
for (auto &attribute : other.m_attributes) { for (auto &attribute : other.m_attributes) {
if (auto node = dynamic_cast<ASTNodeAttribute*>(attribute->clone())) if (auto node = dynamic_cast<ASTNodeAttribute *>(attribute->clone()))
this->m_attributes.push_back(node); this->m_attributes.push_back(node);
else else
delete node; delete node;
@ -455,7 +455,7 @@ namespace hex::pl {
if (auto attributable = dynamic_cast<Attributable *>(type)) { if (auto attributable = dynamic_cast<Attributable *>(type)) {
for (auto &attribute : this->getAttributes()) { for (auto &attribute : this->getAttributes()) {
if (auto node = dynamic_cast<ASTNodeAttribute*>(attribute->clone())) if (auto node = dynamic_cast<ASTNodeAttribute *>(attribute->clone()))
attributable->addAttribute(node); attributable->addAttribute(node);
else else
delete node; delete node;
@ -1536,7 +1536,7 @@ namespace hex::pl {
class ASTNodeParameterPack : public ASTNode { class ASTNodeParameterPack : public ASTNode {
public: public:
explicit ASTNodeParameterPack(std::vector<Token::Literal> values) : m_values(std::move(values)) {} explicit ASTNodeParameterPack(std::vector<Token::Literal> values) : m_values(std::move(values)) { }
[[nodiscard]] ASTNode *clone() const override { [[nodiscard]] ASTNode *clone() const override {
return new ASTNodeParameterPack(*this); return new ASTNodeParameterPack(*this);

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);
} }
@ -731,9 +722,10 @@ namespace hex::pl {
for (auto &c : buffer) for (auto &c : buffer)
c = hex::changeEndianess(c, 2, this->getEndian()); c = hex::changeEndianess(c, 2, this->getEndian());
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);
} }
@ -1404,7 +1391,7 @@ namespace hex::pl {
return false; return false;
}, },
[](std::string&) { return false; }, [](std::string &) { return false; },
[](PatternData *) { return false; } }, [](PatternData *) { return false; } },
entryValueLiteral); entryValueLiteral);
if (matches) if (matches)
@ -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

@ -49,7 +49,7 @@ namespace hex::pl {
[[nodiscard]] bool hasDangerousFunctionBeenCalled() const; [[nodiscard]] bool hasDangerousFunctionBeenCalled() const;
void allowDangerousFunctions(bool allow); void allowDangerousFunctions(bool allow);
[[nodiscard]] std::vector<PatternData*> &getPatterns() { [[nodiscard]] std::vector<PatternData *> &getPatterns() {
return this->m_patterns; return this->m_patterns;
} }
@ -67,7 +67,7 @@ namespace hex::pl {
std::optional<PatternLanguageError> m_currError; std::optional<PatternLanguageError> m_currError;
std::vector<PatternData*> m_patterns; std::vector<PatternData *> m_patterns;
bool m_running = false; bool m_running = false;
}; };

View File

@ -79,8 +79,8 @@ namespace hex::prv {
virtual void drawLoadInterface(); virtual void drawLoadInterface();
virtual void drawInterface(); virtual void drawInterface();
pl::PatternLanguage& getPatternLanguageRuntime() { return this->m_patternLanguageRuntime; } pl::PatternLanguage &getPatternLanguageRuntime() { return this->m_patternLanguageRuntime; }
std::string& getPatternLanguageSourceCode() { return this->m_patternLanguageSourceCode; } std::string &getPatternLanguageSourceCode() { return this->m_patternLanguageSourceCode; }
protected: protected:
u32 m_currPage = 0; u32 m_currPage = 0;

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;
} }
@ -67,7 +69,7 @@ namespace hex {
namespace ImHexApi::Provider { namespace ImHexApi::Provider {
static u32 s_currentProvider; static u32 s_currentProvider;
static std::vector<prv::Provider*> s_providers; static std::vector<prv::Provider *> s_providers;
prv::Provider *get() { prv::Provider *get() {
if (!ImHexApi::Provider::isValid()) if (!ImHexApi::Provider::isValid())
@ -126,7 +128,7 @@ namespace hex {
getDeferredCalls().push_back(function); getDeferredCalls().push_back(function);
} }
std::vector<std::function<void()>>& getDeferredCalls() { std::vector<std::function<void()>> &getDeferredCalls() {
return s_deferredCalls; return s_deferredCalls;
} }
@ -169,8 +171,7 @@ namespace hex {
} }
const ProgramArguments &getProgramArguments() {
const ProgramArguments& getProgramArguments() {
return impl::s_programArguments; return impl::s_programArguments;
} }
@ -203,7 +204,7 @@ namespace hex {
return impl::s_mainDockSpaceId; return impl::s_mainDockSpaceId;
} }
std::map<std::string, std::string>& getInitArguments() { std::map<std::string, std::string> &getInitArguments() {
static std::map<std::string, std::string> initArgs; static std::map<std::string, std::string> initArgs;
return initArgs; return initArgs;

View File

@ -110,12 +110,12 @@ namespace hex {
curl_easy_setopt(this->m_ctx, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(this->m_ctx, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(this->m_ctx, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(this->m_ctx, CURLOPT_NOPROGRESS, 0L);
#if defined(OS_WINDOWS) #if defined(OS_WINDOWS)
curl_easy_setopt(this->m_ctx, CURLOPT_CAINFO, nullptr); curl_easy_setopt(this->m_ctx, CURLOPT_CAINFO, nullptr);
curl_easy_setopt(this->m_ctx, CURLOPT_CAPATH, nullptr); curl_easy_setopt(this->m_ctx, CURLOPT_CAPATH, nullptr);
curl_easy_setopt(this->m_ctx, CURLOPT_SSLCERTTYPE, "PEM"); curl_easy_setopt(this->m_ctx, CURLOPT_SSLCERTTYPE, "PEM");
curl_easy_setopt(this->m_ctx, CURLOPT_SSL_CTX_FUNCTION, sslCtxFunction); curl_easy_setopt(this->m_ctx, CURLOPT_SSL_CTX_FUNCTION, sslCtxFunction);
#endif #endif
} }
std::optional<i32> Net::execute() { std::optional<i32> Net::execute() {

View File

@ -170,12 +170,12 @@ namespace hex::init {
auto meanScale = std::midpoint(xScale, yScale); auto meanScale = std::midpoint(xScale, yScale);
// On Macs with a retina display (basically all modern ones we care about), the OS reports twice // On Macs with a retina display (basically all modern ones we care about), the OS reports twice
// the actual monitor scale for some obscure reason. Get rid of this here so ImHex doesn't look // the actual monitor scale for some obscure reason. Get rid of this here so ImHex doesn't look
// extremely huge with native scaling on MacOS. // extremely huge with native scaling on MacOS.
#if defined(OS_MACOS) #if defined(OS_MACOS)
meanScale /= 2; meanScale /= 2;
#endif #endif
if (meanScale <= 0) { if (meanScale <= 0) {
meanScale = 1.0; meanScale = 1.0;

View File

@ -301,7 +301,7 @@ namespace hex::init {
std::vector<Task> getInitTasks() { std::vector<Task> getInitTasks() {
return { return {
{ "Checking for updates...", checkForUpdates }, {"Checking for updates...", checkForUpdates },
{ "Downloading information...", downloadInformation}, { "Downloading information...", downloadInformation},
{ "Creating directories...", createDirectories }, { "Creating directories...", createDirectories },
{ "Loading settings...", loadSettings }, { "Loading settings...", loadSettings },
@ -312,8 +312,8 @@ namespace hex::init {
std::vector<Task> getExitTasks() { std::vector<Task> getExitTasks() {
return { return {
{ "Saving settings...", storeSettings }, {"Saving settings...", storeSettings },
{ "Cleaning up shared data...", deleteSharedData }, { "Cleaning up shared data...", deleteSharedData},
{ "Unloading plugins...", unloadPlugins }, { "Unloading plugins...", unloadPlugins },
}; };
} }

View File

@ -136,11 +136,11 @@ namespace hex {
// Let's not loop on this... // Let's not loop on this...
std::signal(signalNumber, nullptr); std::signal(signalNumber, nullptr);
#if defined(DEBUG) #if defined(DEBUG)
assert(false); assert(false);
#else #else
std::raise(signalNumber); std::raise(signalNumber);
#endif #endif
}; };
std::signal(SIGTERM, signalHandler); std::signal(SIGTERM, signalHandler);
@ -425,7 +425,6 @@ namespace hex {
} }
void Window::drawWelcomeScreen() { void Window::drawWelcomeScreen() {
} }
void Window::resetLayout() const { void Window::resetLayout() const {

View File

@ -19,7 +19,7 @@ namespace hex::plugin::builtin {
void drawContent() override; void drawContent() override;
private: private:
std::map<prv::Provider*, std::vector<pl::PatternData*>> m_sortedPatterns; std::map<prv::Provider *, std::vector<pl::PatternData *>> m_sortedPatterns;
}; };
} }

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,16 +222,17 @@ 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[] = {
{ "hex.builtin.view.disassembler.m68k.000"_lang, CS_MODE_M68K_000 }, {"hex.builtin.view.disassembler.m68k.000"_lang, CS_MODE_M68K_000},
{ "hex.builtin.view.disassembler.m68k.010"_lang, CS_MODE_M68K_010 }, { "hex.builtin.view.disassembler.m68k.010"_lang, CS_MODE_M68K_010},
{ "hex.builtin.view.disassembler.m68k.020"_lang, CS_MODE_M68K_020 }, { "hex.builtin.view.disassembler.m68k.020"_lang, CS_MODE_M68K_020},
{ "hex.builtin.view.disassembler.m68k.030"_lang, CS_MODE_M68K_030 }, { "hex.builtin.view.disassembler.m68k.030"_lang, CS_MODE_M68K_030},
{ "hex.builtin.view.disassembler.m68k.040"_lang, CS_MODE_M68K_040 }, { "hex.builtin.view.disassembler.m68k.040"_lang, CS_MODE_M68K_040},
{ "hex.builtin.view.disassembler.m68k.060"_lang, CS_MODE_M68K_060 }, { "hex.builtin.view.disassembler.m68k.060"_lang, CS_MODE_M68K_060},
}; };
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) { if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
@ -239,11 +246,12 @@ 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[] = {
{ "hex.builtin.view.disassembler.m680x.6301"_lang, CS_MODE_M680X_6301 }, {"hex.builtin.view.disassembler.m680x.6301"_lang, CS_MODE_M680X_6301 },
{ "hex.builtin.view.disassembler.m680x.6309"_lang, CS_MODE_M680X_6309 }, { "hex.builtin.view.disassembler.m680x.6309"_lang, CS_MODE_M680X_6309 },
{ "hex.builtin.view.disassembler.m680x.6800"_lang, CS_MODE_M680X_6800 }, { "hex.builtin.view.disassembler.m680x.6800"_lang, CS_MODE_M680X_6800 },
{ "hex.builtin.view.disassembler.m680x.6801"_lang, CS_MODE_M680X_6801 }, { "hex.builtin.view.disassembler.m680x.6801"_lang, CS_MODE_M680X_6801 },
@ -251,8 +259,8 @@ namespace hex::plugin::builtin {
{ "hex.builtin.view.disassembler.m680x.6808"_lang, CS_MODE_M680X_6808 }, { "hex.builtin.view.disassembler.m680x.6808"_lang, CS_MODE_M680X_6808 },
{ "hex.builtin.view.disassembler.m680x.6809"_lang, CS_MODE_M680X_6809 }, { "hex.builtin.view.disassembler.m680x.6809"_lang, CS_MODE_M680X_6809 },
{ "hex.builtin.view.disassembler.m680x.6811"_lang, CS_MODE_M680X_6811 }, { "hex.builtin.view.disassembler.m680x.6811"_lang, CS_MODE_M680X_6811 },
{ "hex.builtin.view.disassembler.m680x.cpu12"_lang, CS_MODE_M680X_CPU12 }, { "hex.builtin.view.disassembler.m680x.cpu12"_lang, CS_MODE_M680X_CPU12},
{ "hex.builtin.view.disassembler.m680x.hcs08"_lang, CS_MODE_M680X_HCS08 }, { "hex.builtin.view.disassembler.m680x.hcs08"_lang, CS_MODE_M680X_HCS08},
}; };
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) { if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
@ -266,17 +274,18 @@ 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[] = {
{ "hex.builtin.view.disassembler.mos65xx.6502"_lang, CS_MODE_MOS65XX_6502 }, {"hex.builtin.view.disassembler.mos65xx.6502"_lang, CS_MODE_MOS65XX_6502 },
{ "hex.builtin.view.disassembler.mos65xx.65c02"_lang, CS_MODE_MOS65XX_65C02 }, { "hex.builtin.view.disassembler.mos65xx.65c02"_lang, CS_MODE_MOS65XX_65C02 },
{ "hex.builtin.view.disassembler.mos65xx.w65c02"_lang, CS_MODE_MOS65XX_W65C02 }, { "hex.builtin.view.disassembler.mos65xx.w65c02"_lang, CS_MODE_MOS65XX_W65C02 },
{ "hex.builtin.view.disassembler.mos65xx.65816"_lang, CS_MODE_MOS65XX_65816 }, { "hex.builtin.view.disassembler.mos65xx.65816"_lang, CS_MODE_MOS65XX_65816 },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_m"_lang, CS_MODE_MOS65XX_65816_LONG_M }, { "hex.builtin.view.disassembler.mos65xx.65816_long_m"_lang, CS_MODE_MOS65XX_65816_LONG_M },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_x"_lang, CS_MODE_MOS65XX_65816_LONG_X }, { "hex.builtin.view.disassembler.mos65xx.65816_long_x"_lang, CS_MODE_MOS65XX_65816_LONG_X },
{ "hex.builtin.view.disassembler.mos65xx.65816_long_mx"_lang, CS_MODE_MOS65XX_65816_LONG_MX }, { "hex.builtin.view.disassembler.mos65xx.65816_long_mx"_lang, CS_MODE_MOS65XX_65816_LONG_MX},
}; };
if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) { if (ImGui::BeginCombo("hex.builtin.view.disassembler.settings.mode"_lang, modes[selectedMode].first)) {
@ -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

@ -59,7 +59,7 @@ namespace hex::plugin::builtin {
}; };
this->m_memoryEditor.HighlightFn = [](const ImU8 *data, size_t off, bool next) -> bool { this->m_memoryEditor.HighlightFn = [](const ImU8 *data, size_t off, bool next) -> bool {
auto _this = (ViewHexEditor*)(data); auto _this = (ViewHexEditor *)(data);
std::optional<u32> currColor, prevColor; std::optional<u32> currColor, prevColor;
@ -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

@ -232,7 +232,7 @@ namespace hex::plugin::builtin {
}; };
iterator.context = &context; iterator.context = &context;
iterator.first = [](YR_MEMORY_BLOCK_ITERATOR *iterator) -> YR_MEMORY_BLOCK * { iterator.first = [](YR_MEMORY_BLOCK_ITERATOR *iterator) -> YR_MEMORY_BLOCK *{
auto &context = *static_cast<ScanContext *>(iterator->context); auto &context = *static_cast<ScanContext *>(iterator->context);
context.currBlock.base = 0; context.currBlock.base = 0;

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);
}); });
} }
@ -406,7 +405,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::write( ContentRegistry::Settings::write(
"hex.builtin.setting.imhex", "hex.builtin.setting.imhex",
"hex.builtin.setting.imhex.recent_files", "hex.builtin.setting.imhex.recent_files",
std::vector<std::string>{}); std::vector<std::string> {});
} }
ImGui::EndMenu(); ImGui::EndMenu();
@ -422,7 +421,6 @@ namespace hex::plugin::builtin {
ImGui::EndMenu(); ImGui::EndMenu();
} }
}); });