sys: First attempt at reducing build times
This commit is contained in:
parent
f60f9f9fc9
commit
02d31d2d2a
3811
external/nlohmann_json/include/nlohmann/json.hpp
vendored
3811
external/nlohmann_json/include/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
78
external/nlohmann_json/include/nlohmann/json_fwd.hpp
vendored
Normal file
78
external/nlohmann_json/include/nlohmann/json_fwd.hpp
vendored
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||||
|
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
||||||
|
|
||||||
|
#include <cstdint> // int64_t, uint64_t
|
||||||
|
#include <map> // map
|
||||||
|
#include <memory> // allocator
|
||||||
|
#include <string> // string
|
||||||
|
#include <vector> // vector
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief namespace for Niels Lohmann
|
||||||
|
@see https://github.com/nlohmann
|
||||||
|
@since version 1.0.0
|
||||||
|
*/
|
||||||
|
namespace nlohmann
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
@brief default JSONSerializer template argument
|
||||||
|
|
||||||
|
This serializer ignores the template arguments and uses ADL
|
||||||
|
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
|
||||||
|
for serialization.
|
||||||
|
*/
|
||||||
|
template<typename T = void, typename SFINAE = void>
|
||||||
|
struct adl_serializer;
|
||||||
|
|
||||||
|
template<template<typename U, typename V, typename... Args> class ObjectType =
|
||||||
|
std::map,
|
||||||
|
template<typename U, typename... Args> class ArrayType = std::vector,
|
||||||
|
class StringType = std::string, class BooleanType = bool,
|
||||||
|
class NumberIntegerType = std::int64_t,
|
||||||
|
class NumberUnsignedType = std::uint64_t,
|
||||||
|
class NumberFloatType = double,
|
||||||
|
template<typename U> class AllocatorType = std::allocator,
|
||||||
|
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||||
|
adl_serializer,
|
||||||
|
class BinaryType = std::vector<std::uint8_t>>
|
||||||
|
class basic_json;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief JSON Pointer
|
||||||
|
|
||||||
|
A JSON pointer defines a string syntax for identifying a specific value
|
||||||
|
within a JSON document. It can be used with functions `at` and
|
||||||
|
`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
|
||||||
|
|
||||||
|
@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
|
||||||
|
|
||||||
|
@since version 2.0.0
|
||||||
|
*/
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
class json_pointer;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief default JSON class
|
||||||
|
|
||||||
|
This type is the default specialization of the @ref basic_json class which
|
||||||
|
uses the standard template types.
|
||||||
|
|
||||||
|
@since version 1.0.0
|
||||||
|
*/
|
||||||
|
using json = basic_json<>;
|
||||||
|
|
||||||
|
template<class Key, class T, class IgnoredLess, class Allocator>
|
||||||
|
struct ordered_map;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief ordered JSON class
|
||||||
|
|
||||||
|
This type preserves the insertion order of object keys.
|
||||||
|
|
||||||
|
@since version 3.9.0
|
||||||
|
*/
|
||||||
|
using ordered_json = basic_json<nlohmann::ordered_map>;
|
||||||
|
|
||||||
|
} // namespace nlohmann
|
||||||
|
|
||||||
|
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
#include "math_evaluator.hpp"
|
#include "math_evaluator.hpp"
|
||||||
|
|
||||||
@ -6,8 +6,8 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
void registerCommandPaletteCommands() {
|
void registerCommandPaletteCommands() {
|
||||||
|
|
||||||
hex::ContentRegistry::CommandPaletteCommands::add(
|
ContentRegistry::CommandPaletteCommands::add(
|
||||||
hex::ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
||||||
"#", "hex.builtin.command.calc.desc",
|
"#", "hex.builtin.command.calc.desc",
|
||||||
[](auto input) {
|
[](auto input) {
|
||||||
hex::MathEvaluator evaluator;
|
hex::MathEvaluator evaluator;
|
||||||
@ -27,8 +27,8 @@ namespace hex::plugin::builtin {
|
|||||||
return hex::format("#{0} = ???", input.data());
|
return hex::format("#{0} = ???", input.data());
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::CommandPaletteCommands::add(
|
ContentRegistry::CommandPaletteCommands::add(
|
||||||
hex::ContentRegistry::CommandPaletteCommands::Type::KeywordCommand,
|
ContentRegistry::CommandPaletteCommands::Type::KeywordCommand,
|
||||||
"/web", "hex.builtin.command.web.desc",
|
"/web", "hex.builtin.command.web.desc",
|
||||||
[](auto input) {
|
[](auto input) {
|
||||||
return hex::format("hex.builtin.command.web.result"_lang, input.data());
|
return hex::format("hex.builtin.command.web.result"_lang, input.data());
|
||||||
@ -37,8 +37,8 @@ namespace hex::plugin::builtin {
|
|||||||
hex::openWebpage(input);
|
hex::openWebpage(input);
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::CommandPaletteCommands::add(
|
ContentRegistry::CommandPaletteCommands::add(
|
||||||
hex::ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
||||||
"$", "hex.builtin.command.cmd.desc",
|
"$", "hex.builtin.command.cmd.desc",
|
||||||
[](auto input) {
|
[](auto input) {
|
||||||
return hex::format("hex.builtin.command.cmd.result"_lang, input.data());
|
return hex::format("hex.builtin.command.cmd.result"_lang, input.data());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
@ -18,9 +18,9 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
void registerDataInspectorEntries() {
|
void registerDataInspectorEntries() {
|
||||||
|
|
||||||
using Style = hex::ContentRegistry::DataInspector::NumberDisplayStyle;
|
using Style = ContentRegistry::DataInspector::NumberDisplayStyle;
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.binary", sizeof(u8), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.binary", sizeof(u8), [](auto buffer, auto endian, auto style) {
|
||||||
std::string binary;
|
std::string binary;
|
||||||
for (u8 i = 0; i < 8; i++)
|
for (u8 i = 0; i < 8; i++)
|
||||||
binary += ((buffer[0] << i) & 0x80) == 0 ? '0' : '1';
|
binary += ((buffer[0] << i) & 0x80) == 0 ? '0' : '1';
|
||||||
@ -31,76 +31,76 @@ namespace hex::plugin::builtin {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u8", sizeof(u8), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.u8", sizeof(u8), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, *reinterpret_cast<u8*>(buffer.data()));
|
auto value = hex::format(format, *reinterpret_cast<u8*>(buffer.data()));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s8", sizeof(s8), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.s8", sizeof(s8), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, *reinterpret_cast<s8*>(buffer.data()));
|
auto value = hex::format(format, *reinterpret_cast<s8*>(buffer.data()));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u16", sizeof(u16), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.u16", sizeof(u16), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u16*>(buffer.data()), endian));
|
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u16*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s16", sizeof(s16), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.s16", sizeof(s16), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s16*>(buffer.data()), endian));
|
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s16*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u32", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.u32", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian));
|
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s32", sizeof(s32), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.s32", sizeof(s32), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s32*>(buffer.data()), endian));
|
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s32*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u64", sizeof(u64), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.u64", sizeof(u64), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u64*>(buffer.data()), endian));
|
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u64*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s64", sizeof(s64), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.s64", sizeof(s64), [](auto buffer, auto endian, auto style) {
|
||||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "{0:#o}");
|
||||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s64*>(buffer.data()), endian));
|
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s64*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.float", sizeof(float), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.float", sizeof(float), [](auto buffer, auto endian, auto style) {
|
||||||
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<float*>(buffer.data()), endian));
|
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<float*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.double", sizeof(double), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.double", sizeof(double), [](auto buffer, auto endian, auto style) {
|
||||||
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<float*>(buffer.data()), endian));
|
auto value = hex::format("{0:G}", hex::changeEndianess(*reinterpret_cast<float*>(buffer.data()), endian));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii", sizeof(char8_t), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii", sizeof(char8_t), [](auto buffer, auto endian, auto style) {
|
||||||
auto value = hex::format("'{0}'", makePrintable(*reinterpret_cast<char8_t*>(buffer.data())).c_str());
|
auto value = hex::format("'{0}'", makePrintable(*reinterpret_cast<char8_t*>(buffer.data())).c_str());
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(char16_t), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(char16_t), [](auto buffer, auto endian, auto style) {
|
||||||
auto c = *reinterpret_cast<char16_t*>(buffer.data());
|
auto c = *reinterpret_cast<char16_t*>(buffer.data());
|
||||||
auto value = hex::format("'{0}'", c == 0 ? '\x01' : char16_t(hex::changeEndianess(c, endian)));
|
auto value = hex::format("'{0}'", c == 0 ? '\x01' : char16_t(hex::changeEndianess(c, endian)));
|
||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) {
|
||||||
char utf8Buffer[5] = { 0 };
|
char utf8Buffer[5] = { 0 };
|
||||||
char codepointString[5] = { 0 };
|
char codepointString[5] = { 0 };
|
||||||
u32 codepoint = 0;
|
u32 codepoint = 0;
|
||||||
@ -119,7 +119,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
#if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
|
#if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(__time32_t), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(__time32_t), [](auto buffer, auto endian, auto style) {
|
||||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time32_t*>(buffer.data()), endian);
|
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time32_t*>(buffer.data()), endian);
|
||||||
struct tm *ptm = _localtime32(&endianAdjustedTime);
|
struct tm *ptm = _localtime32(&endianAdjustedTime);
|
||||||
std::string value;
|
std::string value;
|
||||||
@ -131,7 +131,7 @@ namespace hex::plugin::builtin {
|
|||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(__time64_t), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(__time64_t), [](auto buffer, auto endian, auto style) {
|
||||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time64_t*>(buffer.data()), endian);
|
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time64_t*>(buffer.data()), endian);
|
||||||
struct tm *ptm = _localtime64(&endianAdjustedTime);
|
struct tm *ptm = _localtime64(&endianAdjustedTime);
|
||||||
std::string value;
|
std::string value;
|
||||||
@ -145,7 +145,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
|
||||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<time_t*>(buffer.data()), endian);
|
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<time_t*>(buffer.data()), endian);
|
||||||
struct tm *ptm = localtime(&endianAdjustedTime);
|
struct tm *ptm = localtime(&endianAdjustedTime);
|
||||||
std::string value;
|
std::string value;
|
||||||
@ -159,7 +159,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.guid", sizeof(GUID), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.guid", sizeof(GUID), [](auto buffer, auto endian, auto style) {
|
||||||
GUID guid;
|
GUID guid;
|
||||||
std::memcpy(&guid, buffer.data(), sizeof(GUID));
|
std::memcpy(&guid, buffer.data(), sizeof(GUID));
|
||||||
auto value = hex::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
|
auto value = hex::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}",
|
||||||
@ -173,7 +173,7 @@ namespace hex::plugin::builtin {
|
|||||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||||
});
|
});
|
||||||
|
|
||||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||||
ImColor value(hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian));
|
ImColor value(hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian));
|
||||||
|
|
||||||
auto stringValue = hex::format("(0x{:02X}, 0x{:02X}, 0x{:02X}, 0x{:02X})", u8(0xFF * (value.Value.x)), u8(0xFF * (value.Value.y)), u8(0xFF * (value.Value.z)), u8(0xFF * (value.Value.w)));
|
auto stringValue = hex::format("(0x{:02X}, 0x{:02X}, 0x{:02X}, 0x{:02X})", u8(0xFF * (value.Value.x)), u8(0xFF * (value.Value.y)), u8(0xFF * (value.Value.z)), u8(0xFF * (value.Value.w)));
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
#include <hex/data_processor/node.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/crypto.hpp>
|
#include <hex/helpers/crypto.hpp>
|
||||||
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
class NodeNullptr : public dp::Node {
|
class NodeNullptr : public dp::Node {
|
||||||
@ -38,13 +44,11 @@ namespace hex::plugin::builtin {
|
|||||||
this->setBufferOnOutput(0, this->m_buffer);
|
this->setBufferOnOutput(0, this->m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["size"] = this->m_size;
|
j["size"] = this->m_size;
|
||||||
output["data"] = this->m_buffer;
|
j["data"] = this->m_buffer;
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
@ -80,12 +84,10 @@ namespace hex::plugin::builtin {
|
|||||||
this->setBufferOnOutput(0, output);
|
this->setBufferOnOutput(0, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["data"] = this->m_value;
|
j["data"] = this->m_value;
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
@ -115,12 +117,10 @@ namespace hex::plugin::builtin {
|
|||||||
this->setBufferOnOutput(0, data);
|
this->setBufferOnOutput(0, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["data"] = this->m_value;
|
j["data"] = this->m_value;
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
@ -151,12 +151,10 @@ namespace hex::plugin::builtin {
|
|||||||
this->setBufferOnOutput(0, data);
|
this->setBufferOnOutput(0, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["data"] = this->m_value;
|
j["data"] = this->m_value;
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
@ -189,16 +187,14 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["data"] = nlohmann::json::object();
|
j["data"] = nlohmann::json::object();
|
||||||
output["data"]["r"] = this->m_color.Value.x;
|
j["data"]["r"] = this->m_color.Value.x;
|
||||||
output["data"]["g"] = this->m_color.Value.y;
|
j["data"]["g"] = this->m_color.Value.y;
|
||||||
output["data"]["b"] = this->m_color.Value.z;
|
j["data"]["b"] = this->m_color.Value.z;
|
||||||
output["data"]["a"] = this->m_color.Value.w;
|
j["data"]["a"] = this->m_color.Value.w;
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
@ -223,12 +219,10 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["comment"] = this->m_comment;
|
j["comment"] = this->m_comment;
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
@ -751,15 +745,12 @@ namespace hex::plugin::builtin {
|
|||||||
this->setBufferOnOutput(4, output);
|
this->setBufferOnOutput(4, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json store() override {
|
void store(nlohmann::json &j) override {
|
||||||
auto output = nlohmann::json::object();
|
j = nlohmann::json::object();
|
||||||
|
|
||||||
output["data"] = nlohmann::json::object();
|
j["data"] = nlohmann::json::object();
|
||||||
output["data"]["mode"] = this->m_mode;
|
j["data"]["mode"] = this->m_mode;
|
||||||
output["data"]["key_length"] = this->m_keyLength;
|
j["data"]["key_length"] = this->m_keyLength;
|
||||||
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(nlohmann::json &j) override {
|
void load(nlohmann::json &j) override {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
#include <hex/lang/ast_node.hpp>
|
#include <hex/lang/ast_node.hpp>
|
||||||
#include <hex/lang/log_console.hpp>
|
#include <hex/lang/log_console.hpp>
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
#include <hex/api/imhex_api.hpp>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/net.hpp>
|
#include <hex/helpers/net.hpp>
|
||||||
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -8,6 +9,12 @@
|
|||||||
#include <llvm/Demangle/Demangle.h>
|
#include <llvm/Demangle/Demangle.h>
|
||||||
#include "math_evaluator.hpp"
|
#include "math_evaluator.hpp"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#include <imgui_internal.h>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
#include <codicons_font.h>
|
#include <codicons_font.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
|
#include <imgui_imhex_extensions.h>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ set(LIBIMHEX_SOURCES
|
|||||||
source/api/imhex_api.cpp
|
source/api/imhex_api.cpp
|
||||||
source/api/content_registry.cpp
|
source/api/content_registry.cpp
|
||||||
|
|
||||||
|
source/data_processor/attribute.cpp
|
||||||
|
source/data_processor/link.cpp
|
||||||
|
source/data_processor/node.cpp
|
||||||
|
|
||||||
source/helpers/utils.cpp
|
source/helpers/utils.cpp
|
||||||
source/helpers/shared_data.cpp
|
source/helpers/shared_data.cpp
|
||||||
source/helpers/crypto.cpp
|
source/helpers/crypto.cpp
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
#include <hex/helpers/logger.hpp>
|
#include <hex/helpers/logger.hpp>
|
||||||
using namespace hex::lang_literals;
|
using namespace hex::lang_literals;
|
||||||
|
|
||||||
|
constexpr static const auto ImHexApiURL = "https://api.werwolv.net/imhex";
|
||||||
|
constexpr static const auto GitHubApiURL = "https://api.github.com/repos/WerWolv/ImHex";
|
||||||
|
|
||||||
using u8 = std::uint8_t;
|
using u8 = std::uint8_t;
|
||||||
using u16 = std::uint16_t;
|
using u16 = std::uint16_t;
|
||||||
using u32 = std::uint32_t;
|
using u32 = std::uint32_t;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <hex.hpp>
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace hex::dp {
|
namespace hex::dp {
|
||||||
|
|
||||||
@ -16,14 +19,8 @@ namespace hex::dp {
|
|||||||
In, Out
|
In, Out
|
||||||
};
|
};
|
||||||
|
|
||||||
Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorAttrIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) {
|
Attribute(IOType ioType, Type type, std::string_view unlocalizedName);
|
||||||
|
~Attribute();
|
||||||
}
|
|
||||||
|
|
||||||
~Attribute() {
|
|
||||||
for (auto &[linkId, attr] : this->getConnectedAttributes())
|
|
||||||
attr->removeConnectedAttribute(linkId);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] u32 getID() const { return this->m_id; }
|
[[nodiscard]] u32 getID() const { return this->m_id; }
|
||||||
void setID(u32 id) { this->m_id = id; }
|
void setID(u32 id) { this->m_id = id; }
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <hex.hpp>
|
||||||
|
|
||||||
namespace hex::dp {
|
namespace hex::dp {
|
||||||
|
|
||||||
class Link {
|
class Link {
|
||||||
public:
|
public:
|
||||||
Link(u32 from, u32 to) : m_id(SharedData::dataProcessorLinkIdCounter++), m_from(from), m_to(to) { }
|
Link(u32 from, u32 to);
|
||||||
|
|
||||||
[[nodiscard]] u32 getID() const { return this->m_id; }
|
[[nodiscard]] u32 getID() const { return this->m_id; }
|
||||||
void setID(u32 id) { this->m_id = id; }
|
void setID(u32 id) { this->m_id = id; }
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <hex.hpp>
|
||||||
|
|
||||||
#include <hex/data_processor/attribute.hpp>
|
#include <hex/data_processor/attribute.hpp>
|
||||||
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
|
namespace hex::prv { class Provider; class Overlay; }
|
||||||
|
|
||||||
namespace hex::dp {
|
namespace hex::dp {
|
||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
public:
|
public:
|
||||||
Node(std::string_view unlocalizedTitle, std::vector<Attribute> attributes) : m_id(SharedData::dataProcessorNodeIdCounter++), m_unlocalizedTitle(unlocalizedTitle), m_attributes(std::move(attributes)) {
|
Node(std::string_view unlocalizedTitle, std::vector<Attribute> attributes);
|
||||||
for (auto &attr : this->m_attributes)
|
|
||||||
attr.setParentNode(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~Node() = default;
|
virtual ~Node() = default;
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ namespace hex::dp {
|
|||||||
virtual void drawNode() { }
|
virtual void drawNode() { }
|
||||||
virtual void process() = 0;
|
virtual void process() = 0;
|
||||||
|
|
||||||
virtual nlohmann::json store() { return nullptr; }
|
virtual void store(nlohmann::json &j) { }
|
||||||
virtual void load(nlohmann::json &j) { }
|
virtual void load(nlohmann::json &j) { }
|
||||||
|
|
||||||
using NodeError = std::pair<Node*, std::string>;
|
using NodeError = std::pair<Node*, std::string>;
|
||||||
@ -79,121 +81,15 @@ namespace hex::dp {
|
|||||||
throw NodeError(this, message);
|
throw NodeError(this, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> getBufferOnInput(u32 index) {
|
std::vector<u8> getBufferOnInput(u32 index);
|
||||||
auto attribute = this->getConnectedInputAttribute(index);
|
u64 getIntegerOnInput(u32 index);
|
||||||
|
float getFloatOnInput(u32 index);
|
||||||
|
|
||||||
if (attribute == nullptr)
|
void setBufferOnOutput(u32 index, std::vector<u8> data);
|
||||||
throwNodeError(hex::format("Nothing connected to input '{0}'", static_cast<const char*>(LangEntry(this->m_attributes[index].getUnlocalizedName()))));
|
void setIntegerOnOutput(u32 index, u64 integer);
|
||||||
|
void setFloatOnOutput(u32 index, float floatingPoint);
|
||||||
|
|
||||||
if (attribute->getType() != Attribute::Type::Buffer)
|
void setOverlayData(u64 address, const std::vector<u8> &data);
|
||||||
throwNodeError("Tried to read buffer from non-buffer attribute");
|
|
||||||
|
|
||||||
markInputProcessed(index);
|
|
||||||
attribute->getParentNode()->process();
|
|
||||||
|
|
||||||
auto &outputData = attribute->getOutputData();
|
|
||||||
|
|
||||||
if (!outputData.has_value())
|
|
||||||
throw std::runtime_error("No data available at connected attribute");
|
|
||||||
|
|
||||||
return outputData.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 getIntegerOnInput(u32 index) {
|
|
||||||
auto attribute = this->getConnectedInputAttribute(index);
|
|
||||||
|
|
||||||
if (attribute == nullptr)
|
|
||||||
throwNodeError(hex::format("Nothing connected to input '{0}'", static_cast<const char*>(LangEntry(this->m_attributes[index].getUnlocalizedName()))));
|
|
||||||
|
|
||||||
if (attribute->getType() != Attribute::Type::Integer)
|
|
||||||
throwNodeError("Tried to read integer from non-integer attribute");
|
|
||||||
|
|
||||||
markInputProcessed(index);
|
|
||||||
attribute->getParentNode()->process();
|
|
||||||
|
|
||||||
auto &outputData = attribute->getOutputData();
|
|
||||||
|
|
||||||
if (!outputData.has_value())
|
|
||||||
throw std::runtime_error("No data available at connected attribute");
|
|
||||||
|
|
||||||
if (outputData->size() < sizeof(u64))
|
|
||||||
throw std::runtime_error("Not enough data provided for integer");
|
|
||||||
|
|
||||||
return *reinterpret_cast<u64*>(outputData->data());
|
|
||||||
}
|
|
||||||
|
|
||||||
float getFloatOnInput(u32 index) {
|
|
||||||
auto attribute = this->getConnectedInputAttribute(index);
|
|
||||||
|
|
||||||
if (attribute == nullptr)
|
|
||||||
throwNodeError(hex::format("Nothing connected to input '{0}'", static_cast<const char*>(LangEntry(this->m_attributes[index].getUnlocalizedName()))));
|
|
||||||
|
|
||||||
if (attribute->getType() != Attribute::Type::Float)
|
|
||||||
throwNodeError("Tried to read float from non-float attribute");
|
|
||||||
|
|
||||||
markInputProcessed(index);
|
|
||||||
attribute->getParentNode()->process();
|
|
||||||
|
|
||||||
auto &outputData = attribute->getOutputData();
|
|
||||||
|
|
||||||
if (!outputData.has_value())
|
|
||||||
throw std::runtime_error("No data available at connected attribute");
|
|
||||||
|
|
||||||
if (outputData->size() < sizeof(float))
|
|
||||||
throw std::runtime_error("Not enough data provided for float");
|
|
||||||
|
|
||||||
return *reinterpret_cast<float*>(outputData->data());
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBufferOnOutput(u32 index, std::vector<u8> data) {
|
|
||||||
if (index >= this->getAttributes().size())
|
|
||||||
throw std::runtime_error("Attribute index out of bounds!");
|
|
||||||
|
|
||||||
auto &attribute = this->getAttributes()[index];
|
|
||||||
|
|
||||||
if (attribute.getIOType() != Attribute::IOType::Out)
|
|
||||||
throw std::runtime_error("Tried to set output data of an input attribute!");
|
|
||||||
|
|
||||||
attribute.getOutputData() = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIntegerOnOutput(u32 index, u64 integer) {
|
|
||||||
if (index >= this->getAttributes().size())
|
|
||||||
throw std::runtime_error("Attribute index out of bounds!");
|
|
||||||
|
|
||||||
auto &attribute = this->getAttributes()[index];
|
|
||||||
|
|
||||||
if (attribute.getIOType() != Attribute::IOType::Out)
|
|
||||||
throw std::runtime_error("Tried to set output data of an input attribute!");
|
|
||||||
|
|
||||||
std::vector<u8> buffer(sizeof(u64), 0);
|
|
||||||
std::memcpy(buffer.data(), &integer, sizeof(u64));
|
|
||||||
|
|
||||||
attribute.getOutputData() = buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFloatOnOutput(u32 index, float floatingPoint) {
|
|
||||||
if (index >= this->getAttributes().size())
|
|
||||||
throw std::runtime_error("Attribute index out of bounds!");
|
|
||||||
|
|
||||||
auto &attribute = this->getAttributes()[index];
|
|
||||||
|
|
||||||
if (attribute.getIOType() != Attribute::IOType::Out)
|
|
||||||
throw std::runtime_error("Tried to set output data of an input attribute!");
|
|
||||||
|
|
||||||
std::vector<u8> buffer(sizeof(float), 0);
|
|
||||||
std::memcpy(buffer.data(), &floatingPoint, sizeof(float));
|
|
||||||
|
|
||||||
attribute.getOutputData() = buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOverlayData(u64 address, const std::vector<u8> &data) {
|
|
||||||
if (this->m_overlay == nullptr)
|
|
||||||
throw std::runtime_error("Tried setting overlay data on a node that's not the end of a chain!");
|
|
||||||
|
|
||||||
this->m_overlay->setAddress(address);
|
|
||||||
this->m_overlay->getData() = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
namespace hex { class SharedData; }
|
namespace hex { class SharedData; }
|
||||||
|
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
#include <hex/api/imhex_api.hpp>
|
|
||||||
#include <hex/api/content_registry.hpp>
|
|
||||||
#include <hex/views/view.hpp>
|
|
||||||
#include <hex/providers/provider.hpp>
|
|
||||||
#include <hex/helpers/shared_data.hpp>
|
|
||||||
#include <hex/data_processor/node.hpp>
|
|
||||||
|
|
||||||
#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(IMHEX_PLUGIN_NAME, name, author, description)
|
#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(IMHEX_PLUGIN_NAME, name, author, description)
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
|
16
plugins/libimhex/source/data_processor/attribute.cpp
Normal file
16
plugins/libimhex/source/data_processor/attribute.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <hex/data_processor/attribute.hpp>
|
||||||
|
|
||||||
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
|
namespace hex::dp {
|
||||||
|
|
||||||
|
Attribute::Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorAttrIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Attribute::~Attribute() {
|
||||||
|
for (auto &[linkId, attr] : this->getConnectedAttributes())
|
||||||
|
attr->removeConnectedAttribute(linkId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
plugins/libimhex/source/data_processor/link.cpp
Normal file
10
plugins/libimhex/source/data_processor/link.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <hex/data_processor/link.hpp>
|
||||||
|
|
||||||
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
|
namespace hex::dp {
|
||||||
|
|
||||||
|
Link::Link(u32 from, u32 to) : m_id(SharedData::dataProcessorLinkIdCounter++), m_from(from), m_to(to) { }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
128
plugins/libimhex/source/data_processor/node.cpp
Normal file
128
plugins/libimhex/source/data_processor/node.cpp
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
#include <hex/data_processor/node.hpp>
|
||||||
|
|
||||||
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
|
namespace hex::dp {
|
||||||
|
|
||||||
|
Node::Node(std::string_view unlocalizedTitle, std::vector<Attribute> attributes) : m_id(SharedData::dataProcessorNodeIdCounter++), m_unlocalizedTitle(unlocalizedTitle), m_attributes(std::move(attributes)) {
|
||||||
|
for (auto &attr : this->m_attributes)
|
||||||
|
attr.setParentNode(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<u8> Node::getBufferOnInput(u32 index) {
|
||||||
|
auto attribute = this->getConnectedInputAttribute(index);
|
||||||
|
|
||||||
|
if (attribute == nullptr)
|
||||||
|
throwNodeError(hex::format("Nothing connected to input '{0}'", static_cast<const char*>(LangEntry(this->m_attributes[index].getUnlocalizedName()))));
|
||||||
|
|
||||||
|
if (attribute->getType() != Attribute::Type::Buffer)
|
||||||
|
throwNodeError("Tried to read buffer from non-buffer attribute");
|
||||||
|
|
||||||
|
markInputProcessed(index);
|
||||||
|
attribute->getParentNode()->process();
|
||||||
|
|
||||||
|
auto &outputData = attribute->getOutputData();
|
||||||
|
|
||||||
|
if (!outputData.has_value())
|
||||||
|
throw std::runtime_error("No data available at connected attribute");
|
||||||
|
|
||||||
|
return outputData.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 Node::getIntegerOnInput(u32 index) {
|
||||||
|
auto attribute = this->getConnectedInputAttribute(index);
|
||||||
|
|
||||||
|
if (attribute == nullptr)
|
||||||
|
throwNodeError(hex::format("Nothing connected to input '{0}'", static_cast<const char*>(LangEntry(this->m_attributes[index].getUnlocalizedName()))));
|
||||||
|
|
||||||
|
if (attribute->getType() != Attribute::Type::Integer)
|
||||||
|
throwNodeError("Tried to read integer from non-integer attribute");
|
||||||
|
|
||||||
|
markInputProcessed(index);
|
||||||
|
attribute->getParentNode()->process();
|
||||||
|
|
||||||
|
auto &outputData = attribute->getOutputData();
|
||||||
|
|
||||||
|
if (!outputData.has_value())
|
||||||
|
throw std::runtime_error("No data available at connected attribute");
|
||||||
|
|
||||||
|
if (outputData->size() < sizeof(u64))
|
||||||
|
throw std::runtime_error("Not enough data provided for integer");
|
||||||
|
|
||||||
|
return *reinterpret_cast<u64*>(outputData->data());
|
||||||
|
}
|
||||||
|
|
||||||
|
float Node::getFloatOnInput(u32 index) {
|
||||||
|
auto attribute = this->getConnectedInputAttribute(index);
|
||||||
|
|
||||||
|
if (attribute == nullptr)
|
||||||
|
throwNodeError(hex::format("Nothing connected to input '{0}'", static_cast<const char*>(LangEntry(this->m_attributes[index].getUnlocalizedName()))));
|
||||||
|
|
||||||
|
if (attribute->getType() != Attribute::Type::Float)
|
||||||
|
throwNodeError("Tried to read float from non-float attribute");
|
||||||
|
|
||||||
|
markInputProcessed(index);
|
||||||
|
attribute->getParentNode()->process();
|
||||||
|
|
||||||
|
auto &outputData = attribute->getOutputData();
|
||||||
|
|
||||||
|
if (!outputData.has_value())
|
||||||
|
throw std::runtime_error("No data available at connected attribute");
|
||||||
|
|
||||||
|
if (outputData->size() < sizeof(float))
|
||||||
|
throw std::runtime_error("Not enough data provided for float");
|
||||||
|
|
||||||
|
return *reinterpret_cast<float*>(outputData->data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setBufferOnOutput(u32 index, std::vector<u8> data) {
|
||||||
|
if (index >= this->getAttributes().size())
|
||||||
|
throw std::runtime_error("Attribute index out of bounds!");
|
||||||
|
|
||||||
|
auto &attribute = this->getAttributes()[index];
|
||||||
|
|
||||||
|
if (attribute.getIOType() != Attribute::IOType::Out)
|
||||||
|
throw std::runtime_error("Tried to set output data of an input attribute!");
|
||||||
|
|
||||||
|
attribute.getOutputData() = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setIntegerOnOutput(u32 index, u64 integer) {
|
||||||
|
if (index >= this->getAttributes().size())
|
||||||
|
throw std::runtime_error("Attribute index out of bounds!");
|
||||||
|
|
||||||
|
auto &attribute = this->getAttributes()[index];
|
||||||
|
|
||||||
|
if (attribute.getIOType() != Attribute::IOType::Out)
|
||||||
|
throw std::runtime_error("Tried to set output data of an input attribute!");
|
||||||
|
|
||||||
|
std::vector<u8> buffer(sizeof(u64), 0);
|
||||||
|
std::memcpy(buffer.data(), &integer, sizeof(u64));
|
||||||
|
|
||||||
|
attribute.getOutputData() = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setFloatOnOutput(u32 index, float floatingPoint) {
|
||||||
|
if (index >= this->getAttributes().size())
|
||||||
|
throw std::runtime_error("Attribute index out of bounds!");
|
||||||
|
|
||||||
|
auto &attribute = this->getAttributes()[index];
|
||||||
|
|
||||||
|
if (attribute.getIOType() != Attribute::IOType::Out)
|
||||||
|
throw std::runtime_error("Tried to set output data of an input attribute!");
|
||||||
|
|
||||||
|
std::vector<u8> buffer(sizeof(float), 0);
|
||||||
|
std::memcpy(buffer.data(), &floatingPoint, sizeof(float));
|
||||||
|
|
||||||
|
attribute.getOutputData() = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setOverlayData(u64 address, const std::vector<u8> &data) {
|
||||||
|
if (this->m_overlay == nullptr)
|
||||||
|
throw std::runtime_error("Tried setting overlay data on a node that's not the end of a chain!");
|
||||||
|
|
||||||
|
this->m_overlay->setAddress(address);
|
||||||
|
this->m_overlay->getData() = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,8 @@
|
|||||||
#include <mbedtls/ssl.h>
|
#include <mbedtls/ssl.h>
|
||||||
#include <mbedtls/error.h>
|
#include <mbedtls/error.h>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <hex/resources.hpp>
|
#include <hex/resources.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include <hex/helpers/shared_data.hpp>
|
#include <hex/helpers/shared_data.hpp>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
std::vector<std::function<void()>> SharedData::deferredCalls;
|
std::vector<std::function<void()>> SharedData::deferredCalls;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <imgui_imhex_extensions.h>
|
||||||
|
#include <fontawesome_font.h>
|
||||||
|
|
||||||
namespace hex::plugin::windows {
|
namespace hex::plugin::windows {
|
||||||
|
|
||||||
static ULONGLONG subtractTimes(const FILETIME &left, const FILETIME &right) {
|
static ULONGLONG subtractTimes(const FILETIME &left, const FILETIME &right) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::windows {
|
namespace hex::plugin::windows {
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#include <hex/plugin.hpp>
|
#include <hex/plugin.hpp>
|
||||||
#include <imgui.h>
|
|
||||||
#include <imgui_internal.h>
|
|
||||||
|
|
||||||
#include "views/view_tty_console.hpp"
|
#include "views/view_tty_console.hpp"
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <future>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <future>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
|
@ -26,12 +26,16 @@
|
|||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex::init {
|
namespace hex::init {
|
||||||
|
|
||||||
|
using namespace std::literals::string_literals;
|
||||||
|
|
||||||
static bool checkForUpdates() {
|
static bool checkForUpdates() {
|
||||||
hex::Net net;
|
hex::Net net;
|
||||||
|
|
||||||
auto releases = net.getJson("https://api.github.com/repos/WerWolv/ImHex/releases/latest").get();
|
auto releases = net.getJson(GitHubApiURL + "/releases/latest"s).get();
|
||||||
if (releases.code != 200)
|
if (releases.code != 200)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -50,7 +54,7 @@ namespace hex::init {
|
|||||||
static bool downloadInformation() {
|
static bool downloadInformation() {
|
||||||
hex::Net net;
|
hex::Net net;
|
||||||
|
|
||||||
auto tip = net.getString("https://api.werwolv.net/imhex/tip").get();
|
auto tip = net.getString(ImHexApiURL + "/tip"s).get();
|
||||||
if (tip.code != 200)
|
if (tip.code != 200)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -388,7 +388,9 @@ namespace hex {
|
|||||||
currNodeOutput["attrs"] = json::array();
|
currNodeOutput["attrs"] = json::array();
|
||||||
currNodeOutput["id"] = id;
|
currNodeOutput["id"] = id;
|
||||||
|
|
||||||
currNodeOutput["data"] = node->store();
|
json nodeData;
|
||||||
|
node->store(nodeData);
|
||||||
|
currNodeOutput["data"] = nodeData;
|
||||||
|
|
||||||
u32 attrIndex = 0;
|
u32 attrIndex = 0;
|
||||||
for (auto &attr : node->getAttributes()) {
|
for (auto &attr : node->getAttributes()) {
|
||||||
|
@ -4,13 +4,15 @@
|
|||||||
#include <hex/api/imhex_api.hpp>
|
#include <hex/api/imhex_api.hpp>
|
||||||
#include <hex/helpers/crypto.hpp>
|
#include <hex/helpers/crypto.hpp>
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
#include "providers/file_provider.hpp"
|
#include "providers/file_provider.hpp"
|
||||||
#include "helpers/patches.hpp"
|
#include "helpers/patches.hpp"
|
||||||
#include "helpers/project_file_handler.hpp"
|
#include "helpers/project_file_handler.hpp"
|
||||||
#include "helpers/loader_script_handler.hpp"
|
#include "helpers/loader_script_handler.hpp"
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#undef __STRICT_ANSI__
|
#undef __STRICT_ANSI__
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <numeric>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <imgui_imhex_extensions.h>
|
#include <imgui_imhex_extensions.h>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
static const TextEditor::LanguageDefinition& PatternLanguage() {
|
static const TextEditor::LanguageDefinition& PatternLanguage() {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <hex/api/content_registry.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
ViewSettings::ViewSettings() : View("hex.view.settings.name") {
|
ViewSettings::ViewSettings() : View("hex.view.settings.name") {
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user